usbengines/usbotgwatcher/inc/cusbotgwatcher.h
branchRCL_3
changeset 20 a15c582fbf97
parent 13 7068aba64af5
child 21 ff9df6630274
equal deleted inserted replaced
13:7068aba64af5 20:a15c582fbf97
     1 /*
     1 /*
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3  * All rights reserved.
     4 * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     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:  OTG watcher state machine owner
       
    15  *
     8  *
    16 */
     9  * Initial Contributors:
    17 
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description:  OTG watcher state machine owner
       
    15  *
       
    16  */
    18 
    17 
    19 #ifndef C_USBOTGWATCHER_H
    18 #ifndef C_USBOTGWATCHER_H
    20 #define C_USBOTGWATCHER_H
    19 #define C_USBOTGWATCHER_H
    21 
    20 
    22 #include <e32base.h>
    21 #include <e32base.h>
    86     // Methods to change state to be called only by CUsbStates children
    85     // Methods to change state to be called only by CUsbStates children
    87     friend class CUsbState;
    86     friend class CUsbState;
    88     friend class CtUsbOtgWatcher;
    87     friend class CtUsbOtgWatcher;
    89 
    88 
    90 public:
    89 public:
       
    90 
    91     /**
    91     /**
    92      * Two-phased constructor.
    92      * Two-phased constructor.
    93      * @param aUsb usbman API
    93      * @param aUsb usbman API
    94      */
    94      */
    95     IMPORT_C static CUsbOtgWatcher* NewL(RUsb& aUsb);
    95     IMPORT_C
       
    96     static CUsbOtgWatcher* NewL(RUsb& aUsb);
    96 
    97 
    97     /**
    98     /**
    98      * Check ID-Pin state
    99      * Check ID-Pin state
    99      * @return ETrue if the ID-Pin is present (A-Device)
   100      * @return ETrue if the ID-Pin is present (A-Device)
   100      */
   101      */
   101     IMPORT_C TBool IsDeviceA();
   102     IMPORT_C
       
   103     TBool IsDeviceA();
   102 
   104 
   103     /**
   105     /**
   104      * Destructor.
   106      * Destructor.
   105      */
   107      */
   106     IMPORT_C virtual ~CUsbOtgWatcher();
   108     IMPORT_C virtual ~CUsbOtgWatcher();
   157      */
   159      */
   158     void IdPinOnL();
   160     void IdPinOnL();
   159     /**
   161     /**
   160      * Id Pin On
   162      * Id Pin On
   161      * @param aError
   163      * @param aError
   162      */    
   164      */
   163     void IdPinErrorL(TInt aError);
   165     void IdPinErrorL(TInt aError);
   164 
   166 
   165     // From VBus observer
   167     // From VBus observer
   166     /**
   168     /**
   167      * VBus down
   169      * VBus down
   223      */
   225      */
   224     void BusActiveL();
   226     void BusActiveL();
   225     /**
   227     /**
   226      * error
   228      * error
   227      * @param aError error happened
   229      * @param aError error happened
   228      */    
   230      */
   229     void BusActivityErrorL(TInt aError);
   231     void BusActivityErrorL(TInt aError);
   230 
   232 
   231     // From Host Event notification observer
   233     // From Host Event notification observer
   232     /**
   234     /**
   233      * Device is attached
   235      * Device is attached
   255      */
   257      */
   256     void DriverLoadFailureL(TDeviceEventInformation aInfo);
   258     void DriverLoadFailureL(TDeviceEventInformation aInfo);
   257     /**
   259     /**
   258      * Error happened during observing
   260      * Error happened during observing
   259      * @param aError error code
   261      * @param aError error code
   260      */    
   262      */
   261     void HostEventNotificationErrorL(TInt aError);
   263     void HostEventNotificationErrorL(TInt aError);
   262 
   264 
   263     // From message notification observer
   265     // From message notification observer
   264     /**
   266     /**
   265      * Message received
   267      * Message received
   283      */
   285      */
   284     void SessionRequestedL();
   286     void SessionRequestedL();
   285     /**
   287     /**
   286      * Error handler
   288      * Error handler
   287      * @param error code
   289      * @param error code
   288      */    
   290      */
   289     void MessageNotificationErrorL(TInt aError);
   291     void MessageNotificationErrorL(TInt aError);
   290     
   292 
   291     // From CUsbServiceControl
   293     // From CUsbServiceControl
   292     /**
   294     /**
   293      * called when request for usb services is completed
   295      * called when request for usb services is completed
   294      * if there were few requests in a row, during operation, 
   296      * if there were few requests in a row, during operation, 
   295      * only the last one's completion is notified
   297      * only the last one's completion is notified
   346      * @return notif manager
   348      * @return notif manager
   347      */
   349      */
   348     CUsbNotifManager* NotifManager();
   350     CUsbNotifManager* NotifManager();
   349     /**
   351     /**
   350      * @return Handle state 
   352      * @return Handle state 
       
   353      * @param aStateId state id 
   351      */
   354      */
   352     CUsbStateHostHandle* HostHandle(TUsbStateIds aStateId) const;
   355     CUsbStateHostHandle* HostHandle(TUsbStateIds aStateId) const;
   353 
   356 
   354     /**
   357     /**
   355      * Handles problems in host functioning
   358      * Handles problems in host functioning
   356      * @param aWhatKindOf problem Id to be handled
   359      * @param aWhatKindOf problem Id to be handled
       
   360      * @param aInState state id where to handle
   357      */
   361      */
   358     void HandleHostProblemL(TInt aWhatKindOf, TUsbStateIds aInState);
   362     void HandleHostProblemL(TInt aWhatKindOf, TUsbStateIds aInState);
   359     
   363 
   360     /**
   364     /**
   361      * Add observer to USb Otg state machine
   365      * Add observer to USb Otg state machine
   362      * @param aObserver Observer
   366      * @param aObserver Observer
   363      */
   367      */
   364     void SubscribeL(MUsbOtgWatcherStateObserver& aObserver);
   368     void SubscribeL(MUsbOtgWatcherStateObserver& aObserver);
   371 
   375 
   372     /**
   376     /**
   373      * Used for test purposes
   377      * Used for test purposes
   374      */
   378      */
   375     void PrintStateToLog();
   379     void PrintStateToLog();
   376     
   380 
   377 private:
   381 private:
   378 
   382 
   379     /**
   383     /**
   380      * Default constructor
   384      * Default constructor
   381      * @param aUsb usbman API 
   385      * @param aUsb usbman API 
   403      * Changes host's state machine state
   407      * Changes host's state machine state
   404      *
   408      *
   405      * @param aNewStateId new host state (id)
   409      * @param aNewStateId new host state (id)
   406      */
   410      */
   407     void ChangeHostStateL(TUsbStateIds aNewStateId);
   411     void ChangeHostStateL(TUsbStateIds aNewStateId);
   408     
   412 
   409     /**
   413     /**
   410      * Used for test purposes
   414      * Used for test purposes
   411      * @return KErrNone if test is OK, otherwise errorcode
   415      * @return KErrNone if test is OK, otherwise errorcode
   412      */
   416      */
   413      TInt SelfTestL();
   417     TInt SelfTestL();
   414 
   418 
   415 private:
   419 private:
   416     // data
   420     // data
   417 
   421 
   418     /**
   422     /**
   489      * usb service control
   493      * usb service control
   490      * Starts and stops usb service, changes personalities 
   494      * Starts and stops usb service, changes personalities 
   491      * Own.  
   495      * Own.  
   492      */
   496      */
   493     CUsbServiceControl* iUsbServiceControl;
   497     CUsbServiceControl* iUsbServiceControl;
   494     
   498 
   495     /**
   499     /**
   496      * The observer reports state changes to its own observers
   500      * The observer reports state changes to its own observers
   497      * Not Own
   501      * Not Own
   498      */
   502      */
   499     RPointerArray<MUsbOtgWatcherStateObserver> iOtgStateObservers;
   503     RPointerArray<MUsbOtgWatcherStateObserver> iOtgStateObservers;
       
   504 
       
   505     /**
       
   506      * The observer reports state changes to its own observers
       
   507      * Not Own
       
   508      */
       
   509     CUsbServiceControl::TUsbServiceRequest iUsbServiceRequest;
   500     };
   510     };
   501 
   511 
   502 #endif //  C_USBOTGWATCHER_H
   512 #endif //  C_USBOTGWATCHER_H