webengine/wrtharvester/src/wrtusbhandler.cpp
changeset 38 6297cdf66332
parent 37 cb62a4f66ebe
child 42 d39add9822e2
equal deleted inserted replaced
37:cb62a4f66ebe 38:6297cdf66332
     1 /*
     1 //
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
     2 // ============================================================================
     3 * All rights reserved.
     3 //  Name     : WidgetMMCHandler.cpp
     4 * This component and the accompanying materials are made available
     4 //  Part of  : SW Installer UIs / WidgetInstallerUI
     5 * under the terms of the License "Eclipse Public License v1.0"
     5 //
     6 * which accompanies this distribution, and is available
     6 //  Description: Handle notifications of MMC events.
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 *
     8 //
     9 * Initial Contributors:
     9 //  Version     : 3.1
    10 * Nokia Corporation - initial contribution.
    10 //
    11 *
    11 //  Copyright © 2006 Nokia Corporation.
    12 * Contributors:
    12 //  This material, including documentation and any related
    13 *
    13 //  computer programs, is protected by copyright controlled by
    14 * Description:  Handle notifications of MMC events.
    14 //  Nokia Corporation. All rights are reserved. Copying,
    15 *
    15 //  including reproducing, storing, adapting or translating, any
    16 *
    16 //  or all of this material requires the prior written consent of
    17 *
    17 //  Nokia Corporation. This material also contains confidential
    18 */
    18 //  information which may not be disclosed to others without the
    19 
    19 //  prior written consent of Nokia Corporation.
       
    20 // ==============================================================================
       
    21 ///
       
    22 
       
    23 // INCLUDE FILES
    20 #include "wrtusbhandler.h"
    24 #include "wrtusbhandler.h"
    21 #include "wrtharvester.h"
    25 #include "wrtharvester.h"
    22 #include "wrtusbhandler.h"
    26 #include "wrtusbhandler.h"
    23 #include <DriveInfo.h>
    27 #include <DriveInfo.h>
    24 
    28 
   108 //
   112 //
   109 // @since 3.1
   113 // @since 3.1
   110 // ============================================================================
   114 // ============================================================================
   111 void CWrtUsbHandler::RunL()
   115 void CWrtUsbHandler::RunL()
   112     {
   116     {
   113     if ( iStatus == KErrNone )
   117     TInt status = iStatus.Int();
   114         {
   118     
   115         DoScanAndUpdate();
   119     // Restart NotifyChange
   116         }
   120     Start();
       
   121     
       
   122     if ( status == KErrNone )
       
   123       {
       
   124       DoScanAndUpdate();
       
   125       }
   117     }
   126     }
   118 
   127 
   119 void CWrtUsbHandler::DoScanAndUpdate()
   128 void CWrtUsbHandler::DoScanAndUpdate()
   120     {
   129     {
   121     TInt err = 0;
   130     TInt err = 0;
   126         deltaDriveFlags = iDriveFlags ^ driveFlags;
   135         deltaDriveFlags = iDriveFlags ^ driveFlags;
   127         iDriveFlags = driveFlags;
   136         iDriveFlags = driveFlags;
   128         }
   137         }
   129     
   138     
   130     if ( deltaDriveFlags )
   139     if ( deltaDriveFlags )
   131         {           
   140         {
   132         //Unpluging USB from Mass storage . . . 
       
   133         if(iHarvester->IsInMSMode() == 1)
       
   134             {                  
       
   135             iHarvester->ClearAllOperations();
       
   136             iHarvester->SetRegistryAccess(EFalse);
       
   137             iFs.NotifyChange( ENotifyDisk, iStatus );
       
   138             SetActive();
       
   139             return;
       
   140             }
       
   141 
       
   142         TVolumeInfo volInfo;
   141         TVolumeInfo volInfo;
   143         TInt temp = deltaDriveFlags;
   142         TInt temp = deltaDriveFlags;
   144         TBool massMemAltered = EFalse;        
   143         TBool massMemAltered = EFalse;        
       
   144         TBool massMemAvailable = EFalse;
   145         for(TInt DriveNo = EDriveA+1 ; DriveNo<=EDriveY; DriveNo++ )
   145         for(TInt DriveNo = EDriveA+1 ; DriveNo<=EDriveY; DriveNo++ )
   146             {   
   146             {   
   147             temp =  temp >> 1;
   147             temp =  temp >> 1;
   148             if( temp & 01)
   148             if( temp & 01)
   149                 {
   149                 {
   150                 TUint status(0);
   150                 TUint status(0);
   151                 err = DriveInfo::GetDriveStatus( iFs, DriveNo , status );
   151                 err = DriveInfo::GetDriveStatus( iFs, DriveNo , status );
   152                 if(!err && (status & DriveInfo::EDriveExternallyMountable) && (status & DriveInfo::EDriveInternal ))
   152                 if(!err && (status & DriveInfo::EDriveExternallyMountable) && (status & DriveInfo::EDriveInternal ))
   153                     {
   153                     {
   154                     //Internal Memory
   154                     //Internal Memory
   155                     massMemAltered = ETrue;
   155                     massMemAltered = ETrue;                  
       
   156                     // Check is the internal memory available or not
       
   157                     if(iDriveFlags & (1<<DriveNo))
       
   158                       massMemAvailable = ETrue;
   156                     }                     
   159                     }                     
   157                 }            
   160                 }            
   158             }
   161             }
   159        if( massMemAltered )
   162             if( massMemAltered )
   160            {           
   163               {
   161            iHarvester->SetMSMode(1);            
   164               if(!massMemAvailable)
   162            }
   165                 {
   163         }    
   166                 // Mass storage is plugged
   164     iFs.NotifyChange( ENotifyDisk, iStatus );
   167                 iHarvester->SetMSMode(1);
   165     SetActive();
   168                 }
       
   169               else
       
   170                 {
       
   171                 // Mass storage was unplugged
       
   172                 if(iHarvester->IsInMSMode() == 1)
       
   173                   {            
       
   174                   iHarvester->ClearAllOperations();
       
   175                   iHarvester->SetRegistryAccess(EFalse);
       
   176                   }
       
   177                 }
       
   178               }
       
   179         }
   166     }
   180     }
   167 
   181 
   168 
   182 
   169 // ============================================================================
   183 // ============================================================================
   170 // CWrtUsbHandler::RunError()
   184 // CWrtUsbHandler::RunError()