os/persistentdata/persistentstorage/centralrepository/cenrepsrv/clientrequest.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#ifndef __CLIENTREQUEST_H__
sl@0
    17
#define __CLIENTREQUEST_H__
sl@0
    18
sl@0
    19
#include <e32std.h>
sl@0
    20
sl@0
    21
///////////////////////////////////////////////////////////////////////////////
sl@0
    22
// MClientRequest
sl@0
    23
///////////////////////////////////////////////////////////////////////////////
sl@0
    24
// Provides an interface identical to RMessage2.
sl@0
    25
// This facilitiates unit testing of the session by enabling RMessage2 to be
sl@0
    26
// replaced in unit test code.
sl@0
    27
///////////////////////////////////////////////////////////////////////////////
sl@0
    28
class MClientRequest
sl@0
    29
/**
sl@0
    30
@internalComponent
sl@0
    31
*/
sl@0
    32
	{
sl@0
    33
	public:
sl@0
    34
		virtual TInt Function() const = 0;
sl@0
    35
		virtual void Complete(TInt aReason) const = 0;	
sl@0
    36
		virtual void Panic(const TDesC& aCategory, TInt aReason) const = 0;
sl@0
    37
	public:
sl@0
    38
		virtual TInt Int0() const = 0;
sl@0
    39
		virtual TInt Int1() const = 0;
sl@0
    40
		virtual TInt Int2() const = 0;
sl@0
    41
		virtual TInt Int3() const = 0;
sl@0
    42
	public:
sl@0
    43
		virtual TInt GetDesLengthL(TInt aParam) const = 0;
sl@0
    44
		virtual TInt GetDesMaxLength(TInt aParam) const = 0;
sl@0
    45
		virtual void ReadL(TInt aParam, TDes8& aDes, TInt aOffset=0) const = 0;
sl@0
    46
		virtual void ReadL(TInt aParam, TDes& aDes,  TInt aOffset=0) const = 0;
sl@0
    47
		virtual void Read(TInt aParam, TDes8& aDes, TInt aOffset=0) const = 0;
sl@0
    48
		virtual void Read(TInt aParam, TDes& aDes,  TInt aOffset=0) const = 0;
sl@0
    49
		virtual TInt Write(TInt aParam, const TDesC8& aDes, TInt aOffset=0) const = 0;
sl@0
    50
		virtual void WriteL(TInt aParam, const TDesC8& aDes) const = 0;
sl@0
    51
		virtual void WriteL(TInt aParam, const TDesC& aDes, TInt aOffset=0) const = 0;
sl@0
    52
		virtual TBool CheckPolicy(const TSecurityPolicy& aSecurityPolicy,const char *aDiagnostic) const =0;
sl@0
    53
	};
sl@0
    54
sl@0
    55
///////////////////////////////////////////////////////////////////////////////
sl@0
    56
///////////////////////////////////////////////////////////////////////////////
sl@0
    57
sl@0
    58
# ifndef CENTRAL_REPOSITORY_SERVER_TESTING
sl@0
    59
///////////////////////////////////////////////////////////////////////////////
sl@0
    60
// TClientRequest
sl@0
    61
///////////////////////////////////////////////////////////////////////////////
sl@0
    62
// Concrete implementation of MClientRequest that acts as an adaptor for
sl@0
    63
// RMessage.
sl@0
    64
///////////////////////////////////////////////////////////////////////////////
sl@0
    65
class TClientRequest : public MClientRequest
sl@0
    66
/**
sl@0
    67
@internalComponent
sl@0
    68
*/
sl@0
    69
	{
sl@0
    70
	public:
sl@0
    71
		TClientRequest() {}
sl@0
    72
		TClientRequest(const RMessage2&);
sl@0
    73
		virtual TInt Function() const;
sl@0
    74
		virtual void Complete(TInt aReason) const;
sl@0
    75
		virtual void Panic(const TDesC& aCategory, TInt aReason) const;
sl@0
    76
		virtual TInt Int0() const;
sl@0
    77
		virtual TInt Int1() const;
sl@0
    78
		virtual TInt Int2() const;
sl@0
    79
		virtual TInt Int3() const;
sl@0
    80
		virtual TInt GetDesLengthL(TInt aParam) const;
sl@0
    81
		virtual TInt GetDesMaxLength(TInt aParam) const;
sl@0
    82
		virtual void ReadL(TInt aParam, TDes8& aDes, TInt aOffset=0) const;
sl@0
    83
		virtual void ReadL(TInt aParam, TDes& aDes,  TInt aOffset=0) const;
sl@0
    84
		virtual void Read(TInt aParam, TDes8& aDes, TInt aOffset=0) const;
sl@0
    85
		virtual void Read(TInt aParam, TDes& aDes,  TInt aOffset=0) const;
sl@0
    86
		virtual TInt Write(TInt aParam, const TDesC8& aDes, TInt aOffset=0) const;
sl@0
    87
		virtual void WriteL(TInt aParam, const TDesC8& aDes) const;
sl@0
    88
		virtual void WriteL(TInt aParam, const TDesC& aDes, TInt aOffset=0) const;
sl@0
    89
		virtual TBool CheckPolicy(const TSecurityPolicy& aSecurityPolicy,const char *aDiagnostic) const;
sl@0
    90
	private:
sl@0
    91
		RMessage2 iMessage;
sl@0
    92
	};
