sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef __CLIENTREQUEST_H__ sl@0: #define __CLIENTREQUEST_H__ sl@0: sl@0: #include sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: // MClientRequest sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: // Provides an interface identical to RMessage2. sl@0: // This facilitiates unit testing of the session by enabling RMessage2 to be sl@0: // replaced in unit test code. sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: class MClientRequest sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: { sl@0: public: sl@0: virtual TInt Function() const = 0; sl@0: virtual void Complete(TInt aReason) const = 0; sl@0: virtual void Panic(const TDesC& aCategory, TInt aReason) const = 0; sl@0: public: sl@0: virtual TInt Int0() const = 0; sl@0: virtual TInt Int1() const = 0; sl@0: virtual TInt Int2() const = 0; sl@0: virtual TInt Int3() const = 0; sl@0: public: sl@0: virtual TInt GetDesLengthL(TInt aParam) const = 0; sl@0: virtual TInt GetDesMaxLength(TInt aParam) const = 0; sl@0: virtual void ReadL(TInt aParam, TDes8& aDes, TInt aOffset=0) const = 0; sl@0: virtual void ReadL(TInt aParam, TDes& aDes, TInt aOffset=0) const = 0; sl@0: virtual void Read(TInt aParam, TDes8& aDes, TInt aOffset=0) const = 0; sl@0: virtual void Read(TInt aParam, TDes& aDes, TInt aOffset=0) const = 0; sl@0: virtual TInt Write(TInt aParam, const TDesC8& aDes, TInt aOffset=0) const = 0; sl@0: virtual void WriteL(TInt aParam, const TDesC8& aDes) const = 0; sl@0: virtual void WriteL(TInt aParam, const TDesC& aDes, TInt aOffset=0) const = 0; sl@0: virtual TBool CheckPolicy(const TSecurityPolicy& aSecurityPolicy,const char *aDiagnostic) const =0; sl@0: }; sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: # ifndef CENTRAL_REPOSITORY_SERVER_TESTING sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: // TClientRequest sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: // Concrete implementation of MClientRequest that acts as an adaptor for sl@0: // RMessage. sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: class TClientRequest : public MClientRequest sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: { sl@0: public: sl@0: TClientRequest() {} sl@0: TClientRequest(const RMessage2&); sl@0: virtual TInt Function() const; sl@0: virtual void Complete(TInt aReason) const; sl@0: virtual void Panic(const TDesC& aCategory, TInt aReason) const; sl@0: virtual TInt Int0() const; sl@0: virtual TInt Int1() const; sl@0: virtual TInt Int2() const; sl@0: virtual TInt Int3() const; sl@0: virtual TInt GetDesLengthL(TInt aParam) const; sl@0: virtual TInt GetDesMaxLength(TInt aParam) const; sl@0: virtual void ReadL(TInt aParam, TDes8& aDes, TInt aOffset=0) const; sl@0: virtual void ReadL(TInt aParam, TDes& aDes, TInt aOffset=0) const; sl@0: virtual void Read(TInt aParam, TDes8& aDes, TInt aOffset=0) const; sl@0: virtual void Read(TInt aParam, TDes& aDes, TInt aOffset=0) const; sl@0: virtual TInt Write(TInt aParam, const TDesC8& aDes, TInt aOffset=0) const; sl@0: virtual void WriteL(TInt aParam, const TDesC8& aDes) const; sl@0: virtual void WriteL(TInt aParam, const TDesC& aDes, TInt aOffset=0) const; sl@0: virtual TBool CheckPolicy(const TSecurityPolicy& aSecurityPolicy,const char *aDiagnostic) const; sl@0: private: sl@0: RMessage2 iMessage; sl@0: }; sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: # else //_UNIT_TESTING_ sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: // TClientRequest sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: // Unit test version. sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: class TClientRequest : public MClientRequest sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: { sl@0: public: sl@0: TClientRequest(); sl@0: TClientRequest(const RMessage2&) {}; // Needed for compilation, but not used in testing. sl@0: virtual TInt Function() const; sl@0: virtual void Complete(TInt aReason) const; sl@0: virtual void Panic(const TDesC& aCategory, TInt aReason) const; sl@0: virtual TInt Int0() const; sl@0: virtual TInt Int1() const; sl@0: virtual TInt Int2() const; sl@0: virtual TInt Int3() const; sl@0: virtual TInt GetDesLengthL(TInt aParam) const; sl@0: virtual TInt GetDesMaxLength(TInt aParam) const; sl@0: virtual void ReadL(TInt aParam, TDes8& aDes, TInt aOffset=0) const; sl@0: virtual void ReadL(TInt aParam, TDes& aDes, TInt aOffset=0) const; sl@0: virtual void Read(TInt aParam, TDes8& aDes, TInt aOffset=0) const; sl@0: virtual void Read(TInt aParam, TDes& aDes, TInt aOffset=0) const; sl@0: virtual TInt Write(TInt aParam, const TDesC8& aDes, TInt aOffset=0) const; sl@0: virtual void WriteL(TInt aParam, const TDesC8& aDes) const; sl@0: virtual void WriteL(TInt aParam, const TDesC& aDes, TInt aOffset=0) const; sl@0: virtual TBool CheckPolicy(const TSecurityPolicy& aSecurityPolicy,const char *aDiagnostic) const; sl@0: public://debug only sl@0: inline void SetParam(TInt aParam, TInt aValue); sl@0: inline void SetParam(TInt aParam, TDes8* aValue); sl@0: inline void SetPolicyCheck(TBool aPolicyCheck); sl@0: inline TInt CompletionCode() const; sl@0: sl@0: private: sl@0: TInt iFunction; sl@0: TUint32 iCapability; sl@0: mutable TInt iCompletion; sl@0: TInt iParams[KMaxMessageArguments]; sl@0: mutable TRequestStatus* iStatus; sl@0: TBool iStatusActive; sl@0: TUid iIdentity; sl@0: TBool iPolicyCheck; sl@0: }; sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: inline void TClientRequest::SetParam(TInt aParam, TInt aValue) { iParams[aParam] = aValue; } sl@0: inline void TClientRequest::SetParam(TInt aParam, TDes8* aValue) { iParams[aParam] = TInt(aValue); } sl@0: inline void TClientRequest::SetPolicyCheck(TBool aPolicyCheck) {iPolicyCheck=aPolicyCheck;} sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: #endif //CENTRAL_REPOSITORY_SERVER_TESTING sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: #endif //__CLIENTREQUEST_H__