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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
22 #ifndef REMCONPLAYERINFORMATIONTARGET_H
23 #define REMCONPLAYERINFORMATIONTARGET_H
27 #include <e32hashtab.h>
29 #include <remcon/remconinterfacebase.h>
30 #include <remcon/remconinterfaceif.h>
31 #include <remcon/avrcpspec.h>
32 #include <playerinformationtargetobserver.h>
34 class CRemConInterfaceSelector;
35 class CPlayerApplicationSettings;
38 // This is the maximum length of the player application setting attribute and value strings
39 const TInt KMaxPlayerApplicationSettingsValue = 255 ;
40 // This is the minimum length of the player application setting attribute and value strings
41 const TInt KMinPlayerApplicationSettingsValue = 1 ;
44 Client-instantiable class supporting player information responses.
45 This is the container class for the three interface parts
47 NONSHARABLE_CLASS(CPlayerInfoTarget) : public CRemConInterfaceBase,
48 public MRemConInterfaceIf2,
49 private MPlayerCapabilitiesObserver,
50 private MPlayerApplicationSettingsObserver,
51 private MPlayerEventsObserver
57 @param aInterfaceSelector The interface selector. The client must have
58 created one of these first.
59 @param aPlayerCapabilitiesObserver Returns a pointer to a MPlayerCapabilitiesObserver for this interface, owned by the CPlayerInfoTarget.
60 @param aPlayerApplicationSettingsObserver Returns a pointer to a MPlayerApplicationSettingsObserver for this interface, owned by the CPlayerInfoTarget
61 @param aPlayerEventsObserver Returns a pointer to a MPlayerEventsObserver for this interface, owned by the CPlayerInfoTarget
62 @return A new CPlayerInfoTarget, owned by the interface selector.
64 IMPORT_C static CPlayerInfoTarget* NewL(CRemConInterfaceSelector& aInterfaceSelector,
65 MPlayerCapabilitiesObserver*& aPlayerCapabilitiesObserver,
66 MPlayerApplicationSettingsObserver*& aPlayerApplicationSettingsObserver,
67 MPlayerEventsObserver*& aPlayerEventsObserver,
68 MPlayerApplicationSettingsNotify& aApplicationSettingNotifier );
71 IMPORT_C ~CPlayerInfoTarget();
78 @param aInterfaceSelector The interface selector.
80 CPlayerInfoTarget(CRemConInterfaceSelector& aInterfaceSelector, MPlayerApplicationSettingsNotify& aApplicationSettingNotifier );
82 void ConstructL(MPlayerCapabilitiesObserver*& aPlayerCapabilitiesObserver,
83 MPlayerApplicationSettingsObserver*& aPlayerApplicationSettingsObserver,
84 MPlayerEventsObserver*& aPlayerEventsObserver );
86 private: // from CRemConInterfaceBase
87 TAny* GetInterfaceIf(TUid aUid);
89 private: // from MRemConInterfaceIf
90 void MrcibNewMessage(TUint aOperationId, const TDesC8& aData, TRemConMessageSubType aMsgSubType);
93 // Bearer attributes (settings) processing
94 void ProcessListPlayerApplicationAttributes( TInt aOperationId );
95 void ProcessGetPlayerApplicationAttributeText( const TDesC8& aData, TInt aOperationId );
96 void ProcessListPlayerApplicationValues( const TDesC8& aData, TInt aOperationId );
97 void ProcessGetPlayerApplicationValueText( const TDesC8& aData, TInt aOperationId );
98 void ProcessGetCurrentPlayerApplicationValue( const TDesC8& aData, TInt aOperationId );
99 void ProcessSetPlayerApplicationValue( const TDesC8& aData, TInt aOperationId );
101 // Bearer attributes (settings) API implementation from MPlayerApplicationSettingsObserver
102 void DoDefineAttributeL(TUint aAttributeID, TDesC8& aAttributeText, RArray<TUint> &aValues, RArray<TPtrC8> &aValueTexts, TUint aInitialValue);
103 void DoSetAttributeL(TUint aAttributeID, TUint aValue);
105 // Notifier Events API implementation from MPlayerEventsObserver
106 void DoPlaybackStatusChanged(TPlaybackStatus aStatus);
107 void DoTrackChanged(TUint64 aTrackId, TUint32 aLengthInMilliseconds);
108 void DoTrackReachedEnd();
109 void DoTrackReachedStart();
110 void DoSetPlaybackPosition(TUint32 aMilliseconds);
111 void DoSetBatteryStatus(TTargetBatteryStatus aBatteryStatus);
113 // Notifier Events bearer processing
114 void ProcessGetPlayStatus();
115 void ProcessGetStatusAndBeginObserving(TUint aOperationId, TRegisterNotificationEvent aEventId, const TDesC8& aData);
116 void ProcessGetStatus(TUint aOperationId, TRegisterNotificationEvent aEventId);
117 void SendNotificationResponse(TRegisterNotificationEvent aEventId, TRemConMessageSubType aMsgSubType);
118 void ProcessGetPlayStatusUpdate(const TDesC8& aData);
120 // Capabilities API implementation from MPlayerCapabilitiesObserver
121 void DoClearEvents();
122 TInt DoAddEvent(TRegisterNotificationEvent aEvent);
123 TInt DoRemoveEvent(TRegisterNotificationEvent aEvent);
124 void DoClearCompanyIds();
125 TInt DoAddCompanyId(TInt aID);
126 TInt DoRemoveCompanyID(TInt aID);
128 // Capabilities bearer processing
129 void ProcessGetCapabilities( const TDesC8& aData );
132 TBool AttributeSettingExists(TUint anAttribute);
133 TBool IsValidAttributeValue(TUint anAttributeId, TUint aAttributeValue);
134 TBool AttributeValueCanBeSet(TUint anAttributeId, TUint aAttributeValue);
135 void SendError(TInt, TInt);
136 void SendError(TInt, TInt, TRemConMessageSubType aSubType);
137 CPlayerApplicationSettings* GetSetting(TUint anAttribute);
138 MPlayerEventsObserver::TTargetBatteryStatus DetectBatteryStatus();
143 MPlayerApplicationSettingsNotify& iApplicationSettingNotifier;
145 // data for MPlayerEventsObserver
146 TPlaybackStatus iPlayBackStatus;
148 TUint32 iLengthInMilliseconds;
149 TPlayPosition iTrackPosition;
151 // The time interval (received as part if the RegisterNotification)
152 // in which the change in playback position will be notified
153 TUint32 iPlayBackIntervalInMilliseconds;
155 TTargetBatteryStatus iBatteryStatus;
156 TUint32 iPlaybackPositionInMilliseconds;
157 TUint32 iLastNotifiedPlaybackPositionInMilliseconds;
159 // data for MPlayerCapabilitiesObserver
160 TEventsMask* iSupportedNotificationEventList;
161 RArray<TInt> iCompanyIdList;
163 // list of events for which notifications have been request
164 RArray<TRegisterNotificationEvent> iPendingNotificationEventList;
166 // Whether we've been asked for an update when the play status changes
167 TBool iPlaybackStatusUpdatePending;
169 // Attribute (settings) data MPlayerApplicationSettingsObserver
170 RHashMap<TInt, CPlayerApplicationSettings*> iPlayerApplicationSettings;
175 #endif // REMCONPLAYERINFORMATIONTARGET_H