photosgallery/viewframework/uiutilities/src/glxmmcnotifier.cpp
branchRCL_3
changeset 13 bcb43dc84c44
child 24 ea65f74e6de4
equal deleted inserted replaced
12:ce1c7ad1f18b 13:bcb43dc84c44
       
     1 /*
       
     2 * Copyright (c) 2008-2009 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:    MMC Notifier
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <glxtracer.h>
       
    20 #include <glxlog.h>
       
    21 
       
    22 #include "glxmmcnotifier.h"
       
    23 
       
    24 // ---------------------------------------------------------
       
    25 // CGlxMMCNotifier::NewL
       
    26 // ---------------------------------------------------------
       
    27 //
       
    28 EXPORT_C CGlxMMCNotifier* CGlxMMCNotifier::NewL(MStorageNotifierObserver& aNotify)    
       
    29     { 
       
    30     TRACER("CGlxMMCNotifier::NewL()");
       
    31     CGlxMMCNotifier* self = CGlxMMCNotifier::NewLC(aNotify);
       
    32     CleanupStack::Pop(self);
       
    33     return self;
       
    34     }
       
    35 
       
    36 // ---------------------------------------------------------
       
    37 // CGlxMMCNotifier::NewLC
       
    38 // ---------------------------------------------------------
       
    39 //
       
    40 CGlxMMCNotifier* CGlxMMCNotifier::NewLC(MStorageNotifierObserver& aNotify)    
       
    41     {    
       
    42     TRACER("CGlxMMCNotifier::NewLC()");
       
    43     CGlxMMCNotifier* self = new (ELeave) CGlxMMCNotifier(aNotify);    
       
    44     CleanupStack::PushL(self);    
       
    45     self->ConstructL();    
       
    46     return self;
       
    47     }
       
    48 
       
    49 // ---------------------------------------------------------
       
    50 // CGlxMMCNotifier::CGlxMMCNotifier
       
    51 // ---------------------------------------------------------
       
    52 //
       
    53 CGlxMMCNotifier::CGlxMMCNotifier(MStorageNotifierObserver& aNotify)
       
    54         : CActive( CActive::EPriorityStandard ),iNotify(aNotify)    
       
    55     {
       
    56     TRACER("CGlxMMCNotifier::CGlxMMCNotifier()");
       
    57     CActiveScheduler::Add( this );
       
    58     }
       
    59 
       
    60 // ---------------------------------------------------------
       
    61 // CGlxMMCNotifier::~CGlxMMCNotifier()
       
    62 // ---------------------------------------------------------
       
    63 //
       
    64 CGlxMMCNotifier::~CGlxMMCNotifier()
       
    65     {
       
    66     TRACER("CGlxMMCNotifier::~CGlxMMCNotifier()");
       
    67     Cancel();
       
    68     iFs.Close();
       
    69     }
       
    70 
       
    71 // ---------------------------------------------------------
       
    72 // CGlxMMCNotifier::IssueRequest()
       
    73 // ---------------------------------------------------------
       
    74 //
       
    75 void CGlxMMCNotifier::IssueRequest()    
       
    76     {
       
    77     TRACER("CGlxMMCNotifier::IssueRequest()");
       
    78     if ( !IsActive() )       
       
    79         {      
       
    80         // Request to get notified of MMC insertion/removal events      
       
    81         iFs.NotifyChange( ENotifyDisk, iStatus );      
       
    82         SetActive();      
       
    83         }    
       
    84     }
       
    85 
       
    86 // ---------------------------------------------------------
       
    87 // CGlxMMCNotifier::ConstructL()
       
    88 // ---------------------------------------------------------
       
    89 //
       
    90 void CGlxMMCNotifier::ConstructL()    
       
    91     {    
       
    92     TRACER("CGlxMMCNotifier::ConstructL()");
       
    93     TInt err = iFs.Connect();
       
    94     GLX_LOG_INFO1("CGlxMMCNotifier::ConstructL iFs.Connect err %d",err );
       
    95     IssueRequest();
       
    96     }
       
    97 
       
    98 // ---------------------------------------------------------
       
    99 // CGlxMMCNotifier::DoCancel()
       
   100 // ---------------------------------------------------------
       
   101 //
       
   102 void CGlxMMCNotifier::DoCancel()
       
   103     {
       
   104     TRACER("CGlxMMCNotifier::DoCancel()");
       
   105     iFs.NotifyChangeCancel();   
       
   106     }
       
   107 
       
   108 // ---------------------------------------------------------
       
   109 // CGlxMMCNotifier::RunL
       
   110 // ---------------------------------------------------------
       
   111 //
       
   112 void CGlxMMCNotifier::RunL()    
       
   113     {    
       
   114     TRACER("CGlxMMCNotifier::RunL()");
       
   115     TDriveInfo driveInfo;
       
   116     // Get the drive info for memory card     
       
   117     TInt err = iFs.Drive( driveInfo, EDriveF );
       
   118     GLX_LOG_INFO1("CGlxMMCNotifier::RunL err %d",err );
       
   119     if( err == KErrNone )      
       
   120         {      
       
   121         switch( driveInfo.iType )        
       
   122             {        
       
   123             case EMediaNotPresent:          
       
   124                 {          
       
   125                 //MMC removed  don't do anything   
       
   126                 iNotify.HandleMMCRemovalL();
       
   127                 break;          
       
   128                 }        
       
   129             default:          
       
   130                 { 
       
   131                 iNotify.HandleMMCInsertionL();
       
   132                 //MMC inserted                    
       
   133                 break;          
       
   134                 }        
       
   135             }      
       
   136         }    
       
   137     // Issue request for next event notification    
       
   138     IssueRequest();    
       
   139     }
       
   140 
       
   141