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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
24 #ifndef REMCONABSOLUTEVOLUMEAPICONTROLLER_H_
25 #define REMCONABSOLUTEVOLUMEAPICONTROLLER_H_
27 #include <remcon/remconinterfacebase.h>
28 #include <remcon/remconinterfaceif.h>
29 #include <absolutevolumeapi.h>
31 _LIT(KAbsoluteVolumeControllerPanicName, "AbsoluteVolumeController");
32 enum TAbsoluteVolumeControllerPanics
34 EControllerInvalidMaxVolume = 0,
35 EControllerVolumeBeyondMaxVolume = 1,
36 EAbsoluteVolumeNotificationAlreadyRegistered = 2,
37 EMultipleSetAbsoluteVolumes = 3,
38 EMultipleNotifies = 4,
41 class MRemConAbsoluteVolumeControllerObserver;
47 class MAbsVolSenderObserver
50 virtual void MavsoSendComplete(TInt aResult) = 0;
54 This class is used to set and observer the volume level on a remote device.
56 An active scheduler is required in order to use this class.
58 NONSHARABLE_CLASS(CRemConAbsoluteVolumeController)
59 : public CRemConInterfaceBase, public MRemConInterfaceIf2, public MAbsVolSenderObserver
62 IMPORT_C static CRemConAbsoluteVolumeController* NewL(
63 CRemConInterfaceSelector& aInterfaceSelector,
64 MRemConAbsoluteVolumeControllerObserver& aObserver,
67 IMPORT_C ~CRemConAbsoluteVolumeController();
70 IMPORT_C void SetAbsoluteVolume(TRequestStatus& aStatus,
73 IMPORT_C void CancelSetAbsoluteVolume();
75 IMPORT_C void RegisterAbsoluteVolumeNotification();
76 IMPORT_C void CancelAbsoluteVolumeNotification();
79 CRemConAbsoluteVolumeController(
80 CRemConInterfaceSelector& aInterfaceSelector,
81 MRemConAbsoluteVolumeControllerObserver& aObserver,
85 private: // Utility functions
86 void HandleNotify(const TDesC8& aData,
87 TRemConMessageSubType aMessageSubType);
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();
97 void VolumeUpdate(TUint32 aVolume, TUint32 aMaxVolume);
99 private: // From CRemConInterfaceBase
100 TAny* GetInterfaceIf(TUid aUid);
102 private: // From MRemConInterfaceIf2
103 void MrcibNewMessage(TUint aOperationId,
105 TRemConMessageSubType
108 private: // From MAbsVolSenderObserver
109 void MavsoSendComplete(TInt aResult);
112 MRemConAbsoluteVolumeControllerObserver& iObserver;
115 // For operation-specific data.
116 TBuf8<KAbsoluteVolumeRequestDataSize> iNotifyData;
117 TBuf8<KAbsoluteVolumeRequestDataSize> iSetData;
119 // Records the current absolute volume value.
120 TUint32 iCurrentVolume;
121 TUint32 iCurrentMaxVolume;
123 // Used when sending SetAbsoluteVolume commands
124 TUint32 iClientMaxVolume;
126 CAbsVolSender* iAbsVolSender;
128 TBool iNotificationRequested;
130 // Only used for abs vol sends.
131 TRequestStatus* iClientStatus;
132 TUint* iClientNumRemotes;
136 // There is no request outstanding
138 // We're currently sending this request.
140 // This request is waiting to be sent (possibly because we were busy sending a previous request when this one arose).
143 // The two requests we support.
144 TRequestState iAbsVolRequest;
145 TRequestState iNotifyRequest;
148 #endif /*REMCONABSOLUTEVOLUMEAPICONTROLLER_H_*/