|
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 |
|
28 class CVPbkContactManager; |
|
29 class MVPbkContactLink; |
|
30 class MVPbkStoreContact; |
|
31 class CPbk2FieldPropertyArray; |
|
32 class CPbk2StoreSpecificFieldPropertyArray; |
|
33 class CPbk2PresentationContact; |
|
34 class MPbk2ContactNameFormatter; |
|
35 class CPbk2SortOrderManager; |
|
36 class RFs; |
|
37 class CCreateMyCard; |
|
38 class CPbk2ApplicationServices; |
|
39 class CCCAppMyCardPlugin; |
|
40 |
|
41 /** |
|
42 * MyCard Observer class |
|
43 */ |
|
44 class MMyCardObserver |
|
45 { |
|
46 public: |
|
47 /** |
|
48 * MyCard observer event types |
|
49 */ |
|
50 enum TEvent |
|
51 { |
|
52 EEventNull = 0, |
|
53 EEventContactLoaded |
|
54 }; |
|
55 |
|
56 /** |
|
57 * Notification method to report MyCard events to observers |
|
58 * @param aEvent event type |
|
59 */ |
|
60 virtual void MyCardEventL( TEvent aEvent ) = 0; |
|
61 |
|
62 protected: |
|
63 virtual ~MMyCardObserver() {} |
|
64 }; |
|
65 |
|
66 /** |
|
67 * |
|
68 * |
|
69 * @lib ccappmycardplugin.dll |
|
70 * @since S60 9.2 |
|
71 */ |
|
72 NONSHARABLE_CLASS( CCCAppMyCard ) : |
|
73 public CBase, |
|
74 public MVPbkContactStoreObserver, |
|
75 public MVPbkSingleContactLinkOperationObserver, |
|
76 public MVPbkSingleContactOperationObserver, |
|
77 public MVPbkContactObserver, |
|
78 public MPbk2EditedContactObserver |
|
79 { |
|
80 |
|
81 public: |
|
82 |
|
83 /** |
|
84 * Two-phased constructor. |
|
85 */ |
|
86 static CCCAppMyCard* NewL( CCCAppMyCardPlugin& aPlugin, RFs* aFs = NULL ); |
|
87 |
|
88 /** |
|
89 * Destructor. |
|
90 */ |
|
91 ~CCCAppMyCard(); |
|
92 |
|
93 public: // New methods |
|
94 |
|
95 /* |
|
96 * Locks contact and launches the contact editor |
|
97 * @param aFocusedFieldIndex, focused contact field index |
|
98 */ |
|
99 void EditContactL( TInt aFocusedFieldIndex ); |
|
100 |
|
101 /** |
|
102 * Getter for presentation contact of own contact. |
|
103 * |
|
104 * @return presentation contact |
|
105 */ |
|
106 CPbk2PresentationContact& PresentationContactL(); |
|
107 |
|
108 /** |
|
109 * Getter for store contact of own contact. |
|
110 * |
|
111 * @return phonebook store contact |
|
112 */ |
|
113 MVPbkStoreContact& StoreContact(); |
|
114 |
|
115 /** |
|
116 * Getter for Contact Manager |
|
117 * |
|
118 * @return phonebook contact manager |
|
119 */ |
|
120 CVPbkContactManager& ContactManager(); |
|
121 |
|
122 /** |
|
123 * Check if contact link already available. This should be called before |
|
124 * calling ContactLink |
|
125 * |
|
126 * @return ETrue if contact link is available |
|
127 */ |
|
128 TBool IsContactLinkReady() const; |
|
129 |
|
130 /** |
|
131 * Getter for contact link of own contact. Will panic if contact link is |
|
132 * not available. |
|
133 * |
|
134 * @return phonebook contact link |
|
135 */ |
|
136 MVPbkContactLink& ContactLink(); |
|
137 |
|
138 /** |
|
139 * Add observer to MyCard |
|
140 * |
|
141 * @param aObserver New observer for MyCard |
|
142 */ |
|
143 void AddObserverL( MMyCardObserver* aObserver ); |
|
144 |
|
145 /** |
|
146 * Remove observer from MyCard |
|
147 * |
|
148 * @param aObserver Observer to be removed from MyCard |
|
149 */ |
|
150 void RemoveObserver( MMyCardObserver* aObserver ); |
|
151 |
|
152 private: // from MVPbkContactStoreObserver |
|
153 void StoreReady(MVPbkContactStore& aContactStore); |
|
154 void StoreUnavailable(MVPbkContactStore& aContactStore, |
|
155 TInt aReason); |
|
156 void HandleStoreEventL( |
|
157 MVPbkContactStore& aContactStore, |
|
158 TVPbkContactStoreEvent aStoreEvent); |
|
159 |
|
160 private: // From MVPbkSingleContactLinkOperationObserver |
|
161 void VPbkSingleContactLinkOperationComplete( |
|
162 MVPbkContactOperationBase& aOperation, |
|
163 MVPbkContactLink* aLink ); |
|
164 void VPbkSingleContactLinkOperationFailed( |
|
165 MVPbkContactOperationBase& aOperation, |
|
166 TInt aError ); |
|
167 |
|
168 private: // From MVPbkSingleContactOperationObserver |
|
169 virtual void VPbkSingleContactOperationComplete( |
|
170 MVPbkContactOperationBase& aOperation, |
|
171 MVPbkStoreContact* aContact ); |
|
172 virtual void VPbkSingleContactOperationFailed( |
|
173 MVPbkContactOperationBase& aOperation, |
|
174 TInt aError ); |
|
175 |
|
176 private: // From MVPbkContactObserver |
|
177 void ContactOperationCompleted(TContactOpResult aResult); |
|
178 void ContactOperationFailed |
|
179 (TContactOp aOpCode, TInt aErrorCode, TBool aErrorNotified); |
|
180 |
|
181 private: // form MPbk2EditedContactObserver |
|
182 void ContactEditingComplete( |
|
183 MVPbkStoreContact* aEditedContact ); |
|
184 void ContactEditingDeletedContact( |
|
185 MVPbkStoreContact* aEditedContact ); |
|
186 void ContactEditingAborted(); |
|
187 |
|
188 private: // constructors |
|
189 inline CCCAppMyCard( CCCAppMyCardPlugin& aPlugin ); |
|
190 inline void ConstructL(RFs* aFs); |
|
191 |
|
192 private: // new functions |
|
193 /* |
|
194 * Function for launching contact editor. |
|
195 * |
|
196 * @param aFlags - flags for opening the editor (@see TPbk2ContactEditorParams) |
|
197 */ |
|
198 void LaunchContactEditorL( TUint32 aFlags ); |
|
199 |
|
200 /** |
|
201 * Notify all observers that aEvent has occured. |
|
202 * |
|
203 * @param aEvent Occured event. |
|
204 */ |
|
205 void NotifyObservers( MMyCardObserver::TEvent aEvent ) const; |
|
206 |
|
207 /** |
|
208 * Load own contact information |
|
209 */ |
|
210 void LoadContact(); |
|
211 |
|
212 /* |
|
213 * Async callback function. Calls LaunchContactEditorL - function |
|
214 */ |
|
215 static TInt CreateMyCardContact( TAny* aPtr ); |
|
216 |
|
217 /* |
|
218 * Async callback function for closing CCa. Calls DoCloseCCa |
|
219 */ |
|
220 static TInt CloseCcaL( TAny* aPtr ); |
|
221 |
|
222 /* |
|
223 * Closes the CCA |
|
224 */ |
|
225 void DoCloseCCaL(); |
|
226 |
|
227 |
|
228 private: // data |
|
229 |
|
230 /// REF |
|
231 CVPbkContactManager* iVPbkContactManager; |
|
232 /// Own |
|
233 MVPbkContactOperationBase* iOperation; |
|
234 /// Own |
|
235 MVPbkContactOperationBase* iFetchOperation; |
|
236 /// Own |
|
237 MVPbkContactLink* iMyCard; |
|
238 /// Own |
|
239 MVPbkStoreContact* iMyCardContact; |
|
240 /// Own. |
|
241 CPbk2PresentationContact* iPresentationContact; |
|
242 /// Own |
|
243 CPbk2StoreSpecificFieldPropertyArray* iSpecificFieldProperties; |
|
244 /// Own |
|
245 CPbk2FieldPropertyArray* iFieldProperties; |
|
246 /// Elements are not owned. |
|
247 RPointerArray<MMyCardObserver> iObservers; |
|
248 /// Own: Pointer to Application services |
|
249 CPbk2ApplicationServices* iAppServices; |
|
250 /// Own: Asynchronous callback for close |
|
251 CAsyncCallBack* iCloseCallBack; |
|
252 /// Own: Asynchronous callback for create |
|
253 CAsyncCallBack* iCreateCallBack; |
|
254 /// Ref: plugin |
|
255 CCCAppMyCardPlugin& iPlugin; |
|
256 /// Focused contact field index for the editor |
|
257 TInt iFocusedFieldIndex; |
|
258 }; |
|
259 |
|
260 #endif // CCAPPMYCARD_H |
|
261 |
|
262 // End of File |