imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailformatobserver.cpp
changeset 0 2014ca87e772
equal deleted inserted replaced
-1:000000000000 0:2014ca87e772
       
     1 /*
       
     2 * Copyright (c) 2006 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:  File System format monitor
       
    15 *
       
    16 */
       
    17 
       
    18 #include "thumbnailformatobserver.h"
       
    19 #include "thumbnaillog.h"
       
    20  
       
    21 #include <e32base.h>
       
    22 #include <f32file.h>
       
    23 
       
    24 
       
    25 // ======== MEMBER FUNCTIONS ========
       
    26 
       
    27 CThumbnailFormatObserver::CThumbnailFormatObserver ( CThumbnailServer* aServer): 
       
    28      iServer( aServer )
       
    29     {
       
    30     TN_DEBUG1( "CThumbnailFormatObserver::CThumbnailFormatObserver()");
       
    31     
       
    32     }
       
    33     
       
    34     
       
    35 // ---------------------------------------------------------------------------
       
    36 // Second Phase Constructor
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 void CThumbnailFormatObserver::ConstructL()
       
    40     {
       
    41     TN_DEBUG1("CThumbnailFormatObserver::ConstructL in");
       
    42 
       
    43     iBackupSession = CBaBackupSessionWrapper::NewL();
       
    44     iBackupSession->RegisterBackupOperationObserverL( *this );
       
    45 
       
    46 
       
    47     TN_DEBUG1("CThumbnailFormatObserver::ConstructL out");
       
    48     }
       
    49 
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // Two-Phased Constructor
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 CThumbnailFormatObserver* CThumbnailFormatObserver::NewL(CThumbnailServer* aServer )
       
    56     {
       
    57     CThumbnailFormatObserver* self = CThumbnailFormatObserver::NewLC( aServer );
       
    58     CleanupStack::Pop( self );
       
    59     return self;
       
    60     }
       
    61 
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // Two-Phased Constructor
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 CThumbnailFormatObserver* CThumbnailFormatObserver::NewLC( CThumbnailServer* aServer )
       
    68     {
       
    69     CThumbnailFormatObserver* self = new( ELeave ) CThumbnailFormatObserver( aServer );
       
    70     CleanupStack::PushL( self );
       
    71     self->ConstructL();
       
    72     return self;
       
    73     }
       
    74 
       
    75 
       
    76 // ---------------------------------------------------------------------------
       
    77 // destructor
       
    78 // ---------------------------------------------------------------------------
       
    79 //
       
    80 CThumbnailFormatObserver::~CThumbnailFormatObserver()
       
    81     {
       
    82 
       
    83     if( iBackupSession )
       
    84         {
       
    85         iBackupSession->DeRegisterBackupOperationObserver( *this );
       
    86         }
       
    87     delete iBackupSession;
       
    88     }
       
    89 
       
    90 // ---------------------------------------------------------------------------
       
    91 // Checks the current status
       
    92 // ---------------------------------------------------------------------------
       
    93 //
       
    94 void CThumbnailFormatObserver::PollStatus()
       
    95     {
       
    96     
       
    97     TN_DEBUG1("CThumbnailFormatObserver::PollStatus()");
       
    98     
       
    99     TBool aFormatting = iBackupSession->IsBackupOperationRunning();
       
   100     
       
   101     if( aFormatting )
       
   102         {        
       
   103         TRAP_IGNORE(iServer->CloseRemovableDrivesL());   
       
   104         }
       
   105     }
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // CThumbnailFormatObserver::HandleBackupOperationEventL
       
   109 // Handles a format operation
       
   110 // ---------------------------------------------------------------------------
       
   111 //
       
   112 void CThumbnailFormatObserver::HandleBackupOperationEventL(
       
   113                   const TBackupOperationAttributes& aBackupOperationAttributes)
       
   114     {
       
   115     TN_DEBUG1("CThumbnailFormatObserver::HandleBackupOperationEventL in");
       
   116 
       
   117     if( aBackupOperationAttributes.iOperation == EStart )
       
   118         {
       
   119         TRAP_IGNORE(iServer->CloseRemovableDrivesL());
       
   120         }
       
   121     else  // TOperationType::EEnd or TOperationType::EAbort
       
   122         {
       
   123         TRAP_IGNORE(iServer->OpenRemovableDrivesL());
       
   124         }
       
   125 
       
   126     TN_DEBUG1("CThumbnailFormatObserver::HandleBackupOperationEventL out");
       
   127     }