|
1 /* |
|
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Active class to reteive the coordiantes for current location |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 #include "calencurrentlocationacquisition.h" |
|
22 //debug |
|
23 #include "calendarui_debug.h" |
|
24 |
|
25 |
|
26 // ---------------------------------------------------------------------------- |
|
27 // CCalenCurrentLocationAcquisition::NewL |
|
28 // First stage construction |
|
29 // (other items were commented in a header). |
|
30 // ---------------------------------------------------------------------------- |
|
31 // |
|
32 CCalenCurrentLocationAcquisition* CCalenCurrentLocationAcquisition::NewL( MCalenCurrentLocationObserver& aObserver ) |
|
33 { |
|
34 CCalenCurrentLocationAcquisition* self = new ( ELeave ) CCalenCurrentLocationAcquisition(aObserver); |
|
35 CleanupStack::PushL( self ); |
|
36 self->ConstructL(); |
|
37 CleanupStack::Pop(self); // self |
|
38 return self; |
|
39 } |
|
40 |
|
41 // ---------------------------------------------------------------------------- |
|
42 // CCalenCurrentLocationAcquisition::CCalenCurrentLocationAcquisition |
|
43 // C++ constructor |
|
44 // (other items were commented in a header). |
|
45 // ---------------------------------------------------------------------------- |
|
46 // |
|
47 CCalenCurrentLocationAcquisition::CCalenCurrentLocationAcquisition(MCalenCurrentLocationObserver& aObserver) |
|
48 :CActive( CActive::EPriorityStandard ), |
|
49 iObserver(aObserver) |
|
50 { |
|
51 CActiveScheduler::Add( this ); |
|
52 } |
|
53 |
|
54 // ---------------------------------------------------------------------------- |
|
55 // CCalenCurrentLocationAcquisition::ConstructL |
|
56 // Symbian 2nd phase constructor |
|
57 // (other items were commented in a header). |
|
58 // ---------------------------------------------------------------------------- |
|
59 // |
|
60 void CCalenCurrentLocationAcquisition::ConstructL() |
|
61 { |
|
62 _LIT(AppName, "Calendar"); |
|
63 HBufC* srvName = HBufC::NewL(20); |
|
64 srvName->Des().Copy(AppName); |
|
65 User::LeaveIfError(iServer.Connect()); |
|
66 User::LeaveIfError(iPositioner.Open( iServer )); |
|
67 |
|
68 User::LeaveIfError( iPositioner.SetRequestor( |
|
69 CRequestor::ERequestorService, |
|
70 CRequestor::EFormatApplication, |
|
71 *srvName )); |
|
72 } |
|
73 |
|
74 // ---------------------------------------------------------------------------- |
|
75 // CCalenCurrentLocationAcquisition::~CCalenCurrentLocationAcquisition |
|
76 // Destructor |
|
77 // (other items were commented in a header). |
|
78 // ---------------------------------------------------------------------------- |
|
79 // |
|
80 CCalenCurrentLocationAcquisition::~CCalenCurrentLocationAcquisition() |
|
81 { |
|
82 Cancel(); |
|
83 iPositioner.Close(); |
|
84 iServer.Close(); |
|
85 } |
|
86 |
|
87 // ---------------------------------------------------------------------------- |
|
88 // CCalenCurrentLocationAcquisition::RequestL |
|
89 // Requests for current location asynchronously |
|
90 // (other items were commented in a header). |
|
91 // ---------------------------------------------------------------------------- |
|
92 // |
|
93 void CCalenCurrentLocationAcquisition::RequestL() |
|
94 { |
|
95 iPositioner.NotifyPositionUpdate( iPositionInfo, iStatus ); |
|
96 SetActive(); |
|
97 } |
|
98 |
|
99 // ---------------------------------------------------------------------------- |
|
100 // CCalenCurrentLocationAcquisition::CurrentPosition |
|
101 // Function to return current position details |
|
102 // (other items were commented in a header). |
|
103 // ---------------------------------------------------------------------------- |
|
104 // |
|
105 TPosition& CCalenCurrentLocationAcquisition::CurrentPosition() |
|
106 { |
|
107 return iPosition; |
|
108 } |
|
109 |
|
110 // ---------------------------------------------------------------------------- |
|
111 // CCalenCurrentLocationAcquisition::CancelRequest |
|
112 // Cancels the ongoing request |
|
113 // (other items were commented in a header). |
|
114 // ---------------------------------------------------------------------------- |
|
115 // |
|
116 void CCalenCurrentLocationAcquisition::CancelRequest() |
|
117 { |
|
118 Cancel(); |
|
119 } |
|
120 |
|
121 // ---------------------------------------------------------------------------- |
|
122 // CCalenCurrentLocationAcquisition::RunL |
|
123 // RunL method to handle the user selection |
|
124 // (other items were commented in a header). |
|
125 // ---------------------------------------------------------------------------- |
|
126 // |
|
127 void CCalenCurrentLocationAcquisition::RunL() |
|
128 { |
|
129 switch ( iStatus.Int() ) |
|
130 { |
|
131 case KErrNone: |
|
132 case KPositionPartialUpdate: |
|
133 { |
|
134 iPositionInfo.GetPosition( iPosition ); |
|
135 TReal32 altitude = iPosition.Altitude(); |
|
136 if (Math::IsNaN( altitude)) |
|
137 { |
|
138 TRealX nan; |
|
139 nan.SetNaN(); |
|
140 iPosition.SetVerticalAccuracy( nan ); |
|
141 } |
|
142 iObserver.NotifyCurrentLocationL( ); |
|
143 break; |
|
144 } |
|
145 case KErrAccessDenied: |
|
146 case KPositionQualityLoss: |
|
147 case KErrTimedOut: |
|
148 case KErrNotFound: // No PSY selected. |
|
149 case KErrUnknown: |
|
150 case KErrCancel: |
|
151 case KErrArgument: |
|
152 default: |
|
153 { |
|
154 // Notify error to observer |
|
155 iObserver.NotifyErrorL(iStatus.Int()); |
|
156 } |
|
157 } |
|
158 } |
|
159 |
|
160 // ---------------------------------------------------------------------------- |
|
161 // CCalenCurrentLocationAcquisition::DoCancel |
|
162 // Cancel method to handle the user selection |
|
163 // (other items were commented in a header). |
|
164 // ---------------------------------------------------------------------------- |
|
165 // |
|
166 void CCalenCurrentLocationAcquisition::DoCancel() |
|
167 { |
|
168 iPositioner.CancelRequest( EPositionerNotifyPositionUpdate ); |
|
169 } |
|
170 |
|
171 // ---------------------------------------------------------------------------- |
|
172 // CCalenCurrentLocationAcquisition::RunError |
|
173 // Function to handle any errors in async request |
|
174 // (other items were commented in a header). |
|
175 // ---------------------------------------------------------------------------- |
|
176 // |
|
177 TInt CCalenCurrentLocationAcquisition::RunError(TInt aError) |
|
178 { |
|
179 PIM_TRAPD_HANDLE(iObserver.NotifyErrorL( aError )); |
|
180 return KErrNone; |
|
181 } |
|
182 |
|
183 // End of File |