camerauis/cameraapp/generic/src/CamDriveChangeNotifier.cpp
branchRCL_3
changeset 25 bf64cebf4673
parent 20 38fb6f7eacd5
child 27 53c8aa5d97a3
equal deleted inserted replaced
20:38fb6f7eacd5 25:bf64cebf4673
    18 
    18 
    19 
    19 
    20 // INCLUDE FILES
    20 // INCLUDE FILES
    21 #include    <pathinfo.h>
    21 #include    <pathinfo.h>
    22 #include    <driveinfo.h>
    22 #include    <driveinfo.h>
    23 #include    <usbwatcherinternalpskeys.h>
    23 #include    <UsbWatcherInternalPSKeys.h>
    24 #include    <usbpersonalityids.h>
    24 #include    <usbpersonalityids.h>
    25 
    25 
    26 #include    "CamDriveChangeNotifier.h"
    26 #include    "CamDriveChangeNotifier.h"
    27 #include    "camlogging.h"
    27 #include    "camlogging.h"
    28 #include    "CamUtility.h"
    28 #include    "CamUtility.h"
    29 
    29 
    30 
    30 
    31 _LIT(KDriveE, "E:\\");
    31 _LIT(KDriveE, "E:\\");
    32 _LIT(KDriveF, "F:\\");
    32 _LIT(KDriveF, "F:\\");
       
    33 
       
    34 const TInt KUSBTimeout = 1000000;  //1 sec
    33 
    35 
    34 // ============================ MEMBER FUNCTIONS ===============================
    36 // ============================ MEMBER FUNCTIONS ===============================
    35 
    37 
    36 // -----------------------------------------------------------------------------
    38 // -----------------------------------------------------------------------------
    37 // CCamDriveChangeNotifier::CCamDiskChangeListener::NewL
    39 // CCamDriveChangeNotifier::CCamDiskChangeListener::NewL
   223           iUsbMSWatcher->Cancel();
   225           iUsbMSWatcher->Cancel();
   224           }
   226           }
   225       delete iUsbMSWatcher;
   227       delete iUsbMSWatcher;
   226       iUsbMSWatcher = NULL;
   228       iUsbMSWatcher = NULL;
   227       }
   229       }
       
   230   if ( iUSBTimer )
       
   231       {
       
   232       if( iUSBTimer->IsActive() )
       
   233           {
       
   234           iUSBTimer->Cancel();
       
   235           }
       
   236       delete iUSBTimer;
       
   237       iUSBTimer = NULL;
       
   238       }
   228   PRINT( _L( "Camera <= CCamDriveChangeNotifier::~CCamDriveChangeNotifier" ) );
   239   PRINT( _L( "Camera <= CCamDriveChangeNotifier::~CCamDriveChangeNotifier" ) );
   229   }
   240   }
   230 
   241 
   231 // -----------------------------------------------------------------------------
   242 // -----------------------------------------------------------------------------
   232 // CCamDriveChangeNotifier::StartMonitoring
   243 // CCamDriveChangeNotifier::StartMonitoring
   302 // -----------------------------------------------------------------------------
   313 // -----------------------------------------------------------------------------
   303 //
   314 //
   304 void CCamDriveChangeNotifier::HandlePropertyChangedL( const TUid& aCategory, const TUint aKey )
   315 void CCamDriveChangeNotifier::HandlePropertyChangedL( const TUid& aCategory, const TUint aKey )
   305     {
   316     {
   306     PRINT( _L( "Camera => CCamDriveChangeNotifier::HandlePropertyChangedL" ) );
   317     PRINT( _L( "Camera => CCamDriveChangeNotifier::HandlePropertyChangedL" ) );
   307     TInt value = 0;
       
   308     if(KPSUidUsbWatcher == aCategory && 
   318     if(KPSUidUsbWatcher == aCategory && 
   309        KUsbWatcherSelectedPersonality == aKey)
   319        KUsbWatcherSelectedPersonality == aKey)
   310         {
   320         {
       
   321         TInt value = 0;
   311         iUsbMSWatcher->Get( value );
   322         iUsbMSWatcher->Get( value );
   312         if( KUsbPersonalityIdMS == value )
   323         if( KUsbPersonalityIdMS == value )
   313             {
   324             {
   314             iMassStorageModeOn = ETrue;
   325             PRINT( _L( "Camera => CCamDriveChangeNotifier::HandlePropertyChangedL StartTimer" ) );
   315             iObserver.DriveChangeL( MCamDriveChangeNotifierObserver::EDriveUSBMassStorageModeOn );
   326             iUSBTimer->Cancel();
       
   327             iUSBTimer->StartTimer();
   316             }
   328             }
   317         else
   329         else
   318             {
   330             {
   319             if( iMassStorageModeOn )
   331             if( iMassStorageModeOn )
   320                 {
   332                 {
       
   333                 PRINT( _L("CCamDriveChangeNotifier::HandlePropertyChangedL KUsbPersonalityIdMS Off") );
   321                 iMassStorageModeOn = EFalse;
   334                 iMassStorageModeOn = EFalse;
   322                 iObserver.DriveChangeL( MCamDriveChangeNotifierObserver::EDriveUSBMassStorageModeOff );
   335                 iObserver.DriveChangeL( MCamDriveChangeNotifierObserver::EDriveUSBMassStorageModeOff );
   323                 }
   336                 }
   324             }
   337             }
   325         }
   338         }
   341                          *this ) );  
   354                          *this ) );  
   342     
   355     
   343     iUsbMSWatcher = CCamPropertyWatcher::NewL(*this, KPSUidUsbWatcher, 
   356     iUsbMSWatcher = CCamPropertyWatcher::NewL(*this, KPSUidUsbWatcher, 
   344                         KUsbWatcherSelectedPersonality );
   357                         KUsbWatcherSelectedPersonality );
   345     
   358     
       
   359     iUSBTimer = CCamTimer::NewL( KUSBTimeout, TCallBack(USBTimerCallBack, this));
   346     CleanupStack::Pop(); // listener
   360     CleanupStack::Pop(); // listener
   347     CleanupStack::Pop(); // listener 2
   361     CleanupStack::Pop(); // listener 2
   348     
   362     
   349     StartMonitoring();
   363     StartMonitoring();
   350 
   364 
   351     }
   365     }
       
   366 
       
   367 // -----------------------------------------------------------------------------
       
   368 // CCamDriveChangeNotifier::USBTimerCallBackL
       
   369 // -----------------------------------------------------------------------------
       
   370 //
       
   371 void CCamDriveChangeNotifier::USBTimerCallBackL()
       
   372     {
       
   373     TInt value = 0;
       
   374     iUsbMSWatcher->Get( value );
       
   375     if( KUsbPersonalityIdMS == value )
       
   376         {
       
   377         PRINT( _L("CCamDriveChangeNotifier::USBTimerCallBackL KUsbPersonalityIdMS On") );
       
   378         iMassStorageModeOn = ETrue;
       
   379         iObserver.DriveChangeL( MCamDriveChangeNotifierObserver::EDriveUSBMassStorageModeOn );
       
   380         }
       
   381     else
       
   382         {
       
   383         if( iMassStorageModeOn )
       
   384             {
       
   385             PRINT( _L("CCamDriveChangeNotifier::USBTimerCallBackL KUsbPersonalityIdMS Off") );
       
   386             iMassStorageModeOn = EFalse;
       
   387             iObserver.DriveChangeL( MCamDriveChangeNotifierObserver::EDriveUSBMassStorageModeOff );
       
   388             }
       
   389         }
       
   390     }
       
   391         
       
   392 // -----------------------------------------------------------------------------
       
   393 // CCamDriveChangeNotifier::USBTimerCallBack
       
   394 // -----------------------------------------------------------------------------
       
   395 //
       
   396 TInt CCamDriveChangeNotifier::USBTimerCallBack( TAny* aPtr )
       
   397     {
       
   398     CCamDriveChangeNotifier* self = static_cast<CCamDriveChangeNotifier*>(aPtr);
       
   399     if( self )
       
   400         {
       
   401         TRAP_IGNORE( self->USBTimerCallBackL() );
       
   402         }
       
   403     return KErrNone;
       
   404     }
       
   405 
   352 //  End of File
   406 //  End of File