usbmgmt/usbmgr/host/functiondrivers/ms/msmm/server/inc/eventhandler.h
changeset 0 c9bc50fca66e
equal deleted inserted replaced
-1:000000000000 0:c9bc50fca66e
       
     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:
       
    15 *
       
    16 */
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21 */
       
    22 
       
    23 #ifndef EVENTHANDLER_H
       
    24 #define EVENTHANDLER_H
       
    25 
       
    26 #include <e32base.h>
       
    27 #include <e32msgqueue.h>
       
    28 #include "msmm_internal_def.h"
       
    29 #include "subcommandbase.h"
       
    30 #include "handlerinterface.h"
       
    31 
       
    32 class MMsmmSrvProxy;
       
    33 class THostMsErrData;
       
    34 
       
    35 // USB MS sub-commands queue class
       
    36 // Intend to be used in event handler internally.
       
    37 NONSHARABLE_CLASS(RSubCommandQueue)
       
    38     {
       
    39 public:
       
    40     
       
    41     inline TInt Count() const; 
       
    42 
       
    43     // Push a sub-command into the queue and transfer the owership 
       
    44     // to the queue
       
    45     void PushL(TSubCommandBase* aCommand);
       
    46     
       
    47     // Pop the head entity from the queue and destroy it  
       
    48     void Pop();
       
    49     
       
    50     // Insert a sub-command sequence after head entities    
       
    51     void InsertAfterHeadL(TSubCommandBase* aCommand);
       
    52     
       
    53     // Execute the head sub-comment
       
    54     void ExecuteHeadL();
       
    55     
       
    56     // Get a reference of head sub-command in queue
       
    57     TSubCommandBase& Head();
       
    58     
       
    59     // Destory all entities and release the memory of queue
       
    60     void Release();
       
    61     
       
    62 private:
       
    63     RPointerArray<TSubCommandBase> iQueue;
       
    64     };
       
    65 
       
    66 NONSHARABLE_CLASS (CDeviceEventHandler) : 
       
    67     public CActive, 
       
    68     public MUsbMsEventHandler,
       
    69     public MUsbMsSubCommandCreator
       
    70     {
       
    71 public:
       
    72     virtual ~CDeviceEventHandler();
       
    73     static CDeviceEventHandler* NewL(MMsmmSrvProxy& aServer);
       
    74     static CDeviceEventHandler* NewLC(MMsmmSrvProxy& aServer);
       
    75 
       
    76     inline const TDeviceEvent& Event() const;
       
    77 
       
    78     // From MUsbMsSubCommandCreator
       
    79     void CreateSubCmdForRetrieveDriveLetterL(TInt aLogicalUnitCount);
       
    80     void CreateSubCmdForMountingLogicalUnitL(TText aDrive, TInt aLuNumber);
       
    81     void CreateSubCmdForSaveLatestMountInfoL(TText aDrive, TInt aLuNumber);
       
    82     
       
    83     // From MUsbMsEventHandler
       
    84     void Start();
       
    85     void Complete(TInt aError = KErrNone);
       
    86     TRequestStatus& Status() const;
       
    87 
       
    88     /** Send an event to handler and start to secure handler. 
       
    89     * Intends to be used by CDeviceEventQueue class.
       
    90     */
       
    91     void HandleEventL(TRequestStatus& aStatus, const TDeviceEvent& aEvent);
       
    92 
       
    93     /** Reset event handler to be ready for the next event
       
    94      * 
       
    95      */
       
    96     void ResetHandler();
       
    97     inline const THostMsErrData& ErrNotiData() const;
       
    98     
       
    99 private:
       
   100     // CActive implementation
       
   101     void DoCancel();
       
   102     void RunL();
       
   103     TInt RunError(TInt aError);
       
   104 
       
   105 private:
       
   106     CDeviceEventHandler(MMsmmSrvProxy& aServer);
       
   107     void ConstructL();
       
   108 
       
   109     // Create sub-commands based on a particular USB MS event
       
   110     void CreateSubCmdForDeviceEventL();
       
   111     void CreateSubCmdForAddingUsbMsFunctionL();
       
   112     void CreateSubCmdForRemovingUsbMsDeviceL();
       
   113 
       
   114     void ResetHandlerData();
       
   115     void ResetHandlerError();
       
   116     void CompleteClient(TInt aError = KErrNone);
       
   117     
       
   118 private:
       
   119     MMsmmSrvProxy& iServer;
       
   120     TDeviceEvent iIncomingEvent;
       
   121     RSubCommandQueue iSubCommandQueue;
       
   122     TRequestStatus* iEvtQueueStatus; // No ownership
       
   123 
       
   124     THostMsErrData* iErrNotiData; // Error notification - Owned
       
   125     };
       
   126 
       
   127 #include "eventhandler.inl"
       
   128 
       
   129 #endif // EVENTHANDLER_H
       
   130 
       
   131 // End of file