menucontentsrv/enginc/menuengobject.h
changeset 0 79c6a41cd166
child 22 1b207dd38b72
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 __MENUENGOBJECT_H__
       
    19 #define __MENUENGOBJECT_H__
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <gecoobjectbase.h>
       
    23 #include <gecodefaultobject.h>
       
    24 #include <gecoattributeprovider.h>
       
    25 #include "menuengobjectattr.h"
       
    26 
       
    27 // FORWARD DECLARATION
       
    28 
       
    29 class CMenuEng;
       
    30 
       
    31 /**
       
    32 * Menu Engine Object.
       
    33 * Menu Engine Object represent menu items in the Engine. Object are normally
       
    34 * owned by the Engine; exception are the items that are created but not yet
       
    35 * added to the Engine (these are temporarily owned by the client.)
       
    36 * The primary identity of objects is the Id(), this is persistent and unique.
       
    37 * 0 is not a valid ID.
       
    38 */
       
    39 NONSHARABLE_CLASS( CMenuEngObject ): public CGECODefaultObject
       
    40     {
       
    41 
       
    42 public:     // construction
       
    43 
       
    44     /**
       
    45     * Destructor.
       
    46     */
       
    47     IMPORT_C virtual ~CMenuEngObject();
       
    48 
       
    49 protected:  // construction
       
    50 
       
    51     /**
       
    52     * Constructor.
       
    53     * @param aEng Engine.
       
    54     */
       
    55     CMenuEngObject( CMenuEng& aEng );
       
    56 
       
    57     /**
       
    58     * Second phase constructor.
       
    59     * @param aType Type.
       
    60     */
       
    61     void ConstructL( const TDesC& aType );
       
    62 
       
    63 public:     // new methods
       
    64 
       
    65     /**
       
    66     * Get ID. The object always has a valid unique ID (even if the object is
       
    67     * not added to the Engine yet).
       
    68     * @return ID.
       
    69     */
       
    70     IMPORT_C TInt Id() const;
       
    71 
       
    72     /**
       
    73     * Get flags.
       
    74     * @param aFactoryCall for call from factory object(used to skip central repository check).
       
    75     * @return Flags.
       
    76     */
       
    77     IMPORT_C TUint32 Flags( TBool aFactoryCall = EFalse ) const;
       
    78 
       
    79     /**
       
    80     * Get type.
       
    81     * @return Type.
       
    82     */
       
    83     IMPORT_C TPtrC Type() const;
       
    84 
       
    85     /**
       
    86     * Get number of attributes.
       
    87     * @return Number of attributes.
       
    88     */
       
    89     IMPORT_C TInt NumAttributes() const;
       
    90 
       
    91     /**
       
    92     * Get attribute by index.
       
    93     * @param aIndex Attribute index.
       
    94     * @param aName Name is returned here.
       
    95     * @param aValue Value is returned here.
       
    96     * @param aLocalized ETrue if attribute is localized.
       
    97     * @return ETrue (unless aIndex is not valid).
       
    98     */
       
    99     IMPORT_C TBool GetAttribute(
       
   100         TInt aIndex,
       
   101         TPtrC& aName,
       
   102         TPtrC& aValue,
       
   103         TBool& aLocalized ) const;
       
   104 
       
   105     /**
       
   106     * Find attribute by name.
       
   107     * @param aName Name.
       
   108     * @param aValue Value is returned here.
       
   109     * @param aLocalized Etrue if attribute is localized.
       
   110     * @return ETrue if found.
       
   111     */
       
   112     IMPORT_C TBool FindAttribute(
       
   113         const TDesC& aName,
       
   114         TPtrC& aValue,
       
   115         TBool& aLocalized ) const;
       
   116 
       
   117     /**
       
   118     * Set or clear flags.
       
   119     * @param aMask Flags to set or clear.
       
   120     * @param aOn ETrue to set, EFalse to clear.
       
   121     */
       
   122     IMPORT_C void SetFlags( TUint32 aMask, TBool aOn );
       
   123 
       
   124     /**
       
   125     * Set attribute value. Old value, if any, is replaced.
       
   126     * @param aAttrName Name.
       
   127     * @param aAttrValue Value.
       
   128     * @param aLocalized ETrue if attribute is localized.
       
   129     */
       
   130     IMPORT_C void SetAttributeL(
       
   131         const TDesC& aAttrName,
       
   132         const TDesC& aAttrValue,
       
   133         TBool aLocalized ); // Set attribute value.
       
   134 
       
   135     /**
       
   136     * Set attribute value. Old value, if any, is replaced.
       
   137     * For use when reading xml file with initial data
       
   138     * and as a helper method for SetAttributeL.
       
   139     * @param aAttrName Name.
       
   140     * @param aAttrValue Value.
       
   141     * @param aLocalized ETrue if attribute is localized.
       
   142     */
       
   143     void SetInitialAttributeL(
       
   144         const TDesC& aAttrName,
       
   145         const TDesC& aAttrValue,
       
   146         TBool aLocalized ); // Set attribute value.
       
   147     
       
   148     /**
       
   149     * Method to set iNative for apps.
       
   150     */
       
   151     IMPORT_C void SetNative( TBool aNative );
       
   152 
       
   153     /**
       
   154     * Method to get iNative for apps.
       
   155     * @return ETrue if app is native.
       
   156     */
       
   157     IMPORT_C TBool GetNative() const;
       
   158 
       
   159     
       
   160     /**
       
   161     * Remove attribute.
       
   162     * @param aAttrName Name.
       
   163     */
       
   164     IMPORT_C void RemoveAttribute( const TDesC& aAttrName );
       
   165 
       
   166     /**
       
   167     * Remove all attributes and flags.
       
   168     */
       
   169     IMPORT_C void Reset(); // Remove all attributes and clear all flags.
       
   170 
       
   171 public:     // but not imported: for the engine's use only.
       
   172 
       
   173     /**
       
   174     * Two-phased constructor.
       
   175     * @param aEng Engine.
       
   176     * @param aType Type.
       
   177     * @return The created object.
       
   178     */
       
   179     static CMenuEngObject* NewL( CMenuEng& aEng, const TDesC& aType );
       
   180 
       
   181     /**
       
   182     * Set ID.
       
   183     * @param aId ID.
       
   184     */
       
   185     void SetId( TInt aId );
       
   186 
       
   187     /**
       
   188     * Get engine.
       
   189     * @return Engine.
       
   190     */
       
   191     CMenuEng& Engine();
       
   192 
       
   193 private:    // from CGECOObjectBase
       
   194 
       
   195     /**
       
   196     * Get type identifier.
       
   197     * @return Type identifier.
       
   198     */
       
   199     const TDesC& TypeIdentifier();
       
   200     
       
   201     /** 
       
   202      * Updates flags with hidden flag from central repository if nececerry.
       
   203      * @param aFlags flags.
       
   204      */ 
       
   205     void UpdateCrHiddenFlagL( TUint32& aFlags ) const;
       
   206 
       
   207     /** 
       
   208      * Parses descriptor containing folders hidden in central repository.
       
   209      * @param aHiddenFolders descriptor containing folders hidden in central repository.
       
   210      * @param aHiddenFoldersArray array to fill with names of folders hidden in central repository.
       
   211      */ 
       
   212     void ParseHiddenFoldersL( 
       
   213                 const TDesC& aHiddenFolders, 
       
   214                 RArray<TPtrC>& aHiddenFoldersArray ) const;
       
   215 
       
   216     /** 
       
   217      * Checks wether folder name is in Central Repository.
       
   218      * @param aFolderName descriptor containing name of a folder.
       
   219      * @return ETrue if folder is in array, EFalse otherwise.
       
   220      */ 
       
   221     TBool IsInCrL( const TDesC& aFolderName ) const;
       
   222 
       
   223     
       
   224 
       
   225 private:    // data
       
   226 
       
   227     TInt iId; ///< ID.
       
   228     CMenuEng& iEng; ///< Engine. DO NOT USE! Only needed to check ID-generator.
       
   229     RBuf iType; /// Type. Own.
       
   230     RMenuEngObjectAttrArray iAttributes; ///< Attributes. Own.
       
   231     TUint32 iFlags; ///< Flags.
       
   232     TBool iNative;	///< app is not of midlet/java type
       
   233 
       
   234     };
       
   235 
       
   236 #endif // __MENUENGOBJECT_H__