imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailmemorycardobserver.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 memory card status is changed
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #include "thumbnailmemorycardobserver.h"
       
    20 #include "thumbnaillog.h"
       
    21 
       
    22 // ======== MEMBER FUNCTIONS ========
       
    23 
       
    24 // ---------------------------------------------------------------------------
       
    25 // CThumbnailMemoryCardObserver::NewL()
       
    26 // Two-phased constructor.
       
    27 // ---------------------------------------------------------------------------
       
    28 //
       
    29 CThumbnailMemoryCardObserver* CThumbnailMemoryCardObserver::NewL( CThumbnailServer* aServer, RFs& aFs )
       
    30     {
       
    31     CThumbnailMemoryCardObserver* self = new( ELeave )
       
    32         CThumbnailMemoryCardObserver( aServer, aFs );
       
    33     CleanupStack::PushL( self );
       
    34     self->ConstructL();
       
    35     CleanupStack::Pop( self );
       
    36     return self;
       
    37     }
       
    38 
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 // CThumbnailMemoryCardObserver::CThumbnailMemoryCardObserver()
       
    42 // C++ default constructor can NOT contain any code, that might leave.
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 CThumbnailMemoryCardObserver::CThumbnailMemoryCardObserver( CThumbnailServer* aServer, RFs& aFs ): 
       
    46     CActive( CActive::EPriorityStandard ), iServer( aServer ), iFs( aFs ) 
       
    47     {
       
    48     TN_DEBUG1( "CThumbnailMemoryCardObserver::CThumbnailMemoryCardObserver()"
       
    49         );
       
    50     CActiveScheduler::Add( this );
       
    51     StartNotify();
       
    52     }
       
    53 
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // CThumbnailMemoryCardObserver::ConstructL()
       
    57 // Symbian 2nd phase constructor can leave.
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 void CThumbnailMemoryCardObserver::ConstructL()
       
    61     {
       
    62     // No implementation required
       
    63     }
       
    64 
       
    65 
       
    66 // ---------------------------------------------------------------------------
       
    67 // CThumbnailTaskProcessor::~CThumbnailTaskProcessor()
       
    68 // Destructor.
       
    69 // ---------------------------------------------------------------------------
       
    70 //
       
    71 CThumbnailMemoryCardObserver::~CThumbnailMemoryCardObserver()
       
    72     {
       
    73     TN_DEBUG1( 
       
    74         "CThumbnailMemoryCardObserver::~CThumbnailMemoryCardObserver()" );
       
    75     Cancel();
       
    76     }
       
    77 
       
    78 
       
    79 // ---------------------------------------------------------------------------
       
    80 // CThumbnailMemoryCardObserver::RunL()
       
    81 // ---------------------------------------------------------------------------
       
    82 //
       
    83 void CThumbnailMemoryCardObserver::RunL()
       
    84     {
       
    85     TN_DEBUG2( "CThumbnailMemoryCardObserver::RunL() iStatus = %d", iStatus.Int());
       
    86     if ( !iStatus.Int() )
       
    87         {
       
    88         // trap because nothing could be done in RunError
       
    89         TRAP_IGNORE( iServer->MemoryCardStatusChangedL() );
       
    90         StartNotify();
       
    91         }
       
    92     }
       
    93 
       
    94 // ---------------------------------------------------------------------------
       
    95 // CThumbnailMemoryCardObserver::DoCancel()
       
    96 // ---------------------------------------------------------------------------
       
    97 //
       
    98 void CThumbnailMemoryCardObserver::DoCancel()
       
    99     {
       
   100     iFs.NotifyChangeCancel();
       
   101     }
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // CThumbnailMemoryCardObserver::StartNotify()
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 void CThumbnailMemoryCardObserver::StartNotify()
       
   108     {
       
   109     TN_DEBUG1( "CThumbnailMemoryCardObserver::StartNotify()" );
       
   110     
       
   111     if (IsActive()) 
       
   112         {
       
   113         Cancel();
       
   114         }
       
   115     
       
   116     iFs.NotifyChange(ENotifyDisk, iStatus);
       
   117     SetActive();
       
   118     }
       
   119 
       
   120 // End of file