usbengines/usbotgwatcher/inc/cusbhosteventnotificationobserver.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:  Monitors host events
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_USBHOSTEVENTNOTIFICATIONOBSERVER_H
       
    20 #define C_USBHOSTEVENTNOTIFICATIONOBSERVER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <e32property.h>
       
    24 #include <usbotgdefs.h>
       
    25 #include <usbhostdefs.h>
       
    26 
       
    27 class RUsb;
       
    28 
       
    29 /**
       
    30  *  Observer must implement this interface to get notifications
       
    31  *
       
    32  */
       
    33 NONSHARABLE_CLASS( MUsbHostEventNotificationObserver)
       
    34     {
       
    35 public:
       
    36 
       
    37     /**
       
    38      *  Called when device is attached
       
    39      *  @param aInfo additional information
       
    40      */
       
    41     virtual void DeviceAttachedL(TDeviceEventInformation aInfo) = 0;
       
    42 
       
    43     /**
       
    44      *  Called when device is detached
       
    45      *  @param aInfo additional information
       
    46      */
       
    47     virtual void DeviceDetachedL(TDeviceEventInformation aInfo) = 0;
       
    48 
       
    49     /**
       
    50      *  Called when drivers are loaded
       
    51      *  @param aInfo additional information
       
    52      */
       
    53     virtual void DriverLoadSuccessL(TDeviceEventInformation aInfo) = 0;
       
    54 
       
    55     /**
       
    56      *  Called when drivers are loaded partially
       
    57      *  @param aInfo additional information
       
    58      */
       
    59     virtual void DriverLoadPartialSuccessL(TDeviceEventInformation aInfo) = 0;
       
    60 
       
    61     /**
       
    62      *  Called when drivers loading failed
       
    63      *  @param aInfo additional information
       
    64      */
       
    65     virtual void DriverLoadFailureL(TDeviceEventInformation aInfo) = 0;
       
    66     
       
    67     /**
       
    68       *  Called when error happens while observing
       
    69       *  @param aError error code
       
    70       */
       
    71     virtual void HostEventNotificationErrorL(TInt aError) = 0;
       
    72 
       
    73     };
       
    74 
       
    75 /**
       
    76  *  Class observes USB Notifications
       
    77  */
       
    78 NONSHARABLE_CLASS( CUsbHostEventNotificationObserver ) : public CActive
       
    79     {
       
    80 
       
    81 public:
       
    82 
       
    83     /**
       
    84      * Two-phased constructor.
       
    85      * @param aUsb usbman
       
    86      * @return this class instance
       
    87      */
       
    88     static CUsbHostEventNotificationObserver* NewL(RUsb* aUsb);
       
    89 
       
    90     /**
       
    91      * Destructor.
       
    92      */
       
    93     virtual ~CUsbHostEventNotificationObserver();
       
    94 
       
    95     /**
       
    96      * Add observer to list of observers
       
    97      * @param aObserver observer
       
    98      */
       
    99     void SubscribeL(MUsbHostEventNotificationObserver* aObserver);
       
   100 
       
   101     /**
       
   102      * Removes observer from list of observers 
       
   103      * @param aObserver Observer
       
   104      */
       
   105     void UnsubscribeL(MUsbHostEventNotificationObserver* aObserver);
       
   106 
       
   107 private:
       
   108 
       
   109     // From CActive
       
   110     /**
       
   111      * Called when request completed
       
   112      */
       
   113     void RunL();
       
   114 
       
   115     /**
       
   116      * Called when outstanding request cancelled
       
   117      */
       
   118     void DoCancel();
       
   119 
       
   120     /**
       
   121      * Called when RunL leaves
       
   122      * @param aError errorcode from RunL
       
   123      * @return aError errorcode
       
   124      */
       
   125     TInt RunError(TInt aError);
       
   126 
       
   127 private:
       
   128 
       
   129     /**
       
   130      * Default constructor.
       
   131      * @param aUsb usbman
       
   132      */
       
   133     CUsbHostEventNotificationObserver(RUsb* aUsb);
       
   134 
       
   135     /**
       
   136      * 2nd phase constructor.
       
   137      */
       
   138     void ConstructL();
       
   139 
       
   140 private:
       
   141     // data
       
   142 
       
   143     /**
       
   144      * The observer reports changes to own observers
       
   145      * Owns
       
   146      */
       
   147     RPointerArray<MUsbHostEventNotificationObserver> iObservers;
       
   148 
       
   149     /**
       
   150      * Notifications come from USB
       
   151      * Not own
       
   152      */
       
   153     RUsb* iUsb;
       
   154 
       
   155     /**
       
   156      * Info from notification comes to this member
       
   157      */
       
   158     TDeviceEventInformation iEventInfo;
       
   159 
       
   160     };
       
   161 
       
   162 #endif //  C_USBHOSTEVENTNOTIFICATIONOBSERVER_H