landmarks/locationlandmarks/localaccess/inc/EPos_CPosLmLocalResetGlobalCatOp.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 02 Feb 2010 01:06:48 +0200
changeset 0 667063e416a2
permissions -rw-r--r--
Revision: 201003 Kit: 201005

/*
* Copyright (c) 2005 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: Operation for resetting global categories.
*
*
*/


#ifndef CPOSLMLOCALRESETGLOBALCATOP_H
#define CPOSLMLOCALRESETGLOBALCATOP_H

//  INCLUDES
#include "EPos_CPosLmLocalModifyOp.h"

// FORWARD DECLARATIONS
class CPosLmLocalCategoryManager;
class CPosLmGlobalCategoryReader;

// CLASS DECLARATION

/**
* Operation for resetting global categories. This operation can be
* either synchronous or asynchronous.
*
*  @lib eposlmlocalaccess.lib
*/
NONSHARABLE_CLASS(CPosLmLocalResetGlobalCatOp) : public CPosLmLocalModifyOp
    {

    enum TState
        {
        EReadGlCat = 0,
        EResetGlCat,
        ECheckGlCatToBeRemoved,
        ERemoveNotInResource,
        EError
        };

    public:  // Constructors and destructor

        /**
        * Two-phased constructor.
        * @param aDb A landmark database.
        */
        static CPosLmLocalResetGlobalCatOp* NewL(
        /* IN/OUT */    CPosLmLocalDatabase& aDb
        );

        /**
        * Destructor.
        */
        virtual ~CPosLmLocalResetGlobalCatOp();

    public: // Functions from base classes

        /**
        * From CPosLmLocalModifyOp.
        *
        * @param aProgress The current progress.
        */
        void DoNextStepPreL(
        /* OUT */       TReal32& aProgress
        );

        /**
        * From CPosLmLocalModifyOp.
        *
        * @param aProgress The current progress.
        * @return ETrue if a begin transaction should be made. EFalse otherwise.
        */
        TBool DoNextStepPostL(
        /* OUT */       TReal32& aProgress
        );

        /**
        * From CPosLmLocalModifyOp.
        *
        * @return Current step size.
        */
        TReal32 Step();

        /**
        * From CPosLmLocalModifyOp.
        *
        * @param aResourceId A resource id.
        * @param aNoOfSubOperations A number of sub operations.
        */
        void CheckResourceValue(
        /* IN */    TInt aResourceId,
        /* IN */    TInt aNoOfSubOperations
        );

        /**
        * From CPosLmLocalOperation;
        *
        * @param aError An error code generated by NextStepL.
        */
        void HandleError(
        /* IN/OUT */    TInt& aError
        );

    private:

        /**
        * C++ default constructor.
        * @param aDb A landmark db.
        */
        CPosLmLocalResetGlobalCatOp(
        /* IN */        CPosLmLocalDatabase& aDb
        );

        /**
        * By default Symbian 2nd phase constructor is private.
        */
        void ConstructL();

        /**
        * Asynchronously resets a global category.
        */
        void ResetCategoryPreL(
            TReal32& aProgress
        );

        /**
        * Removes a category not in the resource.
        */
        void RemoveCategoryNotInResourceL(
            TReal32& aProgress
        );

        /**
        * Resets a global category.
        */
        void ResetCategoryL(
        /* IN */        TInt aIndex
        );

        /**
        * Removes categories not in resource.
        */
        void RemoveGlCategoriesNotInResourceL(
            TReal32& aProgress
        );

        /**
        * Called when error occured or when object deleted.
        * If a transaction is ongoing it is rolled back.
        * If changes are committed to the database an event is registred
        */
        void RollbackAndRegisterIfNeeded();

        // Prohibit copy constructor if not deriving from CBase.
        CPosLmLocalResetGlobalCatOp(
            const CPosLmLocalResetGlobalCatOp&);
        // Prohibit assigment operator if not deriving from CBase.
        CPosLmLocalResetGlobalCatOp& operator=(
            const CPosLmLocalResetGlobalCatOp&);


    private:    // Data

        // Current global category reset.
        TInt iCurrent;

        RArray<TInt> iModifiedGlCats;
        RArray<TPosLmItemId> iToBeRemoved;


        CPosLmGlobalCategoryReader* iGlCatReader;

        TState iState;

    };

#endif      // CPOSLMLOCALRESETGLOBALCATOP_H

// End of File