accessoryservices/headsetstatusapi/Inc/CHeadsetStatusObserver.h
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2005 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: 
       
    15 *     CHeadsetStatusObserver functionality.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __HEADSETOBSERVER_H__
       
    21 #define __HEADSETOBSERVER_H__
       
    22 
       
    23 #ifdef __ACCESSORY_FW
       
    24 
       
    25 // INCLUDES
       
    26 #include <e32base.h>
       
    27 #include <AccPolAccessoryMode.h>
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class MHeadsetStatusObserver;
       
    31 class RAccessoryMode;
       
    32 
       
    33 // CLASS DECLARATION
       
    34 
       
    35 /**
       
    36 *   Active object for receiving asynchronous requests
       
    37 *   from accessory mode change events.
       
    38 *   Only enabled with __ACCESSORY_FW flag set.
       
    39 */
       
    40 NONSHARABLE_CLASS( CHeadsetStatusObserver ): public CActive
       
    41     {
       
    42     public:     // Constructors & destructors
       
    43        
       
    44         /**
       
    45         * Destructor 
       
    46         */
       
    47         ~CHeadsetStatusObserver();
       
    48 
       
    49         /**
       
    50         * Symbian two phased constructor.
       
    51         */
       
    52         static CHeadsetStatusObserver* NewL( RAccessoryMode& aAccMode );
       
    53 
       
    54     public:     // New methods
       
    55     
       
    56         /**
       
    57         * Sets observer through headset status notifications are received.
       
    58         * @param    aObserver: Observer
       
    59         * @return   None
       
    60         */
       
    61         void SetObserver( MHeadsetStatusObserver* aObserver );
       
    62         
       
    63         /**
       
    64         * Activates observing through RAccessoryMode.
       
    65         * Method will panic if already active.
       
    66         * @param    None
       
    67         * @return   None
       
    68         */
       
    69         void StartObserving();
       
    70         
       
    71     private:  // From base classes
       
    72     
       
    73         // From CActive
       
    74         void RunL();
       
    75         
       
    76         // From CActive
       
    77         void DoCancel();
       
    78     
       
    79         // From CActive
       
    80         TInt RunError( TInt aError );
       
    81         
       
    82     private:    // New methods
       
    83     
       
    84         // Notifies observer from headset status change
       
    85         void NotifyObserverL();
       
    86         
       
    87         // Notifies observer from error
       
    88         void NotifyObserverError( TInt aError );
       
    89                 
       
    90     private: 
       
    91         
       
    92         /**
       
    93         * Default Constructor 
       
    94         */
       
    95         CHeadsetStatusObserver( RAccessoryMode& aAccMode );
       
    96         
       
    97         /**
       
    98         * Symbian OS 2nd phase constructor 
       
    99         */
       
   100         void ConstructL();  
       
   101                
       
   102     private:
       
   103     
       
   104         // headset status observer, not owned
       
   105         MHeadsetStatusObserver* iObserver;
       
   106         
       
   107         // reference to RAccessoryMode, not owned
       
   108         RAccessoryMode& iAccMode;
       
   109         
       
   110         // accessory mode
       
   111         TAccPolAccessoryMode iAccPolMode;
       
   112     };
       
   113     
       
   114 #endif //__ACCESSORY_FW
       
   115 
       
   116 #endif //__HEADSETCONTAINER_H__
       
   117 
       
   118 // End of File