harvesterplugins/file/src/cmmcmonitor.cpp
changeset 2 208a4ba3894c
parent 0 ccd0fd43f247
child 3 6832643895f7
equal deleted inserted replaced
0:ccd0fd43f247 2:208a4ba3894c
    24 #include <pathinfo.h>
    24 #include <pathinfo.h>
    25 #include <s32file.h>
    25 #include <s32file.h>
    26 #include <f32file.h> // TDriveNumber
    26 #include <f32file.h> // TDriveNumber
    27 #include <driveinfo.h> // TDriveInfo
    27 #include <driveinfo.h> // TDriveInfo
    28 
    28 
    29 #include <uikoninternalpskeys.h>
    29 #include <UikonInternalPSKeys.h>
       
    30 #include "OstTraceDefinitions.h"
       
    31 #ifdef OST_TRACE_COMPILER_IN_USE
       
    32 #include "cmmcmonitorTraces.h"
       
    33 #endif
       
    34 
    30 
    35 
    31 // CONSTANTS
    36 // CONSTANTS
    32 // 
    37 // 
    33 
    38 
    34 // ============================ MEMBER FUNCTIONS ===============================
    39 // ============================ MEMBER FUNCTIONS ===============================
    53 //
    58 //
    54 CMMCMonitor::CMMCMonitor( CFilePlugin& aFilePlugin )
    59 CMMCMonitor::CMMCMonitor( CFilePlugin& aFilePlugin )
    55     : CActive( CActive::EPriorityStandard ),
    60     : CActive( CActive::EPriorityStandard ),
    56       iFilePlugin( aFilePlugin )
    61       iFilePlugin( aFilePlugin )
    57     {
    62     {
       
    63     OstTraceFunctionEntry0( CMMCMONITOR_CMMCMONITOR_ENTRY );
    58     CPIXLOGSTRING("ENTER CMMCMonitor::CMMCMonitor");
    64     CPIXLOGSTRING("ENTER CMMCMonitor::CMMCMonitor");
    59     CActiveScheduler::Add( this );
    65     CActiveScheduler::Add( this );
    60     CPIXLOGSTRING("END CMMCMonitor::CMMCMonitor");
    66     CPIXLOGSTRING("END CMMCMonitor::CMMCMonitor");
       
    67     OstTraceFunctionExit0( CMMCMONITOR_CMMCMONITOR_EXIT );
    61     }
    68     }
    62 
    69 
    63 
    70 
    64 // -----------------------------------------------------------------------------
    71 // -----------------------------------------------------------------------------
    65 // CMMCMonitor::~CMMCMonitor
    72 // CMMCMonitor::~CMMCMonitor
    79 // CMMCMonitor::ConstructL
    86 // CMMCMonitor::ConstructL
    80 // -----------------------------------------------------------------------------
    87 // -----------------------------------------------------------------------------
    81 //
    88 //
    82 void CMMCMonitor::ConstructL( RFs* aFsSession )
    89 void CMMCMonitor::ConstructL( RFs* aFsSession )
    83     {
    90     {
       
    91     OstTraceFunctionEntry0( CMMCMONITOR_CONSTRUCTL_ENTRY );
    84     CPIXLOGSTRING("ENTER CMMCMonitor::ConstructL Foobar");
    92     CPIXLOGSTRING("ENTER CMMCMonitor::ConstructL Foobar");
    85     iFsSession = aFsSession;
    93     iFsSession = aFsSession;
    86     
    94     
    87     TInt error = iProperty.Attach( KPSUidUikon, KUikMMCInserted );
    95     TInt error = iProperty.Attach( KPSUidUikon, KUikMMCInserted );
    88     if ( error != KErrNone ) CPIXLOGSTRING("END CMMCMonitor::Attach to MMCInserted failed");
    96     if ( error != KErrNone ) 
       
    97         {
       
    98         OstTrace0( TRACE_NORMAL, CMMCMONITOR_CONSTRUCTL, "END CMMCMonitor::Attach to MMCInserted failed" );
       
    99         CPIXLOGSTRING("END CMMCMonitor::Attach to MMCInserted failed");
       
   100         }
    89     
   101     
    90     error = iProperty.Get( KPSUidUikon, KUikMMCInserted, iMmcStatus );
   102     error = iProperty.Get( KPSUidUikon, KUikMMCInserted, iMmcStatus );
    91     if ( error != KErrNone ) 
   103     if ( error != KErrNone ) 
    92     	{
   104     	{
       
   105 		OstTrace0( TRACE_NORMAL, DUP1_CMMCMONITOR_CONSTRUCTL, "CMMCMonitor::Get MMCInserted failed" );
    93 		CPIXLOGSTRING("CMMCMonitor::Get MMCInserted failed");
   106 		CPIXLOGSTRING("CMMCMonitor::Get MMCInserted failed");
    94     	} 
   107     	} 
    95     else if ( iMmcStatus ) 	 
   108     else if ( iMmcStatus ) 	 
    96     	{
   109     	{
       
   110     	OstTrace0( TRACE_NORMAL, DUP2_CMMCMONITOR_CONSTRUCTL, "CMMCMonitor::MMC card is in" );
    97     	CPIXLOGSTRING("CMMCMonitor::MMC card is in");
   111     	CPIXLOGSTRING("CMMCMonitor::MMC card is in");
    98     	}
   112     	}
    99     else 
   113     else 
   100     	{
   114     	{
       
   115     	OstTrace0( TRACE_NORMAL, DUP3_CMMCMONITOR_CONSTRUCTL, "CMMCMonitor::no MMC card" );
   101     	CPIXLOGSTRING("CMMCMonitor::no MMC card");
   116     	CPIXLOGSTRING("CMMCMonitor::no MMC card");
   102     	}
   117     	}
   103 
   118 
   104     // The CFilePlugin::StartMonitoring() will call
   119     // The CFilePlugin::StartMonitoring() will call
   105     // CMMCMonitor::StartMonitoring() which will call
   120     // CMMCMonitor::StartMonitoring() which will call
   106     // CMMCMonitor::RunL().
   121     // CMMCMonitor::RunL().
   107     //
   122     //
   108     CPIXLOGSTRING("END CMMCMonitor::ConstructL");
   123     CPIXLOGSTRING("END CMMCMonitor::ConstructL");
       
   124     OstTraceFunctionExit0( CMMCMONITOR_CONSTRUCTL_EXIT );
   109     }
   125     }
   110 
   126 
   111 
   127 
   112 // -----------------------------------------------------------------------------
   128 // -----------------------------------------------------------------------------
   113 // CMMCMonitor::StartMonitoring
   129 // CMMCMonitor::StartMonitoring
   114 // -----------------------------------------------------------------------------
   130 // -----------------------------------------------------------------------------
   115 //
   131 //
   116 TBool CMMCMonitor::StartMonitoring()
   132 TBool CMMCMonitor::StartMonitoring()
   117     {
   133     {
       
   134     OstTraceFunctionEntry0( CMMCMONITOR_STARTMONITORING_ENTRY );
   118     CPIXLOGSTRING("ENTER CMMCMonitor::StartMonitoring");
   135     CPIXLOGSTRING("ENTER CMMCMonitor::StartMonitoring");
   119     TRAP_IGNORE( RunL() ); // Need to TRAP this rather than use RunError
   136     TRAP_IGNORE( RunL() ); // Need to TRAP this rather than use RunError
   120     CPIXLOGSTRING("END CMMCMonitor::StartMonitoring");
   137     CPIXLOGSTRING("END CMMCMonitor::StartMonitoring");
       
   138     OstTraceFunctionExit0( CMMCMONITOR_STARTMONITORING_EXIT );
   121     return ETrue;
   139     return ETrue;
   122     }
   140     }
   123 
   141 
   124 
   142 
   125 // -----------------------------------------------------------------------------
   143 // -----------------------------------------------------------------------------
   140             }
   158             }
   141         // MMC drives are removable and user visible
   159         // MMC drives are removable and user visible
   142         if ( ( drvStatus & DriveInfo::EDriveRemovable ) &&
   160         if ( ( drvStatus & DriveInfo::EDriveRemovable ) &&
   143              ( drvStatus & DriveInfo::EDriveUserVisible ) )
   161              ( drvStatus & DriveInfo::EDriveUserVisible ) )
   144                 {
   162                 {
       
   163                 OstTrace1( TRACE_NORMAL, CMMCMONITOR_MMCSTATUS, "CMMCMonitor::MmcStatus;Drive Number=%d", aDriveNumber );
   145                 CPIXLOGSTRING2("CMMCMonitor::MmcStatus Drive Number %d", aDriveNumber);
   164                 CPIXLOGSTRING2("CMMCMonitor::MmcStatus Drive Number %d", aDriveNumber);
   146                 isMmcPresent = ETrue;
   165                 isMmcPresent = ETrue;
   147                 }
   166                 }
   148         }
   167         }
   149     return isMmcPresent;
   168     return isMmcPresent;
   154 // CMMCMonitor::RunError
   173 // CMMCMonitor::RunError
   155 // -----------------------------------------------------------------------------
   174 // -----------------------------------------------------------------------------
   156 //
   175 //
   157 TInt CMMCMonitor::RunError( TInt aError )
   176 TInt CMMCMonitor::RunError( TInt aError )
   158     {
   177     {
       
   178     OstTrace1( TRACE_NORMAL, CMMCMONITOR_RUNERROR, "CMMCMonitor::RunError;aError=%d", aError );
   159     CPIXLOGSTRING2("CMMCMonitor::RunError Error:",aError);
   179     CPIXLOGSTRING2("CMMCMonitor::RunError Error:",aError);
   160     return KErrNone;
   180     return KErrNone;
   161     }
   181     }
   162 
   182 
   163 
   183 
   165 // CMMCMonitor::DoCancel
   185 // CMMCMonitor::DoCancel
   166 // -----------------------------------------------------------------------------
   186 // -----------------------------------------------------------------------------
   167 //
   187 //
   168 void CMMCMonitor::DoCancel()
   188 void CMMCMonitor::DoCancel()
   169     {
   189     {
       
   190     OstTraceFunctionEntry0( CMMCMONITOR_DOCANCEL_ENTRY );
   170     CPIXLOGSTRING("ENTER CMMCMonitor::DoCancel");
   191     CPIXLOGSTRING("ENTER CMMCMonitor::DoCancel");
   171     iProperty.Cancel();
   192     iProperty.Cancel();
   172     CPIXLOGSTRING("END CMMCMonitor::DoCancel");
   193     CPIXLOGSTRING("END CMMCMonitor::DoCancel");
       
   194     OstTraceFunctionExit0( CMMCMONITOR_DOCANCEL_EXIT );
   173     }
   195     }
   174 
   196 
   175 
   197 
   176 // -----------------------------------------------------------------------------
   198 // -----------------------------------------------------------------------------
   177 // CMMCMonitor::RunL
   199 // CMMCMonitor::RunL
   178 // -----------------------------------------------------------------------------
   200 // -----------------------------------------------------------------------------
   179 //
   201 //
   180 void CMMCMonitor::RunL()
   202 void CMMCMonitor::RunL()
   181     {
   203     {
       
   204     OstTraceFunctionEntry0( CMMCMONITOR_RUNL_ENTRY );
   182     CPIXLOGSTRING("ENTER CMMCMonitor::RunL");
   205     CPIXLOGSTRING("ENTER CMMCMonitor::RunL");
   183     iProperty.Subscribe( iStatus );
   206     iProperty.Subscribe( iStatus );
   184     SetActive();
   207     SetActive();
   185     User::LeaveIfError( iProperty.Get( KPSUidUikon, KUikMMCInserted, iMmcStatus ) );
   208     User::LeaveIfError( iProperty.Get( KPSUidUikon, KUikMMCInserted, iMmcStatus ) );
   186     
   209     
   187     if ( iMmcStatus )
   210     if ( iMmcStatus )
   188     	{
   211     	{
       
   212     	OstTrace0( TRACE_NORMAL, CMMCMONITOR_RUNL, "CMMCMonitor::MMC card is in" );
   189     	CPIXLOGSTRING("CMMCMonitor::MMC card is in");
   213     	CPIXLOGSTRING("CMMCMonitor::MMC card is in");
   190     	}
   214     	}
   191     else 
   215     else 
   192     	{
   216     	{
       
   217 		OstTrace0( TRACE_NORMAL, DUP1_CMMCMONITOR_RUNL, "CMMCMonitor::no MMC card" );
   193 		CPIXLOGSTRING("CMMCMonitor::no MMC card");
   218 		CPIXLOGSTRING("CMMCMonitor::no MMC card");
   194     	}
   219     	}
   195 
   220 
   196     for ( TInt driveNumber = EDriveA; driveNumber <= EDriveZ; driveNumber++ )
   221     for ( TInt driveNumber = EDriveA; driveNumber <= EDriveZ; driveNumber++ )
   197         {
   222         {
   212             continue;  // should not happen
   237             continue;  // should not happen
   213             }
   238             }
   214 
   239 
   215         if ( drvStatus & DriveInfo::EDrivePresent )
   240         if ( drvStatus & DriveInfo::EDrivePresent )
   216             {
   241             {
       
   242             OstTrace0( TRACE_NORMAL, DUP2_CMMCMONITOR_RUNL, "CMMCMonitor::RunL insert event" );
   217             CPIXLOGSTRING("CMMCMonitor::RunL insert event");
   243             CPIXLOGSTRING("CMMCMonitor::RunL insert event");
   218             // Mount MMC and force reharvest
   244             // Mount MMC and force reharvest
   219             iFilePlugin.MountL(drv, ETrue);
   245             iFilePlugin.MountL(drv, ETrue);
   220             }
   246             }
   221         else
   247         else
   222             {
   248             {
       
   249             OstTrace0( TRACE_NORMAL, DUP3_CMMCMONITOR_RUNL, "CMMCMonitor::RunL eject event" );
   223             CPIXLOGSTRING("CMMCMonitor::RunL eject event");
   250             CPIXLOGSTRING("CMMCMonitor::RunL eject event");
   224             // If the MMC has been ejected, then need to dismount 
   251             // If the MMC has been ejected, then need to dismount 
   225             // and undefine the volume
   252             // and undefine the volume
   226             iFilePlugin.UnMount(drv, ETrue);
   253             iFilePlugin.UnMount(drv, ETrue);
   227             }
   254             }
   228         }
   255         }
   229     CPIXLOGSTRING("END CMMCMonitor::RunL");
   256     CPIXLOGSTRING("END CMMCMonitor::RunL");
       
   257     OstTraceFunctionExit0( CMMCMONITOR_RUNL_EXIT );
   230     }
   258     }
   231 
   259 
   232 // End Of File
   260 // End Of File