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 // System includes |
|
20 #include <e32def.h> // STATIC_CAST |
|
21 #include <defaultappserver.rsg> // R_DAS_SERVICESMIMES_LISTBOX |
|
22 #include <StringLoader.h> // StringLoader |
|
23 #include <barsread.h> //TResourceRead |
|
24 #include <eikenv.h> //CEikonEnv |
|
25 #include <apgcli.h> |
|
26 #include <apgicnfl.h> // CApaMaskedBitmap |
|
27 |
|
28 #include <serviceregistry.h> |
|
29 |
|
30 #include "das_servmimeapps.h" |
|
31 #include "das_app.h" // KUidDefaultAppServer |
|
32 #include <services_db.h> |
|
33 |
|
34 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
35 #include <apmstd.h> |
|
36 #else |
|
37 #include <apmstd.h> |
|
38 #include <apmfndr.h> // KDataTypePrioritySystem |
|
39 #endif |
|
40 |
|
41 const TInt KStringMargin = 10; //10 is a sufficiently large margin |
|
42 |
|
43 // ======== MEMBER FUNCTIONS ======== CAppHelper |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // Symbian 2-phased constructor |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 CAppHelper* CAppHelper::NewLC(const TDesC& aName, const TInt aUid) |
|
50 { |
|
51 CAppHelper* self = new (ELeave) CAppHelper(aUid,0); |
|
52 CleanupStack::PushL(self); |
|
53 //construct iName, copy it |
|
54 self->iName = HBufC::NewL(aName.Size()); |
|
55 TPtr* ptr=new (ELeave) TPtr(self->iName->Des()); |
|
56 ptr->Copy(aName); |
|
57 delete ptr; |
|
58 |
|
59 return self; |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // Symbian 2-phased constructor |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 CAppHelper* CAppHelper::NewLC(const CAppHelper& aApp) |
|
67 { |
|
68 CAppHelper* self = new (ELeave) CAppHelper(aApp.iUid,1,aApp.iFlags); |
|
69 CleanupStack::PushL(self); |
|
70 //construct iName, get pointer and flag it |
|
71 self->iName = aApp.iName; |
|
72 self->iFlags |= EFlagNameNotOwned; |
|
73 return self; |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // C++ Constructor |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 CAppHelper::CAppHelper(const TInt aUid, const TInt aScore, const TInt aFlags): |
|
81 iName(NULL), iUid(aUid), iScore(aScore), iFlags(aFlags) |
|
82 { |
|
83 //no implementation needed |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // Destructor |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 CAppHelper::~CAppHelper(void) |
|
91 { |
|
92 if(!( iFlags&EFlagNameNotOwned )) |
|
93 delete iName; |
|
94 iName = NULL; |
|
95 } |
|
96 // --------------------------------------------------------------------------- |
|
97 // This function is used to order Applications |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 TInt CAppHelper::OrderApplications(const CAppHelper& a1, const CAppHelper& a2) |
|
101 { |
|
102 //if a1<a2 return -1, otherwise 0 or 1 |
|
103 //platform applications are always first (smaller) |
|
104 if(a1.iFlags&EFlagPlatformApp && !(a2.iFlags&EFlagPlatformApp)) |
|
105 return -1; //a1 is platform app, a2 is not |
|
106 if(!(a1.iFlags&EFlagPlatformApp) && a2.iFlags&EFlagPlatformApp) |
|
107 return 1; //a1 is not platform app, a2 is |
|
108 |
|
109 //look into names names |
|
110 if(*a1.iName < *a2.iName) return -1; |
|
111 if(*a1.iName > *a2.iName) return 1; |
|
112 //if we are here, strings were equal |
|
113 return 0; |
|
114 } |
|
115 |
|
116 |
|
117 // ======== MEMBER FUNCTIONS ======== CServiceMime |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // C++ Constructor |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 CServiceMime::CServiceMime() : iServiceMime(NULL), iMime(NULL) |
|
124 { |
|
125 iDefaultAppUid=TUid::Uid(0); |
|
126 iDefaultApp=-1;//currently we do not know the default index |
|
127 iUsedByTasks=EFalse; |
|
128 } |
|
129 |
|
130 // --------------------------------------------------------------------------- |
|
131 // Destructor |
|
132 // --------------------------------------------------------------------------- |
|
133 // |
|
134 CServiceMime::~CServiceMime() |
|
135 { |
|
136 if (iServiceMime) delete iServiceMime; |
|
137 if (iMime) delete iMime; |
|
138 for (TInt i=0 ; i<iApplications.Count() ; i++) |
|
139 delete iApplications[i]; |
|
140 iApplications.Close(); |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // This function is used to order Services & MIMEs |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 TInt CServiceMime::OrderServiceMimes(const CServiceMime& a1, const CServiceMime& a2) |
|
148 { |
|
149 //if a1<a2 return -1, otherwise 0 or 1 |
|
150 //we sort by the MIME, then by the service |
|
151 if(*a1.iMime<*a2.iMime)return -1; |
|
152 if(*a1.iMime>*a2.iMime)return 1; |
|
153 //if we are here, MIMEs are the same |
|
154 if(*a1.iServiceMime<*a2.iServiceMime)return -1; |
|
155 if(*a1.iServiceMime>*a2.iServiceMime)return 1; |
|
156 //if we are here, strings were equal |
|
157 return 0; |
|
158 } |
|
159 |
|
160 // ======== MEMBER FUNCTIONS ======== CMediaTask |
|
161 |
|
162 // --------------------------------------------------------------------------- |
|
163 // Symbian 2-phased constructor |
|
164 // --------------------------------------------------------------------------- |
|
165 // |
|
166 CMediaTask* CMediaTask::NewLC( TResourceReader& aReader ) |
|
167 { |
|
168 CMediaTask* self = new (ELeave) CMediaTask(); |
|
169 CleanupStack::PushL(self); |
|
170 self->ConstructL(aReader); |
|
171 return self; |
|
172 } |
|
173 |
|
174 // --------------------------------------------------------------------------- |
|
175 // Destructor |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 CMediaTask::~CMediaTask() |
|
179 { |
|
180 |
|
181 if(iTaskList)delete iTaskList; |
|
182 if(iTaskTitle)delete iTaskTitle; |
|
183 |
|
184 if(iMimeLabel)delete iMimeLabel; |
|
185 |
|
186 iMimes.ResetAndDestroy(); |
|
187 iServicesUids.Close(); |
|
188 |
|
189 iSMs.Close();//elements not owned |
|
190 |
|
191 iApplications.ResetAndDestroy(); |
|
192 } |
|
193 |
|
194 // --------------------------------------------------------------------------- |
|
195 // C++ Constructor |
|
196 // --------------------------------------------------------------------------- |
|
197 // |
|
198 CMediaTask::CMediaTask() : iMimeLabel(NULL), iDefaultApp(-1) |
|
199 { |
|
200 } |
|
201 |
|
202 // --------------------------------------------------------------------------- |
|
203 // The construction means reading the task details from the resource file |
|
204 // --------------------------------------------------------------------------- |
|
205 // |
|
206 void CMediaTask::ConstructL( TResourceReader& aReader ) |
|
207 { |
|
208 TInt i,count; |
|
209 //read the task name |
|
210 iTaskList = aReader.ReadHBufCL(); |
|
211 if( !iTaskList )User::Leave(KErrArgument); |
|
212 |
|
213 //read the task title |
|
214 iTaskTitle = aReader.ReadHBufCL(); |
|
215 if( !iTaskTitle )User::Leave(KErrArgument); |
|
216 |
|
217 //read the mime label |
|
218 iMimeLabel = aReader.ReadHBufC8L(); |
|
219 if( !iMimeLabel )User::Leave(KErrArgument); |
|
220 |
|
221 //read the service mimes entries |
|
222 count = aReader.ReadInt16(); |
|
223 for (i=0; i<count; i++) |
|
224 { |
|
225 //read the service uid |
|
226 TInt uid=aReader.ReadInt32(); |
|
227 if(uid == 0)User::Leave(KErrArgument); |
|
228 //read the mime |
|
229 HBufC8* mime=aReader.ReadHBufC8L(); |
|
230 if( !mime )User::Leave(KErrArgument); |
|
231 //append both things |
|
232 iServicesUids.Append(uid); |
|
233 iMimes.Append(mime);//takes ownership |
|
234 } |
|
235 } |
|
236 |
|
237 |
|
238 // ======== MEMBER FUNCTIONS ======== CDefaultAppServMimeApps |
|
239 |
|
240 // --------------------------------------------------------------------------- |
|
241 // Symbian 2-phased constructor |
|
242 // --------------------------------------------------------------------------- |
|
243 // |
|
244 CDefaultAppServMimeApps* CDefaultAppServMimeApps::NewL(const TUid& aAppUid, TInt aServiceFlags) |
|
245 { |
|
246 CDefaultAppServMimeApps* self = CDefaultAppServMimeApps::NewLC(aAppUid, aServiceFlags); |
|
247 CleanupStack::Pop(self); |
|
248 return self; |
|
249 } |
|
250 |
|
251 // --------------------------------------------------------------------------- |
|
252 // Symbian 2-phased constructor |
|
253 // --------------------------------------------------------------------------- |
|
254 // |
|
255 CDefaultAppServMimeApps* CDefaultAppServMimeApps::NewLC(const TUid& aAppUid, TInt aServiceFlags) |
|
256 { |
|
257 CDefaultAppServMimeApps* self = new (ELeave) CDefaultAppServMimeApps(); |
|
258 CleanupStack::PushL(self); |
|
259 self->ConstructL(aAppUid, aServiceFlags); |
|
260 return self; |
|
261 } |
|
262 |
|
263 // --------------------------------------------------------------------------- |
|
264 // This function builds the data structures for the dialog: |
|
265 // It reads the considered services from the resource files, then it builds the |
|
266 // task list and the associated list of Services& MIMEs and applications. |
|
267 // --------------------------------------------------------------------------- |
|
268 // |
|
269 void CDefaultAppServMimeApps::ConstructL(TUid aAppUid, TInt aServiceFlags) |
|
270 { |
|
271 //set the client app uid |
|
272 /* Uncomment this for testing the General Settings (Control Pannel) specific view from another application (R&D purpose) |
|
273 * |
|
274 TBool flagGsClient = aServiceFlags & EFlagGsClient; |
|
275 if(flagGsClient)aAppUid=KUidGS; //we mimic the GS Client. |
|
276 */ |
|
277 iAppUid = aAppUid; |
|
278 |
|
279 //for all the available services, launch the AddMIMEsForServiceL function |
|
280 TResourceReader reader; |
|
281 CEikonEnv::Static()->CreateResourceReaderLC( reader, R_DA_SERVICE_MIME ); |
|
282 CServicesDB* sdb = CServicesDB::NewLC(&reader); |
|
283 TInt i; |
|
284 TUid uid; |
|
285 for(i=0; i<sdb->Count(); i++) |
|
286 { |
|
287 uid = sdb->ServiceUidL(i); |
|
288 AddMIMEsForServiceL(uid,i,aServiceFlags,sdb); |
|
289 }; |
|
290 CleanupStack::PopAndDestroy(sdb); |
|
291 CleanupStack::PopAndDestroy( ); // reader |
|
292 //change MIMEs & sort |
|
293 BeautifyAndSortServMimeApps(); |
|
294 } |
|
295 |
|
296 // --------------------------------------------------------------------------- |
|
297 // this is by far the most complicated function in the entire subsystem |
|
298 // some more comments are needed, but after this function will be split in 2 |
|
299 // --------------------------------------------------------------------------- |
|
300 // |
|
301 void CDefaultAppServMimeApps::AddMIMEsForServiceL(TUid aServiceUid, TInt aServiceIndex, TInt aServiceFlags, CServicesDB* aServicesDb) |
|
302 { |
|
303 CServiceMime *sm = NULL; |
|
304 TUid uid; |
|
305 |
|
306 RApaLsSession ls; |
|
307 TApaAppInfo info; |
|
308 CApaAppServiceInfoArray* serv=NULL; |
|
309 CServiceRegistry *sr=NULL; |
|
310 TInt i,j,k; |
|
311 TInt it,jt;//indexes for iterating inside tasks |
|
312 TInt lowerMarker, upperMarker; |
|
313 //flags |
|
314 TBool flagShowAll = EFalse; |
|
315 /* |
|
316 * Uncomment the line below to show all the Services & MIMEs in views, and not only those for which default app can be changed. |
|
317 * This can be used for R&D, to see all the MIMEs&Services in the system. |
|
318 flagShowAll = aServiceFlags & EFlagShowAllServicesAndMimes; |
|
319 */ |
|
320 iFlagNoObserver = aServiceFlags & EFlagNoObserver; |
|
321 |
|
322 //check who is connecting, so that we can set the view |
|
323 if(iAppUid == KUidGS) |
|
324 { |
|
325 iSimplifiedView=ETrue; //at least in the beginning. |
|
326 //For this function, this is also a flag that says if we have GS as client or not |
|
327 GetTaskListL(R_DA_TASKS); |
|
328 } |
|
329 else iSimplifiedView=EFalse; |
|
330 |
|
331 //connect |
|
332 User::LeaveIfError( ls.Connect() ); |
|
333 CleanupClosePushL( ls ); |
|
334 |
|
335 //Get all the apps and MIMEs for the current service |
|
336 ls.GetAppInfo(info,iAppUid); |
|
337 serv=ls.GetServiceImplementationsLC(aServiceUid); |
|
338 lowerMarker = upperMarker = iServMimes.Count(); |
|
339 //create entries for the MIMEs supported by the client application |
|
340 for (i=0; i<serv->Array().Count(); i++) |
|
341 { |
|
342 uid=serv->Array()[i].Uid(); |
|
343 if( iSimplifiedView || uid == iAppUid) //this means that for app clients, we first skip all the other applications |
|
344 { |
|
345 //if iSimplifiedView is true, then we have GS as a client |
|
346 for(j=0; j<serv->Array()[i].DataTypes().Count(); j++) |
|
347 { |
|
348 TBool createSM=ETrue; |
|
349 if(iSimplifiedView) |
|
350 { |
|
351 //check if we already have an entry for this service & MIME |
|
352 for(k=lowerMarker; k<upperMarker; k++) |
|
353 if(iServMimes[k]->iMime->Des() == serv->Array()[i].DataTypes()[j].iDataType.Des8()) |
|
354 { |
|
355 //we found it! |
|
356 sm=iServMimes[k]; |
|
357 createSM=EFalse; |
|
358 break;//we found the sm, no need to search for it any more |
|
359 } |
|
360 //if we don't find it, we will create an entry ... |
|
361 } |
|
362 |
|
363 if(createSM) |
|
364 { |
|
365 //we have to create sm, we did not found it previously (or we were not looking for it) |
|
366 sm=new (ELeave) CServiceMime; |
|
367 CleanupStack::PushL(sm); |
|
368 sm->iMime = HBufC8::NewL(serv->Array()[i].DataTypes()[j].iDataType.Des8().Size()); |
|
369 *(sm->iMime) = serv->Array()[i].DataTypes()[j].iDataType.Des8(); |
|
370 //transform the MIME from audio/mpeg to audio mpeg |
|
371 HBufC *transformedMime=HBufC::NewLC(serv->Array()[i].DataTypes()[j].iDataType.Des().Size()); |
|
372 TPtr *ptr=new (ELeave) TPtr(transformedMime->Des()); |
|
373 CleanupStack::PushL(ptr); |
|
374 ptr->Copy(serv->Array()[i].DataTypes()[j].iDataType.Des()); |
|
375 TInt location=ptr->Locate('/'); |
|
376 if(location>0)ptr->Replace(location,1,_L(" ")); |
|
377 //transforming done |
|
378 //sm->iServiceMime = aServicesDb->ServiceStringLC(aServiceIndex, serv->Array()[i].DataTypes()[j].iDataType.Des()); |
|
379 sm->iServiceMime = aServicesDb->ServiceStringLC(aServiceIndex, transformedMime->Des()); |
|
380 CleanupStack::Pop(sm->iServiceMime); |
|
381 CleanupStack::PopAndDestroy(ptr); |
|
382 CleanupStack::PopAndDestroy(transformedMime); |
|
383 //StringLoader::LoadL( R_DA_SERVICE_OPEN, serv->Array()[i].DataTypes()[j].iDataType.Des()); |
|
384 sm->iServiceUid=aServiceUid; |
|
385 } |
|
386 |
|
387 //insert the client application |
|
388 InsertApplicationL(*sm, uid, serv->Array()[i].DataTypes()[j].iPriority, &ls); |
|
389 |
|
390 //get the Uid of the default application for this service and MIME |
|
391 ls.AppForDataType(serv->Array()[i].DataTypes()[j].iDataType,sm->iDefaultAppUid); |
|
392 |
|
393 if(createSM) |
|
394 { |
|
395 //sm was created this iteration, ad it. |
|
396 iServMimes.AppendL(sm);//takes ownership of sm |
|
397 upperMarker++; |
|
398 CleanupStack::Pop(sm); |
|
399 |
|
400 } |
|
401 }//for |
|
402 /* |
|
403 * If a service that has no MIME will be considered, some code must be added (probably in this place) |
|
404 */ |
|
405 }//if ( |
|
406 |
|
407 } |
|
408 __ASSERT_DEBUG(upperMarker == iServMimes.Count(), User::Panic( _L("upperMarker bad value"), 1)); |
|
409 |
|
410 if(sr) |
|
411 { |
|
412 //we do not need it any more |
|
413 delete sr; |
|
414 sr=NULL; |
|
415 } |
|
416 if(lowerMarker == upperMarker) |
|
417 { |
|
418 //current app does not support any MIME for the current service, clean and get out of here |
|
419 CleanupStack::PopAndDestroy(serv); |
|
420 CleanupStack::PopAndDestroy(); // closes RApaLsSession |
|
421 return; |
|
422 } |
|
423 |
|
424 if(!iSimplifiedView) |
|
425 { |
|
426 //if we are here, we have MIMEs for the current service |
|
427 //iterate once more and add applications for MIMEs already in the list |
|
428 for (i=0; i<serv->Array().Count(); i++) |
|
429 { |
|
430 uid=serv->Array()[i].Uid(); |
|
431 if( uid == iAppUid) continue; //we don't add our client application once more in the list (it is already there) |
|
432 for(j=0; j<serv->Array()[i].DataTypes().Count(); j++) |
|
433 for(k=lowerMarker; k<upperMarker; k++) |
|
434 if(iServMimes[k]->iMime->Des() == serv->Array()[i].DataTypes()[j].iDataType.Des8()) |
|
435 { |
|
436 InsertApplicationL(*(iServMimes[k]), serv->Array()[i].Uid(), serv->Array()[i].DataTypes()[j].iPriority, &ls); |
|
437 }//if same MIME |
|
438 } |
|
439 } |
|
440 |
|
441 //before deleting some of the entries ... |
|
442 if(iSimplifiedView) |
|
443 { |
|
444 //check the service & MIMEs against the task list... |
|
445 //first, check the service against task services |
|
446 for(it=0; it<iTasks.Count(); it++) |
|
447 for(jt=0; jt<iTasks[it]->iServicesUids.Count(); jt++) |
|
448 if(aServiceUid.iUid == iTasks[it]->iServicesUids[jt]) |
|
449 { |
|
450 //lets check if the MIME matches too... |
|
451 for(k=lowerMarker; k<upperMarker; k++) |
|
452 if(*iServMimes[k]->iMime == *iTasks[it]->iMimes[jt]) |
|
453 { |
|
454 //this entry matches an entry in the task list |
|
455 //add the applications to the list |
|
456 PopulateTaskWithApplicationsL(*iTasks[it],iServMimes[k]); |
|
457 //link the sm, if it has more than 1 application |
|
458 break;//sm found, no need to search for it further |
|
459 } |
|
460 } |
|
461 } |
|
462 |
|
463 |
|
464 |
|
465 //iterate from the newly added entries and set the index |
|
466 for(k=lowerMarker; k<upperMarker; k++) |
|
467 { |
|
468 TBool smSetOrRemoved = EFalse; |
|
469 //check for single applications |
|
470 if( iServMimes[k]->iApplications.Count() <2 && !flagShowAll) |
|
471 { |
|
472 //this entry has a single element (that should not be shown) |
|
473 //we either delete it, or move it |
|
474 if(iServMimes[k]->iUsedByTasks) |
|
475 { |
|
476 //the sm is used by tasks, we move it |
|
477 iTaskServMimes.AppendL(iServMimes[k]);//takes ownership of sm |
|
478 } |
|
479 else |
|
480 { |
|
481 //the sm is not used by tasks, we delete it. |
|
482 delete iServMimes[k]; |
|
483 } |
|
484 |
|
485 //we remove the entry from the iServMimes (so that it is not shown) |
|
486 iServMimes.Remove(k); |
|
487 k--; |
|
488 upperMarker--; |
|
489 smSetOrRemoved=ETrue; |
|
490 } |
|
491 |
|
492 //set the index |
|
493 if(!smSetOrRemoved) |
|
494 { |
|
495 for(i=0 ; i< iServMimes[k]->iApplications.Count() ; i++) |
|
496 { |
|
497 if(iServMimes[k]->iApplications[i]->iUid == iServMimes[k]->iDefaultAppUid.iUid) |
|
498 iServMimes[k]->iDefaultApp=i; |
|
499 } |
|
500 } |
|
501 }; |
|
502 |
|
503 if(iSimplifiedView) |
|
504 for(it=0; it<iTasks.Count(); it++) |
|
505 if(iTasks[it]->iDefaultAppUid.iUid == 0 && iTasks[it]->iApplications.Count()>0) |
|
506 { |
|
507 //there is no uid, look for the platform App and make it the default |
|
508 for(jt=0; jt<iTasks[it]->iApplications.Count(); jt++) |
|
509 if(iTasks[it]->iApplications[jt]->iFlags & CAppHelper::EFlagPlatformApp) |
|
510 { |
|
511 iTasks[it]->iDefaultAppUid.iUid = iTasks[it]->iApplications[jt]->iUid; |
|
512 iTasks[it]->iDefaultApp=jt; |
|
513 break;//app found, no need to search for it any longer |
|
514 }; |
|
515 |
|
516 //if no app found, mark the first one as default |
|
517 if(iTasks[it]->iDefaultAppUid.iUid == 0) |
|
518 { |
|
519 iTasks[it]->iDefaultAppUid.iUid = iTasks[it]->iApplications[0]->iUid; |
|
520 iTasks[it]->iDefaultApp = 0;//the index |
|
521 }; |
|
522 } |
|
523 else |
|
524 for(jt=0; jt<iTasks[it]->iApplications.Count(); jt++) |
|
525 if(iTasks[it]->iApplications[jt]->iUid == iTasks[it]->iDefaultAppUid.iUid) |
|
526 { |
|
527 iTasks[it]->iDefaultApp=jt; |
|
528 break;//app found, no need to search for it any longer |
|
529 } |
|
530 |
|
531 //done, destroy serv |
|
532 CleanupStack::PopAndDestroy(serv); |
|
533 CleanupStack::PopAndDestroy( ); // closes RApaLsSession |
|
534 } |
|
535 |
|
536 // --------------------------------------------------------------------------- |
|
537 // C++ Constructor |
|
538 // --------------------------------------------------------------------------- |
|
539 // |
|
540 CDefaultAppServMimeApps::CDefaultAppServMimeApps(): iList(4) |
|
541 { |
|
542 } |
|
543 |
|
544 // --------------------------------------------------------------------------- |
|
545 // Destructor |
|
546 // --------------------------------------------------------------------------- |
|
547 // |
|
548 CDefaultAppServMimeApps::~CDefaultAppServMimeApps() |
|
549 { |
|
550 iServMimes.ResetAndDestroy(); |
|
551 iTasks.ResetAndDestroy(); |
|
552 iTaskServMimes.ResetAndDestroy(); |
|
553 } |
|
554 |
|
555 // --------------------------------------------------------------------------- |
|
556 // This function sorts the Services & MIMEs and their applications. |
|
557 // It also sorts the Serivces & MIMEs associated with tasks |
|
558 // --------------------------------------------------------------------------- |
|
559 // |
|
560 void CDefaultAppServMimeApps::BeautifyAndSortServMimeApps(void) |
|
561 { |
|
562 //first, go through the Services & MIMEs localized names and sort them |
|
563 TLinearOrder<CServiceMime> order(&CServiceMime::OrderServiceMimes); |
|
564 iServMimes.Sort(order); |
|
565 |
|
566 //go through applications and sort them |
|
567 TInt i,j; |
|
568 for(i=0; i<iServMimes.Count(); i++) |
|
569 { |
|
570 TLinearOrder<CAppHelper> order2(&CAppHelper::OrderApplications); |
|
571 iServMimes[i]->iApplications.Sort(order2); |
|
572 //get our app index |
|
573 for(j=0; j<iServMimes[i]->iApplications.Count(); j++) |
|
574 if(iServMimes[i]->iApplications[j]->iUid == iServMimes[i]->iDefaultAppUid.iUid) |
|
575 iServMimes[i]->iDefaultApp = j; |
|
576 }; |
|
577 //if we have tasks, we sort their apps too |
|
578 for(i=0; i<iTasks.Count(); i++) |
|
579 { |
|
580 TLinearOrder<CAppHelper> order2(&CAppHelper::OrderApplications); |
|
581 iTasks[i]->iApplications.Sort(order2); |
|
582 //get our app index |
|
583 for(j=0; j<iTasks[i]->iApplications.Count(); j++) |
|
584 if(iTasks[i]->iApplications[j]->iUid == iTasks[i]->iDefaultAppUid.iUid) |
|
585 iTasks[i]->iDefaultApp = j; |
|
586 }; |
|
587 } |
|
588 |
|
589 |
|
590 // --------------------------------------------------------------------------- |
|
591 // This function reads from the resource file the list of tasks (and associated data). |
|
592 // This function is used during construction |
|
593 // --------------------------------------------------------------------------- |
|
594 // |
|
595 void CDefaultAppServMimeApps::GetTaskListL( TInt aResourceId ) |
|
596 { |
|
597 TResourceReader reader; |
|
598 TInt i; |
|
599 CServiceRegistry* sr=CServiceRegistry::NewL(); |
|
600 CleanupStack::PushL(sr); |
|
601 |
|
602 // Read tasks |
|
603 |
|
604 CEikonEnv::Static()->CreateResourceReaderLC( reader, aResourceId ); |
|
605 |
|
606 TInt count = reader.ReadInt16(); |
|
607 for ( i = 0; i < count; i++ ) |
|
608 { |
|
609 CMediaTask* task=CMediaTask::NewLC(reader); |
|
610 // Read the default application for this task ... |
|
611 sr->GetDefault(KOpenServiceUid, *task->iMimeLabel, task->iDefaultAppUid); |
|
612 |
|
613 //add the task to the list |
|
614 iTasks.Append(task); |
|
615 CleanupStack::Pop(task); |
|
616 } |
|
617 |
|
618 CleanupStack::PopAndDestroy(); // reader |
|
619 CleanupStack::PopAndDestroy(sr); |
|
620 } |
|
621 |
|
622 // --------------------------------------------------------------------------- |
|
623 // This function adds a new Application to a list of an Service & Mime object. |
|
624 // --------------------------------------------------------------------------- |
|
625 // |
|
626 void CDefaultAppServMimeApps::InsertApplicationL(CServiceMime& aServMime, const TUid& aAppUid, const TDataTypePriority& aPrio, const RApaLsSession *aLs) |
|
627 { |
|
628 TBool addIt = ETrue; |
|
629 |
|
630 if(aPrio == KDataTypePrioritySystem) |
|
631 { |
|
632 // the application to be inserted has system priority |
|
633 if(aServMime.iDefaultApp == -1) |
|
634 { |
|
635 //we have non-system applications in the list |
|
636 //delete them ... |
|
637 aServMime.iApplications.ResetAndDestroy(); |
|
638 |
|
639 //... and make the default -2 ... (it means single app with system priority) |
|
640 aServMime.iDefaultApp = -2; |
|
641 //... and add our application (after exiting from the "if") |
|
642 } |
|
643 else |
|
644 { |
|
645 //do not delete the applications, but just add our application |
|
646 //...and make the default -3 (it means multiple apps with system priority) |
|
647 aServMime.iDefaultApp = -3; |
|
648 //... and add our application (after exiting from the "if") |
|
649 } |
|
650 } |
|
651 else |
|
652 { |
|
653 // the application to be inserted does NOT have system priority |
|
654 if(aServMime.iDefaultApp < -1) |
|
655 { |
|
656 // there are only System apps in the list, do not add ours |
|
657 addIt = EFalse; |
|
658 } |
|
659 // else there are normal applications in the list, insert ours, as well |
|
660 } |
|
661 //add the application to the list |
|
662 if(addIt) |
|
663 { |
|
664 TApaAppInfo info; |
|
665 aLs->GetAppInfo(info,aAppUid); |
|
666 //find the best name for the application |
|
667 CAppHelper *app = NULL; |
|
668 if(info.iCaption.Size() != 0) |
|
669 { |
|
670 //this is for now, the preferred name |
|
671 app = CAppHelper::NewLC(info.iCaption, aAppUid.iUid); |
|
672 } |
|
673 else |
|
674 { |
|
675 //fall-back name |
|
676 app = CAppHelper::NewLC(info.iShortCaption, aAppUid.iUid); |
|
677 }; |
|
678 //is the app platform application?? |
|
679 if (info.iFullName.Left(1) == _L("Z") || |
|
680 info.iFullName.Left(1) == _L("z")) |
|
681 app->iFlags |= CAppHelper::EFlagPlatformApp; |
|
682 //append the name |
|
683 aServMime.iApplications.AppendL(app); |
|
684 CleanupStack::Pop(app); |
|
685 } |
|
686 } |
|
687 |
|
688 // --------------------------------------------------------------------------- |
|
689 // This function takes a task and a Service & MIME object. It checks all the applications that support the given |
|
690 // Service & MIME object (from its list). If an application is not in the task's application list, this function adds |
|
691 // it there, with a score of 1. If the application is already in the list, then its score is incremented. |
|
692 // The Service & MIME object is also marked as being used by a task. |
|
693 // --------------------------------------------------------------------------- |
|
694 // |
|
695 void CDefaultAppServMimeApps::PopulateTaskWithApplicationsL(CMediaTask& aTask,CServiceMime* aServMime) |
|
696 { |
|
697 TInt i,j; |
|
698 TBool found; |
|
699 //add the applications to the list |
|
700 for(i=0; i<aServMime->iApplications.Count(); i++) |
|
701 { |
|
702 found=EFalse; |
|
703 for(j=0; j<aTask.iApplications.Count(); j++) |
|
704 if(aServMime->iApplications[i]->iUid == aTask.iApplications[j]->iUid) |
|
705 { |
|
706 //we found this application... |
|
707 found=ETrue; |
|
708 //... increase its score |
|
709 aTask.iApplications[j]->iScore++; |
|
710 //... and get to the next application |
|
711 break; //application found, no need to search for it any more |
|
712 } |
|
713 //if the application was not found, we have to add it! |
|
714 if(!found) |
|
715 { |
|
716 CAppHelper *app = CAppHelper::NewLC(*aServMime->iApplications[i]); |
|
717 aTask.iApplications.AppendL(app); |
|
718 CleanupStack::Pop(app); |
|
719 } |
|
720 } |
|
721 //mark the sm |
|
722 aServMime->iUsedByTasks=ETrue; |
|
723 //link the sm |
|
724 aTask.iSMs.Append(aServMime); |
|
725 } |
|
726 |
|
727 // --------------------------------------------------------------------------- |
|
728 // This function fills with entries a data structure used by a List Box to display Services & MIMEs or Tasks |
|
729 // --------------------------------------------------------------------------- |
|
730 // |
|
731 void CDefaultAppServMimeApps::GetServicesAndMimesListL(CDesCArray& aServicesAndMimesArray) |
|
732 { |
|
733 TInt i; |
|
734 aServicesAndMimesArray.Reset(); |
|
735 if(iSimplifiedView) |
|
736 { |
|
737 for ( i=0 ; i<iTasks.Count() ; i++ ) |
|
738 { |
|
739 TDesC* string = GetMediaTaskStringLC(*iTasks[i], ETrue); |
|
740 aServicesAndMimesArray.AppendL (*string); |
|
741 CleanupStack::PopAndDestroy(string); |
|
742 } |
|
743 } |
|
744 else |
|
745 { |
|
746 for ( i=0 ; i<iServMimes.Count() ; i++ ) |
|
747 { |
|
748 TDesC* string = GetServiceAndMimeStringLC(*iServMimes[i], ETrue); |
|
749 aServicesAndMimesArray.AppendL (*string); |
|
750 CleanupStack::PopAndDestroy(string); |
|
751 } |
|
752 } |
|
753 |
|
754 } |
|
755 |
|
756 // --------------------------------------------------------------------------- |
|
757 // This function fills a Popup-list data structure with applications specific to the selected Service & MIME or Task |
|
758 // --------------------------------------------------------------------------- |
|
759 // |
|
760 void CDefaultAppServMimeApps::GetApplicationsListL(TInt aIndex, CDesCArray& aApplicationsArray, HBufC*& aTitle) |
|
761 { |
|
762 // Strings will be of the format "1\tApplication" |
|
763 _LIT (KStringAppsDefault, "1\t"); |
|
764 _LIT (KStringAppsNonDefault, "0\t"); |
|
765 |
|
766 TInt bufLen=20; |
|
767 HBufC *string=HBufC::NewLC(bufLen); |
|
768 HBufC *newString=NULL; |
|
769 TInt i,len; |
|
770 RPointerArray<CAppHelper> *apps=NULL; |
|
771 |
|
772 //get the proper list |
|
773 if(iSimplifiedView) |
|
774 apps = &(iTasks[aIndex]->iApplications); |
|
775 else |
|
776 apps = &(iServMimes[aIndex]->iApplications); |
|
777 |
|
778 for ( i=0 ; i<apps->Count() ; i++ ) |
|
779 { |
|
780 len=(*apps)[i]->iName->Size() + KStringMargin ; |
|
781 if(len>bufLen) |
|
782 { |
|
783 newString=string->ReAllocL(len); |
|
784 if(newString != string) |
|
785 { |
|
786 CleanupStack::Pop(string);//already destroyed |
|
787 string=newString; |
|
788 CleanupStack::PushL(string); |
|
789 } |
|
790 bufLen=len; |
|
791 newString=NULL; |
|
792 } |
|
793 //copy the application into the string buffer |
|
794 TPtr ptr=string->Des(); |
|
795 TBool isDefault=EFalse; |
|
796 |
|
797 if( iSimplifiedView && iTasks[aIndex]->iDefaultApp==i) isDefault=ETrue; |
|
798 if( !iSimplifiedView && iServMimes[aIndex]->iDefaultApp==i) isDefault=ETrue; |
|
799 |
|
800 if( isDefault ) ptr.Copy(KStringAppsDefault); |
|
801 else ptr.Copy(KStringAppsNonDefault); |
|
802 ptr.Append(*(*apps)[i]->iName); |
|
803 |
|
804 aApplicationsArray.AppendL (ptr); |
|
805 } |
|
806 |
|
807 CleanupStack::PopAndDestroy(string); //data in ptr is out of scope |
|
808 |
|
809 //get the title now |
|
810 if ( iSimplifiedView ) |
|
811 aTitle = GetMediaTaskStringLC(*iTasks[aIndex], EFalse); |
|
812 else |
|
813 aTitle = GetServiceAndMimeStringLC(*iServMimes[aIndex], EFalse); |
|
814 CleanupStack::Pop(aTitle); |
|
815 } |
|
816 |
|
817 // --------------------------------------------------------------------------- |
|
818 // This function sets a new default, for a Service & MIME pair or for a Task. |
|
819 // The function also updates the list of Services & MIMEs (or Tasks), to display the new default application |
|
820 // --------------------------------------------------------------------------- |
|
821 // |
|
822 void CDefaultAppServMimeApps::UpdateDefaultL(TInt aServiceAndMimeIndex, TInt aDefaultAppIndex, CDesCArray *aServicesAndMimesArray) |
|
823 { |
|
824 //check for correct parameters |
|
825 if (aServiceAndMimeIndex <0 || aDefaultAppIndex <0) User::Leave(KErrArgument); |
|
826 if(iSimplifiedView) |
|
827 { |
|
828 if( aServiceAndMimeIndex >= iTasks.Count() || |
|
829 aDefaultAppIndex >= iTasks[aServiceAndMimeIndex]->iApplications.Count()) |
|
830 User::Leave(KErrArgument); |
|
831 } |
|
832 else |
|
833 { |
|
834 if( aServiceAndMimeIndex >= iServMimes.Count() || |
|
835 aDefaultAppIndex >= iServMimes[aServiceAndMimeIndex]->iApplications.Count()) |
|
836 User::Leave(KErrArgument); |
|
837 } |
|
838 |
|
839 //if we are here, parameters are within their range |
|
840 TBool doUpdate=ETrue; |
|
841 TUid defaultAppUid; |
|
842 CServiceRegistry *sr=CServiceRegistry::NewL(); |
|
843 CleanupStack::PushL(sr); |
|
844 |
|
845 //update the default in the Service Registry |
|
846 if(iSimplifiedView) |
|
847 { |
|
848 TInt i,j; |
|
849 TUid serviceUid; |
|
850 //set the default for the generic MIME (and our server application) |
|
851 TDataType dt(*iTasks[aServiceAndMimeIndex]->iMimeLabel); |
|
852 defaultAppUid=TUid::Uid(iTasks[aServiceAndMimeIndex]->iApplications[aDefaultAppIndex]->iUid); |
|
853 if(sr->SetDefault(KOpenServiceUid, dt,defaultAppUid)) |
|
854 { |
|
855 //if we are here, SetDefault returned an error. |
|
856 //so we do not update the default... |
|
857 doUpdate=EFalse; |
|
858 } |
|
859 //set the selected default for all the Services & MIME that it supports |
|
860 if(doUpdate) |
|
861 { |
|
862 for(i=0; i<iTasks[aServiceAndMimeIndex]->iSMs.Count(); i++) |
|
863 for(j=0; j<iTasks[aServiceAndMimeIndex]->iSMs[i]->iApplications.Count(); j++) |
|
864 if(defaultAppUid.iUid == iTasks[aServiceAndMimeIndex]->iSMs[i]->iApplications[j]->iUid ) |
|
865 { |
|
866 //the selected application supports this Service & MIME pair. |
|
867 //make the app default for the pair. |
|
868 dt=*iTasks[aServiceAndMimeIndex]->iSMs[i]->iMime; |
|
869 serviceUid=iTasks[aServiceAndMimeIndex]->iSMs[i]->iServiceUid; |
|
870 sr->SetDefault(serviceUid, dt,defaultAppUid); |
|
871 //update the sm so that it reflects the new default |
|
872 iTasks[aServiceAndMimeIndex]->iSMs[i]->iDefaultAppUid=defaultAppUid; |
|
873 iTasks[aServiceAndMimeIndex]->iSMs[i]->iDefaultApp=j; |
|
874 break; //application found in sm's list, do not need to search for it any more |
|
875 } |
|
876 //update the default entries |
|
877 iTasks[aServiceAndMimeIndex]->iDefaultApp=aDefaultAppIndex; |
|
878 iTasks[aServiceAndMimeIndex]->iDefaultAppUid=defaultAppUid; |
|
879 } |
|
880 |
|
881 } |
|
882 else |
|
883 { |
|
884 TDataType dt(*iServMimes[aServiceAndMimeIndex]->iMime); |
|
885 defaultAppUid=TUid::Uid(iServMimes[aServiceAndMimeIndex]->iApplications[aDefaultAppIndex]->iUid); |
|
886 if(sr->SetDefault(iServMimes[aServiceAndMimeIndex]->iServiceUid, dt,defaultAppUid)) |
|
887 { |
|
888 //if we are here, SetDefault returned an error. |
|
889 //so we do not update the default... |
|
890 doUpdate=EFalse; |
|
891 } |
|
892 //update the default entries |
|
893 if(doUpdate) |
|
894 { |
|
895 iServMimes[aServiceAndMimeIndex]->iDefaultApp=aDefaultAppIndex; |
|
896 iServMimes[aServiceAndMimeIndex]->iDefaultAppUid=defaultAppUid; |
|
897 } |
|
898 } |
|
899 CleanupStack::PopAndDestroy(sr); |
|
900 |
|
901 //check if setting the default failed |
|
902 if(!doUpdate) |
|
903 { |
|
904 //### if updating the default failed, here would be the place to put an error note to the user |
|
905 return; // or leave |
|
906 }; |
|
907 |
|
908 //update the item in the list |
|
909 if (aServicesAndMimesArray) |
|
910 { |
|
911 //get the string |
|
912 TDesC* string; |
|
913 if(iSimplifiedView) |
|
914 string = GetMediaTaskStringLC(*iTasks[aServiceAndMimeIndex], ETrue); |
|
915 else |
|
916 string = GetServiceAndMimeStringLC(*iServMimes[aServiceAndMimeIndex], ETrue); |
|
917 aServicesAndMimesArray->Delete(aServiceAndMimeIndex); |
|
918 aServicesAndMimesArray->InsertL(aServiceAndMimeIndex,*string); |
|
919 CleanupStack::PopAndDestroy(string); |
|
920 } |
|
921 } |
|
922 |
|
923 // --------------------------------------------------------------------------- |
|
924 // This function creates a string that will become en element of a list box. To create the string, the function |
|
925 // concatenates several sub-strings. |
|
926 // --------------------------------------------------------------------------- |
|
927 // |
|
928 HBufC* CDefaultAppServMimeApps::GetServiceAndMimeStringLC(CServiceMime& aServMime, TBool aInsertDefaultApp) const |
|
929 { |
|
930 HBufC *string=NULL; |
|
931 TPtr *ptr=NULL; |
|
932 TInt len; |
|
933 _LIT(KTab,"\t"); |
|
934 |
|
935 if(aInsertDefaultApp && aServMime.iDefaultApp >= 0) //it may be that we do not have a default ... |
|
936 len=aServMime.iApplications[aServMime.iDefaultApp]->iName->Size(); |
|
937 else |
|
938 len=0; |
|
939 len+= aServMime.iServiceMime->Size(); |
|
940 len+= KStringMargin ; |
|
941 |
|
942 string=HBufC::NewLC(len); |
|
943 |
|
944 //build the string, add the tabs before and after |
|
945 ptr=new (ELeave) TPtr(string->Des()); |
|
946 CleanupStack::PushL(ptr); |
|
947 |
|
948 ptr->Copy(*aServMime.iServiceMime); |
|
949 |
|
950 if(aInsertDefaultApp) |
|
951 { |
|
952 ptr->Insert(0,KTab); |
|
953 ptr->Append(KTab); |
|
954 |
|
955 //add default app |
|
956 if(aServMime.iDefaultApp >= 0) //it may be that we do not have a default ... |
|
957 ptr->Append(*aServMime.iApplications[aServMime.iDefaultApp]->iName); |
|
958 } |
|
959 |
|
960 CleanupStack::PopAndDestroy(ptr); |
|
961 |
|
962 return string; //pass ownership, string also on the stack |
|
963 |
|
964 } |
|
965 |
|
966 // --------------------------------------------------------------------------- |
|
967 // This function creates a string that will become en element of a list box. To create the string, the function |
|
968 // concatenates several sub-strings. |
|
969 // --------------------------------------------------------------------------- |
|
970 // |
|
971 HBufC* CDefaultAppServMimeApps::GetMediaTaskStringLC(CMediaTask& aMediaTask, TBool aInsertDefaultApp) const |
|
972 { |
|
973 TPtr *ptr=NULL; |
|
974 TInt len = KStringMargin; |
|
975 _LIT(KTab,"\t"); |
|
976 HBufC *taskName=NULL; //not owned, not deleted at the end of function |
|
977 |
|
978 //compute the string length |
|
979 if(aInsertDefaultApp) |
|
980 { |
|
981 //we insert the task list name |
|
982 taskName = aMediaTask.iTaskList; |
|
983 //we also insert the length od the default app (if we have it) |
|
984 if(aMediaTask.iDefaultApp >= 0)//it may be that we do not have a default ... |
|
985 len += aMediaTask.iApplications[aMediaTask.iDefaultApp]->iName->Size(); |
|
986 } |
|
987 else |
|
988 { |
|
989 //we should insert the task title, if we have it |
|
990 taskName = aMediaTask.iTaskTitle; |
|
991 //taskName = aMediaTask.iTaskList; |
|
992 }; |
|
993 len += taskName->Size(); |
|
994 |
|
995 //allocate the string |
|
996 HBufC *string=HBufC::NewLC(len); |
|
997 |
|
998 //add the title |
|
999 ptr=new (ELeave) TPtr(string->Des()); |
|
1000 CleanupStack::PushL(ptr); |
|
1001 ptr->Copy(*taskName); |
|
1002 |
|
1003 //add other stuff |
|
1004 if(aInsertDefaultApp) |
|
1005 { |
|
1006 ptr->Insert(0,KTab); |
|
1007 ptr->Append(KTab); |
|
1008 //add default app |
|
1009 if(aMediaTask.iDefaultApp >= 0) //it may be that we do not have a default ... |
|
1010 ptr->Append(*aMediaTask.iApplications[aMediaTask.iDefaultApp]->iName); |
|
1011 } |
|
1012 |
|
1013 CleanupStack::PopAndDestroy(ptr); |
|
1014 |
|
1015 return string; //pass ownership, string also on the stack |
|
1016 } |
|
1017 |
|
1018 // --------------------------------------------------------------------------- |
|
1019 // This function resets (removes) the defaults associated with a certain task, |
|
1020 // or it can remove all the defaults |
|
1021 // --------------------------------------------------------------------------- |
|
1022 // |
|
1023 TInt CDefaultAppServMimeApps::RestoreFactorySettingsL(TInt aCathegory) |
|
1024 { |
|
1025 TInt i, j; |
|
1026 CServiceRegistry *sr=NULL; |
|
1027 |
|
1028 if(aCathegory == -1) |
|
1029 { |
|
1030 sr=CServiceRegistry::NewL(); |
|
1031 |
|
1032 if ( iSimplifiedView ) |
|
1033 { |
|
1034 for(i=0; i<iTasks.Count(); i++) |
|
1035 { |
|
1036 for(j=0; j<iTasks[i]->iMimes.Count(); j++) |
|
1037 { |
|
1038 sr->RemoveEntry(TUid::Uid(iTasks[i]->iServicesUids[j]), TDataType(*iTasks[i]->iMimes[j])); |
|
1039 } |
|
1040 //remove the entry that identifies the default app for the task |
|
1041 sr->RemoveEntry(KOpenServiceUid, TDataType(*iTasks[i]->iMimeLabel)); |
|
1042 } |
|
1043 } |
|
1044 else |
|
1045 { |
|
1046 //we reset the defaults for all the services & MIME |
|
1047 for(i=0; i<iServMimes.Count(); i++) |
|
1048 sr->RemoveEntry(iServMimes[i]->iServiceUid, TDataType(*iServMimes[i]->iMime)); |
|
1049 //remove the entry that identifies the default app for the task |
|
1050 for(i=0; i<iTasks.Count(); i++) |
|
1051 sr->RemoveEntry(KOpenServiceUid, TDataType(*iTasks[i]->iMimeLabel)); |
|
1052 } |
|
1053 } |
|
1054 else if(iSimplifiedView && aCathegory >= 0 && aCathegory < iTasks.Count()) |
|
1055 { |
|
1056 //we are in simplified view, restore defaults for a single task |
|
1057 sr=CServiceRegistry::NewL(); |
|
1058 for(i=0; i<iTasks[aCathegory]->iMimes.Count(); i++) |
|
1059 sr->RemoveEntry(TUid::Uid(iTasks[aCathegory]->iServicesUids[i]), TDataType(*iTasks[aCathegory]->iMimes[i])); |
|
1060 //remove the entry that identifies the default app for the task |
|
1061 sr->RemoveEntry(KOpenServiceUid, TDataType(*iTasks[aCathegory]->iMimeLabel)); |
|
1062 } |
|
1063 else if(!iSimplifiedView && aCathegory >= 0 && aCathegory < iServMimes.Count()) |
|
1064 { |
|
1065 //we are in the advanced view, restore defaults for a single Service & MIME pair |
|
1066 sr=CServiceRegistry::NewL(); |
|
1067 sr->RemoveEntry(iServMimes[aCathegory]->iServiceUid, TDataType(*iServMimes[aCathegory]->iMime)); |
|
1068 } |
|
1069 else return -1; //wrong aCathegory range |
|
1070 |
|
1071 if(sr) delete sr; |
|
1072 return 0; |
|
1073 } |
|