|
1 /* |
|
2 * Copyright (c) 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: A class responsible for geotagging of media files in background. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef C_CINTERNALGEOTAGGER_H |
|
19 #define C_CINTERNALGEOTAGGER_H |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <e32property.h> |
|
23 #include <lbs.h> |
|
24 #include <locationdatatype.h> |
|
25 #include <geotagger.h> |
|
26 |
|
27 #include "mdccommon.h" |
|
28 #include "mdesession.h" |
|
29 #include "mdenamespacedef.h" |
|
30 #include "mdeobjectdef.h" |
|
31 #include "mdepropertydef.h" |
|
32 #include "mderelation.h" |
|
33 #include "mdequery.h" |
|
34 |
|
35 #ifdef LOC_GEOTAGGING_CELLID |
|
36 #include "cgeoconverter.h" |
|
37 #endif |
|
38 |
|
39 #ifdef LOC_REVERSEGEOCODE |
|
40 #include "ctagcreator.h" |
|
41 #include "reversegeocode.h" |
|
42 class CReverseGeoCoderPlugin; |
|
43 #endif |
|
44 |
|
45 |
|
46 /** |
|
47 * GeoTagger converts a given cell ID(CGI Info) to geo-coordinates. |
|
48 * Does reverse geocoding to get country and city name. |
|
49 * Creates country and city tag for image/video files. |
|
50 * @since S60 9.2 |
|
51 */ |
|
52 |
|
53 class CInternalGeoTagger : public CGeoTagger, |
|
54 public MMdESessionObserver, |
|
55 public MMdEQueryObserver |
|
56 #ifdef LOC_GEOTAGGING_CELLID |
|
57 ,public MGeoConverterObserver |
|
58 #endif |
|
59 #ifdef LOC_REVERSEGEOCODE |
|
60 ,public MReverseGeocodeObserver |
|
61 #endif |
|
62 { |
|
63 public: |
|
64 |
|
65 /** |
|
66 * 2-phased constructor. |
|
67 * @param aMdeSession An instance of the CMdESession |
|
68 * @param aObserver The observer that is to be notified when geotagging is over |
|
69 */ |
|
70 IMPORT_C static CInternalGeoTagger* NewL( CMdESession* aMdeSession, |
|
71 MGeoTaggerObserver* aObserver ); |
|
72 |
|
73 /** |
|
74 * C++ destructor. |
|
75 */ |
|
76 IMPORT_C virtual ~CInternalGeoTagger(); |
|
77 |
|
78 |
|
79 public: //exported API |
|
80 // CGeoTagger |
|
81 /** |
|
82 * Harvests location tags. |
|
83 * @param aObserver, observer for geotagging. |
|
84 * @return None. |
|
85 */ |
|
86 virtual void CreateGeoTagsL( const TConnectionOption = EInteractive ); |
|
87 |
|
88 /** |
|
89 * Checks if there is any untagged photos with location info and tags them. |
|
90 * @param aTagInProgress, boolean value to indicate if geotagging is in progress. |
|
91 * @return None. |
|
92 */ |
|
93 virtual void PendingGeoTagsL( TBool aTagInProgress ); |
|
94 |
|
95 public: //observer methods |
|
96 |
|
97 // From MMdEQueryObserver |
|
98 |
|
99 /** |
|
100 * @param aQuery the query type |
|
101 * @param aFirstNewItemIndex The new item index |
|
102 * @param aNewItemCount The new item count |
|
103 */ |
|
104 void HandleQueryNewResults(CMdEQuery& aQuery, TInt aFirstNewItemIndex, |
|
105 TInt aNewItemCount); |
|
106 |
|
107 /** |
|
108 * This method is called on completion of a query |
|
109 * @param aQuery the query type |
|
110 * @param aError Error if any |
|
111 */ |
|
112 void HandleQueryCompleted(CMdEQuery& aQuery, TInt aError); |
|
113 |
|
114 |
|
115 #ifdef LOC_REVERSEGEOCODE |
|
116 /** |
|
117 * Get location objects, where lat, long not populated. |
|
118 * @param aCountryTagId The country tagId |
|
119 * @param aCityTagId The city tagId |
|
120 */ |
|
121 void AddressInfoL( const TItemId aCountryTagId, const TItemId aCityTagId ); |
|
122 |
|
123 |
|
124 //MReverseGeocodeObserver |
|
125 /** |
|
126 * This method is called when reverse geocoding is completed |
|
127 *@param aErrorcode Error if any |
|
128 *@param aAddressInfo the reverse geocoded address |
|
129 */ |
|
130 void ReverseGeocodeComplete( TInt& aErrorcode, MAddressInfo& aAddressInfo ); |
|
131 |
|
132 /* |
|
133 * Get registrer network country code |
|
134 * |
|
135 * @return current register n/w info |
|
136 */ |
|
137 RMobilePhone::TMobilePhoneNetworkInfoV2& GetCurrentRegisterNw(); |
|
138 |
|
139 /* |
|
140 * UE is registered to home network? |
|
141 * |
|
142 * @return ETrue if UE is registered at home network else EFalse |
|
143 */ |
|
144 TBool IsRegisteredAtHomeNetwork(); |
|
145 |
|
146 |
|
147 /* |
|
148 * Get home network country code |
|
149 * @param aHomeNwInfoAvailableFlag ETrue if home n/w info available else EFalse |
|
150 * @return user home n/w info |
|
151 */ |
|
152 const RMobilePhone::TMobilePhoneNetworkInfoV1& |
|
153 GetHomeNetworkInfo(TBool& aHomeNwInfoAvailableFlag); |
|
154 |
|
155 #endif //LOC_REVERSEGEOCODE |
|
156 |
|
157 // From MMdESessionObserver |
|
158 |
|
159 /** |
|
160 * Handles session opening |
|
161 *@param aSession A reference of the CMdESession |
|
162 *@param aError error if any |
|
163 */ |
|
164 void HandleSessionOpened(CMdESession& aSession, TInt aError); |
|
165 |
|
166 /** |
|
167 * Handles any error in session opening |
|
168 *@param aSession A reference of the CMdESession |
|
169 *@param aError error if any |
|
170 */ |
|
171 void HandleSessionError(CMdESession& aSession, TInt aError); |
|
172 |
|
173 #ifdef LOC_GEOTAGGING_CELLID |
|
174 public: // MGeoConverterObserver |
|
175 /** |
|
176 * This method is used for notifying completion of geotagging |
|
177 * @param aError error code |
|
178 * @param aPosition position (lat/lon) for the correcponding n/w info |
|
179 */ |
|
180 void ConversionCompletedL( const TInt aError, TLocality& aPosition ); |
|
181 |
|
182 |
|
183 /** |
|
184 * This method is used to handle the conversion error |
|
185 * @param aError the error code |
|
186 */ |
|
187 void HandleConversionError(TInt aError); |
|
188 |
|
189 private: |
|
190 /** |
|
191 * Update media object with GPS info. |
|
192 */ |
|
193 void UpdateGPSInfoL(const TLocality& aPosition); |
|
194 |
|
195 #endif //LOC_GEOTAGGING_CELLID |
|
196 |
|
197 private: |
|
198 |
|
199 /** |
|
200 * C++ constructor. |
|
201 * @param aMdeSession An instance of the CMdESession |
|
202 * @param aObserver The observer that is to be notified when geotagging is over |
|
203 */ |
|
204 CInternalGeoTagger( CMdESession* aMdeSession, MGeoTaggerObserver* aObserver ); |
|
205 |
|
206 /** |
|
207 * 2nd phase constructor. |
|
208 */ |
|
209 void ConstructL(); |
|
210 |
|
211 /** |
|
212 * Get all relation objects associated with this location |
|
213 * @param aLocID The locationId whose relation is to be fetched |
|
214 */ |
|
215 void GetRelationObjectsL(TItemId aLocID); |
|
216 |
|
217 /** |
|
218 * get tags for this image |
|
219 * @param aImageID The imageIs whose tag is to be fetched |
|
220 */ |
|
221 void GetTagsL( TItemId aImageID ); |
|
222 |
|
223 /** |
|
224 * Get location objects, where lat, long not populated. |
|
225 */ |
|
226 void GetAllLocationsL( ); |
|
227 |
|
228 /** |
|
229 * checks if the session is ready |
|
230 * @return ETrue If the session is ready |
|
231 */ |
|
232 TBool IsSessionReady(); |
|
233 |
|
234 /** |
|
235 * Fetches the location information |
|
236 */ |
|
237 void GetLocationInfoL(); |
|
238 |
|
239 /** |
|
240 * starts geotagging of objects |
|
241 */ |
|
242 void StartGeoTaggingL(); |
|
243 |
|
244 /** |
|
245 * Checks if Location atg exists for an object |
|
246 * @return ETrue if location tag is found |
|
247 */ |
|
248 TBool LocationTagExists(); |
|
249 |
|
250 /** |
|
251 * Moves to the next location for reverse geocoding |
|
252 */ |
|
253 void IterateNextLocation(); |
|
254 |
|
255 /** |
|
256 * @return ETrue if item had valid lat/lon else EFalse |
|
257 */ |
|
258 TBool GPSInfoExists(); |
|
259 private: |
|
260 /** |
|
261 * A session to Metadata Engine for creating and manipulating location objects. |
|
262 */ |
|
263 CMdESession* iMdeSession; |
|
264 |
|
265 /** |
|
266 * This query object is used to find existing locations |
|
267 */ |
|
268 CMdEObjectQuery* iLocationQuery; |
|
269 /** @var iRelationQuery. */ |
|
270 CMdERelationQuery* iRelationQuery; |
|
271 CMdERelationQuery* iTagQuery; |
|
272 |
|
273 TInt iIndex; |
|
274 |
|
275 TBool iSessionReady; |
|
276 |
|
277 MGeoTaggerObserver* iObserver; |
|
278 |
|
279 TLocationData iLocationData; |
|
280 |
|
281 TItemId iLocationId; |
|
282 |
|
283 TConnectionOption iConnectionOption; |
|
284 |
|
285 |
|
286 /** |
|
287 * An active scheduler wait loop for waiting a session to MdE to open. |
|
288 */ |
|
289 CActiveSchedulerWait* iASW; |
|
290 TBool iMdeSessionOwnFlag; |
|
291 TBool iTagPendingHandlerFlag; |
|
292 #ifdef LOC_GEOTAGGING_CELLID |
|
293 /* |
|
294 * Geo converter |
|
295 */ |
|
296 CGeoConverter* iGeoConverter; |
|
297 #endif |
|
298 #ifdef LOC_REVERSEGEOCODE |
|
299 CTagCreator* iTagCreator; |
|
300 CReverseGeoCoderPlugin* iRevGeocoderPlugin; |
|
301 TUid iDtorKey; |
|
302 #endif //LOC_REVERSEGEOCODE |
|
303 }; |
|
304 |
|
305 #endif // C_CGEOTAGGER_H |
|
306 |
|
307 // End of file. |