|
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 // INCLUDE FILES |
|
19 |
|
20 #include "menuenglegacyobjectfactory.h" |
|
21 #include "menuengobject.h" |
|
22 #include "menuengflags.h" |
|
23 #include "mcsmenuitem.h" |
|
24 |
|
25 // Legacy types |
|
26 _LIT( KLegacyTypeData, "appshell:data" ); |
|
27 _LIT( KLegacyTypeApp, "appshell:application" ); |
|
28 _LIT( KLegacyTypeUrl, "appshell:url" ); |
|
29 _LIT( KLegacyTypeFolder, "appshell:folder" ); |
|
30 |
|
31 // Legacy attributes. |
|
32 _LIT( KLegacyAttrLockDelete, "lock_delete" ); |
|
33 _LIT( KLegacyAttrLockName, "lock_name" ); |
|
34 _LIT( KLegacyAttrLockIcon, "lock_icon" ); |
|
35 _LIT( KLegacyAttrLockMoveInto, "lock_moveinto" ); |
|
36 _LIT( KLegacyAttrLockItem, "lock_item" ); |
|
37 |
|
38 // ================= MEMBER FUNCTIONS ======================= |
|
39 |
|
40 // --------------------------------------------------------- |
|
41 // CMenuEngLegacyObjectFactory::~CMenuEngLegacyObjectFactory |
|
42 // --------------------------------------------------------- |
|
43 // |
|
44 CMenuEngLegacyObjectFactory::~CMenuEngLegacyObjectFactory() |
|
45 { |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------- |
|
49 // CMenuEngLegacyObjectFactory::NewL |
|
50 // --------------------------------------------------------- |
|
51 // |
|
52 CMenuEngLegacyObjectFactory* CMenuEngLegacyObjectFactory::NewL( CMenuEng& aEng ) |
|
53 { |
|
54 CMenuEngLegacyObjectFactory* factory = |
|
55 new (ELeave) CMenuEngLegacyObjectFactory( aEng ); |
|
56 return factory; |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------- |
|
60 // CMenuEngLegacyObjectFactory::CMenuEngLegacyObjectFactory |
|
61 // --------------------------------------------------------- |
|
62 // |
|
63 CMenuEngLegacyObjectFactory::CMenuEngLegacyObjectFactory( CMenuEng& aEng ) |
|
64 : iEng( aEng ) |
|
65 { |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------- |
|
69 // CMenuEngLegacyObjectFactory::IsSupportedType |
|
70 // --------------------------------------------------------- |
|
71 // |
|
72 TBool CMenuEngLegacyObjectFactory::IsSupportedType( const TDesC& aLegacyTypeIdentifier ) const |
|
73 { |
|
74 TBool ret = EFalse; |
|
75 if( aLegacyTypeIdentifier.Compare( KLegacyTypeData ) == 0 || |
|
76 aLegacyTypeIdentifier.Compare( KLegacyTypeApp ) == 0 || |
|
77 aLegacyTypeIdentifier.Compare( KLegacyTypeUrl ) == 0 || |
|
78 aLegacyTypeIdentifier.Compare( KLegacyTypeFolder ) == 0 ) |
|
79 { |
|
80 ret = ETrue; |
|
81 } |
|
82 return ret; |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------- |
|
86 // CMenuEngLegacyObjectFactory::ConvertedType |
|
87 // --------------------------------------------------------- |
|
88 // |
|
89 TPtrC CMenuEngLegacyObjectFactory::ConvertedType( const TDesC& aLegacyTypeIdentifier ) const |
|
90 { |
|
91 TPtrC ret( KNullDesC ); |
|
92 if( aLegacyTypeIdentifier.Compare( KLegacyTypeData ) == 0 ) |
|
93 { |
|
94 ret.Set( KMenuTypeData ); |
|
95 } |
|
96 else if( aLegacyTypeIdentifier.Compare( KLegacyTypeApp ) == 0 ) |
|
97 { |
|
98 ret.Set( KMenuTypeApp ); |
|
99 } |
|
100 else if ( aLegacyTypeIdentifier.Compare( KLegacyTypeUrl ) == 0 ) |
|
101 { |
|
102 ret.Set( KMenuTypeUrl ); |
|
103 } |
|
104 else if ( aLegacyTypeIdentifier.Compare( KLegacyTypeFolder ) == 0 ) |
|
105 { |
|
106 ret.Set( KMenuTypeFolder ); |
|
107 } |
|
108 return ret; |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------- |
|
112 // CMenuEngLegacyObjectFactory::GetContentObjectAndSetContextL |
|
113 // --------------------------------------------------------- |
|
114 // |
|
115 CGECOObjectBase* CMenuEngLegacyObjectFactory::GetContentObjectAndSetContextL |
|
116 ( const TDesC& aTypeIdentifier ) |
|
117 { |
|
118 CMenuEngObject* object = 0; |
|
119 if ( !IsSupportedType( aTypeIdentifier ) ) |
|
120 { |
|
121 User::Leave( KErrNotSupported ); |
|
122 } |
|
123 object = CMenuEngObject::NewL( iEng, ConvertedType( aTypeIdentifier ) ); |
|
124 SetContext( object ); |
|
125 return object; |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------- |
|
129 // CMenuEngLegacyObjectFactory::InitializeObjectL |
|
130 // --------------------------------------------------------- |
|
131 // |
|
132 void CMenuEngLegacyObjectFactory::InitializeObjectL |
|
133 ( MGECOAttributeProvider& aAttributeProvider ) |
|
134 { |
|
135 if ( iContext ) |
|
136 { |
|
137 CMenuEngObject* context = (CMenuEngObject*)iContext; |
|
138 TPtrC name; |
|
139 TPtrC value; |
|
140 TBool localized; |
|
141 context->Reset(); |
|
142 const TInt count = aAttributeProvider.NumAttributes(); |
|
143 for ( TInt i = 0; i < count; i++ ) |
|
144 { |
|
145 aAttributeProvider.AttributeDetailsL( i, name, value, localized ); |
|
146 if ( KMenuAttrId() == name ) |
|
147 { |
|
148 // Legacy xml format does not support 'id'. Skip it. |
|
149 } |
|
150 else if ( KMenuAttrFlags() == name ) |
|
151 { |
|
152 // Legacy xml format does not support 'flags'. Skip it. |
|
153 } |
|
154 |
|
155 // Collect attributes that are handled as flags |
|
156 else if ( KLegacyAttrLockDelete() == name ) |
|
157 { |
|
158 context->SetFlags( TMenuItem::ELockDelete, ETrue ); |
|
159 } |
|
160 else if ( KLegacyAttrLockName() == name ) |
|
161 { |
|
162 context->SetFlags( TMenuItem::ELockName, ETrue ); |
|
163 } |
|
164 else if ( KLegacyAttrLockIcon() == name ) |
|
165 { |
|
166 context->SetFlags( TMenuItem::ELockIcon, ETrue ); |
|
167 } |
|
168 else if ( KLegacyAttrLockMoveInto() == name ) |
|
169 { |
|
170 context->SetFlags( TMenuItem::ELockMoveInto, ETrue ); |
|
171 } |
|
172 else if ( KLegacyAttrLockItem() == name ) |
|
173 { |
|
174 context->SetFlags( TMenuItem::ELockItem, ETrue ); |
|
175 } |
|
176 |
|
177 else |
|
178 { |
|
179 // Other attributes stored normally, in the object. |
|
180 context->SetInitialAttributeL( name, value, localized ); |
|
181 } |
|
182 } |
|
183 } |
|
184 } |
|
185 |
|
186 // --------------------------------------------------------- |
|
187 // CMenuEngLegacyObjectFactory::SetContext |
|
188 // --------------------------------------------------------- |
|
189 // |
|
190 TInt CMenuEngLegacyObjectFactory::SetContext( CGECOObjectBase* aContext ) |
|
191 { |
|
192 iContext = aContext; |
|
193 return KErrNone; |
|
194 } |
|
195 |
|
196 // --------------------------------------------------------- |
|
197 // CMenuEngLegacyObjectFactory::NumAttributes |
|
198 // --------------------------------------------------------- |
|
199 // |
|
200 TInt CMenuEngLegacyObjectFactory::NumAttributes() |
|
201 { |
|
202 // Do not support saving in legacy format - panic in debug build! |
|
203 __ASSERT_DEBUG( EFalse, User::Invariant() ); |
|
204 return 0; |
|
205 } |
|
206 |
|
207 // --------------------------------------------------------- |
|
208 // CMenuEngLegacyObjectFactory::AttributeDetailsL |
|
209 // --------------------------------------------------------- |
|
210 // |
|
211 void CMenuEngLegacyObjectFactory::AttributeDetailsL( |
|
212 const TInt /*aIndex*/, |
|
213 TPtrC& /*aAttrName*/, |
|
214 TPtrC& /*aAttrValue*/, |
|
215 TBool& /*aIsLocalized*/ ) |
|
216 { |
|
217 // Do not support saving in legacy format - panic in debug build! |
|
218 __ASSERT_DEBUG( EFalse, User::Invariant() ); |
|
219 } |
|
220 |
|
221 // --------------------------------------------------------- |
|
222 // CMenuEngLegacyObjectFactory::AttributeDetailsL |
|
223 // --------------------------------------------------------- |
|
224 // |
|
225 void CMenuEngLegacyObjectFactory::AttributeDetailsL( |
|
226 const TInt /*aIndex*/, |
|
227 TPtrC& /*aAttrName*/, |
|
228 TPtrC& /*aAttrValue*/ ) |
|
229 { |
|
230 // Do not support saving in legacy format - panic in debug build! |
|
231 __ASSERT_DEBUG( EFalse, User::Invariant() ); |
|
232 } |
|
233 |
|
234 // --------------------------------------------------------- |
|
235 // CMenuEngLegacyObjectFactory::HasTextData |
|
236 // --------------------------------------------------------- |
|
237 // |
|
238 TBool CMenuEngLegacyObjectFactory::HasTextData() |
|
239 { |
|
240 return EFalse; |
|
241 } |
|
242 |
|
243 // --------------------------------------------------------- |
|
244 // CMenuEngLegacyObjectFactory::TextDetailsL |
|
245 // --------------------------------------------------------- |
|
246 // |
|
247 void CMenuEngLegacyObjectFactory::TextDetailsL |
|
248 ( TPtrC& /*aText*/, TBool& /*aIsLocalized*/ ) |
|
249 { |
|
250 } |
|
251 |
|
252 // End of File |