menucontentsrv/srvinc/menusrveng.h
changeset 0 79c6a41cd166
child 82 ace62b58f4b2
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 2009 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:
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __MENUSRVENG_H__
       
    19 #define __MENUSRVENG_H__
       
    20 
       
    21 //  INCLUDES
       
    22 
       
    23 #include <e32base.h>
       
    24 #include "menuengobserver.h"
       
    25 #include "menuengobject.h"
       
    26 #include "menusrvengutils.h"
       
    27 #include "menusrvattr.h"
       
    28 // FORWARD DECLARATION
       
    29 
       
    30 class CMenuEng;
       
    31 class CMenuSrv;
       
    32 class CMenuSrvSession;
       
    33 class CTimeout;
       
    34 class CMenuSrvAppScanner;
       
    35 class CMenuSrvFolderCrNotifier;
       
    36 class CMcsSatMonitor;
       
    37 class CMcsDrmHandler;
       
    38 class CMcsCacheHandler;
       
    39 class CMcsChildrenHandler;
       
    40 class CMcsRunningAppsHandler;
       
    41 class CMcsSuiteHandler;
       
    42 class CMcsGetlistHandler;
       
    43 /**
       
    44 * In release code the macro must be undefined and application 
       
    45 * scanning must be enabled!
       
    46 * Define the macro only for testing purposes!
       
    47 */
       
    48 #undef __TEST_DISABLE_APPSCAN
       
    49 
       
    50 // GLOBAL FUNCTIONS
       
    51 
       
    52 /**
       
    53 * Menu engine instance.
       
    54 * Shared by the sessions using the same content file.
       
    55 * It is also "shared" by its own iTimedClose timer. The timer keeps this
       
    56 * object alive without any sessions, for a short time.
       
    57 * It is a reference counting object, but that is only used for sanity
       
    58 * checking: this->CObject::iAccessCount == iSessions.Count() + 1.
       
    59 */
       
    60 NONSHARABLE_CLASS( CMenuSrvEng ) : public CObject, public MMenuEngObserver
       
    61     {
       
    62 public:
       
    63     enum TExtendedAttributes
       
    64         {
       
    65         EMenuAttrTitleName,
       
    66         EMenuAttrShortName,
       
    67         EMenuAttrLongName,
       
    68         EMenuAttrIconFile,
       
    69         EMenuAttrIconId,
       
    70         EMenuAttrMaskId
       
    71         };
       
    72 
       
    73 public:     // construction
       
    74 
       
    75     /**
       
    76     * Destructor.
       
    77     */
       
    78     virtual ~CMenuSrvEng();
       
    79 
       
    80     /**
       
    81     * Two-phased constructor. Leaves on failure.
       
    82     * @param aMenuSrv Menu Server.
       
    83     * @param aContentName Content file name.
       
    84     * @return The constructed object.
       
    85     */
       
    86     static CMenuSrvEng* NewL( CMenuSrv& aMenuSrv, const TDesC& aContentName );
       
    87 
       
    88 private:    // construction
       
    89 
       
    90     /**
       
    91     * Constructor.
       
    92     * @param aMenuSrv Menu Server.
       
    93     */
       
    94     CMenuSrvEng( CMenuSrv& aMenuSrv );
       
    95 
       
    96     /**
       
    97     * Second-phase constructor.
       
    98     * @param aContentName Content file name.
       
    99     */
       
   100     void ConstructL( const TDesC& aContentName );
       
   101 
       
   102 public:     // new methods
       
   103 
       
   104     /**
       
   105     * Get content file name (without extension).
       
   106     * @return Content file name.
       
   107     */
       
   108     const TDesC& ContentName() const { return iContentName; }
       
   109 
       
   110     /**
       
   111     * Get the Engine.
       
   112     * @return Engine.
       
   113     */
       
   114     CMenuEng& Engine() { return *iEng; }
       
   115 
       
   116     /**
       
   117     * Add a session. Ownership not taken, this object only keeps a list of
       
   118     * sessions that are dependent on its engine.
       
   119     * @param aSession Session.
       
   120     */
       
   121     void AddSessionL( CMenuSrvSession* aSession );
       
   122 
       
   123     /**
       
   124     * Remove a session. Safe to call if not added.
       
   125     * When no more sessions remain dependent on this object, timed
       
   126     * self-deletion is scheduled.
       
   127     */
       
   128     void RemoveSession( CMenuSrvSession* aSession );
       
   129     
       
   130     
       
   131     /**
       
   132     * Get attribute name list.
       
   133     * @since S60 v5.0
       
   134     * @param aList Attribute name list.
       
   135     * @throws System-wide error codes if an error occurs.
       
   136     * @panic None.
       
   137     * 
       
   138     */
       
   139     void GetAttributeListL(
       
   140   		  TInt aId,
       
   141   		  RArray<TPtrC>& aList );
       
   142     
       
   143     /**
       
   144     * Get attribute value.
       
   145     * @since S60 v5.0
       
   146     * @param aAttrName Attribute name.
       
   147     * @param aAttrExists Will be set to indicate whether attribute exists
       
   148     * or not.
       
   149     * @return Attribute value. Empty string if attribute does not exist.
       
   150     */
       
   151     TPtrC GetAttributeL( TInt aId, const TDesC& aAttrName, TBool& aAttrExists );
       
   152 
       
   153     void GetAttributeL( TInt aId, const TDesC& aAttrName, 
       
   154         TBool& aAttrExists, TDes& aAttrVal );
       
   155 
       
   156     //TODO: Add comment
       
   157     TBool InstalledSuiteExist( const TDesC& aSuiteName );
       
   158     
       
   159     //TODO: Add comment
       
   160     void GetSuiteAttribute( const TDesC& aSuiteName, const TDesC& aAttrName, 
       
   161             TBool& aAttrExists, TDes& aAttrVal );
       
   162     
       
   163      /**
       
   164      * Get array of running apps 
       
   165      * 
       
   166      */
       
   167     void GetRunningAppsL(  RArray<TUid>& aArray );
       
   168 
       
   169     
       
   170     /**
       
   171      * Fetches children count for a folder
       
   172      */
       
   173     TUint GetChildrenCountL( TInt aId );
       
   174     
       
   175     /**
       
   176     * Builds output list for GetList operation and returns result
       
   177     * @param aSerializedInput serialized list with input parameters
       
   178     * 	for GetList operation
       
   179     * @return size of output list
       
   180     */
       
   181     TInt GetListSizeL( const TDesC8& aSerializedInput );
       
   182 
       
   183     /**
       
   184     * Returns serialized list containing result of GetList oepration
       
   185     * @return serialized output list
       
   186     */
       
   187     TPtrC8 GetListDataL( );
       
   188     
       
   189     /**
       
   190     * Closes output buffer.
       
   191     */
       
   192     void CloseOutputBuffer( );
       
   193     
       
   194     /**
       
   195     * Cleans attribute cache. Used in case of no memory.
       
   196     */
       
   197     void CleanAttributeCache( );
       
   198 
       
   199 private:    // from MMenuEngObserver
       
   200 
       
   201 
       
   202     void GetExtendedAttributesL( TInt aId, const TDesC& aAttrName, 
       
   203         TBool& aAttrExists, TDes& aAttrVal );
       
   204     
       
   205     void AddToCacheL( TInt aId, const TDesC& aAttrName, TDes& aAttrVal );
       
   206     
       
   207 
       
   208     /**
       
   209     * Fetches an application native attribute value. 
       
   210     * @param aId item id.
       
   211     * @param aAttrExists ETrue if attribute exist.
       
   212     * @param aAttrVal attribute value.
       
   213     */
       
   214     void ApplicationNativeAttributeL(
       
   215     		TInt aId, 
       
   216     		TBool & aAttrExists,
       
   217     		TDes & aAttrVal );
       
   218     
       
   219     /**
       
   220     * Engine event. Dispatch events to all dependent sessions.
       
   221     * @param aFolder Events relate to this folder. May be 0.
       
   222     * @param aEvents Events.
       
   223     */
       
   224     void EngineEvents( TInt aFolder, TInt aEvents );
       
   225 
       
   226     /**
       
   227     * Unrecoverable engine error. Dispatch to all dependent sessions.
       
   228     * @param aErr Error code.
       
   229     */
       
   230     void EngineError( TInt aErr );
       
   231     
       
   232     /**
       
   233      * Engine tree reload event.
       
   234      * Run appscanner again.
       
   235      */
       
   236     void EngineTreeReloaded();
       
   237     /**
       
   238     * Fetches an attribute value from the caption info attributes
       
   239     */
       
   240     void CaptionInfoL( TInt aId, const TDesC& aAttrName, 
       
   241         TBool& aExists, TDes& aAttrVal );
       
   242     
       
   243 	
       
   244     /**
       
   245     * Fetches an attribute value from the skin icon info attributes
       
   246     */
       
   247     void SkinInfoL( TInt aId, TInt aSelect, TBool& aExists, TDes& aAttrVal  );
       
   248     
       
   249     /**
       
   250     * Fetches the DRM protection attribute value
       
   251     */
       
   252     void AppDrmProtectionL( TInt aId, TBool& aExists, TDes& aAttrVal );
       
   253     
       
   254     /**
       
   255     * Fetches an attribute value from the caption info attributes for application
       
   256     */
       
   257     TPtrC AppCaptionInfoL( const CMenuEngObject& aEngObj,
       
   258         const TDesC& aAttrName, TBool& aExists );
       
   259 
       
   260     /**
       
   261      * Fetches the children_count attribute value (for folders)
       
   262      */
       
   263     void FolderChildrenCountL( TInt aId, TBool& aExists, TDes& aAttrVal );
       
   264     
       
   265     /**
       
   266     * Fetches the running status for application and folder
       
   267     */
       
   268     void GetAppRunningL( TInt aId, TBool& aExists, TDes& aAttrVal );
       
   269     
       
   270     /**
       
   271     * Appends extended attributes to attributes list
       
   272     */
       
   273     void AppendExtendedAttrributesL(
       
   274     		const TDesC& aType,  
       
   275     		RArray<TPtrC>& aList );
       
   276 
       
   277 
       
   278 private:    // Data
       
   279 
       
   280     CMenuSrv& iMenuSrv; ///< Menu Server.
       
   281     RBuf iContentName; ///< Content name. Own.
       
   282     RPointerArray<CMenuSrvSession> iSessions; ///< Sessions using this engine.
       
   283     CMenuEng* iEng; ///< Engine. Own.
       
   284     CTimeout* iTimedClose; ///< Closing timer. Closes this object.
       
   285     CMenuSrvAppScanner* iAppScanner; ///< App scanner. Own.
       
   286     CMenuSrvFolderCrNotifier* iFolderNotifier; ///< Folder scanner. Own.
       
   287     CMenuSrvEngUtils* iCMenuSrvEngUtils;///CMenuSrvEngUtils. Own.
       
   288     CMcsSatMonitor* iMcsSatMonitor;
       
   289     CMcsDrmHandler* iDrmHander;
       
   290     CMcsRunningAppsHandler* iRunningAppsHandler;//own
       
   291     CMcsCacheHandler* iCacheHandler;
       
   292     CMcsChildrenHandler* iChildrenHandler;
       
   293     CMcsSuiteHandler* iSuiteHandler;
       
   294     CMcsGetlistHandler* iGetlistHandler;
       
   295     };
       
   296 
       
   297 #ifdef __TEST_DISABLE_APPSCAN
       
   298 #pragma message("Undefine __TEST_DISABLE_APPSCAN !")
       
   299 #endif
       
   300 
       
   301 #endif // __MENUSRVENG_H__
       
   302 
       
   303 // End of File