author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:53:46 +0300 | |
branch | RCL_3 |
changeset 130 | 67f2ed48ad91 |
parent 122 | 6cadd6867c17 |
permissions | -rw-r--r-- |
114 | 1 |
/* |
2 |
* Copyright (c) 2009 - 2010 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: Application list for settings listbox |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include <aistrcnv.h> |
|
19 |
#include <mcsmenuitem.h> |
|
20 |
#include <mcsmenufilter.h> |
|
21 |
||
22 |
#include "mcspluginsettingsapplist.h" |
|
23 |
#include "mcspluginsettingsmodel.h" // For TSettingItem |
|
24 |
||
25 |
_LIT( KMyMenuData, "matrixmenudata" ); |
|
26 |
_LIT( KMenuTypeShortcut, "menu:shortcut" ); |
|
27 |
_LIT( KMenuTypeMailbox, "menu:mailbox" ); |
|
28 |
_LIT( KMenuAttrParameter, "param" ); |
|
29 |
_LIT( KMenuAttrLocked, "locked" ); |
|
30 |
_LIT8( KItemLocked, "locked"); |
|
31 |
_LIT8( KProperValueFolder, "folder" ); |
|
32 |
_LIT( KMenuAttrUndefUid, "0x99999991" ); |
|
33 |
_LIT( KMenuItemLongName, "long_name" ); |
|
34 |
||
35 |
#define KMCSCmailMtmUidValue 0x2001F406 |
|
36 |
||
37 |
// ======== MEMBER FUNCTIONS ======== |
|
38 |
||
39 |
// --------------------------------------------------------------------------- |
|
40 |
// First-phase construction |
|
41 |
// --------------------------------------------------------------------------- |
|
42 |
// |
|
43 |
CMCSPluginSettingsAppList::CMCSPluginSettingsAppList() |
|
44 |
{ |
|
45 |
} |
|
46 |
||
47 |
// --------------------------------------------------------------------------- |
|
48 |
// Second-phase construction |
|
49 |
// --------------------------------------------------------------------------- |
|
50 |
// |
|
51 |
void CMCSPluginSettingsAppList::ConstructL() |
|
52 |
{ |
|
53 |
iMsvSession = CMsvSession::OpenAsObserverL(*this); |
|
54 |
||
55 |
iMenu.OpenL( KMyMenuData ); |
|
56 |
||
130
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
57 |
// Get "Undefined" icon and text |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
58 |
CMenuFilter* filter = CMenuFilter::NewL(); |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
59 |
CleanupStack::PushL( filter ); |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
60 |
|
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
61 |
// 'Undefined' item |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
62 |
filter->HaveAttributeL( KMenuAttrUid, KMenuAttrUndefUid ); |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
63 |
|
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
64 |
TMenuItem item; |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
65 |
const TInt root = iMenu.RootFolderL(); |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
66 |
RArray<TMenuItem> items; |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
67 |
CleanupClosePushL( items ); |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
68 |
iMenu.GetItemsL( items, root, filter, ETrue ); |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
69 |
|
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
70 |
if ( items.Count() > 0 ) |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
71 |
{ |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
72 |
iUndefinedItem = CMenuItem::OpenL( iMenu, items[ 0 ] ); |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
73 |
iUndefinedText = NULL; |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
74 |
|
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
75 |
if ( iUndefinedItem ) |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
76 |
{ |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
77 |
TBool exists( KErrNotFound );//CleanupStack::PushL( undefinedItem ); |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
78 |
TPtrC undefined = iUndefinedItem->GetAttributeL( KMenuItemLongName, exists ); |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
79 |
|
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
80 |
if ( exists ) |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
81 |
{ |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
82 |
iUndefinedText = HBufC::NewMaxL( undefined.Length() ); |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
83 |
iUndefinedText->Des().Copy( undefined ); |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
84 |
} |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
85 |
else |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
86 |
{ |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
87 |
iUndefinedText = KNullDesC().Alloc(); |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
88 |
} |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
89 |
} |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
90 |
} |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
91 |
|
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
92 |
CleanupStack::PopAndDestroy( &items ); |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
93 |
CleanupStack::PopAndDestroy( filter ); |
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
94 |
} |
114 | 95 |
|
96 |
// --------------------------------------------------------------------------- |
|
97 |
// Two-phased constructor |
|
98 |
// --------------------------------------------------------------------------- |
|
99 |
// |
|
100 |
CMCSPluginSettingsAppList* CMCSPluginSettingsAppList::NewL() |
|
101 |
{ |
|
102 |
CMCSPluginSettingsAppList* self = new (ELeave) CMCSPluginSettingsAppList(); |
|
103 |
CleanupStack::PushL(self); |
|
104 |
self->ConstructL(); |
|
105 |
CleanupStack::Pop(self); |
|
106 |
return self; |
|
107 |
} |
|
108 |
||
109 |
// --------------------------------------------------------------------------- |
|
110 |
// Destructor |
|
111 |
// --------------------------------------------------------------------------- |
|
112 |
// |
|
113 |
CMCSPluginSettingsAppList::~CMCSPluginSettingsAppList() |
|
114 |
{ |
|
115 |
delete iMsvSession; |
|
116 |
||
117 |
iListItems.ResetAndDestroy(); |
|
118 |
iMenu.Close(); |
|
119 |
||
120 |
delete iUndefinedText; |
|
130
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
121 |
delete iUndefinedItem; |
114 | 122 |
} |
123 |
||
124 |
// --------------------------------------------------------------------------- |
|
125 |
// From MDesCArray |
|
126 |
// Returns the number of descriptor elements in a descriptor array. |
|
127 |
// --------------------------------------------------------------------------- |
|
128 |
// |
|
129 |
TInt CMCSPluginSettingsAppList::MdcaCount() const |
|
130 |
{ |
|
131 |
return iListItems.Count(); |
|
132 |
} |
|
133 |
||
134 |
// --------------------------------------------------------------------------- |
|
135 |
// From MDesCArray |
|
136 |
// Indexes into a descriptor array. |
|
137 |
// --------------------------------------------------------------------------- |
|
138 |
// |
|
139 |
TPtrC CMCSPluginSettingsAppList::MdcaPoint( TInt aIndex ) const |
|
140 |
{ |
|
141 |
if ( aIndex < 0 || aIndex >= iListItems.Count() ) |
|
142 |
{ |
|
143 |
TPtrC ret( KNullDesC ); |
|
144 |
return ret; |
|
145 |
} |
|
146 |
CMenuItem* item = iListItems[ aIndex ]; |
|
147 |
||
148 |
TBool attrExists; |
|
149 |
TPtrC itm( KNullDesC ); |
|
150 |
TRAP_IGNORE( |
|
151 |
itm.Set( item->GetAttributeL( KMenuAttrLongName, attrExists ) ); |
|
152 |
) |
|
153 |
||
154 |
return itm; |
|
155 |
} |
|
156 |
||
157 |
// --------------------------------------------------------------------------- |
|
158 |
// From class MMsvSessionObserver. |
|
159 |
// Handles an event from the message server. |
|
160 |
// --------------------------------------------------------------------------- |
|
161 |
// |
|
162 |
void CMCSPluginSettingsAppList::HandleSessionEventL( |
|
163 |
TMsvSessionEvent /*aEvent*/, |
|
164 |
TAny* /*aArg1*/, |
|
165 |
TAny* /*aArg2*/, |
|
166 |
TAny* /*aArg3*/ ) |
|
167 |
{ |
|
168 |
||
169 |
} |
|
170 |
||
171 |
// --------------------------------------------------------------------------- |
|
172 |
// Starts the asynchronous application list initialization. |
|
173 |
// --------------------------------------------------------------------------- |
|
174 |
// |
|
175 |
void CMCSPluginSettingsAppList::StartL() |
|
176 |
{ |
|
177 |
iListItems.ResetAndDestroy(); |
|
178 |
AddMailboxesL(); |
|
179 |
AddStaticItemsL(); |
|
180 |
} |
|
181 |
||
182 |
// --------------------------------------------------------------------------- |
|
183 |
// Iterates thru the application list and tries to find a menuitem which |
|
184 |
// matches given property map from HSPS |
|
185 |
// --------------------------------------------------------------------------- |
|
186 |
// |
|
187 |
TSettingItem CMCSPluginSettingsAppList::FindItemL( |
|
188 |
RPointerArray<HSPluginSettingsIf::CPropertyMap>& aProperties ) |
|
189 |
{ |
|
190 |
TBool attrExists( EFalse ); |
|
130
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
191 |
TSettingItem settingItem = { KErrNotFound, EApplication, EFalse }; |
114 | 192 |
TBool isFolder = EFalse; |
193 |
||
194 |
// check if the item is folder |
|
195 |
for ( TInt j = 0; j < aProperties.Count(); j++ ) |
|
196 |
{ |
|
197 |
if( aProperties[j]->Name() == KType ) |
|
198 |
{ |
|
199 |
if ( aProperties[j]->Value() == KProperValueFolder ) |
|
200 |
{ |
|
201 |
isFolder = ETrue; |
|
202 |
} |
|
203 |
break; |
|
204 |
} |
|
205 |
} |
|
206 |
||
207 |
TBool itemFound( EFalse ); |
|
208 |
||
209 |
// compare name/value pairs with every menu item in the list |
|
210 |
for ( TInt i = 0; i < iListItems.Count() && !itemFound; i++ ) |
|
211 |
{ |
|
212 |
TBool match( ETrue ); |
|
213 |
CMenuItem* item = iListItems[ i ]; |
|
214 |
for ( TInt j = 0; j < aProperties.Count() && match; j++ ) |
|
215 |
{ |
|
216 |
// type and locked properties skipped |
|
217 |
if ( aProperties[j]->Name() != KType && |
|
218 |
aProperties[j]->Name() != KItemLocked ) |
|
219 |
{ |
|
220 |
HBufC* attrName( NULL ); |
|
221 |
attrName = AiUtility::CopyToBufferL( attrName, |
|
222 |
aProperties[j]->Name()); |
|
223 |
CleanupStack::PushL( attrName ); |
|
224 |
TPtrC attr = item->GetAttributeL( *attrName, attrExists ); |
|
225 |
||
226 |
HBufC* attrValue( NULL ); |
|
227 |
attrValue = AiUtility::CopyToBufferL( attrValue, |
|
228 |
aProperties[j]->Value()); |
|
229 |
CleanupStack::PushL( attrValue ); |
|
230 |
||
231 |
// in case of folder, we just have to compare id |
|
232 |
// which is stored in param attribute |
|
233 |
if ( isFolder && *attrName == KMenuAttrParameter ) |
|
234 |
{ |
|
235 |
// convert id to integer |
|
236 |
TInt id; |
|
237 |
TLex16 lextmp( attrValue->Ptr() ); |
|
238 |
lextmp.Val( id ); |
|
239 |
||
240 |
if ( item->Id() != id ) |
|
241 |
{ |
|
242 |
match = EFalse; |
|
243 |
} |
|
244 |
CleanupStack::PopAndDestroy( attrValue ); |
|
245 |
CleanupStack::PopAndDestroy( attrName ); |
|
246 |
break; |
|
247 |
} |
|
248 |
||
249 |
// otherwise, compare attributes from HSPS and from menuitem |
|
250 |
// if there is no match, move to the next item in the list |
|
130
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
122
diff
changeset
|
251 |
if ( attr != *attrValue ) |
114 | 252 |
{ |
253 |
match = EFalse; |
|
254 |
} |
|
255 |
CleanupStack::PopAndDestroy( attrValue ); |
|
256 |
CleanupStack::PopAndDestroy( attrName ); |
|
257 |
} |
|
258 |
} |
|
259 |
||
260 |
if ( match ) |
|
261 |
{ |
|
262 |
settingItem.id = i; |
|
263 |
settingItem.type = EApplication; |
|
264 |
itemFound = ETrue; |
|
265 |
} |
|
266 |
} |
|
267 |
return settingItem; |
|
268 |
} |
|
269 |
||
270 |
// --------------------------------------------------------------------------- |
|
271 |
// Returns menuitems at given index. |
|
272 |
// --------------------------------------------------------------------------- |
|
273 |
// |
|
274 |
CMenuItem* CMCSPluginSettingsAppList::ItemL( const TInt& aIndex ) |
|
275 |
{ |
|
276 |
CMenuItem* menuItem( NULL ); |
|
277 |
// check if index is within the list boundaries |
|
278 |
if ( aIndex >= 0 && aIndex < iListItems.Count() ) |
|
279 |
{ |
|
280 |
menuItem = iListItems[ aIndex ]; |
|
281 |
} |
|
282 |
return menuItem; |
|
283 |
} |
|
284 |
||
285 |
// --------------------------------------------------------------------------- |
|
286 |
// Helper method for comparing names of two menuitems. Used to sort the list |
|
287 |
// of items. |
|
288 |
// --------------------------------------------------------------------------- |
|
289 |
// |
|
290 |
TInt CMCSPluginSettingsAppList::CompareNameL( const CMenuItem& aFirst, |
|
291 |
const CMenuItem& aSecond ) |
|
292 |
{ |
|
293 |
TBool exists( EFalse ); |
|
294 |
CMenuItem& first = const_cast<CMenuItem&>(aFirst); |
|
295 |
CMenuItem& second = const_cast<CMenuItem&>(aSecond); |
|
296 |
||
297 |
TPtrC name1 = first.GetAttributeL( KMenuAttrLongName, exists ); |
|
298 |
TPtrC name2 = second.GetAttributeL( KMenuAttrLongName, exists ); |
|
299 |
||
300 |
return name1.CompareC( name2 ); |
|
301 |
} |
|
302 |
||
303 |
// --------------------------------------------------------------------------- |
|
304 |
// Adds the static list items to the application list. |
|
305 |
// --------------------------------------------------------------------------- |
|
306 |
// |
|
307 |
void CMCSPluginSettingsAppList::AddStaticItemsL() |
|
308 |
{ |
|
309 |
TLinearOrder<CMenuItem> sortMethod( CMCSPluginSettingsAppList::CompareNameL ); |
|
310 |
||
311 |
CMenuFilter* filter = CMenuFilter::NewL(); |
|
312 |
CleanupStack::PushL( filter ); |
|
313 |
||
314 |
// skip locked items |
|
315 |
filter->DoNotHaveAttributeL( KMenuAttrLocked ); |
|
316 |
const TInt rootId = iMenu.RootFolderL(); |
|
317 |
RArray<TMenuItem> itemArray; |
|
318 |
CleanupClosePushL( itemArray ); |
|
319 |
iMenu.GetItemsL( itemArray, rootId, filter, ETrue ); |
|
320 |
||
321 |
TInt count( itemArray.Count() ); |
|
322 |
||
323 |
for ( TInt i = 0; i < count; i++ ) |
|
324 |
{ |
|
325 |
TPtrC type = itemArray[ i ].Type(); |
|
326 |
||
327 |
// we add applications, shortcuts and folders to the list |
|
328 |
if ( type == KMenuTypeApp || |
|
329 |
type == KMenuTypeShortcut || |
|
330 |
type == KMenuTypeFolder ) |
|
331 |
{ |
|
332 |
CMenuItem* menuItem = CMenuItem::OpenL( iMenu, itemArray[ i ] ); |
|
333 |
CleanupStack::PushL( menuItem ); |
|
334 |
||
335 |
// only non-hidden and non-missing items should be offered to the user |
|
336 |
if ( ( menuItem->Flags() & TMenuItem::EHidden ) == 0 && |
|
337 |
( menuItem->Flags() & TMenuItem::EMissing ) == 0 ) |
|
338 |
{ |
|
339 |
User::LeaveIfError( iListItems.InsertInOrderAllowRepeats( menuItem, sortMethod ) ); |
|
340 |
CleanupStack::Pop( menuItem ); |
|
341 |
} |
|
342 |
else |
|
343 |
{ |
|
344 |
CleanupStack::PopAndDestroy( menuItem ); |
|
345 |
} |
|
346 |
menuItem = NULL; |
|
347 |
} |
|
348 |
} |
|
349 |
||
350 |
CleanupStack::PopAndDestroy( &itemArray ); |
|
351 |
CleanupStack::PopAndDestroy( filter ); |
|
352 |
} |
|
353 |
||
354 |
||
355 |
// --------------------------------------------------------------------------- |
|
356 |
// Returns the root entry containing mailboxes. |
|
357 |
// --------------------------------------------------------------------------- |
|
358 |
// |
|
359 |
CMsvEntry* CMCSPluginSettingsAppList::GetRootEntryL() |
|
360 |
{ |
|
361 |
return iMsvSession->GetEntryL( KMsvRootIndexEntryIdValue ); |
|
362 |
} |
|
363 |
||
364 |
// --------------------------------------------------------------------------- |
|
365 |
// Adds remote mailboxes to the application list. |
|
366 |
// --------------------------------------------------------------------------- |
|
367 |
// |
|
368 |
void CMCSPluginSettingsAppList::AddMailboxesL() |
|
369 |
{ |
|
370 |
CMsvEntry* rootEntry = GetRootEntryL(); |
|
371 |
CleanupStack::PushL(rootEntry); |
|
372 |
TBuf<255> mailboxId; |
|
373 |
||
374 |
TInt cnt = rootEntry->Count(); |
|
375 |
if ( cnt > 0 ) |
|
376 |
{ |
|
377 |
rootEntry->SetSortTypeL( TMsvSelectionOrdering( |
|
378 |
KMsvGroupByType | KMsvGroupByStandardFolders, |
|
379 |
EMsvSortByDetailsReverse, ETrue ) ); |
|
380 |
||
381 |
for ( TInt i = rootEntry->Count(); --i >= 0; ) |
|
382 |
{ |
|
383 |
const TMsvEntry& tentry = (*rootEntry)[i]; |
|
384 |
||
385 |
if (tentry.iMtm.iUid == KMCSCmailMtmUidValue ) |
|
386 |
{ |
|
387 |
mailboxId.Num( tentry.Id() ); |
|
388 |
AddMailboxL( tentry.iDetails, mailboxId ); |
|
389 |
} |
|
390 |
} |
|
391 |
} |
|
392 |
CleanupStack::PopAndDestroy(rootEntry); |
|
393 |
} |
|
394 |
||
395 |
// --------------------------------------------------------------------------- |
|
396 |
// Adds a mailbox to the list. |
|
397 |
// --------------------------------------------------------------------------- |
|
398 |
// |
|
399 |
void CMCSPluginSettingsAppList::AddMailboxL( const TDesC& aMailbox, |
|
400 |
const TDesC& aMailboxId ) |
|
401 |
{ |
|
402 |
TLinearOrder<CMenuItem> sortMethod( CMCSPluginSettingsAppList::CompareNameL ); |
|
403 |
CMenuItem* newItem = CMenuItem::CreateL( iMenu, KMenuTypeMailbox, 0, 0 ); |
|
404 |
CleanupStack::PushL( newItem ); |
|
405 |
||
406 |
// mailbox is a shortcut item with "mailbox:mailboxID" parameter |
|
407 |
newItem->SetAttributeL( KMenuAttrUid, aMailboxId ); |
|
408 |
newItem->SetAttributeL( KMenuAttrLongName, aMailbox ); |
|
409 |
// Mailbox name is saved to settings into param field. |
|
410 |
newItem->SetAttributeL( KMenuAttrParameter, aMailbox ); |
|
411 |
||
412 |
// append the item into iListItems lists |
|
413 |
User::LeaveIfError( iListItems.InsertInOrderAllowRepeats( newItem, sortMethod ) ); |
|
414 |
CleanupStack::Pop( newItem ); |
|
415 |
} |
|
416 |
||
417 |
// End of File. |