imagehandlingutilities/thumbnailmanager/tmcommon/src/tmformatobserver.cpp
changeset 54 48dd0f169f0d
parent 42 2e2a89493e2b
equal deleted inserted replaced
42:2e2a89493e2b 54:48dd0f169f0d
     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 "tmformatobserver.h"
       
    19 #include "thumbnaillog.h"
       
    20  
       
    21 #include <e32base.h>
       
    22 #include <f32file.h>
       
    23 #include "OstTraceDefinitions.h"
       
    24 #ifdef OST_TRACE_COMPILER_IN_USE
       
    25 #include "tmformatobserverTraces.h"
       
    26 #endif
       
    27 
       
    28 
       
    29 // ======== MEMBER FUNCTIONS ========
       
    30 
       
    31 CTMFormatObserver::CTMFormatObserver ( MTMFormatObserver& aObserver ): 
       
    32     iObserver( aObserver )
       
    33     {
       
    34     TN_DEBUG1( "CTMFormatObserver::CTMFormatObserver()");
       
    35     OstTrace0( TRACE_NORMAL, CTMFORMATOBSERVER_CTMFORMATOBSERVER, "CTMFormatObserver::CTMFormatObserver" );
       
    36     }
       
    37     
       
    38     
       
    39 // ---------------------------------------------------------------------------
       
    40 // Second Phase Constructor
       
    41 // ---------------------------------------------------------------------------
       
    42 //
       
    43 void CTMFormatObserver::ConstructL()
       
    44     {
       
    45     TN_DEBUG1("CTMFormatObserver::ConstructL");
       
    46     OstTrace0( TRACE_NORMAL, CTMFORMATOBSERVER_CONSTRUCTL, "CTMFormatObserver::ConstructL" );
       
    47 
       
    48     iBackupSession = CBaBackupSessionWrapper::NewL();
       
    49     iBackupSession->RegisterBackupOperationObserverL( *this );
       
    50     }
       
    51 
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // Two-Phased Constructor
       
    55 // ---------------------------------------------------------------------------
       
    56 //
       
    57 CTMFormatObserver* CTMFormatObserver::NewL( MTMFormatObserver& aObserver )
       
    58     {
       
    59     CTMFormatObserver* self = CTMFormatObserver::NewLC( aObserver );
       
    60     CleanupStack::Pop( self );
       
    61     return self;
       
    62     }
       
    63 
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // Two-Phased Constructor
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 CTMFormatObserver* CTMFormatObserver::NewLC( MTMFormatObserver& aObserver )
       
    70     {
       
    71     CTMFormatObserver* self = new( ELeave ) CTMFormatObserver( aObserver );
       
    72     CleanupStack::PushL( self );
       
    73     self->ConstructL();
       
    74     return self;
       
    75     }
       
    76 
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // destructor
       
    80 // ---------------------------------------------------------------------------
       
    81 //
       
    82 CTMFormatObserver::~CTMFormatObserver()
       
    83     {
       
    84     if( iBackupSession )
       
    85         {
       
    86         iBackupSession->DeRegisterBackupOperationObserver( *this );
       
    87         }
       
    88     
       
    89     delete iBackupSession;
       
    90     iBackupSession = NULL;
       
    91     }
       
    92 
       
    93 // ---------------------------------------------------------------------------
       
    94 // Checks the current status
       
    95 // ---------------------------------------------------------------------------
       
    96 //
       
    97 void CTMFormatObserver::PollStatus()
       
    98     { 
       
    99     TN_DEBUG1("CTMFormatObserver::PollStatus()");
       
   100     OstTrace0( TRACE_NORMAL, CTMFORMATOBSERVER_POLLSTATUS, "CTMFormatObserver::PollStatus" );
       
   101     
       
   102     TBool formatting = iBackupSession->IsBackupOperationRunning();
       
   103     
       
   104     if( formatting )
       
   105         {     
       
   106         iObserver.FormatNotification(ETrue); 
       
   107         }
       
   108     }
       
   109 
       
   110 // ---------------------------------------------------------------------------
       
   111 // CThumbnailFormatObserver::HandleBackupOperationEventL
       
   112 // Handles a format operation
       
   113 // ---------------------------------------------------------------------------
       
   114 //
       
   115 void CTMFormatObserver::HandleBackupOperationEventL(
       
   116                   const TBackupOperationAttributes& aBackupOperationAttributes)
       
   117     {
       
   118     TN_DEBUG1("CTMFormatObserver::HandleBackupOperationEventL");
       
   119     OstTrace0( TRACE_NORMAL, CTMFORMATOBSERVER_HANDLEBACKUPOPERATIONEVENTL, "CTMFormatObserver::HandleBackupOperationEventL" );
       
   120 
       
   121     if( aBackupOperationAttributes.iOperation == EStart )
       
   122         {
       
   123         iObserver.FormatNotification(ETrue);
       
   124         }
       
   125     else // TOperationType::EEnd or TOperationType::EAbort
       
   126         {
       
   127         iObserver.FormatNotification(EFalse);
       
   128         }
       
   129     }
       
   130