|
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: Used to collect various presence related information for the |
|
15 * extension. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef C_CLOGSPRESENCETABLEMANAGER_H |
|
21 #define C_CLOGSPRESENCETABLEMANAGER_H |
|
22 |
|
23 #include <e32base.h> |
|
24 |
|
25 #include "logwrap.h" |
|
26 |
|
27 class CLogsPresenceStatusTableEntry; |
|
28 class CLogsPresenceIndexTableEntry; |
|
29 class CLogsExtLogIdPresIdMapping; |
|
30 class MLogsModel; |
|
31 |
|
32 /** |
|
33 * Used to collect and to keep track of various presence related |
|
34 * information for the extension. |
|
35 * |
|
36 * @since S60 v3.2 |
|
37 */ |
|
38 NONSHARABLE_CLASS(CLogsPresenceTableManager) : public CBase |
|
39 { |
|
40 friend class ut_clogsuicontrolextension; |
|
41 public: |
|
42 |
|
43 friend class ut_clogspresencetablemanager; |
|
44 |
|
45 /** |
|
46 * Two-phased constructor. |
|
47 * Creates a new CLogsPresenceTableManager. |
|
48 * |
|
49 * @since S60 v3.2 |
|
50 */ |
|
51 static CLogsPresenceTableManager* NewL(); |
|
52 |
|
53 /** |
|
54 * Two-phased constructor. |
|
55 * Creates a new CLogsPresenceTableManager. |
|
56 * |
|
57 * @since S60 v3.2 |
|
58 */ |
|
59 static CLogsPresenceTableManager* NewLC(); |
|
60 |
|
61 /** |
|
62 * Destructor. |
|
63 * |
|
64 * @since S60 v3.2 |
|
65 */ |
|
66 ~CLogsPresenceTableManager(); |
|
67 |
|
68 |
|
69 /** |
|
70 * Gets the index of a certain icon in the listbox's icon array. The index |
|
71 * is found by: |
|
72 * a) looking up the presence status of the given presentity from the |
|
73 * status table (which contains CLogsStatusTableEntry objects) |
|
74 * b) using the status found in step a) to retrieve the index from the |
|
75 * index table (which contains CLogsIndexTableEntry objects) |
|
76 * |
|
77 * @since S60 v3.2 |
|
78 * @param aServiceId service id |
|
79 * @param aPresentityId the presentity id (depends on the particular |
|
80 * service, e.g.'sip:Max.And.Moritz@WilhelmBusch.edu' or similar) |
|
81 * @param aIndex the variable the index will be stored to in case it was |
|
82 * found, aIndex will not be modified in case of an error. |
|
83 * @return KErrNone, if the index information for the specified service |
|
84 * and aPresentityId could be retrieved; |
|
85 * KErrNotReady, if a corresponding index table entry exists, |
|
86 * but the index information was not updated yet (fetching |
|
87 * might be still ongoing) |
|
88 * KErrNotFound, if no corresponding index table entry exists |
|
89 * KErrGeneral, otherwise |
|
90 */ |
|
91 TInt GetIndex( const TUint32 aServiceId, |
|
92 const TDesC& aPresentityId, |
|
93 TInt& aIndex ); |
|
94 |
|
95 /** |
|
96 * Sets the status of a certain status entry of the status table. |
|
97 * |
|
98 * @since S60 v3.2 |
|
99 * @param aServiceId service id |
|
100 * @param aPresentityId the presentity id |
|
101 * @param aPresenceStatus the presence status to be set |
|
102 * @param aShowStatus status display flag |
|
103 * @return KErrNone if setting the value succeeded; |
|
104 * system-wide errorcode otherwise |
|
105 */ |
|
106 TInt SetStatusInStatusTable( const TUint32 aServiceId, |
|
107 const TDesC& aPresentityId, |
|
108 const TDesC& aPresenceStatus, |
|
109 TBool aShowStatus ); |
|
110 |
|
111 /** |
|
112 * Sets the index of a certain index entry of the index table. |
|
113 * |
|
114 * @since S60 v3.2 |
|
115 * @param aServiceId service id |
|
116 * @param aPresenceStatus the presence status |
|
117 * @param aIndex the index to be set |
|
118 * @return KErrNone if setting the value succeeded; |
|
119 * system-wide errorcode otherwise |
|
120 */ |
|
121 TInt SetIndexInIndexTable( const TUint32 aServiceId, |
|
122 const TDesC& aPresenceStatus, |
|
123 const TInt aIndex ); |
|
124 |
|
125 /** |
|
126 * Determines whether the icon index for the specified presentity |
|
127 * of the specified service is already available or not. |
|
128 * |
|
129 * Note: If the index is available then the status of the presentity |
|
130 * has been retrieved and the icon has been added to the icon array list |
|
131 * already. The status icon is ready to be displayed. If the index is not |
|
132 * available yet, the icon has not been added and is not ready to be |
|
133 * displayed. |
|
134 * |
|
135 * @param aServiceId service id |
|
136 * @param aPresentityId the presentity id |
|
137 * @return ETrue, if the index is available, EFalse otherwise |
|
138 */ |
|
139 TBool PresenceIconIndexAvailable( const TUint32 aServiceId, |
|
140 const TDesC& aPresentityId ); |
|
141 |
|
142 /** |
|
143 * Gets the index of a certain icon in the listbox's icon array from the |
|
144 * index table. |
|
145 * |
|
146 * @since S60 v3.2 |
|
147 * @param aServiceId service id |
|
148 * @param aPresenceStatus the presence status (e.g. 'busy' or similar) |
|
149 * @param aIndex the variable the index will be stored to in case it was |
|
150 * found, aIndex will not be modified in case of an error |
|
151 * @return KErrNone, if the index information could be retrieved (means |
|
152 * that an index entry with aServiceId and aPresenceStatus exists |
|
153 * in the table; however, the value of the index of that entry can |
|
154 * still be 'KErrNotFound' if the value was not changed after the |
|
155 * entry was created, since KErrNotFound is the initial value for |
|
156 * the index of a index entry); |
|
157 * KErrNotFound otherwise. |
|
158 * |
|
159 */ |
|
160 TInt GetIndexFromIndexTable( const TUint32 aServiceId, |
|
161 const TDesC& aPresenceStatus, |
|
162 TInt& aIndex ); |
|
163 |
|
164 /** |
|
165 * Creates a new CLogsStatusTableEntry object and adds it to the manager's |
|
166 * status table (which is iPresenceStatusTable). Before adding an entry to |
|
167 * the table it is checked whether the entry already exists in the table |
|
168 * to avoid duplicates. Entries with the same service id and presentity id |
|
169 * are considered to be duplicates. |
|
170 * Note: Since the presence status might not being known when adding the |
|
171 * entry it is possible to leave it unspecified. |
|
172 * |
|
173 * @since S60 v3.2 |
|
174 * @param aServiceId service id |
|
175 * @param aPresentityId the presentity id (depends on the particular |
|
176 * @param aShowStatus status display flag |
|
177 * service, e.g.'sip:Max.And.Moritz@WilhelmBusch.edu' or similar) |
|
178 * @return KErrNone, if the creation and insertation was successful; |
|
179 * system-wide errorcode otherwise. |
|
180 */ |
|
181 TInt AddEntryToStatusTable( const TUint32 aServiceId, |
|
182 const TDesC& aPresentityId, |
|
183 TBool aShowStatus ); |
|
184 |
|
185 /** |
|
186 * Creates a new CLogsIndexTableEntry object and adds it to the manager's |
|
187 * index table (which is iPresenceIndexTable). Before adding an entry to |
|
188 * the table it is checked whether the entry alraedy exists in the table |
|
189 * to avoid duplicates. Entries with the same service id and presence |
|
190 * status are considered to be duplicates. |
|
191 * Note: Since the idnex might not being known when adding the |
|
192 * entry it is possible to leave it unspecified. |
|
193 * |
|
194 * @since S60 v3.2 |
|
195 * @param aServiceId service id |
|
196 * @param aPresentityId the presentity id (depends on the particular |
|
197 * service, e.g.'sip:Max.And.Moritz@WilhelmBusch.edu' or similar) |
|
198 * @return KErrNone, if the creation and insertation was successful; |
|
199 * system-wide errorcode otherwise. |
|
200 */ |
|
201 TInt AddEntryToIndexTable( const TUint32 aServiceId, |
|
202 const TDesC& aPresenceStatus ); |
|
203 |
|
204 /** |
|
205 * Returns the number of entries in the status table. |
|
206 * |
|
207 * @since S60 v3.2 |
|
208 * @return number of entries in the status table |
|
209 */ |
|
210 TInt StatusTableEntriesCount(); |
|
211 |
|
212 /** |
|
213 * Adds another mapping to the collection of mappings |
|
214 * (Log Id is mapped to a presentity id). |
|
215 * |
|
216 * @since S60 v3.2 |
|
217 * @param aLogId a log id |
|
218 * @param aPresentityId a presentity id |
|
219 */ |
|
220 void AddMappingL( const TLogId aLogId, const TDesC& aPresentitytId ); |
|
221 |
|
222 /** |
|
223 * Returns the presentity id of a mapping using the log id to retrieve |
|
224 * the mapping. |
|
225 * |
|
226 * @since S60 v3.2 |
|
227 * @param aLogId a log id |
|
228 * @return the presentity id or NULL if no mapping was found for the |
|
229 * specified lod id. |
|
230 */ |
|
231 const TDesC* RetrievePresentityId( const TLogId aLogId ); |
|
232 |
|
233 /** |
|
234 * Removes unnecessary mappings by comparing the log ids of the current |
|
235 * view to the log ids in the array of mappings. Those mappings which |
|
236 * contain a log id that cannot be found from 'aModel' will be deleted. |
|
237 * |
|
238 * @since S60 v3.2 |
|
239 * @param aModel the data model that contains the |
|
240 * information about the log event entries in the current view. |
|
241 */ |
|
242 void RemoveUnneededMappings( MLogsModel& aModel ); |
|
243 |
|
244 /** |
|
245 * Sets the status of a certain status entry of the status table to the |
|
246 * initial value ( = presense not displayed ) . |
|
247 * |
|
248 * @since S60 v3.2 |
|
249 * @param aServiceId service id |
|
250 * @param aPresentityId a presentity id |
|
251 * @param aShowStatus status display flag |
|
252 * @return KErrNone in case the status entry was reset successfully; |
|
253 * system-wide error code otherwise |
|
254 */ |
|
255 TInt UpdateStatusTableEntry( const TUint32 aServiceId, |
|
256 const TDesC& aPresentityId, |
|
257 TBool aShowStatus ); |
|
258 |
|
259 /** |
|
260 * Sets the status of all status entries of the status table to the initial |
|
261 * value. |
|
262 */ |
|
263 void ResetStatusTableEntries(); |
|
264 |
|
265 /** |
|
266 * Sets state of this class to its initial state |
|
267 * |
|
268 */ |
|
269 void ResetState(); |
|
270 |
|
271 private: |
|
272 |
|
273 /** |
|
274 * Returns the number of entries in the index table. |
|
275 * |
|
276 * @since S60 v3.2 |
|
277 * @return number of entries in the index table |
|
278 */ |
|
279 TInt IndexTableEntriesCount(); |
|
280 |
|
281 /** |
|
282 * Gets the status of a certain entry from the status table. |
|
283 * |
|
284 * @since S60 v3.2 |
|
285 * @param aServiceId service id |
|
286 * @param aPresentityId the presentity id |
|
287 * @return the presence status or NULL if the value could not |
|
288 * be retrieved or if the internal 'ShowStatus' flag |
|
289 * of the status table entry is not set. |
|
290 */ |
|
291 TDesC* GetStatusFromStatusTable( const TUint32 aServiceId, |
|
292 const TDesC& aPresentityId ); |
|
293 /** |
|
294 * Determines whether a status entry exists for the given arguments. |
|
295 * |
|
296 * @since S60 v3.2 |
|
297 * @param aServiceId service id |
|
298 * @param aPresentityId the presentity id |
|
299 * @return ETrue, if a status entry with the given arguments exists; |
|
300 * EFalse otherwise |
|
301 */ |
|
302 TBool StatusEntryExists( const TUint32 aServiceId, |
|
303 const TDesC& aPresentityId ); |
|
304 |
|
305 /** |
|
306 * Determines whether a index entry exists for the given arguments. |
|
307 * |
|
308 * @since S60 v3.2 |
|
309 * @param aServiceId service id |
|
310 * @param aPresenceStatus the presence status (e.g. 'busy' or similar) |
|
311 * @return ETrue, if a index entry with the given arguments exists; |
|
312 * EFalse otherwise |
|
313 */ |
|
314 TBool IndexEntryExists( const TUint32 aServiceId, |
|
315 const TDesC& aPresenceStatus ); |
|
316 |
|
317 /** |
|
318 * Updates the presentity id an existing mapping. |
|
319 * |
|
320 * @since S60 v3.2 |
|
321 * @param aLogId a unique log id |
|
322 * @param aPresentityId the presentity id |
|
323 */ |
|
324 void UpdateMappingL( const TLogId aLogId, |
|
325 const TDesC& aPresentitytId ); |
|
326 |
|
327 |
|
328 /** |
|
329 * Creates a new mapping with the specified arguments. |
|
330 * |
|
331 * @since S60 v3.2 |
|
332 * @param aLogId a unique log id |
|
333 * @param aPresentityId the presentity id |
|
334 */ |
|
335 void AppendMappingL( const TLogId aLogId, |
|
336 const TDesC& aPresentitytId ); |
|
337 |
|
338 /** |
|
339 * Checks if one of the log events in 'aModel' has the same LogId as |
|
340 * the one that is specified. |
|
341 * |
|
342 * @since S60 v3.2 |
|
343 * @param aModel the data model that contains the |
|
344 * information about the log event entries in the current view. |
|
345 * @param aLogId a unique log id |
|
346 * @return ETrue, if aLogId can be found in aModel; EFalse otherwise. |
|
347 */ |
|
348 TBool IsLogIdInMappingArray( MLogsModel& aModel, TLogId aLogId ); |
|
349 |
|
350 |
|
351 /** |
|
352 * Removes a mapping from the array that contains the pointer |
|
353 * of all the mappings. This includes the deletion of the object |
|
354 * whose pointer was stored in the mapping array. |
|
355 * |
|
356 * @since S60 v3.2 |
|
357 * @param aLogId a unique log id |
|
358 */ |
|
359 void RemoveMapping( TLogId aLogId ); |
|
360 |
|
361 private: |
|
362 |
|
363 /** |
|
364 * Symbian second phase constructor. |
|
365 */ |
|
366 void ConstructL(); |
|
367 |
|
368 /** |
|
369 * Constructor. |
|
370 */ |
|
371 CLogsPresenceTableManager(); |
|
372 |
|
373 |
|
374 private: // data |
|
375 |
|
376 /** |
|
377 * Collection of status table entries. |
|
378 * Own. |
|
379 */ |
|
380 RPointerArray<CLogsPresenceStatusTableEntry> iPresenceStatusTable; |
|
381 |
|
382 /** |
|
383 * Collection of index table entries. |
|
384 * Own. |
|
385 */ |
|
386 RPointerArray<CLogsPresenceIndexTableEntry> iPresenceIndexTable; |
|
387 |
|
388 /** |
|
389 * Collection of mappings. |
|
390 * Own. |
|
391 */ |
|
392 RPointerArray<CLogsExtLogIdPresIdMapping> iLogIdPresIdMappingArray; |
|
393 }; |
|
394 |
|
395 #endif // C_CLOGSPRESENCETABLEMANAGER_H |