usbengines/usbotgwatcher/inc/cusbservicecontrol.h
changeset 0 1e05558e2206
child 3 47c263f7e521
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:  Implementation 
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_USBSERVICECONTROL_H
       
    20 #define C_USBSERVICECONTROL_H
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 class RUsb;
       
    25 
       
    26 /**
       
    27  *  usb service control observer interface, to get feedback on usb service state change
       
    28  *
       
    29  */
       
    30 NONSHARABLE_CLASS( MUsbServiceControlObserver)
       
    31     {
       
    32 public:
       
    33 
       
    34     /**
       
    35      * called when request for usb services is completed
       
    36      * if there were few requests in a row, during operation, 
       
    37      * only the last one's completion is notified
       
    38      * @param aError error code
       
    39      */
       
    40     virtual void UsbServiceControlReqCompletedL(TInt aError) = 0;
       
    41 
       
    42     };
       
    43 
       
    44 /**
       
    45  *  This class implements starting/stopping usb services 
       
    46  *
       
    47  */
       
    48 NONSHARABLE_CLASS( CUsbServiceControl ) : public CActive
       
    49     {
       
    50 
       
    51 public:
       
    52 
       
    53     /**
       
    54      * Two-phased constructor.
       
    55      * @param aObserver Observer
       
    56      * @param aUsb RUsb API
       
    57      */
       
    58     static CUsbServiceControl* NewL(MUsbServiceControlObserver* aObserver,
       
    59             RUsb& aUsb);
       
    60 
       
    61     /**
       
    62      * Destructor.
       
    63      */
       
    64     virtual ~CUsbServiceControl();
       
    65 
       
    66     /**
       
    67      * Starts usb service. When service is started call back function 
       
    68      * MUsbServiceControlObserver::UsbServiceStarted will be called.
       
    69      * Client should not worry is usb service already started, or not,
       
    70      * and which one personality is started. Just request this API 
       
    71      * @param aPersonalityId personality id (required by RUsb API to start usb services) 
       
    72      * @return error code
       
    73      */
       
    74     TInt Start(TInt aPersonalityId);
       
    75 
       
    76     /**
       
    77      * Stops service. When service is stopped call back function 
       
    78      * MUsbServiceControlObserver::UsbServiceStopped will be called
       
    79      * @return error code
       
    80      */
       
    81     TInt Stop();
       
    82 
       
    83 public:
       
    84 
       
    85     // from base class CActive
       
    86     /**
       
    87      * Called when request is completed
       
    88      */
       
    89     void RunL();
       
    90 
       
    91     /**
       
    92      * called when RunL leaves
       
    93      * @param aError error code
       
    94      * @return error code
       
    95      */
       
    96     TInt RunError(TInt aError);
       
    97 
       
    98     /**
       
    99      * Called when request is cancelled
       
   100      */
       
   101     void DoCancel();
       
   102 
       
   103 private:
       
   104 
       
   105     /**
       
   106      * Default constructor
       
   107      * @param aObserver receives call back when service started or stopped
       
   108      * @param aUsb usbman API
       
   109      */
       
   110     CUsbServiceControl(MUsbServiceControlObserver* aObserver, RUsb& aUsb);
       
   111 
       
   112     /**
       
   113      * 2nd phase construction
       
   114      */
       
   115     void ConstructL();
       
   116 
       
   117 private:
       
   118 
       
   119     /**
       
   120      * Observer
       
   121      * not own
       
   122      */
       
   123     MUsbServiceControlObserver* iObserver;
       
   124 
       
   125     /**
       
   126      * RUsb API
       
   127      */
       
   128     RUsb& iUsb;
       
   129 
       
   130     /**
       
   131      * personality ID, to be started
       
   132      */
       
   133     TInt iPersonalityId;
       
   134 
       
   135     /**
       
   136      * Service state
       
   137      */
       
   138     TUsbServiceState iServiceState; // required as a parameter for service states notifications 
       
   139 
       
   140     };
       
   141 
       
   142 #endif //  C_USBSTATEHOSTAHANDLE_H