emailservices/emailstore/preinstall/inc/EmailStorePreInstall.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 19 Feb 2010 22:37:30 +0200
branchRCL_3
changeset 8 e1b6206813b4
parent 0 8466d47a6819
child 24 d189ee25cf9d
permissions -rw-r--r--
Revision: 201003 Kit: 201007

/*
* Copyright (c) 2009 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: Pre Install helper class.
*
*/
#ifndef __EMAILSTOREPREINSTALL_H__
#define __EMAILSTOREPREINSTALL_H__

// ========
// INCLUDES
// ========
#include <e32base.h>
#include <w32std.h>
#include <apgtask.h>
#include <e32property.h>
#include <debuglogmacros.h>
#include "ProcessTimer.h"

// ========
// LOCALS
// ========
LOCAL_C void DoPreInstallL( );

/**
 * Pre Install helper class.
 */
class CEmailStorePreInstall : public CTimer , public MObserverPreInstall
    {
    public:
        /**
         * Factory methods.
         */
        static CEmailStorePreInstall* NewL();
        static CEmailStorePreInstall* NewLC();
        
        /**
         * Destructor.
         */
        virtual ~CEmailStorePreInstall();
        
    public:
        // FROM: MObserverPreInstall
        void Timeout();
        
    protected:
        //from CTimer
        void RunL();
        void DoCancel();
        TInt RunError( TInt aError );
                
    private:
        /**
         * Constructor.
         */
        CEmailStorePreInstall( );
        
        /**
         * Second-phase constructor.
         */
        void ConstructL();

        /**
         * Stop servers.
         * Iterates through servers and signals them to stop.
         * If the stop doesn't occur in a certain time, then the server is killed.
         */
        void StopNextServerL();
        
        // Internal state
        enum TState
            {
            EInit,
            EStopServers,
            EWaitForProcess,
            EDone
            };

    private:
        /** Current index in the server list. */
        TInt    iServerIndex;        
        /** Internal state. */
        TState  iState;
        /** Process finish timeout. */
        CProcessTimer* iTimeoutTimer;
        /** Current server to be stopped handle. */
        RProcess iProcess;
        
        /** Logging. */
        __LOG_DECLARATION        
    };

#endif  //__EMAILSTOREPREINSTALL_H__