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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
 
     5 // which accompanies this distribution, and is available
 
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
 
     8 // Initial Contributors:
 
     9 // Nokia Corporation - initial contribution.
 
    24 #ifndef REMCONPLAYERINFORMATIONTARGET_H
 
    25 #define REMCONPLAYERINFORMATIONTARGET_H
 
    29 #include <e32hashtab.h>
 
    31 #include <remcon/remconinterfacebase.h>
 
    32 #include <remcon/remconinterfaceif.h>
 
    33 #include <remcon/avrcpspec.h>
 
    34 #include <playerinformationtargetobserver.h>
 
    36 class CRemConInterfaceSelector;
 
    37 class CPlayerApplicationSettings;
 
    39 // This is the maximum length of the player application setting attribute and value strings
 
    40 const TInt KMaxPlayerApplicationSettingsValue = 255 ;
 
    41 // This is the minimum length of the player application setting attribute and value strings
 
    42 const TInt KMinPlayerApplicationSettingsValue = 1 ;
 
    45 Client-instantiable class supporting player information responses.
 
    46 This is the container class for the three interface parts
 
    48 NONSHARABLE_CLASS(CPlayerInfoTarget) : 	public CRemConInterfaceBase,
 
    49 								       	public MRemConInterfaceIf2, 
 
    50 								       	private MPlayerCapabilitiesObserver,
 
    51 										private MPlayerApplicationSettingsObserver,
 
    52 										private MPlayerEventsObserver
 
    58 	@param aInterfaceSelector The interface selector. The client must have 
 
    59 	created one of these first.
 
    60 	@param aPlayerCapabilitiesObserver Returns a pointer to a MPlayerCapabilitiesObserver for this interface, owned by the CPlayerInfoTarget.
 
    61 	@param aPlayerApplicationSettingsObserver Returns a pointer to a MPlayerApplicationSettingsObserver for this interface, owned by the CPlayerInfoTarget
 
    62 	@param aPlayerEventsObserver Returns a pointer to a MPlayerEventsObserver for this interface, owned by the CPlayerInfoTarget
 
    63 	@return A new CPlayerInfoTarget, owned by the interface selector.
 
    65 	IMPORT_C static CPlayerInfoTarget* NewL(CRemConInterfaceSelector& aInterfaceSelector,
 
    66 								       	MPlayerCapabilitiesObserver*& aPlayerCapabilitiesObserver,
 
    67 										MPlayerApplicationSettingsObserver*& aPlayerApplicationSettingsObserver,
 
    68 										MPlayerEventsObserver*& aPlayerEventsObserver,
 
    69 										MPlayerApplicationSettingsNotify& aApplicationSettingNotifier );
 
    72 	IMPORT_C ~CPlayerInfoTarget();
 
    79 	@param aInterfaceSelector The interface selector.
 
    81 	CPlayerInfoTarget(CRemConInterfaceSelector& aInterfaceSelector, MPlayerApplicationSettingsNotify& aApplicationSettingNotifier );
 
    83 	void ConstructL(MPlayerCapabilitiesObserver*& aPlayerCapabilitiesObserver,
 
    84 							MPlayerApplicationSettingsObserver*& aPlayerApplicationSettingsObserver,
 
    85 							MPlayerEventsObserver*& aPlayerEventsObserver );
 
    87 private: // from CRemConInterfaceBase
 
    88 	TAny* GetInterfaceIf(TUid aUid);
 
    90 private: // from MRemConInterfaceIf
 
    91 	void MrcibNewMessage(TUint aOperationId, const TDesC8& aData, TRemConMessageSubType aMsgSubType);
 
    94 	// Bearer attributes (settings) processing
 
    95 	void ProcessListPlayerApplicationAttributes( TInt aOperationId );
 
    96 	void ProcessGetPlayerApplicationAttributeText( const TDesC8& aData, TInt aOperationId );
 
    97 	void ProcessListPlayerApplicationValues( const TDesC8& aData, TInt aOperationId );
 
    98 	void ProcessGetPlayerApplicationValueText( const TDesC8& aData, TInt aOperationId );
 
    99 	void ProcessGetCurrentPlayerApplicationValue( const TDesC8& aData, TInt aOperationId );
 
   100 	void ProcessSetPlayerApplicationValue( const TDesC8& aData, TInt aOperationId );
 
   102 	// Bearer attributes (settings) API implementation from MPlayerApplicationSettingsObserver
 
   103 	void DoDefineAttributeL(TUint aAttributeID, TDesC8& aAttributeText, RArray<TUint> &aValues, RArray<TPtrC8> &aValueTexts, TUint aInitialValue);
 
   104 	void DoSetAttributeL(TUint aAttributeID, TUint aValue);
 
   106 	// Notifier Events API implementation from MPlayerEventsObserver
 
   107 	void DoPlaybackStatusChanged(TPlaybackStatus aStatus);
 
   108 	void DoTrackChanged(TUint64 aTrackId, TUint32 aLengthInMilliseconds);
 
   109 	void DoTrackReachedEnd();
 
   110 	void DoTrackReachedStart();
 
   111 	void DoSetPlaybackPosition(TUint32 aMilliseconds);	
 
   112 	void DoSetBatteryStatus(TTargetBatteryStatus aBatteryStatus);
 
   114 	// Notifier Events bearer processing  
 
   115 	void ProcessGetPlayStatus();
 
   116 	void ProcessGetStatusAndBeginObserving(TUint aOperationId, TRegisterNotificationEvent aEventId, const TDesC8& aData);
 
   117 	void ProcessGetStatus(TUint aOperationId, TRegisterNotificationEvent aEventId);
 
   118 	void SendNotificationResponse(TRegisterNotificationEvent aEventId, TRemConMessageSubType aMsgSubType);
 
   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);
 
   142 	MPlayerApplicationSettingsNotify& 	iApplicationSettingNotifier;
 
   144 	// data for MPlayerEventsObserver
 
   145 	TPlaybackStatus 					iPlayBackStatus;
 
   147 	TUint32 							iLengthInMilliseconds;
 
   148 	TPlayPosition						iTrackPosition;
 
   150 	// The time interval (received as part if the RegisterNotification) 
 
   151 	// in which the change in playback position will be notified
 
   152 	TUint32								iPlayBackIntervalInMilliseconds;
 
   154 	TTargetBatteryStatus				iBatteryStatus;
 
   155 	TUint32 							iPlaybackPositionInMilliseconds;
 
   156 	TUint32								iLastNotifiedPlaybackPositionInMilliseconds;
 
   158 	// data for MPlayerCapabilitiesObserver
 
   159 	RArray<TRegisterNotificationEvent> 			iSupportedNotificationEventList;
 
   160 	RArray<TInt> 						iCompanyIdList;
 
   162 	// list of events for which notifications have been request 
 
   163 	RArray<TRegisterNotificationEvent> 			iPendingNotificationEventList;
 
   165 	// Attribute (settings) data MPlayerApplicationSettingsObserver
 
   166 	RHashMap<TInt, CPlayerApplicationSettings*>		iPlayerApplicationSettings;
 
   171 #endif // REMCONPLAYERINFORMATIONTARGET_H