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