60
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 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 |
* Item array for the message items to be displayed by mce.
|
|
16 |
* Main view items are kept in memory (CArrayFixFlat<TMceListItem>) when created but
|
|
17 |
* Message view list items are fetched from the msgs when needed in MdcaPoint function
|
|
18 |
*
|
|
19 |
*/
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
// INCLUDE FILES
|
|
24 |
|
|
25 |
#include <AknUtils.h> // AknTextUtils
|
|
26 |
#include <mtudcbas.h>
|
|
27 |
#include <msvids.h>
|
|
28 |
#include <NpdApi.h> // CNotepadApi
|
|
29 |
#include "MtmRegistryObserver.h" // MMtmUiDataRegistryObserver
|
|
30 |
#include <StringLoader.h> // StringLoader
|
|
31 |
#include <mce.rsg>
|
|
32 |
#include <SenduiMtmUids.h> // mtm uids
|
|
33 |
#include <eikenv.h>
|
|
34 |
#include <gulicon.h>
|
|
35 |
#include <e32property.h>
|
|
36 |
|
|
37 |
#include "MceOneRowMessageListArray.h"
|
|
38 |
#include "MceLogText.h"
|
|
39 |
|
|
40 |
#include <MTMStore.h>
|
|
41 |
#include <commonphoneparser.h>
|
|
42 |
|
|
43 |
#include <aknappui.h>
|
|
44 |
#include <akncontext.h>
|
|
45 |
#include <aknconsts.h>
|
|
46 |
#include <e32math.h>
|
|
47 |
|
|
48 |
#include <bldvariant.hrh>
|
|
49 |
#include <featmgr.h>
|
|
50 |
#include <NumberGrouping.h>
|
|
51 |
#include <mmsconst.h>
|
|
52 |
#include <mmsgenutils.h>
|
|
53 |
#include <mmsclient.h>
|
|
54 |
#include <mtclreg.h>
|
|
55 |
#include <muiu.mbg>
|
|
56 |
|
|
57 |
// security data caging
|
|
58 |
#include <data_caging_path_literals.hrh>
|
|
59 |
#include <miutset.h>
|
|
60 |
#include <msvapi.h>
|
|
61 |
|
|
62 |
#include "MceCommands.hrh"
|
|
63 |
#include "MceOneRowMessageListArrayLoader.h"
|
|
64 |
#include <smuthdr.h>
|
|
65 |
#include <messaginginternalpskeys.h>
|
|
66 |
|
|
67 |
|
|
68 |
// CONSTANTS
|
|
69 |
|
|
70 |
// LOCAL CONSTANTS AND MACROS
|
|
71 |
const TInt KMceTimeHours = 23;
|
|
72 |
const TInt KMceTimeMinutes = 59;
|
|
73 |
const TInt KMceTimeSeconds = 59;
|
|
74 |
const TInt KMceTimeMicroSeconds = 999999;
|
|
75 |
const TInt KMceTimeOneDay = 1;
|
|
76 |
const TInt KMceTimeOneWeek = 7;
|
|
77 |
const TUid KUidMsvMessageListSortOrder = {0x10005359};
|
|
78 |
|
|
79 |
_LIT( KSortSubjectSkipString, "*:*" );
|
|
80 |
const TChar KWhiteSpaceCharacter(' ');
|
|
81 |
const TInt KSortSubjectStringLength = 100;
|
|
82 |
const TInt KMceLoopCounter = 200;
|
|
83 |
const TInt KFirstTimeMceLoopCounter = 20;
|
|
84 |
//cmail update
|
|
85 |
#define KUidMsgTypeCmailMtmVal 0x2001F406
|
|
86 |
|
|
87 |
// ================= MEMBER FUNCTIONS =======================
|
|
88 |
|
|
89 |
|
|
90 |
// ----------------------------------------------------
|
|
91 |
// CMceOneRowListItemArrayLoader::NewL
|
|
92 |
// ----------------------------------------------------
|
|
93 |
CMceOneRowListItemArrayLoader* CMceOneRowListItemArrayLoader::NewL(
|
|
94 |
CMsvSessionPtr aSession )
|
|
95 |
{
|
|
96 |
return CMceOneRowListItemArrayLoader::NewL(
|
|
97 |
0x1002, //KMsvGlobalInBoxIndexEntryId,
|
|
98 |
aSession );
|
|
99 |
}
|
|
100 |
|
|
101 |
|
|
102 |
// ----------------------------------------------------
|
|
103 |
// CMceOneRowListItemArrayLoader::NewL
|
|
104 |
// ----------------------------------------------------
|
|
105 |
CMceOneRowListItemArrayLoader* CMceOneRowListItemArrayLoader::NewL(
|
|
106 |
TMsvId aFolderId,
|
|
107 |
CMsvSessionPtr aSession )
|
|
108 |
{
|
|
109 |
CMceOneRowListItemArrayLoader* self = new (ELeave) CMceOneRowListItemArrayLoader( aSession );
|
|
110 |
CleanupStack::PushL( self );
|
|
111 |
self->ConstructL( aFolderId );
|
|
112 |
CleanupStack::Pop( self );
|
|
113 |
return self;
|
|
114 |
}
|
|
115 |
|
|
116 |
|
|
117 |
// ----------------------------------------------------
|
|
118 |
// C++ default constructor can NOT contain any code that
|
|
119 |
// might leave.
|
|
120 |
// ----------------------------------------------------
|
|
121 |
CMceOneRowListItemArrayLoader::CMceOneRowListItemArrayLoader(
|
|
122 |
CMsvSessionPtr aSession )
|
|
123 |
: CActive( CActive::EPriorityIdle ),
|
|
124 |
iListType( EHCListTypeTime ),
|
|
125 |
iSession( aSession ),
|
|
126 |
iEmailFramework(EFalse)
|
|
127 |
{
|
|
128 |
}
|
|
129 |
|
|
130 |
|
|
131 |
// ----------------------------------------------------
|
|
132 |
// destructor
|
|
133 |
// ----------------------------------------------------
|
|
134 |
CMceOneRowListItemArrayLoader::~CMceOneRowListItemArrayLoader()
|
|
135 |
{
|
|
136 |
iHCListItemArray.Close();
|
|
137 |
if ( &iSession )
|
|
138 |
{
|
|
139 |
iSession->RemoveObserver( *this );
|
|
140 |
}
|
|
141 |
Cancel();
|
|
142 |
delete iFolderEntry;
|
|
143 |
delete iEntriesToBeAdded;
|
|
144 |
delete iEntriesReceivedDuringListCreation;
|
|
145 |
if ( iEmailFramework )
|
|
146 |
{
|
|
147 |
delete iCmailSelectionList ;
|
|
148 |
}
|
|
149 |
iMarkedArray.Close();
|
|
150 |
}
|
|
151 |
|
|
152 |
|
|
153 |
// ----------------------------------------------------
|
|
154 |
// CMceOneRowListItemArrayLoader::ConstructL
|
|
155 |
// ----------------------------------------------------
|
|
156 |
void CMceOneRowListItemArrayLoader::ConstructL(
|
|
157 |
TMsvId aFolderId )
|
|
158 |
{
|
|
159 |
iSession->AddObserverL( *this );
|
|
160 |
FeatureManager::InitializeLibL();
|
|
161 |
if ( FeatureManager::FeatureSupported( KFeatureIdFfEmailFramework ) )
|
|
162 |
{
|
|
163 |
iEmailFramework = ETrue;
|
|
164 |
}
|
|
165 |
|
|
166 |
FeatureManager::UnInitializeLib();
|
|
167 |
iFolderEntry = CMsvEntry::NewL(
|
|
168 |
*iSession,
|
|
169 |
aFolderId,
|
|
170 |
TMsvSelectionOrdering(
|
|
171 |
KMsvGroupByStandardFolders, EMsvSortByDateReverse ));
|
|
172 |
CActiveScheduler::Add( this );
|
|
173 |
}
|
|
174 |
|
|
175 |
|
|
176 |
// ---------------------------------------------------------
|
|
177 |
// CMceOneRowListItemArrayLoader::StartL
|
|
178 |
// ---------------------------------------------------------
|
|
179 |
//
|
|
180 |
void CMceOneRowListItemArrayLoader::StartL()
|
|
181 |
{
|
|
182 |
//Before Starting to prepare the list, set the value to zero.
|
|
183 |
TInt r = RProperty::Set( KPSUidMuiu, KMuiuOneRowListPopulated, EFalse );
|
|
184 |
if ( r != KErrNone )
|
|
185 |
{
|
|
186 |
User::LeaveIfError( r );
|
|
187 |
}
|
|
188 |
Cancel();
|
|
189 |
InitialiseSearch();
|
|
190 |
delete iEntriesToBeAdded;
|
|
191 |
iEntriesToBeAdded = NULL;
|
|
192 |
iEntriesToBeAdded = iFolderEntry->ChildrenL();
|
|
193 |
iEntryToBeAdded = 0;
|
|
194 |
LoadMessagesL();
|
|
195 |
QueueLoad();
|
|
196 |
}
|
|
197 |
|
|
198 |
|
|
199 |
// ---------------------------------------------------------
|
|
200 |
// CMceOneRowListItemArrayLoader::FinishL
|
|
201 |
// ---------------------------------------------------------
|
|
202 |
//
|
|
203 |
void CMceOneRowListItemArrayLoader::FinishL()
|
|
204 |
{
|
|
205 |
if(IsActive())
|
|
206 |
{
|
|
207 |
// First consume the outstanding completion.
|
|
208 |
Cancel();
|
|
209 |
}
|
|
210 |
|
|
211 |
// Loop until all entries and subtitles has been added to iHCListItemArray
|
|
212 |
while ( iEntriesToBeAdded && iEntriesToBeAdded->Count() )
|
|
213 |
{
|
|
214 |
LoadMessagesL();
|
|
215 |
}
|
|
216 |
}
|
|
217 |
|
|
218 |
|
|
219 |
// ---------------------------------------------------------
|
|
220 |
// CMceOneRowListItemArrayLoader::DoCancel
|
|
221 |
// ---------------------------------------------------------
|
|
222 |
//
|
|
223 |
void CMceOneRowListItemArrayLoader::DoCancel()
|
|
224 |
{
|
|
225 |
}
|
|
226 |
|
|
227 |
|
|
228 |
// ---------------------------------------------------------
|
|
229 |
// CMceOneRowListItemArrayLoader::RunL
|
|
230 |
// ---------------------------------------------------------
|
|
231 |
//
|
|
232 |
void CMceOneRowListItemArrayLoader::RunL()
|
|
233 |
{
|
|
234 |
TRAP_IGNORE( LoadMessagesL( ) );
|
|
235 |
QueueLoad();
|
|
236 |
if(!IsActive())
|
|
237 |
{
|
|
238 |
}
|
|
239 |
}
|
|
240 |
|
|
241 |
|
|
242 |
// ---------------------------------------------------------
|
|
243 |
// CMceOneRowListItemArrayLoader::QueueLoad
|
|
244 |
// ---------------------------------------------------------
|
|
245 |
//
|
|
246 |
void CMceOneRowListItemArrayLoader::QueueLoad()
|
|
247 |
{
|
|
248 |
if ( IsActive() )
|
|
249 |
{
|
|
250 |
return;
|
|
251 |
}
|
|
252 |
|
|
253 |
if ( iEntriesToBeAdded->Count() || iEntriesReceivedDuringListCreation )
|
|
254 |
{
|
|
255 |
TRequestStatus *s = &iStatus;
|
|
256 |
User::RequestComplete(s, KErrNone);
|
|
257 |
SetActive();
|
|
258 |
}
|
|
259 |
}
|
|
260 |
|
|
261 |
|
|
262 |
// ---------------------------------------------------------
|
|
263 |
// CMceOneRowListItemArrayLoader::LoadMessagesL
|
|
264 |
// ---------------------------------------------------------
|
|
265 |
//
|
|
266 |
void CMceOneRowListItemArrayLoader::LoadMessagesL()
|
|
267 |
{
|
|
268 |
if ( iEntriesToBeAdded->Count() )
|
|
269 |
{
|
|
270 |
if ( iEmailFramework )
|
|
271 |
{
|
|
272 |
TRAP_IGNORE( CreateCmailEntryIndexL() ) ;
|
|
273 |
}
|
|
274 |
AppendMessagesL();
|
|
275 |
}
|
|
276 |
else if ( iEntriesReceivedDuringListCreation )
|
|
277 |
{
|
|
278 |
Cancel();
|
|
279 |
// do something
|
|
280 |
const TInt count = iEntriesReceivedDuringListCreation->Count();
|
|
281 |
for (TInt i=0; i<count; i++)
|
|
282 |
{
|
|
283 |
EntryCreatedL( (*iEntriesReceivedDuringListCreation)[i] );
|
|
284 |
}
|
|
285 |
delete iEntriesReceivedDuringListCreation;
|
|
286 |
iEntriesReceivedDuringListCreation = NULL;
|
|
287 |
}
|
|
288 |
}
|
|
289 |
|
|
290 |
|
|
291 |
// ----------------------------------------------------
|
|
292 |
// CMceOneRowListItemArray::ItemIndex
|
|
293 |
// ----------------------------------------------------
|
|
294 |
TInt CMceOneRowListItemArrayLoader::ItemIndex(TMsvId aItemId) const
|
|
295 |
{
|
|
296 |
TInt foundItem = KErrNotFound;
|
|
297 |
const TInt count = iHCListItemArray.Count();
|
|
298 |
for( TInt loop = 0; loop < count && foundItem == KErrNotFound ; loop++)
|
|
299 |
{
|
|
300 |
if ( iHCListItemArray[loop].iEntryId == aItemId &&
|
|
301 |
iHCListItemArray[loop].iItemType == EHListItemEntry )
|
|
302 |
{
|
|
303 |
foundItem = loop;
|
|
304 |
}
|
|
305 |
}
|
|
306 |
return foundItem;
|
|
307 |
}
|
|
308 |
|
|
309 |
|
|
310 |
// ----------------------------------------------------
|
|
311 |
// CMceOneRowListItemArray::HCItemType
|
|
312 |
// ----------------------------------------------------
|
|
313 |
//THListItemType CMceOneRowListItemArray::HCItemType( TInt aIndex )
|
|
314 |
TInt CMceOneRowListItemArrayLoader::HCItemType(TInt aIndex )
|
|
315 |
{
|
|
316 |
return iHCListItemArray[aIndex].iItemType;
|
|
317 |
}
|
|
318 |
|
|
319 |
|
|
320 |
// ----------------------------------------------------
|
|
321 |
// CMceOneRowListItemArray::ItemId
|
|
322 |
// ----------------------------------------------------
|
|
323 |
TMsvId CMceOneRowListItemArrayLoader::ItemId( TInt aIndex ) const
|
|
324 |
{
|
|
325 |
TMsvId id = KErrNotFound;
|
|
326 |
if ( aIndex >= 0 && iHCListItemArray.Count() > aIndex )
|
|
327 |
{
|
|
328 |
if ( iHCListItemArray[aIndex].iItemType == EHListItemEntry )
|
|
329 |
{
|
|
330 |
id = iHCListItemArray[aIndex].iEntryId;
|
|
331 |
}
|
|
332 |
}
|
|
333 |
|
|
334 |
return id;
|
|
335 |
}
|
|
336 |
|
|
337 |
|
|
338 |
// ----------------------------------------------------
|
|
339 |
// CMceOneRowListItemArrayLoader::SetEntryL
|
|
340 |
// ----------------------------------------------------
|
|
341 |
void CMceOneRowListItemArrayLoader::SetEntryL( TMsvId aFolderId )
|
|
342 |
{
|
|
343 |
iHCListItemArray.Reset();
|
|
344 |
|
|
345 |
iFolderEntry->SetEntryL( aFolderId );
|
|
346 |
TMsvSelectionOrdering ordering = iFolderEntry->SortType();
|
|
347 |
TMsvSorting sorting = iFolderEntry->SortType().Sorting();
|
|
348 |
ordering.SetSorting( sorting );
|
|
349 |
iFolderEntry->SetSortTypeL( ordering );
|
|
350 |
StartL();
|
|
351 |
}
|
|
352 |
|
|
353 |
|
|
354 |
// ----------------------------------------------------
|
|
355 |
// CMceOneRowListItemArrayLoader::Count
|
|
356 |
// ----------------------------------------------------
|
|
357 |
TInt CMceOneRowListItemArrayLoader::Count()
|
|
358 |
{
|
|
359 |
TInt count = 0;
|
|
360 |
count = iHCListItemArray.Count();
|
|
361 |
return count;
|
|
362 |
}
|
|
363 |
|
|
364 |
|
|
365 |
// ----------------------------------------------------
|
|
366 |
// CMceOneRowListItemArrayLoader::GetEntry
|
|
367 |
// ----------------------------------------------------
|
|
368 |
TInt CMceOneRowListItemArrayLoader::GetEntry( TMsvId aEntryId, TMsvEntry& aEntry )
|
|
369 |
{
|
|
370 |
TMsvId serviceId;
|
|
371 |
TInt error = iSession->GetEntry( aEntryId, serviceId, aEntry );
|
|
372 |
return error;
|
|
373 |
}
|
|
374 |
|
|
375 |
|
|
376 |
// ----------------------------------------------------
|
|
377 |
// CMceOneRowListItemArrayLoader::GetEntry
|
|
378 |
// ----------------------------------------------------
|
|
379 |
TInt CMceOneRowListItemArrayLoader::GetEntry( TInt aIndex, TMsvEntry& aEntry )
|
|
380 |
{
|
|
381 |
if ( aIndex < 0 || aIndex > iHCListItemArray.Count() )
|
|
382 |
{
|
|
383 |
return KErrNotFound;
|
|
384 |
}
|
|
385 |
TMsvId serviceId;
|
|
386 |
TMsvId entryId;
|
|
387 |
entryId = iHCListItemArray[aIndex].iEntryId;
|
|
388 |
|
|
389 |
TInt error = iSession->GetEntry( entryId, serviceId, aEntry );
|
|
390 |
if ( error == KErrNone )
|
|
391 |
{
|
|
392 |
if ( iHCListItemArray[aIndex].iItemType == EHListItemSubtitle )
|
|
393 |
{
|
|
394 |
error = iListType;
|
|
395 |
}
|
|
396 |
}
|
|
397 |
return error;
|
|
398 |
}
|
|
399 |
|
|
400 |
|
|
401 |
// ----------------------------------------------------
|
|
402 |
// CMceOneRowListItemArrayLoader::GetTimeBasedSubtitle
|
|
403 |
// ----------------------------------------------------
|
|
404 |
TInt CMceOneRowListItemArrayLoader::GetTimeBasedSubtitle( TInt aIndex )
|
|
405 |
{
|
|
406 |
if ( aIndex < 0 || aIndex > iHCListItemArray.Count() )
|
|
407 |
{
|
|
408 |
return KErrNotFound;
|
|
409 |
}
|
|
410 |
TInt value = KErrNotSupported;
|
|
411 |
if ( iListType == EHCListTypeTime )
|
|
412 |
{
|
|
413 |
if ( iHCListItemArray[aIndex].iItemType == EHListItemSubtitle )
|
|
414 |
{
|
|
415 |
value = iHCListItemArray[aIndex].iSubtitleType;
|
|
416 |
}
|
|
417 |
else
|
|
418 |
{
|
|
419 |
TInt subtitleIndex = ParentItemIndex( aIndex );
|
|
420 |
if ( subtitleIndex >= 0 )
|
|
421 |
{
|
|
422 |
value = iHCListItemArray[subtitleIndex].iSubtitleType;
|
|
423 |
}
|
|
424 |
}
|
|
425 |
}
|
|
426 |
return value;
|
|
427 |
}
|
|
428 |
|
|
429 |
|
|
430 |
// ----------------------------------------------------
|
|
431 |
// CMceOneRowListItemArrayLoader::GetCurrentEntry
|
|
432 |
// ----------------------------------------------------
|
|
433 |
void CMceOneRowListItemArrayLoader::GetCurrentEntry( TMsvEntry& aEntry )
|
|
434 |
{
|
|
435 |
aEntry = iFolderEntry->Entry();
|
|
436 |
}
|
|
437 |
|
|
438 |
|
|
439 |
// ----------------------------------------------------
|
|
440 |
// CMceOneRowListItemArrayLoader::CurrentEntryId
|
|
441 |
// ----------------------------------------------------
|
|
442 |
TMsvId CMceOneRowListItemArrayLoader::CurrentEntryId()
|
|
443 |
{
|
|
444 |
return iFolderEntry->EntryId();
|
|
445 |
}
|
|
446 |
|
|
447 |
|
|
448 |
// ----------------------------------------------------
|
|
449 |
// CMceOneRowListItemArrayLoader::SetListItemArrayObserver
|
|
450 |
// ----------------------------------------------------
|
|
451 |
void CMceOneRowListItemArrayLoader::SetListItemArrayObserver( MMceOneRowListItemArrayObserver* aObserver )
|
|
452 |
{
|
|
453 |
iListItemArrayObserver = aObserver;
|
|
454 |
}
|
|
455 |
|
|
456 |
|
|
457 |
// ----------------------------------------------------
|
|
458 |
// CMceOneRowListItemArrayLoader::InitialiseSearch
|
|
459 |
// ----------------------------------------------------
|
|
460 |
void CMceOneRowListItemArrayLoader::InitialiseSearch()
|
|
461 |
{
|
|
462 |
iHCListItemArray.Reset();
|
|
463 |
iCounter = 0;
|
|
464 |
iStep = 0;
|
|
465 |
for (TInt i=EMondayAdded; i<=EOlderAdded; i++)
|
|
466 |
{
|
|
467 |
iSubtitleAdded[i] = EFalse;
|
|
468 |
}
|
|
469 |
UpdateCurrentTime();
|
|
470 |
iAddSubtitle = EFalse;
|
|
471 |
}
|
|
472 |
|
|
473 |
|
|
474 |
// ----------------------------------------------------
|
|
475 |
// CMceOneRowListItemArrayLoader::HandleSessionEventL
|
|
476 |
// ----------------------------------------------------
|
|
477 |
void CMceOneRowListItemArrayLoader::HandleSessionEventL(
|
|
478 |
TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* /*aArg3*/)
|
|
479 |
{
|
|
480 |
MCELOGGER_ENTERFN("CMceOneRowListItemArrayLoader::HandleSessionEventL");
|
|
481 |
// if active...
|
|
482 |
|
|
483 |
if ( !IsActive() )
|
|
484 |
{
|
|
485 |
MCELOGGER_LEAVEFN("CMceOneRowListItemArrayLoader::HandleSessionEventL not active");
|
|
486 |
return;
|
|
487 |
}
|
|
488 |
|
|
489 |
TMsvId changedFolderId = (*(TMsvId*) (aArg2));
|
|
490 |
if ( changedFolderId != iFolderEntry->EntryId() )
|
|
491 |
{
|
|
492 |
// not in our folder...
|
|
493 |
return;
|
|
494 |
}
|
|
495 |
|
|
496 |
switch (aEvent)
|
|
497 |
{
|
|
498 |
case EMsvEntriesChanged:
|
|
499 |
case EMsvEntriesCreated:
|
|
500 |
{
|
|
501 |
if ( !iEntriesReceivedDuringListCreation )
|
|
502 |
{
|
|
503 |
iEntriesReceivedDuringListCreation = new( ELeave ) CMsvEntrySelection();
|
|
504 |
}
|
|
505 |
CMsvEntrySelection* selection = (CMsvEntrySelection*) aArg1;
|
|
506 |
const TInt count = selection->Count();
|
|
507 |
for (TInt i=0; i<count; i++)
|
|
508 |
{
|
|
509 |
iEntriesReceivedDuringListCreation->AppendL( (*selection)[i] );
|
|
510 |
}
|
|
511 |
}
|
|
512 |
break;
|
|
513 |
case EMsvEntriesDeleted:
|
|
514 |
{
|
|
515 |
// ?
|
|
516 |
}
|
|
517 |
case EMsvEntriesMoved:
|
|
518 |
{
|
|
519 |
}
|
|
520 |
break;
|
|
521 |
default:
|
|
522 |
break;
|
|
523 |
};
|
|
524 |
MCELOGGER_LEAVEFN("CMceOneRowListItemArrayLoader::HandleSessionEventL");
|
|
525 |
}
|
|
526 |
|
|
527 |
|
|
528 |
// ----------------------------------------------------
|
|
529 |
// CMceOneRowListItemArrayLoader::AppendMessagesL
|
|
530 |
// ----------------------------------------------------
|
|
531 |
void CMceOneRowListItemArrayLoader::AppendMessagesL()
|
|
532 |
{
|
|
533 |
switch ( iListType )
|
|
534 |
{
|
|
535 |
case EHCListTypeTime:
|
|
536 |
CreateTimeBasedArrayL();
|
|
537 |
break;
|
|
538 |
case EHCListTypeSender:
|
|
539 |
CreateSenderBasedArrayL();
|
|
540 |
break;
|
|
541 |
case EHCListTypeSubject:
|
|
542 |
CreateSubjectBasedArrayL();
|
|
543 |
break;
|
|
544 |
case EHCListTypeType:
|
|
545 |
CreateTypeBasedArrayL();
|
|
546 |
break;
|
|
547 |
default:
|
|
548 |
CreateTimeBasedArrayL();
|
|
549 |
break;
|
|
550 |
}
|
|
551 |
if(iEntriesToBeAdded->Count() == 0)
|
|
552 |
{
|
|
553 |
//all the entries are populated successfully
|
|
554 |
TInt r = RProperty::Set( KPSUidMuiu, KMuiuOneRowListPopulated, ETrue );
|
|
555 |
if ( r != KErrNone )
|
|
556 |
{
|
|
557 |
User::LeaveIfError( r );
|
|
558 |
}
|
|
559 |
}
|
|
560 |
}
|
|
561 |
|
|
562 |
|
|
563 |
// ----------------------------------------------------
|
|
564 |
// CMceOneRowListItemArrayLoader::CreateTimeBasedArrayL
|
|
565 |
// ----------------------------------------------------
|
|
566 |
void CMceOneRowListItemArrayLoader::CreateTimeBasedArrayL()
|
|
567 |
{
|
|
568 |
CArrayFixFlat<TInt>* itemsAdded = new (ELeave) CArrayFixFlat<TInt>(4);
|
|
569 |
CleanupStack::PushL( itemsAdded );
|
|
570 |
|
|
571 |
TInt entryCount = 0; // divides list building into smaller pieces
|
|
572 |
TBool itemAdded = EFalse;
|
|
573 |
TInt loopCounter = KMceLoopCounter;
|
|
574 |
if (iCounter == 0)
|
|
575 |
{
|
|
576 |
//For the first time, when the list is about to get populated.
|
|
577 |
loopCounter = KFirstTimeMceLoopCounter;
|
|
578 |
}
|
|
579 |
// Loop until all entries and subtitles has been added to iHCListItemArray
|
|
580 |
while ( iEntriesToBeAdded->Count() )
|
|
581 |
{
|
|
582 |
TBool nonCmailEntry = ETrue;
|
|
583 |
if ( iEmailFramework )
|
|
584 |
{
|
|
585 |
nonCmailEntry = CheckCmailEntryIndexL ((*iEntriesToBeAdded)[0]);
|
|
586 |
}
|
|
587 |
if ( nonCmailEntry )
|
|
588 |
{
|
|
589 |
iEntryToBeAdded = (*iEntriesToBeAdded)[0];
|
|
590 |
iEntriesToBeAdded->Delete( 0 );
|
|
591 |
|
|
592 |
// First add folders
|
|
593 |
if ( iStep == 0 )
|
|
594 |
{
|
|
595 |
TMsvEntry entry = iFolderEntry->ChildDataL( iEntryToBeAdded );
|
|
596 |
// Find folders
|
|
597 |
while ( entry.iType == KUidMsvFolderEntry )
|
|
598 |
{
|
|
599 |
THCListListItem item;
|
|
600 |
item.iTreeItemId = 0;
|
|
601 |
item.iEntryId = entry.Id();
|
|
602 |
item.iItemType = EHListItemEntry;
|
|
603 |
itemAdded = ETrue;
|
|
604 |
iHCListItemArray.AppendL( item );
|
|
605 |
itemsAdded->AppendL( iHCListItemArray.Count()-1 );
|
|
606 |
entryCount++;
|
|
607 |
iCounter++;
|
|
608 |
if ( iEntriesToBeAdded->Count() )
|
|
609 |
{
|
|
610 |
iEntryToBeAdded = (*iEntriesToBeAdded)[0];
|
|
611 |
iEntriesToBeAdded->Delete( 0 );
|
|
612 |
entry = iFolderEntry->ChildDataL( iEntryToBeAdded );
|
|
613 |
}
|
|
614 |
else
|
|
615 |
{
|
|
616 |
iEntryToBeAdded = 0;
|
|
617 |
// All entries has been checked for folder type
|
|
618 |
break;
|
|
619 |
}
|
|
620 |
}
|
|
621 |
}
|
|
622 |
|
|
623 |
// Add subtitle
|
|
624 |
if ( iAddSubtitle )
|
|
625 |
{
|
|
626 |
THCListListItem item;
|
|
627 |
item.iTreeItemId = 0;
|
|
628 |
item.iEntryId = iEntryToBeAdded;
|
|
629 |
item.iItemType = EHListItemSubtitle;
|
|
630 |
item.iSubtitleType = iSubtitleType;
|
|
631 |
iHCListItemArray.AppendL( item );
|
|
632 |
itemsAdded->AppendL( iHCListItemArray.Count()-1 );
|
|
633 |
iAddSubtitle = EFalse;
|
|
634 |
entryCount++;
|
|
635 |
}
|
|
636 |
|
|
637 |
// iCounter still in valid range
|
|
638 |
if ( iEntryToBeAdded > 0 )
|
|
639 |
{
|
|
640 |
TMsvEntry entry = iFolderEntry->ChildDataL( iEntryToBeAdded );
|
|
641 |
|
|
642 |
TTime entryTime = entry.iDate;
|
|
643 |
GetTime( entryTime );
|
|
644 |
TInt subtitleType = TimeBasedSubtitleType( entryTime, EFalse );
|
|
645 |
if ( !iSubtitleAdded[subtitleType] )
|
|
646 |
{
|
|
647 |
iAddSubtitle = ETrue;
|
|
648 |
iSubtitleType = subtitleType;
|
|
649 |
iSubtitleAdded[subtitleType] = ETrue;
|
|
650 |
}
|
|
651 |
|
|
652 |
// Add entry item if no subtitle added
|
|
653 |
if( !iAddSubtitle )
|
|
654 |
{
|
|
655 |
THCListListItem item;
|
|
656 |
item.iTreeItemId = 0;
|
|
657 |
item.iEntryId = entry.Id();
|
|
658 |
item.iItemType = EHListItemEntry;
|
|
659 |
iHCListItemArray.AppendL( item );
|
|
660 |
itemsAdded->AppendL( iHCListItemArray.Count()-1 );
|
|
661 |
item.iSubtitleType = iSubtitleType;
|
|
662 |
itemAdded = ETrue;
|
|
663 |
entryCount++;
|
|
664 |
}
|
|
665 |
else
|
|
666 |
{
|
|
667 |
// Subtitle added: breaks out and after that
|
|
668 |
// active scheduler returns to add subtitle and entries
|
|
669 |
iEntriesToBeAdded->InsertL( 0, iEntryToBeAdded );
|
|
670 |
iStep = 1;
|
|
671 |
break;
|
|
672 |
}
|
|
673 |
|
|
674 |
// This breaks building the array after every KMceLoopCounter entries.
|
|
675 |
// Necessary for not slowing down execution when there are many messages
|
|
676 |
// as this is a part of an active scheduler callback.
|
|
677 |
if ( entryCount >= loopCounter)
|
|
678 |
{
|
|
679 |
iCounter++;
|
|
680 |
break;
|
|
681 |
}
|
|
682 |
}
|
|
683 |
}
|
|
684 |
else
|
|
685 |
{
|
|
686 |
iEntriesToBeAdded->Delete( 0 );
|
|
687 |
}
|
|
688 |
iCounter++;
|
|
689 |
}
|
|
690 |
loopCounter = KMceLoopCounter;
|
|
691 |
iStep = 1;
|
|
692 |
|
|
693 |
// Update Tree list
|
|
694 |
if ( iListItemArrayObserver && itemAdded )
|
|
695 |
{
|
|
696 |
iListItemArrayObserver->MceListItemArrayChangedL( *itemsAdded );
|
|
697 |
}
|
|
698 |
CleanupStack::PopAndDestroy( itemsAdded );
|
|
699 |
}
|
|
700 |
|
|
701 |
|
|
702 |
// ----------------------------------------------------
|
|
703 |
// CMceOneRowListItemArrayLoader::CreateSenderBasedArrayL
|
|
704 |
// ----------------------------------------------------
|
|
705 |
void CMceOneRowListItemArrayLoader::CreateSenderBasedArrayL()
|
|
706 |
{
|
|
707 |
CArrayFixFlat<TInt>* itemsAdded = new (ELeave) CArrayFixFlat<TInt>(4);
|
|
708 |
CleanupStack::PushL( itemsAdded );
|
|
709 |
TBool itemAdded = EFalse;
|
|
710 |
TInt i = 0;
|
|
711 |
while ( iEntriesToBeAdded->Count() && i < KMceLoopCounter )
|
|
712 |
{
|
|
713 |
THCListListItem item;
|
|
714 |
item.iTreeItemId = 0;
|
|
715 |
TBool nonCmailEntry = ETrue ;
|
|
716 |
if (iEmailFramework )
|
|
717 |
{
|
|
718 |
nonCmailEntry = CheckCmailEntryIndexL ((*iEntriesToBeAdded)[0]);
|
|
719 |
}
|
|
720 |
if ( nonCmailEntry )
|
|
721 |
{
|
|
722 |
TMsvId entryToBeAdded = (*iEntriesToBeAdded)[0];
|
|
723 |
iEntriesToBeAdded->Delete( 0 );
|
|
724 |
if ( iEntryToBeAdded <= 0 )
|
|
725 |
{
|
|
726 |
TMsvEntry entry = iFolderEntry->ChildDataL( entryToBeAdded );
|
|
727 |
item.iEntryId = entryToBeAdded;
|
|
728 |
if ( entry.iType != KUidMsvFolderEntry )
|
|
729 |
{
|
|
730 |
item.iItemType = EHListItemSubtitle;
|
|
731 |
iHCListItemArray.AppendL( item );
|
|
732 |
itemsAdded->AppendL( iHCListItemArray.Count()-1 );
|
|
733 |
i++;
|
|
734 |
}
|
|
735 |
item.iItemType = EHListItemEntry;
|
|
736 |
itemAdded = ETrue;
|
|
737 |
iHCListItemArray.AppendL( item );
|
|
738 |
iEntryToBeAdded = entryToBeAdded;
|
|
739 |
itemsAdded->AppendL( iHCListItemArray.Count()-1 );
|
|
740 |
}
|
|
741 |
else
|
|
742 |
{
|
|
743 |
TMsvEntry previousEntry = iFolderEntry->ChildDataL( iEntryToBeAdded );
|
|
744 |
TMsvEntry currentEntry = iFolderEntry->ChildDataL( entryToBeAdded );
|
|
745 |
item.iEntryId = currentEntry.Id();
|
|
746 |
if ( currentEntry.iType != KUidMsvFolderEntry &&
|
|
747 |
currentEntry.iDetails.Compare(previousEntry.iDetails) != 0 )
|
|
748 |
{
|
|
749 |
item.iItemType = EHListItemSubtitle;
|
|
750 |
iHCListItemArray.AppendL( item );
|
|
751 |
itemsAdded->AppendL( iHCListItemArray.Count()-1 );
|
|
752 |
i++;
|
|
753 |
}
|
|
754 |
item.iItemType = EHListItemEntry;
|
|
755 |
itemAdded = ETrue;
|
|
756 |
iHCListItemArray.AppendL( item );
|
|
757 |
iEntryToBeAdded = entryToBeAdded;
|
|
758 |
itemsAdded->AppendL( iHCListItemArray.Count()-1 );
|
|
759 |
}
|
|
760 |
}
|
|
761 |
else
|
|
762 |
{
|
|
763 |
iEntriesToBeAdded->Delete( 0 );
|
|
764 |
}
|
|
765 |
iCounter++;
|
|
766 |
i++;
|
|
767 |
}
|
|
768 |
if ( iListItemArrayObserver && itemAdded )
|
|
769 |
{
|
|
770 |
iListItemArrayObserver->MceListItemArrayChangedL( *itemsAdded );
|
|
771 |
}
|
|
772 |
CleanupStack::PopAndDestroy( itemsAdded );
|
|
773 |
}
|
|
774 |
|
|
775 |
|
|
776 |
// ----------------------------------------------------
|
|
777 |
// CMceOneRowListItemArrayLoader::CreateSubjectBasedArrayL
|
|
778 |
// ----------------------------------------------------
|
|
779 |
void CMceOneRowListItemArrayLoader::CreateSubjectBasedArrayL()
|
|
780 |
{
|
|
781 |
CArrayFixFlat<TInt>* itemsAdded = new (ELeave) CArrayFixFlat<TInt>(4);
|
|
782 |
CleanupStack::PushL( itemsAdded );
|
|
783 |
TBool itemAdded = EFalse;
|
|
784 |
TInt i = 0;
|
|
785 |
while ( iEntriesToBeAdded->Count() && i < KMceLoopCounter )
|
|
786 |
{
|
|
787 |
THCListListItem item;
|
|
788 |
item.iTreeItemId = 0;
|
|
789 |
TBool nonCmailEntry = ETrue;
|
|
790 |
if (iEmailFramework )
|
|
791 |
{
|
|
792 |
nonCmailEntry = CheckCmailEntryIndexL ((*iEntriesToBeAdded)[0]);
|
|
793 |
}
|
|
794 |
if ( nonCmailEntry )
|
|
795 |
{
|
|
796 |
TMsvId entryToBeAdded = (*iEntriesToBeAdded)[0];
|
|
797 |
iEntriesToBeAdded->Delete( 0 );
|
|
798 |
|
|
799 |
if ( iEntryToBeAdded <= 0 )
|
|
800 |
{
|
|
801 |
TMsvEntry entry = iFolderEntry->ChildDataL( entryToBeAdded );
|
|
802 |
item.iEntryId = entryToBeAdded;
|
|
803 |
if ( entry.iType != KUidMsvFolderEntry )
|
|
804 |
{
|
|
805 |
item.iItemType = EHListItemSubtitle;
|
|
806 |
iHCListItemArray.AppendL( item );
|
|
807 |
itemsAdded->AppendL( iHCListItemArray.Count()-1 );
|
|
808 |
i++;
|
|
809 |
}
|
|
810 |
item.iItemType = EHListItemEntry;
|
|
811 |
itemAdded = ETrue;
|
|
812 |
iHCListItemArray.AppendL( item );
|
|
813 |
iEntryToBeAdded = entryToBeAdded;
|
|
814 |
itemsAdded->AppendL( iHCListItemArray.Count()-1 );
|
|
815 |
}
|
|
816 |
else
|
|
817 |
{
|
|
818 |
TMsvEntry previousEntry = iFolderEntry->ChildDataL( iEntryToBeAdded );
|
|
819 |
TMsvEntry currentEntry = iFolderEntry->ChildDataL( entryToBeAdded );
|
|
820 |
item.iEntryId = currentEntry.Id();
|
|
821 |
// Remove prefix from current entry description
|
|
822 |
TBufC<100> tmpString( currentEntry.iDescription.Left( KSortSubjectStringLength ) );
|
|
823 |
const TInt length1 = tmpString.Length();
|
|
824 |
TInt start = SkipPrefix( tmpString.Des() );
|
|
825 |
TPtrC currentMid = currentEntry.iDescription.Mid( start, length1 - start );
|
|
826 |
|
|
827 |
// Remove prefix from previous entry description
|
|
828 |
TBufC<100> tmpString2( previousEntry.iDescription.Left( KSortSubjectStringLength ) );
|
|
829 |
const TInt length2 = tmpString2.Length();
|
|
830 |
start = SkipPrefix( tmpString2.Des() );
|
|
831 |
TPtrC prevMid = previousEntry.iDescription.Mid( start, length2 - start );
|
|
832 |
|
|
833 |
// Compare descriptions
|
|
834 |
if ( currentEntry.iType != KUidMsvFolderEntry &&
|
|
835 |
currentMid.CompareF( prevMid ) != 0 )
|
|
836 |
{
|
|
837 |
item.iItemType = EHListItemSubtitle;
|
|
838 |
iHCListItemArray.AppendL( item );
|
|
839 |
itemsAdded->AppendL( iHCListItemArray.Count()-1 );
|
|
840 |
i++;
|
|
841 |
}
|
|
842 |
item.iItemType = EHListItemEntry;
|
|
843 |
itemAdded = ETrue;
|
|
844 |
iHCListItemArray.AppendL( item );
|
|
845 |
iEntryToBeAdded = entryToBeAdded;
|
|
846 |
itemsAdded->AppendL( iHCListItemArray.Count()-1 );
|
|
847 |
}
|
|
848 |
}
|
|
849 |
else
|
|
850 |
{
|
|
851 |
iEntriesToBeAdded->Delete( 0 );
|
|
852 |
}
|
|
853 |
iCounter++;
|
|
854 |
i++;
|
|
855 |
}
|
|
856 |
if ( iListItemArrayObserver && itemAdded )
|
|
857 |
{
|
|
858 |
iListItemArrayObserver->MceListItemArrayChangedL( *itemsAdded );
|
|
859 |
}
|
|
860 |
CleanupStack::PopAndDestroy( itemsAdded );
|
|
861 |
}
|
|
862 |
|
|
863 |
|
|
864 |
// ----------------------------------------------------
|
|
865 |
// CMceOneRowListItemArrayLoader::CreateTypeBasedArrayL
|
|
866 |
// ----------------------------------------------------
|
|
867 |
void CMceOneRowListItemArrayLoader::CreateTypeBasedArrayL()
|
|
868 |
{
|
|
869 |
CArrayFixFlat<TInt>* itemsAdded = new (ELeave) CArrayFixFlat<TInt>(4);
|
|
870 |
CleanupStack::PushL( itemsAdded );
|
|
871 |
|
|
872 |
TBool itemAdded = EFalse;
|
|
873 |
TInt i = 0;
|
|
874 |
while ( iEntriesToBeAdded->Count() && i < KMceLoopCounter )
|
|
875 |
{
|
|
876 |
THCListListItem item;
|
|
877 |
item.iTreeItemId = 0;
|
|
878 |
TBool nonCmailEntry = ETrue;
|
|
879 |
if (iEmailFramework )
|
|
880 |
{
|
|
881 |
nonCmailEntry = CheckCmailEntryIndexL ((*iEntriesToBeAdded)[0]);
|
|
882 |
}
|
|
883 |
if ( nonCmailEntry )
|
|
884 |
{
|
|
885 |
TMsvId entryToBeAdded = (*iEntriesToBeAdded)[0];
|
|
886 |
iEntriesToBeAdded->Delete( 0 );
|
|
887 |
item.iEntryId = entryToBeAdded;
|
|
888 |
item.iItemType = EHListItemEntry;
|
|
889 |
itemAdded = ETrue;
|
|
890 |
iHCListItemArray.AppendL( item );
|
|
891 |
itemsAdded->AppendL( iHCListItemArray.Count()-1 );
|
|
892 |
}
|
|
893 |
else
|
|
894 |
{
|
|
895 |
iEntriesToBeAdded->Delete( 0 );
|
|
896 |
}
|
|
897 |
iCounter++;
|
|
898 |
i++;
|
|
899 |
}
|
|
900 |
if ( iListItemArrayObserver && itemAdded )
|
|
901 |
{
|
|
902 |
iListItemArrayObserver->MceListItemArrayChangedL( *itemsAdded );
|
|
903 |
}
|
|
904 |
CleanupStack::PopAndDestroy( itemsAdded );
|
|
905 |
}
|
|
906 |
|
|
907 |
|
|
908 |
// ----------------------------------------------------
|
|
909 |
// CMceOneRowListItemArrayLoader::SortType
|
|
910 |
// ----------------------------------------------------
|
|
911 |
THCListListType CMceOneRowListItemArrayLoader::SortTypeHCList()
|
|
912 |
{
|
|
913 |
return iListType;
|
|
914 |
}
|
|
915 |
|
|
916 |
|
|
917 |
// ----------------------------------------------------
|
|
918 |
// CMceMessageListItemArray::SortType
|
|
919 |
// returns folder's sort type
|
|
920 |
//
|
|
921 |
// ----------------------------------------------------
|
|
922 |
TMsvSelectionOrdering CMceOneRowListItemArrayLoader::SortType( )
|
|
923 |
{
|
|
924 |
return iFolderEntry->SortType();
|
|
925 |
}
|
|
926 |
|
|
927 |
|
|
928 |
// ----------------------------------------------------
|
|
929 |
// CMceOneRowListItemArrayLoader::SetOrderingL
|
|
930 |
// ----------------------------------------------------
|
|
931 |
void CMceOneRowListItemArrayLoader::SetOrderingL( TInt aSortType, TBool aOrdering )
|
|
932 |
{
|
|
933 |
TMsvSorting sorting = EMsvSortByDateReverse;
|
|
934 |
TInt grouping = KMsvGroupByStandardFolders;
|
|
935 |
switch ( aSortType )
|
|
936 |
{
|
|
937 |
case EMceCmdSortByType:
|
|
938 |
grouping = KMsvGroupByStandardFolders|KMsvGroupByMtm;
|
|
939 |
sorting = aOrdering ? EMsvSortByIdReverse: EMsvSortById;
|
|
940 |
iListType = EHCListTypeType;
|
|
941 |
break;
|
|
942 |
case EMceCmdSortByRecipient:
|
|
943 |
case EMceCmdSortBySender:
|
|
944 |
sorting = aOrdering ? EMsvSortByDetailsReverse: EMsvSortByDetails;
|
|
945 |
iListType = EHCListTypeSender;
|
|
946 |
break;
|
|
947 |
case EMceCmdSortBySubject:
|
|
948 |
sorting = aOrdering ? EMsvSortByDescriptionReverse: EMsvSortByDescription;
|
|
949 |
iListType = EHCListTypeSubject;
|
|
950 |
break;
|
|
951 |
case EMceCmdSortByDate:
|
|
952 |
default:
|
|
953 |
sorting = aOrdering ? EMsvSortByDate: EMsvSortByDateReverse;
|
|
954 |
iListType = EHCListTypeTime;
|
|
955 |
break;
|
|
956 |
}
|
|
957 |
|
|
958 |
const TMsvSelectionOrdering newOrdering( grouping, sorting, EFalse );
|
|
959 |
iFolderEntry->SetSortTypeL( newOrdering );
|
|
960 |
// Ignore possible error. If this leaves worst thing is that ordering is not saved to root for message iterator.
|
|
961 |
TRAP_IGNORE( SaveOrderingL( newOrdering ) );
|
|
962 |
iPreviousSelectionOrdering = newOrdering;
|
|
963 |
StartL();
|
|
964 |
}
|
|
965 |
|
|
966 |
|
|
967 |
// ----------------------------------------------------
|
|
968 |
// CMceOneRowListItemArrayLoader::SaveOrderingL
|
|
969 |
// Write the sorting order into the message store, MUIU accesses and
|
|
970 |
// uses this for CMessageIterator
|
|
971 |
// ----------------------------------------------------
|
|
972 |
void CMceOneRowListItemArrayLoader::SaveOrderingL( const TMsvSelectionOrdering& aNewOrdering ) const
|
|
973 |
{
|
|
974 |
// TMsvSelectionOrdering class does not have != operator
|
|
975 |
if ( !(iPreviousSelectionOrdering == aNewOrdering ) )
|
|
976 |
{
|
|
977 |
CMsvEntry* entry=iSession->GetEntryL( KMsvRootIndexEntryId ); // Access the entry
|
|
978 |
CleanupStack::PushL( entry );
|
|
979 |
CMsvStore* store = entry->EditStoreL();
|
|
980 |
CleanupStack::PushL( store );
|
|
981 |
RMsvWriteStream writeStream;
|
|
982 |
writeStream.AssignLC( *store, KUidMsvMessageListSortOrder );
|
|
983 |
aNewOrdering.ExternalizeL( writeStream );
|
|
984 |
writeStream.CommitL();
|
|
985 |
store->CommitL();
|
|
986 |
CleanupStack::PopAndDestroy( 3 );
|
|
987 |
}
|
|
988 |
}
|
|
989 |
|
|
990 |
|
|
991 |
// ----------------------------------------------------
|
|
992 |
// CMceMessageListItemArray::DeleteDiscard
|
|
993 |
// return ETrue, if delete command should be discarded
|
|
994 |
//
|
|
995 |
// ----------------------------------------------------
|
|
996 |
TBool CMceOneRowListItemArrayLoader::DeleteDiscard( TMsvId aItemId ) const
|
|
997 |
{
|
|
998 |
TMsvEntry entry;
|
|
999 |
TMsvId serviceId;
|
|
1000 |
if ( iSession->GetEntry(aItemId,serviceId,entry) != KErrNone )
|
|
1001 |
{
|
|
1002 |
return ETrue;
|
|
1003 |
}
|
|
1004 |
|
|
1005 |
//mail or syncml folder cannot be deleted
|
|
1006 |
if ( ( entry.iType == KUidMsvFolderEntry ) &&
|
|
1007 |
( entry.iMtm == KSenduiMtmImap4Uid ||
|
|
1008 |
entry.iMtm == KSenduiMtmSyncMLEmailUid ) )
|
|
1009 |
{
|
|
1010 |
return ETrue;
|
|
1011 |
}
|
|
1012 |
|
|
1013 |
if ( iFolderEntry->Entry().Id() == KMsvGlobalOutBoxIndexEntryId )
|
|
1014 |
{
|
|
1015 |
if ( entry.SendingState() == KMsvSendStateSending )
|
|
1016 |
{
|
|
1017 |
return ETrue;
|
|
1018 |
}
|
|
1019 |
|
|
1020 |
// Message in waiting state cannot be deleted except e-mail.
|
|
1021 |
// For e-mail, waiting, resend and scheduled states are presented
|
|
1022 |
// to user as queued state (by CSmtpMtmUiData). Delete is allowed
|
|
1023 |
// from the queued state.
|
|
1024 |
if ( ( entry.SendingState() == KMsvSendStateWaiting ) &&
|
|
1025 |
( entry.iMtm != KSenduiMtmSmtpUid ) )
|
|
1026 |
{
|
|
1027 |
return ETrue;
|
|
1028 |
}
|
|
1029 |
|
|
1030 |
if ( entry.iMtm == KSenduiMtmSmsUid ||
|
|
1031 |
entry.iMtm == KSenduiMtmMmsUid )
|
|
1032 |
{
|
|
1033 |
if ( entry.Connected() || ( entry.SendingState() == KMsvSendStateUnknown )
|
|
1034 |
|| ( entry.SendingState() == KMsvSendStateNotApplicable ) )
|
|
1035 |
{
|
|
1036 |
return ETrue;
|
|
1037 |
}
|
|
1038 |
}
|
|
1039 |
}
|
|
1040 |
return EFalse;
|
|
1041 |
}
|
|
1042 |
|
|
1043 |
|
|
1044 |
// ----------------------------------------------------
|
|
1045 |
// CMceOneRowListItemArrayLoader::IsItemFolder
|
|
1046 |
// ----------------------------------------------------
|
|
1047 |
TBool CMceOneRowListItemArrayLoader::IsItemFolder( TMsvId aItemId ) const
|
|
1048 |
{
|
|
1049 |
TBool isFolder = EFalse;
|
|
1050 |
TMsvId serviceId;
|
|
1051 |
TMsvEntry entry;
|
|
1052 |
if ( iSession->GetEntry( aItemId, serviceId, entry ) == KErrNone &&
|
|
1053 |
entry.iType == KUidMsvFolderEntry )
|
|
1054 |
{
|
|
1055 |
isFolder = ETrue;
|
|
1056 |
}
|
|
1057 |
return isFolder;
|
|
1058 |
}
|
|
1059 |
|
|
1060 |
|
|
1061 |
// ----------------------------------------------------
|
|
1062 |
// CMceOneRowListItemArrayLoader::TreeItemId
|
|
1063 |
// ----------------------------------------------------
|
|
1064 |
TAknTreeItemID CMceOneRowListItemArrayLoader::TreeItemId( TInt aIndex )
|
|
1065 |
{
|
|
1066 |
return iHCListItemArray[aIndex].iTreeItemId;
|
|
1067 |
}
|
|
1068 |
|
|
1069 |
|
|
1070 |
// ----------------------------------------------------
|
|
1071 |
// CMceOneRowListItemArrayLoader::MsvItemId
|
|
1072 |
// ----------------------------------------------------
|
|
1073 |
TMsvId CMceOneRowListItemArrayLoader::MsvItemId( TAknTreeItemID aTreeItemId )
|
|
1074 |
{
|
|
1075 |
TMsvId foundItem = KErrNotFound;
|
|
1076 |
const TInt count = iHCListItemArray.Count();
|
|
1077 |
for( TInt loop = 0; loop < count && foundItem == KErrNotFound ; loop++)
|
|
1078 |
{
|
|
1079 |
if ( iHCListItemArray[loop].iTreeItemId == aTreeItemId &&
|
|
1080 |
iHCListItemArray[loop].iItemType == EHListItemEntry )
|
|
1081 |
{
|
|
1082 |
foundItem = iHCListItemArray[loop].iEntryId;
|
|
1083 |
}
|
|
1084 |
}
|
|
1085 |
return foundItem;
|
|
1086 |
}
|
|
1087 |
|
|
1088 |
|
|
1089 |
// ----------------------------------------------------
|
|
1090 |
// CMceOneRowListItemArrayLoader::ParentItemId
|
|
1091 |
// ----------------------------------------------------
|
|
1092 |
TAknTreeItemID CMceOneRowListItemArrayLoader::ParentItemId( TInt aIndex )
|
|
1093 |
{
|
|
1094 |
if ( aIndex < 0 || aIndex > iHCListItemArray.Count() )
|
|
1095 |
{
|
|
1096 |
return KAknTreeIIDNone;
|
|
1097 |
}
|
|
1098 |
TInt i = aIndex;
|
|
1099 |
TAknTreeItemID parentId = KAknTreeIIDRoot;
|
|
1100 |
|
|
1101 |
if ( iHCListItemArray[i].iItemType == EHListItemEntry )
|
|
1102 |
{
|
|
1103 |
// if item is subtitle row, then return root, but since it is message, search its subtitle row
|
|
1104 |
while ( i >= 0 && iHCListItemArray[i].iItemType == EHListItemEntry )
|
|
1105 |
{
|
|
1106 |
i--;
|
|
1107 |
}
|
|
1108 |
if ( i >= 0 )
|
|
1109 |
{
|
|
1110 |
parentId = iHCListItemArray[i].iTreeItemId;
|
|
1111 |
}
|
|
1112 |
}
|
|
1113 |
return parentId;
|
|
1114 |
}
|
|
1115 |
|
|
1116 |
|
|
1117 |
// ----------------------------------------------------
|
|
1118 |
// CMceOneRowListItemArrayLoader::ParentItemIndex
|
|
1119 |
// ----------------------------------------------------
|
|
1120 |
TInt CMceOneRowListItemArrayLoader::ParentItemIndex( TInt aIndex )
|
|
1121 |
{
|
|
1122 |
if ( aIndex < 0 || aIndex > iHCListItemArray.Count() )
|
|
1123 |
{
|
|
1124 |
return KErrNotFound;
|
|
1125 |
}
|
|
1126 |
TInt i = aIndex;
|
|
1127 |
if ( iHCListItemArray[i].iItemType == EHListItemEntry )
|
|
1128 |
{
|
|
1129 |
// if item is subtitle row, then return root, but since it is message, search its subtitle row
|
|
1130 |
while ( i >= 0 && iHCListItemArray[i].iItemType == EHListItemEntry )
|
|
1131 |
{
|
|
1132 |
i--;
|
|
1133 |
}
|
|
1134 |
}
|
|
1135 |
return i;
|
|
1136 |
}
|
|
1137 |
|
|
1138 |
|
|
1139 |
// ----------------------------------------------------
|
|
1140 |
// CMceOneRowListItemArrayLoader::SetTreeItemId
|
|
1141 |
// ----------------------------------------------------
|
|
1142 |
void CMceOneRowListItemArrayLoader::SetTreeItemId( TInt aIndex, TAknTreeItemID aTreeItemId )
|
|
1143 |
{
|
|
1144 |
iHCListItemArray[aIndex].iTreeItemId = aTreeItemId;
|
|
1145 |
}
|
|
1146 |
|
|
1147 |
|
|
1148 |
// ----------------------------------------------------
|
|
1149 |
// CMceOneRowListItemArrayLoader::ResetAllTreeItemId
|
|
1150 |
// ----------------------------------------------------
|
|
1151 |
void CMceOneRowListItemArrayLoader::ResetAllTreeItemId()
|
|
1152 |
{
|
|
1153 |
TInt i = iHCListItemArray.Count()-1;
|
|
1154 |
while ( i >= 0 )
|
|
1155 |
{
|
|
1156 |
iHCListItemArray[i].iTreeItemId = 0;
|
|
1157 |
i--;
|
|
1158 |
}
|
|
1159 |
}
|
|
1160 |
|
|
1161 |
|
|
1162 |
// ----------------------------------------------------
|
|
1163 |
// CMceOneRowListItemArrayLoader::Compare
|
|
1164 |
// ----------------------------------------------------
|
|
1165 |
TInt CMceOneRowListItemArrayLoader::Compare( TAknTreeItemID aFirst, TAknTreeItemID aSecond )
|
|
1166 |
{
|
|
1167 |
TInt firstIndex = KErrNotFound;
|
|
1168 |
TInt secondIndex = KErrNotFound;
|
|
1169 |
|
|
1170 |
TInt i = iHCListItemArray.Count()-1;
|
|
1171 |
while ( i >= 0 && ( firstIndex < 0 || secondIndex < 0 ) )
|
|
1172 |
{
|
|
1173 |
if ( iHCListItemArray[i].iTreeItemId == aFirst )
|
|
1174 |
{
|
|
1175 |
firstIndex = i;
|
|
1176 |
}
|
|
1177 |
if ( iHCListItemArray[i].iTreeItemId == aSecond )
|
|
1178 |
{
|
|
1179 |
secondIndex = i;
|
|
1180 |
}
|
|
1181 |
i--;
|
|
1182 |
}
|
|
1183 |
|
|
1184 |
if ( firstIndex > KErrNotFound && secondIndex > KErrNotFound )
|
|
1185 |
{
|
|
1186 |
return firstIndex - secondIndex;
|
|
1187 |
}
|
|
1188 |
else
|
|
1189 |
{
|
|
1190 |
return 0;
|
|
1191 |
}
|
|
1192 |
}
|
|
1193 |
|
|
1194 |
|
|
1195 |
// ----------------------------------------------------
|
|
1196 |
// CMceOneRowListItemArrayLoader::ItemIndexTreeId
|
|
1197 |
// ----------------------------------------------------
|
|
1198 |
TInt CMceOneRowListItemArrayLoader::ItemIndexTreeId( TAknTreeItemID aTreeItemId )
|
|
1199 |
{
|
|
1200 |
TInt i = iHCListItemArray.Count()-1;
|
|
1201 |
while ( i >= 0 && iHCListItemArray[i].iTreeItemId != aTreeItemId )
|
|
1202 |
{
|
|
1203 |
i--;
|
|
1204 |
}
|
|
1205 |
return i;
|
|
1206 |
}
|
|
1207 |
|
|
1208 |
|
|
1209 |
// ----------------------------------------------------
|
|
1210 |
// CMceOneRowListItemArrayLoader::SetItemMarked
|
|
1211 |
// ----------------------------------------------------
|
|
1212 |
void CMceOneRowListItemArrayLoader::SetItemMarked( TAknTreeItemID aFocused, TBool aState )
|
|
1213 |
{
|
|
1214 |
TInt index = ItemIndexTreeId( aFocused );
|
|
1215 |
|
|
1216 |
TInt subItemCount = GetSubfolderItemCount( aFocused );
|
|
1217 |
|
|
1218 |
if ( subItemCount != KErrNotFound && iHCListItemArray[index].iItemType == EHListItemSubtitle )
|
|
1219 |
{
|
|
1220 |
while ( index <= subItemCount )
|
|
1221 |
{
|
|
1222 |
iHCListItemArray[index].iMarked = aState;
|
|
1223 |
index++;
|
|
1224 |
}
|
|
1225 |
}
|
|
1226 |
else if ( aFocused == 1 )
|
|
1227 |
{
|
|
1228 |
TInt i = iHCListItemArray.Count()-1;
|
|
1229 |
while ( i >= 0)
|
|
1230 |
{
|
|
1231 |
iHCListItemArray[i].iMarked = aState;
|
|
1232 |
i--;
|
|
1233 |
}
|
|
1234 |
}
|
|
1235 |
else
|
|
1236 |
{
|
|
1237 |
// Set item marked
|
|
1238 |
iHCListItemArray[index].iMarked = aState;
|
|
1239 |
}
|
|
1240 |
}
|
|
1241 |
|
|
1242 |
|
|
1243 |
// ----------------------------------------------------
|
|
1244 |
// CMceOneRowListItemArrayLoader::GetItemMarkStatusL
|
|
1245 |
// ----------------------------------------------------
|
|
1246 |
TBool CMceOneRowListItemArrayLoader::GetItemMarkStatusL( TMsvId aEntryId )
|
|
1247 |
{
|
|
1248 |
TInt markedCount = iMarkedArray.Count();
|
|
1249 |
TInt index = iMarkedArray.Find( aEntryId );
|
|
1250 |
if ( index > KErrNotFound )
|
|
1251 |
{
|
|
1252 |
iMarkedArray.Remove( index );
|
|
1253 |
return ETrue;
|
|
1254 |
}
|
|
1255 |
|
|
1256 |
return EFalse;
|
|
1257 |
}
|
|
1258 |
|
|
1259 |
|
|
1260 |
// ----------------------------------------------------
|
|
1261 |
// CMceOneRowListItemArrayLoader::GetSubfolderItemCount
|
|
1262 |
// ----------------------------------------------------
|
|
1263 |
TInt CMceOneRowListItemArrayLoader::GetSubfolderItemCount( TAknTreeItemID aParent )
|
|
1264 |
{
|
|
1265 |
TInt itemCount = 0;
|
|
1266 |
TInt index = ItemIndexTreeId( aParent );
|
|
1267 |
if ( index != KErrNotFound && iHCListItemArray[index].iItemType == EHListItemSubtitle )
|
|
1268 |
{
|
|
1269 |
TInt arrCount = iHCListItemArray.Count()-1;
|
|
1270 |
while ( index < arrCount && iHCListItemArray[index + 1].iItemType != EHListItemSubtitle )
|
|
1271 |
{
|
|
1272 |
index++;
|
|
1273 |
itemCount++;
|
|
1274 |
}
|
|
1275 |
}
|
|
1276 |
else
|
|
1277 |
{
|
|
1278 |
return KErrNotFound;
|
|
1279 |
}
|
|
1280 |
return itemCount;
|
|
1281 |
}
|
|
1282 |
|
|
1283 |
|
|
1284 |
// ----------------------------------------------------
|
|
1285 |
// CMceOneRowListItemArrayLoader::ResetTreeItemId
|
|
1286 |
// ----------------------------------------------------
|
|
1287 |
void CMceOneRowListItemArrayLoader::ResetTreeItemId( TAknTreeItemID aTreeItemId )
|
|
1288 |
{
|
|
1289 |
TInt index = ItemIndexTreeId( aTreeItemId );
|
|
1290 |
if ( index >= 0 )
|
|
1291 |
{
|
|
1292 |
iHCListItemArray[index].iTreeItemId = 0;
|
|
1293 |
}
|
|
1294 |
}
|
|
1295 |
|
|
1296 |
|
|
1297 |
// ----------------------------------------------------
|
|
1298 |
// CMceOneRowListItemArrayLoader::FolderEntry
|
|
1299 |
// ----------------------------------------------------
|
|
1300 |
const TMsvEntry& CMceOneRowListItemArrayLoader::FolderEntry() const
|
|
1301 |
{
|
|
1302 |
return iFolderEntry->Entry();
|
|
1303 |
}
|
|
1304 |
|
|
1305 |
|
|
1306 |
// ----------------------------------------------------
|
|
1307 |
// CMceMessageListItemArray::GetParentFolder
|
|
1308 |
// ----------------------------------------------------
|
|
1309 |
TMsvId CMceOneRowListItemArrayLoader::GetParentFolderId() const
|
|
1310 |
{
|
|
1311 |
return iFolderEntry->Entry().Parent();
|
|
1312 |
}
|
|
1313 |
|
|
1314 |
|
|
1315 |
// ----------------------------------------------------
|
|
1316 |
// CMceOneRowListItemArrayLoader::FindFirstUnreadMessageL
|
|
1317 |
// ----------------------------------------------------
|
|
1318 |
TBool CMceOneRowListItemArrayLoader::FindFirstUnreadMessageL( TMsvId& aEntryId ) const
|
|
1319 |
{
|
|
1320 |
aEntryId = KErrNotFound;
|
|
1321 |
TInt numberOfUnreadMessages = 0;
|
|
1322 |
const TInt itemCount = iFolderEntry->Count();
|
|
1323 |
for ( TInt loop = 0; loop < itemCount; loop++ )
|
|
1324 |
{
|
|
1325 |
if ( (*iFolderEntry)[loop].iType == KUidMsvMessageEntry &&
|
|
1326 |
(*iFolderEntry)[loop].Unread() )
|
|
1327 |
{
|
|
1328 |
if ( aEntryId == KErrNotFound )
|
|
1329 |
{
|
|
1330 |
aEntryId = (*iFolderEntry)[loop].Id();
|
|
1331 |
}
|
|
1332 |
numberOfUnreadMessages++;
|
|
1333 |
if ( numberOfUnreadMessages > 1 )
|
|
1334 |
{
|
|
1335 |
// we are only interested of first unread message and info that if
|
|
1336 |
// there are more than one unread messages.
|
|
1337 |
// So we can stop if there are more than one.
|
|
1338 |
break;
|
|
1339 |
}
|
|
1340 |
}
|
|
1341 |
}
|
|
1342 |
return (numberOfUnreadMessages == 1);
|
|
1343 |
}
|
|
1344 |
|
|
1345 |
|
|
1346 |
// ----------------------------------------------------
|
|
1347 |
// CMceOneRowListItemArrayLoader::FindUnreadMessageUnderSubtitleL
|
|
1348 |
// ----------------------------------------------------
|
|
1349 |
TBool CMceOneRowListItemArrayLoader::FindUnreadMessageUnderSubtitleL( TAknTreeItemID aSubtitleID )
|
|
1350 |
{
|
|
1351 |
TInt itemCount = GetSubfolderItemCount( aSubtitleID );
|
|
1352 |
|
|
1353 |
TInt startIndex = ItemIndexTreeId( aSubtitleID ) + 1;
|
|
1354 |
for ( TInt loop = startIndex ; loop < itemCount + startIndex ; loop++ )
|
|
1355 |
{
|
|
1356 |
TMsvId entryId = iHCListItemArray[loop].iEntryId;
|
|
1357 |
TMsvEntry entry;
|
|
1358 |
TInt error = GetEntry(entryId, entry );
|
|
1359 |
if ( !error && entry.Unread() )
|
|
1360 |
{
|
|
1361 |
return ETrue;
|
|
1362 |
}
|
|
1363 |
}
|
|
1364 |
return EFalse;
|
|
1365 |
}
|
|
1366 |
|
|
1367 |
|
|
1368 |
// ----------------------------------------------------
|
|
1369 |
// CMceOneRowListItemArrayLoader::FolderCount
|
|
1370 |
// ----------------------------------------------------
|
|
1371 |
TInt CMceOneRowListItemArrayLoader::FolderCount()
|
|
1372 |
{
|
|
1373 |
TInt numberOfFolders = 0;
|
|
1374 |
const TInt itemCount = iFolderEntry->Count();
|
|
1375 |
for ( TInt loop = 0; loop < itemCount; loop++ )
|
|
1376 |
{
|
|
1377 |
if ( (*iFolderEntry)[loop].iType == KUidMsvFolderEntry )
|
|
1378 |
{
|
|
1379 |
numberOfFolders++;
|
|
1380 |
}
|
|
1381 |
else if ( (*iFolderEntry)[loop].iType == KUidMsvMessageEntry )
|
|
1382 |
{
|
|
1383 |
// folders are grouped first, so we can stop when first message is reached.
|
|
1384 |
break; //loop = itemCount;
|
|
1385 |
}
|
|
1386 |
}
|
|
1387 |
return numberOfFolders;
|
|
1388 |
}
|
|
1389 |
|
|
1390 |
|
|
1391 |
// ----------------------------------------------------
|
|
1392 |
// CMceMessageListItemArray::MessageCount
|
|
1393 |
// ----------------------------------------------------
|
|
1394 |
TInt CMceOneRowListItemArrayLoader::MessageCount()
|
|
1395 |
{
|
|
1396 |
TInt numberOfMessages = 0;
|
|
1397 |
const TInt itemCount = iFolderEntry->Count();
|
|
1398 |
for ( TInt loop = 0; loop < itemCount; loop++ )
|
|
1399 |
{
|
|
1400 |
if ( (*iFolderEntry)[loop].iType == KUidMsvMessageEntry )
|
|
1401 |
{
|
|
1402 |
numberOfMessages++;
|
|
1403 |
}
|
|
1404 |
}
|
|
1405 |
return numberOfMessages;
|
|
1406 |
}
|
|
1407 |
|
|
1408 |
|
|
1409 |
// ----------------------------------------------------
|
|
1410 |
// CMceOneRowListItemArrayLoader::IsConnected
|
|
1411 |
// return ETrue, if account is connected
|
|
1412 |
//
|
|
1413 |
// ----------------------------------------------------
|
|
1414 |
TBool CMceOneRowListItemArrayLoader::IsConnected() const
|
|
1415 |
{
|
|
1416 |
TMsvEntry entry;
|
|
1417 |
entry = iFolderEntry->Entry();
|
|
1418 |
|
|
1419 |
TMsvEntry serviceEntry;
|
|
1420 |
TMsvId serviceId;
|
|
1421 |
if ( iSession->GetEntry(entry.iServiceId,serviceId,serviceEntry) == KErrNone )
|
|
1422 |
{
|
|
1423 |
return serviceEntry.Connected();
|
|
1424 |
}
|
|
1425 |
else
|
|
1426 |
{
|
|
1427 |
return EFalse;
|
|
1428 |
}
|
|
1429 |
}
|
|
1430 |
|
|
1431 |
|
|
1432 |
// ----------------------------------------------------
|
|
1433 |
// CMceOneRowListItemArrayLoader::FindEntryIndex
|
|
1434 |
// Finds entry index in message list
|
|
1435 |
//
|
|
1436 |
// ----------------------------------------------------
|
|
1437 |
TInt CMceOneRowListItemArrayLoader::FindEntryIndex( const TDesC& aMatchString ) const
|
|
1438 |
{
|
|
1439 |
TInt foundIndex = KErrNotFound;
|
|
1440 |
TMsvSelectionOrdering ordering( KMsvNoGrouping, EMsvSortByDateReverse, EFalse );
|
|
1441 |
ordering = iFolderEntry->SortType();
|
|
1442 |
|
|
1443 |
const TInt count = iFolderEntry->Count();
|
|
1444 |
const TInt length = aMatchString.Length();
|
|
1445 |
|
|
1446 |
if ( ( ordering.Sorting() == EMsvSortByDetails ) ||
|
|
1447 |
( ordering.Sorting() == EMsvSortByDetailsReverse ) )
|
|
1448 |
{
|
|
1449 |
for( TInt loop = 0; loop < count && foundIndex == KErrNotFound ; loop++ )
|
|
1450 |
{
|
|
1451 |
if ( aMatchString.CompareF( ( *iFolderEntry )[loop].iDetails.Left( length ) ) == 0 )
|
|
1452 |
{
|
|
1453 |
foundIndex = loop;
|
|
1454 |
}
|
|
1455 |
}
|
|
1456 |
}
|
|
1457 |
else if ( ( ordering.Sorting() == EMsvSortByDescription ) ||
|
|
1458 |
( ordering.Sorting() == EMsvSortByDescriptionReverse ) )
|
|
1459 |
{
|
|
1460 |
for( TInt loop = 0; loop < count && foundIndex == KErrNotFound ; loop++ )
|
|
1461 |
{
|
|
1462 |
TBufC<100> tmpString( ( *iFolderEntry )[loop].iDescription.Left(KSortSubjectStringLength) );
|
|
1463 |
TInt start = SkipPrefix( tmpString.Des() );
|
|
1464 |
if ( start < tmpString.Length() && tmpString.Length() >= length )
|
|
1465 |
{
|
|
1466 |
TPtrC mid = (*iFolderEntry)[loop].iDescription.Mid( start, length );
|
|
1467 |
if ( aMatchString.CompareF( mid ) == 0 )
|
|
1468 |
{
|
|
1469 |
foundIndex = loop;
|
|
1470 |
}
|
|
1471 |
}
|
|
1472 |
}
|
|
1473 |
}
|
|
1474 |
else
|
|
1475 |
{
|
|
1476 |
//EMsvSortByReverse, nothing cannot be searched
|
|
1477 |
}
|
|
1478 |
return foundIndex;
|
|
1479 |
}
|
|
1480 |
|
|
1481 |
|
|
1482 |
// ----------------------------------------------------
|
|
1483 |
// CMceOneRowListItemArrayLoader::SkipPrefix
|
|
1484 |
// Removes the "Re:" or "Fw:" prefixes from the given
|
|
1485 |
// text string
|
|
1486 |
// ----------------------------------------------------
|
|
1487 |
TInt CMceOneRowListItemArrayLoader::SkipPrefix( TPtrC aTextString ) const
|
|
1488 |
{
|
|
1489 |
TPtrC searchString( aTextString );
|
|
1490 |
TPtrC searchStringOrig( aTextString );
|
|
1491 |
TInt matchInd = searchString.Match( KSortSubjectSkipString );
|
|
1492 |
TInt matchStart = 0;
|
|
1493 |
TInt lenRight = searchString.Length() - matchInd - 1;
|
|
1494 |
|
|
1495 |
// Find the last prefix character
|
|
1496 |
while ( matchInd != KErrNotFound && lenRight > 0 )
|
|
1497 |
{
|
|
1498 |
TPtrC searchString2 = searchString.Right( lenRight );
|
|
1499 |
matchStart += matchInd + 1;
|
|
1500 |
matchInd = searchString2.Match( KSortSubjectSkipString );
|
|
1501 |
lenRight = searchString2.Length() - matchInd - 1;
|
|
1502 |
searchString.Set( searchString2 );
|
|
1503 |
}
|
|
1504 |
|
|
1505 |
// Skip the white space after the prefix character
|
|
1506 |
matchInd = searchStringOrig.LocateReverse( KWhiteSpaceCharacter );
|
|
1507 |
if ( matchInd != KErrNotFound && matchStart == matchInd )
|
|
1508 |
{
|
|
1509 |
++matchStart;
|
|
1510 |
}
|
|
1511 |
return matchStart;
|
|
1512 |
}
|
|
1513 |
|
|
1514 |
|
|
1515 |
// ----------------------------------------------------
|
|
1516 |
// CMceOneRowListItemArrayLoader::EntryCreatedL
|
|
1517 |
// ----------------------------------------------------
|
|
1518 |
TInt CMceOneRowListItemArrayLoader::EntryCreatedL( TMsvId aEntryId )
|
|
1519 |
{
|
|
1520 |
MCELOGGER_ENTERFN("CMceOneRowListItemArrayLoader::EntryCreatedL");
|
|
1521 |
if ( IsActive() )
|
|
1522 |
{
|
|
1523 |
MCELOGGER_WRITE("Already active, ignore");
|
|
1524 |
MCELOGGER_LEAVEFN("CMceOneRowListItemArrayLoader::EntryCreatedL");
|
|
1525 |
return 0;
|
|
1526 |
}
|
|
1527 |
// how to make sure iFolderEntry is already updated?
|
|
1528 |
MCELOGGER_WRITE_FORMAT("aEntryId = 0x%x", aEntryId );
|
|
1529 |
CMsvEntry* folderEntry = CMsvEntry::NewL(
|
|
1530 |
*iSession,
|
|
1531 |
iFolderEntry->EntryId(),
|
|
1532 |
iFolderEntry->SortType() );
|
|
1533 |
CleanupStack::PushL( folderEntry );
|
|
1534 |
|
|
1535 |
TInt entryIndex = KErrNotFound;
|
|
1536 |
TInt i = 0;
|
|
1537 |
const TInt count = folderEntry->Count();
|
|
1538 |
#ifdef _DEBUG
|
|
1539 |
while ( i < folderEntry->Count() )
|
|
1540 |
{
|
|
1541 |
MCELOGGER_WRITE_FORMAT2("(*folderEntry)[%d].Id() = 0x%x", i, (*folderEntry)[i].Id() );
|
|
1542 |
i++;
|
|
1543 |
}
|
|
1544 |
i = 0;
|
|
1545 |
#endif
|
|
1546 |
while ( i < folderEntry->Count() && entryIndex == KErrNotFound )
|
|
1547 |
{
|
|
1548 |
if ( (*folderEntry)[i].Id() == aEntryId )
|
|
1549 |
{
|
|
1550 |
MCELOGGER_WRITE_FORMAT("found entry at index %d", i );
|
|
1551 |
entryIndex = i;
|
|
1552 |
}
|
|
1553 |
i++;
|
|
1554 |
}
|
|
1555 |
CleanupStack::Pop( folderEntry );
|
|
1556 |
delete iFolderEntry;
|
|
1557 |
iFolderEntry = folderEntry;
|
|
1558 |
|
|
1559 |
TInt createdCount = 0;
|
|
1560 |
|
|
1561 |
if ( entryIndex > KErrNotFound )
|
|
1562 |
{
|
|
1563 |
createdCount = InsertEntryL( entryIndex, aEntryId );
|
|
1564 |
}
|
|
1565 |
|
|
1566 |
MCELOGGER_LEAVEFN("CMceOneRowListItemArrayLoader::EntryCreatedL");
|
|
1567 |
return createdCount;
|
|
1568 |
}
|
|
1569 |
|
|
1570 |
|
|
1571 |
// ----------------------------------------------------
|
|
1572 |
// CMceOneRowListItemArrayLoader::InsertEntryL
|
|
1573 |
// ----------------------------------------------------
|
|
1574 |
TInt CMceOneRowListItemArrayLoader::InsertEntryL( TInt aEntryIndex, TMsvId aEntryId )
|
|
1575 |
{
|
|
1576 |
MCELOGGER_ENTERFN("CMceOneRowListItemArrayLoader::InsertEntryL");
|
|
1577 |
MCELOGGER_WRITE_FORMAT("aEntryId: 0x%x", aEntryId );
|
|
1578 |
MCELOGGER_WRITE_FORMAT("aEntryIndex: %d", aEntryIndex );
|
|
1579 |
iDuplicate = EFalse;
|
|
1580 |
TInt previous = FindPreviousFromArrayL( aEntryId );
|
|
1581 |
if ( iDuplicate )
|
|
1582 |
{
|
|
1583 |
// Entry already exist in array return without creating a new instance
|
|
1584 |
return 0;
|
|
1585 |
}
|
|
1586 |
TInt next = FindNextFromArrayL( aEntryId );
|
|
1587 |
|
|
1588 |
if ( iDuplicate )
|
|
1589 |
{
|
|
1590 |
// Entry already exist in array return without creating a new instance
|
|
1591 |
return 0;
|
|
1592 |
}
|
|
1593 |
|
|
1594 |
MCELOGGER_WRITE_FORMAT2("previous index: %d, next index %d", previous, next );
|
|
1595 |
TBool previousAnchor = EFalse;
|
|
1596 |
|
|
1597 |
if ( iFolderEntry->operator[](aEntryIndex).iType == KUidMsvFolderEntry )
|
|
1598 |
{
|
|
1599 |
TInt count = InsertFolderEntryL( aEntryIndex, aEntryId );
|
|
1600 |
MCELOGGER_LEAVEFN("CMceOneRowListItemArrayLoader::InsertEntryL - folder insert");
|
|
1601 |
return count;
|
|
1602 |
}
|
|
1603 |
|
|
1604 |
TInt needSubtitle = ETrue;
|
|
1605 |
|
|
1606 |
TMsvId insertId = KErrNotFound;
|
|
1607 |
|
|
1608 |
// Index to end of the array by default
|
|
1609 |
TInt insertIndex = iHCListItemArray.Count();
|
|
1610 |
|
|
1611 |
// Sorting by type don't have subtitles
|
|
1612 |
if ( iListType == EHCListTypeType )
|
|
1613 |
{
|
|
1614 |
needSubtitle = EFalse;
|
|
1615 |
if ( next > 0 )
|
|
1616 |
{
|
|
1617 |
insertIndex = next-1;
|
|
1618 |
}
|
|
1619 |
}
|
|
1620 |
|
|
1621 |
// Find closest entry with same subtitle
|
|
1622 |
if ( needSubtitle )
|
|
1623 |
{
|
|
1624 |
// Search subtitle for preceding entry
|
|
1625 |
if ( previous > KErrNotFound )
|
|
1626 |
{
|
|
1627 |
if ( SameSubtitle( aEntryIndex, previous ) )
|
|
1628 |
{
|
|
1629 |
MCELOGGER_WRITE_FORMAT("Prev index %d has SAME subtitle", previous );
|
|
1630 |
needSubtitle = EFalse;
|
|
1631 |
insertId = iFolderEntry->operator[](previous).Id();
|
|
1632 |
previousAnchor = ETrue;
|
|
1633 |
MCELOGGER_WRITE_FORMAT("Id 0x%x has SAME subtitle", insertId );
|
|
1634 |
}
|
|
1635 |
}
|
|
1636 |
// Search subtitle for following entry
|
|
1637 |
if ( needSubtitle && next > KErrNotFound )
|
|
1638 |
{
|
|
1639 |
insertId = iFolderEntry->operator[](next).Id();
|
|
1640 |
if ( SameSubtitle( aEntryIndex, next ) )
|
|
1641 |
{
|
|
1642 |
MCELOGGER_WRITE_FORMAT("Next index %d has SAME subtitle", next );
|
|
1643 |
needSubtitle = EFalse;
|
|
1644 |
previousAnchor = EFalse;
|
|
1645 |
MCELOGGER_WRITE_FORMAT("Id 0x%x has SAME subtitle", insertId );
|
|
1646 |
}
|
|
1647 |
}
|
|
1648 |
}
|
|
1649 |
|
|
1650 |
#ifdef _DEBUG
|
|
1651 |
TInt tempcount = iHCListItemArray.Count();
|
|
1652 |
MCELOGGER_WRITE_FORMAT("array before add, count %d", tempcount );
|
|
1653 |
for( TInt loop = 0; loop < tempcount; loop++)
|
|
1654 |
{
|
|
1655 |
if ( iHCListItemArray[loop].iItemType == EHListItemEntry )
|
|
1656 |
{
|
|
1657 |
MCELOGGER_WRITE_FORMAT2("%d entry 0x%x", loop, iHCListItemArray[loop].iEntryId );
|
|
1658 |
}
|
|
1659 |
else
|
|
1660 |
{
|
|
1661 |
MCELOGGER_WRITE_FORMAT2("%d subtitle 0x%x", loop, iHCListItemArray[loop].iEntryId );
|
|
1662 |
}
|
|
1663 |
}
|
|
1664 |
#endif
|
|
1665 |
|
|
1666 |
|
|
1667 |
// First index and no following entry
|
|
1668 |
if ( aEntryIndex == 0 && insertId <= 0 )
|
|
1669 |
{
|
|
1670 |
insertIndex = 0; // to the beginning...
|
|
1671 |
}
|
|
1672 |
|
|
1673 |
// If neighbour entry
|
|
1674 |
if ( insertId > 0 )
|
|
1675 |
{
|
|
1676 |
MCELOGGER_WRITE_FORMAT("try to find entry 0x%x", insertId );
|
|
1677 |
const TInt count = iHCListItemArray.Count();
|
|
1678 |
|
|
1679 |
// First find entry which already exists in iHCListItemArray
|
|
1680 |
for( TInt loop = 0; loop < count; loop++)
|
|
1681 |
{
|
|
1682 |
if ( iHCListItemArray[loop].iEntryId == insertId &&
|
|
1683 |
iHCListItemArray[loop].iItemType == EHListItemEntry )
|
|
1684 |
{
|
|
1685 |
MCELOGGER_WRITE_FORMAT("FOUND message index %d", loop );
|
|
1686 |
insertIndex = loop;
|
|
1687 |
|
|
1688 |
if ( previousAnchor )
|
|
1689 |
{
|
|
1690 |
insertIndex++;
|
|
1691 |
}
|
|
1692 |
|
|
1693 |
break;
|
|
1694 |
}
|
|
1695 |
}
|
|
1696 |
// next find corresponding subtitle row
|
|
1697 |
while ( needSubtitle && insertIndex >= 0
|
|
1698 |
&& iHCListItemArray[insertIndex].iItemType != EHListItemSubtitle )
|
|
1699 |
{
|
|
1700 |
insertIndex--;
|
|
1701 |
}
|
|
1702 |
MCELOGGER_WRITE_FORMAT("subtitle index %d", insertIndex );
|
|
1703 |
}
|
|
1704 |
|
|
1705 |
|
|
1706 |
// Insert entry item
|
|
1707 |
THCListListItem item;
|
|
1708 |
item.iTreeItemId = 0;
|
|
1709 |
item.iEntryId = aEntryId;
|
|
1710 |
item.iItemType = EHListItemEntry;
|
|
1711 |
iHCListItemArray.InsertL( item, insertIndex );
|
|
1712 |
TInt createdCount = 1;
|
|
1713 |
MCELOGGER_WRITE_FORMAT("Inserted item to %d", insertIndex );
|
|
1714 |
|
|
1715 |
// Add subtitle if needed
|
|
1716 |
if ( needSubtitle )
|
|
1717 |
{
|
|
1718 |
item.iItemType = EHListItemSubtitle;
|
|
1719 |
if ( iListType == EHCListTypeTime )
|
|
1720 |
{
|
|
1721 |
TTime entryTime = iFolderEntry->operator[](aEntryIndex).iDate;
|
|
1722 |
GetTime( entryTime );
|
|
1723 |
item.iSubtitleType = TimeBasedSubtitleType( entryTime, ETrue );
|
|
1724 |
}
|
|
1725 |
else
|
|
1726 |
{
|
|
1727 |
item.iSubtitleType = 0;
|
|
1728 |
}
|
|
1729 |
|
|
1730 |
iHCListItemArray.InsertL( item, insertIndex );
|
|
1731 |
MCELOGGER_WRITE_FORMAT("Inserted subtitle to %d", insertIndex );
|
|
1732 |
createdCount++;
|
|
1733 |
}
|
|
1734 |
|
|
1735 |
// Handle entries that has been received during the list creation
|
|
1736 |
if ( iEntriesReceivedDuringListCreation && iListItemArrayObserver )
|
|
1737 |
{
|
|
1738 |
CArrayFixFlat<TInt>* itemsAdded = new (ELeave) CArrayFixFlat<TInt>(4);
|
|
1739 |
CleanupStack::PushL( itemsAdded );
|
|
1740 |
itemsAdded->AppendL( insertIndex );
|
|
1741 |
if ( needSubtitle )
|
|
1742 |
{
|
|
1743 |
itemsAdded->AppendL( insertIndex+1 );
|
|
1744 |
}
|
|
1745 |
iListItemArrayObserver->MceListItemArrayChangedL( *itemsAdded );
|
|
1746 |
CleanupStack::PopAndDestroy( itemsAdded );
|
|
1747 |
}
|
|
1748 |
|
|
1749 |
#ifdef _DEBUG
|
|
1750 |
tempcount = iHCListItemArray.Count();
|
|
1751 |
MCELOGGER_WRITE_FORMAT("array AFTER add, count %d", tempcount );
|
|
1752 |
for( TInt loop = 0; loop < tempcount; loop++)
|
|
1753 |
{
|
|
1754 |
if ( iHCListItemArray[loop].iItemType == EHListItemEntry )
|
|
1755 |
{
|
|
1756 |
MCELOGGER_WRITE_FORMAT2("%d entry 0x%x", loop, iHCListItemArray[loop].iEntryId );
|
|
1757 |
}
|
|
1758 |
else
|
|
1759 |
{
|
|
1760 |
MCELOGGER_WRITE_FORMAT2("%d subtitle 0x%x", loop, iHCListItemArray[loop].iEntryId );
|
|
1761 |
}
|
|
1762 |
}
|
|
1763 |
#endif
|
|
1764 |
|
|
1765 |
MCELOGGER_LEAVEFN("CMceOneRowListItemArrayLoader::InsertEntryL");
|
|
1766 |
return createdCount;
|
|
1767 |
}
|
|
1768 |
|
|
1769 |
|
|
1770 |
// ----------------------------------------------------
|
|
1771 |
// CMceOneRowListItemArrayLoader::SameSubtitle
|
|
1772 |
// ----------------------------------------------------
|
|
1773 |
TBool CMceOneRowListItemArrayLoader::SameSubtitle( TInt aIndex1, TInt aIndex2 )
|
|
1774 |
{
|
|
1775 |
TBool sameSubtitle = EFalse;
|
|
1776 |
|
|
1777 |
// Time based subtitles
|
|
1778 |
if ( iListType == EHCListTypeTime )
|
|
1779 |
{
|
|
1780 |
|
|
1781 |
TTime entryDate1 = iFolderEntry->operator[](aIndex1).iDate;
|
|
1782 |
GetTime( entryDate1 );
|
|
1783 |
TTime entryDate2 = iFolderEntry->operator[](aIndex2).iDate;
|
|
1784 |
GetTime( entryDate2 );
|
|
1785 |
TInt subtitle1 = TimeBasedSubtitleType( entryDate1, ETrue );
|
|
1786 |
TInt subtitle2 = TimeBasedSubtitleType( entryDate2, EFalse );
|
|
1787 |
|
|
1788 |
if ( subtitle1 == subtitle2 )
|
|
1789 |
{
|
|
1790 |
sameSubtitle = ETrue;
|
|
1791 |
}
|
|
1792 |
}
|
|
1793 |
|
|
1794 |
// Sender based subtitles
|
|
1795 |
else if ( iListType == EHCListTypeSender )
|
|
1796 |
{
|
|
1797 |
TMsvEntry previousEntry = iFolderEntry->operator[](aIndex1);
|
|
1798 |
TMsvEntry currentEntry = iFolderEntry->operator[](aIndex2);
|
|
1799 |
if ( currentEntry.iDetails.Compare(previousEntry.iDetails) == 0 )
|
|
1800 |
{
|
|
1801 |
sameSubtitle = ETrue;
|
|
1802 |
}
|
|
1803 |
}
|
|
1804 |
|
|
1805 |
// Subject based subtitles
|
|
1806 |
else if ( iListType == EHCListTypeSubject )
|
|
1807 |
{
|
|
1808 |
TMsvEntry previousEntry = iFolderEntry->operator[](aIndex1);
|
|
1809 |
TMsvEntry currentEntry = iFolderEntry->operator[](aIndex2);
|
|
1810 |
|
|
1811 |
// Remove prefix from current entry description
|
|
1812 |
TBufC<100> tmpString( currentEntry.iDescription.Left( KSortSubjectStringLength ) );
|
|
1813 |
const TInt length1 = tmpString.Length();
|
|
1814 |
TInt start = SkipPrefix( tmpString.Des() );
|
|
1815 |
TPtrC currentMid = currentEntry.iDescription.Mid( start, length1 - start );
|
|
1816 |
|
|
1817 |
//Remove prefix from previous entry description
|
|
1818 |
TBufC<100> tmpString2( previousEntry.iDescription.Left( KSortSubjectStringLength ) );
|
|
1819 |
const TInt length2 = tmpString2.Length();
|
|
1820 |
start = SkipPrefix( tmpString2.Des() );
|
|
1821 |
TPtrC prevMid = previousEntry.iDescription.Mid( start, length2 - start );
|
|
1822 |
|
|
1823 |
// Compare descriptions
|
|
1824 |
if ( currentMid.CompareF( prevMid ) == 0 )
|
|
1825 |
{
|
|
1826 |
sameSubtitle = ETrue;
|
|
1827 |
}
|
|
1828 |
}
|
|
1829 |
|
|
1830 |
// Type based sorting don't have subtitles. Return ETrue so new subtitle are not created
|
|
1831 |
else if ( iListType == EHCListTypeType )
|
|
1832 |
{
|
|
1833 |
sameSubtitle = ETrue;
|
|
1834 |
}
|
|
1835 |
|
|
1836 |
return sameSubtitle;
|
|
1837 |
}
|
|
1838 |
|
|
1839 |
|
|
1840 |
// ----------------------------------------------------
|
|
1841 |
// CMceOneRowListItemArrayLoader::InsertFolderEntryL
|
|
1842 |
// ----------------------------------------------------
|
|
1843 |
TInt CMceOneRowListItemArrayLoader::InsertFolderEntryL( TInt aEntryIndex, TMsvId aEntryId )
|
|
1844 |
{
|
|
1845 |
MCELOGGER_ENTERFN("CMceOneRowListItemArrayLoader::InsertFolderEntryL");
|
|
1846 |
THCListListItem item;
|
|
1847 |
item.iTreeItemId = 0;
|
|
1848 |
item.iEntryId = aEntryId;
|
|
1849 |
item.iItemType = EHListItemEntry;
|
|
1850 |
iHCListItemArray.InsertL( item, aEntryIndex );
|
|
1851 |
MCELOGGER_WRITE_FORMAT("Inserted item to %d", aEntryIndex );
|
|
1852 |
MCELOGGER_LEAVEFN("CMceOneRowListItemArrayLoader::InsertFolderEntryL");
|
|
1853 |
return 1;
|
|
1854 |
}
|
|
1855 |
|
|
1856 |
|
|
1857 |
// ----------------------------------------------------
|
|
1858 |
// CMceOneRowListItemArrayLoader::EntryDeletedL
|
|
1859 |
// ----------------------------------------------------
|
|
1860 |
TBool CMceOneRowListItemArrayLoader::EntryDeletedL(
|
|
1861 |
TMsvId aEntryId,
|
|
1862 |
TAknTreeItemID& aTreeItemId,
|
|
1863 |
TAknTreeItemID& aParentTreeItemId )
|
|
1864 |
{
|
|
1865 |
aParentTreeItemId = KAknTreeIIDNone;
|
|
1866 |
aTreeItemId = KAknTreeIIDNone;
|
|
1867 |
TBool deleteParent = EFalse;
|
|
1868 |
TInt itemIndex = ItemIndex( aEntryId );
|
|
1869 |
if ( itemIndex >= 0 )
|
|
1870 |
{
|
|
1871 |
aTreeItemId = TreeItemId( itemIndex );
|
|
1872 |
TAknTreeItemID parentTreeItemId = ParentItemId( itemIndex );
|
|
1873 |
|
|
1874 |
iHCListItemArray.Remove( itemIndex );
|
|
1875 |
|
|
1876 |
if ( parentTreeItemId > KAknTreeIIDRoot )
|
|
1877 |
{
|
|
1878 |
TInt parentIndex = ItemIndexTreeId( parentTreeItemId );
|
|
1879 |
if ( parentIndex >= 0 )
|
|
1880 |
{
|
|
1881 |
TInt i = parentIndex+1;
|
|
1882 |
TInt count = iHCListItemArray.Count();
|
|
1883 |
if( i < count && iHCListItemArray[i].iItemType == EHListItemEntry )
|
|
1884 |
{
|
|
1885 |
i++;
|
|
1886 |
}
|
|
1887 |
if ( i-parentIndex == 1 )
|
|
1888 |
{
|
|
1889 |
// we must delete parent also
|
|
1890 |
iHCListItemArray.Remove( parentIndex );
|
|
1891 |
deleteParent = ETrue;
|
|
1892 |
}
|
|
1893 |
}
|
|
1894 |
aParentTreeItemId = parentTreeItemId;
|
|
1895 |
}
|
|
1896 |
}
|
|
1897 |
return deleteParent;
|
|
1898 |
}
|
|
1899 |
|
|
1900 |
|
|
1901 |
// ----------------------------------------------------
|
|
1902 |
// CMceOneRowListItemArrayLoader::GetTime
|
|
1903 |
// ----------------------------------------------------
|
|
1904 |
void CMceOneRowListItemArrayLoader::GetTime( TTime& aEntryTime ) const
|
|
1905 |
{
|
|
1906 |
TTime homeTime;
|
|
1907 |
homeTime.HomeTime();
|
|
1908 |
|
|
1909 |
TTime timeNow;
|
|
1910 |
timeNow.UniversalTime();
|
|
1911 |
|
|
1912 |
TTimeIntervalMinutes timeZone;
|
|
1913 |
if ( homeTime.MinutesFrom(timeNow, timeZone) == KErrNone )
|
|
1914 |
{
|
|
1915 |
aEntryTime = aEntryTime + timeZone;
|
|
1916 |
}
|
|
1917 |
}
|
|
1918 |
|
|
1919 |
|
|
1920 |
// ----------------------------------------------------
|
|
1921 |
// CMceOneRowListItemArrayLoader::GetCurrentTime
|
|
1922 |
// ----------------------------------------------------
|
|
1923 |
void CMceOneRowListItemArrayLoader::GetCurrentTime( TTime& aCurrentTime ) const
|
|
1924 |
{
|
|
1925 |
TTime timeNow;
|
|
1926 |
timeNow.HomeTime();
|
|
1927 |
TDateTime dateTime = timeNow.DateTime();
|
|
1928 |
dateTime.SetHour( KMceTimeHours );
|
|
1929 |
dateTime.SetMinute( KMceTimeMinutes );
|
|
1930 |
dateTime.SetSecond( KMceTimeSeconds );
|
|
1931 |
dateTime.SetMicroSecond( KMceTimeMicroSeconds );
|
|
1932 |
aCurrentTime = dateTime;
|
|
1933 |
}
|
|
1934 |
|
|
1935 |
|
|
1936 |
// ----------------------------------------------------
|
|
1937 |
// CMceOneRowListItemArrayLoader::FindPreviousFromArrayL
|
|
1938 |
// ----------------------------------------------------
|
|
1939 |
TInt CMceOneRowListItemArrayLoader::FindPreviousFromArrayL( TMsvId aId )
|
|
1940 |
{
|
|
1941 |
// Get snapshot from message store
|
|
1942 |
CMsvEntrySelection* children = iFolderEntry->ChildrenL();
|
|
1943 |
CleanupStack::PushL( children );
|
|
1944 |
|
|
1945 |
// Find index in message store
|
|
1946 |
TInt index = children->Find( aId );
|
|
1947 |
TMsvId prevId = KErrNotFound;
|
|
1948 |
|
|
1949 |
if ( index == KErrNotFound )
|
|
1950 |
{
|
|
1951 |
CleanupStack::PopAndDestroy( children );
|
|
1952 |
return KErrNotFound;
|
|
1953 |
}
|
|
1954 |
|
|
1955 |
TInt foundItem = KErrNotFound;
|
|
1956 |
// Go through previous entry indexes in array until end or match found
|
|
1957 |
while ( index >= 0 && foundItem == KErrNotFound )
|
|
1958 |
{
|
|
1959 |
prevId = (*children)[index];
|
|
1960 |
const TInt count = iHCListItemArray.Count();
|
|
1961 |
for( TInt loop = 0; loop < count && foundItem == KErrNotFound ; loop++)
|
|
1962 |
{
|
|
1963 |
// Previous entry exists in list
|
|
1964 |
if ( iHCListItemArray[loop].iEntryId == prevId &&
|
|
1965 |
iHCListItemArray[loop].iItemType == EHListItemEntry )
|
|
1966 |
{
|
|
1967 |
foundItem = loop;
|
|
1968 |
}
|
|
1969 |
|
|
1970 |
// Entry with same Id exists already
|
|
1971 |
if ( iHCListItemArray[loop].iEntryId == aId &&
|
|
1972 |
iHCListItemArray[loop].iItemType == EHListItemEntry )
|
|
1973 |
{
|
|
1974 |
iDuplicate = ETrue;
|
|
1975 |
}
|
|
1976 |
}
|
|
1977 |
if ( foundItem == KErrNotFound )
|
|
1978 |
{
|
|
1979 |
index--;
|
|
1980 |
}
|
|
1981 |
}
|
|
1982 |
// Previous item found, return id
|
|
1983 |
if ( foundItem > KErrNotFound )
|
|
1984 |
{
|
|
1985 |
foundItem = children->Find( prevId );
|
|
1986 |
}
|
|
1987 |
CleanupStack::PopAndDestroy( children );
|
|
1988 |
return foundItem;
|
|
1989 |
}
|
|
1990 |
|
|
1991 |
|
|
1992 |
// ----------------------------------------------------
|
|
1993 |
// CMceOneRowListItemArrayLoader::FindNextFromArrayL
|
|
1994 |
// ----------------------------------------------------
|
|
1995 |
TInt CMceOneRowListItemArrayLoader::FindNextFromArrayL( TMsvId aId )
|
|
1996 |
{
|
|
1997 |
CMsvEntrySelection* children = iFolderEntry->ChildrenL();
|
|
1998 |
CleanupStack::PushL( children );
|
|
1999 |
|
|
2000 |
TInt index = children->Find( aId );
|
|
2001 |
TMsvId nextId = KErrNotFound;
|
|
2002 |
|
|
2003 |
if ( index == KErrNotFound )
|
|
2004 |
{
|
|
2005 |
CleanupStack::PopAndDestroy( children );
|
|
2006 |
return KErrNotFound;
|
|
2007 |
}
|
|
2008 |
|
|
2009 |
const TInt childrenCount = children->Count();
|
|
2010 |
TInt foundItem = KErrNotFound;
|
|
2011 |
while ( index < childrenCount && foundItem == KErrNotFound )
|
|
2012 |
{
|
|
2013 |
nextId = (*children)[index];
|
|
2014 |
const TInt count = iHCListItemArray.Count();
|
|
2015 |
for( TInt loop = 0; loop < count && foundItem == KErrNotFound ; loop++)
|
|
2016 |
{
|
|
2017 |
if ( iHCListItemArray[loop].iEntryId == nextId &&
|
|
2018 |
iHCListItemArray[loop].iItemType == EHListItemEntry )
|
|
2019 |
{
|
|
2020 |
foundItem = loop;
|
|
2021 |
}
|
|
2022 |
|
|
2023 |
if ( iHCListItemArray[loop].iEntryId == aId &&
|
|
2024 |
iHCListItemArray[loop].iItemType == EHListItemEntry )
|
|
2025 |
{
|
|
2026 |
iDuplicate = ETrue;
|
|
2027 |
}
|
|
2028 |
}
|
|
2029 |
if ( foundItem == KErrNotFound )
|
|
2030 |
{
|
|
2031 |
index++;
|
|
2032 |
}
|
|
2033 |
}
|
|
2034 |
|
|
2035 |
if ( foundItem > KErrNotFound )
|
|
2036 |
{
|
|
2037 |
foundItem = children->Find( nextId );
|
|
2038 |
}
|
|
2039 |
CleanupStack::PopAndDestroy( children );
|
|
2040 |
return foundItem;
|
|
2041 |
}
|
|
2042 |
|
|
2043 |
|
|
2044 |
// ----------------------------------------------------
|
|
2045 |
// CMceOneRowListItemArrayLoader::TimeBasedSubtitleType
|
|
2046 |
// ----------------------------------------------------
|
|
2047 |
TInt CMceOneRowListItemArrayLoader::TimeBasedSubtitleType( TTime& aTime, TBool aUpdateCurrentTime )
|
|
2048 |
{
|
|
2049 |
if ( aUpdateCurrentTime )
|
|
2050 |
{
|
|
2051 |
UpdateCurrentTime();
|
|
2052 |
}
|
|
2053 |
TInt timeBasedSubtitleType = 0;
|
|
2054 |
|
|
2055 |
if ( aTime >= iToday )
|
|
2056 |
{
|
|
2057 |
timeBasedSubtitleType = ETodayAdded;
|
|
2058 |
}
|
|
2059 |
else if ( aTime >= iYesterday )
|
|
2060 |
{
|
|
2061 |
timeBasedSubtitleType = EYesterdayAdded;
|
|
2062 |
}
|
|
2063 |
else if ( aTime < iTwoWeeksAgo )
|
|
2064 |
{
|
|
2065 |
timeBasedSubtitleType = EOlderAdded;
|
|
2066 |
}
|
|
2067 |
else if ( aTime < iOneWeekAgo )
|
|
2068 |
{
|
|
2069 |
timeBasedSubtitleType = ELastWeekAdded;
|
|
2070 |
}
|
|
2071 |
else
|
|
2072 |
{
|
|
2073 |
timeBasedSubtitleType = aTime.DayNoInWeek();
|
|
2074 |
}
|
|
2075 |
return timeBasedSubtitleType;
|
|
2076 |
}
|
|
2077 |
|
|
2078 |
|
|
2079 |
// ----------------------------------------------------
|
|
2080 |
// CMceOneRowListItemArrayLoader::UpdateCurrentTime
|
|
2081 |
// ----------------------------------------------------
|
|
2082 |
void CMceOneRowListItemArrayLoader::UpdateCurrentTime()
|
|
2083 |
{
|
|
2084 |
TTime timeNow;
|
|
2085 |
GetCurrentTime( timeNow );
|
|
2086 |
TLocale locale;
|
|
2087 |
TDay startOfWeek = locale.StartOfWeek();
|
|
2088 |
TTimeIntervalDays oneDay( KMceTimeOneDay );
|
|
2089 |
TInt firstDayInWeek = timeNow.DayNoInWeek() - startOfWeek + 1;
|
|
2090 |
if ( firstDayInWeek < 0 )
|
|
2091 |
{
|
|
2092 |
firstDayInWeek+=ESunday+1;
|
|
2093 |
}
|
|
2094 |
TTimeIntervalDays oneWeek( firstDayInWeek );
|
|
2095 |
iOneWeekAgo = timeNow-oneWeek;
|
|
2096 |
|
|
2097 |
TTimeIntervalDays twoWeeks( KMceTimeOneWeek );
|
|
2098 |
iTwoWeeksAgo = iOneWeekAgo-twoWeeks;
|
|
2099 |
iToday = timeNow-oneDay;
|
|
2100 |
iYesterday = iToday-oneDay;
|
|
2101 |
}
|
|
2102 |
|
|
2103 |
// ----------------------------------------------------
|
|
2104 |
// CMceOneRowListItemArrayLoader::SaveMarkingL
|
|
2105 |
// ----------------------------------------------------
|
|
2106 |
void CMceOneRowListItemArrayLoader::SaveMarkingL( RArray<TAknTreeItemID>& aMarked )
|
|
2107 |
{
|
|
2108 |
TInt count( aMarked.Count() );
|
|
2109 |
iMarkedArray.Reset();
|
|
2110 |
for (TInt loop = 0; loop < count; loop++ )
|
|
2111 |
{
|
|
2112 |
TMsvId id = MsvItemId( aMarked[ loop ] );
|
|
2113 |
if ( id != KErrNotFound )
|
|
2114 |
{
|
|
2115 |
iMarkedArray.AppendL( id );
|
|
2116 |
}
|
|
2117 |
}
|
|
2118 |
}
|
|
2119 |
|
|
2120 |
// ----------------------------------------------------
|
|
2121 |
// CMceOneRowListItemArrayLoader::TodayTime
|
|
2122 |
// ----------------------------------------------------
|
|
2123 |
TTime CMceOneRowListItemArrayLoader::TodayTime ()
|
|
2124 |
{
|
|
2125 |
return iToday ;
|
|
2126 |
}
|
|
2127 |
|
|
2128 |
// ----------------------------------------------------
|
|
2129 |
// CMceMessageListItemArray::CreateEntryIndex()
|
|
2130 |
// ----------------------------------------------------
|
|
2131 |
void CMceOneRowListItemArrayLoader::CreateCmailEntryIndexL()
|
|
2132 |
{
|
|
2133 |
iCmailSelectionList = new( ELeave ) CMsvEntrySelection() ;
|
|
2134 |
|
|
2135 |
//Find email messages
|
|
2136 |
CMsvEntrySelection *smtpselection = iFolderEntry->ChildrenWithMtmL( KUidMsgTypeSMTP );
|
|
2137 |
CleanupStack::PushL( smtpselection );
|
|
2138 |
|
|
2139 |
CMsvEntrySelection *pop3selection = NULL;
|
|
2140 |
CMsvEntrySelection *imapselection = NULL ;
|
|
2141 |
CMsvEntrySelection *cmailselection = NULL ;
|
|
2142 |
|
|
2143 |
if(!iEmailFramework)
|
|
2144 |
{
|
|
2145 |
pop3selection = iFolderEntry->ChildrenWithMtmL( KUidMsgTypePOP3 );
|
|
2146 |
CleanupStack::PushL( pop3selection );
|
|
2147 |
imapselection = iFolderEntry->ChildrenWithMtmL( KUidMsgTypeIMAP4 );
|
|
2148 |
CleanupStack::PushL( imapselection );
|
|
2149 |
}
|
|
2150 |
else
|
|
2151 |
{
|
|
2152 |
cmailselection = iFolderEntry->ChildrenWithMtmL( TUid::Uid(KUidMsgTypeCmailMtmVal) );
|
|
2153 |
CleanupStack::PushL( cmailselection );
|
|
2154 |
}
|
|
2155 |
|
|
2156 |
iCmailSelectionList->Reset();
|
|
2157 |
|
|
2158 |
if ( smtpselection!=0 && smtpselection->Count()>0 )
|
|
2159 |
{
|
|
2160 |
for( TInt i=0 ; i < smtpselection->Count() ; i++ )
|
|
2161 |
{
|
|
2162 |
iCmailSelectionList->AppendL( smtpselection->At(i) );
|
|
2163 |
}
|
|
2164 |
}
|
|
2165 |
if(!iEmailFramework)
|
|
2166 |
{
|
|
2167 |
if ( pop3selection!=0 && pop3selection->Count()>0 )
|
|
2168 |
{
|
|
2169 |
for( TInt i=0 ; i < pop3selection->Count() ; i++ )
|
|
2170 |
{
|
|
2171 |
iCmailSelectionList->AppendL( pop3selection->At(i) );
|
|
2172 |
}
|
|
2173 |
}
|
|
2174 |
if ( imapselection!=0 && imapselection->Count()>0 )
|
|
2175 |
{
|
|
2176 |
for( TInt i=0 ; i < imapselection->Count() ; i++ )
|
|
2177 |
{
|
|
2178 |
iCmailSelectionList->AppendL( imapselection->At(i) );
|
|
2179 |
}
|
|
2180 |
}
|
|
2181 |
}
|
|
2182 |
else
|
|
2183 |
{
|
|
2184 |
if ( cmailselection!=0 && cmailselection->Count()>0 )
|
|
2185 |
{
|
|
2186 |
for( TInt i=0 ; i < cmailselection->Count() ; i++ )
|
|
2187 |
{
|
|
2188 |
iCmailSelectionList->AppendL( cmailselection->At(i) );
|
|
2189 |
}
|
|
2190 |
}
|
|
2191 |
}
|
|
2192 |
if(iEmailFramework)
|
|
2193 |
{
|
|
2194 |
CleanupStack::PopAndDestroy( cmailselection );
|
|
2195 |
}
|
|
2196 |
else
|
|
2197 |
{
|
|
2198 |
CleanupStack::PopAndDestroy(imapselection);
|
|
2199 |
CleanupStack::PopAndDestroy( pop3selection );
|
|
2200 |
}
|
|
2201 |
CleanupStack::PopAndDestroy( smtpselection );
|
|
2202 |
}
|
|
2203 |
|
|
2204 |
|
|
2205 |
TBool CMceOneRowListItemArrayLoader::CheckCmailEntryIndexL (TMsvId aId)
|
|
2206 |
{
|
|
2207 |
if ( iCmailSelectionList->Find( aId ) == KErrNotFound )
|
|
2208 |
{
|
|
2209 |
return ETrue;
|
|
2210 |
}
|
|
2211 |
else
|
|
2212 |
{
|
|
2213 |
return EFalse;
|
|
2214 |
}
|
|
2215 |
}
|
|
2216 |
|
|
2217 |
// End of File
|