|
1 /* |
|
2 * Copyright (c) 2008 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: Definition of the class CFscSaveAsContactPluginImpl. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CFSCSAVEASCONTACTPLUGINIMPL_H |
|
20 #define CFSCSAVEASCONTACTPLUGINIMPL_H |
|
21 |
|
22 //<cmail> |
|
23 #include "cfsccontactactionplugin.h" |
|
24 //</cmail> |
|
25 #include <MVPbkContactObserver.h> |
|
26 #include <MVPbkContactStoreObserver.h> |
|
27 #include "mfscreasoncallback.h" |
|
28 #include "mfsccontactsetobserver.h" |
|
29 //<cmail> |
|
30 #include "FscActionPluginUtils.h" |
|
31 //</cmail> |
|
32 |
|
33 // FORWARD DECLARATIONS |
|
34 class CFscContactAction; |
|
35 class CAknWaitDialog; |
|
36 |
|
37 /** |
|
38 * SaveAsContact plugin implementation. |
|
39 * Contains implementation of Save as contact action plugin. |
|
40 * |
|
41 * @lib fscsaveascontactplugin.lib |
|
42 * @since S60 3.1 |
|
43 */ |
|
44 class CFscSaveAsContactPluginImpl : public CFscContactActionPlugin, |
|
45 public MFscReasonCallback, |
|
46 public MFscContactSetObserver, |
|
47 public MVPbkContactObserver, |
|
48 public MVPbkContactStoreObserver |
|
49 { |
|
50 |
|
51 public: |
|
52 |
|
53 /** |
|
54 * Two-phased constructor. |
|
55 * |
|
56 * @param aParams contact action plugin parameters |
|
57 * @return New instance of CFscSaveAsContactPluginImpl |
|
58 */ |
|
59 static CFscSaveAsContactPluginImpl* NewL( |
|
60 TAny* aParams); |
|
61 |
|
62 /** |
|
63 * Destructor. |
|
64 */ |
|
65 virtual ~CFscSaveAsContactPluginImpl(); |
|
66 |
|
67 public: |
|
68 // From CFscContactActionPlugin |
|
69 |
|
70 /** |
|
71 * @see CFscContactActionPlugin::Uid |
|
72 */ |
|
73 virtual TUid Uid() const; |
|
74 |
|
75 /** |
|
76 * @see CFscContactActionPlugin::ActionList |
|
77 */ |
|
78 virtual const CArrayFix<TUid>* ActionList() const; |
|
79 |
|
80 /** |
|
81 * @see CFscContactActionPlugin::GetActionL |
|
82 */ |
|
83 virtual const MFscContactAction& GetActionL( |
|
84 TUid aActionUid) const; |
|
85 |
|
86 /** |
|
87 * @see CFscContactActionPlugin::PriorityForContactSetL |
|
88 */ |
|
89 virtual void PriorityForContactSetL( |
|
90 TUid aActionUid, |
|
91 MFscContactSet& aContactSet, |
|
92 TFscContactActionVisibility& aActionMenuVisibility, |
|
93 TFscContactActionVisibility& aOptionsMenuVisibility, |
|
94 MFscContactActionPluginObserver* aObserver); |
|
95 |
|
96 /** |
|
97 * @see CFscContactActionPlugin::CancelPriorityForContactSet |
|
98 */ |
|
99 virtual void CancelPriorityForContactSet(); |
|
100 |
|
101 /** |
|
102 * @see CFscContactActionPlugin::ExecuteL |
|
103 */ |
|
104 virtual void ExecuteL( |
|
105 TUid aActionUid, |
|
106 MFscContactSet& aContactSet, |
|
107 MFscContactActionPluginObserver* aObserver); |
|
108 |
|
109 /** |
|
110 * @see CFscContactActionPlugin::CancelExecute |
|
111 */ |
|
112 virtual void CancelExecute(); |
|
113 public: |
|
114 // From MFscReasonCallback |
|
115 |
|
116 /** |
|
117 * @see MFscReasonCallback::GetReasonL |
|
118 */ |
|
119 virtual void GetReasonL( |
|
120 TUid aActionUid, |
|
121 TInt aReasonId, |
|
122 HBufC*& aReason) const; |
|
123 |
|
124 public: |
|
125 // From MFscContactSetObserver |
|
126 /** |
|
127 * @see MFscContactSetObserver::NextContactComplete |
|
128 */ |
|
129 virtual void NextContactComplete( |
|
130 MVPbkStoreContact* aContact); |
|
131 |
|
132 /** |
|
133 * @see MFscContactSetObserver::NextContactFailed |
|
134 */ |
|
135 virtual void NextContactFailed( |
|
136 TInt aError); |
|
137 |
|
138 /** |
|
139 * @see MFscContactSetObserver::NextGroupComplete |
|
140 */ |
|
141 virtual void NextGroupComplete( |
|
142 MVPbkStoreContact* aContact); |
|
143 |
|
144 /** |
|
145 * @see MFscContactSetObserver::NextGroupFailed |
|
146 * |
|
147 */ |
|
148 virtual void NextGroupFailed( |
|
149 TInt aError); |
|
150 |
|
151 /** |
|
152 * @see MFscContactSetObserver::GetGroupContactComplete |
|
153 */ |
|
154 virtual void GetGroupContactComplete( |
|
155 MVPbkStoreContact* aContact); |
|
156 |
|
157 /** |
|
158 * @see MFscContactSetObserver::GetGroupContactFailed |
|
159 */ |
|
160 virtual void GetGroupContactFailed( |
|
161 TInt aError); |
|
162 public: |
|
163 |
|
164 //From MVPbkContactStoreObserver |
|
165 |
|
166 /** |
|
167 * @see MVPbkContactStoreObserver::StoreReady |
|
168 */ |
|
169 void StoreReady(MVPbkContactStore& aContactStore); |
|
170 |
|
171 /** |
|
172 * @see MVPbkContactStoreObserver::StoreUnavailable |
|
173 */ |
|
174 void StoreUnavailable(MVPbkContactStore& aContactStore, |
|
175 TInt aReason); |
|
176 |
|
177 /** |
|
178 * @see MVPbkContactStoreObserver::StoreUnavailable |
|
179 */ |
|
180 void HandleStoreEventL( |
|
181 MVPbkContactStore& aContactStore, |
|
182 TVPbkContactStoreEvent aStoreEvent); |
|
183 |
|
184 private: |
|
185 // methods |
|
186 |
|
187 /** |
|
188 * Saves contact to default Pbk2 store |
|
189 * |
|
190 * @param aContactStore to be saved into contact database |
|
191 */ |
|
192 void SaveToContactDatabaseL( |
|
193 MVPbkStoreContact* aStoreContact); |
|
194 |
|
195 /** |
|
196 * Prepares store for update |
|
197 */ |
|
198 void PrepareStoreL(); |
|
199 |
|
200 /** |
|
201 * Checks if store is valid for saving contacts from RCL |
|
202 */ |
|
203 // <cmail> |
|
204 TBool IsValidStoreL(); |
|
205 // </cmail> |
|
206 |
|
207 /** |
|
208 * Helper method to check if action can be executed with |
|
209 * given contacts in current context |
|
210 * |
|
211 * @param aActionId Action Id |
|
212 * @param aContactSet contains contact list and group lists |
|
213 */ |
|
214 void CanExecuteL( |
|
215 TUid aActionUid, |
|
216 MFscContactSet& aContactSet); |
|
217 |
|
218 /** |
|
219 * Updates action icon |
|
220 * |
|
221 * @param aActionId Action Id |
|
222 */ |
|
223 void UpdateActionIconL( |
|
224 TUid aActionUid); |
|
225 |
|
226 /** |
|
227 * @see MVPbkContactObserver::ContactOperationCompleted |
|
228 * |
|
229 */ |
|
230 |
|
231 virtual void ContactOperationCompleted( |
|
232 TContactOpResult aResult); |
|
233 |
|
234 /** |
|
235 * @see MVPbkContactObserver::ContactOperationFailed |
|
236 * |
|
237 */ |
|
238 |
|
239 virtual void ContactOperationFailed( |
|
240 TContactOp aOpCode, |
|
241 TInt aErrorCode, |
|
242 TBool aErrorNotified); |
|
243 private: |
|
244 |
|
245 /** |
|
246 * Constructor. |
|
247 * |
|
248 * @param aParams contact action plugin parameters |
|
249 */ |
|
250 CFscSaveAsContactPluginImpl( |
|
251 const TFscContactActionPluginParams& aParams); |
|
252 |
|
253 /** |
|
254 * Second phase constructor. |
|
255 */ |
|
256 void ConstructL(); |
|
257 |
|
258 /** |
|
259 * Restores members related to state machine |
|
260 */ |
|
261 void ResetData(); |
|
262 |
|
263 /** |
|
264 * Resumes plugin processing |
|
265 * Resumes ExecuteL or PriorityForContactSetL execution |
|
266 * |
|
267 * @param aActionUid action UID |
|
268 * @param aContactSet set of contacts |
|
269 * @param aIsExecute is ExecuteL or PriorityForContactSetL launched |
|
270 */ |
|
271 void ResumeAsync( |
|
272 TUid aActionUid, |
|
273 MFscContactSet& aContactSet, |
|
274 TBool aIsExecute ); |
|
275 |
|
276 /** |
|
277 * Dismisses wait note |
|
278 */ |
|
279 void DismissWaitNote(); |
|
280 |
|
281 private: |
|
282 // data |
|
283 |
|
284 /** |
|
285 * Action plugin parameters |
|
286 */ |
|
287 TFscContactActionPluginParams iParams; |
|
288 |
|
289 /** |
|
290 * Resource handle |
|
291 */ |
|
292 TInt iResourceHandle; |
|
293 |
|
294 /** |
|
295 * Own: save as contact action |
|
296 */ |
|
297 CFscContactAction* iContactSaveAsContactAction; |
|
298 |
|
299 /** |
|
300 * Own: Contact action array |
|
301 */ |
|
302 CArrayFixFlat<TUid>* iActionList; |
|
303 |
|
304 // For async implementation |
|
305 |
|
306 /** |
|
307 * Action Uid |
|
308 */ |
|
309 TUid iActionUid; |
|
310 |
|
311 /** |
|
312 * Contact set |
|
313 */ |
|
314 MFscContactSet* iContactSet; |
|
315 |
|
316 /** |
|
317 * Action menu visbility |
|
318 */ |
|
319 TFscContactActionVisibility* iActionMenuVisibility; |
|
320 |
|
321 /** |
|
322 * Options menu visbility |
|
323 */ |
|
324 TFscContactActionVisibility* iOptionsMenuVisibility; |
|
325 |
|
326 /** |
|
327 * Plug-in observer |
|
328 */ |
|
329 MFscContactActionPluginObserver* iPluginObserver; |
|
330 |
|
331 /** |
|
332 * Current state of state machine |
|
333 */ |
|
334 TActionPluginLastEvent iLastEvent; |
|
335 |
|
336 /** |
|
337 * Action priority |
|
338 */ |
|
339 TInt iActionPriority; |
|
340 |
|
341 /** |
|
342 * Can display action |
|
343 */ |
|
344 TInt iCanDisplay; |
|
345 |
|
346 /** |
|
347 * Retrieved store contact |
|
348 */ |
|
349 MVPbkStoreContact* iRetrievedStoreContact; |
|
350 |
|
351 /** |
|
352 * New contact which will be saved to the phone memory |
|
353 */ |
|
354 MVPbkStoreContact* iNewStoreContact; |
|
355 |
|
356 /** |
|
357 * Is ExecuteL or PriorityForContactSetL launched |
|
358 */ |
|
359 TBool iIsExecute; |
|
360 |
|
361 /** |
|
362 * Waiting dialog launched when contact is being saved to the database |
|
363 */ |
|
364 CAknWaitDialog* iWaitDialog; |
|
365 |
|
366 /** |
|
367 * Ref: Target store |
|
368 */ |
|
369 MVPbkContactStore* iTargetStore; |
|
370 }; |
|
371 |
|
372 #endif // CFSCSAVEASCONTACTPLUGINIMPL_H |