imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailmemorycardobserver.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 14 May 2010 16:10:12 +0300
changeset 19 b790c5b3d11f
parent 0 2014ca87e772
child 39 1a8af2cd6858
permissions -rw-r--r--
Revision: 201017 Kit: 201019

/*
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Class to monitor when memory card status is changed
 *
*/


#include "thumbnailmemorycardobserver.h"
#include "thumbnaillog.h"

// ======== MEMBER FUNCTIONS ========

// ---------------------------------------------------------------------------
// CThumbnailMemoryCardObserver::NewL()
// Two-phased constructor.
// ---------------------------------------------------------------------------
//
CThumbnailMemoryCardObserver* CThumbnailMemoryCardObserver::NewL( CThumbnailServer* aServer, RFs& aFs )
    {
    CThumbnailMemoryCardObserver* self = new( ELeave )
        CThumbnailMemoryCardObserver( aServer, aFs );
    CleanupStack::PushL( self );
    self->ConstructL();
    CleanupStack::Pop( self );
    return self;
    }


// ---------------------------------------------------------------------------
// CThumbnailMemoryCardObserver::CThumbnailMemoryCardObserver()
// C++ default constructor can NOT contain any code, that might leave.
// ---------------------------------------------------------------------------
//
CThumbnailMemoryCardObserver::CThumbnailMemoryCardObserver( CThumbnailServer* aServer, RFs& aFs ): 
    CActive( CActive::EPriorityStandard ), iServer( aServer ), iFs( aFs ) 
    {
    TN_DEBUG1( "CThumbnailMemoryCardObserver::CThumbnailMemoryCardObserver()"
        );
    CActiveScheduler::Add( this );
    StartNotify();
    }


// ---------------------------------------------------------------------------
// CThumbnailMemoryCardObserver::ConstructL()
// Symbian 2nd phase constructor can leave.
// ---------------------------------------------------------------------------
//
void CThumbnailMemoryCardObserver::ConstructL()
    {
    // No implementation required
    }


// ---------------------------------------------------------------------------
// CThumbnailTaskProcessor::~CThumbnailTaskProcessor()
// Destructor.
// ---------------------------------------------------------------------------
//
CThumbnailMemoryCardObserver::~CThumbnailMemoryCardObserver()
    {
    TN_DEBUG1( 
        "CThumbnailMemoryCardObserver::~CThumbnailMemoryCardObserver()" );
    Cancel();
    }


// ---------------------------------------------------------------------------
// CThumbnailMemoryCardObserver::RunL()
// ---------------------------------------------------------------------------
//
void CThumbnailMemoryCardObserver::RunL()
    {
    TN_DEBUG2( "CThumbnailMemoryCardObserver::RunL() iStatus = %d", iStatus.Int());
    if ( !iStatus.Int() )
        {
        // trap because nothing could be done in RunError
        TRAP_IGNORE( iServer->MemoryCardStatusChangedL() );
        StartNotify();
        }
    }

// ---------------------------------------------------------------------------
// CThumbnailMemoryCardObserver::DoCancel()
// ---------------------------------------------------------------------------
//
void CThumbnailMemoryCardObserver::DoCancel()
    {
    iFs.NotifyChangeCancel();
    }

// ---------------------------------------------------------------------------
// CThumbnailMemoryCardObserver::StartNotify()
// ---------------------------------------------------------------------------
//
void CThumbnailMemoryCardObserver::StartNotify()
    {
    TN_DEBUG1( "CThumbnailMemoryCardObserver::StartNotify()" );
    
    if (IsActive()) 
        {
        Cancel();
        }
    
    iFs.NotifyChange(ENotifyDisk, iStatus);
    SetActive();
    }

// End of file