menucontentsrv/srvinc/menusrvengutils.h
branchRCL_3
changeset 78 1b207dd38b72
parent 1 844b978f8d5e
--- a/menucontentsrv/srvinc/menusrvengutils.h	Tue May 11 16:30:05 2010 +0300
+++ b/menucontentsrv/srvinc/menusrvengutils.h	Tue May 25 13:01:39 2010 +0300
@@ -11,22 +11,23 @@
 *
 * Contributors:
 *
-* Description:  The API supports item information that is not supported by 
+* Description:  The API supports item information that is not supported by
 *                the MCS server itself
 *
 */
 
-
 #ifndef __MENUSRVENGUTILS_H__
 #define __MENUSRVENGUTILS_H__
 
 #include <e32base.h>
-#include <w32std.h> 
 #include <apgcli.h>
+#include <w32std.h>
 #include <widgetregistryclient.h>
 #include "menuengobject.h"
 #include "menueng.h"
-#include "menuengfilter.h"
+#include "menusrvtypefilters.h"
+#include "menusrvappattributes.h"
+
 
 /// Number of characters in UID and in MMC-id strings.
 const TInt KUidChars = 10;
@@ -39,29 +40,9 @@
     {
 public:
 
-    virtual ~CMenuSrvEngUtils();
-    static CMenuSrvEngUtils* NewL( CMenuEng& aEng );
-    
-    static TInt GetAppUid( const CMenuEngObject& aEngObj, TUid& aAppUid );
-
-// Caption support
-
-    TInt GetAppInfo( const CMenuEngObject& aEngObj, TApaAppInfo& aAppInfo ) const;
-    TInt GetAppInfoL( TInt aItemId, TApaAppInfo& aAppInfo ) const;
-
-// Icon support
-
-    TInt GetFolderIcon( const CMenuEngObject& aEngObj, 
-                     HBufC*& aFullFileName,
-                     TInt& aBitmapId,
-                     TInt& aMaskId ) const;
-    TInt GetFolderIconL( TInt aItemId,  
-                     HBufC*& aFullFileName,
-                     TInt& aBitmapId,
-                     TInt& aMaskId ) const;
-
-// DRM protection info
-
+    /**
+    * Enum indicating application DRM protection.
+    */
     enum TDRMProtectionInfo
         {
         EDRMUnknownProtection,
@@ -70,75 +51,157 @@
         EDRMRightsExpired
         };
 
-    TInt GetDrmProtectionL( const CMenuEngObject& aEngObj,
-                           TDRMProtectionInfo& aProtectionInfo ) const;
+    /**
+    * Two-phased constructor.
+    * @param aEng menu engine.
+    */
+    static CMenuSrvEngUtils* NewL( CMenuEng& aEng );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CMenuSrvEngUtils();
+
+    /**
+    * Gets app uid based on engine object.
+    * @param aEngObj engine object.
+    * @param aAppUid app uid.
+    * @return error code.
+    */
+    static TInt GetAppUid( const CMenuEngObject& aEngObj, TUid& aAppUid );
+
+    /**
+    * Gets app info based on engine object.
+    * @param aEngObj engine object.
+    * @param aAppInfo app uid.
+    * @return error code.
+    */
+    TInt GetAppInfoL( const CMenuEngObject& aEngObj, TApaAppInfo& aAppInfo ) const;
+
+    /**
+    * Gets app DRM protection for given item id.
+    * @param aItemId item id.
+    * @param aProtectionInfo app DRM protection info.
+    * @return error code.
+    */
     TInt GetDrmProtectionL( TInt aItemId,
                            TDRMProtectionInfo& aProtectionInfo ) const;
-                           
-    TInt GetDrmProtectionL( 
-        const TUid aAppUid, 
-        TDRMProtectionInfo& aProtectionInfo ) const;
+
+    /**
+    * Gets Java app content id.
+    * @param aUid app uid.
+    * @param aContentId content id.
+    * @return error code.
+    */
+    void GetJavaContentIdL( TUid aUid, TDes& aContentId )  const;
+
+    /**
+    * Reloads app items.
+    */
+    void ReloadApaItemsL();
 
-  //  TBool GetAppRunningL( TInt aItemId ) ;
-    
-  //  TBool GetAppRunningL( const CMenuEngObject& aEngObj ) ;
-    void SetValueSkinId( TDes& aAttrName, TInt aValue );
-  
-        
-    TInt GetApaAppInfo( 
-        const CMenuEngObject& aEngObj, 
-        TApaAppInfo& aInfo ) const;
-    TInt GetApaAppInfo( TUid aUid, TApaAppInfo& aInfo ) const;
-    
-    static void GetJavaContentIdL( TUid aUid, TDes& aContentId );
-    
+    /**
+    * Checks if application is midlet.
+    * @param aAppUid app uid.
+    * @return ETrue if app is a midlet.
+    */
+    TBool IsMiddlet( const TUid aAppUid )  const;
+
     /**
-    * Fetches aEngObj native attribute value. 
-    * @param aEngObj engine object.
-    * @param aAttrExists ETrue if attribute exist.
-    * @param aAttrVal attribute value.
+    * Checks wether application is native
+    * @param aAppUid applications uid
+    * @param aIsNative ETrue if apppication is native
+    * @return KErrNone if successful, otherwise one of the other system-wide error codes
     */
-    void IsNative( const CMenuEngObject& aEngObj, 
-        TBool& aAttrExists, TDes& aAttrVal );
+    TInt IsNativeL( TUid aAppUid, TBool& aIsNative );
+
     /**
-     * 
+    * Gets app items list.
+    * @return app items list.
     */
-    static TBool IsMiddlet( const TApaAppInfo& aInfo );
+    RPointerArray<CMenuSrvAppAttributes>& GetAppItemsL();
 
 private:
 
-  //  void GetChildrenRunningAppL( TInt id, TBool& aRunningApp ) ;
-    
-  //  void CheckAppRunningL( TUid aUid, TBool& aRunningApp ) ;
-    
+    /**
+    * Get app info from array
+    * @param aAppInfo with application uid to  fetch rest information
+    * @return KErrNone if successful,
+    *   otherwise one of the other system-wide error codes
+    */
+    TInt GetAppInfoFromArrayL( TApaAppInfo& aAppInfo ) const;
+
+    /**
+    * Get app type from array
+    * @param aAppUid with application uid to  fetch rest information
+    * @param aType app type
+    * @return KErrNone if successful,
+    *   otherwise one of the other system-wide error codes
+    */
+    TInt GetAppTypeFromArrayL( const TUid& aAppUid,
+            CMenuEngObject::TAppType& aType  ) const;
+
+    /**
+    * Gets app DRM protection for given app uid.
+    * @param aAppUid app uid.
+    * @param aProtectionInfo app DRM protection info.
+    * @return error code.
+    */
+    TInt GetDrmProtectionL(
+        const TUid aAppUid,
+        TDRMProtectionInfo& aProtectionInfo ) const;
+
+    /**
+    * Gets app DRM protection based on engine object.
+    * @param aEngObj engine object.
+    * @param aProtectionInfo app DRM protection info.
+    * @return error code.
+    */
+    TInt GetDrmProtectionL( const CMenuEngObject& aEngObj,
+                           TDRMProtectionInfo& aProtectionInfo ) const;
+
+    /**
+    * Gets SAT app info.
+    * @param aAppInfo app info.
+    * @return error code.
+    */
     TInt GetSatAppInfo( TApaAppInfo& aAppInfo ) const;
-    
+
+    /**
+    * Constructor.
+    * @param aEng menu engine.
+    */
     CMenuSrvEngUtils( CMenuEng& aEng );
+
+    /**
+    * Second phased constructor.
+    */
     void ConstructL();
-    
+
     /**
-     */
+    * Drm protection info.
+    * @param aConstenId content id.
+    * @param aProtectionInfo DRM protection info.
+    * @return error code.
+    */
     TInt GetDrmProtectionByContentIdL(
 			const TDesC& aConstenId,
 			TDRMProtectionInfo& aProtectionInfo )const;
-    
-	/**
-	* Checks wether application is native
-	* @since S60 v5.0.
-	* @param aAppUid applications uid 
-	* @param aIsNative ETrue if apppication is native
-	* @return KErrNone if successful, otherwise one of the other system-wide error codes 
-	*/
-    TInt IsNative( TUid aAppUid, TBool& aIsNative );
-    
+
 private: // Data
 
-    CMcsSatHandler* iSatHandler;
-    
+    CMcsSatHandler* iSatHandler; ///< Sat handler. Own.
+
     CMenuEng& iEng; ///< Engine. Not own.
-    RApaLsSession iApaLsSession;
-    RWidgetRegistryClientSession iWidgetSession;
-    RWsSession iWsSession;
+
+    RApaLsSession iApaLsSession; ///< ApaLs session. Own.
+
+    RWidgetRegistryClientSession iWidgetSession; ///< Widget session. Own.
+
+    RWsSession iWsSession; ///< Ws session. Own.
+
+    RPointerArray<CMenuSrvAppAttributes> iAppAttributes; ///< App array. Own.
+
     };
 
 /**********************************************
@@ -150,279 +213,17 @@
 public:
 
     /**
-    */
-    static void UidToStringL( TUint aUid, TDes& aResult,
-     TBool aLegacy, TRadix aRadix );
-    };
-
-/**
-* Type filter: match objects by type.
-*/
-class TMenuSrvTypeFilter: public MMenuEngFilter
-    {
-
-public:     // from MMenuEngFilter
-
-    /**
-    * Filter test function.
-    * @param aObject Object.
-    * @return ETrue if aObject matches this filter.
-    */
-    TBool MatchesObject( const CMenuEngObject& aObject ) const;
-
-public:     // new methods
-
-    /**
-    * Set type filter.
-    * @param aType Type.
-    */
-    void SetType( const TDesC& aType )
-        { iType.Set( aType ); }
-
-private:    // data
-
-    TPtrC iType; ///< Type filter.
-
-    };
-
-/**
-* Type + attribute filter: match objects by type
-* and attribute with a specific value.
-*/
-class TMenuSrvTypeAttrFilter: public TMenuSrvTypeFilter
-    {
-
-public:     // from MMenuEngFilter
-
-    /**
-    * Filter test function.
-    * @param aObject Object.
-    * @return ETrue if aObject matches this filter.
-    */
-    TBool MatchesObject( const CMenuEngObject& aObject ) const;
-
-public:     // new methods
-
-    /**
-    * Set attribute filter.
-    * @param aName Attribute name.
-    * @param aValue Attribute value.
+    * Converts given uid to string.
+    * @param aUid app uid.
+    * @param aResult descriptor with result.
+    * @param aLegacy legacy format.
+    * @param aRadix radix.
+    * @return error code.
     */
-    void SetAttr( const TDesC& aName, const TDesC& aValue )
-        { iAttrName.Set( aName ); iAttrValue.Set( aValue ); }
-
-private:    // data
-
-    TPtrC iAttrName; ///< Attr name.
-    TPtrC iAttrValue; ///< Attr value.
-
-    };
-
-/**
-* Type + attribute filter: match objects by type
-* and attribute with a specific value.
-*/
-class TMenuSrvAttrFilter: public MMenuEngFilter
-    {
-
-public:     // from MMenuEngFilter
-
-    /**
-    * Filter test function.
-    * @param aObject Object.
-    * @return ETrue if aObject matches this filter.
-    */
-    TBool MatchesObject( const CMenuEngObject& aObject ) const;
-
-public:     // new methods
-
-    /**
-    * Set attribute filter.
-    * @param aName Attribute name.
-    * @param aValue Attribute value.
-    */
-    void SetAttr( const TDesC& aName, const TDesC& aValue )
-        { iAttrName.Set( aName ); iAttrValue.Set( aValue ); }
-
-private:    // data
-
-    TPtrC iAttrName; ///< Attr name.
-    TPtrC iAttrValue; ///< Attr value.
-
-    };
-
-/**
-* Type + attribute filter: match objects by type
-* and attribute with a specific value.
-*/
-class TMenuSrvTypeAttrExistsFilter: public TMenuSrvTypeFilter
-    {
-
-public:     // from MMenuEngFilter
-
-    /**
-    * Filter test function.
-    * @param aObject Object.
-    * @return ETrue if aObject matches this filter.
-    */
-    TBool MatchesObject( const CMenuEngObject& aObject ) const;
-
-public:     // new methods
-
-    /**
-    * Set attribute filter.
-    * @param aName Attribute name.
-    */
-    void SetAttr( const TDesC& aName )
-        { iAttrName.Set( aName ); }
-
-private:    // data
-
-    TPtrC iAttrName; ///< Attr name.
-
+    static void UidToStringL( TUint aUid,
+            TDes& aResult,
+            TBool aLegacy,
+            TRadix aRadix );
     };
 
