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.
     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 TInt Function() const = 0;
    35 		virtual void Complete(TInt aReason) const = 0;	
    36 		virtual void Panic(const TDesC& aCategory, TInt aReason) const = 0;
    37 	public:
    38 		virtual TInt Int0() const = 0;
    39 		virtual TInt Int1() const = 0;
    40 		virtual TInt Int2() const = 0;
    41 		virtual TInt Int3() const = 0;
    42 	public:
    43 		virtual TInt GetDesLengthL(TInt aParam) const = 0;
    44 		virtual TInt GetDesMaxLength(TInt aParam) const = 0;
    45 		virtual void ReadL(TInt aParam, TDes8& aDes, TInt aOffset=0) const = 0;
    46 		virtual void ReadL(TInt aParam, TDes& aDes,  TInt aOffset=0) const = 0;
    47 		virtual void Read(TInt aParam, TDes8& aDes, TInt aOffset=0) const = 0;
    48 		virtual void Read(TInt aParam, TDes& aDes,  TInt aOffset=0) const = 0;
    49 		virtual TInt Write(TInt aParam, const TDesC8& aDes, TInt aOffset=0) const = 0;
    50 		virtual void WriteL(TInt aParam, const TDesC8& aDes) const = 0;
    51 		virtual void WriteL(TInt aParam, const TDesC& aDes, TInt aOffset=0) const = 0;
    52 		virtual TBool CheckPolicy(const TSecurityPolicy& aSecurityPolicy,const char *aDiagnostic) const =0;
    53 	};
    54 
    55 ///////////////////////////////////////////////////////////////////////////////
    56 ///////////////////////////////////////////////////////////////////////////////
    57 
    58 # ifndef CENTRAL_REPOSITORY_SERVER_TESTING
    59 ///////////////////////////////////////////////////////////////////////////////
    60 // TClientRequest
    61 ///////////////////////////////////////////////////////////////////////////////
    62 // Concrete implementation of MClientRequest that acts as an adaptor for
    63 // RMessage.
    64 ///////////////////////////////////////////////////////////////////////////////
    65 class TClientRequest : public MClientRequest
    66 /**
    67 @internalComponent
    68 */
    69 	{
    70 	public:
    71 		TClientRequest() {}
    72 		TClientRequest(const RMessage2&);
    73 		virtual TInt Function() const;
    74 		virtual void Complete(TInt aReason) const;
    75 		virtual void Panic(const TDesC& aCategory, TInt aReason) const;
    76 		virtual TInt Int0() const;
    77 		virtual TInt Int1() const;
    78 		virtual TInt Int2() const;
    79 		virtual TInt Int3() const;
    80 		virtual TInt GetDesLengthL(TInt aParam) const;
    81 		virtual TInt GetDesMaxLength(TInt aParam) const;
    82 		virtual void ReadL(TInt aParam, TDes8& aDes, TInt aOffset=0) const;
    83 		virtual void ReadL(TInt aParam, TDes& aDes,  TInt aOffset=0) const;
    84 		virtual void Read(TInt aParam, TDes8& aDes, TInt aOffset=0) const;
    85 		virtual void Read(TInt aParam, TDes& aDes,  TInt aOffset=0) const;
    86 		virtual TInt Write(TInt aParam, const TDesC8& aDes, TInt aOffset=0) const;
    87 		virtual void WriteL(TInt aParam, const TDesC8& aDes) const;
    88 		virtual void WriteL(TInt aParam, const TDesC& aDes, TInt aOffset=0) const;
    89 		virtual TBool CheckPolicy(const TSecurityPolicy& aSecurityPolicy,const char *aDiagnostic) const;
    90 	private:
    91 		RMessage2 iMessage;
    92 	};
    93 
    94 ///////////////////////////////////////////////////////////////////////////////
    95 ///////////////////////////////////////////////////////////////////////////////
    96 # else //_UNIT_TESTING_
    97 ///////////////////////////////////////////////////////////////////////////////
    98 // TClientRequest
    99 ///////////////////////////////////////////////////////////////////////////////
   100 // Unit test version.
   101 ///////////////////////////////////////////////////////////////////////////////
   102 class TClientRequest : public MClientRequest
   103 /**
   104 @internalComponent
   105 */
   106 	{
   107 	public:
   108 		TClientRequest();
   109 		TClientRequest(const RMessage2&) {}; // Needed for compilation, but not used in testing.
   110 		virtual TInt Function() const;
   111 		virtual void Complete(TInt aReason) const;
   112 		virtual void Panic(const TDesC& aCategory, TInt aReason) const;
   113 		virtual TInt Int0() const;
   114 		virtual TInt Int1() const;
   115 		virtual TInt Int2() const;
   116 		virtual TInt Int3() const;
   117 		virtual TInt GetDesLengthL(TInt aParam) const;
   118 		virtual TInt GetDesMaxLength(TInt aParam) const;
   119 		virtual void ReadL(TInt aParam, TDes8& aDes, TInt aOffset=0) const;
   120 		virtual void ReadL(TInt aParam, TDes& aDes, TInt aOffset=0) const;
   121 		virtual void Read(TInt aParam, TDes8& aDes, TInt aOffset=0) const;
   122 		virtual void Read(TInt aParam, TDes& aDes,  TInt aOffset=0) const;
   123 		virtual TInt Write(TInt aParam, const TDesC8& aDes, TInt aOffset=0) const;
   124 		virtual void WriteL(TInt aParam, const TDesC8& aDes) const;
   125 		virtual void WriteL(TInt aParam, const TDesC& aDes, TInt aOffset=0) const;
   126 		virtual TBool CheckPolicy(const TSecurityPolicy& aSecurityPolicy,const char *aDiagnostic) const;
   127 	public://debug only
   128 		inline void SetParam(TInt aParam, TInt aValue);
   129 		inline void SetParam(TInt aParam, TDes8* aValue);
   130 		inline void SetPolicyCheck(TBool aPolicyCheck);
   131 		inline TInt CompletionCode() const;
   132 		
   133 	private:
   134 		TInt iFunction;
   135 		TUint32 iCapability;
   136 		mutable TInt iCompletion;
   137 		TInt iParams[KMaxMessageArguments];
   138 		mutable TRequestStatus* iStatus;
   139 		TBool iStatusActive;
   140 		TUid iIdentity;
   141 		TBool iPolicyCheck;
   142 	};
   143 
   144 ///////////////////////////////////////////////////////////////////////////////
   145 inline void TClientRequest::SetParam(TInt aParam, TInt aValue) { iParams[aParam] = aValue; }
   146 inline void TClientRequest::SetParam(TInt aParam, TDes8* aValue) { iParams[aParam] = TInt(aValue); }
   147 inline void TClientRequest::SetPolicyCheck(TBool aPolicyCheck) {iPolicyCheck=aPolicyCheck;}
   148 
   149 ///////////////////////////////////////////////////////////////////////////////
   150 ///////////////////////////////////////////////////////////////////////////////
   151 #endif //CENTRAL_REPOSITORY_SERVER_TESTING
   152 
   153 ///////////////////////////////////////////////////////////////////////////////
   154 ///////////////////////////////////////////////////////////////////////////////
   155 ///////////////////////////////////////////////////////////////////////////////
   156 #endif //__CLIENTREQUEST_H__