|
1 /* |
|
2 * Copyright (c) 2006-2009 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: Remap location data to location objects* |
|
15 */ |
|
16 |
|
17 |
|
18 #ifndef LOCATIONREMAPPINGAO_H_ |
|
19 #define LOCATIONREMAPPINGAO_H_ |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <etel3rdparty.h> |
|
23 #include <LbsPosition.h> |
|
24 #include <centralrepository.h> |
|
25 |
|
26 #include "locationdatatype.h" |
|
27 #include "mdesession.h" |
|
28 #include "rlocationtrail.h" |
|
29 #include "locationmanagerdebug.h" |
|
30 #include "locationtraildefs.h" |
|
31 |
|
32 |
|
33 class TRemapItem |
|
34 { |
|
35 public: |
|
36 TRemapItem(); |
|
37 public: |
|
38 TItemId iObjectId; |
|
39 TItemId iLocationId; |
|
40 TItemId iRelationId; |
|
41 TTime iTime; |
|
42 }; |
|
43 |
|
44 /** |
|
45 * Class is handling remapping operations |
|
46 */ |
|
47 class CLocationRemappingAO : public CActive |
|
48 { |
|
49 |
|
50 public: |
|
51 |
|
52 /** |
|
53 * Remapping Active object states |
|
54 */ |
|
55 enum TMappingState |
|
56 { |
|
57 EIdle = 0, |
|
58 //EGatherObjects, |
|
59 ERemapObjects, |
|
60 ECommitObjects |
|
61 }; |
|
62 |
|
63 /** |
|
64 * Creates and constructs a new instance of CCameraTrailMonitorAO. |
|
65 * |
|
66 * @return A pointer to the new instance of CCameraTrailMonitorAO |
|
67 */ |
|
68 static CLocationRemappingAO* NewL(); |
|
69 |
|
70 /** |
|
71 * Destructor |
|
72 */ |
|
73 virtual ~CLocationRemappingAO(); |
|
74 |
|
75 /** |
|
76 * Stops remapping |
|
77 * |
|
78 * @return ETrue if success, EFalse if not |
|
79 */ |
|
80 void StopRemapping(); |
|
81 |
|
82 void Append( TRemapItem aItem ); |
|
83 |
|
84 void ResetQueue(); |
|
85 |
|
86 TBool ItemsInQueue(); |
|
87 |
|
88 /** |
|
89 * Check items in remapping queue |
|
90 * |
|
91 * @return ETrue if new location object must be created for remapping |
|
92 */ |
|
93 TBool CheckQueue(); |
|
94 |
|
95 /** |
|
96 * Remap location objects between time limits. |
|
97 */ |
|
98 void StartRemappingObjects( const TLocationData& aLocationData ); |
|
99 |
|
100 /** |
|
101 * Inherited from CActive. This method will be called on file server notifying. |
|
102 */ |
|
103 void RunL(); |
|
104 |
|
105 /** |
|
106 * Initialise parameters |
|
107 * |
|
108 * @param aMdEClient, Instance of CMdESession |
|
109 */ |
|
110 void InitialiseL(CMdESession* aMdEClient); |
|
111 |
|
112 /** |
|
113 * Inherited from CActive. Handles a leave occurring in the request completion event handler RunL(). |
|
114 * |
|
115 * @param aError An error code. |
|
116 * @return An error code. |
|
117 */ |
|
118 TInt RunError( TInt aError ); |
|
119 |
|
120 /** |
|
121 * Inherited from CActive. |
|
122 */ |
|
123 void DoCancel(); |
|
124 |
|
125 /** |
|
126 * Update relations to new location object |
|
127 * |
|
128 * @param aLocationId, locationId for relations |
|
129 */ |
|
130 void UpdateRelationsL( TItemId aLocationId ); |
|
131 private: |
|
132 |
|
133 /** |
|
134 * C++ constructor - not exported; |
|
135 * implicitly called from NewL() |
|
136 */ |
|
137 CLocationRemappingAO(); |
|
138 |
|
139 /** |
|
140 * 2nd phase construction, called by NewL() |
|
141 */ |
|
142 void ConstructL(); |
|
143 |
|
144 /** |
|
145 * Set AO next state |
|
146 */ |
|
147 void NextState(TMappingState aState); |
|
148 |
|
149 |
|
150 /** |
|
151 * Remap objects data |
|
152 */ |
|
153 void RemapObjectsL(); |
|
154 |
|
155 /** |
|
156 * Commit remapped objects to database |
|
157 */ |
|
158 void CommitObjectsL(); |
|
159 |
|
160 /** |
|
161 * Read time limit value from Central Repository |
|
162 */ |
|
163 void ReadTimeFromCenRepL(); |
|
164 |
|
165 private: |
|
166 |
|
167 /** |
|
168 * Active object state |
|
169 */ |
|
170 TMappingState iState; |
|
171 |
|
172 /** |
|
173 * Is there come a new remapping request when |
|
174 * AO have been executing earlier request. |
|
175 */ |
|
176 TBool iContinue; |
|
177 |
|
178 /** |
|
179 * Is start time earlier stamped. |
|
180 */ |
|
181 TBool iTimed; |
|
182 |
|
183 /** |
|
184 * Is location data requested from Location Mananger |
|
185 */ |
|
186 TBool iRequested; |
|
187 |
|
188 /** |
|
189 * Instance of MdeClient |
|
190 */ |
|
191 CMdESession* iMdEClient; |
|
192 |
|
193 /** |
|
194 * Database definitions. |
|
195 */ |
|
196 CMdENamespaceDef* iNamespaceDef; |
|
197 CMdEObjectDef* iObjImageDef; |
|
198 CMdEObjectDef* iObjVideoDef; |
|
199 CMdEPropertyDef* iPropDateDef; |
|
200 CMdEPropertyDef* iPropModifiedDef; |
|
201 CMdEObjectDef* iObjLocationDef; |
|
202 CMdEPropertyDef* iPropLatDef; |
|
203 CMdEPropertyDef* iPropLongDef; |
|
204 CMdEPropertyDef* iPropAltDef; |
|
205 CMdERelationDef* iContainsLocationRelDef; |
|
206 |
|
207 /** |
|
208 * Object id's which location data will be remapped. |
|
209 */ |
|
210 RArray<TItemId> iObjectIds; |
|
211 |
|
212 /** |
|
213 * Location objects which location data will remapped |
|
214 * and it will committed back to Mde. |
|
215 */ |
|
216 RPointerArray<CMdEObject> iObjects; |
|
217 |
|
218 /** |
|
219 * Array of Items to be remapped |
|
220 */ |
|
221 RArray<TRemapItem> iRemapItems; |
|
222 |
|
223 /** |
|
224 * When location trail have started. |
|
225 * Time is compared to time when GPS fix is received. |
|
226 */ |
|
227 TTime iStartTime; |
|
228 |
|
229 /** |
|
230 * When GPS fix is received. |
|
231 */ |
|
232 TTime iEndTime; |
|
233 |
|
234 /** |
|
235 * Time limit for object data mapping (Default is 10min -> 600s) |
|
236 */ |
|
237 TTimeIntervalSeconds iTimeLimit; |
|
238 |
|
239 /** |
|
240 * Location data |
|
241 */ |
|
242 TLocationData iLocationData; |
|
243 |
|
244 }; |
|
245 |
|
246 |
|
247 #endif /*LOCATIONREMAPPINGAO_H_*/ |