114
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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 <e32cmn.h>
|
|
19 |
#include <liwcommon.h>
|
|
20 |
#include <liwgenericparam.h>
|
|
21 |
#include "mcsgetlistcreatorinterface.h"
|
|
22 |
#include "menusrveng.h"
|
|
23 |
|
|
24 |
// ---------------------------------------------------------
|
|
25 |
// CMcsGetListCreatorInterface::~CMcsGetListCreatorInterface
|
|
26 |
// ---------------------------------------------------------
|
|
27 |
//
|
|
28 |
CMcsGetListCreatorInterface::~CMcsGetListCreatorInterface()
|
|
29 |
{
|
|
30 |
}
|
|
31 |
|
|
32 |
// ---------------------------------------------------------
|
|
33 |
// CMcsGetListCreatorInterface::CMcsGetListCreatorInterface
|
|
34 |
// ---------------------------------------------------------
|
|
35 |
//
|
|
36 |
CMcsGetListCreatorInterface::CMcsGetListCreatorInterface( CMenuSrvEng& aEng ):
|
|
37 |
iEng( aEng )
|
|
38 |
{
|
|
39 |
}
|
|
40 |
|
|
41 |
// ---------------------------------------------------------
|
|
42 |
// CMcsGetListCreatorInterface::ConstructL
|
|
43 |
// ---------------------------------------------------------
|
|
44 |
//
|
|
45 |
void CMcsGetListCreatorInterface::ConstructL()
|
|
46 |
{
|
|
47 |
}
|
|
48 |
|
|
49 |
// ---------------------------------------------------------
|
|
50 |
// CMcsGetListCreatorInterface::BuildMapL
|
|
51 |
// ---------------------------------------------------------
|
|
52 |
//
|
|
53 |
void CMcsGetListCreatorInterface::BuildMapL(
|
|
54 |
const TMenuItem& aMenuItem, CDesC16Array* aRequiredAttributes,
|
|
55 |
CDesC16Array* aIgnoredAttributes, CLiwDefaultMap* aMap )
|
|
56 |
{
|
|
57 |
SetItemIdL( aMenuItem.Id() );
|
|
58 |
AddFundamentalAttributesL( aMenuItem, aMap );
|
|
59 |
|
|
60 |
if( aRequiredAttributes->MdcaCount() &&
|
|
61 |
aIgnoredAttributes->MdcaCount() == KErrNone )
|
|
62 |
{
|
|
63 |
AddRequiredAttributesL( aMenuItem, aRequiredAttributes, aMap );
|
|
64 |
}
|
|
65 |
else if( aIgnoredAttributes->MdcaCount() &&
|
|
66 |
aRequiredAttributes->MdcaCount() == KErrNone )
|
|
67 |
{
|
|
68 |
AddAttributesWithoutIgnoredL( aMenuItem, aIgnoredAttributes, aMap );
|
|
69 |
}
|
|
70 |
else if( aRequiredAttributes->MdcaCount() )
|
|
71 |
{
|
|
72 |
AddRequiredAttributesWithoutIgnoredL( aMenuItem, aRequiredAttributes,
|
|
73 |
aIgnoredAttributes, aMap );
|
|
74 |
}
|
|
75 |
else
|
|
76 |
{
|
|
77 |
AddAllAttributesL( aMenuItem, aMap );
|
|
78 |
}
|
|
79 |
}
|
|
80 |
|
|
81 |
// ---------------------------------------------------------
|
|
82 |
// CMcsGetListCreatorInterface::AddFundamentalAttributesL
|
|
83 |
// ---------------------------------------------------------
|
|
84 |
//
|
|
85 |
void CMcsGetListCreatorInterface::AddFundamentalAttributesL(
|
|
86 |
const TMenuItem& aMenuItem, CLiwDefaultMap* aMap )
|
|
87 |
{
|
|
88 |
aMap->InsertL( KMenuAttrId8, TLiwVariant( (TInt32)aMenuItem.Id() ) );
|
|
89 |
|
|
90 |
aMap->InsertL( KType, TLiwVariant( aMenuItem.Type() ) );
|
|
91 |
aMap->InsertL( KMenuParentId, TLiwVariant( (TInt32)aMenuItem.Parent() ) );
|
|
92 |
|
|
93 |
// Flags
|
|
94 |
TInt flag = aMenuItem.Flags();
|
|
95 |
TInt flagvalue = ( flag & TMenuItem::ELockDelete )? 1 : 0;
|
|
96 |
|
|
97 |
aMap->InsertL( KDeleteLocked, TLiwVariant( (TBool)flagvalue) );
|
|
98 |
|
|
99 |
flagvalue = ( flag & TMenuItem::ELockName )? 1 : 0;
|
|
100 |
aMap->InsertL( KNameLocked, TLiwVariant( (TBool)flagvalue) );
|
|
101 |
|
|
102 |
flagvalue = ( flag & TMenuItem::ELockIcon )? 1 : 0;
|
|
103 |
aMap->InsertL( KIconLocked, TLiwVariant( (TBool)flagvalue) );
|
|
104 |
|
|
105 |
flagvalue = ( flag & TMenuItem::ELockMoveInto )? 1 : 0;
|
|
106 |
aMap->InsertL( KAddingLocked, TLiwVariant( (TBool)flagvalue) );
|
|
107 |
|
|
108 |
flagvalue = ( flag & TMenuItem::ELockItem )? 1 : 0;
|
|
109 |
aMap->InsertL( KMoveLocked, TLiwVariant( (TBool)flagvalue) );
|
|
110 |
|
|
111 |
flagvalue = ( flag & TMenuItem::EHidden )? 1 : 0;
|
|
112 |
aMap->InsertL( KHidden, TLiwVariant( (TBool)flagvalue) );
|
|
113 |
|
|
114 |
flagvalue = ( flag & TMenuItem::EMissing )? 1 : 0;
|
|
115 |
aMap->InsertL( KMissing, TLiwVariant( (TBool)flagvalue) );
|
|
116 |
}
|
|
117 |
|
|
118 |
// ---------------------------------------------------------
|
|
119 |
// CMcsGetListCreatorInterface::AddRequiredAttributesL
|
|
120 |
// ---------------------------------------------------------
|
|
121 |
//
|
|
122 |
void CMcsGetListCreatorInterface::AddRequiredAttributesL( const TMenuItem& aMenuItem,
|
|
123 |
CDesC16Array* aRequiredAttributes, CLiwDefaultMap* aMap )
|
|
124 |
{
|
|
125 |
TBool exists = EFalse;
|
|
126 |
TBuf<KMenuMaxAttrNameLen> running;
|
|
127 |
running.Copy( KRunning );
|
|
128 |
TBuf<KMenuMaxAttrNameLen> bitmap;
|
|
129 |
bitmap.Copy( KBitmapBuffer );
|
|
130 |
TBuf<KMenuMaxAttrNameLen> mask;
|
|
131 |
mask.Copy( KMaskBuffer );
|
|
132 |
TBool findBitmap( EFalse );
|
|
133 |
TBool findMask( EFalse );
|
|
134 |
|
|
135 |
RBuf attrvalue;
|
|
136 |
attrvalue.CreateL( KMenuMaxAttrValueLen );
|
|
137 |
CleanupClosePushL( attrvalue );
|
|
138 |
|
|
139 |
for( TInt i= 0; i < aRequiredAttributes->MdcaCount(); i++ )
|
|
140 |
{
|
|
141 |
if( aRequiredAttributes->MdcaPoint(i).Compare( running ) == KErrNone )
|
|
142 |
{
|
|
143 |
if ( aMenuItem.Type() == KMenuTypeApp() ||
|
|
144 |
aMenuItem.Type() == KMenuTypeFolder() )
|
|
145 |
{
|
|
146 |
iEng.GetAttributeL( iId, KRunningStatus, exists, attrvalue );
|
|
147 |
aMap->InsertL( KRunning, TLiwVariant( exists ) );
|
|
148 |
}
|
|
149 |
}
|
|
150 |
else if( aRequiredAttributes->MdcaPoint(i).Compare( bitmap ) == KErrNone )
|
|
151 |
{
|
|
152 |
findBitmap = ETrue;
|
|
153 |
}
|
|
154 |
else if( aRequiredAttributes->MdcaPoint(i).Compare( mask ) == KErrNone )
|
|
155 |
{
|
|
156 |
findMask = ETrue;
|
|
157 |
}
|
|
158 |
else
|
|
159 |
{
|
|
160 |
iEng.GetAttributeL(
|
|
161 |
iId, aRequiredAttributes->MdcaPoint(i), exists, attrvalue );
|
|
162 |
|
|
163 |
if( exists )
|
|
164 |
{
|
|
165 |
TBuf8<KMenuMaxAttrNameLen> attrname;
|
|
166 |
attrname.Copy( aRequiredAttributes->MdcaPoint(i) );
|
|
167 |
aMap->InsertL( attrname, TLiwVariant( attrvalue ) );
|
|
168 |
}
|
|
169 |
}
|
|
170 |
}
|
|
171 |
if( findBitmap && findMask )
|
|
172 |
{
|
|
173 |
CLiwDefaultMap* iconAttrMap = CLiwDefaultMap::NewLC();
|
|
174 |
FillIconAttributesMapL( aMenuItem, iconAttrMap );
|
|
175 |
aMap->InsertL( KIconAttributes, TLiwVariant( iconAttrMap ) );
|
|
176 |
CleanupStack::PopAndDestroy( iconAttrMap );
|
|
177 |
}
|
|
178 |
CleanupStack::PopAndDestroy( &attrvalue );
|
|
179 |
}
|
|
180 |
|
|
181 |
// ---------------------------------------------------------
|
|
182 |
// CMcsGetListCreatorInterface::AddAttributesWithoutIgnoredL
|
|
183 |
// ---------------------------------------------------------
|
|
184 |
//
|
|
185 |
void CMcsGetListCreatorInterface::AddAttributesWithoutIgnoredL( const TMenuItem& aMenuItem,
|
|
186 |
CDesC16Array* aIgnoredAttributes, CLiwDefaultMap* aMap )
|
|
187 |
{
|
|
188 |
TBool exists = EFalse;
|
|
189 |
TInt pos( KErrNotFound );
|
|
190 |
|
|
191 |
RBuf attrvalue;
|
|
192 |
attrvalue.CreateL( KMenuMaxAttrValueLen );
|
|
193 |
CleanupClosePushL( attrvalue );
|
|
194 |
|
|
195 |
if ( aMenuItem.Type() == KMenuTypeApp()
|
|
196 |
|| aMenuItem.Type() == KMenuTypeFolder() )
|
|
197 |
{
|
|
198 |
TBuf<KMenuMaxAttrNameLen> running;
|
|
199 |
running.Copy( KRunning );
|
|
200 |
if( aIgnoredAttributes->Find( running, pos ) != KErrNone )
|
|
201 |
{
|
|
202 |
iEng.GetAttributeL( iId, KRunningStatus, exists, attrvalue );
|
|
203 |
aMap->InsertL( KRunning, TLiwVariant( exists ) );
|
|
204 |
}
|
|
205 |
}
|
|
206 |
|
|
207 |
RArray<TPtrC> attrNameList;
|
|
208 |
CleanupClosePushL(attrNameList);
|
|
209 |
iEng.GetAttributeListL( aMenuItem.Id(), attrNameList );
|
|
210 |
|
|
211 |
for( TInt i = 0; i< attrNameList.Count(); i++ )
|
|
212 |
{
|
|
213 |
if( aIgnoredAttributes->Find( attrNameList[i], pos ) != KErrNone )
|
|
214 |
{
|
|
215 |
iEng.GetAttributeL( iId, attrNameList[i], exists, attrvalue );
|
|
216 |
if( exists )
|
|
217 |
{
|
|
218 |
TBuf8<KMenuMaxAttrNameLen> attrname;
|
|
219 |
attrname.Copy( attrNameList[i] );
|
|
220 |
aMap->InsertL( attrname, TLiwVariant( attrvalue ) );
|
|
221 |
}
|
|
222 |
}
|
|
223 |
}
|
|
224 |
TBuf<KMenuMaxAttrNameLen> bitmap;
|
|
225 |
bitmap.Copy( KBitmapBuffer );
|
|
226 |
TBuf<KMenuMaxAttrNameLen> mask;
|
|
227 |
mask.Copy( KMaskBuffer );
|
|
228 |
if( aIgnoredAttributes->Find( bitmap, pos ) != KErrNone
|
|
229 |
&& aIgnoredAttributes->Find( mask, pos ) != KErrNone )
|
|
230 |
{
|
|
231 |
CLiwDefaultMap* iconAttrMap = CLiwDefaultMap::NewLC();
|
|
232 |
FillIconAttributesMapL( aMenuItem, iconAttrMap );
|
|
233 |
aMap->InsertL( KIconAttributes, TLiwVariant( iconAttrMap ) );
|
|
234 |
CleanupStack::PopAndDestroy( iconAttrMap );
|
|
235 |
}
|
|
236 |
|
|
237 |
CleanupStack::PopAndDestroy(&attrNameList);
|
|
238 |
|
|
239 |
CleanupStack::PopAndDestroy( &attrvalue );
|
|
240 |
}
|
|
241 |
|
|
242 |
// ---------------------------------------------------------
|
|
243 |
// CMcsGetListCreatorInterface::AddRequiredAttributesWithoutIgnoredL
|
|
244 |
// ---------------------------------------------------------
|
|
245 |
//
|
|
246 |
void CMcsGetListCreatorInterface::AddRequiredAttributesWithoutIgnoredL(
|
|
247 |
const TMenuItem& aMenuItem, CDesC16Array* aRequiredAttributes,
|
|
248 |
CDesC16Array* aIgnoredAttributes, CLiwDefaultMap* aMap )
|
|
249 |
{
|
|
250 |
TInt pos( KErrNotFound );
|
|
251 |
TBool exists = EFalse;
|
|
252 |
TBuf<KMenuMaxAttrNameLen> running;
|
|
253 |
running.Copy( KRunning );
|
|
254 |
TBuf<KMenuMaxAttrNameLen> bitmap;
|
|
255 |
bitmap.Copy( KBitmapBuffer );
|
|
256 |
TBuf<KMenuMaxAttrNameLen> mask;
|
|
257 |
mask.Copy( KMaskBuffer );
|
|
258 |
TBool findBitmap( EFalse );
|
|
259 |
TBool findMask( EFalse );
|
|
260 |
|
|
261 |
RBuf attrvalue;
|
|
262 |
attrvalue.CreateL( KMenuMaxAttrValueLen );
|
|
263 |
CleanupClosePushL( attrvalue );
|
|
264 |
|
|
265 |
for( TInt i= 0; i < aRequiredAttributes->MdcaCount(); i++ )
|
|
266 |
{
|
|
267 |
if( aRequiredAttributes->MdcaPoint(i).Compare( running ) == KErrNone
|
|
268 |
&& aIgnoredAttributes->Find( running, pos ) != KErrNone )
|
|
269 |
{
|
|
270 |
if ( aMenuItem.Type() == KMenuTypeApp() || aMenuItem.Type() == KMenuTypeFolder() )
|
|
271 |
{
|
|
272 |
iEng.GetAttributeL( iId, KRunningStatus, exists, attrvalue );
|
|
273 |
aMap->InsertL( KRunning, TLiwVariant( exists ) );
|
|
274 |
}
|
|
275 |
}
|
|
276 |
else if( aRequiredAttributes->MdcaPoint(i).Compare( bitmap ) == KErrNone
|
|
277 |
&& aIgnoredAttributes->Find( bitmap, pos ) != KErrNone )
|
|
278 |
{
|
|
279 |
findBitmap = ETrue;
|
|
280 |
}
|
|
281 |
else if( aRequiredAttributes->MdcaPoint(i).Compare( mask ) == KErrNone
|
|
282 |
&& aIgnoredAttributes->Find( mask, pos ) != KErrNone )
|
|
283 |
{
|
|
284 |
findMask = ETrue;
|
|
285 |
}
|
|
286 |
else if( aIgnoredAttributes->Find( aRequiredAttributes->MdcaPoint(i), pos ) != KErrNone )
|
|
287 |
{
|
|
288 |
iEng.GetAttributeL(
|
|
289 |
iId, aRequiredAttributes->MdcaPoint(i), exists, attrvalue );
|
|
290 |
if( exists )
|
|
291 |
{
|
|
292 |
TBuf8<KMenuMaxAttrNameLen> attrname;
|
|
293 |
attrname.Copy( aRequiredAttributes->MdcaPoint(i) );
|
|
294 |
aMap->InsertL( attrname, TLiwVariant( attrvalue ) );
|
|
295 |
}
|
|
296 |
}
|
|
297 |
}
|
|
298 |
if( findBitmap && findMask )
|
|
299 |
{
|
|
300 |
CLiwDefaultMap* iconAttrMap = CLiwDefaultMap::NewLC();
|
|
301 |
FillIconAttributesMapL( aMenuItem, iconAttrMap );
|
|
302 |
aMap->InsertL( KIconAttributes, TLiwVariant( iconAttrMap ) );
|
|
303 |
CleanupStack::PopAndDestroy( iconAttrMap );
|
|
304 |
}
|
|
305 |
CleanupStack::PopAndDestroy( &attrvalue );
|
|
306 |
}
|
|
307 |
|
|
308 |
// ---------------------------------------------------------
|
|
309 |
// CMcsGetListCreatorInterface::AddAllAttributesL
|
|
310 |
// ---------------------------------------------------------
|
|
311 |
//
|
|
312 |
void CMcsGetListCreatorInterface::AddAllAttributesL(
|
|
313 |
const TMenuItem& aMenuItem, CLiwDefaultMap* aMap )
|
|
314 |
{
|
|
315 |
TBool exists = EFalse;
|
|
316 |
RBuf attrvalue;
|
|
317 |
attrvalue.CreateL( KMenuMaxAttrValueLen );
|
|
318 |
CleanupClosePushL( attrvalue );
|
|
319 |
|
|
320 |
if ( aMenuItem.Type() == KMenuTypeApp() ||
|
|
321 |
aMenuItem.Type() == KMenuTypeFolder() )
|
|
322 |
{
|
|
323 |
iEng.GetAttributeL( iId, KRunningStatus, exists, attrvalue );
|
|
324 |
aMap->InsertL( KRunning, TLiwVariant( exists ) );
|
|
325 |
}
|
|
326 |
RArray<TPtrC> attrNameList;
|
|
327 |
CleanupClosePushL(attrNameList);
|
|
328 |
iEng.GetAttributeListL( aMenuItem.Id(), attrNameList );
|
|
329 |
|
|
330 |
for(TInt i = 0;i< attrNameList.Count();i++)
|
|
331 |
{
|
|
332 |
TBuf8<KMenuMaxAttrNameLen> attrname;
|
|
333 |
attrname.Copy( attrNameList[i] );
|
|
334 |
iEng.GetAttributeL( iId, attrNameList[i], exists, attrvalue );
|
|
335 |
if(exists)
|
|
336 |
{
|
|
337 |
attrname.Copy(attrNameList[i]);
|
|
338 |
aMap->InsertL( attrname, TLiwVariant( attrvalue ) );
|
|
339 |
}
|
|
340 |
}
|
|
341 |
CLiwDefaultMap* iconAttrMap = CLiwDefaultMap::NewLC();
|
|
342 |
FillIconAttributesMapL( aMenuItem, iconAttrMap );
|
|
343 |
aMap->InsertL( KIconAttributes, TLiwVariant( iconAttrMap ) );
|
|
344 |
CleanupStack::PopAndDestroy( iconAttrMap );
|
|
345 |
CleanupStack::PopAndDestroy(&attrNameList);
|
|
346 |
CleanupStack::PopAndDestroy( &attrvalue );
|
|
347 |
}
|
|
348 |
|
|
349 |
// ---------------------------------------------------------
|
|
350 |
// CMcsGetListCreatorInterface::FillIconAttributesMapL
|
|
351 |
// ---------------------------------------------------------
|
|
352 |
//
|
|
353 |
void CMcsGetListCreatorInterface::FillIconAttributesMapL(
|
|
354 |
const TMenuItem& aMenuItem, CLiwDefaultMap* aMap )
|
|
355 |
{
|
|
356 |
|
|
357 |
if ( aMenuItem.Type() == KMenuTypeApp())
|
|
358 |
{
|
|
359 |
AppendAttrL( KMenuAttrUid, aMap );
|
|
360 |
AppendAttrL( KMenuAttrNative, aMap );
|
|
361 |
}
|
|
362 |
else if ( aMenuItem.Type() == KMenuTypeFolder() )
|
|
363 |
{
|
|
364 |
AppendAttrL( KChildrenCount, aMap );
|
|
365 |
}
|
|
366 |
AppendAttrL( KMenuAttrIconSkinMajorId, aMap );
|
|
367 |
AppendAttrL( KMenuAttrIconSkinMinorId, aMap );
|
|
368 |
AppendAttrL( KMenuAttrIconFile, aMap );
|
|
369 |
AppendAttrL( KMenuAttrIconId, aMap );
|
|
370 |
AppendAttrL( KMenuAttrMaskId, aMap );
|
|
371 |
}
|
|
372 |
|
|
373 |
// ---------------------------------------------------------
|
|
374 |
// CMcsGetListCreatorInterface::AppendAttrL
|
|
375 |
// ---------------------------------------------------------
|
|
376 |
//
|
|
377 |
void CMcsGetListCreatorInterface::AppendAttrL(
|
|
378 |
const TDesC& aAttrName, CLiwDefaultMap* aMap )
|
|
379 |
{
|
|
380 |
TBool exists;
|
|
381 |
TBuf8<KMenuMaxAttrNameLen> attrName;
|
|
382 |
RBuf attrvalue;
|
|
383 |
attrvalue.CreateL( KMenuMaxAttrValueLen );
|
|
384 |
CleanupClosePushL( attrvalue );
|
|
385 |
iEng.GetAttributeL( iId, aAttrName, exists, attrvalue );
|
|
386 |
if ( exists )
|
|
387 |
{
|
|
388 |
attrName.Copy( aAttrName );
|
|
389 |
aMap->InsertL(attrName, TLiwVariant( attrvalue ) );
|
|
390 |
}
|
|
391 |
CleanupStack::PopAndDestroy( &attrvalue );
|
|
392 |
}
|
|
393 |
|
|
394 |
// ---------------------------------------------------------
|
|
395 |
// CMcsGetListCreatorInterface::SetGetterStrategyL
|
|
396 |
// ---------------------------------------------------------
|
|
397 |
//
|
|
398 |
void CMcsGetListCreatorInterface::SetItemIdL( TInt aId )
|
|
399 |
{
|
|
400 |
iId = aId;
|
|
401 |
}
|
|
402 |
// End of File
|