camerauis/cameraapp/generic/inc/CamDriveChangeNotifier.h
changeset 0 1ddebce53859
child 13 38fb6f7eacd5
equal deleted inserted replaced
-1:000000000000 0:1ddebce53859
       
     1 /*
       
     2 * Copyright (c) 2008 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 
       
    20 #ifndef CAMDISKCHANGELISTENER_H
       
    21 #define CAMDISKCHANGELISTENER_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <f32file.h>
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class MCamDriveChangeNotifierObserver;
       
    28 
       
    29 // CLASS DECLARATION
       
    30 
       
    31 /**
       
    32 *  Mmc Change Notifier.
       
    33 *
       
    34 *  @since 5.0
       
    35 */
       
    36 class MCamDriveChangeNotifierObserver
       
    37     {
       
    38     public:
       
    39         enum TCamDriveChangeType
       
    40             {
       
    41             EDriveDismount,
       
    42             EDriveMount
       
    43             };
       
    44             
       
    45     public: // New functions
       
    46 
       
    47         /**
       
    48         * This method is used to notify changes.
       
    49         */
       
    50         virtual TInt DriveChangeL( TCamDriveChangeType aType ) = 0;
       
    51         
       
    52 
       
    53     protected:
       
    54 
       
    55         /**
       
    56         * Destructor.
       
    57         */
       
    58         virtual ~MCamDriveChangeNotifierObserver() {}
       
    59 
       
    60     };
       
    61 
       
    62 /**
       
    63 *  Mmc Change Notifier.
       
    64 *
       
    65 *  @since 5.0
       
    66 */
       
    67 class CCamDriveChangeNotifier : public CBase
       
    68 
       
    69     {
       
    70     private:
       
    71         class CCamDiskChangeListener : public CActive
       
    72             {            
       
    73             public:
       
    74                 static CCamDiskChangeListener* NewLC( 
       
    75                      RFs& aFs,
       
    76                      TDriveNumber aDrive,
       
    77                      MCamDriveChangeNotifierObserver::TCamDriveChangeType aType,
       
    78                      CCamDriveChangeNotifier& aObserver );
       
    79                 ~CCamDiskChangeListener();
       
    80                 
       
    81                 void Start();
       
    82                 void Stop();
       
    83             
       
    84             protected:
       
    85                 CCamDiskChangeListener( 
       
    86                      RFs& aFs,
       
    87                      TDriveNumber aDrive,
       
    88                      MCamDriveChangeNotifierObserver::TCamDriveChangeType aType,
       
    89                      CCamDriveChangeNotifier& aObserver );
       
    90                 
       
    91             private:
       
    92                 /**
       
    93                 * From CActive
       
    94                 */
       
    95                 void DoCancel();
       
    96 
       
    97                 /**
       
    98                 * From CActive
       
    99                 */
       
   100                 void RunL();
       
   101                 
       
   102             private:
       
   103                 RFs& iFs;
       
   104                 TDriveNumber iDrive;
       
   105                 MCamDriveChangeNotifierObserver::TCamDriveChangeType iType;
       
   106                 CCamDriveChangeNotifier& iObserver;
       
   107             };
       
   108 
       
   109     public:  // Constructors and destructor
       
   110 
       
   111         /**
       
   112         * Two-phased constructor.
       
   113         */
       
   114         static CCamDriveChangeNotifier* NewL(
       
   115                                 RFs& aFs,
       
   116                                 MCamDriveChangeNotifierObserver& aObserver  );
       
   117 
       
   118         /**
       
   119         * Destructor.
       
   120         */
       
   121         ~CCamDriveChangeNotifier();
       
   122 
       
   123     public:
       
   124         /**
       
   125         * Called from listeners
       
   126         */
       
   127         TInt NotifyChangeL( 
       
   128                 MCamDriveChangeNotifierObserver::TCamDriveChangeType aType );
       
   129 
       
   130         /**
       
   131         * Called by the observer when pending dismount can be done.
       
   132         */     
       
   133         void SendAllowDismount();        
       
   134 
       
   135         // New functions
       
   136 
       
   137         void StartMonitoring();
       
   138         void CancelMonitoring();
       
   139 
       
   140     private:
       
   141 
       
   142         /**
       
   143         * C++ default constructor.
       
   144         */
       
   145         CCamDriveChangeNotifier( 
       
   146                                 RFs& aFs,
       
   147                                 MCamDriveChangeNotifierObserver& aObserver );
       
   148 
       
   149     private:    // Data
       
   150         // Ref.
       
   151         MCamDriveChangeNotifierObserver& iObserver;
       
   152 
       
   153         // Ref. File server session
       
   154         RFs& iFs;
       
   155 
       
   156         RPointerArray<CCamDiskChangeListener> iListeners;
       
   157 
       
   158     };
       
   159 
       
   160 #endif      // CAMDISKCHANGELISTENER_H
       
   161 
       
   162 // End of File