mmappcomponents/harvester/server/inc/mpxusbeventhandler.h
changeset 0 a2952bb97e68
child 14 05b0d2323768
equal deleted inserted replaced
-1:000000000000 0:a2952bb97e68
       
     1 /*
       
     2 * Copyright (c) 2006 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 USB events
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMPXUSBEVENTHANDLER_H
       
    20 #define CMPXUSBEVENTHANDLER_H
       
    21 
       
    22 #include <usbman.h>
       
    23 #include <mpxpskeyobserver.h>
       
    24 #include "mpxsystemeventobserver.h"
       
    25 
       
    26 class CMPXPSKeyWatcher;
       
    27 
       
    28 /**
       
    29  *  USB Monitoring class
       
    30  *
       
    31  *  @lib mpxharvesterserver.exe
       
    32  *  @since S60 3.0
       
    33  */
       
    34 NONSHARABLE_CLASS( CMPXUsbEventHandler ) : public CActive,
       
    35                                            public MMPXPSKeyObserver
       
    36     {
       
    37 public:
       
    38 
       
    39     /**
       
    40     * Two-phase constructor
       
    41     * @param aObserver observer to the event handler
       
    42     */
       
    43     static CMPXUsbEventHandler* NewL( MMPXSystemEventObserver& aObserver );
       
    44 
       
    45     /**
       
    46     * Two-phase constructor
       
    47     * @param aObserver observer to the event handler
       
    48     */
       
    49     static CMPXUsbEventHandler* NewLC( MMPXSystemEventObserver& aObserver );
       
    50 
       
    51     /**
       
    52     * Virtual destructor
       
    53     */
       
    54     virtual ~CMPXUsbEventHandler();
       
    55 
       
    56 public:
       
    57 
       
    58     /**
       
    59     * Polls for the current monitor status
       
    60     * If an event is happening, it will callback the observer of the event
       
    61     */
       
    62     void PollStatus();
       
    63 
       
    64 protected: // From Base Class
       
    65 
       
    66     /**
       
    67     * From CActive
       
    68     */
       
    69     void RunL();
       
    70     void DoCancel();
       
    71 
       
    72     /**
       
    73     * From MMPXPSKeyObserver
       
    74     */
       
    75     void HandlePSEvent( TUid aUid, TInt aKey );
       
    76 
       
    77 private: // New Methods
       
    78 
       
    79     /**
       
    80     * Handle the PS Key event
       
    81     * @param aUid UID of the key
       
    82     * @param aKey ID of the key
       
    83     */
       
    84     void DoHandlePSEventL( TUid aUid, TInt aKey );
       
    85     
       
    86     /**
       
    87      * Connect to usbman.
       
    88      * If error, default iDeviceState to EUsbDeviceStateConfigured so this would not
       
    89      * block usb event mode change.
       
    90      */
       
    91     void ConnectUsbMan();
       
    92 
       
    93 private:
       
    94 
       
    95     /**
       
    96     *  C++ constructor
       
    97     */
       
    98     CMPXUsbEventHandler( MMPXSystemEventObserver& aObserver );
       
    99 
       
   100     /*
       
   101     * Second phased constructor
       
   102     */
       
   103     void ConstructL();
       
   104 
       
   105 private: // data
       
   106 
       
   107     CMPXPSKeyWatcher*  iPSKeyWatcher;  // PS key watcher for USB PS key
       
   108     CMPXPSKeyWatcher*  iMTPKeyWatcher; // PS key watcher for MTP PS key
       
   109     TBool              iWasMtp;        // Was the operation Mass Storage or MTP
       
   110 
       
   111     /*
       
   112     * Observer interface to callback to an observer
       
   113     */
       
   114     MMPXSystemEventObserver& iObserver;
       
   115     TInt iState;
       
   116     TBool iMTPActive;
       
   117     
       
   118     RUsb            iUsbMan;
       
   119     TUsbDeviceState iDeviceState;
       
   120     TBool           iUsbManConnected;
       
   121     };
       
   122 
       
   123 #endif // CMPXUSBEVENTHANDLER_H