devicesrv_plat/headset_status_api/inc/HeadsetStatus.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 *     CHeadsetStatus functionality.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __HEADSET_H__
       
    21 #define __HEADSET_H__
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32base.h>
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class CHeadsetStatusContainer;
       
    28 
       
    29 // CLASS DECLARATION
       
    30 
       
    31 /**
       
    32 * Observer interface through headset status change events are notified.
       
    33 */
       
    34 class MHeadsetStatusObserver
       
    35     {
       
    36     public:     // New methods
       
    37     
       
    38         /**
       
    39         * Callback for headset status change notifications.
       
    40         * @param    aHeadsetConnected: ETrue if connected
       
    41         * @return   None
       
    42         */
       
    43         virtual void HeadsetStatusChangedL( TBool aHeadsetConnected ) = 0;
       
    44         
       
    45         /**
       
    46         * Callback for error situations.
       
    47         * @param    aError: Error code
       
    48         * @return   None
       
    49         */
       
    50         virtual void HeadsetStatusError( TInt aError ) = 0;
       
    51     
       
    52     protected:    // Deny deletion through this class
       
    53     
       
    54         /**
       
    55         * C++ destructor
       
    56         */
       
    57         virtual ~MHeadsetStatusObserver() {};
       
    58     };
       
    59 
       
    60 // CLASS DECLARATION
       
    61 
       
    62 /**
       
    63 *  API for checking the headset status.
       
    64 *  This implementation is a wrapper that encapsulates internal interface 
       
    65 *  for extended SDK
       
    66 *  
       
    67 *  Usage:
       
    68 *  Include HeadsetStatus.h and link against HeadsetStatus.lib
       
    69 *
       
    70 *  Note:
       
    71 *  If you intend to call HeadsetConnectedL more than once it is more efficient
       
    72 *  to declare the instance from CHeadsetStatus as a member variable and create it
       
    73 *  in ConstructL and delete it in destructor.
       
    74 *
       
    75 *  Observing is only enbaled in Series 60 3.1 with __ACCESSORY_FW flag enabled!
       
    76 *
       
    77 *  @code
       
    78 *  TBool connected( EFalse );
       
    79 *  CHeadsetStatus* wrapper = CHeadsetStatus::NewL();
       
    80 *  CleanupStack::PushL( wrapper );
       
    81 *  TInt err( wrapper->HeadsetConnectedL( connected ) );
       
    82 *  CleanupStack::PopAndDestroy( wrapper );
       
    83 *  @endcode
       
    84 */
       
    85 class CHeadsetStatus : public CBase 
       
    86     {
       
    87     public: // Constructors & destructors
       
    88        
       
    89         /**
       
    90         * Destructor 
       
    91         */
       
    92         IMPORT_C ~CHeadsetStatus();
       
    93 
       
    94         /**
       
    95         * Symbian two phased constructor.
       
    96         */
       
    97         IMPORT_C static CHeadsetStatus* NewL();
       
    98         
       
    99     public: // New methods
       
   100     
       
   101         /**
       
   102         * Used to query the headset connectivity status. 
       
   103         * @param    aState: Boolean value of headset status
       
   104         * @return   KErrNone if query succeeded, otherwise one of the
       
   105         *           system wide error codes.
       
   106         */
       
   107         IMPORT_C TInt HeadsetConnectedL( TBool& aState );
       
   108         
       
   109         /**
       
   110         * Sets observer through headset status notifications are received.
       
   111         * NULL pointer will lead to panic.
       
   112         * @param    aObserver: Observer
       
   113         * @return   None
       
   114         */
       
   115         IMPORT_C void SetObserver( MHeadsetStatusObserver* aObserver );
       
   116         
       
   117         /**
       
   118         * Starts observing headset status changes.
       
   119         * @param    None
       
   120         * @return   None
       
   121         */
       
   122         IMPORT_C void StartObserving();
       
   123         
       
   124         /**
       
   125         * Stops observing headset status changes.
       
   126         * This is not nessecary to be called in destructor.
       
   127         * Listening will be automatically stopped when CHeadsetStatus
       
   128         * object is deleted.
       
   129         * @param    None
       
   130         * @return   None
       
   131         */
       
   132         IMPORT_C void StopObserving();
       
   133         
       
   134         /**
       
   135         * Checks whether already observing.
       
   136         * @param    None
       
   137         * @return   ETrue if observing
       
   138         */
       
   139         IMPORT_C TBool IsObserving() const;
       
   140          
       
   141     private: 
       
   142         
       
   143         /**
       
   144         * Default Constructor 
       
   145         */
       
   146         CHeadsetStatus( );
       
   147         
       
   148         /**
       
   149         * Symbian OS 2nd phase constructor 
       
   150         */
       
   151         void ConstructL();  
       
   152          
       
   153     private:
       
   154     
       
   155         // headset container, owned
       
   156         CHeadsetStatusContainer* iContainer;
       
   157     };
       
   158 
       
   159 #endif //__HEADSET_H__
       
   160 
       
   161 // End of File