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