menucontentsrv/srvinc/menusrvengutils.h
branchRCL_3
changeset 78 1b207dd38b72
parent 1 844b978f8d5e
equal deleted inserted replaced
74:edd621764147 78:1b207dd38b72
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  The API supports item information that is not supported by 
    14 * Description:  The API supports item information that is not supported by
    15 *                the MCS server itself
    15 *                the MCS server itself
    16 *
    16 *
    17 */
    17 */
    18 
       
    19 
    18 
    20 #ifndef __MENUSRVENGUTILS_H__
    19 #ifndef __MENUSRVENGUTILS_H__
    21 #define __MENUSRVENGUTILS_H__
    20 #define __MENUSRVENGUTILS_H__
    22 
    21 
    23 #include <e32base.h>
    22 #include <e32base.h>
    24 #include <w32std.h> 
       
    25 #include <apgcli.h>
    23 #include <apgcli.h>
       
    24 #include <w32std.h>
    26 #include <widgetregistryclient.h>
    25 #include <widgetregistryclient.h>
    27 #include "menuengobject.h"
    26 #include "menuengobject.h"
    28 #include "menueng.h"
    27 #include "menueng.h"
    29 #include "menuengfilter.h"
    28 #include "menusrvtypefilters.h"
       
    29 #include "menusrvappattributes.h"
       
    30 
    30 
    31 
    31 /// Number of characters in UID and in MMC-id strings.
    32 /// Number of characters in UID and in MMC-id strings.
    32 const TInt KUidChars = 10;
    33 const TInt KUidChars = 10;
    33 const TInt KUidLegacyChars = 8;
    34 const TInt KUidLegacyChars = 8;
    34 
    35 
    37 
    38 
    38 NONSHARABLE_CLASS( CMenuSrvEngUtils ) : public CBase
    39 NONSHARABLE_CLASS( CMenuSrvEngUtils ) : public CBase
    39     {
    40     {
    40 public:
    41 public:
    41 
    42 
    42     virtual ~CMenuSrvEngUtils();
    43     /**
    43     static CMenuSrvEngUtils* NewL( CMenuEng& aEng );
    44     * Enum indicating application DRM protection.
    44     
    45     */
    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
    46     enum TDRMProtectionInfo
    66         {
    47         {
    67         EDRMUnknownProtection,
    48         EDRMUnknownProtection,
    68         EDRMNotProtected,
    49         EDRMNotProtected,
    69         EDRMProtected,
    50         EDRMProtected,
    70         EDRMRightsExpired
    51         EDRMRightsExpired
    71         };
    52         };
    72 
    53 
       
    54     /**
       
    55     * Two-phased constructor.
       
    56     * @param aEng menu engine.
       
    57     */
       
    58     static CMenuSrvEngUtils* NewL( CMenuEng& aEng );
       
    59 
       
    60     /**
       
    61     * Destructor.
       
    62     */
       
    63     virtual ~CMenuSrvEngUtils();
       
    64 
       
    65     /**
       
    66     * Gets app uid based on engine object.
       
    67     * @param aEngObj engine object.
       
    68     * @param aAppUid app uid.
       
    69     * @return error code.
       
    70     */
       
    71     static TInt GetAppUid( const CMenuEngObject& aEngObj, TUid& aAppUid );
       
    72 
       
    73     /**
       
    74     * Gets app info based on engine object.
       
    75     * @param aEngObj engine object.
       
    76     * @param aAppInfo app uid.
       
    77     * @return error code.
       
    78     */
       
    79     TInt GetAppInfoL( const CMenuEngObject& aEngObj, TApaAppInfo& aAppInfo ) const;
       
    80 
       
    81     /**
       
    82     * Gets app DRM protection for given item id.
       
    83     * @param aItemId item id.
       
    84     * @param aProtectionInfo app DRM protection info.
       
    85     * @return error code.
       
    86     */
       
    87     TInt GetDrmProtectionL( TInt aItemId,
       
    88                            TDRMProtectionInfo& aProtectionInfo ) const;
       
    89 
       
    90     /**
       
    91     * Gets Java app content id.
       
    92     * @param aUid app uid.
       
    93     * @param aContentId content id.
       
    94     * @return error code.
       
    95     */
       
    96     void GetJavaContentIdL( TUid aUid, TDes& aContentId )  const;
       
    97 
       
    98     /**
       
    99     * Reloads app items.
       
   100     */
       
   101     void ReloadApaItemsL();
       
   102 
       
   103     /**
       
   104     * Checks if application is midlet.
       
   105     * @param aAppUid app uid.
       
   106     * @return ETrue if app is a midlet.
       
   107     */
       
   108     TBool IsMiddlet( const TUid aAppUid )  const;
       
   109 
       
   110     /**
       
   111     * Checks wether application is native
       
   112     * @param aAppUid applications uid
       
   113     * @param aIsNative ETrue if apppication is native
       
   114     * @return KErrNone if successful, otherwise one of the other system-wide error codes
       
   115     */
       
   116     TInt IsNativeL( TUid aAppUid, TBool& aIsNative );
       
   117 
       
   118     /**
       
   119     * Gets app items list.
       
   120     * @return app items list.
       
   121     */
       
   122     RPointerArray<CMenuSrvAppAttributes>& GetAppItemsL();
       
   123 
       
   124 private:
       
   125 
       
   126     /**
       
   127     * Get app info from array
       
   128     * @param aAppInfo with application uid to  fetch rest information
       
   129     * @return KErrNone if successful,
       
   130     *   otherwise one of the other system-wide error codes
       
   131     */
       
   132     TInt GetAppInfoFromArrayL( TApaAppInfo& aAppInfo ) const;
       
   133 
       
   134     /**
       
   135     * Get app type from array
       
   136     * @param aAppUid with application uid to  fetch rest information
       
   137     * @param aType app type
       
   138     * @return KErrNone if successful,
       
   139     *   otherwise one of the other system-wide error codes
       
   140     */
       
   141     TInt GetAppTypeFromArrayL( const TUid& aAppUid,
       
   142             CMenuEngObject::TAppType& aType  ) const;
       
   143 
       
   144     /**
       
   145     * Gets app DRM protection for given app uid.
       
   146     * @param aAppUid app uid.
       
   147     * @param aProtectionInfo app DRM protection info.
       
   148     * @return error code.
       
   149     */
       
   150     TInt GetDrmProtectionL(
       
   151         const TUid aAppUid,
       
   152         TDRMProtectionInfo& aProtectionInfo ) const;
       
   153 
       
   154     /**
       
   155     * Gets app DRM protection based on engine object.
       
   156     * @param aEngObj engine object.
       
   157     * @param aProtectionInfo app DRM protection info.
       
   158     * @return error code.
       
   159     */
    73     TInt GetDrmProtectionL( const CMenuEngObject& aEngObj,
   160     TInt GetDrmProtectionL( const CMenuEngObject& aEngObj,
    74                            TDRMProtectionInfo& aProtectionInfo ) const;
   161                            TDRMProtectionInfo& aProtectionInfo ) const;
    75     TInt GetDrmProtectionL( TInt aItemId,
   162 
    76                            TDRMProtectionInfo& aProtectionInfo ) const;
   163     /**
    77                            
   164     * Gets SAT app info.
    78     TInt GetDrmProtectionL( 
   165     * @param aAppInfo app info.
    79         const TUid aAppUid, 
   166     * @return error code.
    80         TDRMProtectionInfo& aProtectionInfo ) const;
   167     */
    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;
   168     TInt GetSatAppInfo( TApaAppInfo& aAppInfo ) const;
   115     
   169 
       
   170     /**
       
   171     * Constructor.
       
   172     * @param aEng menu engine.
       
   173     */
   116     CMenuSrvEngUtils( CMenuEng& aEng );
   174     CMenuSrvEngUtils( CMenuEng& aEng );
       
   175 
       
   176     /**
       
   177     * Second phased constructor.
       
   178     */
   117     void ConstructL();
   179     void ConstructL();
   118     
   180 
   119     /**
   181     /**
   120      */
   182     * Drm protection info.
       
   183     * @param aConstenId content id.
       
   184     * @param aProtectionInfo DRM protection info.
       
   185     * @return error code.
       
   186     */
   121     TInt GetDrmProtectionByContentIdL(
   187     TInt GetDrmProtectionByContentIdL(
   122 			const TDesC& aConstenId,
   188 			const TDesC& aConstenId,
   123 			TDRMProtectionInfo& aProtectionInfo )const;
   189 			TDRMProtectionInfo& aProtectionInfo )const;
   124     
   190 
   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
   191 private: // Data
   135 
   192 
   136     CMcsSatHandler* iSatHandler;
   193     CMcsSatHandler* iSatHandler; ///< Sat handler. Own.
   137     
   194 
   138     CMenuEng& iEng; ///< Engine. Not own.
   195     CMenuEng& iEng; ///< Engine. Not own.
   139     RApaLsSession iApaLsSession;
   196 
   140     RWidgetRegistryClientSession iWidgetSession;
   197     RApaLsSession iApaLsSession; ///< ApaLs session. Own.
   141     RWsSession iWsSession;
   198 
       
   199     RWidgetRegistryClientSession iWidgetSession; ///< Widget session. Own.
       
   200 
       
   201     RWsSession iWsSession; ///< Ws session. Own.
       
   202 
       
   203     RPointerArray<CMenuSrvAppAttributes> iAppAttributes; ///< App array. Own.
       
   204 
   142     };
   205     };
   143 
   206 
   144 /**********************************************
   207 /**********************************************
   145  *  Static utility functions.
   208  *  Static utility functions.
   146  */
   209  */
   148     {
   211     {
   149 
   212 
   150 public:
   213 public:
   151 
   214 
   152     /**
   215     /**
   153     */
   216     * Converts given uid to string.
   154     static void UidToStringL( TUint aUid, TDes& aResult,
   217     * @param aUid app uid.
   155      TBool aLegacy, TRadix aRadix );
   218     * @param aResult descriptor with result.
       
   219     * @param aLegacy legacy format.
       
   220     * @param aRadix radix.
       
   221     * @return error code.
       
   222     */
       
   223     static void UidToStringL( TUint aUid,
       
   224             TDes& aResult,
       
   225             TBool aLegacy,
       
   226             TRadix aRadix );
   156     };
   227     };
   157 
   228 
   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__
   229 #endif // __MENUSRVENGUTILS_H__