os/ossrv/lowlevellibsandfws/pluginfw/Framework/frame/clientrequest.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2003-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 #include <ecom/implementationinformation.h>
    22 //
    23 // MClientRequest
    24 //
    25 // Provides an interface identical to RMessage.
    26 // This facilitiates unit testing of the session by enabling RMessage to be
    27 // replaced in unit test code.
    28 //
    29 
    30 class MClientRequest
    31 /**
    32 @internalComponent
    33 */
    34 	{
    35 	public:
    36 	
    37 		virtual TBool IsNull() const = 0;
    38 	
    39 		virtual TInt Function() const = 0;
    40 	
    41 		virtual void Complete(TInt aReason) const = 0;	
    42 	
    43 		virtual void Panic(const TDesC& aCategory, TInt aReason) const = 0;
    44 	public:
    45 	
    46 		virtual TInt Int0() const = 0;
    47 	
    48 		virtual TInt Int1() const = 0;
    49 	
    50 		virtual TInt Int2() const = 0;
    51 	
    52 		virtual TInt Int3() const = 0;
    53 	public:
    54 	
    55 		virtual TInt GetDesLength(TInt aParam) const = 0;
    56 	
    57 		virtual TInt GetDesMaxLength(TInt aParam) const = 0;
    58 	
    59 		virtual void ReadL(TInt aParam, TDes8& aDes, TInt aOffset=0) const = 0;
    60 	
    61 		virtual void ReadL(TInt aParam, TDes& aDes,  TInt aOffset=0) const = 0;
    62 	
    63 		virtual TInt Write(TInt aParam, const TDesC8& aDes, TInt aOffset=0) const = 0;
    64 	
    65 		virtual void WriteL(TInt aParam, const TDesC8& aDes) const = 0;
    66 	
    67 		virtual void WriteL(TInt aParam, const TDesC& aDes, TInt aOffset=0) const = 0;
    68 	};
    69 
    70 //
    71 //
    72 
    73 # ifndef __ECOMSERVER_TESTING__
    74 //
    75 // TClientRequest
    76 //
    77 // Concrete implementation of MClientRequest that acts as an adaptor for
    78 // RMessage.
    79 //
    80 
    81 class TClientRequest : public MClientRequest
    82 /**
    83 @internalComponent
    84 */
    85 	{
    86 	public:
    87 	
    88 		TClientRequest() {}
    89 	
    90 		TClientRequest(const RMessage2&);
    91 	
    92 		virtual TBool IsNull() const;
    93 	
    94 		virtual TInt Function() const;
    95 	
    96 		virtual void Complete(TInt aReason) const;
    97 	
    98 		virtual void Panic(const TDesC& aCategory, TInt aReason) const;
    99 	
   100 		virtual TInt Int0() const;
   101 	
   102 		virtual TInt Int1() const;
   103 	
   104 		virtual TInt Int2() const;
   105 	
   106 		virtual TInt Int3() const;
   107 	
   108 		virtual TInt GetDesLength(TInt aParam) const;
   109 	
   110 		virtual TInt GetDesMaxLength(TInt aParam) const;
   111 	
   112 		virtual void ReadL(TInt aParam, TDes8& aDes, TInt aOffset=0) const;
   113 	
   114 		virtual void ReadL(TInt aParam, TDes& aDes,  TInt aOffset=0) const;
   115 	
   116 		virtual TInt Write(TInt aParam, const TDesC8& aDes, TInt aOffset=0) const;
   117 	
   118 		virtual void WriteL(TInt aParam, const TDesC8& aDes) const;
   119 	
   120 		virtual void WriteL(TInt aParam, const TDesC& aDes, TInt aOffset=0) const;
   121 		TBool CheckCapability(const TCapabilitySet& aCapabilities, const CImplementationInformation& aImplInfo) const;
   122 	private:
   123 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
   124 		void EmitDiagnostic(const TCapabilitySet& aCapabilities, const CImplementationInformation& aImplInfo) const;
   125 #endif
   126 		TBool HasCapabilities(const TCapabilitySet& aCapabilities) const;
   127 	private:
   128 	
   129 		RMessage2 iMessage;
   130 		TSecurityInfo iSecurityInfo;
   131 	};
   132 
   133 //
   134 //
   135 # else //_UNIT_TESTING_
   136 //
   137 // TClientRequest
   138 //
   139 // Unit test version.
   140 //
   141 class TClientRequest : public MClientRequest
   142 /**
   143 @internalComponent
   144 */
   145 	{
   146 	public:
   147 		TClientRequest();
   148 		TClientRequest(const RMessage2&) {}; // Needed for compilation, but not used in testing.
   149 		virtual TBool IsNull() const;
   150 		virtual TInt Function() const;
   151 		virtual void Complete(TInt aReason) const;
   152 		virtual void Panic(const TDesC& aCategory, TInt aReason) const;
   153 		virtual TInt Int0() const;
   154 		virtual TInt Int1() const;
   155 		virtual TInt Int2() const;
   156 		virtual TInt Int3() const;
   157 		virtual TInt GetDesLength(TInt aParam) const;
   158 		virtual TInt GetDesMaxLength(TInt aParam) const;
   159 		virtual void ReadL(TInt aParam, TDes8& aDes, TInt aOffset=0) const;
   160 		virtual void ReadL(TInt aParam, TDes& aDes, TInt aOffset=0) const;
   161 		virtual TInt Write(TInt aParam, const TDesC8& aDes, TInt aOffset=0) const;
   162 		virtual void WriteL(TInt aParam, const TDesC8& aDes) const;
   163 		virtual void WriteL(TInt aParam, const TDesC& aDes, TInt aOffset=0) const;
   164 		TBool CheckCapability(const TCapabilitySet& aCapabilities, const CImplementationInformation& aImplInfo) const;
   165 	private:
   166 		TBool HasCapabilities(const TCapabilitySet& aCapabilities) const;
   167 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
   168 		void EmitDiagnostic(const TCapabilitySet& aCapabilities, const CImplementationInformation& aImplInfo) const;
   169 #endif
   170 	public://debug only
   171 		inline void SetRequest(TRequestStatus& aStatus);
   172 		inline void SetFunction(TInt);
   173 		inline void SetCapability(TUint32);
   174 		inline void SetParam(TInt aParam, TInt aValue);
   175 		inline void SetParam(TInt aParam, TDes8* aValue);
   176 		inline void SetParam(TInt aParam, const TDesC8* aValue);
   177 		inline void SetParam(TInt aParam, TDes* aValue);
   178 		inline void SetParam(TInt aParam, const TDesC* aValue);
   179 		inline void SetIdentity(TUid aIdentity);
   180 		TUid Identity() const;
   181 		inline TInt CompletionCode() const;
   182 		inline void Reset();
   183 		
   184 	private:
   185 		TInt iFunction;
   186 		TUint32 iCapability;
   187 		mutable TInt iCompletion;
   188 		TInt iParams[KMaxMessageArguments];
   189 		mutable TRequestStatus* iStatus;
   190 		TBool iStatusActive;
   191 		TUid iIdentity;
   192 	};
   193 
   194 //
   195 inline void TClientRequest::SetRequest(TRequestStatus& aStatus) {iStatus = &aStatus; iStatusActive = ETrue;}
   196 inline void TClientRequest::SetFunction(TInt aFunction) { iFunction = aFunction; }
   197 inline void TClientRequest::SetCapability(TUint32 aCap) { iCapability = aCap; }
   198 inline void TClientRequest::SetParam(TInt aParam, TInt aValue) { iParams[aParam] = aValue; }
   199 inline void TClientRequest::SetParam(TInt aParam, TDes8* aValue) { iParams[aParam] = TInt(aValue); }
   200 inline void TClientRequest::SetParam(TInt aParam, const TDesC8* aValue) { iParams[aParam] = TInt(aValue); }
   201 inline void TClientRequest::SetParam(TInt aParam, TDes* aValue) { iParams[aParam] = TInt(aValue); }
   202 inline void TClientRequest::SetParam(TInt aParam, const TDesC* aValue) { iParams[aParam] = TInt(aValue); }
   203 inline void TClientRequest::SetIdentity(TUid aIdentity) { iIdentity = aIdentity; }
   204 inline TInt TClientRequest::CompletionCode() const { return iCompletion; }
   205 inline void TClientRequest::Reset() { *this = TClientRequest(); }
   206 
   207 //
   208 //
   209 #endif //__ECOMSERVER_TESTING__
   210 
   211 //
   212 //
   213 //
   214 #endif //__CLIENTREQUEST_H__