|
1 /* |
|
2 * Copyright (c) 2008 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: The API supports item information that is not supported by |
|
15 * the MCS server itself |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef __MENUSRVENGUTILS_H__ |
|
21 #define __MENUSRVENGUTILS_H__ |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <w32std.h> |
|
25 #include <apgcli.h> |
|
26 #include <WidgetRegistryClient.h> |
|
27 #include "menuengobject.h" |
|
28 #include "menueng.h" |
|
29 #include "menuengfilter.h" |
|
30 |
|
31 /// Number of characters in UID and in MMC-id strings. |
|
32 const TInt KUidChars = 10; |
|
33 const TInt KUidLegacyChars = 8; |
|
34 |
|
35 class TApaAppInfo; |
|
36 class CMcsSatHandler; |
|
37 |
|
38 NONSHARABLE_CLASS( CMenuSrvEngUtils ) : public CBase |
|
39 { |
|
40 public: |
|
41 |
|
42 virtual ~CMenuSrvEngUtils(); |
|
43 static CMenuSrvEngUtils* NewL( CMenuEng& aEng ); |
|
44 |
|
45 static TInt GetAppUid( const CMenuEngObject& aEngObj, TUid& aAppUid ); |
|
46 |
|
47 // Caption support |
|
48 |
|
49 TInt GetAppInfo( const CMenuEngObject& aEngObj, TApaAppInfo& aAppInfo ) const; |
|
50 TInt GetAppInfoL( TInt aItemId, TApaAppInfo& aAppInfo ) const; |
|
51 |
|
52 // Icon support |
|
53 |
|
54 TInt GetFolderIcon( const CMenuEngObject& aEngObj, |
|
55 HBufC*& aFullFileName, |
|
56 TInt& aBitmapId, |
|
57 TInt& aMaskId ) const; |
|
58 TInt GetFolderIconL( TInt aItemId, |
|
59 HBufC*& aFullFileName, |
|
60 TInt& aBitmapId, |
|
61 TInt& aMaskId ) const; |
|
62 |
|
63 // DRM protection info |
|
64 |
|
65 enum TDRMProtectionInfo |
|
66 { |
|
67 EDRMUnknownProtection, |
|
68 EDRMNotProtected, |
|
69 EDRMProtected, |
|
70 EDRMRightsExpired |
|
71 }; |
|
72 |
|
73 TInt GetDrmProtectionL( const CMenuEngObject& aEngObj, |
|
74 TDRMProtectionInfo& aProtectionInfo ) const; |
|
75 TInt GetDrmProtectionL( TInt aItemId, |
|
76 TDRMProtectionInfo& aProtectionInfo ) const; |
|
77 |
|
78 TInt GetDrmProtectionL( |
|
79 const TUid aAppUid, |
|
80 TDRMProtectionInfo& aProtectionInfo ) const; |
|
81 |
|
82 // TBool GetAppRunningL( TInt aItemId ) ; |
|
83 |
|
84 // TBool GetAppRunningL( const CMenuEngObject& aEngObj ) ; |
|
85 void SetValueSkinId( TDes& aAttrName, TInt aValue ); |
|
86 |
|
87 |
|
88 TInt GetApaAppInfo( |
|
89 const CMenuEngObject& aEngObj, |
|
90 TApaAppInfo& aInfo ) const; |
|
91 TInt GetApaAppInfo( TUid aUid, TApaAppInfo& aInfo ) const; |
|
92 |
|
93 static void GetJavaContentIdL( TUid aUid, TDes& aContentId ); |
|
94 |
|
95 /** |
|
96 * Fetches aEngObj native attribute value. |
|
97 * @param aEngObj engine object. |
|
98 * @param aAttrExists ETrue if attribute exist. |
|
99 * @param aAttrVal attribute value. |
|
100 */ |
|
101 void IsNative( const CMenuEngObject& aEngObj, |
|
102 TBool& aAttrExists, TDes& aAttrVal ); |
|
103 /** |
|
104 * |
|
105 */ |
|
106 static TBool IsMiddlet( const TApaAppInfo& aInfo ); |
|
107 |
|
108 private: |
|
109 |
|
110 // void GetChildrenRunningAppL( TInt id, TBool& aRunningApp ) ; |
|
111 |
|
112 // void CheckAppRunningL( TUid aUid, TBool& aRunningApp ) ; |
|
113 |
|
114 TInt GetSatAppInfo( TApaAppInfo& aAppInfo ) const; |
|
115 |
|
116 CMenuSrvEngUtils( CMenuEng& aEng ); |
|
117 void ConstructL(); |
|
118 |
|
119 /** |
|
120 */ |
|
121 TInt GetDrmProtectionByContentIdL( |
|
122 const TDesC& aConstenId, |
|
123 TDRMProtectionInfo& aProtectionInfo )const; |
|
124 |
|
125 /** |
|
126 * Checks wether application is native |
|
127 * @since S60 v5.0. |
|
128 * @param aAppUid applications uid |
|
129 * @param aIsNative ETrue if apppication is native |
|
130 * @return KErrNone if successful, otherwise one of the other system-wide error codes |
|
131 */ |
|
132 TInt IsNative( TUid aAppUid, TBool& aIsNative ); |
|
133 |
|
134 private: // Data |
|
135 |
|
136 CMcsSatHandler* iSatHandler; |
|
137 |
|
138 CMenuEng& iEng; ///< Engine. Not own. |
|
139 RApaLsSession iApaLsSession; |
|
140 RWidgetRegistryClientSession iWidgetSession; |
|
141 RWsSession iWsSession; |
|
142 }; |
|
143 |
|
144 /********************************************** |
|
145 * Static utility functions. |
|
146 */ |
|
147 NONSHARABLE_CLASS( MenuSrvUtil ) |
|
148 { |
|
149 |
|
150 public: |
|
151 |
|
152 /** |
|
153 */ |
|
154 static void UidToStringL( TUint aUid, TDes& aResult, |
|
155 TBool aLegacy, TRadix aRadix ); |
|
156 }; |
|
157 |
|
158 /** |
|
159 * Type filter: match objects by type. |
|
160 */ |
|
161 class TMenuSrvTypeFilter: public MMenuEngFilter |
|
162 { |
|
163 |
|
164 public: // from MMenuEngFilter |
|
165 |
|
166 /** |
|
167 * Filter test function. |
|
168 * @param aObject Object. |
|
169 * @return ETrue if aObject matches this filter. |
|
170 */ |
|
171 TBool MatchesObject( const CMenuEngObject& aObject ) const; |
|
172 |
|
173 public: // new methods |
|
174 |
|
175 /** |
|
176 * Set type filter. |
|
177 * @param aType Type. |
|
178 */ |
|
179 void SetType( const TDesC& aType ) |
|
180 { iType.Set( aType ); } |
|
181 |
|
182 private: // data |
|
183 |
|
184 TPtrC iType; ///< Type filter. |
|
185 |
|
186 }; |
|
187 |
|
188 /** |
|
189 * Type + attribute filter: match objects by type |
|
190 * and attribute with a specific value. |
|
191 */ |
|
192 class TMenuSrvTypeAttrFilter: public TMenuSrvTypeFilter |
|
193 { |
|
194 |
|
195 public: // from MMenuEngFilter |
|
196 |
|
197 /** |
|
198 * Filter test function. |
|
199 * @param aObject Object. |
|
200 * @return ETrue if aObject matches this filter. |
|
201 */ |
|
202 TBool MatchesObject( const CMenuEngObject& aObject ) const; |
|
203 |
|
204 public: // new methods |
|
205 |
|
206 /** |
|
207 * Set attribute filter. |
|
208 * @param aName Attribute name. |
|
209 * @param aValue Attribute value. |
|
210 */ |
|
211 void SetAttr( const TDesC& aName, const TDesC& aValue ) |
|
212 { iAttrName.Set( aName ); iAttrValue.Set( aValue ); } |
|
213 |
|
214 private: // data |
|
215 |
|
216 TPtrC iAttrName; ///< Attr name. |
|
217 TPtrC iAttrValue; ///< Attr value. |
|
218 |
|
219 }; |
|
220 |
|
221 /** |
|
222 * Type + attribute filter: match objects by type |
|
223 * and attribute with a specific value. |
|
224 */ |
|
225 class TMenuSrvAttrFilter: public MMenuEngFilter |
|
226 { |
|
227 |
|
228 public: // from MMenuEngFilter |
|
229 |
|
230 /** |
|
231 * Filter test function. |
|
232 * @param aObject Object. |
|
233 * @return ETrue if aObject matches this filter. |
|
234 */ |
|
235 TBool MatchesObject( const CMenuEngObject& aObject ) const; |
|
236 |
|
237 public: // new methods |
|
238 |
|
239 /** |
|
240 * Set attribute filter. |
|
241 * @param aName Attribute name. |
|
242 * @param aValue Attribute value. |
|
243 */ |
|
244 void SetAttr( const TDesC& aName, const TDesC& aValue ) |
|
245 { iAttrName.Set( aName ); iAttrValue.Set( aValue ); } |
|
246 |
|
247 private: // data |
|
248 |
|
249 TPtrC iAttrName; ///< Attr name. |
|
250 TPtrC iAttrValue; ///< Attr value. |
|
251 |
|
252 }; |
|
253 |
|
254 /** |
|
255 * Type + attribute filter: match objects by type |
|
256 * and attribute with a specific value. |
|
257 */ |
|
258 class TMenuSrvTypeAttrExistsFilter: public TMenuSrvTypeFilter |
|
259 { |
|
260 |
|
261 public: // from MMenuEngFilter |
|
262 |
|
263 /** |
|
264 * Filter test function. |
|
265 * @param aObject Object. |
|
266 * @return ETrue if aObject matches this filter. |
|
267 */ |
|
268 TBool MatchesObject( const CMenuEngObject& aObject ) const; |
|
269 |
|
270 public: // new methods |
|
271 |
|
272 /** |
|
273 * Set attribute filter. |
|
274 * @param aName Attribute name. |
|
275 */ |
|
276 void SetAttr( const TDesC& aName ) |
|
277 { iAttrName.Set( aName ); } |
|
278 |
|
279 private: // data |
|
280 |
|
281 TPtrC iAttrName; ///< Attr name. |
|
282 |
|
283 }; |
|
284 |
|
285 /** |
|
286 * Type + attribute filter: match objects by type |
|
287 * and attribute with a specific value. |
|
288 */ |
|
289 class TMenuSrvAttrExistsFilter: public TMenuSrvTypeFilter |
|
290 { |
|
291 |
|
292 public: // from MMenuEngFilter |
|
293 |
|
294 /** |
|
295 * Filter test function. |
|
296 * @param aObject Object. |
|
297 * @return ETrue if aObject matches this filter. |
|
298 */ |
|
299 TBool MatchesObject( const CMenuEngObject& aObject ) const; |
|
300 |
|
301 public: // new methods |
|
302 |
|
303 /** |
|
304 * Set attribute filter. |
|
305 * @param aName Attribute name. |
|
306 */ |
|
307 void SetAttr( const TDesC& aName ) |
|
308 { iAttrName.Set( aName ); } |
|
309 |
|
310 private: // data |
|
311 |
|
312 TPtrC iAttrName; ///< Attr name. |
|
313 |
|
314 }; |
|
315 |
|
316 /** |
|
317 * Hidden attr filter for application items |
|
318 */ |
|
319 class TMenuSrvHiddenAppFilter: public MMenuEngFilter |
|
320 { |
|
321 |
|
322 public: // from MMenuEngFilter |
|
323 |
|
324 /** |
|
325 * Filter test function. |
|
326 * @param aObject Object. |
|
327 * @return ETrue if aObject matches this filter. |
|
328 */ |
|
329 TBool MatchesObject( const CMenuEngObject& aObject ) const; |
|
330 |
|
331 }; |
|
332 |
|
333 |
|
334 /* |
|
335 * |
|
336 */ |
|
337 class TRunningAppsAttr |
|
338 { |
|
339 public: |
|
340 /* |
|
341 * |
|
342 */ |
|
343 TRunningAppsAttr ( TUid aUid, TBool aFswHidden = EFalse, |
|
344 TBool aHidden = EFalse, TBool aIsRunning = EFalse ) |
|
345 { |
|
346 iUid = aUid; |
|
347 iHidden = aHidden; |
|
348 iFswHidden = aFswHidden; |
|
349 iIsRunning = aIsRunning; |
|
350 } |
|
351 |
|
352 /* |
|
353 * |
|
354 */ |
|
355 TUid GetUid() const |
|
356 { |
|
357 return iUid; |
|
358 } |
|
359 |
|
360 /* |
|
361 * |
|
362 */ |
|
363 TBool IsHidden() const |
|
364 { |
|
365 return iHidden; |
|
366 } |
|
367 |
|
368 /* |
|
369 * |
|
370 */ |
|
371 void SetHidden( TBool aHidden ) |
|
372 { |
|
373 iHidden = aHidden; |
|
374 } |
|
375 |
|
376 /* |
|
377 * |
|
378 */ |
|
379 TBool IsFswHidden() const |
|
380 { |
|
381 return iFswHidden; |
|
382 } |
|
383 |
|
384 /* |
|
385 * |
|
386 */ |
|
387 void SetFswHidden( TBool aFswHidden ) |
|
388 { |
|
389 iFswHidden = aFswHidden; |
|
390 } |
|
391 |
|
392 |
|
393 /* |
|
394 * |
|
395 */ |
|
396 TBool IsRunning() const |
|
397 { |
|
398 return iIsRunning; |
|
399 } |
|
400 |
|
401 /* |
|
402 * |
|
403 */ |
|
404 void SetRunning( TBool aIsRunning ) |
|
405 { |
|
406 iIsRunning = aIsRunning; |
|
407 } |
|
408 |
|
409 /* |
|
410 * |
|
411 */ |
|
412 static TBool MatchByUid( const TRunningAppsAttr& aArg1, |
|
413 const TRunningAppsAttr& aArg2) |
|
414 { |
|
415 return aArg1.GetUid() == aArg2.GetUid(); |
|
416 } |
|
417 |
|
418 private: // data |
|
419 |
|
420 TUid iUid; |
|
421 TBool iHidden; |
|
422 TBool iFswHidden; |
|
423 TBool iIsRunning; |
|
424 |
|
425 }; |
|
426 |
|
427 |
|
428 #endif // __MENUSRVENGUTILS_H__ |