locationrequestmgmt/locationserver/src/EPos_CPositionRequest.cpp
author William Roberts <williamr@symbian.org>
Thu, 22 Jul 2010 16:47:01 +0100
branchGCC_SURGE
changeset 49 5f20f71a57a3
parent 27 aadfb18aaac1
parent 36 b47902b73a93
permissions -rw-r--r--
Catchup to latest Symbian^4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     1
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     2
// All rights reserved.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     3
// This component and the accompanying materials are made available
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     5
// which accompanies this distribution, and is available
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     7
//
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     8
// Initial Contributors:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    10
//
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    11
// Contributors:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    12
//
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    13
// Description:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    14
//
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    15
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    16
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    17
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    18
// INCLUDE FILES
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    19
#include <e32base.h>
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    20
#include <lbspositioninfo.h>
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    21
#include <lbs/epos_cpositioner.h>
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    22
#include <lbs/epos_cposmodules.h>
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    23
#include <lbs/epos_mposmodulesobserver.h>
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    24
#include <centralrepository.h>
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    25
#include "lbsdevloggermacros.h"
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    26
#include "EPos_ServerPanic.h"
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    27
#include "EPos_Global.h"
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    28
#include "EPos_CPosCallbackTimer.h"
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    29
#include "EPos_CPositionRequest.h"
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    30
#include "epos_cposmodulessettings.h"
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    31
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    32
//TODO Verify
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    33
#include "EPos_CPosLocMonitorReqHandlerHub.h"
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    34
#include "OstTraceDefinitions.h"
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    35
#ifdef OST_TRACE_COMPILER_IN_USE
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    36
#include "EPos_CPositionRequestTraces.h"
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    37
#endif
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    38
#include "lbsrootcenrepdefs.h"
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    39
#include "lbspositioningstatusprops.h"
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    40
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    41
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    42
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    43
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    44
// CONSTANTS
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    45
#ifdef _DEBUG
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    46
_LIT(KTraceFileName, "EPos_CPositionRequest.cpp");
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    47
#endif
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    48
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    49
const TInt KParamPositionInfo = 0;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    50
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    51
// ================= LOCAL FUNCTIONS ========================
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    52
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    53
void CancelTimerCleanup(TAny* aTimer)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    54
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    55
    (static_cast<CPosCallbackTimer*>(aTimer))->Cancel();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    56
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    57
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    58
inline TPositionInfoBase& PositionInfoBase(HBufC8* aBuffer)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    59
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    60
        return reinterpret_cast<TPositionInfoBase&>
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    61
        (const_cast<TUint8&>(*aBuffer->Ptr()));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    62
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    63
inline TPositionInfo& PositionInfo(HBufC8* aBuffer)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    64
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    65
        return reinterpret_cast<TPositionInfo&>
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    66
        (const_cast<TUint8&>(*aBuffer->Ptr()));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    67
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    68
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    69
// ================= MEMBER FUNCTIONS =======================
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    70
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    71
// C++ default constructor can NOT contain any code, that
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    72
// might leave.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    73
//
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    74
CPositionRequest::CPositionRequest(
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    75
    CPosModuleSettings& aModuleSettings,
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    76
    CPosLocMonitorReqHandlerHub& aLocMonitorReqHandlerHub,
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    77
    TProxyPositionerConstructParams& aPositionerParams,
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    78
    TBool aIsProxy)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    79
:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    80
    CActive(EPriorityStandard),
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    81
    iRequestPhase(EPosReqInactive),
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    82
    iPositionerParams(aPositionerParams),
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    83
    iHasProxyPositioner(aIsProxy),
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    84
    iLocMonitorReqHandler(aLocMonitorReqHandlerHub),
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    85
    iModuleSettings(aModuleSettings)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    86
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    87
    CActiveScheduler::Add(this);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    88
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    89
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    90
// EPOC default constructor can leave.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    91
void CPositionRequest::ConstructL()
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    92
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    93
    TCallBack timeoutCallBack(HandleTimeOut, this);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    94
    iTimeoutTimer = CPosCallbackTimer::NewL(timeoutCallBack);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    95
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    96
    TCallBack trackingCallBack(TrackingCallback, this);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    97
    iTrackingTimer = CPosCallbackTimer::NewL(trackingCallBack);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    98
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    99
    iModuleSettings.PosModules().GetModuleInfoL(
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   100
        iPositionerParams.iImplementationUid, 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   101
        iModuleInfo);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   102
        
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   103
    if (!iModuleInfo.IsAvailable())
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   104
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   105
        User::Leave(KErrNotFound);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   106
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   107
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   108
    // Get the CategoryUid from the cenrep file owned by LbsRoot.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   109
    CRepository* rep = CRepository::NewLC(KLbsCenRepUid);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   110
    TInt posStatusCategory;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   111
    TInt err = rep->Get(KMoPositioningStatusAPIKey, posStatusCategory);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   112
    User::LeaveIfError(err);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   113
    CleanupStack::PopAndDestroy(rep);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   114
    iPosStatusCategory = TUid::Uid(posStatusCategory);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   115
    
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   116
    LoadPositionerL();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   117
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   118
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   119
/**
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   120
 * Two-phased constructor.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   121
 *
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   122
 * @param aModules Location Settings reference
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   123
 * @param aLocMonitorReqHandlerHub The hub for requests to the location monitor.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   124
 * @param aPositionerParams contruction parameters needed when creating
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   125
 *        positioner.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   126
 * @param aIsProxy ETrue if aImplementationUid represents a proxy PSY,
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   127
 *        EFalse otherwise.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   128
 */
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   129
CPositionRequest* CPositionRequest::NewL(
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   130
    CPosModuleSettings& aModuleSettings,
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   131
    CPosLocMonitorReqHandlerHub& aLocMonitorReqHandlerHub,
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   132
    TProxyPositionerConstructParams& aPositionerParams,
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   133
    TBool aIsProxy)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   134
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   135
    CPositionRequest* self = new (ELeave) CPositionRequest(
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   136
        aModuleSettings,
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   137
        aLocMonitorReqHandlerHub,
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   138
        aPositionerParams,
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   139
        aIsProxy);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   140
    CleanupStack::PushL(self);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   141
    self->ConstructL();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   142
    CleanupStack::Pop(self);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   143
    return self;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   144
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   145
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   146
/**
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   147
 * Destructor.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   148
 */
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   149
CPositionRequest::~CPositionRequest()
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   150
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   151
    // Panic client if request is outstanding
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   152
    if (IsActive())
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   153
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   154
        iMessage.Panic(KPosClientFault, EPositionRequestsNotCancelled);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   155
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   156
    Cancel();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   157
    if (iTrackingState == EPosTracking)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   158
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   159
        StopTracking();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   160
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   161
    delete iTrackingTimer;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   162
    delete iPositionBuffer;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   163
    delete iTimeoutTimer;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   164
    delete iPositioner;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   165
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   166
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   167
/**
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   168
 * Starts a position request cycle. Should only be called when PSY is 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   169
 * enabled.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   170
 * @param aMessage the request message from the client
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   171
 */
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   172
void CPositionRequest::MakeRequestL(const RMessage2& aMessage)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   173
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   174
    if (!iModuleInfo.IsAvailable())
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   175
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   176
        User::Leave(KErrNotFound);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   177
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   178
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   179
    __ASSERT_DEBUG(iPositioner, DebugPanic(EPosServerPanicPositionerNotInitialized));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   180
    
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   181
    //Increment the StatusKeyValue for Positioning Indicator clients
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   182
    if(iTrackingState == EPosNoTracking || iTrackingState == EPosFirstTrackingRequest)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   183
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   184
        TInt     count, err;     
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   185
        err = RProperty::Get(iPosStatusCategory, KLbsMoPositioningStatusKey, count);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   186
        if(err == KErrNone)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   187
            {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   188
            err = RProperty::Set(iPosStatusCategory, KLbsMoPositioningStatusKey, count+1);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   189
            }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   190
        if(err != KErrNone)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   191
            {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   192
            DEBUG_TRACE("CPositionRequest::MakeRequestL() - Error in setting or getting Positioning Status", __LINE__)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   193
            }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   194
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   195
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   196
    iMessage = aMessage; // Store parameter here in case of leave.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   197
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   198
    // Clear previous position data
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   199
    delete iPositionBuffer;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   200
    iPositionBuffer = NULL;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   201
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   202
    HBufC8* clientBuf = Global::CopyClientBuffer8LC(aMessage, KParamPositionInfo);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   203
    CleanupStack::Pop(clientBuf);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   204
    iPositionBuffer = clientBuf;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   205
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   206
    TPositionInfoBase& infoBase = PositionInfoBase(iPositionBuffer);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   207
    TUint32 classType = infoBase.PositionClassType();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   208
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   209
    TUint32 classesSupported = iModuleInfo.ClassesSupported(EPositionInfoFamily);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   210
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   211
    // Check that classtype is supported and is of type TPositionInfo
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   212
    if ((classType != (classType & classesSupported)) ||
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   213
        !(classType & EPositionInfoClass))
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   214
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   215
        User::Leave(KErrArgument);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   216
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   217
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   218
    // Set ModuleId to KNullId to be able to verify that Id is set by PSY.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   219
    infoBase.SetModuleId(KNullUid);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   220
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   221
    CleanupStack::PushL(TCleanupItem(CancelTimerCleanup, iTimeoutTimer));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   222
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   223
    // Start timer if necessary
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   224
    if (iTimeOut.Int64() > 0)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   225
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   226
        LBS_RDEBUG_INFO("CPositionRequest::MakeRequestL() Start Timeout Timer");
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   227
        iTimeoutTimer->StartTimer(iTimeOut);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   228
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   229
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   230
    LBS_RDEBUG_VAR_INT("CPositionRequest::MakeRequestL() iTrackingState", iTrackingState);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   231
    switch (iTrackingState)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   232
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   233
        case EPosNoTracking:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   234
        case EPosFirstTrackingRequest:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   235
            StartPositionDataRequestPhase();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   236
            break;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   237
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   238
        case EPosTracking:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   239
            StartTrackingTimerWaitPhase();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   240
            break;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   241
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   242
        case EPosStopTracking:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   243
            // This must have been handled by Cancel or RunL
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   244
        default:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   245
            DebugPanic(EPosServerPanicTrackingInconsistency);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   246
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   247
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   248
    CleanupStack::Pop(iTimeoutTimer);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   249
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   250
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   251
/**
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   252
 * Set the TPositionUpdateOptions object.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   253
 *
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   254
 * When this class is constructed, the TPositionUpdateOptions object
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   255
 * is constructed using default constructor with no parameters.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   256
 *
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   257
 * @param aOptions The update options from the client.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   258
 */
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   259
void CPositionRequest::SetUpdateOptions(
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   260
    const TPositionUpdateOptionsBase& aOptions)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   261
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   262
    iTimeOut = aOptions.UpdateTimeOut();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   263
    TTimeIntervalMicroSeconds newInterval = aOptions.UpdateInterval();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   264
    TTimeIntervalMicroSeconds oldInterval = iTrackingUpdateInterval;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   265
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   266
    if (newInterval != iTrackingUpdateInterval)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   267
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   268
        iTrackingUpdateInterval = newInterval;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   269
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   270
        if (newInterval == 0) // "stop periodic updates"
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   271
            {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   272
            switch (iTrackingState)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   273
                {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   274
                case EPosFirstTrackingRequest:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   275
                    iTrackingState = EPosNoTracking;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   276
                    break;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   277
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   278
                case EPosTracking:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   279
                    if (!IsActive())
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   280
                        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   281
                        // can stop it right now
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   282
                        StopTracking();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   283
                        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   284
                    else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   285
                        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   286
                        // mark to stop later
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   287
                        iTrackingState = EPosStopTracking;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   288
                        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   289
                    break;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   290
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   291
                case EPosNoTracking:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   292
                case EPosStopTracking:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   293
                    break;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   294
                default:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   295
                    DebugPanic(EPosServerPanicTrackingInconsistency);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   296
                    break;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   297
                }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   298
            }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   299
        else if (oldInterval != 0) // "use another update interval"
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   300
            {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   301
            if (iRequestPhase == EPosReqInactive)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   302
                {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   303
                TInt err;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   304
                TRAP(err, RestartTrackingL());
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   305
                }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   306
            else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   307
                {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   308
                // can't affect outstanding request
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   309
                // postpone until request is completed
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   310
                // it will be handled by RunL or DoCancel
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   311
                // via HandleTrackingStateL
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   312
                iNewTrackingInterval = ETrue;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   313
                }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   314
            }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   315
        else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   316
            {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   317
            // oldInterval == 0
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   318
            // newInterval != 0
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   319
            // it means - "start periodic updates"
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   320
            iTrackingState = EPosFirstTrackingRequest;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   321
            }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   322
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   323
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   324
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   325
/**
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   326
 * Get the TPositionUpdateOptions object.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   327
 * @param aOptions The TPositionUpdateOptions object.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   328
 */
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   329
void CPositionRequest::GetUpdateOptions(
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   330
    TPositionUpdateOptionsBase& aOptions) const
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   331
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   332
    aOptions.SetUpdateTimeOut(iTimeOut);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   333
    aOptions.SetUpdateInterval(iTrackingUpdateInterval);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   334
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   335
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   336
/**
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   337
 * Stops current tracking session
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   338
 */
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   339
void CPositionRequest::NewTrackingSessionIfTracking()
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   340
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   341
    /* Requestor has been changed. Call Privacy Server. */
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   342
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   343
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   344
/**
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   345
 * Called when changes in locations settings occur.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   346
 * @param aEvent Event information
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   347
 */
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   348
void CPositionRequest::HandleSettingsChangeL(TPosModulesEvent aEvent)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   349
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   350
    if (aEvent.iModuleId != iModuleInfo.ModuleId())
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   351
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   352
        return;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   353
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   354
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   355
    switch (aEvent.iType)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   356
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   357
        case EPosModulesEventAvailabilityChanged:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   358
        case EPosModulesEventModuleInstalled:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   359
            iModuleSettings.PosModules().GetModuleInfoL(
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   360
                iModuleInfo.ModuleId(), 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   361
                iModuleInfo);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   362
            break;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   363
        case EPosModulesEventModuleRemoved:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   364
            iModuleInfo.SetIsAvailable(EFalse);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   365
            break;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   366
        default:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   367
            return;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   368
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   369
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   370
    if (!iModuleInfo.IsAvailable())
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   371
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   372
        if (IsActive())
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   373
            {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   374
            CompleteClient(KErrNotFound);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   375
            Cancel();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   376
            }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   377
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   378
        // Unuse positioner and unload it
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   379
        if (iTrackingState == EPosTracking)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   380
            {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   381
            StopPsyTracking();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   382
            }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   383
        delete iPositioner;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   384
        iPositioner = NULL;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   385
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   386
    else if (!iPositioner)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   387
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   388
        // psy is re-enabled after being disabled
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   389
        LoadPositionerL();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   390
        if (iTrackingState == EPosTracking)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   391
            {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   392
            StartPsyTrackingL();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   393
            }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   394
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   395
    else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   396
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   397
        // shouldn't happen, but if it does, ignore it
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   398
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   399
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   400
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   401
/**
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   402
 * Called when the server class is shutting down.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   403
 */
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   404
void CPositionRequest::NotifyServerShutdown()
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   405
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   406
    if (IsActive())
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   407
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   408
        DEBUG_TRACE("CPositionRequest::NotifyServerShutdown() with active request", __LINE__)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   409
        CompleteClient(KErrServerTerminated);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   410
        Cancel();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   411
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   412
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   413
    if (iTrackingState == EPosTracking)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   414
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   415
        StopTracking();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   416
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   417
    delete iPositioner;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   418
    iPositioner = NULL;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   419
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   420
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   421
/**
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   422
 * From CActive
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   423
 */
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   424
void CPositionRequest::RunL()
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   425
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   426
    LBS_RDEBUG_VAR_INT("CPositionRequest::RunL() iRequestPhase", iRequestPhase);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   427
    TInt err = iStatus.Int();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   428
    switch (iRequestPhase)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   429
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   430
        case EPosReqPositionRequest:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   431
            {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   432
            LBS_RDEBUG_INFO("CPositionRequest::RunL() EPosReqPositionRequest");
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   433
            // Position request finished. Cancel timer.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   434
            iTimeoutTimer->Cancel();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   435
            iRequestPhase = EPosReqInactive;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   436
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   437
            CompleteRequest(err);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   438
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   439
            HandleTrackingStateL(); // don't care if it leaves
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   440
            break;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   441
            }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   442
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   443
        case EPosWaitForTracking:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   444
            StartPositionDataRequestPhase();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   445
            break;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   446
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   447
        default :
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   448
        	DEBUG_TRACE("CPositionRequest::RunL() panicing", __LINE__)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   449
            DebugPanic(EPosServerPanicRequestInconsistency);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   450
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   451
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   452
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   453
/**
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   454
 * From CActive
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   455
 */
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   456
TInt CPositionRequest::RunError(TInt /*aError*/)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   457
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   458
    // Happens only if HandleTrackingStateL leaves
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   459
    // which in turn means that StartTrackingL leaved somewhere
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   460
    // As request is already completed, just ignore the error
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   461
    return KErrNone;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   462
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   463
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   464
/**
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   465
 * From CActive
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   466
 */
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   467
void CPositionRequest::DoCancel()
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   468
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   469
    OstTraceFunctionEntry1( CPOSITIONREQUEST_DOCANCEL_ENTRY, this );
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   470
    LBS_RDEBUG_VAR_INT("CPositionRequest::DoCancel() iRequestPhase", iRequestPhase);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   471
    iTimeoutTimer->Cancel();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   472
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   473
    switch (iRequestPhase)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   474
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   475
        case EPosReqPositionRequest:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   476
            {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   477
            __ASSERT_DEBUG(iPositioner, DebugPanic(EPosServerPanicPositionerNotInitialized));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   478
            DEBUG_TRACE("calling CPositioner::CancelNotifyPositionUpdate()", __LINE__)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   479
            if(iRequestTimedOut)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   480
            	{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   481
            	iPositioner->CancelNotifyPositionUpdate(KErrTimedOut);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   482
            	}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   483
            else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   484
            	{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   485
            	iPositioner->CancelNotifyPositionUpdate();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   486
            	}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   487
            break;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   488
            }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   489
        case EPosWaitForTracking:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   490
            CompleteSelf(KErrCancel);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   491
            break;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   492
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   493
        default:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   494
        	DEBUG_TRACE("CPositionRequest::DoCancel() panicing", __LINE__)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   495
            DebugPanic(EPosServerPanicRequestInconsistency);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   496
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   497
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   498
    TInt err;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   499
    if (iRequestTimedOut)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   500
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   501
        iRequestTimedOut = EFalse;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   502
        CompleteClient(KErrTimedOut);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   503
        TRAP(err, HandleTrackingStateL());
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   504
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   505
    else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   506
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   507
        CompleteClient(KErrCancel);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   508
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   509
        // Handle Tracking State
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   510
        if (iTrackingState == EPosStopTracking)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   511
            {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   512
            StopTracking();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   513
            }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   514
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   515
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   516
    iRequestPhase = EPosReqInactive;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   517
    OstTraceFunctionExit1( CPOSITIONREQUEST_DOCANCEL_EXIT, this );
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   518
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   519
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   520
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   521
void CPositionRequest::CompleteSelf(TInt aReason)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   522
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   523
    TRequestStatus* status = &iStatus;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   524
    User::RequestComplete(status, aReason);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   525
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   526
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   527
void CPositionRequest::CompleteClient(TInt aReason)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   528
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   529
    if (!iMessage.IsNull())
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   530
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   531
		LBS_RDEBUG_ARGINT("LBS","Client", "RunL", aReason);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   532
        iMessage.Complete(aReason);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   533
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   534
    //Decrement the StatusKeyValue for Positioning Indicator clients
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   535
    if(iTrackingState == EPosNoTracking)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   536
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   537
        TInt     count, err;     
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   538
        err = RProperty::Get(iPosStatusCategory, KLbsMoPositioningStatusKey, count);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   539
        if(err == KErrNone && count > 0)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   540
            {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   541
            err = RProperty::Set(iPosStatusCategory, KLbsMoPositioningStatusKey, count-1);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   542
            }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   543
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   544
        if(err != KErrNone)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   545
            {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   546
            DEBUG_TRACE("CPositionRequest::StopTracking() - error in getting or setting Positioning Status", __LINE__)            
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   547
            }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   548
        else if (count <=0)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   549
            {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   550
            DEBUG_TRACE("CPositionRequest::StopTracking() - Incorrect Positioning Status tracking count", __LINE__)            
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   551
            }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   552
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   553
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   554
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   555
void CPositionRequest::CompleteRequest(TInt aReason)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   556
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   557
    // Return fix to the client
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   558
    if (aReason == KErrNone || aReason == KPositionPartialUpdate)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   559
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   560
        TInt err = PackPositionData();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   561
        // err - client cannot receive result data
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   562
        CompleteClient((err != KErrNone) ? err : aReason);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   563
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   564
        // Save current fix to LastKnownPosition handler
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   565
        // partial updates are not stored
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   566
        if ( aReason == KErrNone )
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   567
            {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   568
            SaveAsLastKnownPosition();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   569
            }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   570
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   571
    else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   572
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   573
        CompleteClient(aReason);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   574
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   575
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   576
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   577
void CPositionRequest::StartPositionDataRequestPhase()
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   578
    {  
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   579
    LBS_RDEBUG_VAR_INT("CPositionRequest::StartPositionDataRequestPhase() iRequestPhase", iRequestPhase);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   580
    
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   581
    __ASSERT_DEBUG(iPositioner,
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   582
        DebugPanic(EPosServerPanicPositionerNotInitialized));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   583
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   584
    iReqStartTime.UniversalTime();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   585
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   586
    TPositionInfo& info = PositionInfo(iPositionBuffer);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   587
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   588
    // Set datum type to WGS84
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   589
    TPosition position;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   590
    info.GetPosition(position);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   591
    position.SetDatum(KPositionDatumWgs84);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   592
    info.SetPosition(position);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   593
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   594
    TPositionInfoBase& infoBase = reinterpret_cast<TPositionInfoBase&>(info);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   595
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   596
    // issue request to psy
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   597
    DEBUG_TRACE("calling CPositioner::NotifyPositionUpdate()", __LINE__)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   598
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   599
    iStatus = KRequestPending;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   600
    iPositioner->NotifyPositionUpdate(infoBase, iStatus);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   601
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   602
    iRequestPhase = EPosReqPositionRequest;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   603
    SetActive();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   604
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   605
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   606
void CPositionRequest::StartTrackingTimerWaitPhase()
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   607
{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   608
	LBS_RDEBUG_VAR_INT("CPositionRequest::StartTrackingTimerWaitPhase() iRequestPhase", iRequestPhase);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   609
    iRequestPhase = EPosWaitForTracking;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   610
    iStatus = KRequestPending;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   611
    SetActive();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   612
}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   613
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   614
TInt CPositionRequest::PackPositionData()
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   615
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   616
    TPositionInfo& info = PositionInfo(iPositionBuffer);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   617
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   618
    // Verify that ModuleId, set by PSY, is correct if using specific PSY.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   619
    // If a proxy PSY is used, the proxy is responsible for verifying UID.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   620
    if (!iHasProxyPositioner &&
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   621
        info.ModuleId() != iPositionerParams.iImplementationUid)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   622
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   623
        return KErrGeneral;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   624
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   625
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   626
    // Check that datum type still is WGS84
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   627
    TPosition position;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   628
    info.GetPosition(position);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   629
    if (position.Datum() != KPositionDatumWgs84)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   630
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   631
        return KErrNotSupported;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   632
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   633
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   634
    TPtr8 ptrToBuffer = iPositionBuffer->Des();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   635
    return Global::Write(iMessage, KParamPositionInfo, ptrToBuffer);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   636
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   637
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   638
void CPositionRequest::SaveAsLastKnownPosition()
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   639
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   640
    TPosition pos;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   641
    TPositionInfo& positionInfo = PositionInfo(iPositionBuffer);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   642
    positionInfo.GetPosition(pos);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   643
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   644
    // Don't set last known position if the position request is in the past. //TODO check if this is required
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   645
    if (iReqStartTime <= pos.Time())
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   646
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   647
        iLocMonitorReqHandler.SetPositionInfo(positionInfo);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   648
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   649
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   650
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   651
TInt CPositionRequest::HandleTimeOut(TAny* aPositionRequest)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   652
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   653
    CPositionRequest* self =
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   654
        reinterpret_cast<CPositionRequest*>(aPositionRequest);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   655
    
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   656
    LBS_RDEBUG_VAR_INT("CPositionRequest::HandleTimeOut() iRequestPhase", self->iRequestPhase);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   657
    DEBUG_TRACE("CPositionRequest::HandleTimeOut()", __LINE__)    
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   658
    __ASSERT_DEBUG(self->iRequestPhase == EPosReqPositionRequest || self->iRequestPhase == EPosWaitForTracking,
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   659
        DebugPanic(EPosServerPanicRequestInconsistency));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   660
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   661
    self->iRequestTimedOut = ETrue;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   662
    self->Cancel();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   663
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   664
    return KErrNone;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   665
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   666
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   667
TInt CPositionRequest::TrackingCallback(TAny* aPositionRequest)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   668
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   669
    CPositionRequest* self =
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   670
        reinterpret_cast<CPositionRequest*>(aPositionRequest);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   671
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   672
    // continue tracking timer
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   673
    if (self->iTrackingState == EPosTracking)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   674
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   675
        self->ContinueTrackingTimer();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   676
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   677
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   678
    if (self->iRequestPhase == EPosWaitForTracking)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   679
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   680
        // This is the normal case. The client's request was delayed
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   681
        // by the update interval.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   682
        // Complete tracking timer waiting and go next stage
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   683
        self->CompleteSelf(KErrNone);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   684
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   685
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   686
    return KErrNone;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   687
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   688
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   689
void CPositionRequest::HandleTrackingStateL()
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   690
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   691
    switch (iTrackingState)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   692
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   693
        case EPosNoTracking:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   694
            break;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   695
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   696
        case EPosFirstTrackingRequest:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   697
            // start internal tracking
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   698
            iTrackingState = EPosTracking;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   699
            ContinueTrackingTimer();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   700
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   701
            StartPsyTrackingL();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   702
            break;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   703
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   704
        case EPosTracking:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   705
            // if tracking interval was changed
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   706
            if (iNewTrackingInterval)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   707
                {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   708
                RestartTrackingL();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   709
                }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   710
            break;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   711
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   712
        case EPosStopTracking:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   713
            StopTracking();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   714
            break;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   715
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   716
        default:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   717
            DebugPanic(EPosServerPanicTrackingInconsistency);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   718
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   719
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   720
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   721
void CPositionRequest::StartPsyTrackingL()
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   722
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   723
    __ASSERT_DEBUG(iPositioner, DebugPanic(EPosServerPanicPositionerNotInitialized));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   724
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   725
    iNewTrackingInterval = EFalse;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   726
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   727
    DEBUG_TRACE("calling CPositioner::TrackingOverridden()", __LINE__)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   728
    if (iPositioner->TrackingOverridden())
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   729
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   730
        DEBUG_TRACE("calling CPositioner::StartTrackingL()", __LINE__)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   731
        iPositioner->StartTrackingL(iTrackingUpdateInterval);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   732
        iPositionerTrackingStarted = ETrue;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   733
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   734
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   735
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   736
void CPositionRequest::RestartTrackingL()
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   737
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   738
    LBS_RDEBUG_INFO("CPositionRequest::RestartTrackingL()");
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   739
    iTrackingTimer->Cancel();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   740
    StopPsyTracking();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   741
    ContinueTrackingTimer();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   742
    StartPsyTrackingL();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   743
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   744
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   745
void CPositionRequest::StopTracking()
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   746
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   747
    LBS_RDEBUG_INFO("CPositionRequest::StopTracking()");
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   748
    iTrackingTimer->Cancel();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   749
    iTrackingState = EPosNoTracking;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   750
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   751
    StopPsyTracking();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   752
    
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   753
    //Set PositionIndicator Off
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   754
    TInt     count, err;     
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   755
    err = RProperty::Get(iPosStatusCategory, KLbsMoPositioningStatusKey, count);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   756
    if(err == KErrNone && count > 0)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   757
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   758
        err = RProperty::Set(iPosStatusCategory, KLbsMoPositioningStatusKey, count-1);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   759
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   760
    
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   761
    if(err != KErrNone)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   762
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   763
        DEBUG_TRACE("CPositionRequest::StopTracking() - error in getting or setting Positioning Status", __LINE__)            
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   764
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   765
    else if (count <=0)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   766
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   767
        DEBUG_TRACE("CPositionRequest::StopTracking() - Incorrect Positioning Status tracking count", __LINE__)            
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   768
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   769
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   770
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   771
void CPositionRequest::StopPsyTracking()
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   772
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   773
    if (iPositioner && iPositionerTrackingStarted)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   774
        {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   775
        DEBUG_TRACE("calling CPositioner::StopTracking()", __LINE__)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   776
        iPositioner->StopTracking();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   777
        iPositionerTrackingStarted = EFalse;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   778
        }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   779
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   780
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   781
void CPositionRequest::ContinueTrackingTimer()
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   782
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   783
    LBS_RDEBUG_INFO("CPositionRequest::ContinueTrackingTimer()");
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   784
    iTrackingTimer->StartTimer(iTrackingUpdateInterval);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   785
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   786
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   787
void CPositionRequest::LoadPositionerL()
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   788
    {
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   789
    iPositioner = CPositioner::NewL(&iPositionerParams);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   790
    iPositionerTrackingStarted = EFalse;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   791
    }
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   792
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   793
void CPositionRequest::ExtendUpdateTimeOut(const TTimeIntervalMicroSeconds& aAdditionalTime)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   794
	{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   795
	LBS_RDEBUG_INFO("CPositionRequest::ExtendUpdateTimeOut()");
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   796
	iTimeoutTimer->ExtendTimeout(aAdditionalTime);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   797
	}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   798
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   799
//  End of File