12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
|
17 |
17 #include <mcsmenuutils.h> |
18 #include <mcsmenuutils.h> |
18 #include <AknIconUtils.h> |
|
19 #include <avkon.mbg> |
|
20 #include <javaregistry.h> |
19 #include <javaregistry.h> |
21 #include <javaregistryentry.h> |
20 #include <javaregistryentry.h> |
22 #include <drmrightsinfo.h> |
21 #include <drmrightsinfo.h> |
23 #include <e32property.h> |
|
24 #include <satdomainpskeys.h> |
|
25 #include <AknTaskList.h> |
|
26 #include <mmf/common/mmfcontrollerpluginresolver.h> |
|
27 #include <widgetregistryclient.h> |
|
28 |
22 |
29 #include "menusrvengutils.h" |
23 #include "menusrvengutils.h" |
30 |
|
31 #include "mcsdef.h" |
24 #include "mcsdef.h" |
32 #include "mcsmenu.h" |
|
33 #include "mcsmenuitem.h" |
|
34 #include "mcsmenufilter.h" |
|
35 #include "mcssathandler.h" |
25 #include "mcssathandler.h" |
36 #include "menusrvappscanner.h" |
|
37 |
|
38 _LIT( KMidletPostfix, ".fakeapp" ); |
|
39 |
|
40 // ================= LOCAL FUNCTIONS ======================== |
|
41 |
|
42 // --------------------------------------------------------- |
|
43 // GetAppUid |
|
44 // --------------------------------------------------------- |
|
45 // |
|
46 TInt CMenuSrvEngUtils::GetAppUid( const CMenuEngObject& aEngObj, TUid& aAppUid ) |
|
47 { |
|
48 TInt err( 0 ); |
|
49 TPtrC attrVal; |
|
50 TBool attrExists( EFalse ); |
|
51 TBool localized( EFalse );// |
|
52 attrExists = aEngObj.FindAttribute(KMenuAttrUid, attrVal, localized); |
|
53 if ( !attrExists ) |
|
54 { |
|
55 err = KErrNotFound; |
|
56 } |
|
57 else |
|
58 { |
|
59 TUint appUid; |
|
60 err = MenuUtils::GetTUint( attrVal, appUid ); |
|
61 if ( !err ) |
|
62 { |
|
63 aAppUid = TUid::Uid( appUid ); |
|
64 } |
|
65 } |
|
66 return err; |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------- |
|
70 // GetApaAppInfo |
|
71 // --------------------------------------------------------- |
|
72 // |
|
73 TInt CMenuSrvEngUtils::GetApaAppInfo( |
|
74 const CMenuEngObject& aEngObj, |
|
75 TApaAppInfo& aInfo ) const |
|
76 { |
|
77 TUid uid; |
|
78 TInt err; |
|
79 err = CMenuSrvEngUtils::GetAppUid( aEngObj, uid ); |
|
80 if ( err == KErrNone ) |
|
81 { |
|
82 err = GetApaAppInfo( uid, aInfo ); |
|
83 } |
|
84 |
|
85 return err; |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------- |
|
89 // GetApaAppInfo |
|
90 // --------------------------------------------------------- |
|
91 // |
|
92 TInt CMenuSrvEngUtils::GetApaAppInfo( |
|
93 TUid aUid, |
|
94 TApaAppInfo& aInfo ) const |
|
95 { |
|
96 return iApaLsSession.GetAppInfo( aInfo, aUid ); |
|
97 } |
|
98 // --------------------------------------------------------- |
|
99 // CMenuSrvEngUtils::GetJavaContentIdL |
|
100 // --------------------------------------------------------- |
|
101 // |
|
102 void CMenuSrvEngUtils::GetJavaContentIdL( TUid aUid, TDes& aContentId ) |
|
103 { |
|
104 Java::CJavaRegistry* javaRegistry; |
|
105 Java::CJavaRegistryEntry* regEntry = NULL; |
|
106 |
|
107 javaRegistry = Java::CJavaRegistry::NewL(); |
|
108 CleanupStack::PushL( javaRegistry ); |
|
109 |
|
110 //regEntry will be NULL if there is no Java application |
|
111 //corresponding to the specified aUid |
|
112 regEntry = javaRegistry->RegistryEntryL( aUid ); |
|
113 |
|
114 //DrmContentId() will return reference to NULL when |
|
115 //Java application is not DRM protected |
|
116 if( regEntry && ( ®Entry->DrmContentId() ) ) |
|
117 { |
|
118 aContentId.Copy( regEntry->DrmContentId() ); |
|
119 } |
|
120 else |
|
121 { |
|
122 aContentId.Copy( KNullDesC ); |
|
123 } |
|
124 |
|
125 delete regEntry; |
|
126 CleanupStack::PopAndDestroy( javaRegistry ); |
|
127 } |
|
128 |
|
129 |
26 |
130 // ================= MEMBER FUNCTIONS ======================= |
27 // ================= MEMBER FUNCTIONS ======================= |
131 |
28 |
132 // --------------------------------------------------------- |
29 // --------------------------------------------------------- |
133 // CMenuSrvEngUtils::~CMenuSrvEngUtils |
30 // CMenuSrvEngUtils::~CMenuSrvEngUtils |
189 { |
87 { |
190 err = GetSatAppInfo( aAppInfo ); |
88 err = GetSatAppInfo( aAppInfo ); |
191 } |
89 } |
192 else |
90 else |
193 { |
91 { |
194 err = iApaLsSession.GetAppInfo( aAppInfo, appUid ); |
92 aAppInfo.iUid = appUid; |
195 } |
93 err = GetAppInfoFromArrayL( aAppInfo ); |
196 } |
94 if( err ) |
197 return err; |
95 { |
198 } |
96 err = iApaLsSession.GetAppInfo( aAppInfo, appUid ); |
199 |
97 } |
200 // --------------------------------------------------------- |
98 } |
201 // CMenuSrvEngUtils::GetAppInfo |
99 } |
202 // --------------------------------------------------------- |
100 return err; |
203 // |
|
204 TInt CMenuSrvEngUtils::GetAppInfoL( TInt aItemId, TApaAppInfo& aAppInfo ) const |
|
205 { |
|
206 TInt err( 0 ); |
|
207 const CMenuEngObject& obj = iEng.ObjectL( aItemId ); |
|
208 err = GetAppInfo( obj, aAppInfo ); |
|
209 return err; |
|
210 } |
|
211 |
|
212 |
|
213 // --------------------------------------------------------- |
|
214 // CMenuSrvEngUtils::GetFolderIcon |
|
215 // Knowing that in case of folders there is no way to query |
|
216 // folder's icon file from APPARC, the responsibility of handling this is |
|
217 // transferred to the caller of this method, so that he may show some default or |
|
218 // display error etc. |
|
219 // --------------------------------------------------------- |
|
220 // |
|
221 TInt CMenuSrvEngUtils::GetFolderIcon( const CMenuEngObject& /*aEngObj*/, |
|
222 HBufC*& aFullFileName, |
|
223 TInt& /*aBitmapId*/, |
|
224 TInt& /*aMaskId*/ ) const |
|
225 { |
|
226 __ASSERT_ALWAYS( !aFullFileName, User::Invariant() ); |
|
227 |
|
228 return KErrNotFound; |
|
229 } |
|
230 |
|
231 // --------------------------------------------------------- |
|
232 // CMenuSrvEngUtils::GetFolderIcon |
|
233 // --------------------------------------------------------- |
|
234 // |
|
235 TInt CMenuSrvEngUtils::GetFolderIconL( TInt aItemId, |
|
236 HBufC*& aFullFileName, |
|
237 TInt& aBitmapId, |
|
238 TInt& aMaskId ) const |
|
239 { |
|
240 __ASSERT_ALWAYS( !aFullFileName, User::Invariant() ); |
|
241 |
|
242 TInt err( 0 ); |
|
243 const CMenuEngObject& obj = iEng.ObjectL( aItemId ); |
|
244 err = GetFolderIcon( obj, aFullFileName, aBitmapId, aMaskId ); |
|
245 return err; |
|
246 } |
|
247 |
|
248 |
|
249 // --------------------------------------------------------- |
|
250 // CMenuSrvEngUtils::IsNative |
|
251 // --------------------------------------------------------- |
|
252 // |
|
253 void CMenuSrvEngUtils::IsNative( const CMenuEngObject& aEngObj, |
|
254 TBool& aAttrExists, TDes& aAttrVal ) |
|
255 { |
|
256 aAttrExists = EFalse; |
|
257 if( aEngObj.Type().CompareF( KMenuTypeApp ) == KErrNone ) |
|
258 { |
|
259 TInt err; |
|
260 TUid uid; |
|
261 err = GetAppUid( aEngObj, uid ); |
|
262 if( err == KErrNone ) |
|
263 { |
|
264 TBool native(EFalse); |
|
265 err = IsNative( uid, native ); |
|
266 if( !err ) |
|
267 { |
|
268 aAttrExists = ETrue; |
|
269 if( native ) |
|
270 { |
|
271 aAttrVal = KMenuTrue(); |
|
272 } |
|
273 else |
|
274 { |
|
275 aAttrVal = KMenuFalse(); |
|
276 } |
|
277 } |
|
278 } |
|
279 } |
|
280 if( !aAttrExists ) |
|
281 { |
|
282 aAttrVal = KNullDesC(); |
|
283 } |
|
284 } |
101 } |
285 |
102 |
286 // --------------------------------------------------------- |
103 // --------------------------------------------------------- |
287 // CMenuSrvEngUtils::IsNativeL |
104 // CMenuSrvEngUtils::IsNativeL |
288 // --------------------------------------------------------- |
105 // --------------------------------------------------------- |
289 // |
106 // |
290 |
107 |
291 TInt CMenuSrvEngUtils::IsNative( TUid aAppUid, TBool& aIsNative ) |
108 TInt CMenuSrvEngUtils::IsNativeL( TUid aAppUid, TBool& aIsNative ) |
292 { |
109 { |
293 TInt error(KErrNotFound); |
110 TInt error( KErrNotFound ); |
294 TApaAppInfo appInfo; |
111 CMenuEngObject::TAppType aType; |
295 |
112 error = GetAppTypeFromArrayL( aAppUid, aType ); |
296 error = iApaLsSession.GetAppInfo( appInfo, aAppUid ); |
113 if ( error == KErrNone && aType == CMenuEngObject::ENativeApp ) |
297 if( error == KErrNone ) |
114 { |
298 { |
115 aIsNative = ETrue; |
299 error = iApaLsSession.IsProgram( appInfo.iFullName, aIsNative ); |
116 } |
300 } |
117 else if( error != KErrNone ) |
301 |
118 { |
302 return error; |
119 TApaAppInfo appInfo; |
|
120 error = iApaLsSession.GetAppInfo( appInfo, aAppUid ); |
|
121 if( error == KErrNone ) |
|
122 { |
|
123 error = iApaLsSession.IsProgram( appInfo.iFullName, aIsNative ); |
|
124 } |
|
125 } |
|
126 else |
|
127 { |
|
128 aIsNative = EFalse; |
|
129 } |
|
130 return error; |
303 } |
131 } |
304 |
132 |
305 // --------------------------------------------------------- |
133 // --------------------------------------------------------- |
306 // CMenuSrvEngUtils::GetDrmProtectionByContentIdL |
134 // CMenuSrvEngUtils::GetDrmProtectionByContentIdL |
307 // --------------------------------------------------------- |
135 // --------------------------------------------------------- |
339 aProtectionInfo = EDRMUnknownProtection; |
167 aProtectionInfo = EDRMUnknownProtection; |
340 break; |
168 break; |
341 } |
169 } |
342 } |
170 } |
343 } |
171 } |
344 |
|
345 CleanupStack::PopAndDestroy( drmInfo ); |
172 CleanupStack::PopAndDestroy( drmInfo ); |
346 return err; |
173 return err; |
347 } |
174 } |
348 |
175 |
349 |
176 |
350 // --------------------------------------------------------- |
177 // --------------------------------------------------------- |
351 // CMenuSrvEngUtils::GetDrmProtection |
178 // CMenuSrvEngUtils::GetDrmProtection |
352 // --------------------------------------------------------- |
179 // --------------------------------------------------------- |
353 // |
180 // |
354 TInt CMenuSrvEngUtils::GetDrmProtectionL( |
181 TInt CMenuSrvEngUtils::GetDrmProtectionL( |
355 const TUid aAppUid, |
182 const TUid aAppUid, TDRMProtectionInfo& aProtectionInfo ) const |
|
183 { |
|
184 TInt err( KErrNone ); |
|
185 |
|
186 TApaAppInfo info; |
|
187 |
|
188 aProtectionInfo = EDRMUnknownProtection; |
|
189 CMenuEngObject::TAppType aType; |
|
190 err = GetAppTypeFromArrayL( aAppUid, aType ); |
|
191 if( ( !err && aType == CMenuEngObject::EJavaApp ) |
|
192 || ( err && IsMiddlet( aAppUid ) ) ) |
|
193 { |
|
194 TBuf<KMaxFileName> contentId; |
|
195 GetJavaContentIdL( aAppUid, contentId ); |
|
196 if ( contentId != KNullDesC ) |
|
197 { |
|
198 GetDrmProtectionByContentIdL( contentId, aProtectionInfo ); |
|
199 } |
|
200 } |
|
201 return err; |
|
202 } |
|
203 |
|
204 // --------------------------------------------------------- |
|
205 // CMenuSrvEngUtils::GetDrmProtection |
|
206 // --------------------------------------------------------- |
|
207 // |
|
208 TInt CMenuSrvEngUtils::GetDrmProtectionL( |
|
209 const CMenuEngObject& aEngObj, |
356 TDRMProtectionInfo& aProtectionInfo ) const |
210 TDRMProtectionInfo& aProtectionInfo ) const |
357 { |
211 { |
358 TInt err( KErrNone ); |
212 TInt err( KErrNone ); |
359 |
213 |
360 TApaAppInfo info; |
|
361 |
|
362 aProtectionInfo = EDRMUnknownProtection; |
|
363 |
|
364 err = GetApaAppInfo( aAppUid, info ); |
|
365 if ( err == KErrNone ) |
|
366 { |
|
367 if( IsMiddlet( info ) ) |
|
368 { |
|
369 TBuf<KMaxFileName> contentId; |
|
370 GetJavaContentIdL( info.iUid, contentId ); |
|
371 if ( contentId != KNullDesC ) |
|
372 { |
|
373 GetDrmProtectionByContentIdL( contentId, aProtectionInfo ); |
|
374 } |
|
375 } |
|
376 } |
|
377 |
|
378 |
|
379 return err; |
|
380 } |
|
381 |
|
382 // --------------------------------------------------------- |
|
383 // CMenuSrvEngUtils::GetDrmProtection |
|
384 // --------------------------------------------------------- |
|
385 // |
|
386 TInt CMenuSrvEngUtils::GetDrmProtectionL( |
|
387 const CMenuEngObject& aEngObj, |
|
388 TDRMProtectionInfo& aProtectionInfo ) const |
|
389 { |
|
390 TInt err( KErrNone ); |
|
391 |
|
392 if ( aEngObj.Type().CompareF( KMenuTypeApp ) == 0 ) |
214 if ( aEngObj.Type().CompareF( KMenuTypeApp ) == 0 ) |
393 { |
215 { |
394 TUid uid; |
216 TUid uid; |
395 err = CMenuSrvEngUtils::GetAppUid( aEngObj, uid ); |
217 err = CMenuSrvEngUtils::GetAppUid( aEngObj, uid ); |
396 if ( err == KErrNone ) |
218 if ( err == KErrNone ) |
417 TInt err( 0 ); |
239 TInt err( 0 ); |
418 const CMenuEngObject& obj = iEng.ObjectL( aItemId ); |
240 const CMenuEngObject& obj = iEng.ObjectL( aItemId ); |
419 err = GetDrmProtectionL( obj, aProtectionInfo ); |
241 err = GetDrmProtectionL( obj, aProtectionInfo ); |
420 return err; |
242 return err; |
421 } |
243 } |
422 /* |
|
423 // --------------------------------------------------------- |
|
424 // CMenuSrvEngUtils::GetDrmProtection |
|
425 // --------------------------------------------------------- |
|
426 // |
|
427 TBool CMenuSrvEngUtils::GetAppRunningL( TInt aItemId ) |
|
428 { |
|
429 TInt err( 0 ); |
|
430 const CMenuEngObject& obj = iEng.ObjectL( aItemId ); |
|
431 err = GetAppRunningL( obj ); |
|
432 return err; |
|
433 } |
|
434 |
|
435 // --------------------------------------------------------- |
|
436 // CMenuSrvEngUtils::GetDrmProtection |
|
437 // --------------------------------------------------------- |
|
438 // |
|
439 TBool CMenuSrvEngUtils::GetAppRunningL( const CMenuEngObject& aEngObj ) |
|
440 { |
|
441 TBool runningApp( EFalse ); |
|
442 if ( aEngObj.Type().CompareF( KMenuTypeApp ) == KErrNone ) |
|
443 { |
|
444 TUid appUid; |
|
445 TInt errorUid = GetAppUid( aEngObj, appUid ); |
|
446 |
|
447 if( !errorUid ) |
|
448 { |
|
449 CheckAppRunningL( appUid , runningApp ); |
|
450 } |
|
451 else |
|
452 { |
|
453 return EFalse; |
|
454 } |
|
455 } |
|
456 else if( aEngObj.Type().CompareF( KMenuTypeFolder ) == KErrNone ) |
|
457 { |
|
458 GetChildrenRunningAppL( aEngObj.Id(), runningApp ); |
|
459 } |
|
460 |
|
461 return runningApp; |
|
462 } |
|
463 |
|
464 // --------------------------------------------------------- |
|
465 // CMenuSrvEngUtils::GetChildrenRunningAppL |
|
466 // --------------------------------------------------------- |
|
467 // |
|
468 void CMenuSrvEngUtils::GetChildrenRunningAppL( TInt id, |
|
469 TBool& aRunningApp ) |
|
470 { |
|
471 TMenuSrvTypeFilter filter; |
|
472 filter.SetType( KMenuTypeApp() ); |
|
473 |
|
474 RArray<TMenuItem> aItemArray; |
|
475 CleanupClosePushL(aItemArray); |
|
476 iEng.GetItemsL( aItemArray , id , &filter, ETrue ); |
|
477 for( TInt i = 0; i < aItemArray.Count(); i++) |
|
478 { |
|
479 const CMenuEngObject& obj = iEng.ObjectL( aItemArray[i].Id() ); |
|
480 TUid appUid; |
|
481 TInt errorUid = GetAppUid( obj, appUid ); |
|
482 |
|
483 if( !errorUid && |
|
484 !(obj.Flags() & TMenuItem::EHidden) ) |
|
485 { |
|
486 CheckAppRunningL( appUid , aRunningApp ); |
|
487 } |
|
488 if( aRunningApp ) |
|
489 { |
|
490 break; |
|
491 } |
|
492 } |
|
493 CleanupStack::PopAndDestroy( &aItemArray ); |
|
494 } |
|
495 |
|
496 // --------------------------------------------------------- |
|
497 // CMenuSrvEngUtils::CheckAppRunning |
|
498 // --------------------------------------------------------- |
|
499 // |
|
500 void CMenuSrvEngUtils::CheckAppRunningL( TUid aUid, TBool& aRunningApp ) |
|
501 { |
|
502 if ( iWidgetSession.IsWidget( aUid ) ) |
|
503 { |
|
504 aRunningApp = iWidgetSession.IsWidgetRunning( aUid ); |
|
505 } |
|
506 else |
|
507 { |
|
508 CAknTaskList* taskList = CAknTaskList::NewLC( iWsSession ); |
|
509 |
|
510 TApaTask task = taskList->FindRootApp( aUid ); |
|
511 aRunningApp = task.Exists(); |
|
512 |
|
513 CleanupStack::PopAndDestroy( taskList ); |
|
514 } |
|
515 }*/ |
|
516 |
244 |
517 // --------------------------------------------------------- |
245 // --------------------------------------------------------- |
518 // CMenuSrvEngUtils::GetSatAppInfo |
246 // CMenuSrvEngUtils::GetSatAppInfo |
519 // --------------------------------------------------------- |
247 // --------------------------------------------------------- |
520 // |
248 // |
529 } |
257 } |
530 return err; |
258 return err; |
531 } |
259 } |
532 |
260 |
533 // --------------------------------------------------------- |
261 // --------------------------------------------------------- |
534 // MenuSrvUtil::SetValueSkinMajorId |
262 // CMenuSrvEngUtils::IsMiddlet |
535 // --------------------------------------------------------- |
263 // --------------------------------------------------------- |
536 // |
264 // |
537 void CMenuSrvEngUtils::SetValueSkinId( TDes& aAttrName, TInt aValue ) |
265 TBool CMenuSrvEngUtils::IsMiddlet( const TUid aAppUid ) const |
538 { |
266 { |
539 MenuUtils::SetTUint( aAttrName, aValue ); |
267 const TUid KMidletType = { 0x10210E26 }; |
|
268 TUid typeuid = KNullUid; |
|
269 |
|
270 if ( KErrNone == iApaLsSession.GetAppType( typeuid, aAppUid ) ) |
|
271 { |
|
272 if ( typeuid == KMidletType ) |
|
273 { |
|
274 return ETrue; |
|
275 } |
|
276 } |
|
277 return EFalse; |
540 } |
278 } |
|
279 |
|
280 // --------------------------------------------------------- |
|
281 // GetAppUid |
|
282 // --------------------------------------------------------- |
|
283 // |
|
284 TInt CMenuSrvEngUtils::GetAppUid( const CMenuEngObject& aEngObj, TUid& aAppUid ) |
|
285 { |
|
286 TInt err( 0 ); |
|
287 TPtrC attrVal; |
|
288 TBool attrExists( EFalse ); |
|
289 TBool localized( EFalse );// |
|
290 attrExists = aEngObj.FindAttribute( KMenuAttrUid, attrVal, localized ); |
|
291 if ( !attrExists ) |
|
292 { |
|
293 err = KErrNotFound; |
|
294 } |
|
295 else |
|
296 { |
|
297 TUint appUid; |
|
298 err = MenuUtils::GetTUint( attrVal, appUid ); |
|
299 if ( !err ) |
|
300 { |
|
301 aAppUid = TUid::Uid( appUid ); |
|
302 } |
|
303 } |
|
304 return err; |
|
305 } |
|
306 |
|
307 // --------------------------------------------------------- |
|
308 // CMenuSrvEngUtils::GetJavaContentIdL |
|
309 // --------------------------------------------------------- |
|
310 // |
|
311 void CMenuSrvEngUtils::GetJavaContentIdL( TUid aUid, TDes& aContentId ) const |
|
312 { |
|
313 Java::CJavaRegistry* javaRegistry; |
|
314 Java::CJavaRegistryEntry* regEntry = NULL; |
|
315 |
|
316 javaRegistry = Java::CJavaRegistry::NewL(); |
|
317 CleanupStack::PushL( javaRegistry ); |
|
318 |
|
319 //regEntry will be NULL if there is no Java application |
|
320 //corresponding to the specified aUid |
|
321 regEntry = javaRegistry->RegistryEntryL( aUid ); |
|
322 |
|
323 //DrmContentId() will return reference to NULL when |
|
324 //Java application is not DRM protected |
|
325 if( regEntry && ( ®Entry->DrmContentId() ) ) |
|
326 { |
|
327 aContentId.Copy( regEntry->DrmContentId() ); |
|
328 } |
|
329 else |
|
330 { |
|
331 aContentId.Copy( KNullDesC ); |
|
332 } |
|
333 |
|
334 delete regEntry; |
|
335 CleanupStack::PopAndDestroy( javaRegistry ); |
|
336 } |
|
337 |
|
338 // --------------------------------------------------------- |
|
339 // CMenuSrvAppScanner::GetApaItemsL |
|
340 // --------------------------------------------------------- |
|
341 // |
|
342 void CMenuSrvEngUtils::ReloadApaItemsL() |
|
343 { |
|
344 iAppAttributes.ResetAndDestroy(); |
|
345 TApaAppInfo appInfo; |
|
346 TApaAppCapabilityBuf appCap; |
|
347 |
|
348 User::LeaveIfError( iApaLsSession.GetAllApps( 0 ) ); |
|
349 // for every application get uid, hidden and missing attribute |
|
350 // and add to aArray. |
|
351 while ( KErrNone == iApaLsSession.GetNextApp( appInfo ) ) |
|
352 { |
|
353 User::LeaveIfError( |
|
354 iApaLsSession.GetAppCapability( appCap, appInfo.iUid ) ); |
|
355 // "Hidden" status according to AppArc. |
|
356 TBool appHidden = appCap().iAppIsHidden; |
|
357 |
|
358 CMenuSrvAppAttributes* appAtributes = CMenuSrvAppAttributes::NewLC( appCap, appInfo ); |
|
359 if( IsMiddlet( appInfo.iUid ) ) |
|
360 { |
|
361 appAtributes->SetAppType( CMenuEngObject::EJavaApp ); |
|
362 } |
|
363 else if( iWidgetSession.IsWidget( appInfo.iUid ) ) |
|
364 { |
|
365 appAtributes->SetAppType( CMenuEngObject::EWidgetApp ); |
|
366 } |
|
367 else |
|
368 { |
|
369 //TODO: it is really necessary? |
|
370 TBool isNative( EFalse ); |
|
371 iApaLsSession.IsProgram( appInfo.iFullName, isNative ); |
|
372 if( isNative ) |
|
373 { |
|
374 appAtributes->SetAppType( CMenuEngObject::ENativeApp ); |
|
375 } |
|
376 } |
|
377 |
|
378 iAppAttributes.AppendL( appAtributes ); |
|
379 CleanupStack::Pop( appAtributes ); |
|
380 } |
|
381 } |
|
382 |
|
383 // --------------------------------------------------------- |
|
384 // |
|
385 // --------------------------------------------------------- |
|
386 // |
|
387 TInt CMenuSrvEngUtils::GetAppInfoFromArrayL( TApaAppInfo& aAppInfo ) const |
|
388 { |
|
389 TApaAppCapabilityBuf capability; |
|
390 CMenuSrvAppAttributes* attribute = CMenuSrvAppAttributes::NewLC( capability, aAppInfo ); |
|
391 TInt index = iAppAttributes.Find( attribute, |
|
392 TIdentityRelation<CMenuSrvAppAttributes>( CMenuSrvAppAttributes::MatchItems ) ); |
|
393 if( index >= 0 ) |
|
394 { |
|
395 aAppInfo.iCaption = iAppAttributes[index]->GetCaption(); |
|
396 aAppInfo.iFullName = iAppAttributes[index]->GetFullName(); |
|
397 aAppInfo.iShortCaption = iAppAttributes[index]->GetShortCaption(); |
|
398 index = KErrNone; |
|
399 } |
|
400 CleanupStack::PopAndDestroy( attribute ); |
|
401 return index; |
|
402 } |
|
403 |
|
404 // --------------------------------------------------------- |
|
405 // |
|
406 // --------------------------------------------------------- |
|
407 // |
|
408 TInt CMenuSrvEngUtils::GetAppTypeFromArrayL( const TUid& aAppUid, |
|
409 CMenuEngObject::TAppType& aType ) const |
|
410 { |
|
411 TApaAppCapabilityBuf capability; |
|
412 TApaAppInfo appInfo; |
|
413 appInfo.iUid = aAppUid; |
|
414 CMenuSrvAppAttributes* attribute = CMenuSrvAppAttributes::NewLC( capability, appInfo ); |
|
415 TInt index = iAppAttributes.Find( attribute, |
|
416 TIdentityRelation<CMenuSrvAppAttributes>( CMenuSrvAppAttributes::MatchItems ) ); |
|
417 if( index >= 0 ) |
|
418 { |
|
419 aType = iAppAttributes[index]->GetAppType(); |
|
420 index = KErrNone; |
|
421 } |
|
422 |
|
423 CleanupStack::PopAndDestroy( attribute ); |
|
424 return index; |
|
425 } |
|
426 |
|
427 // --------------------------------------------------------- |
|
428 // |
|
429 // --------------------------------------------------------- |
|
430 // |
|
431 RPointerArray<CMenuSrvAppAttributes>& CMenuSrvEngUtils::GetAppItemsL() |
|
432 { |
|
433 return iAppAttributes; |
|
434 } |
541 |
435 |
542 // --------------------------------------------------------- |
436 // --------------------------------------------------------- |
543 // MenuSrvUtil::UidToStringL |
437 // MenuSrvUtil::UidToStringL |
544 // --------------------------------------------------------- |
438 // --------------------------------------------------------- |
545 // |
439 // |
546 void MenuSrvUtil::UidToStringL( TUint aUid, TDes& aResult, |
440 void MenuSrvUtil::UidToStringL( TUint aUid, TDes& aResult, |
547 TBool aLegacy, TRadix aRadix ) |
441 TBool aLegacy, TRadix aRadix ) |
548 { |
442 { |
549 aResult.Zero(); |
443 aResult.Zero(); |
550 |
444 |
551 TBuf<KUidChars> number; |
445 TBuf<KUidChars> number; |
552 if( !aLegacy ) |
446 if( !aLegacy ) |
553 { |
447 { |
554 if (aRadix == EHex) |
448 if (aRadix == EHex) |
555 { |
449 { |
556 aResult.Append( KHex ); |
450 aResult.Append( KHex ); |
557 } |
451 } |
558 } |
452 } |
559 number.AppendNum( aUid, aRadix ); |
453 number.AppendNum( aUid, aRadix ); |
560 number.UpperCase(); |
454 number.UpperCase(); |
561 |
455 |
562 aResult.Append( number ); |
456 aResult.Append( number ); |
563 |
457 } |
564 } |
|
565 |
|
566 // --------------------------------------------------------- |
|
567 // TMenuSrvTypeFilter::MatchesObject |
|
568 // --------------------------------------------------------- |
|
569 // |
|
570 TBool TMenuSrvTypeFilter::MatchesObject |
|
571 ( const CMenuEngObject& aObject ) const |
|
572 { |
|
573 return iType == aObject.Type(); |
|
574 } |
|
575 |
|
576 // ==================== MEMBER FUNCTIONS ==================== |
|
577 |
|
578 // --------------------------------------------------------- |
|
579 // TMenuSrvTypeAttrFilter::MatchesObject |
|
580 // --------------------------------------------------------- |
|
581 // |
|
582 TBool TMenuSrvTypeAttrFilter::MatchesObject |
|
583 ( const CMenuEngObject& aObject ) const |
|
584 { |
|
585 if ( TMenuSrvTypeFilter::MatchesObject( aObject ) ) |
|
586 { |
|
587 TPtrC val; |
|
588 TBool dummy; |
|
589 if( aObject.FindAttribute( iAttrName, val, dummy ) ) |
|
590 { |
|
591 if( !val.CompareF( iAttrValue ) ) |
|
592 { |
|
593 return ETrue; // Match. |
|
594 } |
|
595 } |
|
596 } |
|
597 return EFalse; |
|
598 } |
|
599 |
|
600 // --------------------------------------------------------- |
|
601 // TMenuSrvAttrFilter::MatchesObject |
|
602 // --------------------------------------------------------- |
|
603 // |
|
604 TBool TMenuSrvAttrFilter::MatchesObject |
|
605 ( const CMenuEngObject& aObject ) const |
|
606 { |
|
607 TPtrC val; |
|
608 TBool dummy; |
|
609 if( aObject.FindAttribute( iAttrName, val, dummy ) ) |
|
610 { |
|
611 if( !val.CompareF( iAttrValue ) ) |
|
612 { |
|
613 return ETrue; // Match. |
|
614 } |
|
615 } |
|
616 return EFalse; |
|
617 } |
|
618 |
|
619 // ==================== MEMBER FUNCTIONS ==================== |
|
620 |
|
621 // --------------------------------------------------------- |
|
622 // TMenuSrvTypeAttrFilter::MatchesObject |
|
623 // --------------------------------------------------------- |
|
624 // |
|
625 TBool TMenuSrvTypeAttrExistsFilter::MatchesObject |
|
626 ( const CMenuEngObject& aObject ) const |
|
627 { |
|
628 if ( TMenuSrvTypeFilter::MatchesObject( aObject ) ) |
|
629 { |
|
630 TPtrC val; |
|
631 TBool dummy; |
|
632 if( aObject.FindAttribute( iAttrName, val, dummy ) ) |
|
633 { |
|
634 return ETrue; // Match. |
|
635 } |
|
636 } |
|
637 return EFalse; |
|
638 } |
|
639 |
|
640 // --------------------------------------------------------- |
|
641 // TMenuSrvTypeAttrFilter::MatchesObject |
|
642 // --------------------------------------------------------- |
|
643 // |
|
644 TBool TMenuSrvAttrExistsFilter::MatchesObject |
|
645 ( const CMenuEngObject& aObject ) const |
|
646 { |
|
647 TPtrC val; |
|
648 TBool dummy; |
|
649 if( aObject.FindAttribute( iAttrName, val, dummy ) ) |
|
650 { |
|
651 return ETrue; // Match. |
|
652 } |
|
653 return EFalse; |
|
654 } |
|
655 |
|
656 // --------------------------------------------------------- |
|
657 // TMenuSrvHiddenAppFilter::MatchesObject |
|
658 // --------------------------------------------------------- |
|
659 // |
|
660 TBool TMenuSrvHiddenAppFilter::MatchesObject |
|
661 ( const CMenuEngObject& aObject ) const |
|
662 { |
|
663 if (KMenuTypeApp() == aObject.Type()) |
|
664 { |
|
665 if( aObject.Flags() & TMenuItem::EHidden ) |
|
666 { |
|
667 return ETrue; // Match. |
|
668 } |
|
669 } |
|
670 return EFalse; |
|
671 } |
|
672 |
|
673 // --------------------------------------------------------- |
|
674 // CMenuSrvEngUtils::IsMiddlet |
|
675 // --------------------------------------------------------- |
|
676 // |
|
677 TBool CMenuSrvEngUtils::IsMiddlet( const TApaAppInfo& aInfo ) |
|
678 { |
|
679 TBool ret( EFalse ); |
|
680 if( aInfo.iFullName.Right( KMidletPostfix().Length() ). |
|
681 CompareF( KMidletPostfix ) == 0 ) |
|
682 { |
|
683 ret = ETrue; |
|
684 } |
|
685 return ret; |
|
686 } |
|
687 |
|