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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __CLIENTREQUEST_H__
17 #define __CLIENTREQUEST_H__
21 ///////////////////////////////////////////////////////////////////////////////
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 ///////////////////////////////////////////////////////////////////////////////
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;
38 virtual TInt Int0() const = 0;
39 virtual TInt Int1() const = 0;
40 virtual TInt Int2() const = 0;
41 virtual TInt Int3() const = 0;
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;
55 ///////////////////////////////////////////////////////////////////////////////
56 ///////////////////////////////////////////////////////////////////////////////
58 # ifndef CENTRAL_REPOSITORY_SERVER_TESTING
59 ///////////////////////////////////////////////////////////////////////////////
61 ///////////////////////////////////////////////////////////////////////////////
62 // Concrete implementation of MClientRequest that acts as an adaptor for
64 ///////////////////////////////////////////////////////////////////////////////
65 class TClientRequest : public MClientRequest
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;
94 ///////////////////////////////////////////////////////////////////////////////
95 ///////////////////////////////////////////////////////////////////////////////
96 # else //_UNIT_TESTING_
97 ///////////////////////////////////////////////////////////////////////////////
99 ///////////////////////////////////////////////////////////////////////////////
100 // Unit test version.
101 ///////////////////////////////////////////////////////////////////////////////
102 class TClientRequest : public MClientRequest
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;
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;
136 mutable TInt iCompletion;
137 TInt iParams[KMaxMessageArguments];
138 mutable TRequestStatus* iStatus;
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;}
149 ///////////////////////////////////////////////////////////////////////////////
150 ///////////////////////////////////////////////////////////////////////////////
151 #endif //CENTRAL_REPOSITORY_SERVER_TESTING
153 ///////////////////////////////////////////////////////////////////////////////
154 ///////////////////////////////////////////////////////////////////////////////
155 ///////////////////////////////////////////////////////////////////////////////
156 #endif //__CLIENTREQUEST_H__