|
1 /* |
|
2 * Copyright (c) 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: Fetches the presence id of a certain contact link |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CLOGSEXTPRESENTITYIDFETCHER_H |
|
20 #define C_CLOGSEXTPRESENTITYIDFETCHER_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <MVPbkSingleContactOperationObserver.h> |
|
24 #include <MVPbkContactStoreObserver.h> |
|
25 |
|
26 #include "logwrap.h" |
|
27 |
|
28 class MLogsExtPresentityIdFetcherObserver; |
|
29 class MVPbkContactOperationBase; |
|
30 class MVPbkContactLinkArray; |
|
31 class CVPbkContactManager; |
|
32 class MVPbkContactStore; |
|
33 class CSPSettings; |
|
34 |
|
35 /** |
|
36 * Presentity Id fetcher class. |
|
37 * |
|
38 * @since S60 v3.2 |
|
39 */ |
|
40 NONSHARABLE_CLASS(CLogsExtPresentityIdFetcher) : |
|
41 public CBase, |
|
42 public MVPbkSingleContactOperationObserver, |
|
43 public MVPbkContactStoreObserver |
|
44 { |
|
45 |
|
46 friend class ut_clogsextfetchdonelistener; |
|
47 |
|
48 public: |
|
49 |
|
50 /** |
|
51 * Creates a new CLogsExtPresentityIdFetcher. |
|
52 * |
|
53 * @since S60 v3.2 |
|
54 * @param aServiceId a service id |
|
55 * @param aCntLink a contact link |
|
56 * @param aLogId the log id of the log event that this presentity id is |
|
57 * fetched for |
|
58 * @param aObserver the observer of this fetching process |
|
59 * @return a new CLogsExtPresentityIdFetcher instance |
|
60 */ |
|
61 static CLogsExtPresentityIdFetcher* NewL( |
|
62 const TUint32 aServiceId, |
|
63 const TDesC8& aCntLink, |
|
64 const TLogId aLogId, |
|
65 MLogsExtPresentityIdFetcherObserver& aObserver ); |
|
66 |
|
67 /** |
|
68 * Creates a new CLogsExtPresentityIdFetcher. |
|
69 * |
|
70 * @since S60 v3.2 |
|
71 * @param aServiceId a service id |
|
72 * @param aCntLink a contact link |
|
73 * @param aLogId the log id of the log event that this presentity id is |
|
74 * fetched for |
|
75 * @param aObserver the observer of this fetching process |
|
76 * @return a new CLogsExtPresentityIdFetcher instance |
|
77 */ |
|
78 static CLogsExtPresentityIdFetcher* NewLC( |
|
79 const TUint32 aServiceId, |
|
80 const TDesC8& aCntLink, |
|
81 const TLogId aLogId, |
|
82 MLogsExtPresentityIdFetcherObserver& aObserver ); |
|
83 |
|
84 /** |
|
85 * Destructor. |
|
86 */ |
|
87 ~CLogsExtPresentityIdFetcher(); |
|
88 |
|
89 public: |
|
90 |
|
91 /** |
|
92 * Starts the fetching of the presentity id. |
|
93 * |
|
94 * @since S60 v3.2 |
|
95 * @return system-wide error code |
|
96 */ |
|
97 TInt Fetch(); |
|
98 |
|
99 /** |
|
100 * Returns the service id. |
|
101 * |
|
102 * @since S60 v3.2 |
|
103 * @return the service id |
|
104 */ |
|
105 TUint32 ServiceId(); |
|
106 |
|
107 /** |
|
108 * Returns the unique log event id the presentity id is fetched for. |
|
109 * |
|
110 * @since S60 v3.2 |
|
111 * @return the unique log event id |
|
112 */ |
|
113 TLogId LogId(); |
|
114 |
|
115 /** |
|
116 * Returns the presentity id. |
|
117 * |
|
118 * @since S60 v3.2 |
|
119 * @return the presentity id |
|
120 */ |
|
121 const TDesC& PresentityId(); |
|
122 |
|
123 private: |
|
124 |
|
125 // from base class MVPbkSingleContactOperationObserver |
|
126 |
|
127 /** |
|
128 * From MVPbkSingleContactOperationObserver |
|
129 * Called when the operation is completed. |
|
130 * |
|
131 * @since S60 v3.2 |
|
132 * @param aOperation The completed operation. |
|
133 * @param aContact The contact returned by the operation. |
|
134 * A client must take the ownership immediately. |
|
135 * |
|
136 */ |
|
137 void VPbkSingleContactOperationComplete( |
|
138 MVPbkContactOperationBase& aOperation, |
|
139 MVPbkStoreContact* aContact ); |
|
140 |
|
141 /** |
|
142 * From MVPbkSingleContactOperationObserver |
|
143 * Called if the operation fails. |
|
144 * |
|
145 * @since S60 v3.2 |
|
146 * @param aOperation The failed operation. |
|
147 * @param aError An error code of the failure. |
|
148 */ |
|
149 void VPbkSingleContactOperationFailed( |
|
150 MVPbkContactOperationBase& aOperation, |
|
151 TInt aError ); |
|
152 |
|
153 private: |
|
154 |
|
155 // from base class MVPbkContactStoreObserver |
|
156 |
|
157 /** |
|
158 * From MVPbkContactStoreObserver |
|
159 * Called when a contact store is ready to use. |
|
160 * |
|
161 * @since S60 v3.2 |
|
162 * @param aContactStore The store that is ready. |
|
163 */ |
|
164 void StoreReady( MVPbkContactStore& aContactStore ); |
|
165 |
|
166 /** |
|
167 * From MVPbkContactStoreObserver |
|
168 * Called when a contact store becomes unavailable. |
|
169 * |
|
170 * Client may inspect the reason of the unavailability and decide |
|
171 * whether or not it will keep the store opened (ie. listen to |
|
172 * the store events). |
|
173 * |
|
174 * @since S60 v3.2 |
|
175 * @param aContactStore The store that became unavailable. |
|
176 * @param aReason The reason why the store is unavailable. |
|
177 * This is one of the system wide error codes. |
|
178 */ |
|
179 void StoreUnavailable( MVPbkContactStore& aContactStore, TInt aReason ); |
|
180 |
|
181 /** |
|
182 * From MVPbkContactStoreObserver |
|
183 * Called when changes occur in the contact store. |
|
184 * |
|
185 * @since S60 v3.2 |
|
186 * @see TVPbkContactStoreEvent |
|
187 * @param aContactStore A store whose event it is. |
|
188 * @param aStoreEvent The event that has occurred. |
|
189 */ |
|
190 void HandleStoreEventL( |
|
191 MVPbkContactStore& aContactStore, |
|
192 TVPbkContactStoreEvent aStoreEvent ); |
|
193 |
|
194 private: |
|
195 |
|
196 /** |
|
197 * Symbian second-phase constructor |
|
198 * |
|
199 * @since S60 v3.2 |
|
200 * @param aCntLink a contact link |
|
201 */ |
|
202 void ConstructL( const TDesC8& aCntLink ); |
|
203 |
|
204 /** |
|
205 * Constructor. |
|
206 * |
|
207 * @since S60 v3.2 |
|
208 * @param aServiceId a service id |
|
209 * @param aLogId a unique log event id |
|
210 * @param aObserver observer of this fetcher |
|
211 */ |
|
212 CLogsExtPresentityIdFetcher( |
|
213 const TUint32 aServiceId, |
|
214 const TLogId aLogId, |
|
215 MLogsExtPresentityIdFetcherObserver& aObserver ); |
|
216 |
|
217 /** |
|
218 * Starts the fetching. |
|
219 * |
|
220 * @since S60 v3.2 |
|
221 */ |
|
222 void DoPresenceIdFetchL(); |
|
223 |
|
224 /** |
|
225 * Retrieves the contact store id of a certain service from the service |
|
226 * provider settings table. |
|
227 * |
|
228 * @since S60 v3.2 |
|
229 * @param aSPSettings Service provider settings API |
|
230 */ |
|
231 void GetContactStoreIdL( CSPSettings& aSPSettings ); |
|
232 |
|
233 /** |
|
234 * Retrieves the FieldType of a certain service from the service |
|
235 * provider settings table. |
|
236 * |
|
237 * @since S60 v3.2 |
|
238 * @param aSPSettings Service provider settings API |
|
239 */ |
|
240 void GetPresentityIDFieldTypeL( CSPSettings& aSPSettings ); |
|
241 |
|
242 /** |
|
243 * Handles the completion of an operation. |
|
244 * |
|
245 * @since S60 v3.2 |
|
246 * @param aContact The contact returned by the operation. |
|
247 * A client must take the ownership immediately. |
|
248 */ |
|
249 void HandleRetrievedContactL( MVPbkStoreContact* aContact ); |
|
250 |
|
251 |
|
252 private: // data |
|
253 |
|
254 /** |
|
255 * Service id |
|
256 */ |
|
257 TUint32 iServiceId; |
|
258 |
|
259 /** |
|
260 * Field type resource id. |
|
261 */ |
|
262 TInt iFieldTypeResId; |
|
263 |
|
264 /** |
|
265 * Unique event ID associated with a log event. |
|
266 */ |
|
267 TLogId iLogId; |
|
268 |
|
269 /** |
|
270 * The observer of this fetcher. |
|
271 * Not own. |
|
272 */ |
|
273 MLogsExtPresentityIdFetcherObserver* iObserver; |
|
274 |
|
275 /** |
|
276 * Contact store. |
|
277 * Not own. |
|
278 */ |
|
279 MVPbkContactStore* iCntStore; |
|
280 |
|
281 /** |
|
282 * Contact link. Note: this contact link descriptor should have been |
|
283 * obtained using the MVPbkStreamable interface of the virtual phonebook |
|
284 * Own. |
|
285 */ |
|
286 HBufC8* iCntLink; |
|
287 |
|
288 /** |
|
289 * Presentity Id. |
|
290 * Own. |
|
291 */ |
|
292 HBufC* iPresentityId; |
|
293 |
|
294 /** |
|
295 * Contact store id. |
|
296 * Own. |
|
297 */ |
|
298 HBufC* iContactStoreId; |
|
299 |
|
300 /** |
|
301 * Contact Manager. |
|
302 * Own. |
|
303 */ |
|
304 CVPbkContactManager* iContactManager; |
|
305 |
|
306 /** |
|
307 * Contact link array. |
|
308 * Own. |
|
309 */ |
|
310 MVPbkContactLinkArray* iContactLinkArray; |
|
311 |
|
312 /** |
|
313 * Contact operation base. |
|
314 * Own. |
|
315 */ |
|
316 MVPbkContactOperationBase* iContactOperationBase; |
|
317 |
|
318 }; |
|
319 |
|
320 #endif // C_CLOGSEXTPRESENTITYIDFETCHER_H |