-/**
-* Type + attribute filter: match objects by type
-* and attribute with a specific value.
-*/
-class TMenuSrvAttrExistsFilter: public TMenuSrvTypeFilter
-    {
-
-public:     // from MMenuEngFilter
-
-    /**
-    * Filter test function.
-    * @param aObject Object.
-    * @return ETrue if aObject matches this filter.
-    */
-    TBool MatchesObject( const CMenuEngObject& aObject ) const;
-
-public:     // new methods
-
-    /**
-    * Set attribute filter.
-    * @param aName Attribute name.
-    */
-    void SetAttr( const TDesC& aName )
-        { iAttrName.Set( aName ); }
-
-private:    // data
-
-    TPtrC iAttrName; ///< Attr name.
-
-    };
-
-/**
-* Hidden attr filter for application items
-*/
-class TMenuSrvHiddenAppFilter: public MMenuEngFilter
-    {
-
-public:     // from MMenuEngFilter
-
-    /**
-    * Filter test function.
-    * @param aObject Object.
-    * @return ETrue if aObject matches this filter.
-    */
-    TBool MatchesObject( const CMenuEngObject& aObject ) const;
-
-    };
-
-
-/*
-*
-*/
-class TRunningAppsAttr
-    {
-public:     
-    /*
-    *
-    */
-    TRunningAppsAttr ( TUid aUid, TBool aFswHidden = EFalse, 
-        TBool aHidden = EFalse, TBool aIsRunning = EFalse )
-		{
-		iUid = aUid;
-		iHidden = aHidden;
-		iFswHidden = aFswHidden;
-		iIsRunning = aIsRunning;
-		}
-    
-    /*
-    *
-    */
-    TUid GetUid() const
-		{
-		return iUid;
-		}	
-    
-    /*
-    *
-    */
-    TBool IsHidden() const
-		{
-		return iHidden;
-		}
-    
-    /*
-    *
-    */
-    void SetHidden( TBool aHidden ) 
-		{
-		iHidden = aHidden;
-		}
-
-    /*
-    *
-    */
-    TBool IsFswHidden() const
-		{
-		return iFswHidden;
-		}
-    
-    /*
-    *
-    */
-    void SetFswHidden( TBool aFswHidden )
-		{
-		iFswHidden = aFswHidden;
-		}
-
-
-    /*
-    *
-    */
-    TBool IsRunning() const
-		{
-		return iIsRunning;
-		}
-    
-    /*
-    *
-    */
-    void SetRunning( TBool aIsRunning )
-		{
-		iIsRunning = aIsRunning;
-		}
-
-    /*
-    *
-    */
-    static TBool MatchByUid( const TRunningAppsAttr& aArg1,  
-    		const TRunningAppsAttr& aArg2)
-    	{
-    	return aArg1.GetUid() == aArg2.GetUid();
-    	}    
-    
-private:    // data
-
-    TUid iUid;
-	TBool iHidden;
-	TBool iFswHidden;
-	TBool iIsRunning;
-	
-    };
-
-
 #endif // __MENUSRVENGUTILS_H__