localconnectivityservice/dun/plugins/inc/usb/DunUsbListen.h
branchRCL_3
changeset 20 4a793f564d72
parent 19 0aa8cc770c8a
child 21 74aa6861c87d
equal deleted inserted replaced
19:0aa8cc770c8a 20:4a793f564d72
     1 /*
       
     2 * Copyright (c) 2006-2007 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:  DUN USB plugin's listener
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_CDUNUSBLISTEN_H
       
    20 #define C_CDUNUSBLISTEN_H
       
    21 
       
    22 #include <e32std.h>
       
    23 #include <c32comm.h>
       
    24 #include <usbman.h>
       
    25 #include "DunPlugin.h"
       
    26 
       
    27 enum TUsbListenState
       
    28     {
       
    29     EUsbListenStateIdle,
       
    30     EUsbListenStateListening
       
    31     };
       
    32 
       
    33 /**
       
    34  *  DUN USB plugin's listener class
       
    35  *  This class starts listening for USB device state to change to configured.
       
    36  *  When change to configured is detected, parent (CDunUsbPlugin) is notified
       
    37  *  to create a channel. Also when device state is no longer configured,
       
    38  *  parent (CDunUsbPlugin) is notified to remove a channel.
       
    39  *
       
    40  *  @lib dunusb.lib
       
    41  *  @since S60 v3.2
       
    42  */
       
    43 NONSHARABLE_CLASS( CDunUsbListen ) : public CActive
       
    44     {
       
    45 
       
    46 public:
       
    47 
       
    48     /**
       
    49      * Two-phased constructor.
       
    50      * @param aServer Server
       
    51      * @param aParent Creator of this instance
       
    52      * @param aUsbServer USB server
       
    53      * @return Instance of self
       
    54      */
       
    55     static CDunUsbListen* NewL( MDunServerCallback* aServer,
       
    56                                 MDunListenCallback* aParent,
       
    57                                 RUsb& aUsbServer );
       
    58 
       
    59     /**
       
    60     * Destructor.
       
    61     */
       
    62     virtual ~CDunUsbListen();
       
    63 
       
    64     /**
       
    65      * Resets data to initial values
       
    66      *
       
    67      * @since S60 3.2
       
    68      * @return None
       
    69      */
       
    70     void ResetData();
       
    71 
       
    72     /**
       
    73      * IssueRequest to USB server for device state change notifications
       
    74      *
       
    75      * @return KErrAlreadyExists if device state configured,
       
    76      *         KErrNone otherwise
       
    77      */
       
    78     TInt IssueRequestL();
       
    79 
       
    80     /**
       
    81      * Stops listening
       
    82      *
       
    83      * @since S60 3.2
       
    84      * @return Symbian error code on error, KErrNone otherwise
       
    85      */
       
    86     TInt Stop();
       
    87 
       
    88 private:
       
    89 
       
    90     CDunUsbListen( MDunServerCallback* aServer,
       
    91                    MDunListenCallback* aParent,
       
    92                    RUsb& aUsbServer );
       
    93 
       
    94     void ConstructL();
       
    95 
       
    96     /**
       
    97      * Initializes this class
       
    98      *
       
    99      * @since S60 3.2
       
   100      * @return None
       
   101      */
       
   102     void Initialize();
       
   103 
       
   104     /**
       
   105      * Activates listening request
       
   106      *
       
   107      * @since S60 3.2
       
   108      * @return KErrNotReady if already active, KErrNone otherwise
       
   109      */
       
   110     TInt Activate();
       
   111 
       
   112 // from base class CActive
       
   113 
       
   114     /**
       
   115      * From CActive.
       
   116      * Called when read or write operation is ready.
       
   117      *
       
   118      * @since S60 3.2
       
   119      * @return None
       
   120      */
       
   121     void RunL();
       
   122 
       
   123     /**
       
   124      * From CActive.
       
   125      * Cancel current activity.
       
   126      *
       
   127      * @return None
       
   128      */
       
   129     void DoCancel();
       
   130 
       
   131 private:  // data
       
   132 
       
   133     /**
       
   134      * Callback to call when notification via MDunServerCallback to be made
       
   135      * Not own.
       
   136      */
       
   137     MDunServerCallback* iServer;
       
   138 
       
   139     /**
       
   140      * Callback to call when notification via MDunListenCallback to be made
       
   141      * Not own.
       
   142      */
       
   143     MDunListenCallback* iParent;
       
   144 
       
   145     /**
       
   146      * Current state of listening: active or inactive
       
   147      */
       
   148     TUsbListenState iListenState;
       
   149 
       
   150     /**
       
   151      * USB server (USB manager) needed for device state notifications
       
   152      * Device states needed to create transporter channel
       
   153      */
       
   154     RUsb& iUsbServer;
       
   155 
       
   156     /**
       
   157      * Device state of USB set when RUsb::DeviceStateNotification completes
       
   158      */
       
   159     TUsbDeviceState iDeviceState;
       
   160 
       
   161     /**
       
   162      * Previous state of USB set when RUsb::DeviceStateNotification completes
       
   163      */
       
   164     TUsbDeviceState iDeviceStatePrev;
       
   165 
       
   166     };
       
   167 
       
   168 #endif  // C_CDUNUSBLISTEN_H