webengine/wrtharvester/src/wrtusbhandler.cpp
changeset 65 5bfc169077b2
parent 42 d39add9822e2
child 66 cacf6ee57968
--- a/webengine/wrtharvester/src/wrtusbhandler.cpp	Tue Feb 02 00:56:45 2010 +0200
+++ b/webengine/wrtharvester/src/wrtusbhandler.cpp	Fri Mar 19 09:52:28 2010 +0200
@@ -1,22 +1,26 @@
-/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Handle notifications of MMC events.
-*
-*
-*
-*/
+//
+// ============================================================================
+//  Name     : WidgetMMCHandler.cpp
+//  Part of  : SW Installer UIs / WidgetInstallerUI
+//
+//  Description: Handle notifications of MMC events.
+//
+//
+//  Version     : 3.1
+//
+//  Copyright © 2006 Nokia Corporation.
+//  This material, including documentation and any related
+//  computer programs, is protected by copyright controlled by
+//  Nokia Corporation. All rights are reserved. Copying,
+//  including reproducing, storing, adapting or translating, any
+//  or all of this material requires the prior written consent of
+//  Nokia Corporation. This material also contains confidential
+//  information which may not be disclosed to others without the
+//  prior written consent of Nokia Corporation.
+// ==============================================================================
+///
 
+// INCLUDE FILES
 #include "wrtusbhandler.h"
 #include "wrtharvester.h"
 #include "wrtusbhandler.h"
@@ -25,6 +29,16 @@
 // CONSTANTS
 
 
+static TInt TimerCallBack( TAny* ptr )
+{    
+    CWrtUsbHandler* temp = static_cast<CWrtUsbHandler*>(ptr);
+    if(temp)
+        {
+        temp->DeleteTimer();
+        temp->DoScanAndUpdate();       
+        }
+    return 0;    
+}
 // ============================================================================
 // CWrtUsbHandler::NewL()
 // two-phase constructor
@@ -110,15 +124,12 @@
 // ============================================================================
 void CWrtUsbHandler::RunL()
     {
-    TInt status = iStatus.Int();
-    
-    // Restart NotifyChange
-    Start();
-    
-    if ( status == KErrNone )
-      {
-      DoScanAndUpdate();
-      }
+    if ( iStatus == KErrNone )
+        {
+        //Call back Timer
+        iCallBackTimer = CPeriodic::NewL(CActive::EPriorityLow);
+        iCallBackTimer->Start(10000000,0,TCallBack(&TimerCallBack,this));         
+        }
     }
 
 void CWrtUsbHandler::DoScanAndUpdate()
@@ -133,11 +144,21 @@
         }
     
     if ( deltaDriveFlags )
-        {
+        {           
+        //Unpluging USB from Mass storage . . . 
+        if(iHarvester->IsInMSMode() == 1)
+            {                  
+            iHarvester->SetMSMode(0);
+            iHarvester->ClearAllOperations();
+            TRAP(err, iHarvester->UpdateL() );            
+            iFs.NotifyChange( ENotifyDisk, iStatus );
+            SetActive();
+            return;
+            }
+
         TVolumeInfo volInfo;
         TInt temp = deltaDriveFlags;
         TBool massMemAltered = EFalse;        
-        TBool massMemAvailable = EFalse;
         for(TInt DriveNo = EDriveA+1 ; DriveNo<=EDriveY; DriveNo++ )
             {   
             temp =  temp >> 1;
@@ -148,31 +169,19 @@
                 if(!err && (status & DriveInfo::EDriveExternallyMountable) && (status & DriveInfo::EDriveInternal ))
                     {
                     //Internal Memory
-                    massMemAltered = ETrue;                  
-                    // Check is the internal memory available or not
-                    if(iDriveFlags & (1<<DriveNo))
-                      massMemAvailable = ETrue;
+                    massMemAltered = ETrue;
                     }                     
                 }            
             }
-            if( massMemAltered )
-              {
-              if(!massMemAvailable)
-                {
-                // Mass storage is plugged
-                iHarvester->SetMSMode(1);
-                }
-              else
-                {
-                // Mass storage was unplugged
-                if(iHarvester->IsInMSMode() == 1)
-                  {
-                  iHarvester->SetMSMode(0);	            
-                  iHarvester->ClearAllOperations();                  
-                  }
-                }
-              }
+       if( massMemAltered )
+           {           
+           iHarvester->SetMSMode(1);            
+           }
+       
+        TRAP( err, iHarvester->UpdateL() ); 
         }
+    iFs.NotifyChange( ENotifyDisk, iStatus );
+    SetActive();
     }
 
 
@@ -245,4 +254,9 @@
 
     return error;
     }
-
+void CWrtUsbHandler::DeleteTimer()
+    {
+    iCallBackTimer->Cancel();
+    delete iCallBackTimer;
+    iCallBackTimer = NULL; 
+    }