|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Execute Maps application. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CPMAPCMD_H |
|
19 #define CPMAPCMD_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <e32base.h> |
|
23 #include <MPbk2Command.h> |
|
24 #include <lbsfieldids.h> |
|
25 #include <mngeocoder.h> |
|
26 #include <VPbkFieldType.hrh> |
|
27 #include <Pbk2UIFieldProperty.hrh> |
|
28 #include <MVPbkContactObserver.h> |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class MPbk2CommandObserver; |
|
32 class MPbk2ContactUiControl; |
|
33 class MVPbkStoreContact; |
|
34 class CPosLandmark; |
|
35 class MPbk2ContactEditorControl; |
|
36 class MPbk2ContactEditorControlExtension; |
|
37 class MVPbkStoreContactField; |
|
38 class TLocality; |
|
39 class CMnMapView; |
|
40 |
|
41 enum TCurrentMapLaunchedByState |
|
42 { |
|
43 EMapNone = 1, |
|
44 EMapAssignFromMaps, |
|
45 EMapShowOnMaps |
|
46 }; |
|
47 // CLASS DECLARATION |
|
48 |
|
49 /** |
|
50 * Phonebook 2 show on map command object. |
|
51 */ |
|
52 class CPmapCmd : public CActive, |
|
53 public MPbk2Command, |
|
54 public MVPbkContactObserver |
|
55 { |
|
56 public: // Constructors and destructor |
|
57 |
|
58 /** |
|
59 * Creates a new instance of this class. |
|
60 * @param iEditorControl Editor control. |
|
61 * @param aContact Contact store. |
|
62 * @param aCommandId Command. |
|
63 * @return A new instance of this class. |
|
64 */ |
|
65 static CPmapCmd* NewL( |
|
66 MPbk2ContactEditorControl& iEditorControl, |
|
67 MVPbkStoreContact& aContact, |
|
68 TInt aCommandId ); |
|
69 |
|
70 /** |
|
71 * Creates a new instance of this class. |
|
72 * |
|
73 * @param aUiControl UI control. |
|
74 * @param aCommandId Command. |
|
75 * @return A new instance of this class. |
|
76 */ |
|
77 static CPmapCmd* NewL( |
|
78 MPbk2ContactUiControl& aUiControl, |
|
79 TInt aCommandId ); |
|
80 |
|
81 /** |
|
82 * Destructor. |
|
83 */ |
|
84 ~CPmapCmd(); |
|
85 |
|
86 // CActive-related methods |
|
87 /** |
|
88 * RunL method to handle the user selection |
|
89 */ |
|
90 void RunL(); |
|
91 |
|
92 /** |
|
93 * Cancel method to handle the user selection |
|
94 */ |
|
95 void DoCancel(); |
|
96 |
|
97 /** |
|
98 * Function to handle any errors in async request |
|
99 * @param aError Error Code |
|
100 */ |
|
101 TInt RunError( TInt aError ); |
|
102 |
|
103 /** |
|
104 * Disconnects from provider, when operation is completed |
|
105 */ |
|
106 void Reset(); |
|
107 public: //From MVPbkContactObserver |
|
108 void ContactOperationCompleted( TContactOpResult aResult ); |
|
109 void ContactOperationFailed( |
|
110 TContactOp aOpCode, |
|
111 TInt aErrorCode, |
|
112 TBool aErrorNotified); |
|
113 |
|
114 public: // From MPbk2Command |
|
115 void ExecuteLD(); |
|
116 void ExecuteL(); |
|
117 void AddObserver( |
|
118 MPbk2CommandObserver& aObserver ); |
|
119 void ResetUiControl( |
|
120 MPbk2ContactUiControl& aUiControl ); |
|
121 |
|
122 public: // Implementation |
|
123 /** |
|
124 * Check if exist Maps Api provider. |
|
125 * |
|
126 * @return True if provider exist. |
|
127 */ |
|
128 static TBool CheckViewProviderL(); |
|
129 |
|
130 private: // Members |
|
131 CPmapCmd( |
|
132 MPbk2ContactUiControl& aUiControl, |
|
133 TInt aCommandId ); |
|
134 CPmapCmd( |
|
135 MPbk2ContactEditorControl& iEditorControl, |
|
136 MVPbkStoreContact& aContact, |
|
137 TInt aCommandId ); |
|
138 |
|
139 void ConstructL(); |
|
140 void FinishProcess(); |
|
141 |
|
142 /** |
|
143 * Try to get address from contact editor |
|
144 * |
|
145 * @return Address group ID or EPbk2FieldGroupIdNone. |
|
146 */ |
|
147 TPbk2FieldGroupId GetAddressFromEditorView(); |
|
148 |
|
149 /** |
|
150 * Try to get address from UI control |
|
151 * |
|
152 * @return Address group ID or EPbk2FieldGroupIdNone. |
|
153 */ |
|
154 TPbk2FieldGroupId GetAddressFromUiControl(); |
|
155 |
|
156 /** |
|
157 * Try to get address if there is only one address in contact. |
|
158 * |
|
159 * @return Address group ID or EPbk2FieldGroupIdNone. |
|
160 */ |
|
161 TPbk2FieldGroupId GetAddressIfIsAlone(); |
|
162 |
|
163 /** |
|
164 * Run show on Maps API. |
|
165 * |
|
166 * @param aAddressType Address to show. |
|
167 */ |
|
168 void EditorShowOnMapsL( TVPbkFieldTypeParameter aAddressType ); |
|
169 |
|
170 /** |
|
171 * Run assign on Maps API. |
|
172 * |
|
173 * @param aAddressType Address to assign. |
|
174 */ |
|
175 void EditorAssignFromMapsL( TVPbkFieldTypeParameter aAddressType ); |
|
176 |
|
177 /** |
|
178 * Updates Contact address fields. |
|
179 * |
|
180 * @param aLandmark fields returned from Maps API. |
|
181 * @param aPositionField Type of CPosLandmark field. |
|
182 * @param aVersitSubField Type of Contact field. |
|
183 * @param aAddressType Address type. |
|
184 */ |
|
185 void UpdateFieldL( |
|
186 const CPosLandmark& aLandmark, |
|
187 _TPositionFieldId aPositionField, |
|
188 TVPbkSubFieldType aVersitSubField, |
|
189 TVPbkFieldTypeParameter aAddressType ); |
|
190 |
|
191 /** |
|
192 * Updates Contact geocoordinates. |
|
193 * |
|
194 * @param aLandmark fields returned from Maps API. |
|
195 * @param aAddressType Address type. |
|
196 */ |
|
197 void UpdateCoordsL( |
|
198 const CPosLandmark& aLandmark, |
|
199 TVPbkFieldTypeParameter aAddressType ); |
|
200 |
|
201 /** |
|
202 * Fills CPosLandmark object with Contact address fields. |
|
203 * |
|
204 * @param aLandmark object have geocoordinates. |
|
205 * @param aAddressType Address type. |
|
206 */ |
|
207 void FillLandmarkL( |
|
208 CPosLandmark& aLandmark, |
|
209 TVPbkFieldTypeParameter aAddressType ); |
|
210 |
|
211 /** |
|
212 * Sets CPosLandmark object with land mark name. |
|
213 * |
|
214 * @param aLandmark object have geocoordinates. |
|
215 */ |
|
216 void SetLandmarkNameL(CPosLandmark& aLandmark); |
|
217 |
|
218 /** |
|
219 * Fills CPosLandmark object with Contact geocoordinates. |
|
220 * |
|
221 * @param aLandmark object have geocoordinates. |
|
222 * @param aAddressType Address type. |
|
223 */ |
|
224 TBool FillGeoLandmarkL( |
|
225 CPosLandmark& aLandmark, |
|
226 TVPbkFieldTypeParameter aAddressType ); |
|
227 |
|
228 /** |
|
229 * Fills CPosLandmark object with geocoordinates. |
|
230 * |
|
231 * @param aLandmark object have geocoordinates. |
|
232 * @param aDataText text with geocoordinates. |
|
233 */ |
|
234 TBool DoFillGeoLandmarkL( |
|
235 CPosLandmark& aLandmark, |
|
236 const TDesC& aDataText ); |
|
237 |
|
238 /** |
|
239 * Get Control extension. |
|
240 * |
|
241 * @return Contact Editor Extension or NULL. |
|
242 */ |
|
243 MPbk2ContactEditorControlExtension* ControlExtension(); |
|
244 |
|
245 /** |
|
246 * Shows querry for selecting address. |
|
247 * |
|
248 * @return Address group ID or EPbk2FieldGroupIdNone. |
|
249 */ |
|
250 TPbk2FieldGroupId SelectAddressL(); |
|
251 |
|
252 /** |
|
253 * Check if exist address in Contact. |
|
254 * |
|
255 * @return True if any address exist in Contact. |
|
256 */ |
|
257 TBool IsAddressInContact(); |
|
258 |
|
259 /** |
|
260 * Gets group id from Store Field. |
|
261 * |
|
262 * @param aField Store field. |
|
263 * @return Address group ID or EPbk2FieldGroupIdNone. |
|
264 */ |
|
265 TPbk2FieldGroupId GetFieldGroupL( MVPbkStoreContactField& aField ); |
|
266 |
|
267 /** |
|
268 * Handle the selection of map which was launched from Show On Map option. |
|
269 */ |
|
270 void HandleSelectiOnShowOnMapsL(); |
|
271 |
|
272 /** |
|
273 * Handle the selection of map which was launched from Assign From Maps option. |
|
274 */ |
|
275 void HandleSelectiOnAssignFromMapsL(); |
|
276 |
|
277 private: // Data |
|
278 /// Ref: Contact editor control |
|
279 MPbk2ContactEditorControl* iEditorControl; |
|
280 /// Ref: Contact UI control |
|
281 MPbk2ContactUiControl* iUiControl; |
|
282 /// Ref: The edited contact |
|
283 MVPbkStoreContact* iContact; |
|
284 /// Ref: Command observer |
|
285 MPbk2CommandObserver* iObserver; |
|
286 /// Own: Map View Provider |
|
287 CMnProvider* iMapViewProvider; |
|
288 /// Own: Map View |
|
289 CMnMapView* iMapView; |
|
290 /// Own: Is in editor address view? |
|
291 TBool iAddressView; |
|
292 /// Own: command id |
|
293 TInt iCommandId; |
|
294 /// Own: Is in editor address view? |
|
295 TBool iAddressUpdatePrompt; |
|
296 /// Own: Current map launched is by which option |
|
297 TCurrentMapLaunchedByState iCurrentMapLaunchedByState; |
|
298 /// Own: Current AddressType |
|
299 TVPbkFieldTypeParameter iAddressType; |
|
300 /// Own: Is already address is there? |
|
301 TBool iNoAddress; |
|
302 }; |
|
303 |
|
304 #endif // CPMAPCMD_H |
|
305 |
|
306 // End of File |