|
1 /* |
|
2 * Copyright (c) 2009 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:Conversation (chat) view for messaging application. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "msgconversationview.h" |
|
19 |
|
20 // SYSTEM INCLUDES |
|
21 #include <HbMenu> |
|
22 #include <HbAction> |
|
23 #include <HbListView> |
|
24 #include <HbMessageBox> |
|
25 #include <HbNotificationDialog> |
|
26 #include <HbFrameBackground> |
|
27 #include <XQServiceRequest.h> |
|
28 #include <HbStaticVkbHost> |
|
29 #include <HbStyleLoader> |
|
30 #include <xqaiwrequest.h> |
|
31 #include <xqappmgr.h> |
|
32 |
|
33 #include <QDir> |
|
34 #include <QDateTime> |
|
35 #include <QGraphicsLinearLayout> |
|
36 #include <QStandardItemModel> |
|
37 |
|
38 #include <cntservicescontact.h> |
|
39 #include <ccsdefs.h> |
|
40 #include <centralrepository.h> |
|
41 #include <MmsEngineDomainCRKeys.h> |
|
42 |
|
43 // USER INCLUDES |
|
44 #include "msgsendutil.h" |
|
45 #include "msgconversationviewitem.h" |
|
46 #include "conversationsengine.h" |
|
47 #include "convergedmessageid.h" |
|
48 #include "conversationsenginedefines.h" |
|
49 #include "msgcontactcardwidget.h" |
|
50 #include "msgeditorwidget.h" |
|
51 #include "msgviewdefines.h" |
|
52 #include "debugtraces.h" |
|
53 #include "unidatamodelloader.h" |
|
54 #include "unidatamodelplugininterface.h" |
|
55 #include "ringbc.h" |
|
56 #include "mmsconformancecheck.h" |
|
57 #include "msgsettingsview.h" |
|
58 |
|
59 //Item specific menu. |
|
60 |
|
61 #define LOC_COMMON_OPEN hbTrId("txt_common_menu_open") |
|
62 #define LOC_COMMON_DELETE hbTrId("txt_common_menu_delete") |
|
63 #define LOC_COMMON_FORWARD hbTrId("txt_common_menu_forward") |
|
64 #define LOC_COMMON_DOWNLOAD hbTrId("txt_messaging_menu_download") |
|
65 #define LOC_COMMON_SEND hbTrId("txt_common_menu_send") |
|
66 #define LOC_COMMON_SAVE hbTrId("txt_common_menu_save") |
|
67 #define LOC_BUTTON_DELETE hbTrId("txt_common_button_delete") |
|
68 #define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel") |
|
69 #define LOC_BUTTON_OK hbTrId("txt_common_button_ok") |
|
70 |
|
71 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message") |
|
72 |
|
73 //main menu |
|
74 #define LOC_ATTACH hbTrId("txt_messaging_opt_attach") |
|
75 #define LOC_PHOTO hbTrId("txt_messaging_opt_attach_sub_photo") |
|
76 #define LOC_SOUND hbTrId("txt_messaging_opt_attach_sub_sound") |
|
77 #define LOC_VCARD hbTrId("txt_messaging_list_business_card") |
|
78 #define LOC_ADD_RECIPIENTS hbTrId("txt_messaging_opt_add_recipients") |
|
79 #define LOC_ADD_SUBJECT hbTrId("txt_messaging_opt_add_subject") |
|
80 |
|
81 #define LOC_MSG_SEND_FAILED hbTrId("txt_messaging_dpopinfo_sending_failed") |
|
82 |
|
83 #define LOC_DIALOG_SMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_sms_settings_incomplete") |
|
84 #define LOC_DIALOG_SAVE_RINGTONE hbTrId("txt_conversations_dialog_save_ringing_tone") |
|
85 |
|
86 |
|
87 |
|
88 const int INVALID_MSGID = -1; |
|
89 const int INVALID_CONVID = -1; |
|
90 const int CONTACT_INSERTION_MODE = 1; |
|
91 const int VCARD_INSERTION_MODE = 0; |
|
92 |
|
93 //--------------------------------------------------------------- |
|
94 // MsgConversationView::MsgConversationView |
|
95 // @see header file |
|
96 //--------------------------------------------------------------- |
|
97 MsgConversationView::MsgConversationView(MsgContactCardWidget *contactCardWidget, |
|
98 QGraphicsItem *parent) : |
|
99 MsgBaseView(parent), |
|
100 mConversationList(NULL), |
|
101 mMessageModel(NULL), |
|
102 mEditorWidget(NULL), |
|
103 mContactCardWidget(contactCardWidget), |
|
104 mSendUtil(NULL), |
|
105 mItemLongPressed(false), |
|
106 mVkbHost(NULL), |
|
107 mVkbopened(false) |
|
108 { |
|
109 //create send utils |
|
110 mSendUtil = new MsgSendUtil(this); |
|
111 //initialize view |
|
112 setupView(); |
|
113 setupMenu(); |
|
114 } |
|
115 |
|
116 //--------------------------------------------------------------- |
|
117 // MsgConversationView::~MsgConversationView |
|
118 // @see header file |
|
119 //--------------------------------------------------------------- |
|
120 MsgConversationView::~MsgConversationView() |
|
121 { |
|
122 |
|
123 } |
|
124 //--------------------------------------------------------------- |
|
125 // MsgConversationView::setupView |
|
126 // @see header file |
|
127 //--------------------------------------------------------------- |
|
128 void MsgConversationView::setupView() |
|
129 { |
|
130 // Create HbListView and set properties |
|
131 mConversationList = new HbListView(); |
|
132 if (!HbStyleLoader::registerFilePath(":/layouts")) { |
|
133 QDEBUG_WRITE("ERROR: ConversationView -> HbStyleLoader::registerFilePath"); |
|
134 } |
|
135 mConversationList->setLayoutName("custom"); |
|
136 mConversationList->setItemRecycling(true); |
|
137 MsgConversationViewItem *item = new MsgConversationViewItem(this); |
|
138 HbFrameBackground defaultBackground; |
|
139 defaultBackground.setFrameGraphicsName(QString("")); |
|
140 item->setDefaultFrame(defaultBackground); |
|
141 mConversationList->setItemPrototype(item); |
|
142 mConversationList->setSelectionMode(HbListView::NoSelection); |
|
143 mConversationList->setClampingStyle(HbScrollArea::BounceBackClamping); |
|
144 mConversationList->setScrollingStyle(HbScrollArea::PanOrFlick); |
|
145 |
|
146 mMessageModel = ConversationsEngine::instance()->getConversationsModel(); |
|
147 |
|
148 connect(ConversationsEngine::instance(), |
|
149 SIGNAL(conversationModelPopulated()), |
|
150 this, |
|
151 SLOT(populateConversationsView())); |
|
152 |
|
153 connect(mConversationList, SIGNAL(activated(QModelIndex)), |
|
154 this, SLOT(openItem(QModelIndex))); |
|
155 |
|
156 // Long tap list item |
|
157 connect(mConversationList, SIGNAL(longPressed(HbAbstractViewItem*, QPointF)), |
|
158 this, SLOT(longPressed(HbAbstractViewItem*, QPointF))); |
|
159 |
|
160 // Create message editor widget, will be displayed based on msg type. |
|
161 mEditorWidget = new MsgEditorWidget(this); |
|
162 mEditorWidget->hide(); |
|
163 |
|
164 connect(mEditorWidget, SIGNAL(sendMessage()), this, SLOT(send())); |
|
165 connect(mEditorWidget, SIGNAL(smsCharLimitReached()), |
|
166 this, SLOT(handleSmsCharLimitReached())); |
|
167 connect(mEditorWidget, SIGNAL(replyStarted()), this, SIGNAL(replyStarted())); |
|
168 |
|
169 qreal spacing = HbDeviceProfile::profile(mConversationList).unitValue(); |
|
170 |
|
171 mMainLayout = new QGraphicsLinearLayout(Qt::Vertical,this); |
|
172 |
|
173 mMainLayout->setContentsMargins(CONTENT_MARGIN, CONTENT_MARGIN, |
|
174 CONTENT_MARGIN, CONTENT_MARGIN); |
|
175 mMainLayout->setSpacing(spacing); |
|
176 |
|
177 mMainLayout->addItem(mConversationList); |
|
178 |
|
179 setLayout(mMainLayout); |
|
180 |
|
181 //Create VKB instance and listen to VKB open and close signals for resizing the view. |
|
182 mVkbHost = new HbStaticVkbHost(this); |
|
183 connect(mVkbHost, SIGNAL(keypadOpened()), this, SLOT(vkbOpened())); |
|
184 connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(vkbClosed())); |
|
185 |
|
186 // Refresh view to show the header details |
|
187 refreshView(); |
|
188 } |
|
189 |
|
190 //--------------------------------------------------------------- |
|
191 // MsgConversationView::addMenu |
|
192 // @see header file |
|
193 //--------------------------------------------------------------- |
|
194 void MsgConversationView::setupMenu() |
|
195 { |
|
196 // Just create dummy menu. |
|
197 // Actual menu will be created in menuAboutToShow() |
|
198 HbMenu *mainMenu = this->menu(); |
|
199 HbAction* clearConversation = mainMenu->addAction(QString()); |
|
200 connect(mainMenu, SIGNAL(aboutToShow()), this, SLOT(menuAboutToShow())); |
|
201 } |
|
202 |
|
203 //--------------------------------------------------------------- |
|
204 // MsgConversationView::refreshView() |
|
205 // @see header file |
|
206 //--------------------------------------------------------------- |
|
207 void MsgConversationView::refreshView() |
|
208 { |
|
209 // Hide editor in case of BT conversations. |
|
210 qint64 convId = ConversationsEngine::instance()->getCurrentConversationId(); |
|
211 if (INVALID_CONVID != convId) { |
|
212 if (KBluetoothMsgsConversationId == convId) { |
|
213 mMainLayout->removeItem(mEditorWidget); |
|
214 mEditorWidget->hide(); |
|
215 mEditorWidget->setParent(this); |
|
216 } |
|
217 else { |
|
218 mMainLayout->addItem(mEditorWidget); |
|
219 TRAP_IGNORE(mEditorWidget->setEncodingSettingsL()); |
|
220 mEditorWidget->show(); |
|
221 } |
|
222 mContactCardWidget->updateContents(); |
|
223 } |
|
224 } |
|
225 |
|
226 //--------------------------------------------------------------- |
|
227 // MsgConversationView::scrollToBottom() |
|
228 // @see header file |
|
229 //--------------------------------------------------------------- |
|
230 void MsgConversationView::scrollToBottom() |
|
231 { |
|
232 const int rowCnt = mMessageModel->rowCount(); |
|
233 mConversationList->scrollTo( |
|
234 mMessageModel->index(rowCnt - 1, 0)); |
|
235 } |
|
236 |
|
237 //--------------------------------------------------------------- |
|
238 // MsgConversationView::longPressed |
|
239 // @see header file |
|
240 //--------------------------------------------------------------- |
|
241 void MsgConversationView::longPressed(HbAbstractViewItem* viewItem, |
|
242 const QPointF& point) |
|
243 { |
|
244 mItemLongPressed = true; |
|
245 |
|
246 MsgConversationViewItem* item = qgraphicsitem_cast< |
|
247 MsgConversationViewItem *> (viewItem); |
|
248 |
|
249 // Show the item-specific menu |
|
250 if (this->isVisible()) |
|
251 { |
|
252 //If message is in Sending state or is Scheduled to be sent later, |
|
253 //do not allow any operations on the message |
|
254 int sendingState = item->modelIndex().data(SendingState).toInt(); |
|
255 if(sendingState == ConvergedMessage::Scheduled || |
|
256 sendingState == ConvergedMessage::Sending || |
|
257 sendingState == ConvergedMessage::Waiting) |
|
258 { |
|
259 return; |
|
260 } |
|
261 // Create new menu |
|
262 HbMenu* contextMenu = new HbMenu(); |
|
263 contextMenu->setAttribute(Qt::WA_DeleteOnClose); |
|
264 contextMenu->setPreferredPos(point); |
|
265 setContextMenu(item, contextMenu, sendingState); |
|
266 contextMenu->show(); |
|
267 |
|
268 } |
|
269 else |
|
270 { |
|
271 // For cases where the long tap check failed |
|
272 mItemLongPressed = false; |
|
273 } |
|
274 } |
|
275 |
|
276 //--------------------------------------------------------------- |
|
277 // MsgConversationView::setContextMenu |
|
278 // @see header |
|
279 //--------------------------------------------------------------- |
|
280 |
|
281 void MsgConversationView::setContextMenu(MsgConversationViewItem* item, HbMenu* contextMenu, int sendingState) |
|
282 { |
|
283 addOpenItemToContextMenu(item , contextMenu,sendingState); |
|
284 addResendItemToContextMenu(item, contextMenu, sendingState); |
|
285 addForwardItemToContextMenu(item, contextMenu, sendingState); |
|
286 addDownloadItemToContextMenu(item, contextMenu); |
|
287 addDeleteItemToContextMenu(item, contextMenu, sendingState); |
|
288 addSaveItemToContextMenu(item , contextMenu,sendingState); |
|
289 } |
|
290 |
|
291 |
|
292 //--------------------------------------------------------------- |
|
293 // MsgEditorPrivate::addSaveItemToContextMenu |
|
294 // @see header |
|
295 //--------------------------------------------------------------- |
|
296 void MsgConversationView::addSaveItemToContextMenu(MsgConversationViewItem* item, |
|
297 HbMenu* contextMenu, int sendingState) |
|
298 { |
|
299 int messageSubType = item->modelIndex().data(MessageSubType).toInt(); |
|
300 int direction = item->modelIndex().data(Direction).toInt(); |
|
301 if ((messageSubType == ConvergedMessage::RingingTone) && |
|
302 (direction == ConvergedMessage::Incoming)) { |
|
303 HbAction *contextItem = contextMenu->addAction(LOC_COMMON_SAVE); |
|
304 connect(contextItem, SIGNAL(triggered()), this, SLOT(saveRingingTone())); |
|
305 } |
|
306 } |
|
307 |
|
308 //--------------------------------------------------------------- |
|
309 // MsgEditorPrivate::addOpenItemToContextMenu |
|
310 // @see header |
|
311 //--------------------------------------------------------------- |
|
312 |
|
313 void MsgConversationView::addOpenItemToContextMenu(MsgConversationViewItem* item, HbMenu* contextMenu, int sendingState) |
|
314 { |
|
315 int direction = item->modelIndex().data(Direction).toInt(); |
|
316 int messageType = item->modelIndex().data(MessageType).toInt(); |
|
317 int messageSubType = item->modelIndex().data(MessageSubType).toInt(); |
|
318 |
|
319 if((messageSubType == ConvergedMessage::VCal) || |
|
320 (messageSubType == ConvergedMessage::RingingTone) || |
|
321 (messageType == ConvergedMessage::MmsNotification)) |
|
322 { |
|
323 return; |
|
324 } |
|
325 |
|
326 if( (sendingState == ConvergedMessage::SentState ) || |
|
327 (sendingState == ConvergedMessage::Resend ) || |
|
328 (sendingState == ConvergedMessage::Failed ) || |
|
329 (direction == ConvergedMessage::Incoming)) |
|
330 { |
|
331 HbAction *contextItem = contextMenu->addAction(LOC_COMMON_OPEN); |
|
332 connect(contextItem, SIGNAL(triggered()),this, SLOT(openItem())); |
|
333 } |
|
334 |
|
335 } |
|
336 |
|
337 //--------------------------------------------------------------- |
|
338 // MsgEditorPrivate::addResendItemToContextMenu |
|
339 // @see header |
|
340 //--------------------------------------------------------------- |
|
341 |
|
342 void MsgConversationView::addResendItemToContextMenu(MsgConversationViewItem* item, HbMenu* contextMenu, int sendingState) |
|
343 { |
|
344 Q_UNUSED(item) |
|
345 int direction = item->modelIndex().data(Direction).toInt(); |
|
346 |
|
347 if( (direction == ConvergedMessage::Outgoing)&& |
|
348 ((sendingState == ConvergedMessage::Resend ) || |
|
349 (sendingState == ConvergedMessage::Suspended )|| |
|
350 (sendingState == ConvergedMessage::Failed ))) |
|
351 { |
|
352 HbAction *contextItem = contextMenu->addAction(LOC_COMMON_SEND); |
|
353 connect(contextItem, SIGNAL(triggered()),this, SLOT(resendMessage())); |
|
354 } |
|
355 } |
|
356 |
|
357 //--------------------------------------------------------------- |
|
358 // MsgEditorPrivate::addForwardItemToContextMenu |
|
359 // @see header |
|
360 //--------------------------------------------------------------- |
|
361 void MsgConversationView::addForwardItemToContextMenu(MsgConversationViewItem* item, HbMenu* contextMenu, int sendingState) |
|
362 { |
|
363 int messageType = item->modelIndex().data(MessageType).toInt(); |
|
364 int direction = item->modelIndex().data(Direction).toInt(); |
|
365 int messageSubType = item->modelIndex().data(MessageSubType).toInt(); |
|
366 |
|
367 if( (messageType == ConvergedMessage::BT) || |
|
368 (messageType == ConvergedMessage::MmsNotification) || |
|
369 (messageSubType == ConvergedMessage::Provisioning ) || |
|
370 (messageSubType == ConvergedMessage::RingingTone) || |
|
371 (messageSubType == ConvergedMessage::VCal)) |
|
372 { |
|
373 return; |
|
374 } |
|
375 |
|
376 qint32 messageId = item->modelIndex().data(ConvergedMsgId).toInt(); |
|
377 |
|
378 if( ((sendingState == ConvergedMessage::SentState) || |
|
379 (sendingState == ConvergedMessage::Resend) || |
|
380 (sendingState == ConvergedMessage::Failed) || |
|
381 (direction == ConvergedMessage::Incoming) ) && |
|
382 (validateMsgForForward(messageType,messageId)) ) |
|
383 { |
|
384 HbAction *contextItem = contextMenu->addAction(LOC_COMMON_FORWARD); |
|
385 connect(contextItem, SIGNAL(triggered()),this, SLOT(forwardMessage())); |
|
386 } |
|
387 |
|
388 } |
|
389 |
|
390 //--------------------------------------------------------------- |
|
391 // MsgEditorPrivate::addDeleteItemToContextMenu |
|
392 // @see header |
|
393 //--------------------------------------------------------------- |
|
394 void MsgConversationView::addDeleteItemToContextMenu(MsgConversationViewItem* item, HbMenu* contextMenu, int sendingState) |
|
395 { |
|
396 int direction = item->modelIndex().data(Direction).toInt(); |
|
397 int messageType = item->modelIndex().data(MessageType).toInt(); |
|
398 int notificationState = item->modelIndex().data(NotificationStatus).toInt(); |
|
399 |
|
400 if( (messageType == ConvergedMessage::MmsNotification) && |
|
401 ((notificationState == ConvergedMessage::NotifNull) || |
|
402 (notificationState == ConvergedMessage::NotifRetrieving) || |
|
403 (notificationState == ConvergedMessage::NotifWaiting))) |
|
404 { |
|
405 return; |
|
406 } |
|
407 |
|
408 if( (sendingState == ConvergedMessage::SentState) || |
|
409 (sendingState == ConvergedMessage::Resend) || |
|
410 (sendingState == ConvergedMessage::Suspended) || |
|
411 (sendingState == ConvergedMessage::Failed) || |
|
412 (direction == ConvergedMessage::Incoming)) |
|
413 { |
|
414 HbAction *contextItem = contextMenu->addAction(LOC_COMMON_DELETE); |
|
415 connect(contextItem, SIGNAL(triggered()),this, SLOT(deleteItem())); |
|
416 } |
|
417 } |
|
418 |
|
419 //--------------------------------------------------------------- |
|
420 // MsgEditorPrivate::addDownloadItemToContextMenu |
|
421 // @see header |
|
422 //--------------------------------------------------------------- |
|
423 void MsgConversationView::addDownloadItemToContextMenu(MsgConversationViewItem* item, HbMenu* contextMenu) |
|
424 { |
|
425 int notificationState = item->modelIndex().data(NotificationStatus).toInt(); |
|
426 int messageType = item->modelIndex().data(MessageType).toInt(); |
|
427 qint32 messageId = item->modelIndex().data(ConvergedMsgId).toLongLong(); |
|
428 |
|
429 if( messageType == ConvergedMessage::MmsNotification && |
|
430 ConversationsEngine::instance()->downloadOperationSupported(messageId)) |
|
431 { |
|
432 HbAction *contextItem = contextMenu->addAction(LOC_COMMON_DOWNLOAD); |
|
433 connect(contextItem, SIGNAL(triggered()),this, SLOT(downloadMessage())); |
|
434 } |
|
435 } |
|
436 //--------------------------------------------------------------- |
|
437 // MsgEditorPrivate::send |
|
438 // @see header |
|
439 //--------------------------------------------------------------- |
|
440 void MsgConversationView::send() |
|
441 { |
|
442 activateInputBlocker(); |
|
443 ConvergedMessageAddressList addresses; |
|
444 addresses = mContactCardWidget->address(); |
|
445 int sendResult = KErrNone; |
|
446 |
|
447 // Populate the ConvergedMessage. |
|
448 if (!addresses.isEmpty()) |
|
449 { |
|
450 ConvergedMessage msg; |
|
451 populateForSending(msg); |
|
452 msg.addToRecipients(addresses); |
|
453 |
|
454 // Send |
|
455 sendResult = mSendUtil->send(msg); |
|
456 |
|
457 if( sendResult == KErrNone) |
|
458 { |
|
459 mEditorWidget->clear(); |
|
460 } |
|
461 } |
|
462 deactivateInputBlocker(); |
|
463 if( sendResult == KErrNotFound) |
|
464 { |
|
465 HbMessageBox::question(LOC_DIALOG_SMS_SETTINGS_INCOMPLETE, this, SLOT(onDialogSettingsLaunch(HbAction*)), LOC_BUTTON_OK, LOC_BUTTON_CANCEL); |
|
466 } |
|
467 } |
|
468 |
|
469 //--------------------------------------------------------------- |
|
470 // MsgConversationView::contactsFetchedForVCards |
|
471 // @see header file |
|
472 //--------------------------------------------------------------- |
|
473 void MsgConversationView::contactsFetchedForVCards(const QVariant& value) |
|
474 { |
|
475 // get received contact-list and launch unieditor |
|
476 CntServicesContactList contactList = |
|
477 qVariantValue<CntServicesContactList>(value); |
|
478 int cntCount = contactList.count(); |
|
479 if(cntCount > 0) |
|
480 { |
|
481 QVariantList params; |
|
482 params << MsgBaseView::ADD_VCARD; |
|
483 params << value; |
|
484 launchUniEditor(params); |
|
485 } |
|
486 } |
|
487 |
|
488 //--------------------------------------------------------------- |
|
489 // MsgConversationView::fetchContacts |
|
490 // @see header file |
|
491 //--------------------------------------------------------------- |
|
492 void MsgConversationView::fetchContacts() |
|
493 { |
|
494 HbAction* action = qobject_cast<HbAction*>(sender()); |
|
495 |
|
496 if(!action) |
|
497 return; |
|
498 |
|
499 QList<QVariant> args; |
|
500 QString serviceName("com.nokia.services.phonebookservices"); |
|
501 QString operation("fetch(QString,QString,QString)"); |
|
502 XQAiwRequest* request; |
|
503 XQApplicationManager appManager; |
|
504 request = appManager.create(serviceName, "Fetch", operation, true); //embedded |
|
505 if ( request == NULL ) |
|
506 { |
|
507 return; |
|
508 } |
|
509 |
|
510 int mode = action->data().toInt(); |
|
511 |
|
512 if( VCARD_INSERTION_MODE == mode) //vcard-insert mode |
|
513 { |
|
514 connect(request, SIGNAL(requestOk(const QVariant&)), |
|
515 this, SLOT(contactsFetchedForVCards(const QVariant&))); |
|
516 } |
|
517 else //contact-insert mode |
|
518 { |
|
519 connect(request, SIGNAL(requestOk(const QVariant&)), |
|
520 this, SLOT(contactsFetched(const QVariant&))); |
|
521 } |
|
522 connect (request, SIGNAL(requestError(int,const QString&)), |
|
523 this, SLOT(serviceRequestError(int,const QString&))); |
|
524 |
|
525 args << QString(tr("Phonebook")); |
|
526 args << KCntActionAll; |
|
527 args << KCntFilterDisplayAll; |
|
528 |
|
529 request->setArguments(args); |
|
530 request->send(); |
|
531 delete request; |
|
532 } |
|
533 //--------------------------------------------------------------- |
|
534 // MsgConversationView::fetchImages |
|
535 // @see header file |
|
536 //--------------------------------------------------------------- |
|
537 void MsgConversationView::fetchImages() |
|
538 { |
|
539 QString interface("Image"); |
|
540 QString operation("fetch(QVariantMap,QVariant)"); |
|
541 XQAiwRequest* request = NULL; |
|
542 XQApplicationManager appManager; |
|
543 request = appManager.create(interface, operation, true); // embedded |
|
544 request->setSynchronous(true); // synchronous |
|
545 if(!request) |
|
546 { |
|
547 QDEBUG_WRITE("AIW-ERROR: NULL request"); |
|
548 return; |
|
549 } |
|
550 |
|
551 connect(request, SIGNAL(requestOk(const QVariant&)), |
|
552 this, SLOT(imagesFetched(const QVariant&))); |
|
553 connect(request, SIGNAL(requestError(int,const QString&)), |
|
554 this, SLOT(serviceRequestError(int,const QString&))); |
|
555 |
|
556 // Set arguments for request |
|
557 QList<QVariant> args; |
|
558 args << QVariantMap(); |
|
559 args << QVariant(); |
|
560 request->setArguments(args); |
|
561 // Make the request |
|
562 if (!request->send()) |
|
563 { |
|
564 QDEBUG_WRITE_FORMAT("AIW-ERROR: Request Send failed:" , request->lastError()); |
|
565 } |
|
566 delete request; |
|
567 } |
|
568 |
|
569 //--------------------------------------------------------------- |
|
570 // MsgConversationView::fetchAudio |
|
571 // @see header file |
|
572 //--------------------------------------------------------------- |
|
573 void MsgConversationView::fetchAudio() |
|
574 { |
|
575 QString service("musicplayer"); |
|
576 QString interface("com.nokia.symbian.IMusicFetch"); |
|
577 QString operation("fetch()"); |
|
578 XQAiwRequest* request = NULL; |
|
579 XQApplicationManager appManager; |
|
580 request = appManager.create(service, interface, operation, true); //embedded |
|
581 request->setSynchronous(true); // synchronous |
|
582 if(!request) |
|
583 { |
|
584 QDEBUG_WRITE("AIW-ERROR: NULL request"); |
|
585 return; |
|
586 } |
|
587 |
|
588 connect(request, SIGNAL(requestOk(const QVariant&)), |
|
589 this, SLOT(audiosFetched(const QVariant&))); |
|
590 connect(request, SIGNAL(requestError(int,const QString&)), |
|
591 this, SLOT(serviceRequestError(int,const QString&))); |
|
592 |
|
593 // Make the request |
|
594 if (!request->send()) |
|
595 { |
|
596 QDEBUG_WRITE_FORMAT("AIW-ERROR: Request Send failed ",request->lastError()); |
|
597 } |
|
598 delete request; |
|
599 } |
|
600 |
|
601 //--------------------------------------------------------------- |
|
602 // MsgConversationView::contactsFetched |
|
603 // @see header file |
|
604 //--------------------------------------------------------------- |
|
605 void MsgConversationView::contactsFetched(const QVariant& value) |
|
606 { |
|
607 CntServicesContactList contactList = |
|
608 qVariantValue<CntServicesContactList>(value); |
|
609 int count = contactList.count(); |
|
610 if(count > 0) |
|
611 { |
|
612 QVariantList params; |
|
613 params << MsgBaseView::ADD_RECIPIENTS; |
|
614 params << value; |
|
615 launchUniEditor(params); |
|
616 } |
|
617 } |
|
618 |
|
619 //--------------------------------------------------------------- |
|
620 // MsgConversationView::imagesFetched() |
|
621 // @see header file |
|
622 //--------------------------------------------------------------- |
|
623 void MsgConversationView::imagesFetched(const QVariant& result ) |
|
624 { |
|
625 if(result.canConvert<QStringList>()) |
|
626 { |
|
627 QStringList fileList = result.value<QStringList>(); |
|
628 if ( fileList.size()>0 ) |
|
629 { |
|
630 QString filepath(QDir::toNativeSeparators(fileList.at(0))); |
|
631 QVariantList params; |
|
632 params << MsgBaseView::ADD_PHOTO; |
|
633 params << filepath; |
|
634 launchUniEditor(params); |
|
635 } |
|
636 } |
|
637 } |
|
638 |
|
639 //--------------------------------------------------------------- |
|
640 // MsgConversationView::audiosFetched() |
|
641 // @see header file |
|
642 //--------------------------------------------------------------- |
|
643 void MsgConversationView::audiosFetched(const QVariant& result ) |
|
644 { |
|
645 if(result.canConvert<QStringList>()) |
|
646 { |
|
647 QStringList fileList = result.value<QStringList>(); |
|
648 if ( fileList.size()>0 && !fileList.at(0).isEmpty()) |
|
649 { |
|
650 QString filepath(QDir::toNativeSeparators(fileList.at(0))); |
|
651 QVariantList params; |
|
652 params << MsgBaseView::ADD_AUDIO; |
|
653 params << filepath; |
|
654 launchUniEditor(params); |
|
655 } |
|
656 } |
|
657 } |
|
658 |
|
659 //--------------------------------------------------------------- |
|
660 // MsgConversationView::addSubject() |
|
661 // @see header file |
|
662 //--------------------------------------------------------------- |
|
663 void MsgConversationView::addSubject() |
|
664 { |
|
665 |
|
666 QString filepath; |
|
667 QVariantList params; |
|
668 params << MsgBaseView::ADD_SUBJECT; |
|
669 launchUniEditor(params); |
|
670 } |
|
671 |
|
672 //--------------------------------------------------------------- |
|
673 // MsgConversationView::forwardMessage() |
|
674 // Forwards the message |
|
675 //--------------------------------------------------------------- |
|
676 void MsgConversationView::forwardMessage() |
|
677 { |
|
678 QModelIndex index = mConversationList->currentIndex(); |
|
679 //messageId & messageType to be forwarded |
|
680 qint32 messageId = index.data(ConvergedMsgId).toLongLong(); |
|
681 int messageType = index.data(MessageType).toInt(); |
|
682 |
|
683 //Mark the message to read before forwarding. |
|
684 if(index.data(UnReadStatus).toBool()) |
|
685 { |
|
686 QList<int> msgIdList; |
|
687 msgIdList.append(messageId); |
|
688 ConversationsEngine::instance()->markMessagesRead(msgIdList); |
|
689 } |
|
690 // populate params and launch editor |
|
691 QVariantList params; |
|
692 params << MsgBaseView::FORWARD_MSG; |
|
693 params << messageId; |
|
694 params << messageType; |
|
695 launchUniEditor(params); |
|
696 } |
|
697 |
|
698 //--------------------------------------------------------------- |
|
699 // MsgConversationView::resendMessage() |
|
700 // Resends the message in the failed messages case |
|
701 //--------------------------------------------------------------- |
|
702 void MsgConversationView::resendMessage() |
|
703 { |
|
704 QModelIndex index = mConversationList->currentIndex(); |
|
705 if(index.isValid()) |
|
706 { |
|
707 qint32 messageId = index.data(ConvergedMsgId).toLongLong(); |
|
708 if(!(ConversationsEngine::instance()->resendMessage(messageId))) |
|
709 { |
|
710 HbMessageBox::warning(LOC_MSG_SEND_FAILED); |
|
711 } |
|
712 } |
|
713 |
|
714 } |
|
715 |
|
716 //--------------------------------------------------------------- |
|
717 // MsgConversationView::downloadMessage() |
|
718 // @see header |
|
719 //--------------------------------------------------------------- |
|
720 void MsgConversationView::downloadMessage() |
|
721 { |
|
722 QModelIndex index = mConversationList->currentIndex(); |
|
723 if(index.isValid()) |
|
724 { |
|
725 qint32 messageId = index.data(ConvergedMsgId).toLongLong(); |
|
726 if(ConversationsEngine::instance()->downloadMessage(messageId)!=KErrNone) |
|
727 { |
|
728 HbMessageBox::warning("Message Retrieval Failed!"); //TODO: use logical str name |
|
729 } |
|
730 } |
|
731 |
|
732 } |
|
733 |
|
734 //--------------------------------------------------------------- |
|
735 // MsgConversationView::deleteItem() |
|
736 // Deletes the message |
|
737 //--------------------------------------------------------------- |
|
738 void MsgConversationView::deleteItem() |
|
739 { |
|
740 HbMessageBox::question(LOC_DELETE_MESSAGE,this,SLOT(onDialogdeleteMsg(HbAction*)), |
|
741 LOC_BUTTON_DELETE, |
|
742 LOC_BUTTON_CANCEL); |
|
743 } |
|
744 |
|
745 //--------------------------------------------------------------- |
|
746 // MsgConversationView::openItem() |
|
747 // Opens the message |
|
748 //--------------------------------------------------------------- |
|
749 void MsgConversationView::openItem() |
|
750 { |
|
751 QModelIndex index = mConversationList->currentIndex(); |
|
752 openItem(index); |
|
753 } |
|
754 |
|
755 //--------------------------------------------------------------- |
|
756 // MsgConversationView::clearEditors() |
|
757 // @See header |
|
758 //--------------------------------------------------------------- |
|
759 void MsgConversationView::clearEditors() |
|
760 { |
|
761 mEditorWidget->clear(); |
|
762 mConversationList->setModel(NULL); |
|
763 mContactCardWidget->clearContent(); |
|
764 } |
|
765 |
|
766 //--------------------------------------------------------------- |
|
767 // MsgConversationView::saveContentToDrafts() |
|
768 // @See header |
|
769 //--------------------------------------------------------------- |
|
770 bool MsgConversationView::saveContentToDrafts() |
|
771 { |
|
772 int msgId = INVALID_MSGID; |
|
773 if(!mEditorWidget->content().isEmpty()) |
|
774 { |
|
775 activateInputBlocker(); |
|
776 ConvergedMessageAddressList addresses; |
|
777 addresses = mContactCardWidget->address(); |
|
778 |
|
779 // Populate the ConvergedMessage. |
|
780 if (!addresses.isEmpty()) |
|
781 { |
|
782 ConvergedMessage msg; |
|
783 populateForSending(msg); |
|
784 msg.addToRecipients(addresses); |
|
785 |
|
786 // save to drafts |
|
787 msgId = mSendUtil->saveToDrafts(msg); |
|
788 |
|
789 mEditorWidget->clear(); |
|
790 } |
|
791 deactivateInputBlocker(); |
|
792 } |
|
793 return ((msgId > INVALID_MSGID)? true : false); |
|
794 } |
|
795 |
|
796 //--------------------------------------------------------------- |
|
797 //MsgConversationView::populateForSending() |
|
798 //@see header |
|
799 //--------------------------------------------------------------- |
|
800 void MsgConversationView::populateForSending(ConvergedMessage &message) |
|
801 { |
|
802 message.setMessageType(ConvergedMessage::Sms); |
|
803 message.setBodyText(mEditorWidget->content()); |
|
804 message.setDirection(ConvergedMessage::Outgoing); |
|
805 QDateTime time = QDateTime::currentDateTime(); |
|
806 message.setTimeStamp(time.toTime_t()); |
|
807 } |
|
808 |
|
809 //--------------------------------------------------------------- |
|
810 //MsgConversationView::launchBtDisplayService() |
|
811 //@see header |
|
812 //--------------------------------------------------------------- |
|
813 void MsgConversationView::launchBtDisplayService(const QModelIndex & index) |
|
814 { |
|
815 qint32 messageId = index.data(ConvergedMsgId).toLongLong(); |
|
816 |
|
817 QString interface("com.nokia.services.btmsgdispservices.displaymsg"); |
|
818 QString operation("displaymsg(int)"); |
|
819 |
|
820 XQServiceRequest request(interface, operation, false); |
|
821 |
|
822 request << messageId; |
|
823 |
|
824 bool result = request.send(); |
|
825 } |
|
826 |
|
827 //--------------------------------------------------------------- |
|
828 // MsgConversationView::menuAboutToShow() |
|
829 // @See header |
|
830 //--------------------------------------------------------------- |
|
831 void MsgConversationView::menuAboutToShow() |
|
832 { |
|
833 // Clear all the previously added actions. |
|
834 HbMenu *mainMenu = this->menu(); |
|
835 mainMenu->clearActions(); |
|
836 |
|
837 // Message type specific menu items |
|
838 QModelIndex index = ConversationsEngine::instance()->getConversationsModel()->index(0, 0); |
|
839 if (ConvergedMessage::BT != index.data(MessageType).toInt()) |
|
840 { |
|
841 // Attach sub-menu |
|
842 HbMenu *attachSubMenu = mainMenu->addMenu(LOC_ATTACH); |
|
843 |
|
844 attachSubMenu->addAction(LOC_PHOTO,this, SLOT(fetchImages())); |
|
845 attachSubMenu->addAction(LOC_SOUND,this, SLOT(fetchAudio())); |
|
846 |
|
847 HbAction* addVCard = attachSubMenu->addAction(LOC_VCARD); |
|
848 addVCard->setData(VCARD_INSERTION_MODE); |
|
849 connect(addVCard, SIGNAL(triggered()),this,SLOT(fetchContacts())); |
|
850 |
|
851 HbAction *addRecipients = mainMenu->addAction(LOC_ADD_RECIPIENTS); |
|
852 addRecipients->setData(CONTACT_INSERTION_MODE); |
|
853 connect(addRecipients, SIGNAL(triggered()), this, SLOT(fetchContacts())); |
|
854 |
|
855 mainMenu->addAction(LOC_ADD_SUBJECT,this, SLOT(addSubject())); |
|
856 } |
|
857 } |
|
858 |
|
859 //--------------------------------------------------------------- |
|
860 //MsgConversationView::openItem |
|
861 //@see header |
|
862 //--------------------------------------------------------------- |
|
863 void MsgConversationView::openItem(const QModelIndex & index) |
|
864 { |
|
865 // Return if invalid index. |
|
866 if (!index.isValid() || mVkbopened) |
|
867 { |
|
868 return; |
|
869 } |
|
870 |
|
871 if(mItemLongPressed) |
|
872 { |
|
873 //reset the flag |
|
874 mItemLongPressed = false; |
|
875 return; |
|
876 } |
|
877 |
|
878 int messageType = index.data(MessageType).toInt(); |
|
879 int messageSubType = index.data(MessageSubType).toInt(); |
|
880 |
|
881 if (ConvergedMessage::BioMsg == messageType) { |
|
882 if (ConvergedMessage::RingingTone == messageSubType) { |
|
883 HbMessageBox::question(LOC_DIALOG_SAVE_RINGTONE, this, |
|
884 SLOT(onDialogSaveTone(HbAction*)), LOC_COMMON_SAVE, LOC_BUTTON_CANCEL); |
|
885 return; |
|
886 } |
|
887 else if(ConvergedMessage::Provisioning == messageSubType) |
|
888 { |
|
889 int messageId = index.data(ConvergedMsgId).toInt(); |
|
890 handleProvisoningMsg(messageId); |
|
891 QList<int> msgIdList; |
|
892 if(index.data(UnReadStatus).toInt()) |
|
893 { |
|
894 msgIdList.clear(); |
|
895 msgIdList << messageId; |
|
896 ConversationsEngine::instance()->markMessagesRead(msgIdList); |
|
897 } |
|
898 return; |
|
899 } |
|
900 // Unsupported messages |
|
901 else if (ConvergedMessage::VCard == messageSubType |
|
902 || ConvergedMessage::VCal == messageSubType) { |
|
903 return; |
|
904 } |
|
905 } |
|
906 else if (ConvergedMessage::BT == messageType) { |
|
907 launchBtDisplayService(index); |
|
908 return; |
|
909 } |
|
910 else if(ConvergedMessage::MmsNotification == messageType) |
|
911 { |
|
912 qint32 messageId = index.data(ConvergedMsgId).toLongLong(); |
|
913 if(!ConversationsEngine::instance()->downloadOperationSupported(messageId)) |
|
914 { |
|
915 int notificationState = index.data(NotificationStatus).toInt(); |
|
916 if( notificationState == ConvergedMessage::NotifExpired) |
|
917 { |
|
918 deleteItem(); |
|
919 } |
|
920 return; |
|
921 } |
|
922 else |
|
923 { |
|
924 //TODO: use logical str name |
|
925 HbMessageBox::question("Download Message?",this,SLOT(onDialogDownLoadMsg(HbAction*)), |
|
926 LOC_COMMON_DOWNLOAD, |
|
927 LOC_BUTTON_CANCEL); |
|
928 return; |
|
929 } |
|
930 } |
|
931 |
|
932 ConvergedMessage message; |
|
933 // check whether message is in sending progress, then donot launch viewer. |
|
934 int location = index.data(MessageLocation).toInt(); |
|
935 int sendingState = index.data(SendingState).toInt(); |
|
936 |
|
937 //If message is in Sending state or is Scheduled to be sent later, |
|
938 //do not open the message |
|
939 if(sendingState == ConvergedMessage::Suspended || |
|
940 sendingState == ConvergedMessage::Scheduled || |
|
941 sendingState == ConvergedMessage::Sending || |
|
942 sendingState == ConvergedMessage::Waiting) |
|
943 { |
|
944 return; |
|
945 } |
|
946 |
|
947 //TODO: sendingState check should be removed once msg |
|
948 // movement lock issue is resolved from mw |
|
949 if( !((location == ConvergedMessage::Inbox) || |
|
950 (location == ConvergedMessage::Sent) || |
|
951 (sendingState == ConvergedMessage::SentState)|| |
|
952 (sendingState == ConvergedMessage::Failed) || |
|
953 (sendingState == ConvergedMessage::Resend))) |
|
954 {// do not launch viewer, show a note |
|
955 HbNotificationDialog* dlg = new HbNotificationDialog(); |
|
956 dlg->setFocusPolicy(Qt::NoFocus); |
|
957 QString text(tr("Message Locked")); |
|
958 dlg->setText(text); |
|
959 dlg->setDismissPolicy(HbPopup::TapAnywhere); |
|
960 dlg->setAttribute(Qt::WA_DeleteOnClose, true); |
|
961 dlg->show(); |
|
962 return; |
|
963 } |
|
964 |
|
965 // message id |
|
966 qint32 messageId = index.data(ConvergedMsgId).toLongLong(); |
|
967 ConvergedMessageId msgId(messageId); |
|
968 message.setMessageId(msgId); |
|
969 |
|
970 // contact Id |
|
971 qint32 contactId = index.data(ContactId).toLongLong(); |
|
972 |
|
973 // message type |
|
974 |
|
975 message.setMessageType((ConvergedMessage::MessageType) messageType); |
|
976 message.setMessageSubType((ConvergedMessage::MessageSubType) messageSubType); |
|
977 |
|
978 if (messageType == ConvergedMessage::Mms) |
|
979 { |
|
980 message.setSubject(index.data(Subject).toString()); |
|
981 message.setPriority((ConvergedMessage::Priority) index.data( |
|
982 MessagePriority).toInt()); |
|
983 } |
|
984 else if (messageType == ConvergedMessage::IM) |
|
985 { |
|
986 // add body text and send to the message for IM case |
|
987 message.setBodyText(index.data(BodyText).toString()); |
|
988 } |
|
989 |
|
990 // time stamp |
|
991 message.setTimeStamp(index.data(TimeStamp).toLongLong()); |
|
992 |
|
993 //Message direction |
|
994 message.setDirection((ConvergedMessage::Direction)index.data(Direction).toInt()); |
|
995 |
|
996 // conatct name as address |
|
997 ConvergedMessageAddress address; |
|
998 address.setAlias(mContactCardWidget->address().at(0)->alias()); |
|
999 address.setAddress(mContactCardWidget->address().at(0)->address()); |
|
1000 message.addToRecipient(address); |
|
1001 |
|
1002 // Mark this message as read if its unread |
|
1003 QByteArray dataArray; |
|
1004 QDataStream messageStream |
|
1005 (&dataArray, QIODevice::WriteOnly | QIODevice::Append); |
|
1006 message.serialize(messageStream); |
|
1007 //if message unread, mark as read before opening view |
|
1008 QList<int> msgIdList; |
|
1009 if(index.data(UnReadStatus).toInt()) |
|
1010 { |
|
1011 msgIdList.clear(); |
|
1012 msgIdList << messageId; |
|
1013 ConversationsEngine::instance()->markMessagesRead(msgIdList); |
|
1014 } |
|
1015 |
|
1016 //switch view |
|
1017 QVariantList param; |
|
1018 param << MsgBaseView::UNIVIEWER; // target view |
|
1019 param << MsgBaseView::CV; // source view |
|
1020 |
|
1021 param << contactId; |
|
1022 param << dataArray; |
|
1023 param << mMessageModel->rowCount(); |
|
1024 |
|
1025 emit switchView(param); |
|
1026 } |
|
1027 |
|
1028 //--------------------------------------------------------------- |
|
1029 // MsgConversationView::launchUniEditor |
|
1030 // @see header file |
|
1031 //--------------------------------------------------------------- |
|
1032 void MsgConversationView::launchUniEditor(const QVariantList& data) |
|
1033 { |
|
1034 // param list for switching to editor view |
|
1035 QVariantList params; |
|
1036 QByteArray dataArray; |
|
1037 QDataStream messageStream |
|
1038 (&dataArray, QIODevice::WriteOnly | QIODevice::Append); |
|
1039 |
|
1040 // first arg is always the editor operation |
|
1041 int editorOperation = data.at(0).toInt(); |
|
1042 |
|
1043 ConvergedMessage message; |
|
1044 QVariant data2; |
|
1045 if( editorOperation != MsgBaseView::FORWARD_MSG ) |
|
1046 { |
|
1047 message.setBodyText(mEditorWidget->content()); |
|
1048 |
|
1049 // add address from contact-card to to-field |
|
1050 ConvergedMessageAddress address; |
|
1051 address.setAlias(mContactCardWidget->address().at(0)->alias()); |
|
1052 address.setAddress(mContactCardWidget->address().at(0)->address()); |
|
1053 message.addToRecipient(address); |
|
1054 |
|
1055 if(editorOperation == MsgBaseView::ADD_PHOTO || |
|
1056 editorOperation == MsgBaseView::ADD_AUDIO || |
|
1057 editorOperation == MsgBaseView::ADD_VIDEO ) |
|
1058 { |
|
1059 // filepath is sent in cases like ADD_PHOTO, ADD_AUDIO etc. |
|
1060 QString filepath; |
|
1061 filepath = data.at(1).toString(); |
|
1062 if(!filepath.isEmpty()) |
|
1063 { |
|
1064 ConvergedMessageAttachment* attachment = |
|
1065 new ConvergedMessageAttachment(filepath); |
|
1066 ConvergedMessageAttachmentList attachmentList; |
|
1067 attachmentList.append(attachment); |
|
1068 message.addAttachments(attachmentList); |
|
1069 } |
|
1070 } |
|
1071 else if(editorOperation == MsgBaseView::ADD_VCARD) |
|
1072 { |
|
1073 // filepath is not sent in cases like VCards & recipients |
|
1074 // instead, we will get a list of contacts. Pass it as it is. |
|
1075 data2 = data.at(1); |
|
1076 } |
|
1077 else if(editorOperation == MsgBaseView::ADD_RECIPIENTS) |
|
1078 { |
|
1079 ConvergedMessageAddressList addresses; |
|
1080 CntServicesContactList contactList = |
|
1081 qVariantValue<CntServicesContactList>(data.at(1)); |
|
1082 // now add fetched contacts from contact selection dialog |
|
1083 for(int i = 0; i < contactList.count(); i++ ) |
|
1084 { |
|
1085 ConvergedMessageAddress* address = new ConvergedMessageAddress; |
|
1086 address->setAlias(contactList[i].mDisplayName); |
|
1087 address->setAddress(contactList[i].mPhoneNumber); |
|
1088 addresses.append(address); |
|
1089 } |
|
1090 message.addToRecipients(addresses); |
|
1091 } |
|
1092 } |
|
1093 else |
|
1094 { |
|
1095 qint32 msgId = (qint32)data.at(1).toInt(); |
|
1096 int msgType = data.at(2).toInt(); |
|
1097 ConvergedMessageId id(msgId); |
|
1098 message.setMessageId(id); |
|
1099 message.setMessageType((ConvergedMessage::MessageType)msgType); |
|
1100 } |
|
1101 |
|
1102 message.serialize(messageStream); |
|
1103 params << MsgBaseView::UNIEDITOR; |
|
1104 params << MsgBaseView::CV; |
|
1105 params << dataArray; |
|
1106 params << editorOperation; |
|
1107 if(!data2.isNull()) |
|
1108 params << data2; |
|
1109 |
|
1110 clearEditors(); |
|
1111 emit switchView(params); |
|
1112 } |
|
1113 |
|
1114 //--------------------------------------------------------------- |
|
1115 // MsgConversationView::populateConversationsView |
|
1116 // @see header file |
|
1117 //--------------------------------------------------------------- |
|
1118 void MsgConversationView::populateConversationsView() |
|
1119 { |
|
1120 bool b = connect(ConversationsEngine::instance(), |
|
1121 SIGNAL(conversationModelUpdated()), |
|
1122 this, |
|
1123 SLOT(scrollToBottom())); |
|
1124 |
|
1125 mConversationList->setModel(mMessageModel); |
|
1126 |
|
1127 refreshView(); |
|
1128 scrollToBottom(); |
|
1129 } |
|
1130 |
|
1131 //--------------------------------------------------------------- |
|
1132 // MsgConversationView::saveRingingTone |
|
1133 // @see header file |
|
1134 //--------------------------------------------------------------- |
|
1135 void MsgConversationView::saveRingingTone() |
|
1136 { |
|
1137 QModelIndex index = mConversationList->currentIndex(); |
|
1138 int messageId = index.data(ConvergedMsgId).toInt(); |
|
1139 |
|
1140 UniDataModelLoader* pluginLoader = new UniDataModelLoader(); |
|
1141 UniDataModelPluginInterface* pluginInterface = |
|
1142 pluginLoader->getDataModelPlugin(ConvergedMessage::BioMsg); |
|
1143 pluginInterface->setMessageId(messageId); |
|
1144 UniMessageInfoList attachments = pluginInterface->attachmentList(); |
|
1145 if(attachments.count() > 0) |
|
1146 { |
|
1147 QString attachmentPath = attachments[0]->path(); |
|
1148 |
|
1149 RingBc* ringBc = new RingBc(); |
|
1150 |
|
1151 ringBc->saveTone(attachmentPath); |
|
1152 |
|
1153 // clear attachement list : its allocated at data model |
|
1154 while(!attachments.isEmpty()) |
|
1155 { |
|
1156 delete attachments.takeFirst(); |
|
1157 } |
|
1158 |
|
1159 delete ringBc; |
|
1160 } |
|
1161 delete pluginLoader; |
|
1162 } |
|
1163 |
|
1164 //--------------------------------------------------------------- |
|
1165 // MsgConversationView::handleSmsCharLimitReached |
|
1166 // @see header file |
|
1167 //--------------------------------------------------------------- |
|
1168 void MsgConversationView::handleSmsCharLimitReached() |
|
1169 { |
|
1170 QString filepath; |
|
1171 QVariantList params; |
|
1172 params << MsgBaseView::ADD_OTHERS; |
|
1173 launchUniEditor(params); |
|
1174 } |
|
1175 |
|
1176 //--------------------------------------------------------------- |
|
1177 // MsgConversationView::validateMsgForForward |
|
1178 // @see header file |
|
1179 //--------------------------------------------------------------- |
|
1180 bool MsgConversationView::validateMsgForForward(int &messageType, |
|
1181 qint32 &messageId) |
|
1182 { |
|
1183 bool retValue = true; |
|
1184 if (messageType == ConvergedMessage::Mms) |
|
1185 { |
|
1186 //Validate if the mms msg can be forwarded or not |
|
1187 MmsConformanceCheck* mmsConformanceCheck = new MmsConformanceCheck; |
|
1188 retValue = mmsConformanceCheck->validateMsgForForward(messageId); |
|
1189 |
|
1190 delete mmsConformanceCheck; |
|
1191 } |
|
1192 |
|
1193 return retValue; |
|
1194 } |
|
1195 |
|
1196 //--------------------------------------------------------------- |
|
1197 // MsgConversationView::vkbOpened |
|
1198 // @see header file |
|
1199 //--------------------------------------------------------------- |
|
1200 void MsgConversationView::vkbOpened() |
|
1201 { |
|
1202 mVkbopened = true; |
|
1203 |
|
1204 mContactCardWidget->connectSignals(false); |
|
1205 |
|
1206 emit hideChrome(true); |
|
1207 |
|
1208 QRectF appRect = mVkbHost->applicationArea(); |
|
1209 qreal spacing = 0.0; |
|
1210 qreal cardHeight = 0.0; |
|
1211 if(mContactCardWidget->isVisible()) |
|
1212 { |
|
1213 cardHeight = mContactCardWidget->rect().height(); |
|
1214 spacing = HbDeviceProfile::profile(this).unitValue(); |
|
1215 } |
|
1216 |
|
1217 this->setMaximumHeight(appRect.height()- cardHeight - spacing); |
|
1218 |
|
1219 disconnect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened())); |
|
1220 |
|
1221 scrollToBottom(); |
|
1222 } |
|
1223 |
|
1224 //--------------------------------------------------------------- |
|
1225 // MsgConversationView::vkbClosed |
|
1226 // @see header file |
|
1227 //--------------------------------------------------------------- |
|
1228 void MsgConversationView::vkbClosed() |
|
1229 { |
|
1230 mVkbopened = false; |
|
1231 |
|
1232 mContactCardWidget->connectSignals(true); |
|
1233 |
|
1234 emit hideChrome(false); |
|
1235 |
|
1236 this->setMaximumHeight(-1); |
|
1237 connect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened())); |
|
1238 |
|
1239 scrollToBottom(); |
|
1240 } |
|
1241 |
|
1242 //--------------------------------------------------------------- |
|
1243 // MsgConversationView::serviceRequestError |
|
1244 // @see header file |
|
1245 //--------------------------------------------------------------- |
|
1246 void MsgConversationView::serviceRequestError(int errorCode, const QString& errorMessage) |
|
1247 { |
|
1248 QDEBUG_WRITE_FORMAT(errorMessage,errorCode); |
|
1249 } |
|
1250 |
|
1251 //--------------------------------------------------------------- |
|
1252 // MsgConversationView::activateInputBlocker |
|
1253 // @see header file |
|
1254 //-------------------------------------------------------------- |
|
1255 void MsgConversationView::activateInputBlocker() |
|
1256 { |
|
1257 this->grabMouse(); |
|
1258 this->grabKeyboard(); |
|
1259 } |
|
1260 |
|
1261 //--------------------------------------------------------------- |
|
1262 // MsgConversationView::deactivateInputBlocker |
|
1263 // @see header file |
|
1264 //-------------------------------------------------------------- |
|
1265 void MsgConversationView::deactivateInputBlocker() |
|
1266 { |
|
1267 this->ungrabKeyboard(); |
|
1268 this->ungrabMouse(); |
|
1269 } |
|
1270 |
|
1271 //--------------------------------------------------------------- |
|
1272 // MsgConversationView::handleProvisoningMsg |
|
1273 // @see header file |
|
1274 //-------------------------------------------------------------- |
|
1275 void MsgConversationView::handleProvisoningMsg(int msgId) |
|
1276 { |
|
1277 QString messageId; |
|
1278 messageId.setNum(msgId); |
|
1279 |
|
1280 XQApplicationManager* aiwMgr = new XQApplicationManager(); |
|
1281 |
|
1282 XQAiwRequest* request = aiwMgr->create("com.nokia.services.MDM", |
|
1283 "Provisioning", |
|
1284 "ProcessMessage(QString)", true); // embedded |
|
1285 |
|
1286 if (request) { |
|
1287 QList<QVariant> args; |
|
1288 args << QVariant(messageId); |
|
1289 request->setArguments(args); |
|
1290 |
|
1291 // Send the request |
|
1292 bool res = request->send(); |
|
1293 |
|
1294 // Cleanup |
|
1295 delete request; |
|
1296 } |
|
1297 |
|
1298 delete aiwMgr; |
|
1299 } |
|
1300 |
|
1301 //--------------------------------------------------------------- |
|
1302 // MsgConversationView::onDialogSettingsLaunch |
|
1303 // @see header file |
|
1304 //-------------------------------------------------------------- |
|
1305 void MsgConversationView::onDialogSettingsLaunch(HbAction* action) |
|
1306 { |
|
1307 HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
|
1308 if (action == dlg->actions().at(0)) { |
|
1309 //switch to settings view |
|
1310 QVariantList param; |
|
1311 param << MsgBaseView::MSGSETTINGS; |
|
1312 param << MsgBaseView::CV; |
|
1313 param << MsgSettingsView::SMSView; |
|
1314 emit switchView(param); |
|
1315 } |
|
1316 |
|
1317 } |
|
1318 |
|
1319 //--------------------------------------------------------------- |
|
1320 // MsgConversationView::onDialogdeleteMsg |
|
1321 // @see header file |
|
1322 //-------------------------------------------------------------- |
|
1323 void MsgConversationView::onDialogdeleteMsg(HbAction* action) |
|
1324 { |
|
1325 HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
|
1326 if (action == dlg->actions().at(0)) { |
|
1327 QModelIndex index = mConversationList->currentIndex(); |
|
1328 if (index.isValid()) { |
|
1329 int count = mMessageModel->rowCount(); |
|
1330 //delete message |
|
1331 qint32 messageId = index.data(ConvergedMsgId).toLongLong(); |
|
1332 if (messageId) { |
|
1333 QList<int> msgIdList; |
|
1334 msgIdList.append(messageId); |
|
1335 ConversationsEngine::instance()->deleteMessages(msgIdList); |
|
1336 //switch view |
|
1337 if (count == 1) { |
|
1338 QVariantList param; |
|
1339 param << MsgBaseView::CLV; // target view |
|
1340 param << MsgBaseView::CV; // source view |
|
1341 emit switchView(param); |
|
1342 } |
|
1343 } |
|
1344 } |
|
1345 |
|
1346 } |
|
1347 |
|
1348 } |
|
1349 |
|
1350 //--------------------------------------------------------------- |
|
1351 // MsgConversationView::onDialogDownLoadMsg |
|
1352 // @see header file |
|
1353 //-------------------------------------------------------------- |
|
1354 void MsgConversationView::onDialogDownLoadMsg(HbAction* action) |
|
1355 { |
|
1356 HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
|
1357 if (action == dlg->actions().at(0)) { |
|
1358 downloadMessage(); |
|
1359 } |
|
1360 } |
|
1361 |
|
1362 //--------------------------------------------------------------- |
|
1363 // MsgConversationView::onDialogSaveTone |
|
1364 // @see header file |
|
1365 //-------------------------------------------------------------- |
|
1366 void MsgConversationView::onDialogSaveTone(HbAction* action) |
|
1367 { |
|
1368 HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
|
1369 if (action == dlg->actions().at(0)) { |
|
1370 saveRingingTone(); |
|
1371 } |
|
1372 } |
|
1373 |
|
1374 // EOF |