javaextensions/location/position/inc/clocationprovider.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 19 Aug 2010 09:48:13 +0300
branchRCL_3
changeset 24 6c158198356e
parent 14 04becd199f91
permissions -rw-r--r--
Revision: v2.2.9 Kit: 201033

/*
* 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 CLOCATIONPROVIDER_H
#define CLOCATIONPROVIDER_H

//  INCLUDES
#include <e32base.h>
#include <lbs.h>
#include <jni.h>
#include "locationfunctionserver.h"

namespace java
{
namespace location
{

//  FORWARD DECLARATIONS
class LocationFunctionServer;
class CPositioner;
class CTrackingPositioner;
class CPosGlobalPrivacyDb;
class CDelayStateChangeTimer;

// CLASS DECLARATION

/**
 *  Handles LocationProvider operations.
 */
class CLocationProvider: public CActive
{
public:
    // Constructors and destructor

    /**
     * Two-phased constructor.
     */
    static void NewL(LocationFunctionServer* aFunctionSource, TInt* aHandle);

    /**
     * Destructor.
     */
    ~CLocationProvider();

public:
    // New functions

    static void StaticCreatePositionerL(JNIEnv* aJni, jobject aPositioner,
                                        CLocationProvider* aSelf, TInt* aHandle,
                                        LocationFunctionServer* aFunctionSource);

    void SelectModuleL(TInt aHacc, TInt aVacc, TInt aRespTime, TInt aPower,
                       TInt aRequiredFlags, TInt* aLocationMethod);

protected:
    // Functions from base classes

    /**
     * From CBase
     */
    void RunL();

    /**
     * From CBase
     */
    void DoCancel();

private:

    /**
     * C++ default constructor.
     */
    CLocationProvider(LocationFunctionServer* aEventSource);

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

private:

    CPositioner* CreatePositionerL();

    static TBool CheckRequirements(const TPositionQuality& aQuality,
                                   TPositionModuleInfo::TCapabilities aCaps, TInt aHacc, TInt aVacc,
                                   TInt aRespTime, TInt aPower, TInt aRequiredFlags);

    void RequestModuleStatus();

    TInt StatusToState(TPositionModuleStatus& aStatus);

    void ChangeState(TInt aState);

    TBool AllLocationRequestsDeniedL();

public:
    CTrackingPositioner* iTrackingPositioner;

    // JNI Environment Data
    JNIEnv* mJni;
    jobject mPeer;

    // Location Updated Callback JNI Method ID
    jmethodID mStateChangMethod;

private:
    // Data
    LocationFunctionServer* mFunctionServer;
    RPositionServer iPositionServer;
    TPositionModuleId iModuleId;
    TPositionModuleInfo::TCapabilities iCapabilities;
    TPositionModuleStatusEvent iStatusEvent;
    TInt iState;
    TInt iNewState;
    CDelayStateChangeTimer* iStateTimer;
private:
    friend class CDelayStateChangeTimer;
};

}
}
#endif // CLOCATIONPROVIDER_H
// End of File