bluetoothappprofiles/avrcp/remconbeareravrcp/inc/playerstatewatcher.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 #ifndef PLAYERSTATEWATCHER_H
       
    17 #define PLAYERSTATEWATCHER_H
       
    18 
       
    19 #include <e32base.h>
       
    20 #include <e32hashtab.h>
       
    21 #include <remcon/clientid.h>
       
    22 #include <playerinformationtargetobserver.h>
       
    23 #include "commandhandlerinterface.h"
       
    24 
       
    25 class MRemConCommandInterface;
       
    26 class CInternalCommand;
       
    27 class CAvrcpCommand;
       
    28 NONSHARABLE_CLASS(CPlayerWatcherBase) : public CBase, public MIncomingCommandHandler
       
    29 	{
       
    30 public:
       
    31 	virtual void StartWatchingPlayerL(TRemConClientId aClientId) = 0;
       
    32 	void StopWatchingPlayer(TRemConClientId aClientId);
       
    33 	
       
    34 protected:
       
    35 	virtual void ReceiveUpdate(CInternalCommand& aCommand, TRemConClientId aClientId, RBuf8& aData) = 0;
       
    36 	virtual void ReceiveReject(TRemConClientId aClientId) = 0;
       
    37 
       
    38 private: // from MIncomingCommandHandler
       
    39 
       
    40 	// lower interface 
       
    41 	void MessageSent(CAvrcpCommand& aCommand, TInt aSendResult);
       
    42 	void MaxPacketSize(TInt aMtu);
       
    43 	void ReceiveCommandL(const TDesC8& aMessageInformation, SymbianAvctp::TTransactionLabel aTransLabel, const TBTDevAddr& aAddr);
       
    44 	
       
    45 	// upper interface
       
    46 	TInt SendRemConResponse(TUid aInterfaceUid, TUint aTransactionId, RBuf8& aData) ;
       
    47 	void SendReject(TUid aInterfaceUid, TUint aTransactionId);
       
    48 	void Disconnect();
       
    49 	
       
    50 protected:
       
    51 	CPlayerWatcherBase(MRemConCommandInterface& aCommandInterface);
       
    52 	~CPlayerWatcherBase();
       
    53 	
       
    54 private:
       
    55 	CInternalCommand& FindCommand(TUid aInterfaceUid, TUint aTransactionId, 
       
    56 			TRemConClientId& aFoundClientId);
       
    57 
       
    58 	
       
    59 protected:
       
    60 	MRemConCommandInterface& iCommandInterface;
       
    61 	RHashMap<TRemConClientId, CInternalCommand*> iCommands;
       
    62 	};
       
    63 
       
    64 NONSHARABLE_CLASS(MPlayStatusObserver)
       
    65 	{
       
    66 public:
       
    67 	virtual void MpsoPlayStatusChanged(TRemConClientId aId, MPlayerEventsObserver::TPlaybackStatus aPlaybackStatus) = 0;
       
    68 	virtual void MpsoError(TRemConClientId aId) = 0;
       
    69 	};
       
    70 
       
    71 NONSHARABLE_CLASS(CPlayStatusWatcher) : public CPlayerWatcherBase
       
    72 	{
       
    73 public:
       
    74 	static CPlayStatusWatcher* NewL(MPlayStatusObserver& aObserver,
       
    75 			MRemConCommandInterface& aCommandInterface);
       
    76 	~CPlayStatusWatcher();
       
    77 
       
    78 	void StartWatchingPlayerL(TRemConClientId aClientId);
       
    79 	
       
    80 private:
       
    81 	CPlayStatusWatcher(MPlayStatusObserver& aObserver,
       
    82 			MRemConCommandInterface& aCommandInterface);
       
    83 	
       
    84 	void SendPlayStatusUpdateRequest(CInternalCommand& aCommand, TRemConClientId& aClientId, MPlayerEventsObserver::TPlaybackStatus aPlaybackStatus);
       
    85 	void ReceiveUpdate(CInternalCommand& aCommand, TRemConClientId aClientId, RBuf8& aData);
       
    86 	void ReceiveReject(TRemConClientId aClientId);
       
    87 
       
    88 private:
       
    89 	MPlayStatusObserver& iObserver;
       
    90 	};
       
    91 
       
    92 
       
    93 NONSHARABLE_CLASS(MUidObserver)
       
    94 	{
       
    95 public:
       
    96 	virtual void MuoUidChanged(TRemConClientId aId, TUint16 aUidCounter) = 0;
       
    97 	virtual void MuoError(TRemConClientId aId) = 0;
       
    98 	};
       
    99 
       
   100 NONSHARABLE_CLASS(CUidWatcher) : public CPlayerWatcherBase
       
   101 	{
       
   102 public:
       
   103 	static CUidWatcher* NewL(MUidObserver& aObserver,
       
   104 			MRemConCommandInterface& aCommandInterface);
       
   105 	~CUidWatcher();
       
   106 	
       
   107 	void StartWatchingPlayerL(TRemConClientId aClientId);
       
   108 
       
   109 private:
       
   110 	CUidWatcher(MUidObserver& aObserver,
       
   111 			MRemConCommandInterface& aCommandInterface);
       
   112 	
       
   113 	void SendUidUpdateRequest(CInternalCommand& aCommand, TRemConClientId& aClientId, TUint16 aUidCounter);
       
   114 	void ReceiveUpdate(CInternalCommand& aCommand, TRemConClientId aClientId, RBuf8& aData);
       
   115 	void ReceiveReject(TRemConClientId aClientId);
       
   116 
       
   117 private:
       
   118 	MUidObserver& iObserver;
       
   119 	};
       
   120 
       
   121 #endif //PLAYERSTATEWATCHER_H