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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __CLIENTREQUEST_H__
17 #define __CLIENTREQUEST_H__
21 #include <ecom/implementationinformation.h>
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.
37 virtual TBool IsNull() const = 0;
39 virtual TInt Function() const = 0;
41 virtual void Complete(TInt aReason) const = 0;
43 virtual void Panic(const TDesC& aCategory, TInt aReason) const = 0;
46 virtual TInt Int0() const = 0;
48 virtual TInt Int1() const = 0;
50 virtual TInt Int2() const = 0;
52 virtual TInt Int3() const = 0;
55 virtual TInt GetDesLength(TInt aParam) const = 0;
57 virtual TInt GetDesMaxLength(TInt aParam) const = 0;
59 virtual void ReadL(TInt aParam, TDes8& aDes, TInt aOffset=0) const = 0;
61 virtual void ReadL(TInt aParam, TDes& aDes, TInt aOffset=0) const = 0;
63 virtual TInt Write(TInt aParam, const TDesC8& aDes, TInt aOffset=0) const = 0;
65 virtual void WriteL(TInt aParam, const TDesC8& aDes) const = 0;
67 virtual void WriteL(TInt aParam, const TDesC& aDes, TInt aOffset=0) const = 0;
73 # ifndef __ECOMSERVER_TESTING__
77 // Concrete implementation of MClientRequest that acts as an adaptor for
81 class TClientRequest : public MClientRequest
90 TClientRequest(const RMessage2&);
92 virtual TBool IsNull() const;
94 virtual TInt Function() const;
96 virtual void Complete(TInt aReason) const;
98 virtual void Panic(const TDesC& aCategory, TInt aReason) const;
100 virtual TInt Int0() const;
102 virtual TInt Int1() const;
104 virtual TInt Int2() const;
106 virtual TInt Int3() const;
108 virtual TInt GetDesLength(TInt aParam) const;
110 virtual TInt GetDesMaxLength(TInt aParam) const;
112 virtual void ReadL(TInt aParam, TDes8& aDes, TInt aOffset=0) const;
114 virtual void ReadL(TInt aParam, TDes& aDes, TInt aOffset=0) const;
116 virtual TInt Write(TInt aParam, const TDesC8& aDes, TInt aOffset=0) const;
118 virtual void WriteL(TInt aParam, const TDesC8& aDes) const;
120 virtual void WriteL(TInt aParam, const TDesC& aDes, TInt aOffset=0) const;
121 TBool CheckCapability(const TCapabilitySet& aCapabilities, const CImplementationInformation& aImplInfo) const;
123 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
124 void EmitDiagnostic(const TCapabilitySet& aCapabilities, const CImplementationInformation& aImplInfo) const;
126 TBool HasCapabilities(const TCapabilitySet& aCapabilities) const;
130 TSecurityInfo iSecurityInfo;
135 # else //_UNIT_TESTING_
139 // Unit test version.
141 class TClientRequest : public MClientRequest
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;
166 TBool HasCapabilities(const TCapabilitySet& aCapabilities) const;
167 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
168 void EmitDiagnostic(const TCapabilitySet& aCapabilities, const CImplementationInformation& aImplInfo) const;
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;
187 mutable TInt iCompletion;
188 TInt iParams[KMaxMessageArguments];
189 mutable TRequestStatus* iStatus;
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(); }
209 #endif //__ECOMSERVER_TESTING__
214 #endif //__CLIENTREQUEST_H__