accessoryservices/accessoryserver/inc/Server/AccSrvConnectionController.h
changeset 0 4e1aa6a622a0
child 12 4a5c47a50617
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Accessory Connection Controller
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CACCSRVCONNECTIONCONTROLLER_H
       
    21 #define CACCSRVCONNECTIONCONTROLLER_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include "AccSrvNotificationQueue.h"
       
    25 #include "AccSrvConnectionHandler.h"
       
    26 #include <e32base.h>
       
    27 
       
    28 // CONSTANTS
       
    29 
       
    30 // MACROS
       
    31 
       
    32 // DATA TYPES
       
    33 
       
    34 // FUNCTION PROTOTYPES
       
    35 
       
    36 // FORWARD DECLARATIONS
       
    37 class TAccPolGenericID;
       
    38 class CAccPolAccessoryPolicy;
       
    39 class CAccSrvServerModel;
       
    40 class CAccSrvNotificationQueue;
       
    41 class CAccSrvConnectionStatusHandler;
       
    42 class CAccSrvModeHandler;
       
    43 class CAccSrvASYProxyHandler;
       
    44 class CAccSrvSettingsHandler;
       
    45 class CAccSrvWiredConnectionPublisher;
       
    46 class CAccSrvChargingContextController;
       
    47 
       
    48 // CLASS DECLARATION
       
    49 
       
    50 /**
       
    51 *  Interface class to be used from Handlers to Connection Controller
       
    52 *  for call-backs.
       
    53 *
       
    54 *  @lib AccServer.lib
       
    55 *  @since S60 3.1
       
    56 */
       
    57 NONSHARABLE_CLASS( MAccSrvConnectionControllerObserver )
       
    58     {
       
    59     public:
       
    60 
       
    61         /**
       
    62         * Called when connection status changed handling should be started.
       
    63         * @since S60 3.1
       
    64         * @return void
       
    65         */
       
    66         virtual void HandleConnectionStatusChangedL() = 0;
       
    67 
       
    68         /**
       
    69         * Called when accessory mode changed handling should be started.
       
    70         * @since S60 3.1
       
    71         * @param aDbId Unique identifier of a Generic ID. If not exist,
       
    72         *              Accessory Mode is updated according to the currecnt
       
    73         *              Combined Accessory Connection Status.
       
    74         * @param aAudioOutputStatus Current audio routing status.
       
    75         *                           Used when aDbId exists.
       
    76         * @return void
       
    77         */
       
    78         virtual void HandleAccessoryModeChangedL( TInt aDbId = KErrUnknown, 
       
    79                                                   TBool aAudioOutputStatus = EFalse ) = 0;
       
    80 
       
    81         /**
       
    82         * Called when all critical capabilities are initialized and connection
       
    83         * handling should proceed.
       
    84         * @since S60 3.1
       
    85         * @param aGenericId A Generic ID of the connected accessory.
       
    86         * @param aCaller    A handle to the caller of this call-back method.
       
    87         *                   Used to delete the caller, because all tasks for that
       
    88         *                   handler are done.
       
    89         * @param aError     Error code for connect validation. Connection handling
       
    90         *                   will continue with KErrNone, otherwise connection is denied.
       
    91         * @return void
       
    92         */
       
    93         virtual void HandleConnectValidationL( const TAccPolGenericID& aGenericId,
       
    94                                                const CAccSrvConnectionHandler* aCaller,
       
    95                                                TInt aError ) = 0;
       
    96 
       
    97         /**
       
    98         * Handle possible single connection and multiple connection status.
       
    99         * changes after a connection update
       
   100         *
       
   101         * @since S60 3.1
       
   102         * @param aGenericID Generic ID of the connected accessory.
       
   103         * @return void
       
   104         */
       
   105 		virtual void HandleConnectionUpdateValidationL( const TAccPolGenericID& aGenericID, 
       
   106 												TAccPolGenericID& aOldGenericId, 
       
   107 												const CAccSrvConnectionHandler* aCaller,
       
   108 												TInt aError  ) = 0;
       
   109 
       
   110         /**
       
   111         * Cancel connection handling 
       
   112         *
       
   113         * @since S60 3.1
       
   114         * @return void
       
   115         */
       
   116 		virtual void ConnectionHandlingCancel( const CAccSrvConnectionHandler* aCaller) = 0;
       
   117 
       
   118 
       
   119         /**
       
   120         * Interface to queue. Allows Handler to register messages to queue.
       
   121         * @since S60 3.1
       
   122         * @param aMsgID    Message to which the observer is registered to.
       
   123         * @param aCallback Handle to observer.
       
   124         * @return void
       
   125         */
       
   126         virtual void RegisterControlMessageL( TMsgID aMsgID,
       
   127                                               MQueueObserver* aCallback ) = 0;
       
   128 
       
   129         /**
       
   130         * Interface to queue. Allows Handler to cancel messages from queue.
       
   131         * @since S60 3.1
       
   132         * @param aMsgID    Message to which the observer is registered to.
       
   133         * @param aCallback Handle to observer.
       
   134         * @return void
       
   135         */
       
   136         virtual void CancelControlMessage( TMsgID aMsgID,
       
   137                                               MQueueObserver* aCallback ) = 0;
       
   138 
       
   139         /**
       
   140         * Interface to ASY handler. Allows Handler to send commands to ASY.
       
   141         * @since S60 3.1
       
   142         * @param aCmdId Defines the ASY command in question.
       
   143         * @param aASYCommandParamRecord Data for ASY command.
       
   144         * @param aPtrBuf Pointer to CBufFlat buffer where CAccPolObjectCon object
       
   145         *                is externalized to.
       
   146         * @return void
       
   147         */
       
   148         virtual TInt HandleASYCommsL( TProcessCmdId aCmdId,
       
   149                                       TASYCommandParamRecord& aASYCommandParamRecord,
       
   150                                       TPtr8* aPtrBuf=NULL ) = 0;
       
   151 
       
   152         /**
       
   153         * Interface to ServerModel. Allows Handler to access Server Model.
       
   154         * @since S60 3.1
       
   155         * @return void
       
   156         */
       
   157         virtual CAccSrvServerModel& ServerModelHandle() = 0;
       
   158         
       
   159         
       
   160         /**
       
   161         * Set default accessory information so mode handler can show default 
       
   162         * accessory selected information note when accessory mode is changed
       
   163         *
       
   164         * @since S60 3.1
       
   165         * @param aGenericID Generic ID information note to be shown
       
   166         * @param aDefaultValue Default selection value
       
   167         * @return void
       
   168         */
       
   169 		virtual void SetDefaultAccessoryInformation( const TAccPolGenericID& aGenericID, 
       
   170 													 const TUint32 aDefaultValue) = 0;
       
   171 
       
   172     };
       
   173 
       
   174 /**
       
   175 *  Connection Controller handles accessory connection related tasks.
       
   176 *
       
   177 *  @lib AccServer.lib
       
   178 *  @since S60 3.1
       
   179 */
       
   180 NONSHARABLE_CLASS( CAccSrvConnectionController ) : public CActive,
       
   181                                                    public MAccSrvConnectionControllerObserver
       
   182     {
       
   183     public  :// Constructors and destructor
       
   184 
       
   185         /**
       
   186         * Two-phased constructor.
       
   187         */
       
   188         static CAccSrvConnectionController* NewL( CAccSrvServerModel* aServerModel );
       
   189 
       
   190         /**
       
   191         * Destructor.
       
   192         */
       
   193         virtual ~CAccSrvConnectionController();
       
   194 
       
   195     public: // New functions
       
   196 
       
   197         /**
       
   198         * Start to handle accessory connection according to given Generic ID
       
   199         *
       
   200         * @since S60 3.1
       
   201         * @param aGenericId      Generic ID of the connected accessory.
       
   202         * @param aCallerThreadID ConnectAccessory was called from this thread.
       
   203         * @param aEvaluateConnectionRules If true evaluate connection rules
       
   204         * @param aUpdateConnection Indicates new connection or update for existing connection
       
   205         * @return void
       
   206         */
       
   207         void HandleConnectL( TAccPolGenericID& aGenericId,
       
   208                              TUint aCallerThreadID, 
       
   209                              TBool aEvaluateConnectionRules,
       
   210                              TBool aUpdateConnection );
       
   211 
       
   212         /**
       
   213         * Handle possible single connection and multiple connection status.
       
   214         * changes after a change of critical capability value.
       
   215         *
       
   216         * @since S60 3.1
       
   217         * @param aGenericID Generic ID of the connected accessory.
       
   218         * @return void
       
   219         */
       
   220         void HandleConnectionChangeValidationL( const TAccPolGenericID& aGenericID );
       
   221 
       
   222         /**
       
   223         * Start to handle accessory disconnection according to given Generic ID
       
   224         *
       
   225         * @since S60 3.1
       
   226         * @param aGenericID Generic ID of the disconnected accessory
       
   227         * @return void
       
   228         */
       
   229         void HandleDisconnectL( const TAccPolGenericID& aGenericId );
       
   230 
       
   231         /**
       
   232         * Get handle to Server Model.
       
   233         * @since S60 3.1
       
   234         * @return void
       
   235         */
       
   236         CAccSrvServerModel& ServerModel() const;
       
   237 
       
   238         /**
       
   239         * Get handle to Notification Queue.
       
   240         * @since S60 3.1
       
   241         * @return void
       
   242         */
       
   243         CAccSrvNotificationQueue& NotificationQueue() const;
       
   244 
       
   245         /**
       
   246         * Get handle to ASY Proxy Handler.
       
   247         * @since S60 3.1
       
   248         * @return void
       
   249         */
       
   250         CAccSrvASYProxyHandler& ASYProxyHandler() const;
       
   251 
       
   252         /**
       
   253         * Get handle to Settings Handler.
       
   254         * @since S60 3.1
       
   255         * @return void
       
   256         */
       
   257         CAccSrvSettingsHandler& SettingsHandler() const;
       
   258 
       
   259         /**
       
   260         * Get handle to Accessory Policy.
       
   261         * @since S60 3.1
       
   262         * @return void
       
   263         */
       
   264         CAccPolAccessoryPolicy& Policy() const;
       
   265 
       
   266         /**
       
   267         * Accessory Connection Status and Accessory Mode asynchronous client
       
   268         * requests are completed. Used when ASYs are loaded.
       
   269         * @since S60 3.1
       
   270         * @return void
       
   271         */
       
   272         void InitializeConnectionStatusL();
       
   273 
       
   274     public: // Functions from base classes
       
   275 
       
   276         /**
       
   277         * From MAccSrvConnectionControllerObserver
       
   278         */
       
   279         void HandleConnectionStatusChangedL();
       
   280 
       
   281         /**
       
   282         * From MAccSrvConnectionControllerObserver
       
   283         */
       
   284         void HandleAccessoryModeChangedL( TInt aDbId = KErrUnknown,
       
   285                                           TBool aAudioOutputStatus = EFalse );
       
   286 
       
   287         /**
       
   288         * From MAccSrvConnectionControllerObserver
       
   289         */
       
   290         void HandleConnectValidationL( const TAccPolGenericID& aGenericId,
       
   291                                        const CAccSrvConnectionHandler* aCaller,
       
   292                                        TInt aError );
       
   293 
       
   294         /**
       
   295         * From MAccSrvConnectionControllerObserver
       
   296         */
       
   297 		void HandleConnectionUpdateValidationL( const TAccPolGenericID& aGenericID, 
       
   298 												TAccPolGenericID& aOldGenericId,
       
   299 												const CAccSrvConnectionHandler* aCaller, 
       
   300 												TInt aError  );
       
   301         
       
   302         
       
   303         /**
       
   304         * From MAccSrvConnectionControllerObserver
       
   305         */
       
   306 		void ConnectionHandlingCancel( const CAccSrvConnectionHandler* aCaller);        
       
   307 
       
   308 
       
   309         /**
       
   310         * From MAccSrvConnectionControllerObserver
       
   311         */
       
   312         void RegisterControlMessageL( TMsgID aMsgID,
       
   313                                       MQueueObserver* aCallback );
       
   314 
       
   315         /**
       
   316         * From MAccSrvConnectionControllerObserver
       
   317         */
       
   318         void CancelControlMessage( TMsgID aMsgID,
       
   319                                       MQueueObserver* aCallback );
       
   320 
       
   321         /**
       
   322         * From MAccSrvConnectionControllerObserver
       
   323         */
       
   324         TInt HandleASYCommsL( TProcessCmdId aCmdId,
       
   325                               TASYCommandParamRecord& aASYCommandParamRecord,
       
   326                               TPtr8* aPtrBuf=NULL );
       
   327 
       
   328         /**
       
   329         * From MAccSrvConnectionControllerObserver
       
   330         */
       
   331        CAccSrvServerModel& ServerModelHandle();
       
   332 
       
   333         /**
       
   334         * From MAccSrvConnectionControllerObserver
       
   335         */
       
   336 		void SetDefaultAccessoryInformation( const TAccPolGenericID& aGenericID, 
       
   337 													 const TUint32 aDefaultValue);
       
   338 
       
   339         /**
       
   340         * From CActive
       
   341         */
       
   342         void RunL();
       
   343         void DoCancel();
       
   344 
       
   345     protected:  // New functions
       
   346 
       
   347     protected:  // Functions from base classes
       
   348 
       
   349     private:
       
   350 
       
   351         /**
       
   352         * C++ default constructor.
       
   353         */
       
   354         CAccSrvConnectionController();
       
   355 
       
   356         /**
       
   357         * By default Symbian 2nd phase constructor is private.
       
   358         */
       
   359         void ConstructL( CAccSrvServerModel* aServerModel );
       
   360 
       
   361         /**
       
   362         * Change accessory connection status to Connected.
       
   363         */
       
   364         void PromoteToConnectedL( const TAccPolGenericID& aGenericID );
       
   365 
       
   366         /**
       
   367         * Change accessory connection status to Detected.
       
   368         */
       
   369         void LowerToDetectedL( const TAccPolGenericID& aGenericID );
       
   370 
       
   371     public:     // Data
       
   372 
       
   373     protected:  // Data
       
   374 
       
   375     private:    // Data
       
   376 
       
   377         CAccPolAccessoryPolicy*                 iPolicy;                 //Owned
       
   378         CAccSrvServerModel*                     iServerModel;            //Not Owned
       
   379         CAccSrvNotificationQueue*               iNotificationQueue;      //Owned
       
   380         CAccSrvConnectionStatusHandler*         iConnectionStatusHandler;//Owned
       
   381         CAccSrvModeHandler*                     iModeHandler;            //Owned
       
   382         CAccSrvASYProxyHandler*                 iASYProxyHandler;        //Owned
       
   383         CAccSrvSettingsHandler*                 iSettingsHandler;        //Owned
       
   384         CAccSrvChargingContextController*       iChargingContextController; //Owned
       
   385         RPointerArray<CAccSrvConnectionHandler> iConnectionHandler;      //Owned
       
   386 
       
   387 	    TUint32                                 iInformationNoteUID;	  
       
   388 	    TUint32                                 iInformationNoteDefault;
       
   389 
       
   390         // Indicates should accfw show notes about connected accessory. This is 
       
   391         // set to ETrue when accessory is connected and EFalse after note is shown.
       
   392         // The reason for this is to prevent multiple notes one after another
       
   393         TBool                                   iShowNotes;
       
   394         CAccSrvWiredConnectionPublisher*        iWiredConnPublisher; // Owned
       
   395 
       
   396 		// Ui notifier
       
   397 		RNotifier iNotifier;
       
   398 		
       
   399 		// Response data from notifier
       
   400 		TInt iReplyValue;
       
   401 		TPckg<TInt> iReplyPck;
       
   402 	
       
   403     public:     // Friend classes
       
   404 
       
   405     protected:  // Friend classes
       
   406 
       
   407     private:    // Friend classes
       
   408   };
       
   409 
       
   410 #endif      // CACCSRVCONNECTIONCONTROLLER_H
       
   411 
       
   412 // End of File