changeset 43 | 99bcbff212ad |
parent 40 | 2c62ef3caffd |
child 44 | c2d07d913565 |
42:139d4b7b2938 | 43:99bcbff212ad |
---|---|
25 */ |
25 */ |
26 |
26 |
27 NmUiEngine *NmUiEngine::mInstance; |
27 NmUiEngine *NmUiEngine::mInstance; |
28 int NmUiEngine::mReferenceCount; |
28 int NmUiEngine::mReferenceCount; |
29 |
29 |
30 const QString syncIndicatorName = "com.nokia.hb.nmsyncindicator/1.0"; |
|
31 |
|
30 /*! |
32 /*! |
31 Constructor |
33 Constructor |
32 */ |
34 */ |
33 NmUiEngine::NmUiEngine() |
35 NmUiEngine::NmUiEngine() |
34 : mMailboxListModel(NULL), |
36 : mMailboxListModel(NULL), |
37 mInboxListModel(NULL), |
|
35 mMessageListModel(NULL), |
38 mMessageListModel(NULL), |
36 mMessageSearchListModel(NULL), |
39 mMessageSearchListModel(NULL), |
37 mSendOperation(NULL) |
40 mSendOperation(NULL), |
38 { |
41 mRemoveDraftOperation(NULL), |
42 mSaveDraftOperation(NULL) |
|
43 { |
|
44 NM_FUNCTION; |
|
45 |
|
39 mPluginFactory = NmDataPluginFactory::instance(); |
46 mPluginFactory = NmDataPluginFactory::instance(); |
40 mDataManager = new NmDataManager(); |
47 mDataManager = new NmDataManager(); |
41 // Connect to the plugins to receive change notifications |
48 // Connect to the plugins to receive change notifications |
42 QList<QObject*> *dataPlugins = mPluginFactory->pluginInstances(); |
49 QList<QObject*> *dataPlugins = mPluginFactory->pluginInstances(); |
43 for (int i(0); i < dataPlugins->count(); i++) { |
50 for (int i(0); i < dataPlugins->count(); i++) { |
76 /*! |
83 /*! |
77 Destructor |
84 Destructor |
78 */ |
85 */ |
79 NmUiEngine::~NmUiEngine() |
86 NmUiEngine::~NmUiEngine() |
80 { |
87 { |
88 NM_FUNCTION; |
|
89 |
|
81 if (mMessageSearchListModel) { |
90 if (mMessageSearchListModel) { |
82 delete mMessageSearchListModel; |
91 delete mMessageSearchListModel; |
83 mMessageSearchListModel = NULL; |
92 mMessageSearchListModel = NULL; |
84 } |
93 } |
85 |
94 if (mInboxListModel) { |
95 delete mInboxListModel; |
|
96 mInboxListModel = NULL; |
|
97 } |
|
86 if (mMessageListModel) { |
98 if (mMessageListModel) { |
87 delete mMessageListModel; |
99 delete mMessageListModel; |
88 mMessageListModel = NULL; |
100 mMessageListModel = NULL; |
89 } |
101 } |
90 if (mMailboxListModel) { |
102 if (mMailboxListModel) { |
105 NmDataPluginFactory::releaseInstance(mPluginFactory); |
117 NmDataPluginFactory::releaseInstance(mPluginFactory); |
106 delete mDataManager; |
118 delete mDataManager; |
107 if (mSendOperation && mSendOperation->isRunning()) { |
119 if (mSendOperation && mSendOperation->isRunning()) { |
108 mSendOperation->cancelOperation(); |
120 mSendOperation->cancelOperation(); |
109 } |
121 } |
122 if(mRemoveDraftOperation && mRemoveDraftOperation->isRunning()) { |
|
123 mRemoveDraftOperation->cancelOperation(); |
|
124 } |
|
125 if(mSaveDraftOperation && mSaveDraftOperation->isRunning()) { |
|
126 mSaveDraftOperation->cancelOperation(); |
|
127 } |
|
110 } |
128 } |
111 |
129 |
112 /*! |
130 /*! |
113 |
131 |
114 */ |
132 */ |
115 NmUiEngine *NmUiEngine::instance() |
133 NmUiEngine *NmUiEngine::instance() |
116 { |
134 { |
135 NM_FUNCTION; |
|
136 |
|
117 if (!mInstance) { |
137 if (!mInstance) { |
118 mInstance = new NmUiEngine(); |
138 mInstance = new NmUiEngine(); |
119 } |
139 } |
120 mReferenceCount++; |
140 mReferenceCount++; |
121 return mInstance; |
141 return mInstance; |
124 /*! |
144 /*! |
125 |
145 |
126 */ |
146 */ |
127 void NmUiEngine::releaseInstance(NmUiEngine *&instance) |
147 void NmUiEngine::releaseInstance(NmUiEngine *&instance) |
128 { |
148 { |
149 NM_FUNCTION; |
|
150 |
|
129 //can't have passed out instances if we don't have any |
151 //can't have passed out instances if we don't have any |
130 if (mInstance) { |
152 if (mInstance) { |
131 if(instance == mInstance) { |
153 if(instance == mInstance) { |
132 instance = NULL; |
154 instance = NULL; |
133 mReferenceCount--; |
155 mReferenceCount--; |
143 Returns a list model populated with the mailbox and top level folder objects. The model is |
165 Returns a list model populated with the mailbox and top level folder objects. The model is |
144 updated dynamically. The ownership of the model object is not moved to the caller. |
166 updated dynamically. The ownership of the model object is not moved to the caller. |
145 */ |
167 */ |
146 NmMailboxListModel &NmUiEngine::mailboxListModel() |
168 NmMailboxListModel &NmUiEngine::mailboxListModel() |
147 { |
169 { |
170 NM_FUNCTION; |
|
171 |
|
148 if (!mMailboxListModel) { |
172 if (!mMailboxListModel) { |
149 refreshMailboxListModel(); // creates the model too |
173 refreshMailboxListModel(); // creates the model too |
150 } |
174 } |
151 |
175 |
152 return *mMailboxListModel; |
176 return *mMailboxListModel; |
156 Populate the list model with the mailbox and top level folder objects. The model is |
180 Populate the list model with the mailbox and top level folder objects. The model is |
157 updated dynamically. Creates the model if needed. |
181 updated dynamically. Creates the model if needed. |
158 */ |
182 */ |
159 void NmUiEngine::refreshMailboxListModel() |
183 void NmUiEngine::refreshMailboxListModel() |
160 { |
184 { |
185 NM_FUNCTION; |
|
186 |
|
161 if (!mMailboxListModel) { |
187 if (!mMailboxListModel) { |
162 mMailboxListModel = new NmMailboxListModel(*mDataManager); |
188 mMailboxListModel = new NmMailboxListModel(*mDataManager); |
163 |
189 |
164 // Connect the model to the plugins to receive change notifications |
190 // Connect the model to the plugins to receive change notifications |
165 QList<QObject*> *dataPlugins = mPluginFactory->pluginInstances(); |
191 QList<QObject*> *dataPlugins = mPluginFactory->pluginInstances(); |
189 object is not moved to the caller. |
215 object is not moved to the caller. |
190 */ |
216 */ |
191 NmMessageListModel &NmUiEngine::messageListModel(const NmId &mailboxId, |
217 NmMessageListModel &NmUiEngine::messageListModel(const NmId &mailboxId, |
192 const NmId &folderId) |
218 const NmId &folderId) |
193 { |
219 { |
194 if (!mMessageListModel) { |
220 NM_FUNCTION; |
195 mMessageListModel = new NmMessageListModel(*mDataManager); |
|
196 } |
|
197 else { |
|
198 mMessageListModel->clear(); |
|
199 } |
|
200 |
221 |
201 QObject *plugin = mPluginFactory->pluginInstance(mailboxId); |
222 QObject *plugin = mPluginFactory->pluginInstance(mailboxId); |
202 |
223 bool isInbox(false); |
203 if (plugin) { |
224 if (standardFolderId(mailboxId,NmFolderInbox)==folderId){ |
204 QObject::connect(plugin, |
225 isInbox=true; |
205 SIGNAL(messageEvent(NmMessageEvent, const NmId &, const QList<NmId> &, const NmId&)), |
226 } |
206 mMessageListModel, |
227 if (plugin) { |
207 SLOT(handleMessageEvent(NmMessageEvent, const NmId &, const QList<NmId> &)), |
228 // Connect plugin message events to handler slot messageEventForListModel |
208 Qt::UniqueConnection ); |
229 QObject::connect(plugin, SIGNAL(messageEvent(NmMessageEvent, const NmId &, |
209 |
230 const QList<NmId> &, const NmId&)), |
231 this, SLOT(messageEventForListModel(NmMessageEvent, |
|
232 const NmId &, const QList<NmId> &, const NmId&)), Qt::UniqueConnection ); |
|
233 // Create inbox list model only once when entering to inbox for the first time |
|
234 // or re-create inbox list model when mailbox has changed |
|
235 if ((!mInboxListModel&&isInbox)|| |
|
236 (mInboxListModel&&isInbox&&mailboxId!=mInboxListModel->currentMailboxId())){ |
|
237 // Delete previous model and set to NULL. Deleting model will also |
|
238 // delete all items in model. |
|
239 if (mInboxListModel){ |
|
240 delete mInboxListModel; |
|
241 mInboxListModel=NULL; |
|
242 } |
|
243 // Create new inbox model |
|
244 mInboxListModel = new NmMessageListModel(*mDataManager); |
|
245 // Initial fill up of inbox list model, otherwise updated in the background |
|
246 QList<NmMessageEnvelope*> messageEnvelopeList; |
|
247 mDataManager->listMessages(mailboxId, folderId, messageEnvelopeList); |
|
248 mInboxListModel->refresh(mailboxId, folderId, messageEnvelopeList); |
|
249 |
|
250 while (!messageEnvelopeList.isEmpty()) { |
|
251 delete messageEnvelopeList.takeFirst(); |
|
252 } |
|
253 } |
|
254 // Selected folder is not inbox folder for the mailbox |
|
255 else if (!isInbox){ |
|
256 // Recreate model for other folders when needed, previous model |
|
257 // items are deleted from the memory with the old model |
|
258 if (mMessageListModel){ |
|
259 delete mMessageListModel; |
|
260 mMessageListModel=NULL; |
|
261 } |
|
262 mMessageListModel = new NmMessageListModel(*mDataManager); |
|
263 |
|
264 // Fill up other model |
|
265 QList<NmMessageEnvelope*> messageEnvelopeList; |
|
266 mDataManager->listMessages(mailboxId, folderId, messageEnvelopeList); |
|
267 mMessageListModel->refresh(mailboxId, folderId, messageEnvelopeList); |
|
268 |
|
269 while (!messageEnvelopeList.isEmpty()) { |
|
270 delete messageEnvelopeList.takeFirst(); |
|
271 } |
|
272 } |
|
273 } |
|
274 |
|
275 // Connect sync state changed |
|
276 if (plugin){ |
|
210 QObject::connect( |
277 QObject::connect( |
211 plugin, SIGNAL(syncStateEvent(NmSyncState, const NmOperationCompletionEvent &)), |
278 plugin, SIGNAL(syncStateEvent(NmSyncState, const NmOperationCompletionEvent &)), |
212 this, SLOT(handleSyncStateEvent(NmSyncState, const NmOperationCompletionEvent &)), |
279 this, SLOT(handleSyncStateEvent(NmSyncState, const NmOperationCompletionEvent &)), |
213 Qt::UniqueConnection); |
280 Qt::UniqueConnection); |
214 |
281 } |
215 // No need for mailbox event subscription here, already done in |
282 NmMessageListModel* ret(NULL); |
216 // constructor. |
283 if (isInbox){ |
217 } |
284 ret = mInboxListModel; |
218 |
285 // Inbox list model is queried, other model is not |
219 QList<NmMessageEnvelope*> messageEnvelopeList; |
286 // needed anymore and memory should be freeded |
220 mDataManager->listMessages(mailboxId, folderId, messageEnvelopeList); |
287 if (mMessageListModel){ |
221 mMessageListModel->refresh(mailboxId, folderId, messageEnvelopeList); |
288 delete mMessageListModel; |
222 |
289 mMessageListModel=NULL; |
223 while (!messageEnvelopeList.isEmpty()) { |
290 } |
224 delete messageEnvelopeList.takeFirst(); |
291 } |
225 } |
292 else { |
226 |
293 ret = mMessageListModel; |
227 return *mMessageListModel; |
294 } |
295 return *ret; |
|
228 } |
296 } |
229 |
297 |
230 |
298 |
231 /*! |
299 /*! |
232 Returns a message list model used in the search view. |
300 Returns a message list model used in the search view. |
235 |
303 |
236 \return A message list model. |
304 \return A message list model. |
237 */ |
305 */ |
238 NmMessageListModel &NmUiEngine::messageListModelForSearch(const NmId &mailboxId) |
306 NmMessageListModel &NmUiEngine::messageListModelForSearch(const NmId &mailboxId) |
239 { |
307 { |
308 NM_FUNCTION; |
|
309 |
|
240 Q_UNUSED(mailboxId); |
310 Q_UNUSED(mailboxId); |
241 |
311 |
242 if (!mMessageSearchListModel) { |
312 if (!mMessageSearchListModel) { |
243 mMessageSearchListModel = new NmMessageListModel(*mDataManager); |
313 mMessageSearchListModel = new NmMessageListModel(*mDataManager); |
244 mMessageSearchListModel->setIgnoreFolderIds(true); |
314 mMessageSearchListModel->setIgnoreFolderIds(true); |
249 |
319 |
250 QObject *plugin = mPluginFactory->pluginInstance(mailboxId); |
320 QObject *plugin = mPluginFactory->pluginInstance(mailboxId); |
251 |
321 |
252 if (plugin) { |
322 if (plugin) { |
253 QObject::connect(plugin, |
323 QObject::connect(plugin, |
254 SIGNAL(messageEvent(NmMessageEvent, const NmId &, const QList<NmId> &, const NmId&)), |
324 SIGNAL(messageEvent(NmMessageEvent, const NmId &, const QList<NmId> &, const NmId &)), |
255 mMessageSearchListModel, |
325 mMessageSearchListModel, |
256 SLOT(handleMessageEvent(NmMessageEvent, const NmId &, const QList<NmId> &)), |
326 SLOT(handleMessageEvent(NmMessageEvent, const NmId &, const QList<NmId> &, const NmId &)), |
257 Qt::UniqueConnection); |
327 Qt::UniqueConnection); |
258 } |
328 } |
259 |
329 |
260 // Refresh to set the mailbox ID. |
330 // Refresh to set the mailbox ID. |
261 QList<NmMessageEnvelope*> messageEnvelopeList; |
331 QList<NmMessageEnvelope*> messageEnvelopeList; |
271 */ |
341 */ |
272 NmId NmUiEngine::standardFolderId( |
342 NmId NmUiEngine::standardFolderId( |
273 const NmId &mailboxId, |
343 const NmId &mailboxId, |
274 NmFolderType folderType) |
344 NmFolderType folderType) |
275 { |
345 { |
346 NM_FUNCTION; |
|
347 |
|
276 NmId value; |
348 NmId value; |
277 if (folderType != NmFolderOther) { |
349 if (folderType != NmFolderOther) { |
278 NmDataPluginInterface *plugin = |
350 NmDataPluginInterface *plugin = |
279 mPluginFactory->interfaceInstance(mailboxId); |
351 mPluginFactory->interfaceInstance(mailboxId); |
280 if(plugin) { |
352 if(plugin) { |
291 */ |
363 */ |
292 NmMessage *NmUiEngine::message(const NmId &mailboxId, |
364 NmMessage *NmUiEngine::message(const NmId &mailboxId, |
293 const NmId &folderId, |
365 const NmId &folderId, |
294 const NmId &messageId) |
366 const NmId &messageId) |
295 { |
367 { |
368 NM_FUNCTION; |
|
369 |
|
296 NmMessage *message = mDataManager->message(mailboxId, folderId, messageId); |
370 NmMessage *message = mDataManager->message(mailboxId, folderId, messageId); |
297 return message; |
371 return message; |
298 } |
372 } |
299 |
373 |
300 /*! |
374 /*! |
302 */ |
376 */ |
303 QPointer<NmOperation> NmUiEngine::fetchMessage( const NmId &mailboxId, |
377 QPointer<NmOperation> NmUiEngine::fetchMessage( const NmId &mailboxId, |
304 const NmId &folderId, |
378 const NmId &folderId, |
305 const NmId &messageId ) |
379 const NmId &messageId ) |
306 { |
380 { |
307 NMLOG("NmUiEngine::fetchMessage() <---"); |
381 NM_FUNCTION; |
382 |
|
308 QPointer<NmOperation> value(NULL); |
383 QPointer<NmOperation> value(NULL); |
309 NmDataPluginInterface *plugin = |
384 NmDataPluginInterface *plugin = |
310 mPluginFactory->interfaceInstance(mailboxId); |
385 mPluginFactory->interfaceInstance(mailboxId); |
311 if (plugin) { |
386 if (plugin) { |
312 value = plugin->fetchMessage(mailboxId, folderId, messageId); |
387 value = plugin->fetchMessage(mailboxId, folderId, messageId); |
321 const NmId &mailboxId, |
396 const NmId &mailboxId, |
322 const NmId &folderId, |
397 const NmId &folderId, |
323 const NmId &messageId, |
398 const NmId &messageId, |
324 const NmId &messagePartId) |
399 const NmId &messagePartId) |
325 { |
400 { |
326 NMLOG("NmUiEngine::fetchMessagePart() <---"); |
401 NM_FUNCTION; |
402 |
|
327 QPointer<NmOperation> value(NULL); |
403 QPointer<NmOperation> value(NULL); |
328 NmDataPluginInterface *plugin = |
404 NmDataPluginInterface *plugin = |
329 mPluginFactory->interfaceInstance(mailboxId); |
405 mPluginFactory->interfaceInstance(mailboxId); |
330 if (plugin) { |
406 if (plugin) { |
331 value = plugin->fetchMessagePart(mailboxId, folderId, messageId, messagePartId); |
407 value = plugin->fetchMessagePart(mailboxId, folderId, messageId, messagePartId); |
340 const NmId &mailboxId, |
416 const NmId &mailboxId, |
341 const NmId &folderId, |
417 const NmId &folderId, |
342 const NmId &messageId, |
418 const NmId &messageId, |
343 const QList<NmId> &messagePartIds) |
419 const QList<NmId> &messagePartIds) |
344 { |
420 { |
345 NMLOG("NmUiEngine::fetchMessageParts() <---"); |
421 NM_FUNCTION; |
422 |
|
346 QPointer<NmOperation> value(NULL); |
423 QPointer<NmOperation> value(NULL); |
347 NmDataPluginInterface *plugin = |
424 NmDataPluginInterface *plugin = |
348 mPluginFactory->interfaceInstance(mailboxId); |
425 mPluginFactory->interfaceInstance(mailboxId); |
349 if (plugin) { |
426 if (plugin) { |
350 value = plugin->fetchMessageParts(mailboxId, folderId, messageId, messagePartIds); |
427 value = plugin->fetchMessageParts(mailboxId, folderId, messageId, messagePartIds); |
359 const NmId &mailboxId, |
436 const NmId &mailboxId, |
360 const NmId &folderId, |
437 const NmId &folderId, |
361 const NmId &messageId, |
438 const NmId &messageId, |
362 const NmId &messagePartId) |
439 const NmId &messagePartId) |
363 { |
440 { |
441 NM_FUNCTION; |
|
442 |
|
364 NmDataPluginInterface *plugin = |
443 NmDataPluginInterface *plugin = |
365 mPluginFactory->interfaceInstance(mailboxId); |
444 mPluginFactory->interfaceInstance(mailboxId); |
366 if (plugin) { |
445 if (plugin) { |
367 return plugin->messagePartFile(mailboxId, folderId, messageId, messagePartId); |
446 return plugin->messagePartFile(mailboxId, folderId, messageId, messagePartId); |
368 } |
447 } |
378 const NmId &mailboxId, |
457 const NmId &mailboxId, |
379 const NmId &folderId, |
458 const NmId &folderId, |
380 const NmId &messageId, |
459 const NmId &messageId, |
381 NmMessagePart &messagePart) |
460 NmMessagePart &messagePart) |
382 { |
461 { |
462 NM_FUNCTION; |
|
463 |
|
383 return mDataManager->contentToMessagePart(mailboxId, folderId, messageId, messagePart); |
464 return mDataManager->contentToMessagePart(mailboxId, folderId, messageId, messagePart); |
384 } |
465 } |
385 |
466 |
386 /*! |
467 |
387 Deletes messages from model and routes call to plugin |
468 /*! |
388 */ |
469 Deletes messages from the model and forwards the call to plugin. |
389 int NmUiEngine::deleteMessages( |
470 |
390 const NmId &mailboxId, |
471 \param mailboxId The ID of the mailbox which contains the deleted message(s). |
391 const NmId &folderId, |
472 \param folderId The ID of the folder which contains the deleted message(s). |
392 const QList<NmId> &messageIdList) |
473 \param messageIdList A list containing the IDs of the message to be deleted. |
393 { |
474 |
475 \return A possible error code (returned by the plugin). |
|
476 */ |
|
477 int NmUiEngine::deleteMessages(const NmId &mailboxId, |
|
478 const NmId &folderId, |
|
479 const QList<NmId> &messageIdList) |
|
480 { |
|
481 NM_FUNCTION; |
|
482 |
|
394 int result(NmNotFoundError); |
483 int result(NmNotFoundError); |
395 if (mMessageListModel) { |
484 |
396 mMessageListModel->handleMessageEvent(NmMessageDeleted, folderId, messageIdList); |
485 bool isInbox(false); |
486 if (standardFolderId(mailboxId,NmFolderInbox)==folderId){ |
|
487 isInbox=true; |
|
488 } |
|
489 if (isInbox&&mInboxListModel){ |
|
490 mInboxListModel->handleMessageEvent(NmMessageDeleted, folderId, |
|
491 messageIdList, mailboxId); |
|
492 } |
|
493 else if (mMessageListModel) { |
|
494 mMessageListModel->handleMessageEvent(NmMessageDeleted, folderId, |
|
495 messageIdList, mailboxId); |
|
397 } |
496 } |
398 NmDataPluginInterface *plugin = |
497 |
399 mPluginFactory->interfaceInstance(mailboxId); |
498 // If the search list model exists and contains message, remove the |
400 if (plugin) { |
499 // message from it too. |
401 result = plugin->deleteMessages( |
500 if (mMessageSearchListModel && mMessageSearchListModel->rowCount()) { |
402 mailboxId, folderId, messageIdList); |
501 mMessageSearchListModel->handleMessageEvent(NmMessageDeleted, folderId, |
403 } |
502 messageIdList, mailboxId); |
503 } |
|
504 |
|
505 NmDataPluginInterface *plugin = |
|
506 mPluginFactory->interfaceInstance(mailboxId); |
|
507 |
|
508 if (plugin) { |
|
509 result = plugin->deleteMessages(mailboxId, folderId, messageIdList); |
|
510 } |
|
511 |
|
404 return result; |
512 return result; |
405 } |
513 } |
406 |
514 |
407 /*! |
515 |
408 Sets envelope property given in argument. |
516 /*! |
409 Operation is automatically deleted after completion or cancelling. |
517 Sets the envelope property for the given envelopes. |
518 The operation is automatically deleted after the completion or cancelling. |
|
519 |
|
520 \param mailboxId The ID of the mailbox containing the envelope(s). |
|
521 \param folderId The ID of the folder containing the envelope(s). |
|
522 \param property The property to set. |
|
523 \param envelopeList The list containing the envelopes. |
|
524 |
|
525 \return The constructed operation. |
|
410 */ |
526 */ |
411 QPointer<NmStoreEnvelopesOperation> NmUiEngine::setEnvelopes( |
527 QPointer<NmStoreEnvelopesOperation> NmUiEngine::setEnvelopes( |
412 const NmId &mailboxId, |
528 const NmId &mailboxId, |
413 const NmId &folderId, |
529 const NmId &folderId, |
414 NmEnvelopeProperties property, |
530 NmEnvelopeProperties property, |
415 const QList<const NmMessageEnvelope*> &envelopeList) |
531 const QList<const NmMessageEnvelope*> &envelopeList) |
416 { |
532 { |
417 NMLOG("NmUiEngine::setEnvelopes() <---"); |
533 NM_FUNCTION; |
534 |
|
418 QPointer<NmStoreEnvelopesOperation> operation(NULL); |
535 QPointer<NmStoreEnvelopesOperation> operation(NULL); |
419 if (mMessageListModel && envelopeList.count()) { |
536 NmMessageListModel *theMessageListModel = mMessageListModel; |
537 |
|
538 if (!theMessageListModel) { |
|
539 theMessageListModel = &messageListModel(mailboxId, folderId); |
|
540 } |
|
541 |
|
542 if (theMessageListModel && envelopeList.count()) { |
|
420 QList<NmId> messageIdList; |
543 QList<NmId> messageIdList; |
421 |
544 |
422 for (int i(0); i < envelopeList.count(); i++){ |
545 for (int i(0); i < envelopeList.count(); i++){ |
423 messageIdList.append(envelopeList[i]->messageId()); |
546 messageIdList.append(envelopeList[i]->messageId()); |
424 } |
547 } |
425 mMessageListModel->setEnvelopeProperties( |
548 |
426 property, messageIdList); |
549 theMessageListModel->setEnvelopeProperties(property, messageIdList); |
427 // Store new envelopes to plugin |
550 |
551 if (mMessageSearchListModel && mMessageSearchListModel->rowCount()) { |
|
552 // Update the envelopes in the search list model as well. |
|
553 mMessageSearchListModel->setEnvelopeProperties(property, |
|
554 messageIdList); |
|
555 } |
|
556 |
|
557 // Store the new envelopes to plugin. |
|
428 NmDataPluginInterface *plugin = |
558 NmDataPluginInterface *plugin = |
429 mPluginFactory->interfaceInstance(mailboxId); |
559 mPluginFactory->interfaceInstance(mailboxId); |
560 |
|
430 if (plugin) { |
561 if (plugin) { |
431 operation = plugin->storeEnvelopes( |
562 operation = |
432 mailboxId, folderId, envelopeList); |
563 plugin->storeEnvelopes(mailboxId, folderId, envelopeList); |
433 } |
564 } |
565 |
|
434 messageIdList.clear(); |
566 messageIdList.clear(); |
435 } |
567 } |
436 NMLOG("NmUiEngine::setEnvelopes() --->"); |
568 |
437 return operation; |
569 return operation; |
438 } |
570 } |
439 |
571 |
440 |
572 |
441 /*! |
573 /*! |
465 Creates a new message (into Drafts-folder). |
597 Creates a new message (into Drafts-folder). |
466 Operation is automatically deleted after completion or cancelling. |
598 Operation is automatically deleted after completion or cancelling. |
467 */ |
599 */ |
468 QPointer<NmMessageCreationOperation> NmUiEngine::createNewMessage(const NmId &mailboxId) |
600 QPointer<NmMessageCreationOperation> NmUiEngine::createNewMessage(const NmId &mailboxId) |
469 { |
601 { |
470 NMLOG("NmUiEngine::createNewMessage() <---"); |
602 NM_FUNCTION; |
603 |
|
471 QPointer<NmMessageCreationOperation> value(NULL); |
604 QPointer<NmMessageCreationOperation> value(NULL); |
472 NmDataPluginInterface *plugin = |
605 NmDataPluginInterface *plugin = |
473 mPluginFactory->interfaceInstance(mailboxId); |
606 mPluginFactory->interfaceInstance(mailboxId); |
474 if (plugin) { |
607 if (plugin) { |
475 value = plugin->createNewMessage(mailboxId); |
608 value = plugin->createNewMessage(mailboxId); |
483 */ |
616 */ |
484 QPointer<NmMessageCreationOperation> NmUiEngine::createForwardMessage( |
617 QPointer<NmMessageCreationOperation> NmUiEngine::createForwardMessage( |
485 const NmId &mailboxId, |
618 const NmId &mailboxId, |
486 const NmId &originalMessageId) |
619 const NmId &originalMessageId) |
487 { |
620 { |
488 NMLOG("NmUiEngine::createForwardMessage() <---"); |
621 NM_FUNCTION; |
622 |
|
489 QPointer<NmMessageCreationOperation> value(NULL); |
623 QPointer<NmMessageCreationOperation> value(NULL); |
490 NmDataPluginInterface *plugin = |
624 NmDataPluginInterface *plugin = |
491 mPluginFactory->interfaceInstance(mailboxId); |
625 mPluginFactory->interfaceInstance(mailboxId); |
492 if (plugin) { |
626 if (plugin) { |
493 value = plugin->createForwardMessage(mailboxId, originalMessageId); |
627 value = plugin->createForwardMessage(mailboxId, originalMessageId); |
502 QPointer<NmMessageCreationOperation> NmUiEngine::createReplyMessage( |
636 QPointer<NmMessageCreationOperation> NmUiEngine::createReplyMessage( |
503 const NmId &mailboxId, |
637 const NmId &mailboxId, |
504 const NmId &originalMessageId, |
638 const NmId &originalMessageId, |
505 bool replyAll) |
639 bool replyAll) |
506 { |
640 { |
507 NMLOG("NmUiEngine::createReplyMessage() <---"); |
641 NM_FUNCTION; |
642 |
|
508 QPointer<NmMessageCreationOperation> value(NULL); |
643 QPointer<NmMessageCreationOperation> value(NULL); |
509 NmDataPluginInterface *plugin = |
644 NmDataPluginInterface *plugin = |
510 mPluginFactory->interfaceInstance(mailboxId); |
645 mPluginFactory->interfaceInstance(mailboxId); |
511 if (plugin) { |
646 if (plugin) { |
512 value = plugin->createReplyMessage(mailboxId, originalMessageId, replyAll); |
647 value = plugin->createReplyMessage(mailboxId, originalMessageId, replyAll); |
517 /*! |
652 /*! |
518 Saves a message (into message store). |
653 Saves a message (into message store). |
519 */ |
654 */ |
520 int NmUiEngine::saveMessage(const NmMessage &message) |
655 int NmUiEngine::saveMessage(const NmMessage &message) |
521 { |
656 { |
657 NM_FUNCTION; |
|
658 |
|
522 const NmId &mailboxId = message.envelope().mailboxId(); |
659 const NmId &mailboxId = message.envelope().mailboxId(); |
523 int ret(NmNotFoundError); |
660 int ret(NmNotFoundError); |
524 NmDataPluginInterface *plugin = |
661 NmDataPluginInterface *plugin = |
525 mPluginFactory->interfaceInstance(mailboxId); |
662 mPluginFactory->interfaceInstance(mailboxId); |
526 if (plugin) { |
663 if (plugin) { |
532 /*! |
669 /*! |
533 Refreshes mailbox. |
670 Refreshes mailbox. |
534 */ |
671 */ |
535 int NmUiEngine::refreshMailbox(const NmId &mailboxId ) |
672 int NmUiEngine::refreshMailbox(const NmId &mailboxId ) |
536 { |
673 { |
674 NM_FUNCTION; |
|
675 |
|
537 int ret(NmNotFoundError); |
676 int ret(NmNotFoundError); |
538 NmDataPluginInterface *plugin = |
677 NmDataPluginInterface *plugin = |
539 mPluginFactory->interfaceInstance(mailboxId); |
678 mPluginFactory->interfaceInstance(mailboxId); |
540 if (plugin) { |
679 if (plugin) { |
541 ret = plugin->refreshMailbox(mailboxId); |
680 ret = plugin->refreshMailbox(mailboxId); |
681 if (NmNoError == ret) { |
|
682 HbIndicator indicator; |
|
683 indicator.activate(syncIndicatorName, QVariant()); |
|
684 } |
|
542 } |
685 } |
543 return ret; |
686 return ret; |
544 } |
687 } |
545 |
688 |
546 /*! |
689 /*! |
547 Online mailbox. |
690 Online mailbox. |
548 */ |
691 */ |
549 int NmUiEngine::goOnline(const NmId &mailboxId ) |
692 int NmUiEngine::goOnline(const NmId &mailboxId ) |
550 { |
693 { |
694 NM_FUNCTION; |
|
695 |
|
551 int ret(NmNotFoundError); |
696 int ret(NmNotFoundError); |
552 NmDataPluginInterface *plugin = |
697 NmDataPluginInterface *plugin = |
553 mPluginFactory->interfaceInstance(mailboxId); |
698 mPluginFactory->interfaceInstance(mailboxId); |
554 if (plugin) { |
699 if (plugin) { |
555 ret = plugin->goOnline(mailboxId); |
700 ret = plugin->goOnline(mailboxId); |
560 /*! |
705 /*! |
561 Offline mailbox. |
706 Offline mailbox. |
562 */ |
707 */ |
563 int NmUiEngine::goOffline(const NmId &mailboxId ) |
708 int NmUiEngine::goOffline(const NmId &mailboxId ) |
564 { |
709 { |
710 NM_FUNCTION; |
|
711 |
|
565 int ret(NmNotFoundError); |
712 int ret(NmNotFoundError); |
566 NmDataPluginInterface *plugin = |
713 NmDataPluginInterface *plugin = |
567 mPluginFactory->interfaceInstance(mailboxId); |
714 mPluginFactory->interfaceInstance(mailboxId); |
568 if (plugin) { |
715 if (plugin) { |
569 ret = plugin->goOffline(mailboxId); |
716 ret = plugin->goOffline(mailboxId); |
578 int NmUiEngine::removeMessage( |
725 int NmUiEngine::removeMessage( |
579 const NmId &mailboxId, |
726 const NmId &mailboxId, |
580 const NmId &folderId, |
727 const NmId &folderId, |
581 const NmId &messageId) |
728 const NmId &messageId) |
582 { |
729 { |
730 NM_FUNCTION; |
|
731 |
|
583 int result(NmNotFoundError); |
732 int result(NmNotFoundError); |
584 NmDataPluginInterface *plugin = |
733 NmDataPluginInterface *plugin = |
585 mPluginFactory->interfaceInstance(mailboxId); |
734 mPluginFactory->interfaceInstance(mailboxId); |
586 if (plugin) { |
735 if (plugin) { |
587 result = plugin->removeMessage(mailboxId, folderId, messageId); |
736 result = plugin->removeMessage(mailboxId, folderId, messageId); |
588 } |
737 } |
589 return result; |
738 return result; |
590 } |
739 } |
591 |
740 |
741 |
|
742 /*! |
|
743 Handles draft message deletion after editor has closed, takes ownership of message. |
|
744 */ |
|
745 void NmUiEngine::removeDraftMessage(NmMessage *message) |
|
746 { |
|
747 NM_FUNCTION; |
|
748 |
|
749 if (message) { |
|
750 NmDataPluginInterface *plugin = |
|
751 mPluginFactory->interfaceInstance(message->envelope().mailboxId()); |
|
752 |
|
753 if (plugin) { |
|
754 // to be on the safer side: |
|
755 // we shouldn't even be here if mRemoveDraftOperation != NULL |
|
756 if (mRemoveDraftOperation && mRemoveDraftOperation->isRunning()) { |
|
757 mRemoveDraftOperation->cancelOperation(); |
|
758 } |
|
759 // ownership of message changes |
|
760 mRemoveDraftOperation = plugin->removeDraftMessage(message); |
|
761 |
|
762 if (mRemoveDraftOperation) { |
|
763 connect(mRemoveDraftOperation, |
|
764 SIGNAL(operationCompleted(int)), |
|
765 this, |
|
766 SLOT(handleCompletedRemoveDraftOperation())); |
|
767 } |
|
768 } |
|
769 } |
|
770 } |
|
771 |
|
772 /*! |
|
773 Handles draft message saving after editor has closed, takes ownership of message. |
|
774 */ |
|
775 void NmUiEngine::saveDraftMessage(NmMessage *message, |
|
776 const QList<NmOperation*> &preliminaryOperations) |
|
777 { |
|
778 NM_FUNCTION; |
|
779 |
|
780 if (message) { |
|
781 NmDataPluginInterface *plugin = |
|
782 mPluginFactory->interfaceInstance(message->envelope().mailboxId()); |
|
783 |
|
784 if (plugin) { |
|
785 // to be on the safer side: |
|
786 // we shouldn't even be here if mSaveDraftOperation != NULL |
|
787 if (mSaveDraftOperation && mSaveDraftOperation->isRunning()) { |
|
788 mSaveDraftOperation->cancelOperation(); |
|
789 } |
|
790 // ownership of message changes |
|
791 mSaveDraftOperation = plugin->saveMessageWithSubparts(*message); |
|
792 // don't put this to mOperations as we need to handle this |
|
793 // operation separately |
|
794 if (mSaveDraftOperation) { |
|
795 for (int i(0); i < preliminaryOperations.count(); i++ ) { |
|
796 QPointer<NmOperation> op = preliminaryOperations[i]; |
|
797 mSaveDraftOperation->addPreliminaryOperation(op); |
|
798 } |
|
799 |
|
800 connect(mSaveDraftOperation, |
|
801 SIGNAL(operationCompleted(int)), |
|
802 this, |
|
803 SLOT(handleCompletedSaveDraftOperation())); |
|
804 |
|
805 // message object is not needed any more, so delete it |
|
806 delete message; |
|
807 message = NULL; |
|
808 } |
|
809 } |
|
810 } |
|
811 } |
|
592 |
812 |
593 /*! |
813 /*! |
594 Sends the given message. |
814 Sends the given message. |
595 */ |
815 */ |
596 void NmUiEngine::sendMessage(NmMessage *message, const QList<NmOperation *> &preliminaryOperations) |
816 void NmUiEngine::sendMessage(NmMessage *message, const QList<NmOperation *> &preliminaryOperations) |
597 { |
817 { |
818 NM_FUNCTION; |
|
819 |
|
598 //First trigger message storing |
820 //First trigger message storing |
599 if (message) { |
821 if (message) { |
600 NmDataPluginInterface *plugin = |
822 NmDataPluginInterface *plugin = |
601 mPluginFactory->interfaceInstance(message->envelope().mailboxId()); |
823 mPluginFactory->interfaceInstance(message->envelope().mailboxId()); |
602 |
824 |
628 /*! |
850 /*! |
629 Is sending operation in progress. |
851 Is sending operation in progress. |
630 */ |
852 */ |
631 bool NmUiEngine::isSendingMessage() const |
853 bool NmUiEngine::isSendingMessage() const |
632 { |
854 { |
855 NM_FUNCTION; |
|
856 |
|
633 int ret(false); |
857 int ret(false); |
634 if (mSendOperation && mSendOperation->isRunning()) { |
858 if (mSendOperation && mSendOperation->isRunning()) { |
635 ret = true; |
859 ret = true; |
636 } |
860 } |
637 return ret; |
861 return ret; |
640 /*! |
864 /*! |
641 Returns a pointer to the message that is being sent. Returns NULL if not sending. |
865 Returns a pointer to the message that is being sent. Returns NULL if not sending. |
642 */ |
866 */ |
643 const NmMessage *NmUiEngine::messageBeingSent() const |
867 const NmMessage *NmUiEngine::messageBeingSent() const |
644 { |
868 { |
869 NM_FUNCTION; |
|
870 |
|
645 const NmMessage *message = NULL; |
871 const NmMessage *message = NULL; |
646 |
872 |
647 if (mSendOperation != NULL) { |
873 if (mSendOperation != NULL) { |
648 message = mSendOperation->getMessage(); |
874 message = mSendOperation->getMessage(); |
649 } |
875 } |
657 */ |
883 */ |
658 QPointer<NmAddAttachmentsOperation> NmUiEngine::addAttachments( |
884 QPointer<NmAddAttachmentsOperation> NmUiEngine::addAttachments( |
659 const NmMessage &message, |
885 const NmMessage &message, |
660 const QList<QString> &fileList) |
886 const QList<QString> &fileList) |
661 { |
887 { |
662 NMLOG("NmUiEngine::addAttachments() <---"); |
888 NM_FUNCTION; |
889 |
|
663 NmDataPluginInterface *plugin = |
890 NmDataPluginInterface *plugin = |
664 mPluginFactory->interfaceInstance(message.envelope().mailboxId()); |
891 mPluginFactory->interfaceInstance(message.envelope().mailboxId()); |
665 |
892 |
666 QPointer<NmAddAttachmentsOperation> ret(NULL); |
893 QPointer<NmAddAttachmentsOperation> ret(NULL); |
667 if (plugin) { |
894 if (plugin) { |
676 */ |
903 */ |
677 QPointer<NmOperation> NmUiEngine::removeAttachment( |
904 QPointer<NmOperation> NmUiEngine::removeAttachment( |
678 const NmMessage &message, |
905 const NmMessage &message, |
679 const NmId &attachmentPartId) |
906 const NmId &attachmentPartId) |
680 { |
907 { |
681 NMLOG("NmUiEngine::removeAttachments() <---"); |
908 NM_FUNCTION; |
909 |
|
682 NmDataPluginInterface *plugin = |
910 NmDataPluginInterface *plugin = |
683 mPluginFactory->interfaceInstance(message.envelope().mailboxId()); |
911 mPluginFactory->interfaceInstance(message.envelope().mailboxId()); |
684 |
912 |
685 QPointer<NmOperation> ret(NULL); |
913 QPointer<NmOperation> ret(NULL); |
686 if (plugin) { |
914 if (plugin) { |
687 ret = plugin->removeAttachment(message, attachmentPartId); |
915 ret = plugin->removeAttachment(message, attachmentPartId); |
688 } |
916 } |
689 return ret; |
|
690 } |
|
691 |
|
692 /*! |
|
693 Operation is automatically deleted after completion or cancelling. |
|
694 */ |
|
695 QPointer<NmCheckOutboxOperation> NmUiEngine::checkOutbox(const NmId &mailboxId) |
|
696 { |
|
697 NMLOG("NmUiEngine::checkOutbox() <---"); |
|
698 NmDataPluginInterface *plugin = |
|
699 mPluginFactory->interfaceInstance(mailboxId); |
|
700 |
|
701 QPointer<NmCheckOutboxOperation> ret(NULL); |
|
702 if (plugin) { |
|
703 ret = plugin->checkOutbox(mailboxId); |
|
704 } |
|
705 return ret; |
917 return ret; |
706 } |
918 } |
707 |
919 |
708 /*! |
920 /*! |
709 Returns the current sync state of the mailbox |
921 Returns the current sync state of the mailbox |
710 */ |
922 */ |
711 NmSyncState NmUiEngine::syncState(const NmId& mailboxId) |
923 NmSyncState NmUiEngine::syncState(const NmId& mailboxId) |
712 { |
924 { |
925 NM_FUNCTION; |
|
926 |
|
713 NmDataPluginInterface *plugin = |
927 NmDataPluginInterface *plugin = |
714 mPluginFactory->interfaceInstance(mailboxId); |
928 mPluginFactory->interfaceInstance(mailboxId); |
715 if (plugin) { |
929 if (plugin) { |
716 return plugin->syncState(mailboxId); |
930 return plugin->syncState(mailboxId); |
717 } |
931 } |
723 /*! |
937 /*! |
724 Returns the current connection state of the mailbox |
938 Returns the current connection state of the mailbox |
725 */ |
939 */ |
726 NmConnectState NmUiEngine::connectionState(const NmId& mailboxId) |
940 NmConnectState NmUiEngine::connectionState(const NmId& mailboxId) |
727 { |
941 { |
942 NM_FUNCTION; |
|
943 |
|
728 NmDataPluginInterface *plugin = |
944 NmDataPluginInterface *plugin = |
729 mPluginFactory->interfaceInstance(mailboxId); |
945 mPluginFactory->interfaceInstance(mailboxId); |
730 if (plugin) { |
946 if (plugin) { |
731 return plugin->connectionState(mailboxId); |
947 return plugin->connectionState(mailboxId); |
732 } |
948 } |
745 \return A possible error code. |
961 \return A possible error code. |
746 */ |
962 */ |
747 int NmUiEngine::search(const NmId &mailboxId, |
963 int NmUiEngine::search(const NmId &mailboxId, |
748 const QStringList &searchStrings) |
964 const QStringList &searchStrings) |
749 { |
965 { |
966 NM_FUNCTION; |
|
967 |
|
750 // Get the plugin instance. |
968 // Get the plugin instance. |
751 QObject *pluginInstance = mPluginFactory->pluginInstance(mailboxId); |
969 QObject *pluginInstance = mPluginFactory->pluginInstance(mailboxId); |
752 |
970 |
753 if (pluginInstance) { |
971 if (pluginInstance) { |
754 // Make sure the required signals are connected. |
972 // Make sure the required signals are connected. |
787 |
1005 |
788 \return A possible error code. |
1006 \return A possible error code. |
789 */ |
1007 */ |
790 int NmUiEngine::cancelSearch(const NmId &mailboxId) |
1008 int NmUiEngine::cancelSearch(const NmId &mailboxId) |
791 { |
1009 { |
1010 NM_FUNCTION; |
|
1011 |
|
792 int retVal(NmNoError); |
1012 int retVal(NmNoError); |
793 |
1013 |
794 // Get the plugin interface. |
1014 // Get the plugin interface. |
795 NmDataPluginInterface *pluginInterface = |
1015 NmDataPluginInterface *pluginInterface = |
796 mPluginFactory->interfaceInstance(mailboxId); |
1016 mPluginFactory->interfaceInstance(mailboxId); |
804 |
1024 |
805 /*! |
1025 /*! |
806 \return Folder type |
1026 \return Folder type |
807 */ |
1027 */ |
808 NmFolderType NmUiEngine::folderTypeById(NmId mailboxId, NmId folderId) |
1028 NmFolderType NmUiEngine::folderTypeById(NmId mailboxId, NmId folderId) |
809 { |
1029 { |
1030 NM_FUNCTION; |
|
1031 |
|
810 NmFolderType ret(NmFolderInbox); |
1032 NmFolderType ret(NmFolderInbox); |
811 if (mDataManager){ |
1033 if (mDataManager){ |
812 ret = mDataManager->folderTypeById(mailboxId,folderId); |
1034 ret = mDataManager->folderTypeById(mailboxId,folderId); |
813 } |
1035 } |
814 return ret; |
1036 return ret; |
819 \param mailboxId Id of active mailbox, 0 if application is closed. |
1041 \param mailboxId Id of active mailbox, 0 if application is closed. |
820 \param folderId Id of active folder, 0 if application is closed. |
1042 \param folderId Id of active folder, 0 if application is closed. |
821 */ |
1043 */ |
822 void NmUiEngine::updateActiveFolder(const NmId &mailboxId, const NmId &folderId) |
1044 void NmUiEngine::updateActiveFolder(const NmId &mailboxId, const NmId &folderId) |
823 { |
1045 { |
1046 NM_FUNCTION; |
|
1047 |
|
824 NmApplicationStateInterface *interface = |
1048 NmApplicationStateInterface *interface = |
825 mPluginFactory->applicationStateInterfaceInstance(mailboxId); |
1049 mPluginFactory->applicationStateInterfaceInstance(mailboxId); |
826 if (interface) { |
1050 if (interface) { |
827 interface->updateActiveFolder(mailboxId, folderId); |
1051 interface->updateActiveFolder(mailboxId, folderId); |
828 } |
1052 } |
831 /*! |
1055 /*! |
832 Handle completed send operation. |
1056 Handle completed send operation. |
833 */ |
1057 */ |
834 void NmUiEngine::handleCompletedSendOperation() |
1058 void NmUiEngine::handleCompletedSendOperation() |
835 { |
1059 { |
836 NMLOG("NmUiEngine::handleCompletedSendOperation()"); |
1060 NM_FUNCTION; |
1061 |
|
837 emit sendOperationCompleted(); |
1062 emit sendOperationCompleted(); |
1063 } |
|
1064 |
|
1065 /*! |
|
1066 Handle completed remove draft operation. |
|
1067 */ |
|
1068 void NmUiEngine::handleCompletedRemoveDraftOperation() |
|
1069 { |
|
1070 NM_FUNCTION; |
|
1071 |
|
1072 // draft message deletion observing not yet implemented... |
|
1073 } |
|
1074 |
|
1075 /*! |
|
1076 Handle completed save draft operation. |
|
1077 */ |
|
1078 void NmUiEngine::handleCompletedSaveDraftOperation() |
|
1079 { |
|
1080 NM_FUNCTION; |
|
1081 |
|
1082 // draft message saving observing not yet implemented... |
|
838 } |
1083 } |
839 |
1084 |
840 /*! |
1085 /*! |
841 Handles synch operation related events |
1086 Handles synch operation related events |
842 */ |
1087 */ |
843 void NmUiEngine::handleSyncStateEvent(NmSyncState syncState, const NmOperationCompletionEvent &event) |
1088 void NmUiEngine::handleSyncStateEvent(NmSyncState syncState, const NmOperationCompletionEvent &event) |
844 { |
1089 { |
845 NMLOG("NmUiEngine::handleSyncStateEvent()"); |
1090 NM_FUNCTION; |
846 |
1091 |
847 if ( syncState == SyncComplete ) { |
1092 if ( syncState == SyncComplete ) { |
848 // signal for reporting about (sync) operation completion status |
1093 // signal for reporting about (sync) operation completion status |
849 emit operationCompleted(event); |
1094 emit operationCompleted(event); |
1095 HbIndicator indicator; |
|
1096 indicator.deactivate(syncIndicatorName, QVariant()); |
|
850 } |
1097 } |
851 |
1098 |
852 // signal for handling sync state icons |
1099 // signal for handling sync state icons |
853 emit syncStateEvent(syncState, event.mMailboxId); |
1100 emit syncStateEvent(syncState, event.mMailboxId); |
854 } |
1101 } |
860 void NmUiEngine::handleMessageEvent(NmMessageEvent event, |
1107 void NmUiEngine::handleMessageEvent(NmMessageEvent event, |
861 const NmId &folderId, |
1108 const NmId &folderId, |
862 const QList<NmId> &messageIds, |
1109 const QList<NmId> &messageIds, |
863 const NmId& mailboxId) |
1110 const NmId& mailboxId) |
864 { |
1111 { |
1112 NM_FUNCTION; |
|
1113 |
|
865 switch (event) { |
1114 switch (event) { |
866 case NmMessageDeleted: |
1115 case NmMessageDeleted: |
867 { |
1116 { |
868 for (int i(0); i < messageIds.count(); i++) { |
1117 for (int i(0); i < messageIds.count(); i++) { |
869 emit messageDeleted(mailboxId, folderId, messageIds[i]); |
1118 emit messageDeleted(mailboxId, folderId, messageIds[i]); |
880 Currently only NmMailboxDeleted is handled. |
1129 Currently only NmMailboxDeleted is handled. |
881 */ |
1130 */ |
882 void NmUiEngine::handleMailboxEvent(NmMailboxEvent event, |
1131 void NmUiEngine::handleMailboxEvent(NmMailboxEvent event, |
883 const QList<NmId> &mailboxIds) |
1132 const QList<NmId> &mailboxIds) |
884 { |
1133 { |
1134 NM_FUNCTION; |
|
1135 |
|
885 switch (event) { |
1136 switch (event) { |
886 case NmMailboxDeleted: |
1137 case NmMailboxDeleted: |
887 { |
1138 { |
888 for (int i(0); i < mailboxIds.count(); i++) { |
1139 for (int i(0); i < mailboxIds.count(); i++) { |
889 emit mailboxDeleted(mailboxIds[i]); |
1140 emit mailboxDeleted(mailboxIds[i]); |
902 \param messageId The ID of the found message. |
1153 \param messageId The ID of the found message. |
903 \param folderId The ID of the folder where the message is located. |
1154 \param folderId The ID of the folder where the message is located. |
904 */ |
1155 */ |
905 void NmUiEngine::handleMatchFound(const NmId &messageId, const NmId &folderId) |
1156 void NmUiEngine::handleMatchFound(const NmId &messageId, const NmId &folderId) |
906 { |
1157 { |
1158 NM_FUNCTION; |
|
1159 |
|
907 if (!mMessageSearchListModel) { |
1160 if (!mMessageSearchListModel) { |
908 // No search list model! |
1161 // No search list model! |
909 return; |
1162 return; |
910 } |
1163 } |
911 |
1164 |
912 // Add the found message into the search model. |
1165 // Resolve the folder type. |
913 QList<NmId> messageIdList; |
1166 NmId mailboxId = mMessageSearchListModel->currentMailboxId(); |
914 messageIdList.append(messageId); |
1167 NmFolderType folderType = folderTypeById(mailboxId, folderId); |
915 |
1168 |
916 mMessageSearchListModel->handleMessageEvent(NmMessageFound, |
1169 // Do not display matches from outbox or draft folders. |
917 folderId, |
1170 if (folderType != NmFolderOutbox && folderType != NmFolderDrafts) { |
918 messageIdList); |
1171 // Add the found message into the search model. |
919 } |
1172 QList<NmId> messageIdList; |
920 |
1173 messageIdList.append(messageId); |
1174 |
|
1175 mMessageSearchListModel->handleMessageEvent(NmMessageFound, folderId, |
|
1176 messageIdList, mailboxId); |
|
1177 } |
|
1178 } |
|
1179 |
|
1180 /*! |
|
1181 Function sens events from plugin to both models. Inbox model for |
|
1182 active mailbox is always alove whereas mMessageListModel can represent |
|
1183 other folder in the device (sent, outbox, drafts, etc.) |
|
1184 */ |
|
1185 void NmUiEngine::messageEventForListModel(NmMessageEvent event, |
|
1186 const NmId &folderId, |
|
1187 const QList<NmId> &messageIds, |
|
1188 const NmId& mailboxId) |
|
1189 { |
|
1190 NM_FUNCTION; |
|
1191 |
|
1192 // Forward event to both list models. Models will take care of checking |
|
1193 // whether event really belongs to current mailbox & folder |
|
1194 if (mInboxListModel){ |
|
1195 mInboxListModel->handleMessageEvent(event, folderId, |
|
1196 messageIds, mailboxId); |
|
1197 } |
|
1198 if (mMessageListModel){ |
|
1199 mMessageListModel->handleMessageEvent(event, folderId, |
|
1200 messageIds, mailboxId); |
|
1201 } |
|
1202 } |
|
921 |
1203 |
922 /*! |
1204 /*! |
923 receives events when going online, and offline. |
1205 receives events when going online, and offline. |
924 */ |
1206 */ |
925 void NmUiEngine::handleConnectEvent(NmConnectState connectState, const NmId &mailboxId, const int errorCode) |
1207 void NmUiEngine::handleConnectEvent(NmConnectState connectState, const NmId &mailboxId, const int errorCode) |
926 { |
1208 { |
1209 NM_FUNCTION; |
|
1210 |
|
927 // signal for connection state icon handling |
1211 // signal for connection state icon handling |
928 emit connectionEvent(connectState, mailboxId); |
1212 emit connectionEvent(connectState, mailboxId); |
929 |
1213 |
930 // in case going offline w/ error, emit signal to UI |
1214 // in case going offline w/ error, emit signal to UI |
931 if ( connectState == Disconnected && errorCode!= NmNoError ) { |
1215 if ( connectState == Disconnected && errorCode!= NmNoError ) { |