|
1 /* |
|
2 * Copyright (c) 2009-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: Implementation of MyCard |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CCAPPMYCARD_H |
|
19 #define CCAPPMYCARD_H |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <MVPbkContactStoreObserver.h> |
|
23 #include <MVPbkSingleContactLinkOperationObserver.h> |
|
24 #include <MVPbkContactObserver.h> |
|
25 #include <MVPbkSingleContactOperationObserver.h> |
|
26 #include <MPbk2EditedContactObserver.h> |
|
27 #include <MPbk2ExitCallback.h> |
|
28 |
|
29 class CVPbkContactManager; |
|
30 class MVPbkContactLink; |
|
31 class MVPbkStoreContact; |
|
32 class CPbk2FieldPropertyArray; |
|
33 class CPbk2StoreSpecificFieldPropertyArray; |
|
34 class CPbk2PresentationContact; |
|
35 class MPbk2ContactNameFormatter; |
|
36 class CPbk2SortOrderManager; |
|
37 class RFs; |
|
38 class CCreateMyCard; |
|
39 class CPbk2ApplicationServices; |
|
40 class CCCAppMyCardPlugin; |
|
41 class MPbk2DialogEliminator; |
|
42 class CTimerCallBack; |
|
43 |
|
44 /** |
|
45 * MyCard Observer class |
|
46 */ |
|
47 class MMyCardObserver |
|
48 { |
|
49 public: |
|
50 /** |
|
51 * MyCard observer event types |
|
52 */ |
|
53 enum TEvent |
|
54 { |
|
55 /// Undefined event |
|
56 EEventNull = 0, |
|
57 /// Contact loaded for the first time |
|
58 EEventContactLoaded, |
|
59 /// Contact has been changed |
|
60 EEventContactChanged |
|
61 }; |
|
62 |
|
63 /** |
|
64 * Notification method to report MyCard events to observers |
|
65 * @param aEvent event type |
|
66 */ |
|
67 virtual void MyCardEventL( TEvent aEvent ) = 0; |
|
68 |
|
69 protected: |
|
70 virtual ~MMyCardObserver() {} |
|
71 }; |
|
72 |
|
73 /** |
|
74 * |
|
75 * |
|
76 * @lib ccappmycardplugin.dll |
|
77 * @since S60 9.2 |
|
78 */ |
|
79 NONSHARABLE_CLASS( CCCAppMyCard ) : |
|
80 public CBase, |
|
81 public MVPbkContactStoreObserver, |
|
82 public MVPbkSingleContactLinkOperationObserver, |
|
83 public MVPbkSingleContactOperationObserver, |
|
84 public MVPbkContactObserver, |
|
85 public MPbk2EditedContactObserver, |
|
86 public MPbk2ExitCallback |
|
87 { |
|
88 |
|
89 public: |
|
90 |
|
91 /** |
|
92 * Two-phased constructor. |
|
93 */ |
|
94 static CCCAppMyCard* NewL( CCCAppMyCardPlugin& aPlugin, RFs* aFs = NULL ); |
|
95 |
|
96 /** |
|
97 * Destructor. |
|
98 */ |
|
99 ~CCCAppMyCard(); |
|
100 |
|
101 public: // New methods |
|
102 |
|
103 /* |
|
104 * Locks contact and launches the contact editor |
|
105 * @param aFocusedFieldIndex, focused contact field index |
|
106 */ |
|
107 void EditContactL( TInt aFocusedFieldIndex ); |
|
108 |
|
109 /** |
|
110 * Getter for presentation contact of own contact. |
|
111 * |
|
112 * @return presentation contact |
|
113 */ |
|
114 CPbk2PresentationContact& PresentationContactL(); |
|
115 |
|
116 /** |
|
117 * Getter for store contact of own contact. |
|
118 * |
|
119 * @return phonebook store contact |
|
120 */ |
|
121 MVPbkStoreContact& StoreContact(); |
|
122 |
|
123 /** |
|
124 * Getter for Contact Manager |
|
125 * |
|
126 * @return phonebook contact manager |
|
127 */ |
|
128 CVPbkContactManager& ContactManager(); |
|
129 |
|
130 /** |
|
131 * Check if contact link already available. This should be called before |
|
132 * calling ContactLink |
|
133 * |
|
134 * @return ETrue if contact link is available |
|
135 */ |
|
136 TBool IsContactLinkReady() const; |
|
137 |
|
138 /** |
|
139 * Getter for contact link of own contact. Will panic if contact link is |
|
140 * not available. |
|
141 * |
|
142 * @return phonebook contact link |
|
143 */ |
|
144 MVPbkContactLink& ContactLink(); |
|
145 |
|
146 /** |
|
147 * Add observer to MyCard |
|
148 * |
|
149 * @param aObserver New observer for MyCard |
|
150 */ |
|
151 void AddObserverL( MMyCardObserver* aObserver ); |
|
152 |
|
153 /** |
|
154 * Remove observer from MyCard |
|
155 * |
|
156 * @param aObserver Observer to be removed from MyCard |
|
157 */ |
|
158 void RemoveObserver( MMyCardObserver* aObserver ); |
|
159 |
|
160 /** |
|
161 * Set contact link. If link is provided it will be used instead of resolving |
|
162 * the own contact link from contact store. This should be called before call to |
|
163 * FetchMyCardL(). |
|
164 * |
|
165 * @param aLink contact link |
|
166 */ |
|
167 void SetLinkL( const MVPbkContactLink& aLink ); |
|
168 |
|
169 /** |
|
170 * Start fetching the data of own contact and observe it's changing. |
|
171 */ |
|
172 void FetchMyCardL(); |
|
173 |
|
174 /** |
|
175 * Force MyCard to open editor and create new own contact once the |
|
176 * contact store is opened. This should be called before calling FetchMyCardL. |
|
177 */ |
|
178 void ForceCreateMyCard(); |
|
179 |
|
180 /* |
|
181 * Returns information about header control blocking |
|
182 * |
|
183 * @return ETrue if the header control events are blocked, EFalse otherwise |
|
184 */ |
|
185 TBool HeaderControlBlocked(); |
|
186 |
|
187 private: // from MVPbkContactStoreObserver |
|
188 void StoreReady(MVPbkContactStore& aContactStore); |
|
189 void StoreUnavailable(MVPbkContactStore& aContactStore, |
|
190 TInt aReason); |
|
191 void HandleStoreEventL( |
|
192 MVPbkContactStore& aContactStore, |
|
193 TVPbkContactStoreEvent aStoreEvent); |
|
194 |
|
195 private: // From MVPbkSingleContactLinkOperationObserver |
|
196 void VPbkSingleContactLinkOperationComplete( |
|
197 MVPbkContactOperationBase& aOperation, |
|
198 MVPbkContactLink* aLink ); |
|
199 void VPbkSingleContactLinkOperationFailed( |
|
200 MVPbkContactOperationBase& aOperation, |
|
201 TInt aError ); |
|
202 |
|
203 private: // From MVPbkSingleContactOperationObserver |
|
204 virtual void VPbkSingleContactOperationComplete( |
|
205 MVPbkContactOperationBase& aOperation, |
|
206 MVPbkStoreContact* aContact ); |
|
207 virtual void VPbkSingleContactOperationFailed( |
|
208 MVPbkContactOperationBase& aOperation, |
|
209 TInt aError ); |
|
210 |
|
211 private: // From MVPbkContactObserver |
|
212 void ContactOperationCompleted(TContactOpResult aResult); |
|
213 void ContactOperationFailed |
|
214 (TContactOp aOpCode, TInt aErrorCode, TBool aErrorNotified); |
|
215 |
|
216 private: // form MPbk2EditedContactObserver |
|
217 void ContactEditingComplete( |
|
218 MVPbkStoreContact* aEditedContact ); |
|
219 void ContactEditingDeletedContact( |
|
220 MVPbkStoreContact* aEditedContact ); |
|
221 void ContactEditingAborted(); |
|
222 |
|
223 private: // From MPbk2ExitCallback |
|
224 TBool OkToExitL( TInt aCommandId ); |
|
225 |
|
226 private: // constructors |
|
227 inline CCCAppMyCard( CCCAppMyCardPlugin& aPlugin ); |
|
228 inline void ConstructL(RFs* aFs); |
|
229 |
|
230 private: // new functions |
|
231 /* |
|
232 * Function for launching contact editor. |
|
233 * |
|
234 * @param aFlags - flags for opening the editor (@see TPbk2ContactEditorParams) |
|
235 */ |
|
236 void LaunchContactEditorL( TUint32 aFlags ); |
|
237 |
|
238 /** |
|
239 * Notify all observers that aEvent has occured. |
|
240 * |
|
241 * @param aEvent Occured event. |
|
242 */ |
|
243 void NotifyObservers( MMyCardObserver::TEvent aEvent ) const; |
|
244 |
|
245 /** |
|
246 * Load own contact information |
|
247 */ |
|
248 void LoadContact(); |
|
249 |
|
250 /* |
|
251 * Async callback function. Calls LaunchContactEditorL - function |
|
252 */ |
|
253 static TInt CreateMyCardContact( TAny* aPtr ); |
|
254 |
|
255 /* |
|
256 * Async callback function for closing CCa. Calls DoCloseCCa |
|
257 */ |
|
258 static TInt CloseCcaL( TAny* aPtr ); |
|
259 |
|
260 /** |
|
261 * Async callback function for closing editor dialog. |
|
262 */ |
|
263 static TInt ExitDlgL( TAny* aPtr ); |
|
264 |
|
265 /** |
|
266 * Async callback function for opening stores. |
|
267 */ |
|
268 static TInt OpenStoresL( TAny* aPtr ); |
|
269 |
|
270 /* |
|
271 * Closes the CCA |
|
272 */ |
|
273 void DoCloseCCaL(); |
|
274 |
|
275 |
|
276 private: // data |
|
277 |
|
278 /// REF |
|
279 CVPbkContactManager* iVPbkContactManager; |
|
280 /// Own |
|
281 MVPbkContactOperationBase* iOperation; |
|
282 /// Own |
|
283 MVPbkContactOperationBase* iFetchOperation; |
|
284 /// Own |
|
285 MVPbkContactLink* iMyCard; |
|
286 /// Own |
|
287 MVPbkStoreContact* iMyCardContact; |
|
288 /// Own. |
|
289 CPbk2PresentationContact* iPresentationContact; |
|
290 /// Own |
|
291 CPbk2StoreSpecificFieldPropertyArray* iSpecificFieldProperties; |
|
292 /// Own |
|
293 CPbk2FieldPropertyArray* iFieldProperties; |
|
294 /// Elements are not owned. |
|
295 RPointerArray<MMyCardObserver> iObservers; |
|
296 /// Own: Pointer to Application services |
|
297 CPbk2ApplicationServices* iAppServices; |
|
298 /// Own: Asynchronous callback for close |
|
299 CAsyncCallBack* iCloseCallBack; |
|
300 /// Own: Asynchronous callback for create |
|
301 CAsyncCallBack* iCreateCallBack; |
|
302 /// Own: Asynchronous callback for close dialog |
|
303 CAsyncCallBack* iDlgCloseCallBack; |
|
304 /// Ref: plugin |
|
305 CCCAppMyCardPlugin& iPlugin; |
|
306 /// Focused contact field index for the editor |
|
307 TInt iFocusedFieldIndex; |
|
308 /// Now own. Editor dialog eliminator |
|
309 MPbk2DialogEliminator* iEditorEliminator; |
|
310 /// Current event |
|
311 MMyCardObserver::TEvent iEvent; |
|
312 /// Own. Store opener callback |
|
313 CTimerCallBack* iStoreCallBack; |
|
314 /// Force editor flag |
|
315 TBool iForceCreateMyCard; |
|
316 // Flag for editor state |
|
317 TBool iDialogIsRunning; |
|
318 }; |
|
319 |
|
320 #endif // CCAPPMYCARD_H |
|
321 |
|
322 // End of File |