imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnaildiskunmountobserver.cpp
changeset 0 2014ca87e772
child 39 1a8af2cd6858
equal deleted inserted replaced
-1:000000000000 0:2014ca87e772
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Class to monitor when volumes are unmounted
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #include "thumbnaildiskunmountobserver.h"
       
    20 #include "thumbnaillog.h"
       
    21 #include "thumbnailserver.h"
       
    22 
       
    23 // ======== MEMBER FUNCTIONS ========
       
    24 
       
    25 // ---------------------------------------------------------------------------
       
    26 // CThumbnailTaskProcessor::NewL()
       
    27 // Two-phased constructor.
       
    28 // ---------------------------------------------------------------------------
       
    29 //
       
    30 CThumbnailDiskUnmountObserver* CThumbnailDiskUnmountObserver::NewL( RFs& aFs,
       
    31     TInt aDrive, CThumbnailServer* aServer )
       
    32     {
       
    33     CThumbnailDiskUnmountObserver* self = new( ELeave )
       
    34         CThumbnailDiskUnmountObserver( aFs, aDrive, aServer );
       
    35     CleanupStack::PushL( self );
       
    36     self->ConstructL();
       
    37     CleanupStack::Pop( self );
       
    38     return self;
       
    39     }
       
    40 
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // CThumbnailTaskProcessor::CThumbnailTaskProcessor()
       
    44 // C++ default constructor can NOT contain any code, that might leave.
       
    45 // ---------------------------------------------------------------------------
       
    46 //
       
    47 CThumbnailDiskUnmountObserver::CThumbnailDiskUnmountObserver( RFs& aFs,
       
    48     TInt aDrive, CThumbnailServer* aServer )
       
    49     : CActive( CActive::EPriorityStandard ), iFs( aFs ), iDrive( aDrive), iServer( aServer )
       
    50     {
       
    51     TN_DEBUG1( "CThumbnailDiskUnmountObserver::CThumbnailDiskUnmountObserver()"
       
    52         );
       
    53     CActiveScheduler::Add( this );
       
    54     StartNotify();
       
    55     }
       
    56 
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // CThumbnailTaskProcessor::ConstructL()
       
    60 // Symbian 2nd phase constructor can leave.
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 void CThumbnailDiskUnmountObserver::ConstructL()
       
    64     {
       
    65     // No implementation required
       
    66     }
       
    67 
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // CThumbnailTaskProcessor::~CThumbnailTaskProcessor()
       
    71 // Destructor.
       
    72 // ---------------------------------------------------------------------------
       
    73 //
       
    74 CThumbnailDiskUnmountObserver::~CThumbnailDiskUnmountObserver()
       
    75     {
       
    76     TN_DEBUG1( 
       
    77         "CThumbnailDiskUnmountObserver::~CThumbnailDiskUnmountObserver()" );
       
    78     Cancel();
       
    79     }
       
    80 
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // CThumbnailTaskProcessor::RunL()
       
    84 // ---------------------------------------------------------------------------
       
    85 //
       
    86 void CThumbnailDiskUnmountObserver::RunL()
       
    87     {
       
    88     TN_DEBUG2( "CThumbnailDiskUnmountObserver::RunL() iStatus = %d",
       
    89         iStatus.Int());
       
    90     
       
    91     if( !iStatus.Int() )
       
    92         {       
       
    93         // close store before allowing unmount
       
    94         // trap because nothing could be done in RunError anyway
       
    95         TRAP_IGNORE( iServer->CloseStoreForDriveL( iDrive ) );
       
    96         iFs.AllowDismount( iDrive );
       
    97         }
       
    98     if ( iStatus.Int() != KErrNotReady)
       
    99         {
       
   100         StartNotify();
       
   101         }
       
   102     }
       
   103 
       
   104 // ---------------------------------------------------------------------------
       
   105 // CThumbnailDiskUnmountObserver::DoCancel()
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 void CThumbnailDiskUnmountObserver::DoCancel()
       
   109     {
       
   110     iFs.NotifyDismountCancel( iStatus );
       
   111     }
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // CThumbnailDiskUnmountObserver::StartNotify()
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 void CThumbnailDiskUnmountObserver::StartNotify()
       
   118     {
       
   119     TN_DEBUG1( "CThumbnailDiskUnmountObserver::StartNotify()" );
       
   120     if(!IsActive())
       
   121         { 
       
   122         iFs.NotifyDismount( iDrive, iStatus, EFsDismountRegisterClient );
       
   123         SetActive();
       
   124         }
       
   125     }
       
   126 
       
   127 // End of file