bluetoothappprofiles/avrcp/absolutevolumeapi/public/absolutevolumeapicontroller.h
changeset 70 f5508c13dfe0
parent 67 16e4b9007960
child 71 083fd884d7dd
equal deleted inserted replaced
67:16e4b9007960 70:f5508c13dfe0
     1 // Copyright (c) 2008-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 //
       
    15 
       
    16 
       
    17 
       
    18 /**
       
    19  @file
       
    20  @publishedAll
       
    21  @released
       
    22 */
       
    23 
       
    24 #ifndef REMCONABSOLUTEVOLUMEAPICONTROLLER_H_
       
    25 #define REMCONABSOLUTEVOLUMEAPICONTROLLER_H_
       
    26 
       
    27 #include <remcon/remconinterfacebase.h>
       
    28 #include <remcon/remconinterfaceif.h>
       
    29 #include <absolutevolumeapi.h>
       
    30 
       
    31 _LIT(KAbsoluteVolumeControllerPanicName, "AbsoluteVolumeController");
       
    32 enum TAbsoluteVolumeControllerPanics
       
    33 	{
       
    34 	EControllerInvalidMaxVolume = 0,
       
    35 	EControllerVolumeBeyondMaxVolume = 1,
       
    36 	EAbsoluteVolumeNotificationAlreadyRegistered = 2,
       
    37 	EMultipleSetAbsoluteVolumes = 3,
       
    38 	EMultipleNotifies = 4,
       
    39 	};
       
    40 
       
    41 class MRemConAbsoluteVolumeControllerObserver;
       
    42 class CAbsVolSender;
       
    43 
       
    44 /**
       
    45 @internalComponent
       
    46 */
       
    47 class MAbsVolSenderObserver
       
    48 	{
       
    49 public:
       
    50 	virtual void MavsoSendComplete(TInt aResult) = 0;
       
    51 	};
       
    52 
       
    53 /**
       
    54 This class is used to set and observer the volume level on a remote device.
       
    55 
       
    56 An active scheduler is required in order to use this class.
       
    57 */
       
    58 NONSHARABLE_CLASS(CRemConAbsoluteVolumeController) 
       
    59 : public CRemConInterfaceBase, public MRemConInterfaceIf2, public MAbsVolSenderObserver
       
    60 	{
       
    61 public:    
       
    62 	IMPORT_C static CRemConAbsoluteVolumeController* NewL(
       
    63 			CRemConInterfaceSelector& aInterfaceSelector, 
       
    64 			MRemConAbsoluteVolumeControllerObserver& aObserver,
       
    65 			TUint32 aMaxVolume);
       
    66 	
       
    67 	IMPORT_C ~CRemConAbsoluteVolumeController();
       
    68 
       
    69 public:    
       
    70 	IMPORT_C void SetAbsoluteVolume(TRequestStatus& aStatus, 
       
    71 			TUint32 aVolume, 
       
    72 			TUint& aNumRemotes); 
       
    73 	IMPORT_C void CancelSetAbsoluteVolume();
       
    74 	
       
    75 	IMPORT_C void RegisterAbsoluteVolumeNotification();    
       
    76 	IMPORT_C void CancelAbsoluteVolumeNotification();
       
    77     
       
    78 private:    
       
    79 	CRemConAbsoluteVolumeController(
       
    80 			CRemConInterfaceSelector& aInterfaceSelector, 
       
    81 			MRemConAbsoluteVolumeControllerObserver& aObserver,
       
    82 			TUint32 aMaxVolume); 
       
    83     void ConstructL();
       
    84 
       
    85 private: // Utility functions    
       
    86 	void HandleNotify(const TDesC8& aData, 
       
    87 			TRemConMessageSubType aMessageSubType);  
       
    88     
       
    89     void HandleSetAbsoluteVolumeResponse( const TDesC8& aData );
       
    90     static TInt AsyncErrorCallBack(TAny* aObserver);
       
    91     void KickOffSendIfNeeded();
       
    92     void SetAbsoluteVolumeSendComplete(TInt aResult);
       
    93     void RegisterNotifySendComplete();
       
    94     void SendSetAbsoluteVolume();
       
    95     void SendNotify();
       
    96     
       
    97     void VolumeUpdate(TUint32 aVolume, TUint32 aMaxVolume);
       
    98 
       
    99 private: // From CRemConInterfaceBase
       
   100 	TAny* GetInterfaceIf(TUid aUid);
       
   101     
       
   102 private: // From MRemConInterfaceIf2
       
   103 	void MrcibNewMessage(TUint aOperationId, 
       
   104 			const TDesC8& aData, 
       
   105 			TRemConMessageSubType 
       
   106 			aMessageSubType);
       
   107     
       
   108 private: // From MAbsVolSenderObserver
       
   109 		void MavsoSendComplete(TInt aResult);
       
   110 	
       
   111 private: // Unowned
       
   112 	MRemConAbsoluteVolumeControllerObserver& iObserver;
       
   113 	  
       
   114 private: // Owned
       
   115 	// For operation-specific data.
       
   116 	TBuf8<KAbsoluteVolumeRequestDataSize> iNotifyData;
       
   117 	TBuf8<KAbsoluteVolumeRequestDataSize> iSetData;
       
   118 	
       
   119 	// Records the current absolute volume value.
       
   120 	TUint32 iCurrentVolume;  
       
   121 	TUint32 iCurrentMaxVolume;
       
   122 	
       
   123 	// Used when sending SetAbsoluteVolume commands
       
   124 	TUint32 iClientMaxVolume;
       
   125 	
       
   126 	CAbsVolSender* iAbsVolSender;
       
   127 	
       
   128 	TBool iNotificationRequested;
       
   129 
       
   130 	// Only used for abs vol sends.
       
   131 	TRequestStatus* iClientStatus;
       
   132 	TUint* iClientNumRemotes;
       
   133 
       
   134 	enum TRequestState
       
   135 		{
       
   136 	// There is no request outstanding
       
   137 	ENotInUse = 0,
       
   138 	// We're currently sending this request.
       
   139 	ESending,
       
   140 	// This request is waiting to be sent (possibly because we were busy sending a previous request when this one arose).
       
   141 	EPending,
       
   142 		};
       
   143 	// The two requests we support.
       
   144 	TRequestState iAbsVolRequest;
       
   145 	TRequestState iNotifyRequest;
       
   146 	};
       
   147 
       
   148 #endif /*REMCONABSOLUTEVOLUMEAPICONTROLLER_H_*/