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