bluetooth/btstack/eirman/eirmansession.h
branchRCL_3
changeset 17 32ba20339036
parent 0 29b1cd4cb562
child 18 1f10b9300be6
equal deleted inserted replaced
16:9f17f914e828 17:32ba20339036
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    25 #include <e32std.h>
    25 #include <e32std.h>
    26 #include <bluetooth/eirmanshared.h>
    26 #include <bluetooth/eirmanshared.h>
    27 #include "eirmanager.h"
    27 #include "eirmanager.h"
    28 
    28 
    29 class CEirManServer;
    29 class CEirManServer;
       
    30 class CEirManInternalSession;
    30 
    31 
    31 NONSHARABLE_CLASS(CEirManSession) : public CSession2, public MEirManagerNotifiee
    32 NONSHARABLE_CLASS(MEirSessionNotifier)
    32 	{
    33 	{
    33 public:
    34 public:
    34 	static CEirManSession* NewL(CEirManServer& aServer);
    35 	virtual void MesnRegisterComplete(TInt aResult) = 0;
       
    36 	virtual void MesnSpaceAvailable(TUint aSpaceForTag) = 0;
       
    37 	};
       
    38 
       
    39 NONSHARABLE_CLASS(MEirInternalSessionNotifier)
       
    40 	{
       
    41 public:
       
    42 	virtual void MeisnRegisterComplete(TInt aResult) = 0;
       
    43 	virtual void MeisnSpaceAvailable(TUint aSpaceForTag) = 0;
       
    44 	virtual void MeisnSetDataError(TInt aError) = 0;
       
    45 	};
       
    46 
       
    47 NONSHARABLE_CLASS(CEirManSession) : public CBase, public MEirManagerNotifiee
       
    48 	{
       
    49 public:
       
    50 	static CEirManSession* NewL(CEirManServer& aServer, MEirSessionNotifier& aParent, TBool aInternalSession);
    35 	~CEirManSession();
    51 	~CEirManSession();
    36 	void NotifyEirFeatureState(TInt aResult);
    52 	void NotifyEirFeatureState(TInt aResult);
       
    53 	
       
    54 	void RegisterTag(TEirTag aTag);
       
    55 	TInt SetData(const TDesC8& aData, TEirDataMode aMode);
       
    56 	TInt NewData(TInt aRequiredLength);
       
    57 	TEirTag EirTag() const;
       
    58 
    37 private:
    59 private:
    38 	CEirManSession(CEirManServer& aServer);
    60 	CEirManSession(CEirManServer& aServer, MEirSessionNotifier& aParent, TBool aInternalSession);
    39 	void ConstructL();
    61 	void ConstructL();
       
    62 	void DeregisterTag();
    40 
    63 
    41 	// ServiceL handlers
    64 private: // from MEirManagerNotifiee
       
    65 	virtual void MemnEirBlockAvailable(TEirTag aTag, TUint aSpaceForTag);
       
    66 
       
    67 public:
       
    68 	TDblQueLink	iLink;
       
    69 	
       
    70 private:
       
    71 	CEirManServer& 		iEirManServer; // unowned
       
    72 	MEirSessionNotifier& iParent;
       
    73 	TEirTag 			iEirTag;
       
    74 	TEirTag				iPendingEirTag;
       
    75 	TBool				iRegisterPending;
       
    76 	TBool				iInternalSession;
       
    77 	};
       
    78 
       
    79 NONSHARABLE_CLASS(CEirManExternalSession): public CSession2, public MEirSessionNotifier
       
    80 	{
       
    81 public:
       
    82 	static CEirManExternalSession* NewL(CEirManServer& aServer);
       
    83 	~CEirManExternalSession();
       
    84 	
       
    85 private:
       
    86 	void ConstructL(CEirManServer& aServer);
       
    87 	CEirManExternalSession();
    42 	void RegisterTag(const RMessage2& aMessage);
    88 	void RegisterTag(const RMessage2& aMessage);
    43 	TInt RegisterSpaceAvailableListener(const RMessage2& aMessage, TBool& aComplete);
    89 	TInt RegisterSpaceAvailableListener(const RMessage2& aMessage, TBool& aComplete);
    44 	TInt CancelSpaceAvailableListener();
    90 	TInt CancelSpaceAvailableListener();
       
    91 	TInt NewData(const RMessage2& aMessage);
    45 	TInt SetData(const RMessage2& aMessage);
    92 	TInt SetData(const RMessage2& aMessage);
    46 	TInt NewData(const RMessage2& aMessage);
    93 
    47 	
    94 private:
    48 	void CompleteSpaceAvailableRequest(TUint aBytesAvailable);
    95 	void CompleteSpaceAvailableRequest(TUint aBytesAvailable);
    49 	void DeregisterTag();
       
    50 
    96 
    51 private: // CSession2 virtuals
    97 private: // CSession2 virtuals
    52 	virtual void ServiceL(const RMessage2& aMessage);
    98 	virtual void ServiceL(const RMessage2& aMessage);
    53 
    99 
    54 private: // from MEirManagerNotifiee
       
    55 	virtual void MemnEirBlockAvailable(TEirTag aTag, TUint aSpaceForTag);
       
    56 
       
    57 private:
   100 private:
    58 	CEirManServer& 		iEirManServer; // unowned
   101 	virtual void MesnRegisterComplete(TInt aResult);
    59 	TEirTag 			iEirTag;
   102 	virtual void MesnSpaceAvailable(TUint aSpaceForTag);
    60 	TEirTag				iPendingEirTag;
   103 	
    61 	TUint 				iLastSpaceOffered;
   104 private:
    62 	TBool 				iSpaceAvailableListenerOutstanding;
       
    63 	RMessage2			iRegisterMessage;
   105 	RMessage2			iRegisterMessage;
    64 	RMessage2			iDataAvailableListenerMessage;
   106 	RMessage2			iDataAvailableListenerMessage;
       
   107 	TUint 				iLastSpaceOffered;
       
   108 
       
   109 	CEirManSession* iSession;
       
   110 	};
       
   111 
       
   112 NONSHARABLE_CLASS(CEirManInternalSession) : public CBase, public MEirSessionNotifier
       
   113 	{
       
   114 public:
       
   115 	static CEirManInternalSession* NewL(CEirManServer& aServer, MEirInternalSessionNotifier& aParent);
       
   116 	~CEirManInternalSession();
       
   117 	
       
   118 	void RegisterTag(TEirTag aTag);
       
   119 	void SetData(const TDesC8& aData, TEirDataMode aMode);
       
   120 	TInt NewData(TInt aRequiredLength);
       
   121 	
       
   122 private:
       
   123 	CEirManInternalSession(MEirInternalSessionNotifier& aParent);
       
   124 	void ConstructL(CEirManServer& aServer);
       
   125 
       
   126 	static TInt SetDataCb(TAny* aThis);
       
   127 	void DoSetData();
       
   128 	
       
   129 private: // from MEirManagerNotifiee
       
   130 	virtual void MesnRegisterComplete(TInt aResult);
       
   131 	virtual void MesnSpaceAvailable(TUint aSpaceForTag);
       
   132 	
       
   133 private:
       
   134 	CEirManSession* iSession;
       
   135 	MEirInternalSessionNotifier& iParent;
       
   136 	CAsyncCallBack* iSetDataCb;
       
   137 	HBufC8* iPendingData;
       
   138 	TEirDataMode iPendingMode;
    65 	};
   139 	};
    66 
   140 
    67 #endif // _EIRMANSESSION_H
   141 #endif // _EIRMANSESSION_H
    68 
   142