|
1 /* |
|
2 * Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "nmframeworkadapterheaders.h" |
|
19 |
|
20 /*! |
|
21 \class NmFrameworkAdapter |
|
22 |
|
23 \brief The NmFrameworkAdapter works as an adapter between emailframework which is (legacy) |
|
24 Symbian code and emailuis which is done using QT. |
|
25 |
|
26 The NmFrameworkAdapter works as an adapter between emailframework which is (legacy) |
|
27 Symbian code and emailuis which is done using QT. Most functions in the adapter merely do d |
|
28 ata type conversions and forward function calls to emailframework implementation. |
|
29 Also events coming from emailframework are converted and emitted as signals. |
|
30 */ |
|
31 |
|
32 static const int NmListMessagesBlock = 100; |
|
33 |
|
34 |
|
35 |
|
36 /*! |
|
37 Constructor |
|
38 */ |
|
39 NmFrameworkAdapter::NmFrameworkAdapter() |
|
40 : mFSfw(NULL), |
|
41 mSearchObserver(NULL), |
|
42 mCurrentMailBox(NULL), |
|
43 mStateExtension(NULL) |
|
44 { |
|
45 NM_FUNCTION; |
|
46 |
|
47 // get s60 email framework |
|
48 TRAP_IGNORE(mFSfw = CFSMailClient::NewL()); |
|
49 |
|
50 if (mFSfw) { |
|
51 TRAP_IGNORE(mFSfw->AddObserverL(*this)); |
|
52 } |
|
53 } |
|
54 |
|
55 /*! |
|
56 Destructor |
|
57 */ |
|
58 NmFrameworkAdapter::~NmFrameworkAdapter() |
|
59 { |
|
60 NM_FUNCTION; |
|
61 |
|
62 delete mCurrentMailBox; |
|
63 mCurrentMailBox = NULL; |
|
64 |
|
65 mStateExtension = NULL; |
|
66 |
|
67 if (mSearchObserver) { |
|
68 delete mSearchObserver; |
|
69 mSearchObserver = NULL; |
|
70 } |
|
71 |
|
72 if (mFSfw) { |
|
73 mFSfw->RemoveObserver(*this); |
|
74 mFSfw->Close(); |
|
75 } |
|
76 |
|
77 mFSfw = NULL; |
|
78 } |
|
79 |
|
80 /*! |
|
81 Add ids of all existing mailboxes to list given as reference. |
|
82 |
|
83 \param mailboxIdList The list to receive the mailbox ids. |
|
84 |
|
85 \return Error code. |
|
86 */ |
|
87 int NmFrameworkAdapter::listMailboxIds(QList<NmId>& mailboxIdList) |
|
88 { |
|
89 NM_FUNCTION; |
|
90 |
|
91 QList<NmMailbox*> mailboxList; |
|
92 int ret = listMailboxes(mailboxList); |
|
93 |
|
94 if (ret == NmNoError) { |
|
95 QListIterator<NmMailbox*> iterator(mailboxList); |
|
96 while (iterator.hasNext()) { |
|
97 NmMailbox *box = iterator.next(); |
|
98 mailboxIdList.append(box->id()); |
|
99 delete box; |
|
100 box = NULL; |
|
101 } |
|
102 } |
|
103 return ret; |
|
104 } |
|
105 |
|
106 /*! |
|
107 Fill array given as reference with new mailbox objects, one for each existing mailbox. |
|
108 |
|
109 \param mailboxList The list to receive the mailbox object pointers, ownership of which is transferred to caller. |
|
110 |
|
111 \return Error code. |
|
112 */ |
|
113 int NmFrameworkAdapter::listMailboxes(QList<NmMailbox*>& mailboxList) |
|
114 { |
|
115 NM_FUNCTION; |
|
116 |
|
117 // get list of mailboxes from all plugins |
|
118 TFSMailMsgId id; |
|
119 id.SetNullId(); |
|
120 RPointerArray<CFSMailBox> mailBoxes; |
|
121 |
|
122 //if id.IsNullId(), mailboxes are listed from all plugins. |
|
123 //otherwise, only from the given one. |
|
124 TInt rcode = mFSfw->ListMailBoxes(id, mailBoxes); |
|
125 |
|
126 if (rcode == NmNoError) { |
|
127 // convert mailbox data to QT classes |
|
128 NmMailbox *box(NULL); |
|
129 for (TInt i(0) ; i < mailBoxes.Count(); i++) { |
|
130 box = NULL; |
|
131 if (mailBoxes[i]) { |
|
132 box = mailBoxes[i]->GetNmMailbox(); |
|
133 } |
|
134 if (box) { |
|
135 mailboxList.append(box); |
|
136 } |
|
137 } |
|
138 } |
|
139 mailBoxes.ResetAndDestroy(); |
|
140 return rcode; |
|
141 } |
|
142 |
|
143 /*! |
|
144 Get a pointer to a new mailbox object for the mailbox identified by id. |
|
145 |
|
146 \param id Id of the mailbox. |
|
147 \param mailbox Pointer reference to receive the mailbox object, ownership of which is transferred to caller. |
|
148 |
|
149 \return Error code. |
|
150 */ |
|
151 int NmFrameworkAdapter::getMailboxById(const NmId& id, NmMailbox*& mailbox) |
|
152 { |
|
153 NM_FUNCTION; |
|
154 |
|
155 const TFSMailMsgId mailMsgId(id.pluginId32(), id.id32()); |
|
156 CFSMailBox *box(NULL); |
|
157 TRAPD(err, box = mFSfw->GetMailBoxByUidL(mailMsgId)); |
|
158 if (err == KErrNone && box) { |
|
159 mailbox = box->GetNmMailbox(); |
|
160 delete box; |
|
161 box = NULL; |
|
162 } |
|
163 return err; |
|
164 } |
|
165 |
|
166 /*! |
|
167 Deletes the mailbox with the given id asynchronously. |
|
168 |
|
169 \param mailboxId Id of the mailbox to be deleted. |
|
170 |
|
171 \return Error code. |
|
172 */ |
|
173 QPointer<NmOperation> NmFrameworkAdapter::deleteMailboxById(const NmId& mailboxId) |
|
174 { |
|
175 NM_FUNCTION; |
|
176 QPointer<NmOperation> oper = new NmFwaDeleteMailboxOperation(mailboxId, *mFSfw); |
|
177 return oper; |
|
178 } |
|
179 |
|
180 /*! |
|
181 Returns folder |
|
182 |
|
183 \param mailboxId Id of the mailbox containing the folder. |
|
184 \param folderId Id of the requested folder |
|
185 \param message Pointer reference to receive a folder object, ownership is transferred. |
|
186 |
|
187 \return Error code. |
|
188 */ |
|
189 int NmFrameworkAdapter::getFolderById(const NmId& mailboxId, const NmId& folderId, NmFolder*& folder) |
|
190 { |
|
191 NM_FUNCTION; |
|
192 |
|
193 TRAPD(err, getFolderByIdL(mailboxId, folderId, folder)); |
|
194 return err; |
|
195 } |
|
196 |
|
197 /*! |
|
198 Leaving version of getFolderById function |
|
199 */ |
|
200 void NmFrameworkAdapter::getFolderByIdL(const NmId& mailboxId, const NmId& folderId, NmFolder*& folder) |
|
201 { |
|
202 NM_FUNCTION; |
|
203 |
|
204 CFSMailFolder* fsFolder(NULL); |
|
205 fsFolder = mFSfw->GetFolderByUidL(TFSMailMsgId(mailboxId), TFSMailMsgId(folderId)); |
|
206 if (fsFolder) { |
|
207 folder = fsFolder->GetNmFolder(); |
|
208 delete fsFolder; |
|
209 fsFolder = NULL; |
|
210 } else { |
|
211 User::Leave(KErrNotFound); |
|
212 } |
|
213 } |
|
214 |
|
215 |
|
216 /*! |
|
217 Returns message from the store together with whole message part structure |
|
218 |
|
219 \param mailboxId Id of the mailbox containing the folder. |
|
220 \param folderId Id of the folder containing the message. |
|
221 \param messageId Id of the message. |
|
222 \param message Pointer reference to receive a message object containing requested message, |
|
223 ownership is transferred. |
|
224 |
|
225 \return Error code. |
|
226 */ |
|
227 int NmFrameworkAdapter::getMessageById( |
|
228 const NmId& mailboxId, |
|
229 const NmId& folderId, |
|
230 const NmId& messageId, |
|
231 NmMessage*& message) |
|
232 { |
|
233 NM_FUNCTION; |
|
234 |
|
235 TRAPD(err, getMessageByIdL(mailboxId, folderId, messageId, message)); |
|
236 return err; |
|
237 } |
|
238 |
|
239 /*! |
|
240 Leaving version of getMessageById function |
|
241 */ |
|
242 void NmFrameworkAdapter::getMessageByIdL( |
|
243 const NmId& mailboxId, |
|
244 const NmId& folderId, |
|
245 const NmId& messageId, |
|
246 NmMessage*& message) |
|
247 { |
|
248 NM_FUNCTION; |
|
249 |
|
250 // select message details to be listed |
|
251 TFSMailDetails details(EFSMsgDataStructure); |
|
252 |
|
253 CFSMailMessage* newMessage(NULL); |
|
254 newMessage = mFSfw->GetMessageByUidL(TFSMailMsgId(mailboxId), TFSMailMsgId(folderId), |
|
255 TFSMailMsgId(messageId), details); |
|
256 |
|
257 // GetMessageByUidL can return NULL pointer |
|
258 if (newMessage) { |
|
259 message = newMessage->GetNmMessage(); |
|
260 //assign all children found by mail plugin to NmMessage |
|
261 |
|
262 message->removeAllChildParts(); |
|
263 childrenToNmMessagePartL(newMessage, message); |
|
264 delete newMessage; |
|
265 newMessage = NULL; |
|
266 } |
|
267 else { |
|
268 User::Leave(KErrNotFound); |
|
269 } |
|
270 } |
|
271 |
|
272 /*! |
|
273 Returns list of folders in a mailbox. |
|
274 |
|
275 \param mailboxId Id of the mailbox containing the folder. |
|
276 \param folderList Reference to a pointer list to receive pointers to the folders. |
|
277 |
|
278 \return Error code. |
|
279 */ |
|
280 int NmFrameworkAdapter::listFolders( |
|
281 const NmId& mailboxId, |
|
282 QList<NmFolder*>& folderList) |
|
283 { |
|
284 NM_FUNCTION; |
|
285 int err(NmNoError); |
|
286 CFSMailBox* currentMailbox(NULL); |
|
287 TRAP(err, currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId)); |
|
288 if (KErrNone == err && currentMailbox) { |
|
289 RPointerArray<CFSMailFolder> folders = currentMailbox->ListFolders(); |
|
290 for (int i = 0; i < folders.Count(); i++) { |
|
291 folderList.append(folders[i]->GetNmFolder()); |
|
292 } |
|
293 delete currentMailbox; |
|
294 currentMailbox = NULL; |
|
295 } else { |
|
296 err = NmNotFoundError; |
|
297 } |
|
298 return err; |
|
299 } |
|
300 |
|
301 |
|
302 /*! |
|
303 Fetches all the messages from the given folder and appends their meta data |
|
304 into the given list. |
|
305 |
|
306 \param folder The folder instance. |
|
307 \param messageEnvelopeList The list where the data is stored to. |
|
308 \param maxEnvelopeCount The maximum number of messages to get. |
|
309 */ |
|
310 void NmFrameworkAdapter::getMessagesFromFolderL( |
|
311 CFSMailFolder *folder, |
|
312 QList<NmMessageEnvelope*> &messageEnvelopeList, |
|
313 const int maxEnvelopeCount) |
|
314 { |
|
315 NM_FUNCTION; |
|
316 // validity of input parameters is checked in calling function |
|
317 int blockSize = NmListMessagesBlock; |
|
318 int maxItemCount = NmMaxItemsInMessageList; |
|
319 |
|
320 if (maxEnvelopeCount < NmMaxItemsInMessageList) { |
|
321 maxItemCount = maxEnvelopeCount; |
|
322 |
|
323 if(maxEnvelopeCount < NmListMessagesBlock) { |
|
324 blockSize = maxEnvelopeCount; |
|
325 } |
|
326 } |
|
327 |
|
328 // First prepare all the parameters and select message details to be listed. |
|
329 TFSMailDetails details(EFSMsgDataEnvelope); |
|
330 |
|
331 // Set the sorting criteria. |
|
332 TFSMailSortCriteria criteria; |
|
333 criteria.iField = EFSMailSortByDate; |
|
334 criteria.iOrder = EFSMailDescending; |
|
335 RArray<TFSMailSortCriteria> sorting; |
|
336 CleanupClosePushL(sorting); |
|
337 sorting.Append(criteria); |
|
338 |
|
339 // Get the message list from the backend. |
|
340 MFSMailIterator* iterator(NULL); |
|
341 iterator = folder->ListMessagesL(details, sorting); |
|
342 |
|
343 if (iterator) { |
|
344 CleanupStack::PushL(iterator); |
|
345 RPointerArray<CFSMailMessage> messages; |
|
346 CleanupResetAndDestroy<CFSMailMessage>::PushL(messages); |
|
347 |
|
348 // The message list is fetched in blocks to prevent OOM in protocol |
|
349 // plugin side. |
|
350 bool moreMessagesToFollow(false); |
|
351 moreMessagesToFollow = iterator->NextL(TFSMailMsgId(), blockSize, messages); |
|
352 |
|
353 for (int i = blockSize; |
|
354 i < maxItemCount && moreMessagesToFollow; |
|
355 i += blockSize) { |
|
356 moreMessagesToFollow = |
|
357 iterator->NextL(messages[i-1]->GetMessageId(), blockSize, messages); |
|
358 } |
|
359 |
|
360 // Add all the found emails into the result list. |
|
361 const TInt messageCount(messages.Count()); |
|
362 |
|
363 for (TInt i = 0; i < messageCount; ++i) { |
|
364 NmMessageEnvelope *newEnvelope(NULL); |
|
365 newEnvelope = messages[i]->GetNmMessageEnvelope(); |
|
366 |
|
367 if (newEnvelope) { |
|
368 messageEnvelopeList.append(newEnvelope); |
|
369 } |
|
370 } |
|
371 |
|
372 CleanupStack::PopAndDestroy(&messages); |
|
373 CleanupStack::Pop(iterator); |
|
374 delete iterator; |
|
375 iterator = NULL; |
|
376 } |
|
377 |
|
378 CleanupStack::PopAndDestroy(); // sorting |
|
379 } |
|
380 |
|
381 |
|
382 /*! |
|
383 Returns list of envelopes from the backend for specific mailbox and folder. |
|
384 |
|
385 \param mailboxId Id of the mailbox containing the folder. |
|
386 \param folderId Folder id. |
|
387 \param messageMetaDataList Reference to pointer list to receive the envelope objects, |
|
388 ownership is transferred. |
|
389 |
|
390 \return Error code. |
|
391 */ |
|
392 int NmFrameworkAdapter::listMessages( |
|
393 const NmId &mailboxId, |
|
394 const NmId &folderId, |
|
395 QList<NmMessageEnvelope*> &messageEnvelopeList) |
|
396 { |
|
397 NM_FUNCTION; |
|
398 |
|
399 TRAPD(err, listMessagesL(mailboxId,folderId,messageEnvelopeList, NmMaxItemsInMessageList)); |
|
400 return err; |
|
401 } |
|
402 |
|
403 |
|
404 /*! |
|
405 Fetches the meta data for each message in the given mailbox and given |
|
406 folder. |
|
407 |
|
408 \param mailboxId The ID of the mailbox of which messages to list. |
|
409 \param folderId The ID of the folder of which messages to list. |
|
410 \param messageEnvelopeList The list where the message data is stored to. |
|
411 Note that the ownership is transferred! |
|
412 \param maxAmountOfEnvelopes The maximum number of messages to list. |
|
413 |
|
414 \return If success, KErrNone, an error code otherwise. |
|
415 */ |
|
416 int NmFrameworkAdapter::listMessages( |
|
417 const NmId& mailboxId, |
|
418 const NmId& folderId, |
|
419 QList<NmMessageEnvelope*> &messageEnvelopeList, |
|
420 const int maxAmountOfEnvelopes) |
|
421 { |
|
422 NM_FUNCTION; |
|
423 |
|
424 TInt err(KErrNone); |
|
425 TRAP(err, listMessagesL(mailboxId,folderId, messageEnvelopeList,maxAmountOfEnvelopes) ); |
|
426 return err; |
|
427 } |
|
428 |
|
429 |
|
430 /*! |
|
431 Fetches the meta data for each message in the given mailbox and given |
|
432 folder. Note that this private method can leave. |
|
433 */ |
|
434 void NmFrameworkAdapter::listMessagesL( |
|
435 const NmId &mailboxId, |
|
436 const NmId &folderId, |
|
437 QList<NmMessageEnvelope*> &messageEnvelopeList, |
|
438 const int maxAmountOfEnvelopes) |
|
439 { |
|
440 NM_FUNCTION; |
|
441 |
|
442 // If we are requesting 0 or less mails, we can just return. |
|
443 if (maxAmountOfEnvelopes <= 0) { |
|
444 return; |
|
445 } |
|
446 |
|
447 CFSMailBox *mailbox(NULL); |
|
448 mailbox = mFSfw->GetMailBoxByUidL(mailboxId); |
|
449 |
|
450 if (!mailbox) { |
|
451 User::Leave(KErrNotFound); |
|
452 } |
|
453 |
|
454 CleanupStack::PushL(mailbox); |
|
455 |
|
456 CFSMailFolder* folder(NULL); |
|
457 folder = mFSfw->GetFolderByUidL(mailbox->GetId(), TFSMailMsgId(folderId)); |
|
458 |
|
459 if (folder) { |
|
460 CleanupStack::PushL(folder); |
|
461 getMessagesFromFolderL(folder, messageEnvelopeList, maxAmountOfEnvelopes); |
|
462 CleanupStack::PopAndDestroy(folder); |
|
463 } |
|
464 |
|
465 CleanupStack::PopAndDestroy(mailbox); |
|
466 } |
|
467 |
|
468 |
|
469 /*! |
|
470 Returns list of messages from the backend for specific mailbox and folder. |
|
471 |
|
472 \param mailboxId Id of the mailbox containing the folder. |
|
473 \param folderId Folder id. |
|
474 \param messageMetaDataList Reference to pointer list to receive the envelope objects, |
|
475 ownership is transferred. |
|
476 |
|
477 \return Error code. |
|
478 */ |
|
479 int NmFrameworkAdapter::listMessages( |
|
480 const NmId &mailboxId, |
|
481 const NmId &folderId, |
|
482 QList<NmMessage*> &messageList, |
|
483 const int maxAmountOfMessages) |
|
484 { |
|
485 NM_FUNCTION; |
|
486 |
|
487 TRAPD(err, listMessagesL(mailboxId,folderId,messageList, maxAmountOfMessages)); |
|
488 return err; |
|
489 } |
|
490 |
|
491 |
|
492 /*! |
|
493 Leaving version of list messages with NmMessageList input |
|
494 */ |
|
495 void NmFrameworkAdapter::listMessagesL( |
|
496 const NmId &mailboxId, |
|
497 const NmId &folderId, |
|
498 QList<NmMessage*> &messageList, |
|
499 const int maxAmountOfEnvelopes) |
|
500 { |
|
501 NM_FUNCTION; |
|
502 |
|
503 CFSMailBox* currentMailbox(NULL); |
|
504 CFSMailFolder* folder(NULL); |
|
505 |
|
506 //If we are requesting 0 or less mails so we can return |
|
507 if( maxAmountOfEnvelopes <= 0) |
|
508 { |
|
509 return; |
|
510 } |
|
511 |
|
512 int blockSize = NmListMessagesBlock; |
|
513 int maxLimit = NmMaxItemsInMessageList; |
|
514 |
|
515 if( maxAmountOfEnvelopes < NmMaxItemsInMessageList ) |
|
516 { |
|
517 maxLimit = maxAmountOfEnvelopes; |
|
518 if(maxAmountOfEnvelopes < NmListMessagesBlock) |
|
519 { |
|
520 blockSize = maxAmountOfEnvelopes; |
|
521 } |
|
522 } |
|
523 |
|
524 currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId); |
|
525 if (!currentMailbox) { |
|
526 User::Leave(KErrNotFound); |
|
527 } |
|
528 CleanupStack::PushL(currentMailbox); |
|
529 folder = mFSfw->GetFolderByUidL(currentMailbox->GetId(), TFSMailMsgId(folderId)); |
|
530 |
|
531 if (folder) { |
|
532 CleanupStack::PushL(folder); |
|
533 // First prepare all the parameters |
|
534 // select message details to be listed |
|
535 TFSMailDetails details(EFSMsgDataEnvelope); |
|
536 |
|
537 // set sorting criteria |
|
538 TFSMailSortCriteria criteria; |
|
539 criteria.iField = EFSMailSortByDate; |
|
540 criteria.iOrder = EFSMailDescending; |
|
541 RArray<TFSMailSortCriteria> sorting; |
|
542 CleanupClosePushL(sorting); |
|
543 sorting.Append(criteria); |
|
544 |
|
545 TFSMailMsgId currentMessageId; // first call contains NULL id as begin id |
|
546 // get messages list from the backend |
|
547 MFSMailIterator* iterator(NULL); |
|
548 |
|
549 iterator = folder->ListMessagesL(details, sorting); |
|
550 if (iterator) { |
|
551 CleanupStack::PushL(iterator); |
|
552 RPointerArray<CFSMailMessage> messages; |
|
553 CleanupResetAndDestroy<CFSMailMessage>::PushL(messages); |
|
554 |
|
555 //Message list is fetched in blocks to prevent OOM in protocol plugin side |
|
556 bool moreMessagesToFollow(false); |
|
557 moreMessagesToFollow = iterator->NextL( |
|
558 TFSMailMsgId(), blockSize, messages); |
|
559 for ( int i = blockSize; |
|
560 i < maxLimit && moreMessagesToFollow ; |
|
561 i += blockSize ) { |
|
562 moreMessagesToFollow = iterator->NextL( |
|
563 messages[i-1]->GetMessageId(), blockSize, messages); |
|
564 |
|
565 } |
|
566 |
|
567 //Add all found emails to the result list |
|
568 for(TInt i=0; i<messages.Count(); i++) { |
|
569 NmMessage* newMessage(NULL); |
|
570 newMessage = messages[i]->GetNmMessage(); |
|
571 if (newMessage) { |
|
572 //Add content of message |
|
573 NmMessagePart *plainTextPart = newMessage->plainTextBodyPart(); |
|
574 if (plainTextPart) { |
|
575 contentToMessagePart(mailboxId, folderId, newMessage->envelope().messageId(), |
|
576 *plainTextPart); |
|
577 } |
|
578 messageList.append(newMessage); |
|
579 } |
|
580 } |
|
581 |
|
582 CleanupStack::PopAndDestroy( &messages ); |
|
583 CleanupStack::Pop(iterator); |
|
584 delete iterator; |
|
585 iterator = NULL; |
|
586 } |
|
587 CleanupStack::PopAndDestroy(); // sorting |
|
588 CleanupStack::PopAndDestroy(folder); |
|
589 } |
|
590 CleanupStack::PopAndDestroy(currentMailbox); |
|
591 } |
|
592 |
|
593 |
|
594 /*! |
|
595 Starts an asynchronous search for messages with the given search strings. |
|
596 This is part of the public interface. |
|
597 |
|
598 \see NmFrameworkAdapter::searchL(). |
|
599 |
|
600 \param mailboxId The mailbox to search from. |
|
601 \param searchStrings The strings to search. |
|
602 |
|
603 \return A possible error code. |
|
604 */ |
|
605 int NmFrameworkAdapter::search(const NmId &mailboxId, |
|
606 const QStringList &searchStrings) |
|
607 { |
|
608 NM_FUNCTION; |
|
609 |
|
610 if (!mSearchObserver) { |
|
611 mSearchObserver = new NmMailboxSearchObserver(); |
|
612 } |
|
613 |
|
614 // Set connections for forwarding the signals emitted by the search |
|
615 // observer. |
|
616 connect(mSearchObserver, SIGNAL(matchFound(const NmId &, const NmId &)), |
|
617 this, SIGNAL(matchFound(const NmId &, const NmId &)), Qt::UniqueConnection); |
|
618 connect(mSearchObserver, SIGNAL(searchComplete()), |
|
619 this, SIGNAL(searchComplete()), Qt::UniqueConnection); |
|
620 |
|
621 TRAPD(err, searchL(mailboxId, QList<NmId>(), searchStrings, *mSearchObserver)); |
|
622 return err; |
|
623 } |
|
624 |
|
625 |
|
626 /*! |
|
627 Cancels the search if one is ongoing. |
|
628 |
|
629 \param mailboxId The ID of the mailbox running the search. |
|
630 |
|
631 \return A possible error code. |
|
632 */ |
|
633 int NmFrameworkAdapter::cancelSearch(const NmId &mailboxId) |
|
634 { |
|
635 NM_FUNCTION; |
|
636 |
|
637 // Get the mailbox with the given ID. |
|
638 CFSMailBox *mailbox(NULL); |
|
639 TRAPD(err, mailbox = mFSfw->GetMailBoxByUidL(mailboxId)); |
|
640 |
|
641 if (err == KErrNone && mailbox) { |
|
642 mailbox->CancelSearch(); |
|
643 delete mailbox; |
|
644 mailbox = NULL; |
|
645 } |
|
646 |
|
647 return err; |
|
648 } |
|
649 |
|
650 /*! |
|
651 Indicates application state information to protocol plugins |
|
652 \param mailboxId Id of active mailbox, 0 if application is closed. |
|
653 \param folderId Id of active folder, 0 if application is closed. |
|
654 */ |
|
655 void NmFrameworkAdapter::updateActiveFolder( |
|
656 const NmId &mailboxId, const NmId &folderId) |
|
657 { |
|
658 TRAP_IGNORE(doUpdateActiveFolderL(mailboxId, folderId)); |
|
659 } |
|
660 |
|
661 /*! |
|
662 Removes draft message asynchronously |
|
663 */ |
|
664 QPointer<NmOperation> NmFrameworkAdapter::removeDraftMessage(NmMessage *message) |
|
665 { |
|
666 NM_FUNCTION; |
|
667 |
|
668 QPointer<NmOperation> oper = new NmFwaRemoveDraftMessageOperation(*this, message, *mFSfw); |
|
669 return oper; |
|
670 } |
|
671 |
|
672 /*! |
|
673 function to process updateActiveFolder. This method may leave. |
|
674 */ |
|
675 void NmFrameworkAdapter::doUpdateActiveFolderL( |
|
676 const NmId &mailboxId, const NmId &folderId) |
|
677 { |
|
678 if ((mFSfw) && (!mCurrentMailBox || mCurrentMailBox->GetId()!=mailboxId)) { |
|
679 delete mCurrentMailBox; |
|
680 mCurrentMailBox = NULL; |
|
681 mCurrentMailBox = mFSfw->GetMailBoxByUidL(mailboxId); |
|
682 } |
|
683 CEmailExtension *extension = getEMailStateExtensionL(); |
|
684 CMailboxStateExtension *stateExtension = |
|
685 static_cast<CMailboxStateExtension*>(extension); |
|
686 if (stateExtension) { |
|
687 stateExtension->NotifyActiveFolderChanged(mailboxId, folderId); |
|
688 } |
|
689 } |
|
690 |
|
691 /*! |
|
692 function to process updateActiveFolder. This method may leave. |
|
693 */ |
|
694 CEmailExtension* NmFrameworkAdapter::getEMailStateExtensionL() |
|
695 { |
|
696 if (!mStateExtension && mCurrentMailBox) { |
|
697 // This extension is owned and deleted by the plugin, so no need to |
|
698 // use release unless the extension will be relocated into extensionbase. |
|
699 mStateExtension = mCurrentMailBox->ExtensionL(KEmailMailboxStateExtensionUid); |
|
700 } |
|
701 return mStateExtension; |
|
702 } |
|
703 |
|
704 /*! |
|
705 Starts an asynchronous search for messages with the given search strings. |
|
706 |
|
707 \param mailboxId The mailbox to search from. |
|
708 \param folderIds (not used) |
|
709 \param searchStrings The strings to search. |
|
710 \param searchObserver The observer which gets informed about the progress |
|
711 of the search (match found, search complete etc.) |
|
712 */ |
|
713 void NmFrameworkAdapter::searchL(const NmId &mailboxId, |
|
714 const QList<NmId> &folderIds, |
|
715 const QStringList &searchStrings, |
|
716 NmMailboxSearchObserver &searchObserver) |
|
717 { |
|
718 NM_FUNCTION; |
|
719 |
|
720 // CFSMailBox has no support for search using folder IDs. |
|
721 Q_UNUSED(folderIds); |
|
722 |
|
723 // Get the mailbox with the given ID. |
|
724 CFSMailBox *mailbox(NULL); |
|
725 mailbox = mFSfw->GetMailBoxByUidL(mailboxId); |
|
726 |
|
727 if (mailbox) { |
|
728 CleanupStack::PushL(mailbox); |
|
729 RPointerArray<TDesC> strings; |
|
730 CleanupResetAndDestroy<TDesC>::PushL(strings); |
|
731 |
|
732 // Convert the search strings to HBufCs. |
|
733 foreach (QString string, searchStrings) { |
|
734 HBufC *buffer = NmConverter::qstringToHBufCLC(string); |
|
735 strings.AppendL(buffer); |
|
736 CleanupStack::Pop(buffer); |
|
737 } |
|
738 |
|
739 // Show results in ascending date/time order. |
|
740 TFSMailSortCriteria sortCriteria; |
|
741 sortCriteria.iField = EFSMailSortByDate; |
|
742 sortCriteria.iOrder = EFSMailAscending; |
|
743 |
|
744 // Start the search. |
|
745 mailbox->SearchL(strings, sortCriteria, searchObserver); |
|
746 |
|
747 // Clean up. |
|
748 strings.ResetAndDestroy(); |
|
749 CleanupStack::Pop(&strings); |
|
750 CleanupStack::PopAndDestroy(mailbox); |
|
751 } |
|
752 } |
|
753 |
|
754 |
|
755 /*! |
|
756 Starts a message fetching operation. |
|
757 |
|
758 \param mailboxId Id of the mailbox containing the folder. |
|
759 \param folderId Id of the folder containing the message. |
|
760 \param messageId Id of the message to fetch. |
|
761 |
|
762 \return An NmOperation object for the operation, ownership is transferred to caller |
|
763 */ |
|
764 QPointer<NmOperation> NmFrameworkAdapter::fetchMessage( |
|
765 const NmId &mailboxId, |
|
766 const NmId &folderId, |
|
767 const NmId &messageId ) |
|
768 { |
|
769 NM_FUNCTION; |
|
770 |
|
771 NmOperation *oper = new NmFwaMessageFetchingOperation(mailboxId, folderId, messageId, *mFSfw); |
|
772 return oper; |
|
773 } |
|
774 |
|
775 /*! |
|
776 Starts a message part fetching operation. |
|
777 |
|
778 \param mailboxId Id of the mailbox containing the folder. |
|
779 \param folderId Id of the folder containing the message. |
|
780 \param messageId Id of message containing the message parts |
|
781 \param messagePartId id of message part |
|
782 |
|
783 \return An NmOperation object for the operation, ownership is transferred to caller |
|
784 */ |
|
785 QPointer<NmOperation> NmFrameworkAdapter::fetchMessagePart( |
|
786 const NmId &mailboxId, |
|
787 const NmId &folderId, |
|
788 const NmId &messageId, |
|
789 const NmId &messagePartId) |
|
790 { |
|
791 NM_FUNCTION; |
|
792 |
|
793 QPointer<NmOperation> oper = new NmFwaMessagePartFetchingOperation( |
|
794 mailboxId, folderId, messageId, messagePartId, *mFSfw); |
|
795 return oper; |
|
796 } |
|
797 |
|
798 /*! |
|
799 Starts a message parts fetching operation. |
|
800 |
|
801 \param mailboxId Id of the mailbox containing the folder. |
|
802 \param folderId Id of the folder containing the message. |
|
803 \param messageId Id of message containing the message parts |
|
804 \param messagePartIds ids of message parts |
|
805 |
|
806 \return An NmOperation object for the operation, ownership is transferred to caller |
|
807 */ |
|
808 QPointer<NmOperation> NmFrameworkAdapter::fetchMessageParts( |
|
809 const NmId &mailboxId, |
|
810 const NmId &folderId, |
|
811 const NmId &messageId, |
|
812 const QList<NmId> &messagePartIds) |
|
813 { |
|
814 NM_FUNCTION; |
|
815 |
|
816 QPointer<NmOperation> oper = new NmFwaMessagePartsFetchingOperation( |
|
817 mailboxId, folderId, messageId, messagePartIds, *mFSfw); |
|
818 return oper; |
|
819 } |
|
820 |
|
821 /*! |
|
822 Returns sharable file handle to message part content |
|
823 |
|
824 \param mailboxId Id of the mailbox containing the folder. |
|
825 \param folderId Id of the folder containing the message. |
|
826 \param messageId Id of message containing the message parts |
|
827 \param messagePartId id of message part |
|
828 |
|
829 \return XQSharableFile, sharable file object |
|
830 */ |
|
831 XQSharableFile NmFrameworkAdapter::messagePartFile( |
|
832 const NmId &mailboxId, |
|
833 const NmId &folderId, |
|
834 const NmId &messageId, |
|
835 const NmId &messagePartId) |
|
836 { |
|
837 NM_FUNCTION; |
|
838 |
|
839 XQSharableFile retFile; |
|
840 TFSMailDetails details(EFSMsgDataEnvelope); |
|
841 TFSMailMsgId fsMboxId(mailboxId); |
|
842 TFSMailMsgId fsFolderId(folderId); |
|
843 TFSMailMsgId fsMsgId(messageId); |
|
844 TFSMailMsgId fsMsgPartId(messagePartId); |
|
845 |
|
846 CFSMailMessage* fsMessage(NULL); |
|
847 int error(KErrNone); |
|
848 TRAP(error, fsMessage = mFSfw->GetMessageByUidL(fsMboxId, fsFolderId, |
|
849 fsMsgId, details) ); |
|
850 |
|
851 CFSMailMessagePart* fsMessagePart(NULL); |
|
852 if (fsMessage && error == KErrNone) { |
|
853 TRAP(error, fsMessagePart = fsMessage->ChildPartL(fsMsgPartId) ); |
|
854 |
|
855 } |
|
856 if (fsMessagePart && error == KErrNone) { |
|
857 RFile file = fsMessagePart->GetContentFileL(); |
|
858 retFile.setHandle(file); |
|
859 } |
|
860 delete fsMessagePart; |
|
861 fsMessagePart = NULL; |
|
862 delete fsMessage; |
|
863 fsMessage = NULL; |
|
864 return retFile; |
|
865 } |
|
866 |
|
867 /*! |
|
868 Get the id of a standard folder. |
|
869 |
|
870 \param mailboxId Id of the mailbox containing the folder. |
|
871 \param folderType Type of standard folder to get the id of. |
|
872 |
|
873 \return Id of the standard folder, or NmId for which NmId.getId() == 0 if not found. |
|
874 */ |
|
875 NmId NmFrameworkAdapter::getStandardFolderId( |
|
876 const NmId& mailboxId, |
|
877 NmFolderType folderType ) |
|
878 { |
|
879 NM_FUNCTION; |
|
880 |
|
881 TFSMailMsgId folderId; |
|
882 NmId resultId(0); |
|
883 CFSMailBox* currentMailbox(NULL); |
|
884 |
|
885 TRAPD(error, currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId)); |
|
886 |
|
887 if(!currentMailbox || error != KErrNone) { |
|
888 return resultId; |
|
889 } |
|
890 |
|
891 switch(folderType) { |
|
892 case NmFolderInbox: |
|
893 folderId = currentMailbox->GetStandardFolderId(EFSInbox); |
|
894 break; |
|
895 case NmFolderOutbox: |
|
896 folderId = currentMailbox->GetStandardFolderId(EFSOutbox); |
|
897 break; |
|
898 case NmFolderDrafts: |
|
899 folderId = currentMailbox->GetStandardFolderId(EFSDraftsFolder); |
|
900 break; |
|
901 case NmFolderSent: |
|
902 folderId = currentMailbox->GetStandardFolderId(EFSSentFolder); |
|
903 break; |
|
904 case NmFolderDeleted: |
|
905 folderId = currentMailbox->GetStandardFolderId(EFSDeleted); |
|
906 break; |
|
907 case NmFolderOther: |
|
908 default: |
|
909 folderId = currentMailbox->GetStandardFolderId(EFSOther); |
|
910 break; |
|
911 } |
|
912 |
|
913 delete currentMailbox; |
|
914 currentMailbox = NULL; |
|
915 |
|
916 resultId.setPluginId32(static_cast<quint32>(folderId.PluginId().iUid)); |
|
917 resultId.setId32(folderId.Id()); |
|
918 |
|
919 return resultId; |
|
920 } |
|
921 |
|
922 /*! |
|
923 Connect to mailbox if not already connected and refresh. |
|
924 |
|
925 \param mailboxId Id of the mailbox. |
|
926 \return Async request id or error code. |
|
927 */ |
|
928 int NmFrameworkAdapter::refreshMailbox(NmId mailboxId) |
|
929 { |
|
930 NM_FUNCTION; |
|
931 |
|
932 TRAPD(err, RefreshMailboxL(mailboxId)); // return value not used |
|
933 return (err == KErrNone) ? NmNoError : NmGeneralError; |
|
934 } |
|
935 |
|
936 /*! |
|
937 Connect to mailbox if not already connected and refresh. |
|
938 |
|
939 \param mailboxId Id of the mailbox. |
|
940 \return Async request id or error code. |
|
941 */ |
|
942 int NmFrameworkAdapter::goOnline(const NmId& mailboxId) |
|
943 { |
|
944 NM_FUNCTION; |
|
945 |
|
946 TRAPD(err, GoOnlineL(mailboxId)); // return value not used |
|
947 return (err == KErrNone) ? NmNoError : NmGeneralError; |
|
948 } |
|
949 |
|
950 /*! |
|
951 Disconnect to mailbox if not already disconnected. |
|
952 |
|
953 \param mailboxId Id of the mailbox. |
|
954 \return Async request id or error code. |
|
955 */ |
|
956 int NmFrameworkAdapter::goOffline(const NmId& mailboxId) |
|
957 { |
|
958 NM_FUNCTION; |
|
959 |
|
960 TRAPD(err, GoOfflineL(mailboxId)); // return value not used |
|
961 return (err == KErrNone) ? NmNoError : NmGeneralError; |
|
962 } |
|
963 |
|
964 /*! |
|
965 Sets content for the given message part. Client shouldn't create |
|
966 message part on its own. Instead it should be requested by calling |
|
967 e.g. getMessageById. |
|
968 |
|
969 \param mailboxId Id of the mailbox containing the folder (Unused). |
|
970 \param folderId Id of the folder containing the message (Unused). |
|
971 \param messageId Id of the message (Unused). |
|
972 \param messagePart Part of a message for which content is going to be requested. |
|
973 |
|
974 \return Error code. |
|
975 */ |
|
976 int NmFrameworkAdapter::contentToMessagePart( |
|
977 const NmId &mailboxId, |
|
978 const NmId &folderId, |
|
979 const NmId &messageId, |
|
980 NmMessagePart &messagePart) |
|
981 { |
|
982 NM_FUNCTION; |
|
983 |
|
984 TRAPD(err, contentToMessagePartL(mailboxId,folderId,messageId,messagePart)); |
|
985 return err; |
|
986 } |
|
987 |
|
988 /*! |
|
989 Leaving version of contentToMessagePart function |
|
990 */ |
|
991 void NmFrameworkAdapter::contentToMessagePartL( |
|
992 const NmId &mailboxId, |
|
993 const NmId &folderId, |
|
994 const NmId &messageId, |
|
995 NmMessagePart &messagePart) |
|
996 { |
|
997 NM_FUNCTION; |
|
998 |
|
999 CFSMailMessagePart* cfsPart = CFSMailMessagePart::NewLC(messageId,messagePart); |
|
1000 cfsPart->SetMailBoxId(TFSMailMsgId(mailboxId)); |
|
1001 cfsPart->SetFolderId(TFSMailMsgId(folderId)); |
|
1002 QString contentType = messagePart.contentType(); |
|
1003 |
|
1004 if (contentType.startsWith(NmContentTypeTextPlain)) { |
|
1005 // add 1 for max size for zero termination and prevend 0 size hbufc |
|
1006 HBufC* data = HBufC::NewLC(cfsPart->FetchedContentSize()+1); |
|
1007 TPtr dataPtr = data->Des(); |
|
1008 TInt startOffset = 0; |
|
1009 |
|
1010 cfsPart->GetContentToBufferL(dataPtr, startOffset); |
|
1011 messagePart.setTextContent(NmConverter::toQString(dataPtr), contentType); |
|
1012 CleanupStack::PopAndDestroy(data); |
|
1013 } else { |
|
1014 RFile file = cfsPart->GetContentFileL(); |
|
1015 TInt fileSize = 0; |
|
1016 file.Size(fileSize); |
|
1017 if (fileSize != 0) { |
|
1018 HBufC8* data = HBufC8::NewLC(fileSize); |
|
1019 TPtr8 dataPtr = data->Des(); |
|
1020 |
|
1021 if (fileSize != 0) { |
|
1022 TInt dummyPos = 0; |
|
1023 file.Seek(ESeekStart, dummyPos); |
|
1024 User::LeaveIfError(file.Read(dataPtr)); |
|
1025 } |
|
1026 |
|
1027 if (contentType.startsWith(NmContentTypeTextHtml) || contentType.contains( NmContentDescrAttachmentHtml)) { |
|
1028 QRegExp rxlen("(?:charset=)(?:\"?)([\\-\\_a-zA-Z0-9]+)", Qt::CaseInsensitive); |
|
1029 QString charset; |
|
1030 int pos = rxlen.indexIn(contentType); |
|
1031 if (pos > -1) { |
|
1032 charset = rxlen.cap(1); |
|
1033 } |
|
1034 QByteArray msgBytes = QByteArray(reinterpret_cast<const char*>(dataPtr.Ptr()), fileSize); |
|
1035 QTextCodec *codec = QTextCodec::codecForName(charset.toAscii()); |
|
1036 if (!codec) { |
|
1037 codec = QTextCodec::codecForName("UTF-8"); |
|
1038 } |
|
1039 QString encodedStr = codec->toUnicode(msgBytes); |
|
1040 messagePart.setTextContent(encodedStr, contentType); |
|
1041 } else { |
|
1042 messagePart.setBinaryContent(QByteArray( |
|
1043 reinterpret_cast<const char*>(dataPtr.Ptr()), fileSize), contentType); |
|
1044 } |
|
1045 CleanupStack::PopAndDestroy(data); |
|
1046 } |
|
1047 file.Close(); |
|
1048 } |
|
1049 CleanupStack::PopAndDestroy(cfsPart); |
|
1050 } |
|
1051 |
|
1052 /*! |
|
1053 Deletes the listed messages from specific mailbox and folder. |
|
1054 |
|
1055 \param mailboxId Id of the mailbox containing the folder. |
|
1056 \param folderId Id of the folder containing the messages. |
|
1057 \param messageIdList List of ids of the messages to be deleted. |
|
1058 |
|
1059 \return Error code. |
|
1060 */ |
|
1061 int NmFrameworkAdapter::deleteMessages( |
|
1062 const NmId &mailboxId, |
|
1063 const NmId &folderId, |
|
1064 const QList<NmId> &messageIdList) |
|
1065 { |
|
1066 NM_FUNCTION; |
|
1067 |
|
1068 TInt err(NmNoError); |
|
1069 RArray<TFSMailMsgId> messageIds; |
|
1070 for (TInt i(0); i < messageIdList.size(); i++) { |
|
1071 err = messageIds.Append(TFSMailMsgId(messageIdList[i])); |
|
1072 if (err != NmNoError) { |
|
1073 break; |
|
1074 } |
|
1075 } |
|
1076 if (NmNoError == err) { |
|
1077 TRAP(err, mFSfw->DeleteMessagesByUidL(TFSMailMsgId(mailboxId), TFSMailMsgId(folderId), messageIds)); |
|
1078 } |
|
1079 messageIds.Close(); |
|
1080 |
|
1081 return (err == NmNoError) ? NmNoError : NmGeneralError; |
|
1082 } |
|
1083 |
|
1084 /*! |
|
1085 Starts an async operation to store listed message envelopes to the given mailbox |
|
1086 |
|
1087 \param mailboxId Id of the mailbox. |
|
1088 \param folderId Unused. |
|
1089 \param envelopeList List of the envelope objects to store. |
|
1090 |
|
1091 \return NmStoreEnvelopesOperation |
|
1092 */ |
|
1093 QPointer<NmStoreEnvelopesOperation> NmFrameworkAdapter::storeEnvelopes( |
|
1094 const NmId &mailboxId, |
|
1095 const NmId &folderId, |
|
1096 const QList<const NmMessageEnvelope*> &envelopeList) |
|
1097 { |
|
1098 NM_FUNCTION; |
|
1099 |
|
1100 Q_UNUSED(folderId); |
|
1101 |
|
1102 QPointer<NmStoreEnvelopesOperation> operation(NULL); |
|
1103 RPointerArray<CFSMailMessage> envelopeMessages; |
|
1104 |
|
1105 int count(envelopeList.count()); |
|
1106 for(int i(0); i < count; i++) { |
|
1107 TRAP_IGNORE(envelopeMessages.AppendL(mailMessageFromEnvelopeL(*envelopeList.at(i)))); |
|
1108 } |
|
1109 |
|
1110 if (envelopeMessages.Count()) { |
|
1111 operation = new NmFwaStoreEnvelopesOperation( |
|
1112 mailboxId, |
|
1113 envelopeMessages, |
|
1114 *mFSfw); |
|
1115 } |
|
1116 |
|
1117 return operation; |
|
1118 } |
|
1119 |
|
1120 /*! |
|
1121 Creates a new message into the drafts folder a mailbox. |
|
1122 |
|
1123 \param mailboxId Id of the mailbox. |
|
1124 |
|
1125 \return NmMessageCreationOperation |
|
1126 */ |
|
1127 QPointer<NmMessageCreationOperation> NmFrameworkAdapter::createNewMessage(const NmId &mailboxId) |
|
1128 { |
|
1129 NM_FUNCTION; |
|
1130 |
|
1131 QPointer<NmMessageCreationOperation> oper = |
|
1132 new NmFwaMessageCreationOperation(mailboxId, *mFSfw); |
|
1133 return oper; |
|
1134 } |
|
1135 |
|
1136 /*! |
|
1137 Creates a new forward message into the drafts folder of a mailbox. |
|
1138 |
|
1139 \param mailboxId Id of the mailbox. |
|
1140 \param originalMessageId Id of the original message. Original message must be in the given mailbox. |
|
1141 |
|
1142 \return NmMessageCreationOperation |
|
1143 */ |
|
1144 QPointer<NmMessageCreationOperation> NmFrameworkAdapter::createForwardMessage( |
|
1145 const NmId &mailboxId, |
|
1146 const NmId &originalMessageId) |
|
1147 { |
|
1148 NM_FUNCTION; |
|
1149 |
|
1150 QPointer<NmMessageCreationOperation> oper = |
|
1151 new NmFwaForwardMessageCreationOperation(mailboxId, originalMessageId, *mFSfw); |
|
1152 return oper; |
|
1153 } |
|
1154 |
|
1155 /*! |
|
1156 Creates a new reply message into the drafts folder of a mailbox. |
|
1157 |
|
1158 \param mailboxId Id of the mailbox. |
|
1159 \param originalMessageId Id of the original message. Original message must be in the given mailbox. |
|
1160 \param replyAll Is reply for all recipients? |
|
1161 |
|
1162 \return NmMessageCreationOperation |
|
1163 */ |
|
1164 QPointer<NmMessageCreationOperation> NmFrameworkAdapter::createReplyMessage( |
|
1165 const NmId &mailboxId, |
|
1166 const NmId &originalMessageId, |
|
1167 const bool replyAll) |
|
1168 { |
|
1169 NM_FUNCTION; |
|
1170 |
|
1171 QPointer<NmMessageCreationOperation> oper = |
|
1172 new NmFwaReplyMessageCreationOperation(mailboxId, originalMessageId, replyAll, *mFSfw); |
|
1173 return oper; |
|
1174 } |
|
1175 |
|
1176 /*! |
|
1177 Not implemented yet. |
|
1178 */ |
|
1179 int NmFrameworkAdapter::saveMessage(const NmMessage &message) |
|
1180 { |
|
1181 NM_FUNCTION; |
|
1182 |
|
1183 Q_UNUSED(message); |
|
1184 return NmNoError; |
|
1185 } |
|
1186 |
|
1187 /*! |
|
1188 Store asynchronously message with its parts. |
|
1189 */ |
|
1190 QPointer<NmOperation> NmFrameworkAdapter::saveMessageWithSubparts(const NmMessage &message) |
|
1191 { |
|
1192 NM_FUNCTION; |
|
1193 |
|
1194 CFSMailMessage * cfsMessage = NULL; |
|
1195 QPointer<NmOperation> oper(NULL); |
|
1196 |
|
1197 int err = KErrNone; |
|
1198 TRAP(err, cfsMessage = CFSMailMessage::NewL(message)); |
|
1199 if (err == KErrNone) { |
|
1200 //transfers ownership of cfsMessage |
|
1201 oper = new NmFwaStoreMessageOperation(cfsMessage, *mFSfw); |
|
1202 } |
|
1203 |
|
1204 return oper; |
|
1205 } |
|
1206 |
|
1207 /*! |
|
1208 From MFSMailEventObserver |
|
1209 |
|
1210 \sa MFSMailEventObserver |
|
1211 */ |
|
1212 void NmFrameworkAdapter::EventL( |
|
1213 TFSMailEvent aEvent, |
|
1214 TFSMailMsgId mailbox, |
|
1215 TAny* param1, |
|
1216 TAny* param2, |
|
1217 TAny* param3) |
|
1218 { |
|
1219 NM_FUNCTION; |
|
1220 |
|
1221 switch (aEvent) { |
|
1222 // Mailbox related events: |
|
1223 case TFSEventNewMailbox: |
|
1224 handleMailboxEvent(mailbox, NmMailboxCreated); |
|
1225 break; |
|
1226 case TFSEventMailboxDeleted: |
|
1227 handleMailboxEvent(mailbox, NmMailboxDeleted); |
|
1228 break; |
|
1229 case TFSEventMailboxRenamed: |
|
1230 handleMailboxEvent(mailbox, NmMailboxChanged); |
|
1231 break; |
|
1232 |
|
1233 // |
|
1234 // Mail related events: |
|
1235 // signal: |
|
1236 // void messageEvent( |
|
1237 // NmMessageEvent event, |
|
1238 // const NmId &folderId, |
|
1239 // QList<NmId> &messageIds |
|
1240 // const NmId& mailboxId); |
|
1241 // |
|
1242 // enum NmMessageEvent |
|
1243 // NmMessageCreated, |
|
1244 // NmMessageChanged, |
|
1245 // NmMessageDeleted |
|
1246 // |
|
1247 |
|
1248 // New mails created |
|
1249 // param1: RArray<TFSMailMsgId>* aNewEntries |
|
1250 // param2: TFSMailMsgId* aParentFolder |
|
1251 // param3: NULL |
|
1252 case TFSEventNewMail: |
|
1253 handleMessageEvent(param1, param2, NmMessageCreated, mailbox); |
|
1254 break; |
|
1255 // Mails changed |
|
1256 // param1: RArray<TFSMailMsgId>* aEntries |
|
1257 // param2: TFSMailMsgId* aParentFolder |
|
1258 // param3: NULL |
|
1259 case TFSEventMailChanged: |
|
1260 handleMessageEvent(param1, param2, NmMessageChanged, mailbox); |
|
1261 break; |
|
1262 // Mails deleted |
|
1263 // param1: RArray<TFSMailMsgId>* aEntries |
|
1264 // param2: TFSMailMsgId* aParentFolder |
|
1265 // param3: NULL |
|
1266 case TFSEventMailDeleted: |
|
1267 handleMessageEvent(param1, param2, NmMessageDeleted, mailbox); |
|
1268 break; |
|
1269 |
|
1270 |
|
1271 // Mails moved |
|
1272 // param1: RArray<TFSMailMsgId>* aEntries |
|
1273 // param2: TFSMailMsgId* aNewParentFolder |
|
1274 // param3: TFSMailMsgId* aOldParentFolder |
|
1275 case TFSEventMailMoved: |
|
1276 handleMailMoved(param1, param2, param3, mailbox); |
|
1277 break; |
|
1278 |
|
1279 // Mails copied |
|
1280 // param1: RArray<TFSMailMsgId>* aNewEntries |
|
1281 // param2: TFSMailMsgId* aNewParentFolder |
|
1282 // param3: TFSMailMsgId* aOldParentFolder |
|
1283 case TFSEventMailCopied: |
|
1284 handleMailCopied(param1, param2, mailbox); |
|
1285 break; |
|
1286 |
|
1287 |
|
1288 //sync state related events |
|
1289 case TFSEventMailboxSyncStateChanged: |
|
1290 handleSyncstateEvent(param1, mailbox); |
|
1291 break; |
|
1292 |
|
1293 case TFSEventMailboxOnline:{ |
|
1294 NmId id = NmConverter::mailMsgIdToNmId(mailbox); |
|
1295 emit connectionEvent(Connected, id, NmNoError); |
|
1296 } |
|
1297 break; |
|
1298 |
|
1299 // param1: errorcode |
|
1300 case TFSEventMailboxOffline: { |
|
1301 NmId id = NmConverter::mailMsgIdToNmId(mailbox); |
|
1302 TInt error(KErrNone); |
|
1303 // if param1 is set, and it is != KErrNone, an unexpected offline event has occurred |
|
1304 if(param1) { |
|
1305 error=*(static_cast<TInt*>(param1)); |
|
1306 } |
|
1307 if(error) { |
|
1308 emit connectionEvent(Disconnected, id, NmConnectionError); |
|
1309 } |
|
1310 else { |
|
1311 emit connectionEvent(Disconnected, id, NmNoError); |
|
1312 } |
|
1313 } |
|
1314 break; |
|
1315 |
|
1316 default: |
|
1317 break; |
|
1318 } |
|
1319 } |
|
1320 |
|
1321 /*! |
|
1322 Delete the message from specific mailbox and folder. |
|
1323 |
|
1324 \param mailboxId Id of the mailbox containing the folder. |
|
1325 \param folderId Id of the folder containing the message. |
|
1326 \param messageId Id of the message. |
|
1327 |
|
1328 \return Error code. |
|
1329 */ |
|
1330 int NmFrameworkAdapter::removeMessage( |
|
1331 const NmId& mailboxId, |
|
1332 const NmId& folderId, |
|
1333 const NmId& messageId) |
|
1334 { |
|
1335 NM_FUNCTION; |
|
1336 |
|
1337 TRAPD(error, removeMessageL(mailboxId, folderId, messageId)); |
|
1338 return error; |
|
1339 } |
|
1340 |
|
1341 /*! |
|
1342 Copy messages between folders from specific mailbox. |
|
1343 |
|
1344 \param mailboxId Id of the mailbox containing messages. |
|
1345 \param messageIds The list of source message Ids. |
|
1346 \param newMessages The list of destination message Ids. |
|
1347 \param sourceFolderId Id of source folder. |
|
1348 \param destinationFolderId Id of destination folder. |
|
1349 */ |
|
1350 int NmFrameworkAdapter::copyMessages( |
|
1351 const NmId &mailboxId, |
|
1352 const QList<quint64>& messageIds, |
|
1353 const NmId& sourceFolderId, |
|
1354 const NmId& destinationFolderId) |
|
1355 { |
|
1356 NM_FUNCTION; |
|
1357 TRAPD(error, copyMessagesL(mailboxId, messageIds, sourceFolderId, destinationFolderId)); |
|
1358 return error; |
|
1359 } |
|
1360 |
|
1361 /*! |
|
1362 Gets the signature for the given mailbox. |
|
1363 |
|
1364 \param mailboxId Id of the mailbox. |
|
1365 */ |
|
1366 int NmFrameworkAdapter::getSignature(const NmId &mailboxId, QString *&signature) |
|
1367 { |
|
1368 NM_FUNCTION; |
|
1369 TRAPD(error, getSignatureL(mailboxId, signature)); |
|
1370 |
|
1371 return error; |
|
1372 } |
|
1373 |
|
1374 /*! |
|
1375 Subscribe to events from a mailbox. |
|
1376 |
|
1377 \param mailboxId Id of the mailbox. |
|
1378 */ |
|
1379 void NmFrameworkAdapter::subscribeMailboxEvents(const NmId& mailboxId) |
|
1380 { |
|
1381 NM_FUNCTION; |
|
1382 |
|
1383 TRAP_IGNORE(mFSfw->SubscribeMailboxEventsL(mailboxId, *this)); |
|
1384 } |
|
1385 |
|
1386 /*! |
|
1387 Unsubscribe to events from a mailbox. |
|
1388 |
|
1389 \param mailboxId Id of the mailbox. |
|
1390 */ |
|
1391 void NmFrameworkAdapter::unsubscribeMailboxEvents(const NmId& mailboxId) |
|
1392 { |
|
1393 NM_FUNCTION; |
|
1394 |
|
1395 mFSfw->UnsubscribeMailboxEvents(mailboxId, *this); |
|
1396 } |
|
1397 |
|
1398 |
|
1399 /*! |
|
1400 Leaving version of removeMessage |
|
1401 */ |
|
1402 void NmFrameworkAdapter::removeMessageL( |
|
1403 const NmId& mailboxId, |
|
1404 const NmId& folderId, |
|
1405 const NmId& messageId) |
|
1406 { |
|
1407 NM_FUNCTION; |
|
1408 |
|
1409 CFSMailFolder* folder = mFSfw->GetFolderByUidL( TFSMailMsgId(mailboxId), TFSMailMsgId(folderId)); |
|
1410 CleanupStack::PushL(folder); |
|
1411 if ( folder ) { |
|
1412 folder->RemoveMessageL(TFSMailMsgId(messageId)); |
|
1413 } |
|
1414 CleanupStack::PopAndDestroy(folder); |
|
1415 } |
|
1416 |
|
1417 /*! |
|
1418 Leaving version of copyMessages |
|
1419 */ |
|
1420 void NmFrameworkAdapter::copyMessagesL( |
|
1421 const NmId &mailboxId, |
|
1422 const QList<quint64>& messageIds, |
|
1423 const NmId& sourceFolderId, |
|
1424 const NmId& destinationFolderId) |
|
1425 { |
|
1426 NM_FUNCTION; |
|
1427 TInt count(messageIds.count()); |
|
1428 if (!count) { |
|
1429 return; |
|
1430 } |
|
1431 RArray<TFSMailMsgId> messages; |
|
1432 RArray<TFSMailMsgId> copiedMessages; |
|
1433 |
|
1434 CleanupClosePushL(messages); |
|
1435 CleanupClosePushL(copiedMessages); |
|
1436 |
|
1437 for (TInt i = 0; i < count; i++) { |
|
1438 NmId tmpId(messageIds[i]); |
|
1439 messages.AppendL(TFSMailMsgId(tmpId)); |
|
1440 } |
|
1441 |
|
1442 CFSMailBox* mailBox(NULL); |
|
1443 mailBox = mFSfw->GetMailBoxByUidL(mailboxId); |
|
1444 if (mailBox) { |
|
1445 mailBox->CopyMessagesL(messages, copiedMessages, |
|
1446 TFSMailMsgId(sourceFolderId), |
|
1447 TFSMailMsgId(destinationFolderId)); |
|
1448 delete mailBox; |
|
1449 mailBox = NULL; |
|
1450 } else { |
|
1451 User::Leave(NmNotFoundError); |
|
1452 } |
|
1453 CleanupStack::PopAndDestroy(2,&messages); |
|
1454 } |
|
1455 |
|
1456 /*! |
|
1457 Leaving version of getSignature |
|
1458 */ |
|
1459 void NmFrameworkAdapter::getSignatureL(const NmId &mailboxId, QString *&signature) |
|
1460 { |
|
1461 NM_FUNCTION; |
|
1462 |
|
1463 HBufC *sig = mFSfw->GetSignatureL(TFSMailMsgId(mailboxId)); |
|
1464 |
|
1465 if (sig) { |
|
1466 signature = new QString(NmConverter::toQString(*sig)); |
|
1467 } |
|
1468 } |
|
1469 |
|
1470 |
|
1471 /*! |
|
1472 Sends the given message. |
|
1473 */ |
|
1474 QPointer<NmMessageSendingOperation> NmFrameworkAdapter::sendMessage( |
|
1475 NmMessage *message) |
|
1476 { |
|
1477 NM_FUNCTION; |
|
1478 |
|
1479 QPointer<NmMessageSendingOperation>oper = new NmFwaMessageSendingOperation(*this, message, *mFSfw); |
|
1480 return oper; |
|
1481 } |
|
1482 |
|
1483 /*! |
|
1484 Add attachment into the given message. |
|
1485 */ |
|
1486 QPointer<NmAddAttachmentsOperation> NmFrameworkAdapter::addAttachments( |
|
1487 const NmMessage &message, |
|
1488 const QList<QString> &fileList) |
|
1489 { |
|
1490 NM_FUNCTION; |
|
1491 |
|
1492 QPointer<NmAddAttachmentsOperation>oper = new NmFwaAddAttachmentsOperation(message, fileList, *mFSfw); |
|
1493 return oper; |
|
1494 } |
|
1495 |
|
1496 /*! |
|
1497 Remove attachment from the given message. |
|
1498 */ |
|
1499 QPointer<NmOperation> NmFrameworkAdapter::removeAttachment( |
|
1500 const NmMessage &message, |
|
1501 const NmId &attachmentPartId) |
|
1502 { |
|
1503 NM_FUNCTION; |
|
1504 |
|
1505 QPointer<NmOperation> oper = new NmFwaRemoveAttachmentOperation(message, attachmentPartId, *mFSfw); |
|
1506 return oper; |
|
1507 } |
|
1508 |
|
1509 /*! |
|
1510 Returns the current sync state of the given mailbox |
|
1511 */ |
|
1512 NmSyncState NmFrameworkAdapter::syncState(const NmId& mailboxId) const |
|
1513 { |
|
1514 NM_FUNCTION; |
|
1515 |
|
1516 CFSMailBox* mailBox = NULL; |
|
1517 TRAPD(err, mailBox = mFSfw->GetMailBoxByUidL(TFSMailMsgId(mailboxId)) ); |
|
1518 if (KErrNone == err && mailBox) { |
|
1519 TSSMailSyncState syncState = mailBox->CurrentSyncState(); |
|
1520 delete mailBox; |
|
1521 mailBox = NULL; |
|
1522 if (EmailSyncing == syncState) { |
|
1523 return Synchronizing; |
|
1524 } |
|
1525 else { |
|
1526 return SyncComplete; |
|
1527 } |
|
1528 } |
|
1529 else { |
|
1530 return SyncComplete; |
|
1531 } |
|
1532 } |
|
1533 |
|
1534 /*! |
|
1535 Returns the current connection state of the given mailbox |
|
1536 */ |
|
1537 NmConnectState NmFrameworkAdapter::connectionState(const NmId& mailboxId) const |
|
1538 { |
|
1539 NM_FUNCTION; |
|
1540 |
|
1541 CFSMailBox* mailBox(NULL); |
|
1542 TRAPD(err, mailBox = mFSfw->GetMailBoxByUidL(TFSMailMsgId(mailboxId)) ); |
|
1543 if (KErrNone == err && mailBox) { |
|
1544 TFSMailBoxStatus status = mailBox->GetMailBoxStatus(); |
|
1545 delete mailBox; |
|
1546 mailBox = NULL; |
|
1547 if (status == EFSMailBoxOnline) { |
|
1548 return Connected; |
|
1549 } |
|
1550 else { |
|
1551 return Disconnected; |
|
1552 } |
|
1553 } |
|
1554 else { |
|
1555 return Disconnected; |
|
1556 } |
|
1557 } |
|
1558 |
|
1559 /*! |
|
1560 creates CFSMailMessage based on envelope |
|
1561 Call to this must be trapped |
|
1562 */ |
|
1563 CFSMailMessage* NmFrameworkAdapter::mailMessageFromEnvelopeL( |
|
1564 const NmMessageEnvelope& envelope) |
|
1565 { |
|
1566 NM_FUNCTION; |
|
1567 |
|
1568 NmMessage* nmMessage = new(ELeave) NmMessage( envelope ); |
|
1569 CFSMailMessage* message = CFSMailMessage::NewL( *nmMessage ); |
|
1570 delete nmMessage; |
|
1571 nmMessage = NULL; |
|
1572 return message; |
|
1573 } |
|
1574 |
|
1575 |
|
1576 /*! |
|
1577 Assigns recursively all children to NmMessagePart object. |
|
1578 */ |
|
1579 void NmFrameworkAdapter::childrenToNmMessagePartL( |
|
1580 CFSMailMessagePart *cfsParent, |
|
1581 NmMessagePart *nmParent) |
|
1582 { |
|
1583 NM_FUNCTION; |
|
1584 |
|
1585 User::LeaveIfNull(cfsParent); |
|
1586 User::LeaveIfNull(nmParent); |
|
1587 |
|
1588 RPointerArray<CFSMailMessagePart> parts; |
|
1589 cfsParent->ChildPartsL(parts); |
|
1590 CleanupResetAndDestroy<CFSMailMessagePart>::PushL(parts); |
|
1591 |
|
1592 NmMessagePart *nmPart = NULL; |
|
1593 if(parts.Count()){ |
|
1594 for(int i=0; i<parts.Count(); i++){ |
|
1595 nmPart = parts[i]->GetNmMessagePart(); |
|
1596 nmParent->addChildPart(nmPart); |
|
1597 childrenToNmMessagePartL(parts[i], nmPart); |
|
1598 } |
|
1599 } |
|
1600 CleanupStack::PopAndDestroy(1, &parts); |
|
1601 } |
|
1602 |
|
1603 /*! |
|
1604 Leaving Refresh function |
|
1605 */ |
|
1606 int NmFrameworkAdapter::RefreshMailboxL(NmId mailboxId) |
|
1607 { |
|
1608 NM_FUNCTION; |
|
1609 |
|
1610 int result(KErrNotFound); |
|
1611 CFSMailBox *currentMailbox(NULL); |
|
1612 currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId); |
|
1613 if(currentMailbox) { |
|
1614 CleanupStack::PushL(currentMailbox); |
|
1615 result = currentMailbox->RefreshNowL(); |
|
1616 CleanupStack::PopAndDestroy(currentMailbox); |
|
1617 } |
|
1618 return result; |
|
1619 } |
|
1620 |
|
1621 /*! |
|
1622 Leaving Go Online function |
|
1623 */ |
|
1624 int NmFrameworkAdapter::GoOnlineL(const NmId& mailboxId) |
|
1625 { |
|
1626 NM_FUNCTION; |
|
1627 |
|
1628 int result(KErrNotFound); |
|
1629 CFSMailBox *currentMailbox(NULL); |
|
1630 currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId); |
|
1631 if(currentMailbox) { |
|
1632 CleanupStack::PushL(currentMailbox); |
|
1633 currentMailbox->GoOnlineL(); |
|
1634 CleanupStack::PopAndDestroy(currentMailbox); |
|
1635 } |
|
1636 return result; |
|
1637 } |
|
1638 |
|
1639 /*! |
|
1640 Leaving Go Offline function |
|
1641 */ |
|
1642 int NmFrameworkAdapter::GoOfflineL(const NmId& mailboxId) |
|
1643 { |
|
1644 NM_FUNCTION; |
|
1645 |
|
1646 int result(KErrNotFound); |
|
1647 CFSMailBox *currentMailbox(NULL); |
|
1648 currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId); |
|
1649 if(currentMailbox) { |
|
1650 CleanupStack::PushL(currentMailbox); |
|
1651 currentMailbox->GoOfflineL(); |
|
1652 CleanupStack::PopAndDestroy(currentMailbox); |
|
1653 } |
|
1654 return result; |
|
1655 } |
|
1656 |
|
1657 /*! |
|
1658 handles mailbox related events |
|
1659 */ |
|
1660 void NmFrameworkAdapter::handleMailboxEvent(TFSMailMsgId mailbox, NmMailboxEvent event) |
|
1661 { |
|
1662 NM_FUNCTION; |
|
1663 |
|
1664 QList<NmId> mailboxIds; |
|
1665 NmId nmId = mailbox.GetNmId(); |
|
1666 mailboxIds.append(nmId); |
|
1667 emit mailboxEvent(event, mailboxIds); |
|
1668 } |
|
1669 |
|
1670 /*! |
|
1671 handles new, changed, deleted events |
|
1672 */ |
|
1673 void NmFrameworkAdapter::handleMessageEvent( |
|
1674 TAny* param1, |
|
1675 TAny* param2, |
|
1676 NmMessageEvent event, |
|
1677 TFSMailMsgId mailbox) |
|
1678 { |
|
1679 NM_FUNCTION; |
|
1680 |
|
1681 NmId nmMsgId(0); |
|
1682 QList<NmId> messageIds; |
|
1683 RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1); |
|
1684 TFSMailMsgId* fsFolderId = reinterpret_cast<TFSMailMsgId*> (param2); |
|
1685 NmId folderId = fsFolderId->GetNmId(); |
|
1686 |
|
1687 TFSMailMsgId fsMsgId; |
|
1688 for(TInt i = 0; i < newFsEntries->Count(); i++){ |
|
1689 fsMsgId = (*newFsEntries)[i]; |
|
1690 nmMsgId = fsMsgId.GetNmId(); |
|
1691 messageIds.append(nmMsgId); |
|
1692 } |
|
1693 emit messageEvent(event, folderId, messageIds, mailbox.GetNmId()); |
|
1694 } |
|
1695 |
|
1696 /*! |
|
1697 function to handle mailmoved event |
|
1698 */ |
|
1699 void NmFrameworkAdapter::handleMailMoved(TAny* param1,TAny* param2,TAny* param3, TFSMailMsgId mailbox) |
|
1700 { |
|
1701 NM_FUNCTION; |
|
1702 |
|
1703 NmId nmMsgId(0); |
|
1704 QList<NmId> messageIds; |
|
1705 RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1); |
|
1706 TFSMailMsgId* fsFromFolderId = reinterpret_cast<TFSMailMsgId*> (param3); |
|
1707 NmId fromFolderId = fsFromFolderId->GetNmId(); |
|
1708 TFSMailMsgId* fsToFolderId = reinterpret_cast<TFSMailMsgId*> (param2); |
|
1709 NmId toFolderId = fsToFolderId->GetNmId(); |
|
1710 |
|
1711 TFSMailMsgId fsMsgId; |
|
1712 for(TInt i = 0; i < newFsEntries->Count(); i++){ |
|
1713 fsMsgId = (*newFsEntries)[i]; |
|
1714 nmMsgId = fsMsgId.GetNmId(); |
|
1715 messageIds.append(nmMsgId); |
|
1716 } |
|
1717 // Yes, this is supposed to emit two signals from single incoming |
|
1718 // event. Design decison was to create separate signals. |
|
1719 emit messageEvent(NmMessageDeleted, fromFolderId, messageIds, mailbox.GetNmId()); |
|
1720 emit messageEvent(NmMessageCreated, toFolderId, messageIds, mailbox.GetNmId()); |
|
1721 } |
|
1722 |
|
1723 /*! |
|
1724 function to handle mailcopied event |
|
1725 */ |
|
1726 void NmFrameworkAdapter::handleMailCopied(TAny* param1,TAny* param2, TFSMailMsgId mailbox) |
|
1727 { |
|
1728 NM_FUNCTION; |
|
1729 |
|
1730 NmId nmMsgId(0); |
|
1731 QList<NmId> messageIds; |
|
1732 RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1); |
|
1733 TFSMailMsgId* fsToFolderId = reinterpret_cast<TFSMailMsgId*> (param2); |
|
1734 NmId toFolderId = fsToFolderId->GetNmId(); |
|
1735 |
|
1736 TFSMailMsgId fsMsgId; |
|
1737 for(TInt i = 0; i < newFsEntries->Count(); i++){ |
|
1738 fsMsgId = (*newFsEntries)[i]; |
|
1739 nmMsgId = fsMsgId.GetNmId(); |
|
1740 messageIds.append(nmMsgId); |
|
1741 } |
|
1742 // Not interested in param3 (aOldParentFolder) |
|
1743 emit messageEvent(NmMessageCreated, toFolderId, messageIds, mailbox.GetNmId()); |
|
1744 } |
|
1745 |
|
1746 void NmFrameworkAdapter::handleSyncstateEvent(TAny* param1, TFSMailMsgId mailbox) |
|
1747 { |
|
1748 NM_FUNCTION; |
|
1749 |
|
1750 TSSMailSyncState* state = static_cast<TSSMailSyncState*>( param1 ); |
|
1751 NmOperationCompletionEvent event; |
|
1752 event.mMailboxId = NmConverter::mailMsgIdToNmId(mailbox); |
|
1753 event.mOperationType = Synch; |
|
1754 |
|
1755 switch(*state) |
|
1756 { |
|
1757 case StartingSync: |
|
1758 { |
|
1759 event.mCompletionCode = NmNoError; |
|
1760 emit syncStateEvent(Synchronizing, event); |
|
1761 break; |
|
1762 } |
|
1763 case FinishedSuccessfully: |
|
1764 { |
|
1765 event.mCompletionCode = NmNoError; |
|
1766 emit syncStateEvent(SyncComplete, event); |
|
1767 break; |
|
1768 } |
|
1769 case PasswordNotVerified: |
|
1770 { |
|
1771 event.mCompletionCode = NmAuthenticationError; |
|
1772 emit syncStateEvent(SyncComplete, event); |
|
1773 break; |
|
1774 } |
|
1775 case SyncCancelled: |
|
1776 { |
|
1777 event.mCompletionCode = NmCancelError; |
|
1778 emit syncStateEvent(SyncComplete, event); |
|
1779 break; |
|
1780 } |
|
1781 case ServerConnectionError: |
|
1782 { |
|
1783 event.mCompletionCode = NmServerConnectionError; |
|
1784 emit syncStateEvent(SyncComplete, event); |
|
1785 break; |
|
1786 } |
|
1787 case SyncError: |
|
1788 { |
|
1789 event.mCompletionCode = NmConnectionError; |
|
1790 emit syncStateEvent(SyncComplete, event); |
|
1791 break; |
|
1792 } |
|
1793 default: |
|
1794 // ignore other statuses |
|
1795 break; |
|
1796 }; |
|
1797 } |
|
1798 Q_EXPORT_PLUGIN(NmFrameworkAdapter) |
|
1799 |