|
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: Presence in pbonebook |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef PRESENCEICONINFO_H |
|
20 #define PRESENCEICONINFO_H |
|
21 |
|
22 #include <e32std.h> |
|
23 #include <badesca.h> |
|
24 #include <MVPbkSingleContactOperationObserver.h> |
|
25 #include <mcontactpresence.h> |
|
26 #include <VPbkEng.rsg> |
|
27 |
|
28 #include "mpresencetrafficlightsobs.h" |
|
29 #include "presenceiconinfolistener.h" |
|
30 |
|
31 |
|
32 class MContactPresenceObs; |
|
33 class MPresenceTrafficLights; |
|
34 class CVPbkContactLinkArray; |
|
35 class MVPbkContactOperationBase; |
|
36 class MContactPresenceInfo; |
|
37 class CPresenceIconInfoRes; |
|
38 class MPresenceServiceIconInfo; |
|
39 |
|
40 //The types for chat |
|
41 const TInt KPresenceFieldGroup[] = { R_VPBK_FIELD_TYPE_IMPP }; |
|
42 |
|
43 /** |
|
44 * CPresenceInfoInfo |
|
45 * |
|
46 * Presence in phonebook |
|
47 * |
|
48 * @lib contactpresence |
|
49 * @since s60 v5.0 |
|
50 */ |
|
51 NONSHARABLE_CLASS( CPresenceIconInfo ) : public CBase, |
|
52 public MVPbkSingleContactOperationObserver, public MPresenceIconNotifier |
|
53 { |
|
54 public: |
|
55 |
|
56 /** |
|
57 * Constructor. |
|
58 * @param aObs callback observer |
|
59 * @param aPackedContactId contact id |
|
60 */ |
|
61 static CPresenceIconInfo* NewL( |
|
62 CPresenceIconInfoListener& aParent, |
|
63 MContactPresenceObs& aObs, |
|
64 const TDesC8& aPackedContactId, |
|
65 MPresenceTrafficLights& aIcons, |
|
66 TBool aIsSubscription, |
|
67 TInt aOpId ); |
|
68 |
|
69 virtual ~CPresenceIconInfo(); |
|
70 |
|
71 /** |
|
72 * Destructor plus remove from queue |
|
73 */ |
|
74 void Destroy(); |
|
75 |
|
76 /** |
|
77 * start to get icon info |
|
78 * @param aPpId operation id used in response |
|
79 */ |
|
80 void StartGetIconInfoL( ); |
|
81 |
|
82 /** |
|
83 * start to get icon info once |
|
84 */ |
|
85 // void StartGetIconInfoOnceL( TInt aOpId ); |
|
86 |
|
87 /** |
|
88 * contact link accessor |
|
89 * @return contact link |
|
90 */ |
|
91 TPtrC8 ContactLink(); |
|
92 |
|
93 /** |
|
94 * Is this request running or waiting |
|
95 * @Return ETrue if waiting |
|
96 */ |
|
97 TBool IsWaiting(); |
|
98 |
|
99 /** |
|
100 * Send empty Notification to tell that there is no valid presence status anymore |
|
101 * This is called when contact link is modified or deleted |
|
102 */ |
|
103 void SendEmptyNotification(); |
|
104 |
|
105 /** |
|
106 * Is this subscritpion or get method |
|
107 */ |
|
108 TBool IsSubscription(); |
|
109 |
|
110 /** |
|
111 * Operation id accessor |
|
112 * @return operation id |
|
113 */ |
|
114 TInt OpId(); |
|
115 |
|
116 /** |
|
117 * Send error callback method and delete this instance |
|
118 * @param aError error code |
|
119 */ |
|
120 void SendErrorCallback( TInt aError ); |
|
121 |
|
122 inline static TInt LinkOffset(); |
|
123 |
|
124 public: // from base class MPresenceIconNotifier |
|
125 |
|
126 void NewIconForContact( |
|
127 MVPbkContactLink* aLink, |
|
128 const TDesC8& aBrandId, |
|
129 const TDesC8& aElementId, |
|
130 TInt aId, |
|
131 TInt aBrandLanguage ); |
|
132 |
|
133 void NewIconsForContact( |
|
134 MVPbkContactLink* aLink, |
|
135 RPointerArray <MPresenceServiceIconInfo>& aInfoArray, |
|
136 TInt aId ); |
|
137 |
|
138 |
|
139 private: |
|
140 |
|
141 |
|
142 // from MVPbkSingleContactOperationObserver |
|
143 |
|
144 /** |
|
145 * Called when operation is completed. |
|
146 * |
|
147 * @param aOperation the completed operation. |
|
148 * @param aContact the contact returned by the operation. |
|
149 * Client must take the ownership immediately. |
|
150 * |
|
151 * !!! NOTICE !!! |
|
152 * If you use Cleanupstack for MVPbkStoreContact |
|
153 * Use MVPbkStoreContact::PushL or |
|
154 * CleanupDeletePushL from e32base.h. |
|
155 * (Do Not Use CleanupStack::PushL(TAny*) because |
|
156 * then the virtual destructor of the M-class |
|
157 * won't be called when the object is deleted). |
|
158 */ |
|
159 void VPbkSingleContactOperationComplete( MVPbkContactOperationBase& aOperation, |
|
160 MVPbkStoreContact* aContact ); |
|
161 |
|
162 /** |
|
163 * Called if the operation fails. |
|
164 * |
|
165 * @param aOperation the failed operation. |
|
166 * @param aError error code of the failure. |
|
167 */ |
|
168 void VPbkSingleContactOperationFailed( MVPbkContactOperationBase& aOperation, TInt aError ); |
|
169 |
|
170 private: |
|
171 |
|
172 /** |
|
173 * constructor |
|
174 */ |
|
175 CPresenceIconInfo( |
|
176 CPresenceIconInfoListener& aParent, |
|
177 MContactPresenceObs& aObs, |
|
178 MPresenceTrafficLights& aIcons, |
|
179 TBool aIsSubscription, |
|
180 TInt aOpId ); |
|
181 |
|
182 /** |
|
183 * constructor |
|
184 */ |
|
185 void ConstructL( const TDesC8& aPackedContactId ); |
|
186 |
|
187 private: |
|
188 |
|
189 // void OpenCmsConnectionsL(); |
|
190 |
|
191 /** |
|
192 * Fetch contact data |
|
193 */ |
|
194 void FetchContactL( ); |
|
195 |
|
196 /** |
|
197 * Reset members |
|
198 */ |
|
199 void ResetData(); |
|
200 |
|
201 /** |
|
202 * Reset members |
|
203 */ |
|
204 void ResetData( MVPbkContactOperationBase& aOperation ); |
|
205 |
|
206 void DoVPbkSingleContactOperationCompleteL( MVPbkContactOperationBase& aOperation, |
|
207 MVPbkStoreContact* aContact ); |
|
208 |
|
209 |
|
210 /** |
|
211 * Fetch relevant fields |
|
212 * @param aContact open store contact |
|
213 * @return array of field values |
|
214 */ |
|
215 CDesCArrayFlat* FetchContactFieldsLC( MVPbkStoreContact* aContact ); |
|
216 |
|
217 /** |
|
218 * Fetch a single field |
|
219 * @param aResourceId resource id |
|
220 * @param aArray array where to put findings |
|
221 * @param aContact open store contact |
|
222 */ |
|
223 void FetchContactFieldL( TInt aResourceId, CDesCArrayFlat& aArray, MVPbkStoreContact* aContact ); |
|
224 |
|
225 /** |
|
226 * Temporary save of first notification data |
|
227 */ |
|
228 void AllocatePendingNotifyL( |
|
229 const TDesC8& aBrandId, |
|
230 const TDesC8& aElementId ); |
|
231 |
|
232 /** |
|
233 * Send pending callback method call |
|
234 */ |
|
235 void SendPendingCallback(); |
|
236 |
|
237 void DoCopyInfosL( |
|
238 MVPbkContactLink* aLink, |
|
239 RPointerArray <MPresenceServiceIconInfo>& aInfoArray, |
|
240 TInt aId ); |
|
241 |
|
242 |
|
243 |
|
244 private: // Data |
|
245 |
|
246 /** |
|
247 * Parent |
|
248 */ |
|
249 CPresenceIconInfoListener& iParent; |
|
250 |
|
251 TDblQueLink iLink; |
|
252 |
|
253 /** |
|
254 * callback observer |
|
255 */ |
|
256 MContactPresenceObs& iObs; |
|
257 |
|
258 |
|
259 /** |
|
260 * Packed Contact link |
|
261 * Own. |
|
262 */ |
|
263 HBufC8* iContactLink; |
|
264 |
|
265 /** |
|
266 * Pointer to stack variable to detect the deletion of the heap |
|
267 * instance. This case takes place if a client |
|
268 * calls destructor in callback method. |
|
269 * Own. |
|
270 */ |
|
271 TBool* iDestroyedPtr; |
|
272 |
|
273 /** |
|
274 * traffic light icon provider |
|
275 */ |
|
276 MPresenceTrafficLights& iIcons; |
|
277 |
|
278 /** |
|
279 * Waiting store open |
|
280 */ |
|
281 TBool iWaiting; |
|
282 |
|
283 /** |
|
284 * links |
|
285 * OWN |
|
286 */ |
|
287 CVPbkContactLinkArray* iLinkArray; |
|
288 |
|
289 MVPbkContactOperationBase* iOperation; |
|
290 |
|
291 /** |
|
292 * Contact link |
|
293 * OWN |
|
294 */ |
|
295 MVPbkContactLink* iPbkContactLink; |
|
296 |
|
297 /** |
|
298 * Are we in intialization, then we have to wait before sending data to callback method |
|
299 */ |
|
300 TBool iInitialization; |
|
301 |
|
302 /** |
|
303 * Temporary save for pending notification, M-classes |
|
304 */ |
|
305 RPointerArray <MContactPresenceInfo> iPendings; |
|
306 |
|
307 /** |
|
308 * Temporary save for pending notification, C-classes to enable deletion |
|
309 */ |
|
310 RPointerArray <CPresenceIconInfoRes> iPendings2; |
|
311 |
|
312 TBool iNotifyPending; |
|
313 |
|
314 /** |
|
315 * Subscription or get method |
|
316 */ |
|
317 TBool iSubscription; |
|
318 |
|
319 /** |
|
320 * Operation id used in get once method |
|
321 */ |
|
322 TInt iOpId; |
|
323 |
|
324 }; |
|
325 |
|
326 TInt CPresenceIconInfo::LinkOffset() |
|
327 { |
|
328 return _FOFF(CPresenceIconInfo, iLink); |
|
329 } |
|
330 |
|
331 |
|
332 #endif // PRESENCEICONINFO_H |