311 /*! |
311 /*! |
312 Return envelope given by mailbox, folder and envelope id. |
312 Return envelope given by mailbox, folder and envelope id. |
313 |
313 |
314 \param mailboxId Mailbox id from where envlope should come |
314 \param mailboxId Mailbox id from where envlope should come |
315 \param folderId Folder id from where envlope should come |
315 \param folderId Folder id from where envlope should come |
316 \param folderId Id of envelope which should be returned |
316 \param messageId Id of envelope which should be returned |
317 \param envelope Envelope to fill. |
317 \param envelope Envelope to fill. |
318 |
318 |
319 \return Return true if it will find any envelope |
319 \return Return true if it will find any envelope |
320 */ |
320 */ |
321 bool NmApiEngine::getEnvelopeById( |
321 bool NmApiEngine::getEnvelopeById( |
354 } |
354 } |
355 return found; |
355 return found; |
356 } |
356 } |
357 |
357 |
358 /*! |
358 /*! |
|
359 Return folder given by mailbox and folder id. |
|
360 |
|
361 \param mailboxId Id of Mailbox which should be returned |
|
362 \param folderId Folder id id of folder to be fetched |
|
363 \param mailboxFolder reference to copy reference of NmApiFolder |
|
364 |
|
365 \return Return true if it will find folder |
|
366 */ |
|
367 bool NmApiEngine::getFolderById( |
|
368 const quint64 mailboxId, |
|
369 const quint64 folderId, |
|
370 EmailClientApi::NmApiFolder &mailboxFolder) |
|
371 { |
|
372 NM_FUNCTION; |
|
373 |
|
374 bool found = false; |
|
375 |
|
376 listMailPlugins(); |
|
377 |
|
378 CFSMailPlugin *plugin = NULL; |
|
379 CFSMailFolder *fsFolder = NULL; |
|
380 TFSMailMsgId fsMailBoxId = TFSMailMsgId(mailboxId); |
|
381 TFSMailMsgId fsFolderId = TFSMailMsgId(folderId); |
|
382 |
|
383 for (int i = 0; i < mMailPlugins.Count() && !fsFolder; i++){ |
|
384 plugin = mMailPlugins[i]; |
|
385 if (plugin && (plugin->Id() == fsMailBoxId.PluginId())) { |
|
386 TRAPD(err, fsFolder = plugin->GetFolderByUidL(fsMailBoxId, fsFolderId)); |
|
387 Q_UNUSED(err); |
|
388 } |
|
389 } |
|
390 if (fsFolder) { |
|
391 NmFolder *nmFolder = fsFolder->GetNmFolder(); |
|
392 EmailClientApi::NmApiFolder apiFolder = NmToApiConverter::NmFolder2NmApiFolder(*nmFolder); |
|
393 mailboxFolder = apiFolder; |
|
394 found = true; |
|
395 delete nmFolder; |
|
396 delete fsFolder; |
|
397 } |
|
398 return found; |
|
399 } |
|
400 |
|
401 /*! |
359 Return message given by mailbox, folder and message id. |
402 Return message given by mailbox, folder and message id. |
360 |
403 |
361 \param mailboxId Mailbox id from where message should come |
404 \param mailboxId Mailbox id from where message should come |
362 \param folderId Folder id from where message should come |
405 \param folderId Folder id from where message should come |
363 \param messageId Id of message which should be returned |
406 \param messageId Id of message which should be returned |
376 bool found = false; |
419 bool found = false; |
377 |
420 |
378 listMailPlugins(); |
421 listMailPlugins(); |
379 |
422 |
380 CFSMailPlugin *plugin = NULL; |
423 CFSMailPlugin *plugin = NULL; |
381 CFSMailMessage* fsMessage = NULL; |
424 CFSMailMessage *fsMessage = NULL; |
382 TFSMailMsgId fsMailBoxId = TFSMailMsgId(mailboxId); |
425 TFSMailMsgId fsMailBoxId = TFSMailMsgId(mailboxId); |
383 TFSMailMsgId fsFolderId = TFSMailMsgId(folderId); |
426 TFSMailMsgId fsFolderId = TFSMailMsgId(folderId); |
384 TFSMailMsgId fsMessageId = TFSMailMsgId(messageId); |
427 TFSMailMsgId fsMessageId = TFSMailMsgId(messageId); |
385 |
428 |
386 for (int i = 0; i < mMailPlugins.Count() && !fsMessage; i++){ |
429 for (int i = 0; i < mMailPlugins.Count() && !fsMessage; i++){ |
387 plugin = mMailPlugins[i]; |
430 plugin = mMailPlugins[i]; |
388 if (plugin) { |
431 if (plugin && (plugin->Id() == fsMailBoxId.PluginId())) { |
389 QT_TRY { |
432 TRAPD(err, fsMessage = plugin->GetMessageByUidL(fsMailBoxId, |
390 fsMessage = plugin->GetMessageByUidL(fsMailBoxId, |
|
391 fsFolderId, |
433 fsFolderId, |
392 fsMessageId, |
434 fsMessageId, |
393 EFSMsgDataStructure); |
435 EFSMsgDataStructure)); |
394 } |
436 Q_UNUSED(err); |
395 QT_CATCH(...){} |
|
396 } |
437 } |
397 } |
438 } |
398 if (fsMessage) { |
439 if (fsMessage) { |
399 NmMessage *nmMessage = fsMessage->GetNmMessage(); |
440 NmMessage *nmMessage = fsMessage->GetNmMessage(); |
400 EmailClientApi::NmApiMessage apiMessage = NmToApiConverter::NmMessage2NmApiMessage(*nmMessage); |
441 EmailClientApi::NmApiMessage apiMessage = NmToApiConverter::NmMessage2NmApiMessage(*nmMessage); |
401 message = apiMessage; |
442 message = apiMessage; |
402 found = true; |
443 found = true; |
|
444 delete nmMessage; |
403 delete fsMessage; |
445 delete fsMessage; |
404 } |
446 } |
405 return found; |
447 return found; |
406 } |
448 } |
407 |
449 |
422 bool found = false; |
464 bool found = false; |
423 NmDataPluginInterface *instance = mFactory->interfaceInstance(); |
465 NmDataPluginInterface *instance = mFactory->interfaceInstance(); |
424 |
466 |
425 if (instance) { |
467 if (instance) { |
426 NmMailbox *nmmailbox = NULL; |
468 NmMailbox *nmmailbox = NULL; |
427 instance->getMailboxById(NmId(mailboxId), nmmailbox); |
469 int err =instance->getMailboxById(NmId(mailboxId), nmmailbox); |
428 |
470 |
429 if (nmmailbox) { |
471 if (err == NmNoError && nmmailbox) { |
430 mailbox = NmToApiConverter::NmMailbox2NmApiMailbox(*nmmailbox); |
472 mailbox = NmToApiConverter::NmMailbox2NmApiMailbox(*nmmailbox); |
431 found = true; |
473 found = true; |
432 delete nmmailbox; |
474 } |
433 } |
475 delete nmmailbox; |
434 } |
476 } |
435 |
477 |
436 return found; |
478 return found; |
437 } |
479 } |
438 |
480 |