|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 #include "lbsearlycompletionupdatehandler.h" |
|
18 #include <lbs/lbsextendedsatellite.h> |
|
19 |
|
20 CEarlyCompletionUpdateHandler * CEarlyCompletionUpdateHandler::NewL |
|
21 ( |
|
22 MLbsEarlyCompletionUpdateObserver* aObserver |
|
23 ) |
|
24 { |
|
25 |
|
26 CEarlyCompletionUpdateHandler * self = new(ELeave) CEarlyCompletionUpdateHandler (aObserver); |
|
27 |
|
28 CleanupStack::PushL(self); |
|
29 |
|
30 self->ConstructL(); |
|
31 CleanupStack::Pop(); |
|
32 |
|
33 return self; |
|
34 } |
|
35 |
|
36 |
|
37 |
|
38 CEarlyCompletionUpdateHandler::CEarlyCompletionUpdateHandler(MLbsEarlyCompletionUpdateObserver* aObserver) : |
|
39 CActive(CActive::EPriorityStandard), |
|
40 iObserver(aObserver) |
|
41 { |
|
42 |
|
43 } |
|
44 |
|
45 void CEarlyCompletionUpdateHandler::DoCancel() |
|
46 { |
|
47 // cancel RLbsPositionUpdateRequests aync request |
|
48 iEarlyCompletionPosUpdates.CancelNotifyPositionUpdate(); |
|
49 } |
|
50 |
|
51 void CEarlyCompletionUpdateHandler::ListenForEarlyCompletionUpdates() |
|
52 { |
|
53 Cancel(); |
|
54 iEarlyCompletionPosUpdates.NotifyPositionUpdate(iStatus); |
|
55 SetActive(); |
|
56 } |
|
57 |
|
58 void CEarlyCompletionUpdateHandler::ConstructL() |
|
59 { |
|
60 iEarlyCompletionPosUpdates.OpenL(KLbsLocServerUid); |
|
61 CActiveScheduler::Add(this); |
|
62 } |
|
63 |
|
64 //------------------------------------------------------------------------------------------------------------ |
|
65 CEarlyCompletionUpdateHandler::~CEarlyCompletionUpdateHandler() |
|
66 { |
|
67 Cancel(); |
|
68 iEarlyCompletionPosUpdates.Close(); |
|
69 } |
|
70 |
|
71 |
|
72 TInt CEarlyCompletionUpdateHandler::RunError(TInt aError) |
|
73 { |
|
74 // handle RunL leaving - in our case we do nothing |
|
75 // as this means we have had encountered a program inconsistency |
|
76 // By doing nothing here causes the main manager thread to exit |
|
77 // and the Lbs root process resolves any issues - by stopping and restarting |
|
78 // lbs components |
|
79 return aError; |
|
80 |
|
81 } |
|
82 |
|
83 void CEarlyCompletionUpdateHandler::RunL() |
|
84 { |
|
85 TInt status = iStatus.Int(); |
|
86 |
|
87 // Expect further updates |
|
88 ListenForEarlyCompletionUpdates(); |
|
89 |
|
90 switch (status) |
|
91 { |
|
92 case KErrNone: |
|
93 { |
|
94 TPositionExtendedSatelliteInfo satInfo; |
|
95 TTime targetTime; |
|
96 TTime actualTime; |
|
97 TBool conflict; |
|
98 |
|
99 TInt ret = iEarlyCompletionPosUpdates.GetAsMuchAsCanPositionInfo(conflict, &satInfo, sizeof(satInfo), targetTime, actualTime); |
|
100 |
|
101 // Loc Server must publish the position with this code: |
|
102 if (KPositionEarlyComplete == ret) |
|
103 { |
|
104 // only pass on good locations - discard any associated with errors |
|
105 __ASSERT_DEBUG(iObserver!= NULL,User::Panic(_L("CEarlyCompletionUpdateHandler1"), KErrArgument)); |
|
106 iObserver->EarlyCompletionUpdate(satInfo, targetTime, actualTime); // call back to observer (MainLogic) |
|
107 } |
|
108 __ASSERT_DEBUG(ret == KPositionEarlyComplete, User::Panic(_L("CEarlyCompletionUpdateHandler2"), KErrArgument)); |
|
109 |
|
110 break; |
|
111 } |
|
112 default: |
|
113 { |
|
114 User::LeaveIfError(status); |
|
115 break; |
|
116 } |
|
117 } |
|
118 } |
|
119 |
|
120 |
|
121 |
|
122 |