contentstorage/srvinc/cammcwatcher.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 14 May 2010 16:10:06 +0300
changeset 73 4bc7b118b3df
parent 66 32469d7d46ff
permissions -rw-r--r--
Revision: 201017 Kit: 201019

/*
* Copyright (c) 2008 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:
*
*/

#ifndef C_CAMMCWATCHER_H
#define C_CAMMCWATCHER_H


#include <e32base.h>
#include <f32file.h>

/**
 *  Interface for observing MMC events.
 *
 *  @since S60 S60 v3.1
 */
class MMmcWatcherCallback
    {

public:
    /**
     * MmcChangeL is called when the MMC is removed or inserted.
     */
    virtual void MmcChangeL() = 0;

    };

/**
 *  This active object waits for an indication that the media has changed.
 *
 *  @since S60 S60 v3.1
 */
NONSHARABLE_CLASS( CCaMmcWatcher ) : public CActive
    {

public:

    /**
    * Two-phased constructor.
    * @param aObserver Pointer to notifier interface.
    * @param aFs file server session.
    */
IMPORT_C static CCaMmcWatcher* NewL( RFs& aFs,
            MMmcWatcherCallback* aObserver );

    /**
    * Two-phased constructor.
    * @param aObserver Pointer to notifier interface.
    * @param aFs file server session.
    */
IMPORT_C static CCaMmcWatcher* NewLC( RFs& aFs,
            MMmcWatcherCallback* aObserver );

    /**
    * Destructor
    */
    ~CCaMmcWatcher();

private:

    /**
    * C++ default constructor
    * @param aObserver Pointer to notifier interface.
    * @param aFs file server session.
    */
    CCaMmcWatcher( RFs& aFs, MMmcWatcherCallback* aObserver );

    /**
    * By default Symbian OS constructor is private.
    */
    void ConstructL();

    /**
    * Set notification request
    */
    void WaitForChangeL();

    /**
    * From CActive.
    */
    void DoCancel();

    /**
    * From CActive.
    */
    void RunL();

    /**
     * From CActive.
     */
    TInt RunError( TInt aError );

private:

    /**
     * File server session.
     * Not Own
     */
    RFs iFs;

    /**
     * MMC events observer
     * Not own.
     */
    MMmcWatcherCallback* iObserver;
    };


#endif      // C_CAMMCWATCHER_H