sl@0
    93
sl@0
    94
///////////////////////////////////////////////////////////////////////////////
sl@0
    95
///////////////////////////////////////////////////////////////////////////////
sl@0
    96
# else //_UNIT_TESTING_
sl@0
    97
///////////////////////////////////////////////////////////////////////////////
sl@0
    98
// TClientRequest
sl@0
    99
///////////////////////////////////////////////////////////////////////////////
sl@0
   100
// Unit test version.
sl@0
   101
///////////////////////////////////////////////////////////////////////////////
sl@0
   102
class TClientRequest : public MClientRequest
sl@0
   103
/**
sl@0
   104
@internalComponent
sl@0
   105
*/
sl@0
   106
	{
sl@0
   107
	public:
sl@0
   108
		TClientRequest();
sl@0
   109
		TClientRequest(const RMessage2&) {}; // Needed for compilation, but not used in testing.
sl@0
   110
		virtual TInt Function() const;
sl@0
   111
		virtual void Complete(TInt aReason) const;
sl@0
   112
		virtual void Panic(const TDesC& aCategory, TInt aReason) const;
sl@0
   113
		virtual TInt Int0() const;
sl@0
   114
		virtual TInt Int1() const;
sl@0
   115
		virtual TInt Int2() const;
sl@0
   116
		virtual TInt Int3() const;
sl@0
   117
		virtual TInt GetDesLengthL(TInt aParam) const;
sl@0
   118
		virtual TInt GetDesMaxLength(TInt aParam) const;
sl@0
   119
		virtual void ReadL(TInt aParam, TDes8& aDes, TInt aOffset=0) const;
sl@0
   120
		virtual void ReadL(TInt aParam, TDes& aDes, TInt aOffset=0) const;
sl@0
   121
		virtual void Read(TInt aParam, TDes8& aDes, TInt aOffset=0) const;
sl@0
   122
		virtual void Read(TInt aParam, TDes& aDes,  TInt aOffset=0) const;
sl@0
   123
		virtual TInt Write(TInt aParam, const TDesC8& aDes, TInt aOffset=0) const;
sl@0
   124
		virtual void WriteL(TInt aParam, const TDesC8& aDes) const;
sl@0
   125
		virtual void WriteL(TInt aParam, const TDesC& aDes, TInt aOffset=0) const;
sl@0
   126
		virtual TBool CheckPolicy(const TSecurityPolicy& aSecurityPolicy,const char *aDiagnostic) const;
sl@0
   127
	public://debug only
sl@0
   128
		inline void SetParam(TInt aParam, TInt aValue);
sl@0
   129
		inline void SetParam(TInt aParam, TDes8* aValue);
sl@0
   130
		inline void SetPolicyCheck(TBool aPolicyCheck);
sl@0
   131
		inline TInt CompletionCode() const;
sl@0
   132
		
sl@0
   133
	private:
sl@0
   134
		TInt iFunction;
sl@0
   135
		TUint32 iCapability;
sl@0
   136
		mutable TInt iCompletion;
sl@0
   137
		TInt iParams[KMaxMessageArguments];
sl@0
   138
		mutable TRequestStatus* iStatus;
sl@0
   139
		TBool iStatusActive;
sl@0
   140
		TUid iIdentity;
sl@0
   141
		TBool iPolicyCheck;
sl@0
   142
	};
sl@0
   143
sl@0
   144
///////////////////////////////////////////////////////////////////////////////
sl@0
   145
inline void TClientRequest::SetParam(TInt aParam, TInt aValue) { iParams[aParam] = aValue; }
sl@0
   146
inline void TClientRequest::SetParam(TInt aParam, TDes8* aValue) { iParams[aParam] = TInt(aValue); }
sl@0
   147
inline void TClientRequest::SetPolicyCheck(TBool aPolicyCheck) {iPolicyCheck=aPolicyCheck;}
sl@0
   148
sl@0
   149
///////////////////////////////////////////////////////////////////////////////
sl@0
   150
///////////////////////////////////////////////////////////////////////////////
sl@0
   151
#endif //CENTRAL_REPOSITORY_SERVER_TESTING
sl@0
   152
sl@0
   153
///////////////////////////////////////////////////////////////////////////////
sl@0
   154
///////////////////////////////////////////////////////////////////////////////
sl@0
   155
///////////////////////////////////////////////////////////////////////////////
sl@0
   156
#endif //__CLIENTREQUEST_H__