44 { |
44 { |
45 if ( iEntrySelection ) |
45 if ( iEntrySelection ) |
46 { |
46 { |
47 iEntrySelection->Reset(); |
47 iEntrySelection->Reset(); |
48 } |
48 } |
|
49 if ( IsActive() ) |
|
50 { |
|
51 iCallNotifyForCancelFlag = EFalse; |
|
52 Cancel(); |
|
53 } |
49 |
54 |
50 iMtmArrayId.Reset(); |
55 iMtmArrayId.Reset(); |
51 |
56 |
52 delete iEntrySelection; |
57 delete iEntrySelection; |
53 delete iFilter; |
58 delete iFilter; |
|
59 delete iNotifyCallback; |
54 } |
60 } |
55 |
61 |
56 // --------------------------------------------------------------------------- |
62 // --------------------------------------------------------------------------- |
57 // Constructor. |
63 // Constructor. |
58 // --------------------------------------------------------------------------- |
64 // --------------------------------------------------------------------------- |
59 // |
65 // |
60 CMessagingAccessFolder::CMessagingAccessFolder( CMsvSession& aServerSession ): |
66 CMessagingAccessFolder::CMessagingAccessFolder( CMsvSession& aServerSession ): |
61 iServerSession(aServerSession) |
67 iServerSession(aServerSession), |
62 { |
68 CActive( EPriorityStandard ), |
63 } |
69 iCallNotifyForCancelFlag(ETrue) |
|
70 { |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // Activates the asynchronous request |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 void CMessagingAccessFolder::ActivateRequest( TInt aReason ) |
|
78 { |
|
79 iStatus = KRequestPending; |
|
80 SetActive(); |
|
81 TRequestStatus* temp = &iStatus; |
|
82 User::RequestComplete( temp, aReason ); |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // Inherited from CActive class |
|
87 // --------------------------------------------------------------------------- |
|
88 // |
|
89 void CMessagingAccessFolder::DoCancel() |
|
90 { |
|
91 NotifyRequestResult( KErrCancel,iEntrySelection, iFilter ); |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------------------------- |
|
95 // Inherited from CActive class |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 void CMessagingAccessFolder::RunL() |
|
99 { |
|
100 TInt err = iStatus.Int(); |
|
101 if ( err == KErrNone ) |
|
102 { |
|
103 TInt groupingKey = KMsvNoGrouping; |
|
104 TMsvSelectionOrdering order( groupingKey, iFilter->SortType() ); |
|
105 CMsvEntry* entry = iServerSession.GetEntryL( iFolderId ); |
|
106 CleanupStack::PushL( entry ); |
|
107 |
|
108 // Getlist can be performed on Folders entries only |
|
109 if ( entry->Entry().iType != KUidMsvFolderEntry ) |
|
110 { |
|
111 User::Leave( KErrArgument ); |
|
112 } |
|
113 |
|
114 entry->SetSortTypeL( order ); |
|
115 |
|
116 InitializeMtmArray(); |
|
117 |
|
118 if ( iEntrySelection ) |
|
119 { |
|
120 iEntrySelection->Reset(); |
|
121 delete iEntrySelection; |
|
122 iEntrySelection = NULL; |
|
123 } |
|
124 |
|
125 if ( iMtmArrayId.Count() == 1 ) |
|
126 { |
|
127 iEntrySelection = entry->ChildrenWithMtmL( iMtmArrayId[0] ); |
|
128 } |
|
129 else |
|
130 { |
|
131 iEntrySelection = entry->ChildrenL(); |
|
132 } |
|
133 |
|
134 CleanupStack::PopAndDestroy( entry ); |
|
135 NotifyRequestResult( KErrNone, iEntrySelection, iFilter); |
|
136 } |
|
137 else |
|
138 { |
|
139 NotifyRequestResult( err, iEntrySelection, iFilter); |
|
140 } |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // Sets message input parameters |
|
145 // aMessageParam/aNotifyCallback ownership is passed to this |
|
146 // --------------------------------------------------------------------------- |
|
147 // |
|
148 void CMessagingAccessFolder::SetInputParamsL(CMsgCallbackBase* aNotifyCallback , |
|
149 MAsyncRequestObserver* aAsyncRequestObserver ) |
|
150 { |
|
151 |
|
152 iNotifyCallback = aNotifyCallback; |
|
153 iAsyncRequestObserver = aAsyncRequestObserver; |
|
154 } |
64 |
155 |
65 void CMessagingAccessFolder::GetIdListL(TMsvId aFolderId , |
156 void CMessagingAccessFolder::GetIdListL(TMsvId aFolderId , |
66 CFilterParamInfo* aFilter, |
157 CFilterParamInfo* aFilter, |
67 CMsvEntrySelection*& aEntrySelection ) |
158 CMsvEntrySelection*& aEntrySelection ) |
68 { |
159 { |
102 // call function for filtering the message headers. |
193 // call function for filtering the message headers. |
103 // --------------------------------------------------------------------------- |
194 // --------------------------------------------------------------------------- |
104 // |
195 // |
105 void CMessagingAccessFolder::GetListL() |
196 void CMessagingAccessFolder::GetListL() |
106 { |
197 { |
107 TInt groupingKey = KMsvNoGrouping; |
198 if ( iNotifyCallback ) // making call as asynchronous |
108 TMsvSelectionOrdering order( groupingKey, iFilter->SortType() ); |
199 { |
109 CMsvEntry* entry = iServerSession.GetEntryL( iFolderId ); |
200 CActiveScheduler::Add( this ); |
110 CleanupStack::PushL( entry ); |
201 ActivateRequest( KErrNone ); |
111 |
202 } |
112 // Getlist can be performed on Folders entries only |
|
113 if ( entry->Entry().iType != KUidMsvFolderEntry ) |
|
114 { |
|
115 User::Leave( KErrArgument ); |
|
116 } |
|
117 |
|
118 entry->SetSortTypeL( order ); |
|
119 |
|
120 InitializeMtmArray(); |
|
121 |
|
122 if ( iEntrySelection ) |
|
123 { |
|
124 iEntrySelection->Reset(); |
|
125 delete iEntrySelection; |
|
126 iEntrySelection = NULL; |
|
127 } |
|
128 |
|
129 if ( iMtmArrayId.Count() == 1 ) |
|
130 { |
|
131 iEntrySelection = entry->ChildrenWithMtmL( iMtmArrayId[0] ); |
|
132 } |
|
133 else |
203 else |
134 { |
204 { |
135 iEntrySelection = entry->ChildrenL(); |
205 TInt groupingKey = KMsvNoGrouping; |
136 } |
206 TMsvSelectionOrdering order( groupingKey, iFilter->SortType() ); |
137 |
207 CMsvEntry* entry = iServerSession.GetEntryL( iFolderId ); |
138 CleanupStack::PopAndDestroy( entry ); |
208 CleanupStack::PushL( entry ); |
139 } |
209 |
|
210 // Getlist can be performed on Folders entries only |
|
211 if ( entry->Entry().iType != KUidMsvFolderEntry ) |
|
212 { |
|
213 User::Leave( KErrArgument ); |
|
214 } |
|
215 |
|
216 entry->SetSortTypeL( order ); |
|
217 |
|
218 InitializeMtmArray(); |
|
219 |
|
220 if ( iEntrySelection ) |
|
221 { |
|
222 iEntrySelection->Reset(); |
|
223 delete iEntrySelection; |
|
224 iEntrySelection = NULL; |
|
225 } |
|
226 |
|
227 if ( iMtmArrayId.Count() == 1 ) |
|
228 { |
|
229 iEntrySelection = entry->ChildrenWithMtmL( iMtmArrayId[0] ); |
|
230 } |
|
231 else |
|
232 { |
|
233 iEntrySelection = entry->ChildrenL(); |
|
234 } |
|
235 |
|
236 CleanupStack::PopAndDestroy( entry ); |
|
237 } |
|
238 } |
|
239 |
|
240 // --------------------------------------------------------------------------- |
|
241 // Notifies callback the result for asynchronous request. |
|
242 // --------------------------------------------------------------------------- |
|
243 // |
|
244 void CMessagingAccessFolder::NotifyRequestResult( TInt aReason,CMsvEntrySelection* aEntrySelection ,CFilterParamInfo* aFilter ) |
|
245 |
|
246 { |
|
247 if ( iNotifyCallback ) |
|
248 { |
|
249 iEntrySelection=NULL; |
|
250 iFilter=NULL; |
|
251 iAsyncRequestObserver->RequestComplete( iNotifyCallback->iTransactionId ); |
|
252 |
|
253 if( iCallNotifyForCancelFlag ) |
|
254 { |
|
255 TRAPD( err, iNotifyCallback->HandleGetlistL( aReason, aEntrySelection, aFilter )); |
|
256 } |
|
257 |
|
258 } |
|
259 // caller will delete the object in case of cancel |
|
260 if ( aReason != KErrCancel ) |
|
261 delete this; |
|
262 } |
140 |
263 |
141 // --------------------------------------------------------------------------- |
264 // --------------------------------------------------------------------------- |
142 // Initializes the MtmID array by the Mtm string passed |
265 // Initializes the MtmID array by the Mtm string passed |
143 // by user. |
266 // by user. |
144 // --------------------------------------------------------------------------- |
267 // --------------------------------------------------------------------------- |