|
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 "nmuiengineheaders.h" |
|
19 |
|
20 /*! |
|
21 \class NmBaseClientPlugin |
|
22 |
|
23 \brief The NmBaseClientPlugin plugin provides ui services for IMAP/POP mail protocols. |
|
24 |
|
25 The NmBaseClientPlugin contains the following services: |
|
26 \li get actions |
|
27 \li refresh mailbox |
|
28 \li create new email |
|
29 \li open settings |
|
30 \li send email |
|
31 \li delete email |
|
32 \li open email |
|
33 \li reply email |
|
34 \li reply all email |
|
35 \li forward email |
|
36 |
|
37 The plugin provides a list of supported UI services as NmAction objects. Actions are connected to |
|
38 different public slots and when they are triggered plugin will handle action by itself directly to |
|
39 NmUiEngine or by using NmActionResponse to inform user of service. |
|
40 |
|
41 */ |
|
42 |
|
43 /*! |
|
44 \fn void NmBaseClientPlugin::getActions(const NmActionRequest &request, QList<NmAction*> &actionList) |
|
45 Implementation of NmUiExtension interface. The plugin provides to caller supported actions for email protocol. |
|
46 \a request contains NmActionRequest with needed request data. |
|
47 \a actionList QList array will be filled by action supported protocol and controlled by NmActionRequest. |
|
48 */ |
|
49 |
|
50 /*! |
|
51 \fn void NmBaseClientPlugin::openMessage() |
|
52 When open action is triggered this slot is called to open message. |
|
53 */ |
|
54 |
|
55 /*! |
|
56 \fn void NmBaseClientPlugin::deleteMessage() |
|
57 When delete action is triggered this slot is called to delete message. |
|
58 */ |
|
59 |
|
60 /*! |
|
61 \fn void NmBaseClientPlugin::refresh() |
|
62 When refresh action is triggered this slot is called to start refreshing the mailbox. |
|
63 */ |
|
64 |
|
65 /*! |
|
66 \fn void NmBaseClientPlugin::createNewMail() |
|
67 When create new action is triggered this slot is called to notify responce observer |
|
68 with NmActionResponseCommandNewMail enum. |
|
69 */ |
|
70 |
|
71 /*! |
|
72 \fn void NmBaseClientPlugin::settings() |
|
73 When settings action is triggered this slot is called to open settings. |
|
74 */ |
|
75 |
|
76 /*! |
|
77 \fn void NmBaseClientPlugin::sendMail() |
|
78 When send mail action is triggered this slot is called to send an email. |
|
79 */ |
|
80 |
|
81 /*! |
|
82 \fn void NmBaseClientPlugin::replyMail() |
|
83 When reply mail action is triggered this slot is called to reply an email. |
|
84 */ |
|
85 |
|
86 /*! |
|
87 \fn void NmBaseClientPlugin::replyAllMail() |
|
88 When reply all mail action is triggered this slot is called to reply all an email. |
|
89 */ |
|
90 |
|
91 /*! |
|
92 \fn void NmBaseClientPlugin::forwardMail() |
|
93 When forward mail action is triggered this slot is called to forward an email. |
|
94 */ |
|
95 |
|
96 /*! |
|
97 Constructs a new NmBaseClientPlugin. |
|
98 */ |
|
99 NmBaseClientPlugin::NmBaseClientPlugin() |
|
100 :mMenuRequest(NULL), |
|
101 mEditorToolBarRequest(NULL), |
|
102 mViewerToolBarRequest(NULL), |
|
103 mViewerViewToolbarRequest(NULL), |
|
104 mUiEngine(NULL), |
|
105 mSettingsViewLauncher(NULL) |
|
106 { |
|
107 NMLOG("NmBaseClientPlugin::NmBaseClientPlugin()-->"); |
|
108 mUiEngine = NmUiEngine::instance(); |
|
109 NMLOG("<--NmBaseClientPlugin::NmBaseClientPlugin()"); |
|
110 } |
|
111 |
|
112 /*! |
|
113 Destructor. |
|
114 */ |
|
115 NmBaseClientPlugin::~NmBaseClientPlugin() |
|
116 { |
|
117 NMLOG("NmBaseClientPlugin::~NmBaseClientPlugin()-->"); |
|
118 NmUiEngine::releaseInstance(mUiEngine); |
|
119 mUiEngine = NULL; |
|
120 delete mSettingsViewLauncher; |
|
121 NMLOG("<--NmBaseClientPlugin::~NmBaseClientPlugin()"); |
|
122 } |
|
123 |
|
124 /*! |
|
125 Provides list of supported NmActions. |
|
126 Implementation of NmUiExtensionInterface. |
|
127 Parameter \a request controls list of request services. |
|
128 Parameter \a actionList is updated by supported NmActions. |
|
129 */ |
|
130 void NmBaseClientPlugin::getActions( |
|
131 const NmActionRequest &request, |
|
132 QList<NmAction *> &actionList) |
|
133 { |
|
134 NMLOG("NmBaseClientPlugin::getActions()-->"); |
|
135 |
|
136 if (request.observer()) { |
|
137 switch (request.contextView()) { |
|
138 case NmActionContextViewMessageList: |
|
139 { |
|
140 createMessageListCommands(request, actionList); |
|
141 break; |
|
142 } |
|
143 case NmActionContextViewViewer: |
|
144 { |
|
145 createViewerViewCommands(request, actionList); |
|
146 break; |
|
147 } |
|
148 case NmActionContextViewEditor: |
|
149 { |
|
150 createEditorViewCommands(request, actionList); |
|
151 break; |
|
152 } |
|
153 default: |
|
154 { |
|
155 NMLOG(QString("NmBaseClientPlugin::getActions(): Unknown contextView()=%1").arg(request.contextView())); |
|
156 break; |
|
157 } |
|
158 } |
|
159 } |
|
160 NMLOG("<--NmBaseClientPlugin::getActions()"); |
|
161 } |
|
162 |
|
163 /*! |
|
164 Public slot connected to options menu refresh NmAction. |
|
165 Refreshes mailbox using the NmUiEngine instance. |
|
166 */ |
|
167 void NmBaseClientPlugin::refresh() |
|
168 { |
|
169 NMLOG("NmBaseClientPlugin::refresh()-->"); |
|
170 |
|
171 int err = mUiEngine->refreshMailbox(mMenuRequest.mailboxId()); |
|
172 |
|
173 if (NmNoError != err) { |
|
174 // Failed to refresh the mailbox! |
|
175 NMLOG(QString("NmBaseClientPlugin::refresh(): failed err=%1").arg(err)); |
|
176 } |
|
177 |
|
178 NMLOG("<--NmBaseClientPlugin::refresh()"); |
|
179 } |
|
180 |
|
181 /*! |
|
182 Public slot connected to triggered() signal of open message action instance. |
|
183 The method sends an open response command to the action observer. |
|
184 */ |
|
185 void NmBaseClientPlugin::openMessage() |
|
186 { |
|
187 handleRequest(NmActionResponseCommandOpen, mMenuRequest); |
|
188 } |
|
189 |
|
190 /*! |
|
191 Public slot connected to delete message. Method asks UI engine to delete messages |
|
192 */ |
|
193 void NmBaseClientPlugin::deleteMessage() |
|
194 { |
|
195 NMLOG("NmBaseClientPlugin::deleteMessage()-->"); |
|
196 |
|
197 QList<NmId> messageList; |
|
198 messageList.append(mMenuRequest.messageId()); |
|
199 |
|
200 int err = mUiEngine->deleteMessages(mMenuRequest.mailboxId(), |
|
201 mMenuRequest.folderId(), |
|
202 messageList); |
|
203 if (NmNoError != err) { |
|
204 // Failed to delete the messages! |
|
205 NMLOG(QString("NmBaseClientPlugin::deleteMessage(): failed err=%1").arg(err)); |
|
206 } |
|
207 messageList.clear(); |
|
208 NMLOG("<--NmBaseClientPlugin::deleteMessage()"); |
|
209 } |
|
210 |
|
211 /*! |
|
212 Public slot connected to triggered() signal of delete action instance. |
|
213 The method sends a delete mail command to the action observer. |
|
214 */ |
|
215 void NmBaseClientPlugin::deleteMessageFromViewerViewToolbar() |
|
216 { |
|
217 handleRequest(NmActionResponseCommandDeleteMail, mViewerViewToolbarRequest); |
|
218 } |
|
219 |
|
220 /*! |
|
221 Public slot connected to triggered() signal of create mail action instance. |
|
222 The method sends a new mail command to the action observer. |
|
223 */ |
|
224 void NmBaseClientPlugin::createNewMailViewerToolBar() |
|
225 { |
|
226 handleRequest(NmActionResponseCommandNewMail, mViewerToolBarRequest); |
|
227 } |
|
228 |
|
229 /*! |
|
230 Public slot for handling the event of menu request for creating a new email. |
|
231 The method sends a new mail command to the action observer of the menu request. |
|
232 */ |
|
233 void NmBaseClientPlugin::createNewMail() |
|
234 { |
|
235 handleRequest(NmActionResponseCommandNewMail, mMenuRequest); |
|
236 } |
|
237 |
|
238 /*! |
|
239 Public slot connected to options menu settings NmAction. |
|
240 Opens mailbox settings. |
|
241 */ |
|
242 void NmBaseClientPlugin::settings() |
|
243 { |
|
244 NMLOG("NmBaseClientPlugin::settings()-->"); |
|
245 |
|
246 #ifndef NM_WINS_ENV |
|
247 const NmId &id = mMenuRequest.mailboxId(); |
|
248 NmMailboxMetaData *mailbox = mUiEngine->mailboxById(id); |
|
249 |
|
250 if (mailbox) { |
|
251 if (!mSettingsViewLauncher) { |
|
252 mSettingsViewLauncher = new NmSettingsViewLauncher(); |
|
253 |
|
254 connect(mSettingsViewLauncher, |
|
255 SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)), |
|
256 this, SLOT(mailboxListChanged(const NmId &, NmSettings::MailboxEventType))); |
|
257 |
|
258 connect(mSettingsViewLauncher, |
|
259 SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant)), |
|
260 this, SLOT(mailboxPropertyChanged(const NmId &, QVariant, QVariant))); |
|
261 } |
|
262 |
|
263 mSettingsViewLauncher->launchSettingsView(id, mailbox->name()); |
|
264 } |
|
265 #endif |
|
266 |
|
267 NMLOG("<--NmBaseClientPlugin::settings()"); |
|
268 } |
|
269 |
|
270 /*! |
|
271 Public slot connected to triggered() signal of send mail action instance. |
|
272 Sends the send mail command to the action observer. |
|
273 */ |
|
274 void NmBaseClientPlugin::sendMail() |
|
275 { |
|
276 handleRequest(NmActionResponseCommandSendMail, mEditorToolBarRequest); |
|
277 } |
|
278 |
|
279 /*! |
|
280 Public slot connected to triggered() signal of reply action instance of the |
|
281 toolbar. Sends a reply mail command to the action observer. |
|
282 */ |
|
283 |
|
284 void NmBaseClientPlugin::replyMail() |
|
285 { |
|
286 handleRequest(NmActionResponseCommandReply, mViewerViewToolbarRequest); |
|
287 } |
|
288 |
|
289 /*! |
|
290 Public slot connected to triggered signal of reply all action instance of |
|
291 the toolbar. Sends a reply all mail command to the action observer. |
|
292 */ |
|
293 |
|
294 void NmBaseClientPlugin::replyAllMail() |
|
295 { |
|
296 handleRequest(NmActionResponseCommandReplyAll, mViewerViewToolbarRequest); |
|
297 } |
|
298 |
|
299 /*! |
|
300 Public slot connected to triggered() signal of forward action instance of |
|
301 the toolbar. Sends a forward mail command to the action observer. |
|
302 */ |
|
303 void NmBaseClientPlugin::forwardMail() |
|
304 { |
|
305 handleRequest(NmActionResponseCommandForward, mViewerViewToolbarRequest); |
|
306 } |
|
307 |
|
308 /*! |
|
309 Public slot connected to set high priority toolbar action. |
|
310 */ |
|
311 void NmBaseClientPlugin::setPriorityHigh() |
|
312 { |
|
313 handleRequest(NmActionResponseCommandPriorityHigh, mMenuRequest); |
|
314 } |
|
315 |
|
316 /*! |
|
317 Public slot connected to set normal priority toolbar action. |
|
318 */ |
|
319 void NmBaseClientPlugin::setPriorityNormal() |
|
320 { |
|
321 handleRequest(NmActionResponseCommandNone, mMenuRequest); |
|
322 } |
|
323 |
|
324 /*! |
|
325 Public slot connected to set low priority toolbar action. |
|
326 */ |
|
327 void NmBaseClientPlugin::setPriorityLow() |
|
328 { |
|
329 handleRequest(NmActionResponseCommandPriorityLow, mMenuRequest); |
|
330 } |
|
331 |
|
332 /*! |
|
333 Public slot connected to attach toolbar action. |
|
334 */ |
|
335 void NmBaseClientPlugin::attach() |
|
336 { |
|
337 handleRequest(NmActionResponseCommandAttach, mEditorToolBarRequest); |
|
338 } |
|
339 |
|
340 /*! |
|
341 Private slot connected to settings view launcher. |
|
342 |
|
343 \param mailboxId Id of mailbox. |
|
344 \param type type of change. |
|
345 */ |
|
346 void NmBaseClientPlugin::mailboxListChanged(const NmId &mailboxId, |
|
347 NmSettings::MailboxEventType type) |
|
348 { |
|
349 Q_UNUSED(mailboxId) |
|
350 Q_UNUSED(type) |
|
351 handleRequest(NmActionResponseCommandMailboxDeleted, mMenuRequest); |
|
352 } |
|
353 |
|
354 /*! |
|
355 Private slot connected to settings view launcher. |
|
356 |
|
357 \param mailboxId Id of mailbox. |
|
358 \param property |
|
359 \param value |
|
360 */ |
|
361 void NmBaseClientPlugin::mailboxPropertyChanged(const NmId &mailboxId, QVariant property, |
|
362 QVariant value) |
|
363 { |
|
364 Q_UNUSED(property) |
|
365 Q_UNUSED(value) |
|
366 |
|
367 NmActionObserver *observer = mMenuRequest.observer(); |
|
368 if (observer) { |
|
369 // Force model item to be updated, because framework adapter sends it too slowly. |
|
370 // Data changed signal is not emitted by this change, it is send when ever famework adapter |
|
371 // calls data model's handleMailboxEvent method. |
|
372 mUiEngine->mailboxListModel().refreshModelItem(mailboxId, false); |
|
373 |
|
374 // Notify view of changes. |
|
375 NmActionResponse response(NmActionResponseCommandUpdateMailboxName, mMenuRequest); |
|
376 observer->handleActionCommand(response); |
|
377 } |
|
378 } |
|
379 |
|
380 /*! |
|
381 Create messagelist command actions. |
|
382 Internal helper method. |
|
383 Parameter \a request is used to identify requested menu type. |
|
384 Parameter \a actionList is updated by supported NmActions for message list. |
|
385 */ |
|
386 void NmBaseClientPlugin::createMessageListCommands( |
|
387 const NmActionRequest &request, |
|
388 QList<NmAction *> &actionList) |
|
389 { |
|
390 NMLOG("NmBaseClientPlugin::createMessageListCommands()-->"); |
|
391 |
|
392 switch (request.menuType()) { |
|
393 case NmActionOptionsMenu: |
|
394 { |
|
395 mMenuRequest = request; |
|
396 |
|
397 NmAction *refreshAction = new NmAction(0); |
|
398 refreshAction->setObjectName("baseclientplugin_refresh"); |
|
399 refreshAction->setText(hbTrId("txt_mail_opt_send_and_receive_now")); |
|
400 connect(refreshAction, SIGNAL(triggered()), this, SLOT(refresh())); |
|
401 actionList.append(refreshAction); |
|
402 |
|
403 NmAction *settingsAction = new NmAction(0); |
|
404 settingsAction->setObjectName("baseclientplugin_settings"); |
|
405 settingsAction->setText(hbTrId("txt_common_opt_settings")); |
|
406 connect(settingsAction, SIGNAL(triggered()), this, SLOT(settings())); |
|
407 actionList.append(settingsAction); |
|
408 break; |
|
409 } |
|
410 case NmActionToolbar: |
|
411 { |
|
412 mViewerToolBarRequest = request; |
|
413 NmAction *createMailAction = new NmAction(0); |
|
414 createMailAction->setObjectName("baseclientplugin_createmailaction"); |
|
415 createMailAction->setText(hbTrId("txt_mail_button_new_mail")); |
|
416 createMailAction->setIcon(NmIcons::getIcon(NmIcons::NmIconNewEmail)); |
|
417 connect(createMailAction, SIGNAL(triggered()), |
|
418 this, SLOT(createNewMailViewerToolBar())); |
|
419 actionList.append(createMailAction); |
|
420 break; |
|
421 } |
|
422 case NmActionContextMenu: |
|
423 { |
|
424 if (request.contextDataType() == NmActionContextDataMessage){ |
|
425 mMenuRequest = request; |
|
426 |
|
427 // Open message |
|
428 NmAction* openAction = new NmAction(0); |
|
429 openAction->setObjectName("baseclientplugin_openaction"); |
|
430 openAction->setText(hbTrId("txt_common_menu_open")); |
|
431 connect(openAction, SIGNAL(triggered()), this, SLOT(openMessage())); |
|
432 actionList.append(openAction); |
|
433 |
|
434 // Delete message |
|
435 NmAction* deleteAction = new NmAction(0); |
|
436 deleteAction->setObjectName("baseclientplugin_deleteaction"); |
|
437 deleteAction->setText(hbTrId("txt_common_menu_delete")); |
|
438 connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteMessage())); |
|
439 actionList.append(deleteAction); |
|
440 |
|
441 NmMessageEnvelope *envelope = |
|
442 request.requestData().value<NmMessageEnvelope*>(); |
|
443 |
|
444 if (envelope){ |
|
445 if (envelope->isRead()){ |
|
446 NMLOG("nmailui: envelope is read"); |
|
447 NmAction* unreadAction = new NmAction(0); |
|
448 unreadAction->setObjectName("baseclientplugin_unreadaction"); |
|
449 unreadAction->setText(hbTrId("txt_mail_menu_mark_as_unread")); |
|
450 |
|
451 connect(unreadAction, |
|
452 SIGNAL(triggered()), |
|
453 this, |
|
454 SLOT(markAsUnread())); |
|
455 |
|
456 actionList.append(unreadAction); |
|
457 } |
|
458 else { |
|
459 NMLOG("nmailui: envelope is unread"); |
|
460 NmAction* readAction = new NmAction(0); |
|
461 readAction->setObjectName("baseclientplugin_readaction"); |
|
462 readAction->setText(hbTrId("txt_mail_menu_mark_as_read")); |
|
463 |
|
464 connect(readAction, |
|
465 SIGNAL(triggered()), |
|
466 this, |
|
467 SLOT(markAsRead())); |
|
468 |
|
469 actionList.append(readAction); |
|
470 } |
|
471 } |
|
472 } |
|
473 break; |
|
474 } |
|
475 default: |
|
476 { |
|
477 NMLOG(QString("NmBaseClientPlugin::createMessageListCommands(): Unknown menuType()=%1").arg(request.menuType())); |
|
478 break; |
|
479 } |
|
480 } |
|
481 NMLOG("<--NmBaseClientPlugin::createMessageListCommands()"); |
|
482 } |
|
483 |
|
484 /*! |
|
485 Create Viewer view command actions. |
|
486 Internal helper method. |
|
487 Parameter \a request is used to identify requested menu type. |
|
488 Parameter \a actionList is updated by supported NmActions for message list. |
|
489 */ |
|
490 void NmBaseClientPlugin::createViewerViewCommands( |
|
491 const NmActionRequest &request, |
|
492 QList<NmAction *> &actionList) |
|
493 { |
|
494 NMLOG("NmBaseClientPlugin::createViewerViewCommands()-->"); |
|
495 |
|
496 switch (request.menuType()) { |
|
497 case NmActionToolbar: |
|
498 { |
|
499 mViewerViewToolbarRequest = request; |
|
500 Qt::Orientation orientation = Qt::Horizontal; |
|
501 HbMainWindow *mainWindow = static_cast<HbMainWindow*>(HbApplication::activeWindow()); |
|
502 if( mainWindow ) { |
|
503 orientation = mainWindow->orientation(); |
|
504 } |
|
505 |
|
506 // ToolBar Reply action |
|
507 NmAction *replyAction = new NmAction(0); |
|
508 if (Qt::Horizontal == orientation) { |
|
509 replyAction->setText(hbTrId("txt_mail_button_reply")); |
|
510 } |
|
511 replyAction->setToolTip(hbTrId("txt_mail_button_reply")); |
|
512 replyAction->setIcon(NmIcons::getIcon(NmIcons::NmIconReply)); |
|
513 replyAction->setObjectName("baseclientplugin_reply"); |
|
514 connect(replyAction, SIGNAL(triggered()), this, SLOT(replyMail())); |
|
515 actionList.append(replyAction); |
|
516 |
|
517 // ToolBar Reply all action |
|
518 NmAction *replyAllAction = new NmAction(0); |
|
519 if (Qt::Horizontal == orientation) { |
|
520 replyAllAction->setText(hbTrId("txt_mail_button_reply_all")); |
|
521 } |
|
522 replyAllAction->setToolTip(hbTrId("txt_mail_button_reply_all")); |
|
523 replyAllAction->setIcon(NmIcons::getIcon(NmIcons::NmIconReplyAll)); |
|
524 replyAllAction->setObjectName("baseclientplugin_reply_all"); |
|
525 connect(replyAllAction, SIGNAL(triggered()), this, SLOT(replyAllMail())); |
|
526 actionList.append(replyAllAction); |
|
527 |
|
528 // ToolBar Forward action |
|
529 NmAction *forwardAction = new NmAction(0); |
|
530 if (Qt::Horizontal == orientation) { |
|
531 forwardAction->setText(hbTrId("txt_mail_button_forward")); |
|
532 } |
|
533 forwardAction->setToolTip(hbTrId("txt_mail_button_forward")); |
|
534 forwardAction->setIcon(NmIcons::getIcon(NmIcons::NmIconForward)); |
|
535 forwardAction->setObjectName("baseclientplugin_forward"); |
|
536 connect(forwardAction, SIGNAL(triggered()), this, SLOT(forwardMail())); |
|
537 actionList.append(forwardAction); |
|
538 |
|
539 // ToolBar Delete action |
|
540 NmAction *deleteAction = new NmAction(0); |
|
541 if (Qt::Horizontal == orientation) { |
|
542 deleteAction->setText(hbTrId("txt_mail_button_delete")); |
|
543 } |
|
544 deleteAction->setToolTip(hbTrId("txt_mail_button_delete")); |
|
545 deleteAction->setIcon(NmIcons::getIcon(NmIcons::NmIconDelete)); |
|
546 deleteAction->setObjectName("baseclientplugin_delete"); |
|
547 connect(deleteAction, SIGNAL(triggered()), |
|
548 this, SLOT(deleteMessageFromViewerViewToolbar())); |
|
549 actionList.append(deleteAction); |
|
550 break; |
|
551 } |
|
552 default: |
|
553 { |
|
554 NMLOG(QString("NmBaseClientPlugin::createViewerViewCommands(): Unknown menuType()=%1").arg(request.menuType())); |
|
555 break; |
|
556 } |
|
557 } |
|
558 |
|
559 } |
|
560 |
|
561 /*! |
|
562 Create Editor view command actions. |
|
563 Internal helper method. |
|
564 Parameter \a request is used to identify requested menu type. |
|
565 Parameter \a actionList is updated by supported NmActions for message list. |
|
566 */ |
|
567 void NmBaseClientPlugin::createEditorViewCommands( |
|
568 const NmActionRequest &request, |
|
569 QList<NmAction *> &actionList) |
|
570 { |
|
571 NMLOG("NmBaseClientPlugin::createEditorViewCommands()-->"); |
|
572 |
|
573 switch (request.menuType()) { |
|
574 case NmActionToolbar: |
|
575 { |
|
576 mEditorToolBarRequest = request; |
|
577 |
|
578 // ToolBar Attach action |
|
579 NmAction *attachAction = new NmAction(0); |
|
580 attachAction->setObjectName("baseclientplugin_attachaction"); |
|
581 attachAction->setText(hbTrId("txt_mail_button_attach")); |
|
582 attachAction->setIcon(NmIcons::getIcon(NmIcons::NmIconAttach)); |
|
583 // connect action/add toolbar extensions |
|
584 connect(attachAction, SIGNAL(triggered()), this, SLOT(attach())); |
|
585 actionList.append(attachAction); |
|
586 |
|
587 // ToolBar Send action |
|
588 NmAction *sendAction = new NmAction(0); |
|
589 sendAction->setObjectName("baseclientplugin_sendaction"); |
|
590 sendAction->setText(hbTrId("txt_common_button_send")); |
|
591 sendAction->setIcon(NmIcons::getIcon(NmIcons::NmIconSend)); |
|
592 // Action only available when the message related to it can be sent. |
|
593 sendAction->setAvailabilityCondition(NmAction::NmSendable); |
|
594 connect(sendAction, SIGNAL(triggered()), this, SLOT(sendMail())); |
|
595 actionList.append(sendAction); |
|
596 break; |
|
597 } |
|
598 case NmActionOptionsMenu: |
|
599 { |
|
600 mMenuRequest = request; |
|
601 |
|
602 NmAction *action = new NmAction(0); |
|
603 action->setObjectName("baseclientplugin_highpriorityaction"); |
|
604 action->setText(hbTrId("txt_mail_opt_add_priority_sub_high")); |
|
605 connect(action, SIGNAL(triggered()), this, SLOT(setPriorityHigh())); |
|
606 actionList.append(action); |
|
607 |
|
608 action = new NmAction(0); |
|
609 action->setObjectName("baseclientplugin_normalpriorityaction"); |
|
610 action->setText(hbTrId("txt_mail_opt_add_priority_sub_normal")); |
|
611 connect(action, SIGNAL(triggered()), this, SLOT(setPriorityNormal())); |
|
612 actionList.append(action); |
|
613 |
|
614 action = new NmAction(0); |
|
615 action->setObjectName("baseclientplugin_lowpriorityaction"); |
|
616 action->setText(hbTrId("txt_mail_opt_add_priority_sub_low")); |
|
617 connect(action, SIGNAL(triggered()), this, SLOT(setPriorityLow())); |
|
618 actionList.append(action); |
|
619 break; |
|
620 } |
|
621 case NmActionVKB: |
|
622 { |
|
623 mMenuRequest = request; |
|
624 |
|
625 // Virtual Keyboard Send action |
|
626 NmAction *sendAction = new NmAction(0); |
|
627 sendAction->setObjectName("baseclientplugin_vblsendaction"); |
|
628 sendAction->setText(hbTrId("txt_common_button_send")); |
|
629 // Action only available when the message related to it can be sent. |
|
630 sendAction->setAvailabilityCondition(NmAction::NmSendable); |
|
631 connect(sendAction, SIGNAL(triggered()), this, SLOT(sendMail())); |
|
632 actionList.append(sendAction); |
|
633 break; |
|
634 } |
|
635 default: |
|
636 { |
|
637 NMLOG(QString("NmBaseClientPlugin::createEditorViewCommands(): Unknown menuType()=%1").arg(request.menuType())); |
|
638 break; |
|
639 } |
|
640 } |
|
641 |
|
642 NMLOG("<--NmBaseClientPlugin::createEditorViewCommands()"); |
|
643 } |
|
644 |
|
645 /*! |
|
646 Marks the message as read. |
|
647 */ |
|
648 void NmBaseClientPlugin::markAsRead() |
|
649 { |
|
650 NMLOG("NmBaseClientPlugin::markAsRead()-->"); |
|
651 updateEnvelopeProperty(MarkAsRead); |
|
652 NMLOG("<--NmBaseClientPlugin::markAsRead()"); |
|
653 } |
|
654 |
|
655 /*! |
|
656 Marks the message as unread. |
|
657 */ |
|
658 void NmBaseClientPlugin::markAsUnread() |
|
659 { |
|
660 NMLOG("NmBaseClientPlugin::markAsUnread()-->"); |
|
661 updateEnvelopeProperty(MarkAsUnread); |
|
662 NMLOG("<--NmBaseClientPlugin::markAsUnread()"); |
|
663 } |
|
664 |
|
665 /*! |
|
666 Handles requests. |
|
667 */ |
|
668 void NmBaseClientPlugin::handleRequest(NmActionResponseCommand command, const NmActionRequest &request) |
|
669 { |
|
670 NmActionObserver *observer = request.observer(); |
|
671 if (observer) { |
|
672 NmActionResponse response(command, request); |
|
673 observer->handleActionCommand(response); |
|
674 } |
|
675 } |
|
676 /*! |
|
677 Store envelope property. |
|
678 */ |
|
679 void NmBaseClientPlugin::updateEnvelopeProperty(NmEnvelopeProperties property) |
|
680 { |
|
681 NMLOG("NmBaseClientPlugin::updateEnvelopeProperty()-->"); |
|
682 |
|
683 QList<const NmMessageEnvelope*> envelopeList; |
|
684 NmMessageEnvelope *envelope = |
|
685 mMenuRequest.requestData().value<NmMessageEnvelope*>(); |
|
686 |
|
687 if (envelope) { |
|
688 envelopeList.append(envelope); |
|
689 |
|
690 NmStoreEnvelopesOperation* op = |
|
691 mUiEngine->setEnvelopes(mMenuRequest.mailboxId(), |
|
692 mMenuRequest.folderId(), |
|
693 property, |
|
694 envelopeList); |
|
695 |
|
696 if (op) { |
|
697 mUiEngine->storeOperation(op); |
|
698 } |
|
699 } |
|
700 envelopeList.clear(); |
|
701 NMLOG("<--NmBaseClientPlugin::updateEnvelopeProperty()"); |
|
702 } |