harvester/monitorplugins/mmcplugin/inc/mmcmonitorao.h
changeset 0 c53acadfccc6
child 8 6752808b2036
equal deleted inserted replaced
-1:000000000000 0:c53acadfccc6
       
     1 /*
       
     2 * Copyright (c) 2006-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:  Monitors MMC insertions and removals.*
       
    15 */
       
    16 
       
    17 
       
    18 #ifndef __MMCMONITORAO_H__
       
    19 #define __MMCMONITORAO_H__
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <f32file.h>
       
    23 #include "mdscommoninternal.h"
       
    24 
       
    25 enum TMMCEventType
       
    26     {
       
    27     EMounted,
       
    28     EDismounted,
       
    29     EFormatted
       
    30     };
       
    31 
       
    32 class MMMCMonitorObserver
       
    33     {
       
    34     public:
       
    35         /**
       
    36         * A pure virtual method to notify about any MMC insertions and removals.
       
    37         *
       
    38         * @param aDriveChar  A drive char of MMC which was inserted or removed.
       
    39         * @param aEventType  EMounted if MMC is inserted, EDismounted if it is removed.
       
    40         */
       
    41         virtual void MountEvent( TChar aDriveChar,
       
    42         	TUint32 aMediaID, TMMCEventType aEventType ) = 0;
       
    43     };
       
    44 
       
    45 class CMMCMonitorAO : public CActive
       
    46     {
       
    47     public:
       
    48         
       
    49         /**
       
    50         * Creates and constructs a new instance of CMMCMonitorAO.
       
    51         *
       
    52         * @return A pointer to the new instance of CMMCMonitorAO
       
    53         */
       
    54         static CMMCMonitorAO* NewL();
       
    55         
       
    56         /**
       
    57         * Destructor
       
    58         */
       
    59         virtual ~CMMCMonitorAO();
       
    60         
       
    61         /**
       
    62         * Starts monitoring the MMC insertions and removals.
       
    63         *
       
    64         * @param aObserver  Both events are notified via the aObserver.
       
    65         * @return ETrue if success, EFalse if not
       
    66         */
       
    67         TBool StartMonitoring( MMMCMonitorObserver& aObserver, RArray<TMdEMediaInfo>& aMedias );
       
    68         
       
    69         /**
       
    70         * Stops monitoring.
       
    71         *
       
    72         * @return ETrue if success, EFalse if not
       
    73         */
       
    74         TBool StopMonitoring();
       
    75         
       
    76         /**
       
    77         * Resumes paused monitoring.
       
    78         *
       
    79         * @return ETrue if success, EFalse if not
       
    80         */
       
    81         TBool Resume();
       
    82         
       
    83         /**
       
    84         * Pauses monitoring.
       
    85         *
       
    86         * @return ETrue if success, EFalse if not
       
    87         */
       
    88         TBool Pause();
       
    89         
       
    90         /**
       
    91         * Inherited from CActive. This method will be called on file server notifying.
       
    92         */
       
    93         void RunL();
       
    94         
       
    95         /**
       
    96         * Handles a leave occurring in the request completion event handler RunL().
       
    97         *
       
    98         * @param aError  An error code.
       
    99         * @return An error code.
       
   100         */
       
   101         TInt RunError( TInt aError );
       
   102         
       
   103         /**
       
   104         * Cancels file server notifying. Inherited from CActive.
       
   105         */
       
   106         void DoCancel();
       
   107         
       
   108     private:
       
   109         
       
   110         /**
       
   111         * C++ constructor - not exported;
       
   112         * implicitly called from NewL()
       
   113         */
       
   114         CMMCMonitorAO();
       
   115         
       
   116         /**
       
   117         * 2nd phase construction, called by NewL()
       
   118         */
       
   119         void ConstructL();
       
   120         
       
   121         /**
       
   122         * Starts file server to notify us about MMC insertions and removals.
       
   123         */
       
   124         void StartNotify();
       
   125         
       
   126         /**
       
   127         * Makes a list of all removable medias which is present.
       
   128         */
       
   129         void BuildDriveList();
       
   130         
       
   131         /**
       
   132         * Compares previous and present drive list. Notify an observer about any differences in lists.
       
   133         */
       
   134         void CompareDriveLists();
       
   135         
       
   136 #ifdef _DEBUG
       
   137     	void PrintAllLists();
       
   138 #endif
       
   139     
       
   140         
       
   141     private:
       
   142         /**
       
   143         * An observer.
       
   144         */
       
   145         MMMCMonitorObserver* iObserver;
       
   146         
       
   147         /**
       
   148         * A file server.
       
   149         */
       
   150         RFs iFs;
       
   151         
       
   152         /**
       
   153         * A present drive list.
       
   154         */
       
   155         TDriveList iDriveList;
       
   156         
       
   157         /**
       
   158         * A previous drive list.
       
   159         */
       
   160         TDriveList iPreviousDriveList;
       
   161         
       
   162         TUint32 iMediaIdList[KMaxDrives];
       
   163     };
       
   164 
       
   165 #endif // __MMCMONITORAO_H__