mmappcomponents/harvester/server/inc/mpxconnectioneventhandler.h
changeset 32 edd273b3192a
equal deleted inserted replaced
27:cbb1bfb7ebfb 32:edd273b3192a
       
     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 CMPXCONNECTIONEVENTHANDLER_H
       
    20 #define CMPXCONNECTIONEVENTHANDLER_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( CMPXConnectionEventHandler ) : 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 CMPXConnectionEventHandler* NewL( MMPXSystemEventObserver& aObserver );
       
    44 
       
    45     /**
       
    46     * Two-phase constructor
       
    47     * @param aObserver observer to the event handler
       
    48     */
       
    49     static CMPXConnectionEventHandler* NewLC( MMPXSystemEventObserver& aObserver );
       
    50 
       
    51     /**
       
    52     * Virtual destructor
       
    53     */
       
    54     virtual ~CMPXConnectionEventHandler();
       
    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     void DoMSStartEventL();
       
    87     void DoMTPStartEventL();
       
    88     void DoMTPNotActiveEventL();
       
    89     
       
    90     /**
       
    91      * Connect to usbman.
       
    92      * If error, default iDeviceState to EUsbDeviceStateConfigured so this would not
       
    93      * block usb event mode change.
       
    94      */
       
    95     void ConnectUsbMan();
       
    96 
       
    97 private:
       
    98 
       
    99     /**
       
   100     *  C++ constructor
       
   101     */
       
   102     CMPXConnectionEventHandler( MMPXSystemEventObserver& aObserver );
       
   103 
       
   104     /*
       
   105     * Second phased constructor
       
   106     */
       
   107     void ConstructL();
       
   108 
       
   109 private: // data
       
   110     
       
   111     enum TMPXConnectionState
       
   112         {
       
   113         EMPXConnectionNone,
       
   114         EMPXConnectionMassStorage,
       
   115         EMPXConnectionMTPIdle,
       
   116         EMPXConnectionMTPActive
       
   117         };
       
   118 
       
   119     CMPXPSKeyWatcher*  iUSBKeyWatcher;  // PS key watcher for USB PS key
       
   120     CMPXPSKeyWatcher*  iMTPKeyWatcher; // PS key watcher for MTP PS key
       
   121 
       
   122     /*
       
   123     * Observer interface to callback to an observer
       
   124     */
       
   125     MMPXSystemEventObserver& iObserver;
       
   126     TInt iState;
       
   127     
       
   128     RUsb            iUsbMan;
       
   129     TUsbDeviceState iDeviceState;
       
   130     TBool           iUsbManConnected;
       
   131     };
       
   132 
       
   133 #endif // CMPXCONNECTIONEVENTHANDLER_H