| branch | GCC_SURGE |
| changeset 55 | cdd802add233 |
| parent 54 | 997a02608b3a |
| child 51 | d845db10c0d4 |
| 28:011f79704660 | 55:cdd802add233 |
|---|---|
36 /*! |
36 /*! |
37 Constructor |
37 Constructor |
38 */ |
38 */ |
39 NmFrameworkAdapter::NmFrameworkAdapter() |
39 NmFrameworkAdapter::NmFrameworkAdapter() |
40 : mFSfw(NULL), |
40 : mFSfw(NULL), |
41 mSearchObserver(NULL) |
41 mSearchObserver(NULL), |
42 { |
42 mCurrentMailBox(NULL), |
43 NMLOG("NmFrameworkAdapter::NmFrameworkAdapter() <---"); |
43 mStateExtension(NULL) |
44 |
44 { |
45 NM_FUNCTION; |
|
46 |
|
45 // get s60 email framework |
47 // get s60 email framework |
46 TRAP_IGNORE(mFSfw = CFSMailClient::NewL()); |
48 TRAP_IGNORE(mFSfw = CFSMailClient::NewL()); |
47 |
49 |
48 if (mFSfw) { |
50 if (mFSfw) { |
49 TRAP_IGNORE(mFSfw->AddObserverL(*this)); |
51 TRAP_IGNORE(mFSfw->AddObserverL(*this)); |
50 } |
52 } |
51 |
|
52 NMLOG("NmFrameworkAdapter::NmFrameworkAdapter() --->"); |
|
53 } |
53 } |
54 |
54 |
55 /*! |
55 /*! |
56 Destructor |
56 Destructor |
57 */ |
57 */ |
58 NmFrameworkAdapter::~NmFrameworkAdapter() |
58 NmFrameworkAdapter::~NmFrameworkAdapter() |
59 { |
59 { |
60 NM_FUNCTION; |
|
61 |
|
62 delete mCurrentMailBox; |
|
63 mCurrentMailBox = NULL; |
|
64 |
|
65 mStateExtension = NULL; |
|
66 |
|
60 if (mSearchObserver) { |
67 if (mSearchObserver) { |
61 delete mSearchObserver; |
68 delete mSearchObserver; |
62 mSearchObserver = NULL; |
69 mSearchObserver = NULL; |
63 } |
70 } |
64 |
71 |
77 |
84 |
78 \return Error code. |
85 \return Error code. |
79 */ |
86 */ |
80 int NmFrameworkAdapter::listMailboxIds(QList<NmId>& mailboxIdList) |
87 int NmFrameworkAdapter::listMailboxIds(QList<NmId>& mailboxIdList) |
81 { |
88 { |
89 NM_FUNCTION; |
|
90 |
|
82 QList<NmMailbox*> mailboxList; |
91 QList<NmMailbox*> mailboxList; |
83 int ret = listMailboxes(mailboxList); |
92 int ret = listMailboxes(mailboxList); |
84 |
93 |
85 if ( ret == NmNoError ) { |
94 if ( ret == NmNoError ) { |
86 QListIterator<NmMailbox*> iterator(mailboxList); |
95 QListIterator<NmMailbox*> iterator(mailboxList); |
101 |
110 |
102 \return Error code. |
111 \return Error code. |
103 */ |
112 */ |
104 int NmFrameworkAdapter::listMailboxes(QList<NmMailbox*>& mailboxList) |
113 int NmFrameworkAdapter::listMailboxes(QList<NmMailbox*>& mailboxList) |
105 { |
114 { |
115 NM_FUNCTION; |
|
116 |
|
106 // get list of mailboxes from all plugins |
117 // get list of mailboxes from all plugins |
107 TFSMailMsgId id; |
118 TFSMailMsgId id; |
108 id.SetNullId(); |
119 id.SetNullId(); |
109 RPointerArray<CFSMailBox> mailBoxes; |
120 RPointerArray<CFSMailBox> mailBoxes; |
110 |
121 |
137 |
148 |
138 \return Error code. |
149 \return Error code. |
139 */ |
150 */ |
140 int NmFrameworkAdapter::getMailboxById(const NmId& id, NmMailbox*& mailbox) |
151 int NmFrameworkAdapter::getMailboxById(const NmId& id, NmMailbox*& mailbox) |
141 { |
152 { |
153 NM_FUNCTION; |
|
154 |
|
142 const TFSMailMsgId mailMsgId(id.pluginId32(), id.id32()); |
155 const TFSMailMsgId mailMsgId(id.pluginId32(), id.id32()); |
143 CFSMailBox *box(NULL); |
156 CFSMailBox *box(NULL); |
144 TRAPD(err, box = mFSfw->GetMailBoxByUidL(mailMsgId)); |
157 TRAPD(err, box = mFSfw->GetMailBoxByUidL(mailMsgId)); |
145 if (err == KErrNone && box) { |
158 if (err == KErrNone && box) { |
146 mailbox = box->GetNmMailbox(); |
159 mailbox = box->GetNmMailbox(); |
149 } |
162 } |
150 return err; |
163 return err; |
151 } |
164 } |
152 |
165 |
153 /*! |
166 /*! |
154 Delete the mailbox with the given id. Not implemented yet. |
167 Deletes the mailbox with the given id asynchronously. |
155 |
168 |
156 \param id Id of the mailbox to be deleted. |
169 \param mailboxId Id of the mailbox to be deleted. |
157 |
170 |
158 \return Error code. |
171 \return Error code. |
159 */ |
172 */ |
160 int NmFrameworkAdapter::deleteMailboxById(const NmId& /*id*/) |
173 QPointer<NmOperation> NmFrameworkAdapter::deleteMailboxById(const NmId& mailboxId) |
161 { |
174 { |
162 return 0; |
175 NM_FUNCTION; |
176 QPointer<NmOperation> oper = new NmFwaDeleteMailboxOperation(mailboxId, *mFSfw); |
|
177 return oper; |
|
163 } |
178 } |
164 |
179 |
165 /*! |
180 /*! |
166 Returns folder |
181 Returns folder |
167 |
182 |
171 |
186 |
172 \return Error code. |
187 \return Error code. |
173 */ |
188 */ |
174 int NmFrameworkAdapter::getFolderById( const NmId& mailboxId, const NmId& folderId, NmFolder*& folder ) |
189 int NmFrameworkAdapter::getFolderById( const NmId& mailboxId, const NmId& folderId, NmFolder*& folder ) |
175 { |
190 { |
191 NM_FUNCTION; |
|
192 |
|
176 TRAPD(err, getFolderByIdL( mailboxId, folderId, folder ) ); |
193 TRAPD(err, getFolderByIdL( mailboxId, folderId, folder ) ); |
177 return err; |
194 return err; |
178 } |
195 } |
179 |
196 |
180 /*! |
197 /*! |
181 Leaving version of getFolderById function |
198 Leaving version of getFolderById function |
182 */ |
199 */ |
183 void NmFrameworkAdapter::getFolderByIdL( const NmId& mailboxId, const NmId& folderId, NmFolder*& folder ) |
200 void NmFrameworkAdapter::getFolderByIdL( const NmId& mailboxId, const NmId& folderId, NmFolder*& folder ) |
184 { |
201 { |
202 NM_FUNCTION; |
|
203 |
|
185 CFSMailFolder* fsFolder(NULL); |
204 CFSMailFolder* fsFolder(NULL); |
186 if (mFSfw) |
205 if (mFSfw) |
187 { |
206 { |
188 fsFolder = mFSfw->GetFolderByUidL(TFSMailMsgId(mailboxId), TFSMailMsgId(folderId)); |
207 fsFolder = mFSfw->GetFolderByUidL(TFSMailMsgId(mailboxId), TFSMailMsgId(folderId)); |
189 if (fsFolder) |
208 if (fsFolder) |
215 const NmId& mailboxId, |
234 const NmId& mailboxId, |
216 const NmId& folderId, |
235 const NmId& folderId, |
217 const NmId& messageId, |
236 const NmId& messageId, |
218 NmMessage*& message) |
237 NmMessage*& message) |
219 { |
238 { |
239 NM_FUNCTION; |
|
240 |
|
220 TRAPD(err, getMessageByIdL(mailboxId,folderId,messageId,message)); |
241 TRAPD(err, getMessageByIdL(mailboxId,folderId,messageId,message)); |
221 return err; |
242 return err; |
222 } |
243 } |
223 |
244 |
224 /*! |
245 /*! |
228 const NmId& mailboxId, |
249 const NmId& mailboxId, |
229 const NmId& folderId, |
250 const NmId& folderId, |
230 const NmId& messageId, |
251 const NmId& messageId, |
231 NmMessage*& message) |
252 NmMessage*& message) |
232 { |
253 { |
254 NM_FUNCTION; |
|
255 |
|
233 // select message details to be listed |
256 // select message details to be listed |
234 TFSMailDetails details(EFSMsgDataStructure); |
257 TFSMailDetails details(EFSMsgDataStructure); |
235 |
258 |
236 CFSMailMessage* newMessage(NULL); |
259 CFSMailMessage* newMessage(NULL); |
237 newMessage = mFSfw->GetMessageByUidL(TFSMailMsgId(mailboxId), TFSMailMsgId(folderId), |
260 newMessage = mFSfw->GetMessageByUidL(TFSMailMsgId(mailboxId), TFSMailMsgId(folderId), |
260 */ |
283 */ |
261 int NmFrameworkAdapter::listFolders( |
284 int NmFrameworkAdapter::listFolders( |
262 const NmId& mailboxId, |
285 const NmId& mailboxId, |
263 QList<NmFolder*>& folderList) |
286 QList<NmFolder*>& folderList) |
264 { |
287 { |
288 NM_FUNCTION; |
|
289 |
|
265 CFSMailBox* currentMailbox = NULL; |
290 CFSMailBox* currentMailbox = NULL; |
266 TRAPD (err, currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId)); |
291 TRAPD (err, currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId)); |
267 if (KErrNone == err) { |
292 if (KErrNone == err) { |
268 RPointerArray<CFSMailFolder> folders = currentMailbox->ListFolders(); |
293 RPointerArray<CFSMailFolder> folders = currentMailbox->ListFolders(); |
269 for (int i = 0; i < folders.Count(); i++) { |
294 for (int i = 0; i < folders.Count(); i++) { |
274 else { |
299 else { |
275 return err; |
300 return err; |
276 } |
301 } |
277 } |
302 } |
278 |
303 |
304 |
|
305 /*! |
|
306 Fetches all the messages from the given folder and appends their meta data |
|
307 into the given list. |
|
308 |
|
309 \param folder The folder instance. |
|
310 \param messageEnvelopeList The list where the data is stored to. |
|
311 \param maxEnvelopeCount The maximum number of messages to get. |
|
312 */ |
|
313 void NmFrameworkAdapter::getMessagesFromFolderL( |
|
314 CFSMailFolder *folder, |
|
315 QList<NmMessageEnvelope*> &messageEnvelopeList, |
|
316 const int maxEnvelopeCount) |
|
317 { |
|
318 NM_FUNCTION; |
|
319 |
|
320 if (!folder || maxEnvelopeCount < 1) { |
|
321 return; |
|
322 } |
|
323 |
|
324 int blockSize = NmListMessagesBlock; |
|
325 int maxItemCount = NmMaxItemsInMessageList; |
|
326 |
|
327 if (maxEnvelopeCount < NmMaxItemsInMessageList) { |
|
328 maxItemCount = maxEnvelopeCount; |
|
329 |
|
330 if(maxEnvelopeCount < NmListMessagesBlock) { |
|
331 blockSize = maxEnvelopeCount; |
|
332 } |
|
333 } |
|
334 |
|
335 // First prepare all the parameters and select message details to be listed. |
|
336 TFSMailDetails details(EFSMsgDataEnvelope); |
|
337 |
|
338 // Set the sorting criteria. |
|
339 TFSMailSortCriteria criteria; |
|
340 criteria.iField = EFSMailSortByDate; |
|
341 criteria.iOrder = EFSMailDescending; |
|
342 RArray<TFSMailSortCriteria> sorting; |
|
343 CleanupClosePushL(sorting); |
|
344 sorting.Append(criteria); |
|
345 |
|
346 // Get the message list from the backend. |
|
347 MFSMailIterator* iterator(NULL); |
|
348 iterator = folder->ListMessagesL(details, sorting); |
|
349 |
|
350 if (iterator) { |
|
351 CleanupStack::PushL(iterator); |
|
352 RPointerArray<CFSMailMessage> messages; |
|
353 CleanupResetAndDestroy<CFSMailMessage>::PushL(messages); |
|
354 |
|
355 // The message list is fetched in blocks to prevent OOM in protocol |
|
356 // plugin side. |
|
357 bool moreMessagesToFollow(false); |
|
358 moreMessagesToFollow = iterator->NextL(TFSMailMsgId(), blockSize, messages); |
|
359 |
|
360 for (int i = blockSize; |
|
361 i < maxItemCount && moreMessagesToFollow; |
|
362 i += blockSize) { |
|
363 moreMessagesToFollow = |
|
364 iterator->NextL(messages[i-1]->GetMessageId(), blockSize, messages); |
|
365 } |
|
366 |
|
367 // Add all the found emails into the result list. |
|
368 const TInt messageCount(messages.Count()); |
|
369 |
|
370 for (TInt i = 0; i < messageCount; ++i) { |
|
371 NmMessageEnvelope *newEnvelope(NULL); |
|
372 newEnvelope = messages[i]->GetNmMessageEnvelope(); |
|
373 |
|
374 if (newEnvelope) { |
|
375 messageEnvelopeList.append(newEnvelope); |
|
376 } |
|
377 } |
|
378 |
|
379 CleanupStack::PopAndDestroy(&messages); |
|
380 CleanupStack::Pop(iterator); |
|
381 delete iterator; |
|
382 iterator = NULL; |
|
383 } |
|
384 |
|
385 CleanupStack::PopAndDestroy(); // sorting |
|
386 } |
|
387 |
|
388 |
|
279 /*! |
389 /*! |
280 Returns list of envelopes from the backend for specific mailbox and folder. |
390 Returns list of envelopes from the backend for specific mailbox and folder. |
281 |
391 |
282 \param mailboxId Id of the mailbox containing the folder. |
392 \param mailboxId Id of the mailbox containing the folder. |
283 \param folderId Folder id. |
393 \param folderId Folder id. |
289 int NmFrameworkAdapter::listMessages( |
399 int NmFrameworkAdapter::listMessages( |
290 const NmId &mailboxId, |
400 const NmId &mailboxId, |
291 const NmId &folderId, |
401 const NmId &folderId, |
292 QList<NmMessageEnvelope*> &messageEnvelopeList) |
402 QList<NmMessageEnvelope*> &messageEnvelopeList) |
293 { |
403 { |
404 NM_FUNCTION; |
|
405 |
|
294 TRAPD(err, listMessagesL(mailboxId,folderId,messageEnvelopeList, NmMaxItemsInMessageList)); |
406 TRAPD(err, listMessagesL(mailboxId,folderId,messageEnvelopeList, NmMaxItemsInMessageList)); |
295 return err; |
407 return err; |
296 } |
408 } |
297 |
409 |
410 |
|
411 /*! |
|
412 Fetches the meta data for each message in the given mailbox and given |
|
413 folder. |
|
414 |
|
415 \param mailboxId The ID of the mailbox of which messages to list. |
|
416 \param folderId The ID of the folder of which messages to list. |
|
417 \param messageEnvelopeList The list where the message data is stored to. |
|
418 Note that the ownership is transferred! |
|
419 \param maxAmountOfEnvelopes The maximum number of messages to list. |
|
420 |
|
421 \return If success, KErrNone, an error code otherwise. |
|
422 */ |
|
298 int NmFrameworkAdapter::listMessages( |
423 int NmFrameworkAdapter::listMessages( |
299 const NmId& mailboxId, |
424 const NmId& mailboxId, |
300 const NmId& folderId, |
425 const NmId& folderId, |
301 QList<NmMessageEnvelope*> &messageEnvelopeList, |
426 QList<NmMessageEnvelope*> &messageEnvelopeList, |
302 const int maxAmountOfEnvelopes) |
427 const int maxAmountOfEnvelopes) |
303 { |
428 { |
429 NM_FUNCTION; |
|
430 |
|
304 TInt err = KErrNone; |
431 TInt err = KErrNone; |
305 TRAP(err, listMessagesL(mailboxId,folderId, messageEnvelopeList,maxAmountOfEnvelopes) ); |
432 TRAP(err, listMessagesL(mailboxId,folderId, messageEnvelopeList,maxAmountOfEnvelopes) ); |
306 return err; |
433 return err; |
307 } |
434 } |
308 |
435 |
309 /*! |
436 |
310 Leaving version of list messages |
437 /*! |
311 */ |
438 Fetches the meta data for each message in the given mailbox and given |
439 folder. Note that this private method can leave. |
|
440 */ |
|
312 void NmFrameworkAdapter::listMessagesL( |
441 void NmFrameworkAdapter::listMessagesL( |
313 const NmId &mailboxId, |
442 const NmId &mailboxId, |
314 const NmId &folderId, |
443 const NmId &folderId, |
315 QList<NmMessageEnvelope*> &messageEnvelopeList, |
444 QList<NmMessageEnvelope*> &messageEnvelopeList, |
316 const int maxAmountOfEnvelopes) |
445 const int maxAmountOfEnvelopes) |
317 { |
446 { |
447 NM_FUNCTION; |
|
448 |
|
449 // If we are requesting 0 or less mails, we can just return. |
|
450 if (maxAmountOfEnvelopes <= 0) { |
|
451 return; |
|
452 } |
|
453 |
|
454 CFSMailBox *mailbox(NULL); |
|
455 mailbox = mFSfw->GetMailBoxByUidL(mailboxId); |
|
456 |
|
457 if (!mailbox) { |
|
458 User::Leave(KErrNotFound); |
|
459 } |
|
460 |
|
461 CleanupStack::PushL(mailbox); |
|
462 |
|
463 CFSMailFolder* folder(NULL); |
|
464 folder = mFSfw->GetFolderByUidL(mailbox->GetId(), TFSMailMsgId(folderId)); |
|
465 |
|
466 if (folder) { |
|
467 CleanupStack::PushL(folder); |
|
468 getMessagesFromFolderL(folder, messageEnvelopeList, maxAmountOfEnvelopes); |
|
469 CleanupStack::PopAndDestroy(folder); |
|
470 } |
|
471 |
|
472 CleanupStack::PopAndDestroy(mailbox); |
|
473 } |
|
474 |
|
475 |
|
476 /*! |
|
477 Returns list of messages from the backend for specific mailbox and folder. |
|
478 |
|
479 \param mailboxId Id of the mailbox containing the folder. |
|
480 \param folderId Folder id. |
|
481 \param messageMetaDataList Reference to pointer list to receive the envelope objects, |
|
482 ownership is transferred. |
|
483 |
|
484 \return Error code. |
|
485 */ |
|
486 int NmFrameworkAdapter::listMessages( |
|
487 const NmId &mailboxId, |
|
488 const NmId &folderId, |
|
489 QList<NmMessage*> &messageList, |
|
490 const int maxAmountOfMessages) |
|
491 { |
|
492 NM_FUNCTION; |
|
493 |
|
494 TRAPD(err, listMessagesL(mailboxId,folderId,messageList, maxAmountOfMessages)); |
|
495 return err; |
|
496 } |
|
497 |
|
498 |
|
499 /*! |
|
500 Leaving version of list messages with NmMessageList input |
|
501 */ |
|
502 void NmFrameworkAdapter::listMessagesL( |
|
503 const NmId &mailboxId, |
|
504 const NmId &folderId, |
|
505 QList<NmMessage*> &messageList, |
|
506 const int maxAmountOfEnvelopes) |
|
507 { |
|
508 NM_FUNCTION; |
|
509 |
|
318 CFSMailBox * currentMailbox(NULL); |
510 CFSMailBox * currentMailbox(NULL); |
319 CFSMailFolder* folder(NULL); |
511 CFSMailFolder* folder(NULL); |
320 |
512 |
321 //If we are requesting 0 or less mails so we can return |
513 //If we are requesting 0 or less mails so we can return |
322 if( maxAmountOfEnvelopes <= 0) |
514 if( maxAmountOfEnvelopes <= 0) |
324 return; |
516 return; |
325 } |
517 } |
326 |
518 |
327 int blockSize = NmListMessagesBlock; |
519 int blockSize = NmListMessagesBlock; |
328 int maxLimit = NmMaxItemsInMessageList; |
520 int maxLimit = NmMaxItemsInMessageList; |
521 |
|
329 if( maxAmountOfEnvelopes < NmMaxItemsInMessageList ) |
522 if( maxAmountOfEnvelopes < NmMaxItemsInMessageList ) |
330 { |
523 { |
331 maxLimit = maxAmountOfEnvelopes; |
524 maxLimit = maxAmountOfEnvelopes; |
332 if(maxAmountOfEnvelopes < NmListMessagesBlock) |
525 if(maxAmountOfEnvelopes < NmListMessagesBlock) |
333 { |
526 { |
334 blockSize = maxAmountOfEnvelopes; |
527 blockSize = maxAmountOfEnvelopes; |
335 } |
528 } |
336 } |
529 } |
337 |
530 |
338 |
|
339 currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId); |
|
340 if (!currentMailbox) { |
|
341 User::Leave(KErrNotFound); |
|
342 } |
|
343 CleanupStack::PushL(currentMailbox); |
|
344 folder = mFSfw->GetFolderByUidL(currentMailbox->GetId(), TFSMailMsgId(folderId)); |
|
345 |
|
346 if (folder) { |
|
347 CleanupStack::PushL(folder); |
|
348 // First prepare all the parameters |
|
349 // select message details to be listed |
|
350 TFSMailDetails details(EFSMsgDataEnvelope); |
|
351 |
|
352 // set sorting criteria |
|
353 TFSMailSortCriteria criteria; |
|
354 criteria.iField = EFSMailSortByDate; |
|
355 criteria.iOrder = EFSMailDescending; |
|
356 RArray<TFSMailSortCriteria> sorting; |
|
357 CleanupClosePushL(sorting); |
|
358 sorting.Append(criteria); |
|
359 |
|
360 TFSMailMsgId currentMessageId; // first call contains NULL id as begin id |
|
361 // get messages list from the backend |
|
362 MFSMailIterator* iterator(NULL); |
|
363 |
|
364 iterator = folder->ListMessagesL(details, sorting); |
|
365 if (iterator) { |
|
366 CleanupStack::PushL(iterator); |
|
367 RPointerArray<CFSMailMessage> messages; |
|
368 CleanupResetAndDestroy<CFSMailMessage>::PushL(messages); |
|
369 |
|
370 //Message list is fetched in blocks to prevent OOM in protocol plugin side |
|
371 bool moreMessagesToFollow(false); |
|
372 moreMessagesToFollow = iterator->NextL( |
|
373 TFSMailMsgId(), blockSize, messages); |
|
374 for ( int i = blockSize; |
|
375 i < maxLimit && moreMessagesToFollow ; |
|
376 i += blockSize ) { |
|
377 moreMessagesToFollow = iterator->NextL( |
|
378 messages[i-1]->GetMessageId(), blockSize, messages); |
|
379 } |
|
380 |
|
381 //Add all found emails to the result list |
|
382 for(TInt i=0; i<messages.Count(); i++) { |
|
383 NmMessageEnvelope* newEnvelope(NULL); |
|
384 newEnvelope = messages[i]->GetNmMessageEnvelope(); |
|
385 if (newEnvelope) { |
|
386 messageEnvelopeList.append(newEnvelope); |
|
387 } |
|
388 } |
|
389 CleanupStack::PopAndDestroy( &messages ); |
|
390 CleanupStack::Pop(iterator); |
|
391 delete iterator; |
|
392 iterator = NULL; |
|
393 } |
|
394 CleanupStack::PopAndDestroy(); // sorting |
|
395 CleanupStack::PopAndDestroy(folder); |
|
396 } |
|
397 CleanupStack::PopAndDestroy(currentMailbox); |
|
398 } |
|
399 |
|
400 /*! |
|
401 Returns list of messages from the backend for specific mailbox and folder. |
|
402 |
|
403 \param mailboxId Id of the mailbox containing the folder. |
|
404 \param folderId Folder id. |
|
405 \param messageMetaDataList Reference to pointer list to receive the envelope objects, |
|
406 ownership is transferred. |
|
407 |
|
408 \return Error code. |
|
409 */ |
|
410 int NmFrameworkAdapter::listMessages( |
|
411 const NmId &mailboxId, |
|
412 const NmId &folderId, |
|
413 QList<NmMessage*> &messageList, |
|
414 const int maxAmountOfMessages) |
|
415 { |
|
416 TRAPD(err, listMessagesL(mailboxId,folderId,messageList, maxAmountOfMessages)); |
|
417 return err; |
|
418 } |
|
419 |
|
420 /*! |
|
421 Leaving version of list messages with NmMessageList input |
|
422 */ |
|
423 void NmFrameworkAdapter::listMessagesL( |
|
424 const NmId &mailboxId, |
|
425 const NmId &folderId, |
|
426 QList<NmMessage*> &messageList, |
|
427 const int maxAmountOfEnvelopes) |
|
428 { |
|
429 CFSMailBox * currentMailbox(NULL); |
|
430 CFSMailFolder* folder(NULL); |
|
431 |
|
432 //If we are requesting 0 or less mails so we can return |
|
433 if( maxAmountOfEnvelopes <= 0) |
|
434 { |
|
435 return; |
|
436 } |
|
437 |
|
438 int blockSize = NmListMessagesBlock; |
|
439 int maxLimit = NmMaxItemsInMessageList; |
|
440 if( maxAmountOfEnvelopes < NmMaxItemsInMessageList ) |
|
441 { |
|
442 maxLimit = maxAmountOfEnvelopes; |
|
443 if(maxAmountOfEnvelopes < NmListMessagesBlock) |
|
444 { |
|
445 blockSize = maxAmountOfEnvelopes; |
|
446 } |
|
447 } |
|
448 |
|
449 |
|
450 currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId); |
531 currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId); |
451 if (!currentMailbox) { |
532 if (!currentMailbox) { |
452 User::Leave(KErrNotFound); |
533 User::Leave(KErrNotFound); |
453 } |
534 } |
454 CleanupStack::PushL(currentMailbox); |
535 CleanupStack::PushL(currentMailbox); |
514 CleanupStack::PopAndDestroy(folder); |
595 CleanupStack::PopAndDestroy(folder); |
515 } |
596 } |
516 CleanupStack::PopAndDestroy(currentMailbox); |
597 CleanupStack::PopAndDestroy(currentMailbox); |
517 } |
598 } |
518 |
599 |
600 |
|
519 /*! |
601 /*! |
520 Starts an asynchronous search for messages with the given search strings. |
602 Starts an asynchronous search for messages with the given search strings. |
521 This is part of the public interface. |
603 This is part of the public interface. |
522 |
604 |
523 \see NmFrameworkAdapter::searchL(). |
605 \see NmFrameworkAdapter::searchL(). |
528 \return A possible error code. |
610 \return A possible error code. |
529 */ |
611 */ |
530 int NmFrameworkAdapter::search(const NmId &mailboxId, |
612 int NmFrameworkAdapter::search(const NmId &mailboxId, |
531 const QStringList &searchStrings) |
613 const QStringList &searchStrings) |
532 { |
614 { |
615 NM_FUNCTION; |
|
616 |
|
533 if (!mSearchObserver) { |
617 if (!mSearchObserver) { |
534 mSearchObserver = new NmMailboxSearchObserver(); |
618 mSearchObserver = new NmMailboxSearchObserver(); |
535 } |
619 } |
536 |
620 |
537 // Set connections for forwarding the signals emitted by the search |
621 // Set connections for forwarding the signals emitted by the search |
538 // observer. |
622 // observer. |
539 connect(mSearchObserver, SIGNAL(matchFound(const NmId &)), |
623 connect(mSearchObserver, SIGNAL(matchFound(const NmId &, const NmId &)), |
540 this, SIGNAL(matchFound(const NmId &)), Qt::UniqueConnection); |
624 this, SIGNAL(matchFound(const NmId &, const NmId &)), Qt::UniqueConnection); |
541 connect(mSearchObserver, SIGNAL(searchComplete()), |
625 connect(mSearchObserver, SIGNAL(searchComplete()), |
542 this, SIGNAL(searchComplete()), Qt::UniqueConnection); |
626 this, SIGNAL(searchComplete()), Qt::UniqueConnection); |
543 |
627 |
544 TRAPD(err, searchL(mailboxId, QList<NmId>(), searchStrings, *mSearchObserver)); |
628 TRAPD(err, searchL(mailboxId, QList<NmId>(), searchStrings, *mSearchObserver)); |
545 return err; |
629 return err; |
548 |
632 |
549 /*! |
633 /*! |
550 Cancels the search if one is ongoing. |
634 Cancels the search if one is ongoing. |
551 |
635 |
552 \param mailboxId The ID of the mailbox running the search. |
636 \param mailboxId The ID of the mailbox running the search. |
637 |
|
553 |
638 |
554 \return A possible error code. |
639 \return A possible error code. |
555 */ |
640 */ |
556 int NmFrameworkAdapter::cancelSearch(const NmId &mailboxId) |
641 int NmFrameworkAdapter::cancelSearch(const NmId &mailboxId) |
557 { |
642 { |
643 NM_FUNCTION; |
|
644 |
|
558 // Get the mailbox with the given ID. |
645 // Get the mailbox with the given ID. |
559 CFSMailBox *mailbox(NULL); |
646 CFSMailBox *mailbox(NULL); |
560 TRAPD(err, mailbox = mFSfw->GetMailBoxByUidL(mailboxId)); |
647 TRAPD(err, mailbox = mFSfw->GetMailBoxByUidL(mailboxId)); |
561 |
648 |
562 if (err == KErrNone && mailbox) { |
649 if (err == KErrNone && mailbox) { |
564 } |
651 } |
565 |
652 |
566 return err; |
653 return err; |
567 } |
654 } |
568 |
655 |
656 /*! |
|
657 Indicates application state information to protocol plugins |
|
658 \param mailboxId Id of active mailbox, 0 if application is closed. |
|
659 \param folderId Id of active folder, 0 if application is closed. |
|
660 */ |
|
661 void NmFrameworkAdapter::updateActiveFolder( |
|
662 const NmId &mailboxId, const NmId &folderId) |
|
663 { |
|
664 TRAP_IGNORE(doUpdateActiveFolderL(mailboxId, folderId)); |
|
665 } |
|
666 |
|
667 /*! |
|
668 Removes draft message asynchronously |
|
669 */ |
|
670 QPointer<NmOperation> NmFrameworkAdapter::removeDraftMessage(NmMessage *message) |
|
671 { |
|
672 NM_FUNCTION; |
|
673 |
|
674 QPointer<NmOperation> oper = new NmFwaRemoveDraftMessageOperation(*this, message, *mFSfw); |
|
675 return oper; |
|
676 } |
|
677 |
|
678 /*! |
|
679 function to process updateActiveFolder. This method may leave. |
|
680 */ |
|
681 void NmFrameworkAdapter::doUpdateActiveFolderL( |
|
682 const NmId &mailboxId, const NmId &folderId) |
|
683 { |
|
684 if ((mFSfw) && (!mCurrentMailBox || mCurrentMailBox->GetId()!=mailboxId)) { |
|
685 delete mCurrentMailBox; |
|
686 mCurrentMailBox = NULL; |
|
687 mCurrentMailBox = mFSfw->GetMailBoxByUidL(mailboxId); |
|
688 } |
|
689 CEmailExtension *extension = getEMailStateExtensionL(); |
|
690 CMailboxStateExtension *stateExtension = |
|
691 static_cast<CMailboxStateExtension*>(extension); |
|
692 if (stateExtension) { |
|
693 stateExtension->NotifyActiveFolderChanged(mailboxId, folderId); |
|
694 } |
|
695 } |
|
696 |
|
697 /*! |
|
698 function to process updateActiveFolder. This method may leave. |
|
699 */ |
|
700 CEmailExtension* NmFrameworkAdapter::getEMailStateExtensionL() |
|
701 { |
|
702 if (!mStateExtension && mCurrentMailBox) { |
|
703 // This extension is owned and deleted by the plugin, so no need to |
|
704 // use release unless the extension will be relocated into extensionbase. |
|
705 mStateExtension = mCurrentMailBox->ExtensionL(KEmailMailboxStateExtensionUid); |
|
706 } |
|
707 return mStateExtension; |
|
708 } |
|
569 |
709 |
570 /*! |
710 /*! |
571 Starts an asynchronous search for messages with the given search strings. |
711 Starts an asynchronous search for messages with the given search strings. |
572 |
712 |
573 \param mailboxId The mailbox to search from. |
713 \param mailboxId The mailbox to search from. |
579 void NmFrameworkAdapter::searchL(const NmId &mailboxId, |
719 void NmFrameworkAdapter::searchL(const NmId &mailboxId, |
580 const QList<NmId> &folderIds, |
720 const QList<NmId> &folderIds, |
581 const QStringList &searchStrings, |
721 const QStringList &searchStrings, |
582 NmMailboxSearchObserver &searchObserver) |
722 NmMailboxSearchObserver &searchObserver) |
583 { |
723 { |
724 NM_FUNCTION; |
|
725 |
|
584 // CFSMailBox has no support for search using folder IDs. |
726 // CFSMailBox has no support for search using folder IDs. |
585 Q_UNUSED(folderIds); |
727 Q_UNUSED(folderIds); |
586 |
728 |
587 // Get the mailbox with the given ID. |
729 // Get the mailbox with the given ID. |
588 CFSMailBox *mailbox(NULL); |
730 CFSMailBox *mailbox(NULL); |
626 QPointer<NmOperation> NmFrameworkAdapter::fetchMessage( |
768 QPointer<NmOperation> NmFrameworkAdapter::fetchMessage( |
627 const NmId &mailboxId, |
769 const NmId &mailboxId, |
628 const NmId &folderId, |
770 const NmId &folderId, |
629 const NmId &messageId ) |
771 const NmId &messageId ) |
630 { |
772 { |
773 NM_FUNCTION; |
|
774 |
|
631 NmOperation *oper = new NmFwaMessageFetchingOperation(mailboxId, folderId, messageId, *mFSfw); |
775 NmOperation *oper = new NmFwaMessageFetchingOperation(mailboxId, folderId, messageId, *mFSfw); |
632 return oper; |
776 return oper; |
633 } |
777 } |
634 |
778 |
635 /*! |
779 /*! |
646 const NmId &mailboxId, |
790 const NmId &mailboxId, |
647 const NmId &folderId, |
791 const NmId &folderId, |
648 const NmId &messageId, |
792 const NmId &messageId, |
649 const NmId &messagePartId) |
793 const NmId &messagePartId) |
650 { |
794 { |
795 NM_FUNCTION; |
|
796 |
|
651 QPointer<NmOperation> oper = new NmFwaMessagePartFetchingOperation( |
797 QPointer<NmOperation> oper = new NmFwaMessagePartFetchingOperation( |
652 mailboxId, folderId, messageId, messagePartId, *mFSfw); |
798 mailboxId, folderId, messageId, messagePartId, *mFSfw); |
653 return oper; |
799 return oper; |
800 } |
|
801 |
|
802 /*! |
|
803 Starts a message parts fetching operation. |
|
804 |
|
805 \param mailboxId Id of the mailbox containing the folder. |
|
806 \param folderId Id of the folder containing the message. |
|
807 \param messageId Id of message containing the message parts |
|
808 \param messagePartIds ids of message parts |
|
809 |
|
810 \return An NmOperation object for the operation, ownership is transferred to caller |
|
811 */ |
|
812 QPointer<NmOperation> NmFrameworkAdapter::fetchMessageParts( |
|
813 const NmId &mailboxId, |
|
814 const NmId &folderId, |
|
815 const NmId &messageId, |
|
816 const QList<NmId> &messagePartIds) |
|
817 { |
|
818 NM_FUNCTION; |
|
819 |
|
820 QPointer<NmOperation> oper = new NmFwaMessagePartsFetchingOperation( |
|
821 mailboxId, folderId, messageId, messagePartIds, *mFSfw); |
|
822 return oper; |
|
654 } |
823 } |
655 |
824 |
656 /*! |
825 /*! |
657 Returns sharable file handle to message part content |
826 Returns sharable file handle to message part content |
658 |
827 |
667 const NmId &mailboxId, |
836 const NmId &mailboxId, |
668 const NmId &folderId, |
837 const NmId &folderId, |
669 const NmId &messageId, |
838 const NmId &messageId, |
670 const NmId &messagePartId) |
839 const NmId &messagePartId) |
671 { |
840 { |
841 NM_FUNCTION; |
|
842 |
|
672 XQSharableFile retFile; |
843 XQSharableFile retFile; |
673 TFSMailDetails details(EFSMsgDataEnvelope); |
844 TFSMailDetails details(EFSMsgDataEnvelope); |
674 TFSMailMsgId fsMboxId(mailboxId); |
845 TFSMailMsgId fsMboxId(mailboxId); |
675 TFSMailMsgId fsFolderId(folderId); |
846 TFSMailMsgId fsFolderId(folderId); |
676 TFSMailMsgId fsMsgId(messageId); |
847 TFSMailMsgId fsMsgId(messageId); |
703 */ |
874 */ |
704 NmId NmFrameworkAdapter::getStandardFolderId( |
875 NmId NmFrameworkAdapter::getStandardFolderId( |
705 const NmId& mailboxId, |
876 const NmId& mailboxId, |
706 NmFolderType folderType ) |
877 NmFolderType folderType ) |
707 { |
878 { |
879 NM_FUNCTION; |
|
880 |
|
708 TFSMailMsgId folderId; |
881 TFSMailMsgId folderId; |
709 NmId resultId(0); |
882 NmId resultId(0); |
710 CFSMailBox * currentMailbox(NULL); |
883 CFSMailBox * currentMailbox(NULL); |
711 |
884 |
712 TRAPD(error, currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId) ); |
885 TRAPD(error, currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId) ); |
752 \param mailboxId Id of the mailbox. |
925 \param mailboxId Id of the mailbox. |
753 \return Async request id or error code. |
926 \return Async request id or error code. |
754 */ |
927 */ |
755 int NmFrameworkAdapter::refreshMailbox(NmId mailboxId) |
928 int NmFrameworkAdapter::refreshMailbox(NmId mailboxId) |
756 { |
929 { |
930 NM_FUNCTION; |
|
931 |
|
757 TRAPD(err, RefreshMailboxL(mailboxId)); // return value not used |
932 TRAPD(err, RefreshMailboxL(mailboxId)); // return value not used |
758 return ( err == KErrNone ) ? NmNoError : NmGeneralError; |
933 return ( err == KErrNone ) ? NmNoError : NmGeneralError; |
759 } |
934 } |
760 |
935 |
761 /*! |
936 /*! |
764 \param mailboxId Id of the mailbox. |
939 \param mailboxId Id of the mailbox. |
765 \return Async request id or error code. |
940 \return Async request id or error code. |
766 */ |
941 */ |
767 int NmFrameworkAdapter::goOnline(const NmId& mailboxId) |
942 int NmFrameworkAdapter::goOnline(const NmId& mailboxId) |
768 { |
943 { |
944 NM_FUNCTION; |
|
945 |
|
769 TRAPD(err, GoOnlineL(mailboxId)); // return value not used |
946 TRAPD(err, GoOnlineL(mailboxId)); // return value not used |
770 return ( err == KErrNone ) ? NmNoError : NmGeneralError; |
947 return ( err == KErrNone ) ? NmNoError : NmGeneralError; |
771 } |
948 } |
772 |
949 |
773 /*! |
950 /*! |
776 \param mailboxId Id of the mailbox. |
953 \param mailboxId Id of the mailbox. |
777 \return Async request id or error code. |
954 \return Async request id or error code. |
778 */ |
955 */ |
779 int NmFrameworkAdapter::goOffline(const NmId& mailboxId) |
956 int NmFrameworkAdapter::goOffline(const NmId& mailboxId) |
780 { |
957 { |
958 NM_FUNCTION; |
|
959 |
|
781 TRAPD(err, GoOfflineL(mailboxId)); // return value not used |
960 TRAPD(err, GoOfflineL(mailboxId)); // return value not used |
782 return ( err == KErrNone ) ? NmNoError : NmGeneralError; |
961 return ( err == KErrNone ) ? NmNoError : NmGeneralError; |
783 } |
962 } |
784 |
963 |
785 /*! |
964 /*! |
798 const NmId &mailboxId, |
977 const NmId &mailboxId, |
799 const NmId &folderId, |
978 const NmId &folderId, |
800 const NmId &messageId, |
979 const NmId &messageId, |
801 NmMessagePart &messagePart) |
980 NmMessagePart &messagePart) |
802 { |
981 { |
982 NM_FUNCTION; |
|
983 |
|
803 TRAPD(err, contentToMessagePartL(mailboxId,folderId,messageId,messagePart)); |
984 TRAPD(err, contentToMessagePartL(mailboxId,folderId,messageId,messagePart)); |
804 return err; |
985 return err; |
805 } |
986 } |
806 |
987 |
807 /*! |
988 /*! |
811 const NmId &mailboxId, |
992 const NmId &mailboxId, |
812 const NmId &folderId, |
993 const NmId &folderId, |
813 const NmId &messageId, |
994 const NmId &messageId, |
814 NmMessagePart &messagePart) |
995 NmMessagePart &messagePart) |
815 { |
996 { |
997 NM_FUNCTION; |
|
998 |
|
816 CFSMailMessagePart* cfsPart = CFSMailMessagePart::NewLC(messageId,messagePart); |
999 CFSMailMessagePart* cfsPart = CFSMailMessagePart::NewLC(messageId,messagePart); |
817 cfsPart->SetMailBoxId(TFSMailMsgId(mailboxId)); |
1000 cfsPart->SetMailBoxId(TFSMailMsgId(mailboxId)); |
818 cfsPart->SetFolderId(TFSMailMsgId(folderId)); |
1001 cfsPart->SetFolderId(TFSMailMsgId(folderId)); |
819 QString contentType = messagePart.contentType(); |
1002 QString contentType = messagePart.contentType(); |
820 |
1003 |
885 int NmFrameworkAdapter::deleteMessages( |
1068 int NmFrameworkAdapter::deleteMessages( |
886 const NmId &mailboxId, |
1069 const NmId &mailboxId, |
887 const NmId &folderId, |
1070 const NmId &folderId, |
888 const QList<NmId> &messageIdList) |
1071 const QList<NmId> &messageIdList) |
889 { |
1072 { |
1073 NM_FUNCTION; |
|
1074 |
|
890 TInt err = NmNoError; |
1075 TInt err = NmNoError; |
891 RArray<TFSMailMsgId> messageIds; |
1076 RArray<TFSMailMsgId> messageIds; |
892 for (TInt i=0; i<messageIdList.size(); i++) { |
1077 for (TInt i=0; i<messageIdList.size(); i++) { |
893 err = messageIds.Append(TFSMailMsgId(messageIdList[i])); |
1078 err = messageIds.Append(TFSMailMsgId(messageIdList[i])); |
894 if (err!=NmNoError) { |
1079 if (err!=NmNoError) { |
915 QPointer<NmStoreEnvelopesOperation> NmFrameworkAdapter::storeEnvelopes( |
1100 QPointer<NmStoreEnvelopesOperation> NmFrameworkAdapter::storeEnvelopes( |
916 const NmId &mailboxId, |
1101 const NmId &mailboxId, |
917 const NmId &folderId, |
1102 const NmId &folderId, |
918 const QList<const NmMessageEnvelope*> &envelopeList) |
1103 const QList<const NmMessageEnvelope*> &envelopeList) |
919 { |
1104 { |
1105 NM_FUNCTION; |
|
1106 |
|
920 Q_UNUSED(folderId); |
1107 Q_UNUSED(folderId); |
921 NMLOG("NmFrameworkAdapter::storeEnvelopes() <---"); |
|
922 |
1108 |
923 QPointer<NmStoreEnvelopesOperation> operation(NULL); |
1109 QPointer<NmStoreEnvelopesOperation> operation(NULL); |
924 RPointerArray<CFSMailMessage> envelopeMessages; |
1110 RPointerArray<CFSMailMessage> envelopeMessages; |
925 |
1111 |
926 int count = envelopeList.count(); |
1112 int count = envelopeList.count(); |
933 mailboxId, |
1119 mailboxId, |
934 envelopeMessages, |
1120 envelopeMessages, |
935 *mFSfw); |
1121 *mFSfw); |
936 } |
1122 } |
937 |
1123 |
938 NMLOG("NmFrameworkAdapter::storeEnvelopes() --->"); |
|
939 return operation; |
1124 return operation; |
940 } |
1125 } |
941 |
1126 |
942 /*! |
1127 /*! |
943 Creates a new message into the drafts folder a mailbox. |
1128 Creates a new message into the drafts folder a mailbox. |
946 |
1131 |
947 \return NmMessageCreationOperation |
1132 \return NmMessageCreationOperation |
948 */ |
1133 */ |
949 QPointer<NmMessageCreationOperation> NmFrameworkAdapter::createNewMessage(const NmId &mailboxId) |
1134 QPointer<NmMessageCreationOperation> NmFrameworkAdapter::createNewMessage(const NmId &mailboxId) |
950 { |
1135 { |
1136 NM_FUNCTION; |
|
1137 |
|
951 QPointer<NmMessageCreationOperation> oper = |
1138 QPointer<NmMessageCreationOperation> oper = |
952 new NmFwaMessageCreationOperation(mailboxId, *mFSfw); |
1139 new NmFwaMessageCreationOperation(mailboxId, *mFSfw); |
953 return oper; |
1140 return oper; |
954 } |
1141 } |
955 |
1142 |
963 */ |
1150 */ |
964 QPointer<NmMessageCreationOperation> NmFrameworkAdapter::createForwardMessage( |
1151 QPointer<NmMessageCreationOperation> NmFrameworkAdapter::createForwardMessage( |
965 const NmId &mailboxId, |
1152 const NmId &mailboxId, |
966 const NmId &originalMessageId) |
1153 const NmId &originalMessageId) |
967 { |
1154 { |
1155 NM_FUNCTION; |
|
1156 |
|
968 QPointer<NmMessageCreationOperation> oper = |
1157 QPointer<NmMessageCreationOperation> oper = |
969 new NmFwaForwardMessageCreationOperation(mailboxId, originalMessageId, *mFSfw); |
1158 new NmFwaForwardMessageCreationOperation(mailboxId, originalMessageId, *mFSfw); |
970 return oper; |
1159 return oper; |
971 } |
1160 } |
972 |
1161 |
982 QPointer<NmMessageCreationOperation> NmFrameworkAdapter::createReplyMessage( |
1171 QPointer<NmMessageCreationOperation> NmFrameworkAdapter::createReplyMessage( |
983 const NmId &mailboxId, |
1172 const NmId &mailboxId, |
984 const NmId &originalMessageId, |
1173 const NmId &originalMessageId, |
985 const bool replyAll) |
1174 const bool replyAll) |
986 { |
1175 { |
1176 NM_FUNCTION; |
|
1177 |
|
987 QPointer<NmMessageCreationOperation> oper = |
1178 QPointer<NmMessageCreationOperation> oper = |
988 new NmFwaReplyMessageCreationOperation(mailboxId, originalMessageId, replyAll, *mFSfw); |
1179 new NmFwaReplyMessageCreationOperation(mailboxId, originalMessageId, replyAll, *mFSfw); |
989 return oper; |
1180 return oper; |
990 } |
1181 } |
991 |
1182 |
992 /*! |
1183 /*! |
993 Not implemented yet. |
1184 Not implemented yet. |
994 */ |
1185 */ |
995 int NmFrameworkAdapter::saveMessage(const NmMessage &message) |
1186 int NmFrameworkAdapter::saveMessage(const NmMessage &message) |
996 { |
1187 { |
1188 NM_FUNCTION; |
|
1189 |
|
997 Q_UNUSED(message); |
1190 Q_UNUSED(message); |
998 return NmNoError; |
1191 return NmNoError; |
999 } |
1192 } |
1000 |
1193 |
1001 /*! |
1194 /*! |
1002 Store asynchronously message with its parts. |
1195 Store asynchronously message with its parts. |
1003 */ |
1196 */ |
1004 QPointer<NmOperation> NmFrameworkAdapter::saveMessageWithSubparts(const NmMessage &message) |
1197 QPointer<NmOperation> NmFrameworkAdapter::saveMessageWithSubparts(const NmMessage &message) |
1005 { |
1198 { |
1199 NM_FUNCTION; |
|
1200 |
|
1006 CFSMailMessage * cfsMessage = NULL; |
1201 CFSMailMessage * cfsMessage = NULL; |
1007 QPointer<NmOperation> oper(NULL); |
1202 QPointer<NmOperation> oper(NULL); |
1008 |
1203 |
1009 int err = KErrNone; |
1204 int err = KErrNone; |
1010 TRAP(err, cfsMessage = CFSMailMessage::NewL(message)); |
1205 TRAP(err, cfsMessage = CFSMailMessage::NewL(message)); |
1026 TFSMailMsgId mailbox, |
1221 TFSMailMsgId mailbox, |
1027 TAny* param1, |
1222 TAny* param1, |
1028 TAny* param2, |
1223 TAny* param2, |
1029 TAny* param3) |
1224 TAny* param3) |
1030 { |
1225 { |
1226 NM_FUNCTION; |
|
1227 |
|
1031 switch (aEvent) { |
1228 switch (aEvent) { |
1032 // Mailbox related events: |
1229 // Mailbox related events: |
1033 case TFSEventNewMailbox: |
1230 case TFSEventNewMailbox: |
1034 handleMailboxEvent(mailbox, NmMailboxCreated); |
1231 handleMailboxEvent(mailbox, NmMailboxCreated); |
1035 break; |
1232 break; |
1139 int NmFrameworkAdapter::removeMessage( |
1336 int NmFrameworkAdapter::removeMessage( |
1140 const NmId& mailboxId, |
1337 const NmId& mailboxId, |
1141 const NmId& folderId, |
1338 const NmId& folderId, |
1142 const NmId& messageId) |
1339 const NmId& messageId) |
1143 { |
1340 { |
1341 NM_FUNCTION; |
|
1342 |
|
1144 TRAPD(error, removeMessageL(mailboxId, folderId, messageId)); |
1343 TRAPD(error, removeMessageL(mailboxId, folderId, messageId)); |
1344 return error; |
|
1345 } |
|
1346 |
|
1347 /*! |
|
1348 Copy messages between folders from specific mailbox. |
|
1349 |
|
1350 \param mailboxId Id of the mailbox containing messages. |
|
1351 \param messageIds The list of source message Ids. |
|
1352 \param newMessages The list of destination message Ids. |
|
1353 \param sourceFolderId Id of source folder. |
|
1354 \param destinationFolderId Id of destination folder. |
|
1355 */ |
|
1356 int NmFrameworkAdapter::copyMessages( |
|
1357 const NmId &mailboxId, |
|
1358 const QList<quint64>& messageIds, |
|
1359 const NmId& sourceFolderId, |
|
1360 const NmId& destinationFolderId) |
|
1361 { |
|
1362 NM_FUNCTION; |
|
1363 TRAPD(error, copyMessagesL(mailboxId, messageIds, sourceFolderId, destinationFolderId)); |
|
1145 return error; |
1364 return error; |
1146 } |
1365 } |
1147 |
1366 |
1148 /*! |
1367 /*! |
1149 Subscribe to events from a mailbox. |
1368 Subscribe to events from a mailbox. |
1150 |
1369 |
1151 \param mailboxId Id of the mailbox. |
1370 \param mailboxId Id of the mailbox. |
1152 */ |
1371 */ |
1153 void NmFrameworkAdapter::subscribeMailboxEvents(const NmId& mailboxId) |
1372 void NmFrameworkAdapter::subscribeMailboxEvents(const NmId& mailboxId) |
1154 { |
1373 { |
1374 NM_FUNCTION; |
|
1375 |
|
1155 TRAP_IGNORE(mFSfw->SubscribeMailboxEventsL(mailboxId, *this)); |
1376 TRAP_IGNORE(mFSfw->SubscribeMailboxEventsL(mailboxId, *this)); |
1156 } |
1377 } |
1157 |
1378 |
1158 /*! |
1379 /*! |
1159 Unsubscribe to events from a mailbox. |
1380 Unsubscribe to events from a mailbox. |
1160 |
1381 |
1161 \param mailboxId Id of the mailbox. |
1382 \param mailboxId Id of the mailbox. |
1162 */ |
1383 */ |
1163 void NmFrameworkAdapter::unsubscribeMailboxEvents(const NmId& mailboxId) |
1384 void NmFrameworkAdapter::unsubscribeMailboxEvents(const NmId& mailboxId) |
1164 { |
1385 { |
1386 NM_FUNCTION; |
|
1387 |
|
1165 mFSfw->UnsubscribeMailboxEvents(mailboxId, *this); |
1388 mFSfw->UnsubscribeMailboxEvents(mailboxId, *this); |
1166 } |
1389 } |
1167 |
1390 |
1168 NmId NmFrameworkAdapter::getMailboxIdByMailMsgId(TFSMailMsgId mailbox) |
1391 NmId NmFrameworkAdapter::getMailboxIdByMailMsgId(TFSMailMsgId mailbox) |
1169 { |
1392 { |
1393 NM_FUNCTION; |
|
1394 |
|
1170 NmId nmId(0); |
1395 NmId nmId(0); |
1171 |
1396 |
1172 QList<NmId> mailboxIds; |
1397 QList<NmId> mailboxIds; |
1173 listMailboxIds(mailboxIds); |
1398 listMailboxIds(mailboxIds); |
1174 |
1399 |
1189 void NmFrameworkAdapter::removeMessageL( |
1414 void NmFrameworkAdapter::removeMessageL( |
1190 const NmId& mailboxId, |
1415 const NmId& mailboxId, |
1191 const NmId& folderId, |
1416 const NmId& folderId, |
1192 const NmId& messageId) |
1417 const NmId& messageId) |
1193 { |
1418 { |
1419 NM_FUNCTION; |
|
1420 |
|
1194 CFSMailFolder* folder = mFSfw->GetFolderByUidL( TFSMailMsgId(mailboxId), TFSMailMsgId(folderId)); |
1421 CFSMailFolder* folder = mFSfw->GetFolderByUidL( TFSMailMsgId(mailboxId), TFSMailMsgId(folderId)); |
1195 CleanupStack::PushL(folder); |
1422 CleanupStack::PushL(folder); |
1196 if ( folder ) { |
1423 if ( folder ) { |
1197 folder->RemoveMessageL(TFSMailMsgId(messageId)); |
1424 folder->RemoveMessageL(TFSMailMsgId(messageId)); |
1198 } |
1425 } |
1199 CleanupStack::PopAndDestroy(folder); |
1426 CleanupStack::PopAndDestroy(folder); |
1200 } |
1427 } |
1201 |
1428 |
1429 /*! |
|
1430 Leaving version of copyMessages |
|
1431 */ |
|
1432 void NmFrameworkAdapter::copyMessagesL( |
|
1433 const NmId &mailboxId, |
|
1434 const QList<quint64>& messageIds, |
|
1435 const NmId& sourceFolderId, |
|
1436 const NmId& destinationFolderId) |
|
1437 { |
|
1438 NM_FUNCTION; |
|
1439 |
|
1440 RArray<TFSMailMsgId> messages; |
|
1441 RArray<TFSMailMsgId> copiedMessages; |
|
1442 |
|
1443 CleanupClosePushL(messages); |
|
1444 CleanupClosePushL(copiedMessages); |
|
1445 |
|
1446 for (TInt i = 0; i < messageIds.count(); i++) { |
|
1447 NmId tmpId(messageIds[i]); |
|
1448 messages.AppendL(TFSMailMsgId(tmpId)); |
|
1449 } |
|
1450 |
|
1451 CFSMailBox* mailBox = NULL; |
|
1452 mailBox = mFSfw->GetMailBoxByUidL(mailboxId); |
|
1453 if (mailBox) { |
|
1454 mailBox->CopyMessagesL(messages, copiedMessages, |
|
1455 TFSMailMsgId(sourceFolderId), |
|
1456 TFSMailMsgId(destinationFolderId)); |
|
1457 delete mailBox; |
|
1458 } |
|
1459 |
|
1460 CleanupStack::PopAndDestroy(2,&messages); |
|
1461 } |
|
1202 |
1462 |
1203 /*! |
1463 /*! |
1204 Sends the given message. |
1464 Sends the given message. |
1205 */ |
1465 */ |
1206 QPointer<NmMessageSendingOperation> NmFrameworkAdapter::sendMessage( |
1466 QPointer<NmMessageSendingOperation> NmFrameworkAdapter::sendMessage( |
1207 NmMessage *message) |
1467 NmMessage *message) |
1208 { |
1468 { |
1469 NM_FUNCTION; |
|
1470 |
|
1209 QPointer<NmMessageSendingOperation>oper = new NmFwaMessageSendingOperation(*this, message, *mFSfw); |
1471 QPointer<NmMessageSendingOperation>oper = new NmFwaMessageSendingOperation(*this, message, *mFSfw); |
1210 return oper; |
1472 return oper; |
1211 } |
1473 } |
1212 |
1474 |
1213 /*! |
1475 /*! |
1215 */ |
1477 */ |
1216 QPointer<NmAddAttachmentsOperation> NmFrameworkAdapter::addAttachments( |
1478 QPointer<NmAddAttachmentsOperation> NmFrameworkAdapter::addAttachments( |
1217 const NmMessage &message, |
1479 const NmMessage &message, |
1218 const QList<QString> &fileList) |
1480 const QList<QString> &fileList) |
1219 { |
1481 { |
1482 NM_FUNCTION; |
|
1483 |
|
1220 QPointer<NmAddAttachmentsOperation>oper = new NmFwaAddAttachmentsOperation(message, fileList, *mFSfw); |
1484 QPointer<NmAddAttachmentsOperation>oper = new NmFwaAddAttachmentsOperation(message, fileList, *mFSfw); |
1221 return oper; |
1485 return oper; |
1222 } |
1486 } |
1223 |
1487 |
1224 /*! |
1488 /*! |
1226 */ |
1490 */ |
1227 QPointer<NmOperation> NmFrameworkAdapter::removeAttachment( |
1491 QPointer<NmOperation> NmFrameworkAdapter::removeAttachment( |
1228 const NmMessage &message, |
1492 const NmMessage &message, |
1229 const NmId &attachmentPartId) |
1493 const NmId &attachmentPartId) |
1230 { |
1494 { |
1495 NM_FUNCTION; |
|
1496 |
|
1231 QPointer<NmOperation> oper = new NmFwaRemoveAttachmentOperation(message, attachmentPartId, *mFSfw); |
1497 QPointer<NmOperation> oper = new NmFwaRemoveAttachmentOperation(message, attachmentPartId, *mFSfw); |
1232 return oper; |
1498 return oper; |
1233 } |
1499 } |
1234 |
1500 |
1235 /*! |
1501 /*! |
1236 Checks outbox for messages |
|
1237 */ |
|
1238 QPointer<NmCheckOutboxOperation> NmFrameworkAdapter::checkOutbox(const NmId& mailboxId) |
|
1239 { |
|
1240 QPointer<NmCheckOutboxOperation> oper = |
|
1241 new NmFwaCheckOutboxOperation(mailboxId, *mFSfw); |
|
1242 |
|
1243 return oper; |
|
1244 } |
|
1245 |
|
1246 /*! |
|
1247 Returns the current sync state of the given mailbox |
1502 Returns the current sync state of the given mailbox |
1248 */ |
1503 */ |
1249 NmSyncState NmFrameworkAdapter::syncState(const NmId& mailboxId) const |
1504 NmSyncState NmFrameworkAdapter::syncState(const NmId& mailboxId) const |
1250 { |
1505 { |
1506 NM_FUNCTION; |
|
1507 |
|
1251 CFSMailBox* mailBox = NULL; |
1508 CFSMailBox* mailBox = NULL; |
1252 TRAPD(err, mailBox = mFSfw->GetMailBoxByUidL(TFSMailMsgId(mailboxId)) ); |
1509 TRAPD(err, mailBox = mFSfw->GetMailBoxByUidL(TFSMailMsgId(mailboxId)) ); |
1253 if (KErrNone == err && mailBox) { |
1510 if (KErrNone == err && mailBox) { |
1254 TSSMailSyncState syncState = mailBox->CurrentSyncState(); |
1511 TSSMailSyncState syncState = mailBox->CurrentSyncState(); |
1255 delete mailBox; |
1512 delete mailBox; |
1268 /*! |
1525 /*! |
1269 Returns the current connection state of the given mailbox |
1526 Returns the current connection state of the given mailbox |
1270 */ |
1527 */ |
1271 NmConnectState NmFrameworkAdapter::connectionState(const NmId& mailboxId) const |
1528 NmConnectState NmFrameworkAdapter::connectionState(const NmId& mailboxId) const |
1272 { |
1529 { |
1530 NM_FUNCTION; |
|
1531 |
|
1273 CFSMailBox* mailBox = NULL; |
1532 CFSMailBox* mailBox = NULL; |
1274 TRAPD(err, mailBox = mFSfw->GetMailBoxByUidL(TFSMailMsgId(mailboxId)) ); |
1533 TRAPD(err, mailBox = mFSfw->GetMailBoxByUidL(TFSMailMsgId(mailboxId)) ); |
1275 if (KErrNone == err && mailBox) { |
1534 if (KErrNone == err && mailBox) { |
1276 TFSMailBoxStatus status = mailBox->GetMailBoxStatus(); |
1535 TFSMailBoxStatus status = mailBox->GetMailBoxStatus(); |
1277 delete mailBox; |
1536 delete mailBox; |
1292 Call to this must be trapped |
1551 Call to this must be trapped |
1293 */ |
1552 */ |
1294 CFSMailMessage* NmFrameworkAdapter::mailMessageFromEnvelopeL( |
1553 CFSMailMessage* NmFrameworkAdapter::mailMessageFromEnvelopeL( |
1295 const NmMessageEnvelope& envelope) |
1554 const NmMessageEnvelope& envelope) |
1296 { |
1555 { |
1556 NM_FUNCTION; |
|
1557 |
|
1297 NmMessage* nmMessage = new(ELeave) NmMessage( envelope ); |
1558 NmMessage* nmMessage = new(ELeave) NmMessage( envelope ); |
1298 CFSMailMessage* message = CFSMailMessage::NewL( *nmMessage ); |
1559 CFSMailMessage* message = CFSMailMessage::NewL( *nmMessage ); |
1299 delete nmMessage; |
1560 delete nmMessage; |
1300 nmMessage = NULL; |
1561 nmMessage = NULL; |
1301 return message; |
1562 return message; |
1307 */ |
1568 */ |
1308 void NmFrameworkAdapter::childrenToNmMessagePartL( |
1569 void NmFrameworkAdapter::childrenToNmMessagePartL( |
1309 CFSMailMessagePart *cfsParent, |
1570 CFSMailMessagePart *cfsParent, |
1310 NmMessagePart *nmParent) |
1571 NmMessagePart *nmParent) |
1311 { |
1572 { |
1573 NM_FUNCTION; |
|
1574 |
|
1312 User::LeaveIfNull(cfsParent); |
1575 User::LeaveIfNull(cfsParent); |
1313 User::LeaveIfNull(nmParent); |
1576 User::LeaveIfNull(nmParent); |
1314 |
1577 |
1315 RPointerArray<CFSMailMessagePart> parts; |
1578 RPointerArray<CFSMailMessagePart> parts; |
1316 cfsParent->ChildPartsL(parts); |
1579 cfsParent->ChildPartsL(parts); |
1330 /*! |
1593 /*! |
1331 Leaving Refresh function |
1594 Leaving Refresh function |
1332 */ |
1595 */ |
1333 int NmFrameworkAdapter::RefreshMailboxL(NmId mailboxId) |
1596 int NmFrameworkAdapter::RefreshMailboxL(NmId mailboxId) |
1334 { |
1597 { |
1598 NM_FUNCTION; |
|
1599 |
|
1335 int result(KErrNotFound); |
1600 int result(KErrNotFound); |
1336 CFSMailBox *currentMailbox(NULL); |
1601 CFSMailBox *currentMailbox(NULL); |
1337 currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId); |
1602 currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId); |
1338 if(currentMailbox) { |
1603 if(currentMailbox) { |
1339 CleanupStack::PushL(currentMailbox); |
1604 CleanupStack::PushL(currentMailbox); |
1347 /*! |
1612 /*! |
1348 Leaving Go Online function |
1613 Leaving Go Online function |
1349 */ |
1614 */ |
1350 int NmFrameworkAdapter::GoOnlineL(const NmId& mailboxId) |
1615 int NmFrameworkAdapter::GoOnlineL(const NmId& mailboxId) |
1351 { |
1616 { |
1617 NM_FUNCTION; |
|
1618 |
|
1352 int result(KErrNotFound); |
1619 int result(KErrNotFound); |
1353 CFSMailBox *currentMailbox(NULL); |
1620 CFSMailBox *currentMailbox(NULL); |
1354 currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId); |
1621 currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId); |
1355 if(currentMailbox) { |
1622 if(currentMailbox) { |
1356 CleanupStack::PushL(currentMailbox); |
1623 CleanupStack::PushL(currentMailbox); |
1364 /*! |
1631 /*! |
1365 Leaving Go Offline function |
1632 Leaving Go Offline function |
1366 */ |
1633 */ |
1367 int NmFrameworkAdapter::GoOfflineL(const NmId& mailboxId) |
1634 int NmFrameworkAdapter::GoOfflineL(const NmId& mailboxId) |
1368 { |
1635 { |
1636 NM_FUNCTION; |
|
1637 |
|
1369 int result(KErrNotFound); |
1638 int result(KErrNotFound); |
1370 CFSMailBox *currentMailbox(NULL); |
1639 CFSMailBox *currentMailbox(NULL); |
1371 currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId); |
1640 currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId); |
1372 if(currentMailbox) { |
1641 if(currentMailbox) { |
1373 CleanupStack::PushL(currentMailbox); |
1642 CleanupStack::PushL(currentMailbox); |
1381 /*! |
1650 /*! |
1382 handles mailbox related events |
1651 handles mailbox related events |
1383 */ |
1652 */ |
1384 void NmFrameworkAdapter::handleMailboxEvent( TFSMailMsgId mailbox, NmMailboxEvent event) |
1653 void NmFrameworkAdapter::handleMailboxEvent( TFSMailMsgId mailbox, NmMailboxEvent event) |
1385 { |
1654 { |
1655 NM_FUNCTION; |
|
1656 |
|
1386 QList<NmId> mailboxIds; |
1657 QList<NmId> mailboxIds; |
1387 NmId nmId; |
1658 NmId nmId; |
1388 if (event == NmMailboxDeleted) { |
1659 if (event == NmMailboxDeleted) { |
1389 nmId = mailbox.GetNmId(); |
1660 nmId = mailbox.GetNmId(); |
1390 } else { |
1661 } else { |
1401 TAny* param1, |
1672 TAny* param1, |
1402 TAny* param2, |
1673 TAny* param2, |
1403 NmMessageEvent event, |
1674 NmMessageEvent event, |
1404 TFSMailMsgId mailbox) |
1675 TFSMailMsgId mailbox) |
1405 { |
1676 { |
1677 NM_FUNCTION; |
|
1678 |
|
1406 NmId nmMsgId(0); |
1679 NmId nmMsgId(0); |
1407 QList<NmId> messageIds; |
1680 QList<NmId> messageIds; |
1408 RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1); |
1681 RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1); |
1409 TFSMailMsgId* fsFolderId = reinterpret_cast<TFSMailMsgId*> (param2); |
1682 TFSMailMsgId* fsFolderId = reinterpret_cast<TFSMailMsgId*> (param2); |
1410 NmId folderId = fsFolderId->GetNmId(); |
1683 NmId folderId = fsFolderId->GetNmId(); |
1421 /*! |
1694 /*! |
1422 function to handle mailmoved event |
1695 function to handle mailmoved event |
1423 */ |
1696 */ |
1424 void NmFrameworkAdapter::handleMailMoved(TAny* param1,TAny* param2,TAny* param3, TFSMailMsgId mailbox) |
1697 void NmFrameworkAdapter::handleMailMoved(TAny* param1,TAny* param2,TAny* param3, TFSMailMsgId mailbox) |
1425 { |
1698 { |
1699 NM_FUNCTION; |
|
1700 |
|
1426 NmId nmMsgId(0); |
1701 NmId nmMsgId(0); |
1427 QList<NmId> messageIds; |
1702 QList<NmId> messageIds; |
1428 RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1); |
1703 RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1); |
1429 TFSMailMsgId* fsFromFolderId = reinterpret_cast<TFSMailMsgId*> (param3); |
1704 TFSMailMsgId* fsFromFolderId = reinterpret_cast<TFSMailMsgId*> (param3); |
1430 NmId fromFolderId = fsFromFolderId->GetNmId(); |
1705 NmId fromFolderId = fsFromFolderId->GetNmId(); |
1446 /*! |
1721 /*! |
1447 function to handle mailcopied event |
1722 function to handle mailcopied event |
1448 */ |
1723 */ |
1449 void NmFrameworkAdapter::handleMailCopied(TAny* param1,TAny* param2, TFSMailMsgId mailbox) |
1724 void NmFrameworkAdapter::handleMailCopied(TAny* param1,TAny* param2, TFSMailMsgId mailbox) |
1450 { |
1725 { |
1726 NM_FUNCTION; |
|
1727 |
|
1451 NmId nmMsgId(0); |
1728 NmId nmMsgId(0); |
1452 QList<NmId> messageIds; |
1729 QList<NmId> messageIds; |
1453 RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1); |
1730 RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1); |
1454 TFSMailMsgId* fsToFolderId = reinterpret_cast<TFSMailMsgId*> (param2); |
1731 TFSMailMsgId* fsToFolderId = reinterpret_cast<TFSMailMsgId*> (param2); |
1455 NmId toFolderId = fsToFolderId->GetNmId(); |
1732 NmId toFolderId = fsToFolderId->GetNmId(); |
1464 emit messageEvent(NmMessageCreated, toFolderId, messageIds, mailbox.GetNmId()); |
1741 emit messageEvent(NmMessageCreated, toFolderId, messageIds, mailbox.GetNmId()); |
1465 } |
1742 } |
1466 |
1743 |
1467 void NmFrameworkAdapter::handleSyncstateEvent(TAny* param1, TFSMailMsgId mailbox) |
1744 void NmFrameworkAdapter::handleSyncstateEvent(TAny* param1, TFSMailMsgId mailbox) |
1468 { |
1745 { |
1746 NM_FUNCTION; |
|
1747 |
|
1469 TSSMailSyncState* state = static_cast<TSSMailSyncState*>( param1 ); |
1748 TSSMailSyncState* state = static_cast<TSSMailSyncState*>( param1 ); |
1470 NmOperationCompletionEvent event; |
1749 NmOperationCompletionEvent event; |
1471 event.mMailboxId = NmConverter::mailMsgIdToNmId(mailbox); |
1750 event.mMailboxId = NmConverter::mailMsgIdToNmId(mailbox); |
1472 event.mOperationType = Synch; |
1751 event.mOperationType = Synch; |
1473 |
1752 |