1 /* |
|
2 * Copyright (c) 2005-2006 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: Keeps info about Services, MIMEs and Applications |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef C_DEFAULTAPPSERVMIMEAPPS_H |
|
21 #define C_DEFAULTAPPSERVMIMEAPPS_H |
|
22 |
|
23 class CApaMaskedBitmap; |
|
24 class CDefaultAppServMimeApps; |
|
25 class CServicesDB; |
|
26 class RApaLsSession; |
|
27 |
|
28 /** The UID of the General Settings Application */ |
|
29 const TUid KUidGS = { 0x100058EC }; //we define this here because we use it in several places |
|
30 |
|
31 /** |
|
32 * Helper class: stores an Application name, its UID and some other info (how many |
|
33 * service&MIMEs pair it supports, is it platform application or not) |
|
34 * This helper class is used to sort the list of Applications that support a Service&MIME pair |
|
35 * |
|
36 * @since S60 v5.0 |
|
37 */ |
|
38 class CAppHelper : public CBase |
|
39 { |
|
40 public: |
|
41 /** flags used with the app helper. */ |
|
42 enum |
|
43 { |
|
44 EFlagPlatformApp =0x0001, |
|
45 EFlagNameNotOwned =0x0002 |
|
46 }; |
|
47 public: |
|
48 |
|
49 /** |
|
50 * Destructor. |
|
51 */ |
|
52 ~CAppHelper(); |
|
53 |
|
54 /** |
|
55 * Symbian OS two-phased constructor |
|
56 * @return |
|
57 */ |
|
58 static CAppHelper* NewLC(const TDesC& aName, const TInt aUid); |
|
59 |
|
60 /** |
|
61 * Symbian OS two-phased constructor |
|
62 * @return |
|
63 */ |
|
64 static CAppHelper* NewLC(const CAppHelper& aApp); |
|
65 |
|
66 /** |
|
67 * This function is used for ordering an array of CAppHelper objects |
|
68 * |
|
69 * @since S60 v5.0 |
|
70 * @param a1 CAppHelper object |
|
71 * @param a2 CAppHelper object |
|
72 */ |
|
73 static TInt OrderApplications(const CAppHelper& a1, const CAppHelper& a2); |
|
74 private: |
|
75 |
|
76 /** |
|
77 * C++ constructor |
|
78 */ |
|
79 CAppHelper(const TInt aUid, const TInt aScore, const TInt aFlags=0); |
|
80 public: |
|
81 |
|
82 /** |
|
83 * the App name |
|
84 * Owned or Not Owned, depending on flags (iFlag&EFlagNameNotOwned). |
|
85 */ |
|
86 HBufC* iName; |
|
87 |
|
88 /** |
|
89 * the UID of the application |
|
90 */ |
|
91 TInt iUid; |
|
92 |
|
93 /** |
|
94 * the application score (how many Services & MIMEs it supports) |
|
95 */ |
|
96 TInt iScore; |
|
97 |
|
98 /** |
|
99 * Object flags |
|
100 */ |
|
101 TInt iFlags; |
|
102 }; |
|
103 |
|
104 /** |
|
105 * Helper class: stores a Service & Mime Pair |
|
106 * |
|
107 * This class stores data specific to a Service & MIME pair: |
|
108 * -the Service + MIME string |
|
109 * -the Service Uid |
|
110 * -the MIME |
|
111 * -a list of applications (CAppHelper) that support this Service & MIME pair |
|
112 * -the list index and Uid of the default application for this Service & MIME pair |
|
113 * |
|
114 * @since S60 v5.0 |
|
115 */ |
|
116 class CServiceMime : public CBase |
|
117 { |
|
118 friend class CDefaultAppServMimeApps; |
|
119 public: |
|
120 |
|
121 /** |
|
122 * C++ constructor |
|
123 */ |
|
124 CServiceMime(); |
|
125 |
|
126 /** |
|
127 * Destructor. |
|
128 */ |
|
129 ~CServiceMime(); |
|
130 |
|
131 /** |
|
132 * This function is used for ordering an array of CServiceMime objects |
|
133 * |
|
134 * @since S60 v5.0 |
|
135 * @param a1 CServiceMime object |
|
136 * @param a2 CServiceMime object |
|
137 */ |
|
138 static TInt OrderServiceMimes(const CServiceMime& a1, const CServiceMime& a2); |
|
139 |
|
140 private: |
|
141 /** |
|
142 * String that contains the localized Service + MIME name |
|
143 * Owned. |
|
144 */ |
|
145 HBufC *iServiceMime; |
|
146 |
|
147 /** |
|
148 * The Uid of the service |
|
149 */ |
|
150 TUid iServiceUid; |
|
151 |
|
152 /** |
|
153 * the MIME string |
|
154 * Owned. |
|
155 */ |
|
156 HBufC8 *iMime; |
|
157 |
|
158 /** |
|
159 * list of applications that support this Service & MIME pair |
|
160 * Owned (members of the array). |
|
161 */ |
|
162 RPointerArray<CAppHelper> iApplications; |
|
163 |
|
164 /** |
|
165 * the UID of the default application for this Service & MIME |
|
166 */ |
|
167 TUid iDefaultAppUid; |
|
168 |
|
169 /** |
|
170 * the list index for the default application |
|
171 * this has the following special values: |
|
172 * -1 : the default is (yet) unknown |
|
173 * -2 : there is a single app in the list, its priority is System |
|
174 * (this means: do not add other apps unless they have system priority) |
|
175 * -3 : there are more than one applications in the list, ALL have the System priority |
|
176 * (this also means: do not add other apps unless they have system priority) |
|
177 */ |
|
178 TInt iDefaultApp; |
|
179 |
|
180 /** |
|
181 * indicates if the Service & MIME pair instance is used by a task or not |
|
182 */ |
|
183 TBool iUsedByTasks; |
|
184 }; |
|
185 |
|
186 |
|
187 /** |
|
188 * Helper class: stores a Task |
|
189 * |
|
190 * This class stores data specific to a Task: |
|
191 * -the task caption/title (list layout and title layout) |
|
192 * -the lists of Service (UIDs) & MIMEs associated with this task |
|
193 * -the MIME label |
|
194 * -a list of Services & MIMEs objects (and their associated application list) that correspond to the list |
|
195 * of Services & MIMEs associated with the task |
|
196 * -a list of applications (CAppHelper) that are associated with this task |
|
197 * -the UID and list index of the default application for the task, in the list(s) above. |
|
198 * |
|
199 * How this works: |
|
200 * The Service & MIME pairs associated with the task are those pairs for which changing the default application for the |
|
201 * task will have an impact: the new default becomes the default application for all these pairs, if applicable. |
|
202 * The list of candidate default applications is build from the Service & MIME pairs associated with the task: any |
|
203 * application that can handle at least one pair, is added to the list. The score corresponds to the number of pairs an |
|
204 * application is able to handle (the better the score, the more suitable the application is for the task). |
|
205 * When a new application is made default, it is also made default for Open + the MIME label. This way we can retrieve |
|
206 * the default application for the task, to display it to the user. |
|
207 * The list of Services & MIME objects are instances of CServiceMime that correspond to the list of Services & MIMEs that |
|
208 * are associated with the task (the associated Services & MIMEs is a "theoretical" list, while the CServiceMime list |
|
209 * is a list of Services & MIMEs that were found in the system. The Services & MIMEs in this object list is a subset of |
|
210 * the associated Services & MIMEs. The reunion of all Applications lists associated with each CServiceMime object in the |
|
211 * list is going to be same as the list of Applications that are associated with the Task. |
|
212 * When a new default application is selected for the task, this new default is saved in 2 ways: |
|
213 * -the new default application is made default for the Open service and the MIME label. This way, we can retrieve next |
|
214 * time the default application for the task. There is no danger to launch this default for opening the MIME label, since |
|
215 * no application is supposed to support the MIME label. |
|
216 * -the new default application is made default for all the Services & MIMEs associated with the task: for each instance |
|
217 * of CServiceMime in the list, the default is looked in the application list of the object: if it is found (which means |
|
218 * that the new default application supports that Service & MIME), then the new task default is made default for the |
|
219 * current Service & MIME too. |
|
220 * |
|
221 * @since S60 v5.0 |
|
222 */ |
|
223 class CMediaTask : public CBase |
|
224 { |
|
225 friend class CDefaultAppServMimeApps; |
|
226 public: |
|
227 |
|
228 /** |
|
229 * Symbian OS two-phased constructor |
|
230 * @return |
|
231 */ |
|
232 static CMediaTask* NewLC( TResourceReader& aReader ); |
|
233 |
|
234 /** |
|
235 * Destructor. |
|
236 */ |
|
237 ~CMediaTask(); |
|
238 private: |
|
239 |
|
240 /** |
|
241 * C++ constructor |
|
242 */ |
|
243 CMediaTask(); |
|
244 |
|
245 /** |
|
246 * Symbian constructor |
|
247 */ |
|
248 void ConstructL( TResourceReader& aReader ); |
|
249 private: |
|
250 /** |
|
251 * Task caption, list layout |
|
252 * Owned. |
|
253 */ |
|
254 HBufC *iTaskList; |
|
255 |
|
256 /** |
|
257 * Task caption, title layout |
|
258 * Owned. |
|
259 */ |
|
260 HBufC *iTaskTitle; |
|
261 |
|
262 /** |
|
263 * List of MIMEs associated with the task |
|
264 * Owned (members of the array). |
|
265 */ |
|
266 RPointerArray<HBufC8> iMimes; |
|
267 |
|
268 /** |
|
269 * List of services associated with the task (1 to 1 correspondence with iMimes, they form pairs together) |
|
270 */ |
|
271 RArray<TInt> iServicesUids; |
|
272 |
|
273 /** |
|
274 * the MIME label |
|
275 * Owned. |
|
276 */ |
|
277 HBufC8 *iMimeLabel; |
|
278 |
|
279 /** |
|
280 * the list of real/discovered CServiceMime associated with the task |
|
281 * Not Owned (members of the array). |
|
282 */ |
|
283 RPointerArray<CServiceMime> iSMs; //not owned |
|
284 |
|
285 /** |
|
286 * Application captions for the applications associated with the task |
|
287 * Owned (members of the array). |
|
288 * Application names NOT owned (names are owned by CServiceMime objects) |
|
289 */ |
|
290 RPointerArray<CAppHelper> iApplications; |
|
291 |
|
292 /** |
|
293 * The UID of the default application for the task |
|
294 */ |
|
295 TUid iDefaultAppUid; //the Uid for the default application |
|
296 |
|
297 /** |
|
298 * the index (in the application list) of the default application for the task |
|
299 */ |
|
300 TInt iDefaultApp; //index |
|
301 |
|
302 }; |
|
303 |
|
304 |
|
305 /** |
|
306 * Engine class for the application |
|
307 * |
|
308 * This class stores a list of Services and MIMEs and it may store a list of Tasks. All data handling operations |
|
309 * are implemented in this class. |
|
310 * There are 2 types of clients for the Default App Server: |
|
311 * 1. General Settings Application (using a plugin). For this type of client we have to display first a list of tasks, |
|
312 * and if the user switches to the advanced view, we have to display a list of all Services & MIMEs in the system |
|
313 * for which the user can change the default application. |
|
314 * 2. Normal applications may also be clients for the Default APp Server. For normal applications, only a list of Services |
|
315 * and MIMEs for which the cliet application is a default candidate is displayed. The task list is not constructed. |
|
316 * When the class is instantiated, it looks in the system (AppArc) and it builds all the data structures it needs. After |
|
317 * that, it can populate various lists for displaying them to the user, and can also change the default application, as |
|
318 * instructed by the user (AppUi calls the functions). |
|
319 * |
|
320 * @since S60 v5.0 |
|
321 */ |
|
322 class CDefaultAppServMimeApps : public CBase |
|
323 { |
|
324 public: |
|
325 /** flags used with the Set Default service. They influence what data is stored in the data structures. */ |
|
326 enum |
|
327 { |
|
328 EFlagNoObserver=1, |
|
329 //R&D values |
|
330 EFlagShowAllServicesAndMimes = 0x00010000, |
|
331 EFlagGsClient = 0x00020000, |
|
332 }; |
|
333 |
|
334 /** |
|
335 * Symbian OS two-phased constructor |
|
336 * @return |
|
337 */ |
|
338 static CDefaultAppServMimeApps* NewL(const TUid& aAppUid, TInt aServiceFlags); |
|
339 |
|
340 /** |
|
341 * Symbian OS two-phased constructor |
|
342 * @return |
|
343 */ |
|
344 static CDefaultAppServMimeApps* NewLC(const TUid& aAppUid, TInt aServiceFlags); |
|
345 |
|
346 /** |
|
347 * Destructor. |
|
348 */ |
|
349 virtual ~CDefaultAppServMimeApps(); |
|
350 |
|
351 /** |
|
352 * This function fills with entries a data structure used by a List Box to display Services & MIMEs or Tasks |
|
353 * |
|
354 * @since S60 v5.0 |
|
355 * @param aServicesAndMimes the container for the list entries |
|
356 */ |
|
357 void GetServicesAndMimesListL(CDesCArray& aServicesAndMimesArray); |
|
358 |
|
359 /** |
|
360 * This function fills a Popup-list data structure with applications specific to the selected Service & MIME or Task |
|
361 * |
|
362 * @since S60 v5.0 |
|
363 * @param aIndex the index of the selected Service & MIME pair or Task |
|
364 * @param aApplicationsArray the container for the list entries |
|
365 * @param aTitle a container for the title of the list (also filled by the function) |
|
366 */ |
|
367 void GetApplicationsListL(TInt aIndex, CDesCArray& aApplicationsArray, HBufC*& aTitle); |
|
368 |
|
369 /** |
|
370 * This function sets a new default, for a Service & MIME pair or for a Task. |
|
371 * The function also updates the list of Services & MIMEs (or Tasks), to display the new default application |
|
372 * |
|
373 * @since S60 v5.0 |
|
374 * @param aServiceAndMimeIndex the index of the selected Service or Mime (or Task) |
|
375 * @param aDefaultAppIndex the index of the new default application |
|
376 * @param aServicesAndMimesArray the container for the list entries (to be updated) |
|
377 */ |
|
378 void UpdateDefaultL(TInt aServiceAndMimeIndex, TInt aDefaultAppIndex, CDesCArray *aServicesAndMimesArray); |
|
379 |
|
380 /** |
|
381 * This function resets (removes) the defaults associated with a certain task, |
|
382 * or it can remove all the defaults |
|
383 * |
|
384 * @since S60 v5.0 |
|
385 * @param aCathegory specifies the task index for which the function should reset |
|
386 * the default, or -1 if all defaults should be reset |
|
387 * @return 0 or error code (KErrArgument -> aCathegory has an invalid value) |
|
388 */ |
|
389 TInt RestoreFactorySettingsL(TInt aCathegory); |
|
390 |
|
391 private: //construction |
|
392 |
|
393 /** |
|
394 * C++ constructor |
|
395 */ |
|
396 CDefaultAppServMimeApps(); |
|
397 |
|
398 /** |
|
399 * This function builds the info database behind this class. |
|
400 * For all available services in the resources it creats the corresponding |
|
401 * Services & MIMEs (or Tasks) instances. |
|
402 * |
|
403 * @since S60 v5.0 |
|
404 * @param aAppUid the Uid of the client application |
|
405 * @param aServiceFlags different service flags requested by the client |
|
406 */ |
|
407 void ConstructL(TUid aAppUid, TInt aServiceFlags); |
|
408 |
|
409 /** |
|
410 * This function builds part the info database behind this class. |
|
411 * It creates the Services & MIMEs (or Tasks) instances for the given service |
|
412 * |
|
413 * @since S60 v5.0 |
|
414 * @param aServiceUid the Uid of the current service |
|
415 * @param aServiceIndex the index of the current service |
|
416 * @param aServiceFlags different service flags requested by the client |
|
417 * @param aServicesDb pointer to an instance that holds localized service names |
|
418 */ |
|
419 void AddMIMEsForServiceL(TUid aServiceUid, TInt aServiceIndex, TInt aServiceFlags, CServicesDB* aServicesDb); |
|
420 |
|
421 /** |
|
422 * This function sorts the Services & MIMEs and their applications. |
|
423 * It also sorts the Serivces & MIMEs associated with tasks |
|
424 * |
|
425 * @since S60 v5.0 |
|
426 */ |
|
427 void BeautifyAndSortServMimeApps(void); |
|
428 |
|
429 /** |
|
430 * This function reads from the resource file the list of tasks (and associated data). |
|
431 * This function is used during construction |
|
432 * |
|
433 * @since S60 v5.0 |
|
434 * @param aResourceId the resource id corresponding to the tasks resource |
|
435 */ |
|
436 void GetTaskListL( TInt aResourceId ); |
|
437 |
|
438 /** |
|
439 * This function adds a new Application to a list of an Service & Mime object. |
|
440 * |
|
441 * @since S60 v5.0 |
|
442 * @param aServMime the Service & Mime object |
|
443 * @param aAppUid the uid of the inserted application |
|
444 * @param aPrio the priority of the inserted application for the Service & MIME of the host object |
|
445 * @param aLs pointer to a RApaLsSession object (so we do not need to create a new connection) |
|
446 */ |
|
447 void InsertApplicationL(CServiceMime& aServMime, const TUid& aAppUid, const TDataTypePriority& aPrio, const RApaLsSession *aLs); |
|
448 |
|
449 /** |
|
450 * This function takes a task and a Service & MIME object. It checks all the applications that support the given |
|
451 * Service & MIME object (from its list). If an application is not in the task's application list, this function adds |
|
452 * it there, with a score of 1. If the application is already in the list, then its score is incremented. |
|
453 * The Service & MIME object is also marked as being used by a task. |
|
454 * |
|
455 * @since S60 v5.0 |
|
456 * @param aTask the selected task |
|
457 * @param aServMime the selected Service & MIME object |
|
458 */ |
|
459 void PopulateTaskWithApplicationsL(CMediaTask& aTask, CServiceMime* aServMime); |
|
460 |
|
461 /** |
|
462 * This function creates a string that will become en element of a list box. To create the string, the function |
|
463 * concatenates several sub-strings. |
|
464 * |
|
465 * @since S60 v5.0 |
|
466 * @param aServMime the selected Service & MIME object |
|
467 * @param aInsertDefaultApp if TRUE, creates an object that also contains the name of the default application for the |
|
468 * Service & MIME pair |
|
469 * @return the created string |
|
470 */ |
|
471 HBufC* GetServiceAndMimeStringLC(CServiceMime& aServMime, TBool aInsertDefaultApp) const; |
|
472 |
|
473 /** |
|
474 * This function creates a string that will become en element of a list box. To create the string, the function |
|
475 * concatenates several sub-strings. |
|
476 * |
|
477 * @since S60 v5.0 |
|
478 * @param aMediaTask the selected Task object |
|
479 * @param aInsertDefaultApp if TRUE, creates an object that also contains the name of the default application for the |
|
480 * Service & MIME pair |
|
481 * @return the created string |
|
482 */ |
|
483 HBufC* GetMediaTaskStringLC(CMediaTask& aMediaTask, TBool aInsertDefaultApp) const; |
|
484 |
|
485 private: //data |
|
486 |
|
487 /** |
|
488 * The list of Services & MIMEs |
|
489 * Owned (members of the array). |
|
490 */ |
|
491 RPointerArray<CServiceMime> iServMimes; |
|
492 |
|
493 /** |
|
494 * The list of Tasks |
|
495 * Owned (members of the array). |
|
496 */ |
|
497 RPointerArray<CMediaTask> iTasks; |
|
498 |
|
499 /** |
|
500 * The list of Services & MIMEs that are used by tasks (but otherwise would have been deleted, since they are not |
|
501 * displayed to the user, because there is no more than one default candidate for each Service & MIME in this list) |
|
502 * Owned (members of the array). |
|
503 */ |
|
504 RPointerArray<CServiceMime> iTaskServMimes; //ServMimes with a single application, used in tasks |
|
505 |
|
506 public: |
|
507 |
|
508 /** |
|
509 * the list of elements, ar required by the dialog |
|
510 */ |
|
511 CDesCArraySeg iList; |
|
512 |
|
513 /** |
|
514 * the UID of the client application |
|
515 */ |
|
516 TUid iAppUid; |
|
517 |
|
518 /** |
|
519 * TRUE if the current view is the GS simplified view (if this var is TRUE, it also implies that GS is our client) |
|
520 */ |
|
521 TBool iSimplifiedView; |
|
522 |
|
523 /** |
|
524 * if TRUE, the client application does not observe our exit. In this case do not display "Exit" in the menu, since |
|
525 * the client application will not exit when the server exits. |
|
526 */ |
|
527 TBool iFlagNoObserver; |
|
528 }; |
|
529 |
|
530 |
|
531 #endif // C_DEFAULTAPPSRVMIMEVIEW_H |
|
532 |
|
533 // end of file |
|