imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagformatobserver.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 "thumbagformatobserver.h"
       
    19 #include "thumbnaillog.h"
       
    20  
       
    21 #include <e32base.h>
       
    22 #include <f32file.h>
       
    23 
       
    24 
       
    25 // ======== MEMBER FUNCTIONS ========
       
    26 
       
    27 CThumbAGFormatObserver::CThumbAGFormatObserver ( CThumbAGProcessor* aProcessor): 
       
    28      iProcessor( aProcessor )
       
    29     {
       
    30     TN_DEBUG1( "CThumbAGFormatObserver::CThumbAGFormatObserver()");
       
    31     
       
    32     }
       
    33     
       
    34     
       
    35 // ---------------------------------------------------------------------------
       
    36 // Second Phase Constructor
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 void CThumbAGFormatObserver::ConstructL()
       
    40     {
       
    41     TN_DEBUG1("CThumbAGFormatObserver::ConstructL in");
       
    42 
       
    43     iBackupSession = CBaBackupSessionWrapper::NewL();
       
    44     iBackupSession->RegisterBackupOperationObserverL( *this );
       
    45 
       
    46 
       
    47     TN_DEBUG1("CThumbAGFormatObserver::ConstructL out");
       
    48     }
       
    49 
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // Two-Phased Constructor
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 CThumbAGFormatObserver* CThumbAGFormatObserver::NewL(CThumbAGProcessor* aProcessor )
       
    56     {
       
    57     CThumbAGFormatObserver* self = CThumbAGFormatObserver::NewLC( aProcessor );
       
    58     CleanupStack::Pop( self );
       
    59     return self;
       
    60     }
       
    61 
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // Two-Phased Constructor
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 CThumbAGFormatObserver* CThumbAGFormatObserver::NewLC( CThumbAGProcessor* aProcessor )
       
    68     {
       
    69     CThumbAGFormatObserver* self = new( ELeave ) CThumbAGFormatObserver( aProcessor );
       
    70     CleanupStack::PushL( self );
       
    71     self->ConstructL();
       
    72     return self;
       
    73     }
       
    74 
       
    75 
       
    76 // ---------------------------------------------------------------------------
       
    77 // destructor
       
    78 // ---------------------------------------------------------------------------
       
    79 //
       
    80 CThumbAGFormatObserver::~CThumbAGFormatObserver()
       
    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 CThumbAGFormatObserver::PollStatus()
       
    95     {
       
    96     
       
    97     TN_DEBUG1("CThumbAGFormatObserver::PollStatus()");
       
    98     
       
    99     TBool formatting = iBackupSession->IsBackupOperationRunning();
       
   100     
       
   101     if( formatting )
       
   102         {     
       
   103         iProcessor->SetFormat(ETrue);   
       
   104         }
       
   105     }
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // CThumbnailFormatObserver::HandleBackupOperationEventL
       
   109 // Handles a format operation
       
   110 // ---------------------------------------------------------------------------
       
   111 //
       
   112 void CThumbAGFormatObserver::HandleBackupOperationEventL(
       
   113                   const TBackupOperationAttributes& aBackupOperationAttributes)
       
   114     {
       
   115     TN_DEBUG1("CThumbAGFormatObserver::HandleBackupOperationEventL in");
       
   116 
       
   117     if( aBackupOperationAttributes.iOperation == EStart )
       
   118         {
       
   119         iProcessor->SetFormat(ETrue);
       
   120         }
       
   121     else  // TOperationType::EEnd or TOperationType::EAbort
       
   122         {
       
   123         iProcessor->SetFormat(EFalse);
       
   124         }
       
   125 
       
   126     TN_DEBUG1("CThumbAGObserver::HandleBackupOperationEventL out");
       
   127     }
       
   128 
       
   129