usbengines/usbotgwatcher/inc/cusbotgstateobserver.h
changeset 0 1e05558e2206
child 5 7068aba64af5
equal deleted inserted replaced
-1:000000000000 0:1e05558e2206
       
     1 /*
       
     2 * Copyright (c) 2008-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:  Observes OTG states
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_USBOTGSTATEOBSERVER_H
       
    20 #define C_USBOTGSTATEOBSERVER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <e32property.h>
       
    24 #include <usbotgdefs.h>
       
    25 
       
    26 /**
       
    27  *  Observer need to implement this interface to get OTG state change notifications
       
    28  */
       
    29 NONSHARABLE_CLASS( MUsbOtgStateObserver)
       
    30     {
       
    31 public:
       
    32 
       
    33     /**
       
    34      * Local device is A, and get to Idle state
       
    35      */
       
    36     virtual void AIdleL() = 0;
       
    37 
       
    38     /**
       
    39      * Local device is A, and get to Host state
       
    40      */
       
    41     virtual void AHostL() = 0;
       
    42 
       
    43     /**
       
    44      * Local device is A, and get to Peripheral state
       
    45      */
       
    46     virtual void APeripheralL() = 0;
       
    47 
       
    48     /**
       
    49      * Local device is A, and get VBus error
       
    50      */
       
    51     virtual void AVBusErrorL() = 0;
       
    52 
       
    53     /**
       
    54      * Local device is B, and get to Idle state
       
    55      */
       
    56     virtual void BIdleL() = 0;
       
    57 
       
    58     /**
       
    59      * Local device is B, and get to Peripheral state
       
    60      */
       
    61     virtual void BPeripheralL() = 0;
       
    62 
       
    63     /**
       
    64      * Local device is B, and get to Host state
       
    65      */
       
    66     virtual void BHostL() = 0;
       
    67     
       
    68     /**
       
    69      * Error handler
       
    70      * @param aError error code
       
    71      */
       
    72     virtual void OtgStateErrorL(TInt aError) = 0;    
       
    73     };
       
    74 
       
    75 /**
       
    76  *  Class observes OTG State property
       
    77  *
       
    78  */
       
    79 NONSHARABLE_CLASS( CUsbOtgStateObserver ) : public CActive
       
    80     {
       
    81 
       
    82 public:
       
    83 
       
    84     /**
       
    85      * Two-phased constructor.
       
    86      */
       
    87     static CUsbOtgStateObserver* NewL();
       
    88 
       
    89     /**
       
    90      * Destructor.
       
    91      */
       
    92     virtual ~CUsbOtgStateObserver();
       
    93 
       
    94     /**
       
    95      * Gets current OTG state
       
    96      * @return OTG state
       
    97      */
       
    98     TUsbOtgState OtgState();
       
    99 
       
   100     /**
       
   101      * Subscribes for getting notifications
       
   102      * @param aObserver Observer
       
   103      */
       
   104     void SubscribeL(MUsbOtgStateObserver* aObserver);
       
   105 
       
   106     /**
       
   107      * Unsubscribes from getting notifications
       
   108      * @param aObserver Observer
       
   109      */
       
   110     void UnsubscribeL(MUsbOtgStateObserver* aObserver);
       
   111 
       
   112 private:
       
   113 
       
   114     // From CActive
       
   115     /**
       
   116      * Called when outstanding request completed
       
   117      *
       
   118      */
       
   119     void RunL();
       
   120 
       
   121     /**
       
   122      * Called when outstanding request is cancelled
       
   123      *
       
   124      */
       
   125     void DoCancel();
       
   126 
       
   127     /**
       
   128      * Called when RunL leaves
       
   129      *
       
   130      * @param errorcode
       
   131      * @return errorcode
       
   132      */
       
   133     TInt RunError(TInt aError);
       
   134 
       
   135 private:
       
   136 
       
   137     /**
       
   138      * Default constructor
       
   139      *
       
   140      */
       
   141     CUsbOtgStateObserver();
       
   142 
       
   143     /**
       
   144      * Second phase construction
       
   145      *
       
   146      */
       
   147     void ConstructL();
       
   148 
       
   149 private:
       
   150     // data
       
   151 
       
   152     /**
       
   153      * The observer reports state changes to own observers
       
   154      * Owns
       
   155      */
       
   156     RPointerArray<MUsbOtgStateObserver> iObservers;
       
   157 
       
   158     /**
       
   159      * The observer observes property change
       
   160      */
       
   161     RProperty iOtgState;
       
   162 
       
   163     };
       
   164 
       
   165 #endif //  C_USBOTGSTATEOBSERVER_H