bluetoothmgmt/btmgr/eirclient/interface/eirpublisher.h
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 2007-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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // EIR Publisher client header.
       
    15 // Implements the C-class used by clients to publish data to the local EIR
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalTechnology
       
    22 */
       
    23 
       
    24 #ifndef _EIRPUBLISHER_H
       
    25 #define _EIRPUBLISHER_H
       
    26 
       
    27 #include <e32std.h>
       
    28 #include <e32base.h>
       
    29 #include <bluetooth/eirmanshared.h>
       
    30 #include <bluetooth/eirclient.h>
       
    31 
       
    32 
       
    33 class MEirPublisherNotifier
       
    34 	{
       
    35 public:
       
    36 	virtual void MepnSpaceAvailable(TUint aBytesAvailable) = 0;
       
    37 	virtual void MepnSetDataError(TInt aResult) = 0;
       
    38 	};
       
    39 
       
    40 class CEirPublisher;
       
    41 
       
    42 /**
       
    43 @internalComponent
       
    44 */
       
    45 NONSHARABLE_CLASS(CEirPublisherNotifier) : public CActive
       
    46 	{
       
    47 public:
       
    48 	CEirPublisherNotifier(CEirPublisher& aPublisher);
       
    49 	~CEirPublisherNotifier();
       
    50 	
       
    51 	void Start();
       
    52 	
       
    53 private:
       
    54 	void RunL();
       
    55 	void DoCancel();
       
    56 	TInt RunError(TInt aError);
       
    57 	
       
    58 private:
       
    59 	CEirPublisher&	iPublisher;
       
    60 	TUint			iSpaceAvailable;
       
    61 	};
       
    62 
       
    63 NONSHARABLE_CLASS(CEirPublisher) : public CActive
       
    64 /**
       
    65 The CEirPublisher class encapsulates a data publisher to the local EIR
       
    66 */
       
    67 	{
       
    68 public:
       
    69 	// Factory
       
    70 	IMPORT_C static CEirPublisher* NewL(TEirTag aEirTag, MEirPublisherNotifier& aNotifier);
       
    71 	~CEirPublisher();
       
    72 
       
    73 	// Public methods
       
    74 	IMPORT_C void SetData(const TDesC8& aData, TEirDataMode aDataMode);
       
    75 	IMPORT_C void PublishData(TInt aRequiredLength);
       
    76 	
       
    77 public: // used by CEirPublisherNotifier
       
    78 	void SpaceAvailable(TUint aSpace);
       
    79 	void NotifierError(TInt aError);
       
    80 	REirMan& EirMan();
       
    81 	
       
    82 private:
       
    83 	CEirPublisher(TEirTag aEirTag, MEirPublisherNotifier& aNotifier);
       
    84 	void ConstructL();
       
    85 
       
    86 private:
       
    87 	// From CActive
       
    88 	virtual void RunL();
       
    89 	virtual void DoCancel();
       
    90 	virtual TInt RunError(TInt aError);
       
    91 	
       
    92 private:
       
    93 	enum TState
       
    94 		{
       
    95 		EInvalid,
       
    96 		EConnecting,
       
    97 		ENewData,
       
    98 		ERegisterTag,
       
    99 		EDataCallback,
       
   100 		ESettingData,
       
   101 		EIdle,
       
   102 		ENoConnection,
       
   103 		};
       
   104 
       
   105 private:
       
   106 	TEirTag 				iEirTag;
       
   107 	MEirPublisherNotifier& 	iNotifier;
       
   108 	CEirPublisherNotifier*	iNotifierAo;
       
   109 	REirMan					iEirMan;
       
   110 	TUint 					iBytesAvailable;
       
   111 	TBool 					iSetDataPending;
       
   112 	TState 					iState;
       
   113 	TBool					iPublishOutstanding;
       
   114 	TInt					iRequiredBytes;
       
   115 	TBool					iCallbackOutstanding;
       
   116 	TUint					iAvailableBytes;
       
   117 	};
       
   118 	
       
   119 enum TBTEirPublisherPanic
       
   120 	{
       
   121 	EUnexpectedPublisherState,
       
   122 	EInvalidEirManHandle,
       
   123 	};
       
   124 	
       
   125 _LIT(KBTEirPublisherPanic, "BT Eir Publisher");
       
   126 	
       
   127 #endif // _EIRPUBLISHER_H