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