author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Thu, 24 Sep 2009 12:43:20 +0300 | |
changeset 12 | f4292e0e20df |
parent 10 | fc9cf246af83 |
child 23 | 50974a8b132e |
permissions | -rw-r--r-- |
5 | 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 the License "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: Implementation of class CMessagingAccessFolder |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
#include <e32base.h> |
|
21 |
#include <badesca.h> |
|
22 |
#include <msvapi.h> |
|
23 |
#include <MsvUids.h> |
|
24 |
#include <senduiconsts.h> |
|
25 |
||
26 |
#include "messageheader.h" |
|
27 |
#include "accessfolder.h" |
|
28 |
||
29 |
// --------------------------------------------------------------------------- |
|
30 |
// Two-phased constructor. |
|
31 |
// --------------------------------------------------------------------------- |
|
32 |
// |
|
33 |
CMessagingAccessFolder* CMessagingAccessFolder::NewL( CMsvSession& aServerSession ) |
|
34 |
{ |
|
35 |
CMessagingAccessFolder* self = new (ELeave) CMessagingAccessFolder( aServerSession ); |
|
36 |
return self; |
|
37 |
} |
|
38 |
||
39 |
// --------------------------------------------------------------------------- |
|
40 |
// Destructor. |
|
41 |
// --------------------------------------------------------------------------- |
|
42 |
// |
|
43 |
CMessagingAccessFolder::~CMessagingAccessFolder() |
|
44 |
{ |
|
45 |
if ( iEntrySelection ) |
|
46 |
{ |
|
47 |
iEntrySelection->Reset(); |
|
48 |
} |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
49 |
if ( IsActive() ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
50 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
51 |
iCallNotifyForCancelFlag = EFalse; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
52 |
Cancel(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
53 |
} |
5 | 54 |
|
55 |
iMtmArrayId.Reset(); |
|
56 |
||
57 |
delete iEntrySelection; |
|
58 |
delete iFilter; |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
59 |
delete iNotifyCallback; |
5 | 60 |
} |
61 |
||
62 |
// --------------------------------------------------------------------------- |
|
63 |
// Constructor. |
|
64 |
// --------------------------------------------------------------------------- |
|
65 |
// |
|
66 |
CMessagingAccessFolder::CMessagingAccessFolder( CMsvSession& aServerSession ): |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
67 |
iServerSession(aServerSession), |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
68 |
CActive( EPriorityStandard ), |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
69 |
iCallNotifyForCancelFlag(ETrue) |
5 | 70 |
{ |
71 |
} |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
72 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
73 |
// --------------------------------------------------------------------------- |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
74 |
// Activates the asynchronous request |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
75 |
// --------------------------------------------------------------------------- |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
76 |
// |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
77 |
void CMessagingAccessFolder::ActivateRequest( TInt aReason ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
78 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
79 |
iStatus = KRequestPending; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
80 |
SetActive(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
81 |
TRequestStatus* temp = &iStatus; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
82 |
User::RequestComplete( temp, aReason ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
83 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
84 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
85 |
// --------------------------------------------------------------------------- |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
86 |
// Inherited from CActive class |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
87 |
// --------------------------------------------------------------------------- |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
88 |
// |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
89 |
void CMessagingAccessFolder::DoCancel() |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
90 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
91 |
NotifyRequestResult( KErrCancel,iEntrySelection, iFilter ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
92 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
93 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
94 |
// --------------------------------------------------------------------------- |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
95 |
// Inherited from CActive class |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
96 |
// --------------------------------------------------------------------------- |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
97 |
// |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
98 |
void CMessagingAccessFolder::RunL() |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
99 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
100 |
TInt err = iStatus.Int(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
101 |
if ( err == KErrNone ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
102 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
103 |
TInt groupingKey = KMsvNoGrouping; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
104 |
TMsvSelectionOrdering order( groupingKey, iFilter->SortType() ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
105 |
CMsvEntry* entry = iServerSession.GetEntryL( iFolderId ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
106 |
CleanupStack::PushL( entry ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
107 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
108 |
// Getlist can be performed on Folders entries only |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
109 |
if ( entry->Entry().iType != KUidMsvFolderEntry ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
110 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
111 |
User::Leave( KErrArgument ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
112 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
113 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
114 |
entry->SetSortTypeL( order ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
115 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
116 |
InitializeMtmArray(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
117 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
118 |
if ( iEntrySelection ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
119 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
120 |
iEntrySelection->Reset(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
121 |
delete iEntrySelection; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
122 |
iEntrySelection = NULL; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
123 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
124 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
125 |
if ( iMtmArrayId.Count() == 1 ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
126 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
127 |
iEntrySelection = entry->ChildrenWithMtmL( iMtmArrayId[0] ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
128 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
129 |
else |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
130 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
131 |
iEntrySelection = entry->ChildrenL(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
132 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
133 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
134 |
CleanupStack::PopAndDestroy( entry ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
135 |
NotifyRequestResult( KErrNone, iEntrySelection, iFilter); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
136 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
137 |
else |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
138 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
139 |
NotifyRequestResult( err, iEntrySelection, iFilter); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
140 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
141 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
142 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
143 |
// --------------------------------------------------------------------------- |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
144 |
// Sets message input parameters |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
145 |
// aMessageParam/aNotifyCallback ownership is passed to this |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
146 |
// --------------------------------------------------------------------------- |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
147 |
// |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
148 |
void CMessagingAccessFolder::SetInputParamsL(CMsgCallbackBase* aNotifyCallback , |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
149 |
MAsyncRequestObserver* aAsyncRequestObserver ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
150 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
151 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
152 |
iNotifyCallback = aNotifyCallback; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
153 |
iAsyncRequestObserver = aAsyncRequestObserver; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
154 |
} |
5 | 155 |
|
156 |
void CMessagingAccessFolder::GetIdListL(TMsvId aFolderId , |
|
157 |
CFilterParamInfo* aFilter, |
|
158 |
CMsvEntrySelection*& aEntrySelection ) |
|
159 |
{ |
|
160 |
if ( !iFilter ) |
|
161 |
iFilter = CFilterParamInfo::NewL(); |
|
162 |
||
163 |
if( aFilter ) //added this check to do the copy only if aFilter is not NULL |
|
164 |
*iFilter = *aFilter; |
|
165 |
iFolderId = aFolderId; |
|
166 |
||
167 |
GetListL(); |
|
168 |
||
169 |
aEntrySelection = iEntrySelection; |
|
170 |
iEntrySelection = NULL; |
|
171 |
} |
|
172 |
||
173 |
void CMessagingAccessFolder::GetNextHeaderL( CFilterParamInfo* aFilter, |
|
174 |
CMsvEntrySelection* aEntrySelection, |
|
175 |
TInt& aIndex, |
|
176 |
CMessageHeader*& aHeader ) |
|
177 |
{ |
|
178 |
if(!aEntrySelection || ( aEntrySelection->Count() <= aIndex )) |
|
179 |
return; |
|
180 |
||
181 |
if ( !iFilter ) |
|
182 |
iFilter = CFilterParamInfo::NewL(); |
|
183 |
||
184 |
if( aFilter ) //added this check to do the copy only if aFilter is not NULL |
|
185 |
*iFilter = *aFilter; |
|
186 |
||
187 |
GetNextFilteredHeaderL( aEntrySelection, aIndex, aHeader ); |
|
188 |
||
189 |
} |
|
190 |
||
191 |
// --------------------------------------------------------------------------- |
|
192 |
// Gives the list of message headers ,sets the sorting order and |
|
193 |
// call function for filtering the message headers. |
|
194 |
// --------------------------------------------------------------------------- |
|
195 |
// |
|
196 |
void CMessagingAccessFolder::GetListL() |
|
197 |
{ |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
198 |
if ( iNotifyCallback ) // making call as asynchronous |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
199 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
200 |
CActiveScheduler::Add( this ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
201 |
ActivateRequest( KErrNone ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
202 |
} |
5 | 203 |
else |
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
204 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
205 |
TInt groupingKey = KMsvNoGrouping; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
206 |
TMsvSelectionOrdering order( groupingKey, iFilter->SortType() ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
207 |
CMsvEntry* entry = iServerSession.GetEntryL( iFolderId ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
208 |
CleanupStack::PushL( entry ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
209 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
210 |
// Getlist can be performed on Folders entries only |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
211 |
if ( entry->Entry().iType != KUidMsvFolderEntry ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
212 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
213 |
User::Leave( KErrArgument ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
214 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
215 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
216 |
entry->SetSortTypeL( order ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
217 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
218 |
InitializeMtmArray(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
219 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
220 |
if ( iEntrySelection ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
221 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
222 |
iEntrySelection->Reset(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
223 |
delete iEntrySelection; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
224 |
iEntrySelection = NULL; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
225 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
226 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
227 |
if ( iMtmArrayId.Count() == 1 ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
228 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
229 |
iEntrySelection = entry->ChildrenWithMtmL( iMtmArrayId[0] ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
230 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
231 |
else |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
232 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
233 |
iEntrySelection = entry->ChildrenL(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
234 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
235 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
236 |
CleanupStack::PopAndDestroy( entry ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
237 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
238 |
} |
5 | 239 |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
240 |
// --------------------------------------------------------------------------- |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
241 |
// Notifies callback the result for asynchronous request. |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
242 |
// --------------------------------------------------------------------------- |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
243 |
// |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
244 |
void CMessagingAccessFolder::NotifyRequestResult( TInt aReason,CMsvEntrySelection* aEntrySelection ,CFilterParamInfo* aFilter ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
245 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
246 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
247 |
if ( iNotifyCallback ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
248 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
249 |
iEntrySelection=NULL; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
250 |
iFilter=NULL; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
251 |
iAsyncRequestObserver->RequestComplete( iNotifyCallback->iTransactionId ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
252 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
253 |
if( iCallNotifyForCancelFlag ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
254 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
255 |
TRAPD( err, iNotifyCallback->HandleGetlistL( aReason, aEntrySelection, aFilter )); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
256 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
257 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
258 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
259 |
// caller will delete the object in case of cancel |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
260 |
if ( aReason != KErrCancel ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
261 |
delete this; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
262 |
} |
5 | 263 |
|
264 |
// --------------------------------------------------------------------------- |
|
265 |
// Initializes the MtmID array by the Mtm string passed |
|
266 |
// by user. |
|
267 |
// --------------------------------------------------------------------------- |
|
268 |
// |
|
269 |
void CMessagingAccessFolder::InitializeMtmArray() |
|
270 |
{ |
|
271 |
const CDesCArray* mtmArray = iFilter->Mtm(); |
|
272 |
||
273 |
iMtmArrayId.Reset(); |
|
274 |
||
275 |
if ( mtmArray ) |
|
276 |
{ |
|
277 |
for ( int i= 0; i< mtmArray->Count(); i++ ) |
|
278 |
{ |
|
279 |
if ( (*mtmArray)[i].CompareF( KMessageTypeSMS ) == KErrNone ) |
|
280 |
{ |
|
281 |
iMtmArrayId.Append( KSenduiMtmSmsUid ); |
|
282 |
} |
|
283 |
else if ( (*mtmArray)[i].CompareF( KMessageTypeMMS ) == KErrNone ) |
|
284 |
{ |
|
285 |
iMtmArrayId.Append( KSenduiMtmMmsUid ); |
|
286 |
} |
|
287 |
} |
|
288 |
} |
|
289 |
} |
|
290 |
||
291 |
// --------------------------------------------------------------------------- |
|
292 |
// Fetches next header based on input parameters |
|
293 |
// --------------------------------------------------------------------------- |
|
294 |
// |
|
295 |
void CMessagingAccessFolder::GetNextFilteredHeaderL( CMsvEntrySelection* aEntrySelection, |
|
296 |
TInt& aIndex, |
|
297 |
CMessageHeader*& aHeader ) |
|
298 |
{ |
|
299 |
TInt count = aEntrySelection->Count(); |
|
300 |
||
301 |
InitializeMtmArray(); |
|
302 |
||
303 |
for ( ;aIndex < count; ) |
|
304 |
{ |
|
305 |
TMsvId id = (*aEntrySelection)[aIndex]; |
|
306 |
TMsvEntry tentry; |
|
307 |
TMsvId serviceId; |
|
308 |
iServerSession.GetEntry( id, serviceId, tentry ); // Getting TMsvEntry |
|
309 |
||
310 |
aIndex++; |
|
311 |
||
312 |
if ( iFilter->Filter() & EFilterId ) |
|
313 |
{ |
|
314 |
if ( !FilterId( id ) ) |
|
315 |
continue; |
|
316 |
} |
|
317 |
||
318 |
if ( iFilter->Filter() & EFilterMtm ) |
|
319 |
{ |
|
320 |
if ( !FilterMtm( tentry ) ) |
|
321 |
continue; |
|
322 |
} |
|
323 |
||
324 |
if ( iFilter->Filter() & EFilterFrom ) |
|
325 |
{ |
|
326 |
if ( !FilterFrom( tentry ) ) |
|
327 |
continue; |
|
328 |
} |
|
329 |
||
330 |
if ( iFilter->Filter() & EFilterSubject ) |
|
331 |
{ |
|
332 |
if ( !FilterSubject( tentry ) ) |
|
333 |
continue; |
|
334 |
} |
|
335 |
||
336 |
if ( iFilter->Filter() & EFilterStartDate || |
|
337 |
iFilter->Filter() & EFilterEndDate ) |
|
338 |
{ |
|
339 |
if ( !FilterDate( tentry ) ) |
|
340 |
continue; |
|
341 |
} |
|
342 |
||
343 |
CMessageHeader * header = CMessageHeader::NewL(); |
|
344 |
CleanupStack::PushL( header ); |
|
345 |
header->SetMessageId( id ); |
|
346 |
header->SetFromL( tentry.iDetails ); |
|
347 |
header->SetMtmId( tentry.iMtm ); |
|
348 |
header->SetAttachFlag( tentry.Attachment() ); |
|
349 |
header->SetPriorityFlag( tentry.Priority() ); |
|
350 |
header->SetUnreadFlag( tentry.Unread() ); |
|
351 |
header->SetSubjectL( tentry.iDescription ); |
|
352 |
header->SetTime( tentry.iDate ); |
|
353 |
CleanupStack::Pop( header ); |
|
354 |
aHeader = header; |
|
355 |
break; |
|
356 |
} |
|
357 |
} |
|
358 |
||
359 |
// --------------------------------------------------------------------------- |
|
360 |
// Filters out with message id |
|
361 |
// --------------------------------------------------------------------------- |
|
362 |
// |
|
363 |
TBool CMessagingAccessFolder::FilterId(const TMsvId aMessageId) const |
|
364 |
{ |
|
365 |
if ( aMessageId == iFilter->MessageId() ) |
|
366 |
{ |
|
367 |
return ETrue; |
|
368 |
} |
|
369 |
return EFalse; |
|
370 |
} |
|
371 |
||
372 |
// --------------------------------------------------------------------------- |
|
373 |
// Filters out with mtm type |
|
374 |
// --------------------------------------------------------------------------- |
|
375 |
// |
|
376 |
TBool CMessagingAccessFolder::FilterMtm( const TMsvEntry& aEntry) const |
|
377 |
{ |
|
378 |
for ( int i= 0; i< iMtmArrayId.Count(); i++ ) |
|
379 |
{ |
|
380 |
if( iMtmArrayId[i] == aEntry.iMtm ) |
|
381 |
{ |
|
382 |
return ETrue; |
|
383 |
} |
|
384 |
} |
|
385 |
return EFalse; |
|
386 |
} |
|
387 |
||
388 |
// --------------------------------------------------------------------------- |
|
389 |
// Filters out with sender address |
|
390 |
// --------------------------------------------------------------------------- |
|
391 |
// |
|
392 |
TBool CMessagingAccessFolder::FilterFrom( const TMsvEntry& aEntry) const |
|
393 |
{ |
|
394 |
const CDesCArray* fromArray = iFilter->From(); |
|
395 |
for ( int i= 0; i < fromArray->Count(); i++ ) |
|
396 |
{ |
|
397 |
if ( aEntry.iDetails.FindF( (*fromArray)[i] ) != KErrNotFound ) |
|
398 |
{ |
|
399 |
return ETrue ; |
|
400 |
} |
|
401 |
} |
|
402 |
||
403 |
return EFalse ; |
|
404 |
} |
|
405 |
||
406 |
// --------------------------------------------------------------------------- |
|
407 |
// Filters out with subject |
|
408 |
// --------------------------------------------------------------------------- |
|
409 |
// |
|
410 |
TBool CMessagingAccessFolder::FilterSubject( const TMsvEntry& aEntry) const |
|
411 |
{ |
|
412 |
if ( aEntry.iDescription.FindF( iFilter->Subject() ) != KErrNotFound ) |
|
413 |
{ |
|
414 |
return ETrue ; |
|
415 |
} |
|
416 |
||
417 |
return EFalse; |
|
418 |
} |
|
419 |
||
420 |
// --------------------------------------------------------------------------- |
|
421 |
// Filters out with Date |
|
422 |
// --------------------------------------------------------------------------- |
|
423 |
// |
|
424 |
TBool CMessagingAccessFolder::FilterDate( const TMsvEntry& aEntry) const |
|
425 |
{ |
|
426 |
TDateTime startDateTime( iFilter->StartDate().DateTime().Year(), |
|
427 |
iFilter->StartDate().DateTime().Month(), |
|
428 |
iFilter->StartDate().DateTime().Day(), |
|
429 |
0, 0, 0, 0 ); |
|
430 |
||
431 |
TDateTime endDateTime( iFilter->EndDate().DateTime().Year(), |
|
432 |
iFilter->EndDate().DateTime().Month(), |
|
433 |
iFilter->EndDate().DateTime().Day(), |
|
434 |
0, 0, 0, 0 ); |
|
435 |
||
436 |
TDateTime checkDateTime( aEntry.iDate.DateTime().Year(), |
|
437 |
aEntry.iDate.DateTime().Month(), |
|
438 |
aEntry.iDate.DateTime().Day(), |
|
439 |
0, 0, 0, 0 ); |
|
440 |
||
441 |
TTime startTime( startDateTime ); |
|
442 |
TTime endTime( endDateTime ); |
|
443 |
TTime checkTime( checkDateTime ); |
|
444 |
||
445 |
if ( ( iFilter->Filter() & EFilterStartDate ) && |
|
446 |
( iFilter->Filter() & EFilterEndDate ) ) |
|
447 |
{ |
|
448 |
if ( checkTime >= startTime && checkTime <= endTime ) |
|
449 |
{ |
|
450 |
return ETrue; |
|
451 |
} |
|
452 |
} |
|
453 |
else if ( iFilter->Filter() & EFilterStartDate ) |
|
454 |
{ |
|
455 |
if( checkTime >= startTime ) |
|
456 |
{ |
|
457 |
return ETrue; |
|
458 |
} |
|
459 |
} |
|
460 |
else if ( iFilter->Filter() & EFilterEndDate ) |
|
461 |
{ |
|
462 |
if( checkTime <= endTime ) |
|
463 |
{ |
|
464 |
return ETrue; |
|
465 |
} |
|
466 |
} |
|
467 |
return EFalse; |
|
468 |
} |
|
469 |
||
470 |