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