16 */ |
16 */ |
17 |
17 |
18 #include "msgconversationview.h" |
18 #include "msgconversationview.h" |
19 |
19 |
20 // SYSTEM INCLUDES |
20 // SYSTEM INCLUDES |
|
21 #include <hbapplication.h> |
21 #include <HbMenu> |
22 #include <HbMenu> |
22 #include <HbAction> |
23 #include <HbAction> |
23 #include <HbListView> |
24 #include <HbListView> |
24 #include <HbMessageBox> |
25 #include <HbMessageBox> |
25 #include <HbNotificationDialog> |
26 #include <HbNotificationDialog> |
26 #include <HbFrameBackground> |
27 #include <HbFrameBackground> |
27 #include <xqservicerequest.h> |
|
28 #include <HbStaticVkbHost> |
28 #include <HbStaticVkbHost> |
29 #include <HbStyleLoader> |
29 #include <HbStyleLoader> |
30 #include <xqaiwrequest.h> |
30 #include <xqaiwrequest.h> |
31 #include <xqappmgr.h> |
31 #include <xqappmgr.h> |
32 #include <HbMainWindow> |
32 #include <HbMainWindow> |
33 |
33 |
|
34 #include <QInputContext> |
34 #include <QDir> |
35 #include <QDir> |
35 #include <QDateTime> |
36 #include <QDateTime> |
36 #include <QGraphicsLinearLayout> |
37 #include <QGraphicsLinearLayout> |
37 #include <QStandardItemModel> |
38 #include <QStandardItemModel> |
38 |
39 |
55 #include "unidatamodelloader.h" |
56 #include "unidatamodelloader.h" |
56 #include "unidatamodelplugininterface.h" |
57 #include "unidatamodelplugininterface.h" |
57 #include "ringbc.h" |
58 #include "ringbc.h" |
58 #include "mmsconformancecheck.h" |
59 #include "mmsconformancecheck.h" |
59 #include "msgsettingsview.h" |
60 #include "msgsettingsview.h" |
60 #include "msgaudiofetcherview.h" |
|
61 #include "unieditorpluginloader.h" |
61 #include "unieditorpluginloader.h" |
62 #include "unieditorplugininterface.h" |
62 #include "unieditorplugininterface.h" |
|
63 #include "msgaudiofetcherdialog.h" |
63 |
64 |
64 //Item specific menu. |
65 //Item specific menu. |
65 |
66 |
66 #define LOC_COMMON_OPEN hbTrId("txt_common_menu_open") |
67 #define LOC_COMMON_OPEN hbTrId("txt_common_menu_open") |
67 #define LOC_COMMON_DELETE hbTrId("txt_common_menu_delete") |
68 #define LOC_COMMON_DELETE hbTrId("txt_common_menu_delete") |
131 // MsgConversationView::~MsgConversationView |
133 // MsgConversationView::~MsgConversationView |
132 // @see header file |
134 // @see header file |
133 //--------------------------------------------------------------- |
135 //--------------------------------------------------------------- |
134 MsgConversationView::~MsgConversationView() |
136 MsgConversationView::~MsgConversationView() |
135 { |
137 { |
136 |
138 //delete the popup dialog |
|
139 delete mDialog; |
137 } |
140 } |
138 //--------------------------------------------------------------- |
141 //--------------------------------------------------------------- |
139 // MsgConversationView::setupView |
142 // MsgConversationView::setupView |
140 // @see header file |
143 // @see header file |
141 //--------------------------------------------------------------- |
144 //--------------------------------------------------------------- |
483 { |
486 { |
484 mEditorWidget->clear(); |
487 mEditorWidget->clear(); |
485 } |
488 } |
486 } |
489 } |
487 deactivateInputBlocker(); |
490 deactivateInputBlocker(); |
|
491 |
|
492 // make sure virtual keyboard is closed |
|
493 QInputContext *ic = qApp->inputContext(); |
|
494 if (ic) { |
|
495 QEvent *closeEvent = new QEvent(QEvent::CloseSoftwareInputPanel); |
|
496 ic->filterEvent(closeEvent); |
|
497 delete closeEvent; |
|
498 } |
|
499 |
488 if( sendResult == KErrNotFound) |
500 if( sendResult == KErrNotFound) |
489 { |
501 { |
490 HbMessageBox::question(LOC_DIALOG_SMS_SETTINGS_INCOMPLETE, this, |
502 HbMessageBox::question(LOC_DIALOG_SMS_SETTINGS_INCOMPLETE, this, |
491 SLOT(onDialogSettingsLaunch(HbAction*)), |
503 SLOT(onDialogSettingsLaunch(HbAction*)), |
492 HbMessageBox::Ok | HbMessageBox::Cancel); |
504 HbMessageBox::Ok | HbMessageBox::Cancel); |
521 HbAction* action = qobject_cast<HbAction*>(sender()); |
533 HbAction* action = qobject_cast<HbAction*>(sender()); |
522 |
534 |
523 if(!action) |
535 if(!action) |
524 return; |
536 return; |
525 |
537 |
526 QList<QVariant> args; |
538 QString service("phonebookservices"); |
527 QString serviceName("com.nokia.services.phonebookservices"); |
539 QString interface("com.nokia.symbian.IContactsFetch"); |
528 QString operation("fetch(QString,QString,QString)"); |
540 QString operation("multiFetch(QString,QString)"); |
529 XQAiwRequest* request; |
541 XQAiwRequest* request; |
530 XQApplicationManager appManager; |
542 XQApplicationManager appManager; |
531 request = appManager.create(serviceName, "Fetch", operation, true); //embedded |
543 request = appManager.create(service, interface, operation, true); //embedded |
532 if ( request == NULL ) |
544 if ( request == NULL ) |
533 { |
545 { |
534 return; |
546 return; |
535 } |
547 } |
536 |
548 |
547 this, SLOT(contactsFetched(const QVariant&))); |
559 this, SLOT(contactsFetched(const QVariant&))); |
548 } |
560 } |
549 connect (request, SIGNAL(requestError(int,const QString&)), |
561 connect (request, SIGNAL(requestError(int,const QString&)), |
550 this, SLOT(serviceRequestError(int,const QString&))); |
562 this, SLOT(serviceRequestError(int,const QString&))); |
551 |
563 |
|
564 QList<QVariant> args; |
552 args << QString(tr("Phonebook")); |
565 args << QString(tr("Phonebook")); |
553 args << KCntActionAll; |
566 args << KCntActionAll; |
554 args << KCntFilterDisplayAll; |
567 args << KCntFilterDisplayAll; |
555 |
568 |
556 request->setArguments(args); |
569 request->setArguments(args); |
567 QString interface("com.nokia.symbian.IImageFetch"); |
580 QString interface("com.nokia.symbian.IImageFetch"); |
568 QString operation("fetch()"); |
581 QString operation("fetch()"); |
569 XQAiwRequest* request = NULL; |
582 XQAiwRequest* request = NULL; |
570 XQApplicationManager appManager; |
583 XQApplicationManager appManager; |
571 request = appManager.create(service,interface, operation, true); // embedded |
584 request = appManager.create(service,interface, operation, true); // embedded |
572 request->setSynchronous(true); // synchronous |
585 |
573 if(!request) |
586 if(!request) |
574 { |
587 { |
575 QDEBUG_WRITE("AIW-ERROR: NULL request"); |
588 QDEBUG_WRITE("AIW-ERROR: NULL request"); |
576 return; |
589 return; |
577 } |
590 } |
578 |
591 |
|
592 request->setSynchronous(true); // synchronous |
|
593 |
579 connect(request, SIGNAL(requestOk(const QVariant&)), |
594 connect(request, SIGNAL(requestOk(const QVariant&)), |
580 this, SLOT(imagesFetched(const QVariant&))); |
595 this, SLOT(imagesFetched(const QVariant&))); |
581 connect(request, SIGNAL(requestError(int,const QString&)), |
596 connect(request, SIGNAL(requestError(int,const QString&)), |
582 this, SLOT(serviceRequestError(int,const QString&))); |
597 this, SLOT(serviceRequestError(int,const QString&))); |
583 |
598 |
593 // MsgConversationView::fetchAudio |
608 // MsgConversationView::fetchAudio |
594 // @see header file |
609 // @see header file |
595 //--------------------------------------------------------------- |
610 //--------------------------------------------------------------- |
596 void MsgConversationView::fetchAudio() |
611 void MsgConversationView::fetchAudio() |
597 { |
612 { |
598 // Launch Audio fetcher view |
613 // Launch Audio fetcher dialog |
599 QVariantList params; |
614 if (!mDialog) |
600 QByteArray dataArray; |
615 { |
601 QDataStream messageStream |
616 mDialog = new MsgAudioFetcherDialog(); |
602 (&dataArray, QIODevice::WriteOnly | QIODevice::Append); |
617 bool b = connect(mDialog, |
603 |
618 SIGNAL(audioSelected(QString&)), |
604 ConvergedMessage message; |
619 this, |
605 message.setBodyText(mEditorWidget->content()); |
620 SLOT(onAudioSelected(QString&))); |
606 // add address from contact-card to to-field |
621 } |
607 ConvergedMessageAddress address; |
622 |
608 address.setAlias(mContactCardWidget->address().at(0)->alias()); |
623 //show the dialog |
609 address.setAddress(mContactCardWidget->address().at(0)->address()); |
624 mDialog->show(); |
610 message.addToRecipient(address); |
|
611 message.serialize(messageStream); |
|
612 |
|
613 params << MsgBaseView::AUDIOFETCHER; // target view |
|
614 params << MsgBaseView::CV; // source view |
|
615 params << dataArray; |
|
616 emit switchView(params); |
|
617 } |
625 } |
618 |
626 |
619 //--------------------------------------------------------------- |
627 //--------------------------------------------------------------- |
620 // MsgConversationView::contactsFetched |
628 // MsgConversationView::contactsFetched |
621 // @see header file |
629 // @see header file |
1486 delete pluginLoader; |
1493 delete pluginLoader; |
1487 |
1494 |
1488 return shared; |
1495 return shared; |
1489 } |
1496 } |
1490 |
1497 |
|
1498 //--------------------------------------------------------------- |
|
1499 // MsgConversationView::onAudioSelected |
|
1500 // @see header file |
|
1501 //--------------------------------------------------------------- |
|
1502 void MsgConversationView::onAudioSelected(QString& filePath) |
|
1503 { |
|
1504 QVariantList params; |
|
1505 QByteArray dataArray; |
|
1506 QDataStream messageStream |
|
1507 (&dataArray, QIODevice::WriteOnly | QIODevice::Append); |
|
1508 |
|
1509 ConvergedMessage message; |
|
1510 message.setBodyText(mEditorWidget->content()); |
|
1511 // add address from contact-card to to-field |
|
1512 ConvergedMessageAddress address; |
|
1513 address.setAlias(mContactCardWidget->address().at(0)->alias()); |
|
1514 address.setAddress(mContactCardWidget->address().at(0)->address()); |
|
1515 message.addToRecipient(address); |
|
1516 |
|
1517 //add the attachment as selected from audio picker |
|
1518 ConvergedMessageAttachment* attachment = |
|
1519 new ConvergedMessageAttachment(filePath); |
|
1520 ConvergedMessageAttachmentList attachmentList; |
|
1521 attachmentList.append(attachment); |
|
1522 message.addAttachments(attachmentList); |
|
1523 message.serialize(messageStream); |
|
1524 |
|
1525 params << MsgBaseView::UNIEDITOR; // target view |
|
1526 params << MsgBaseView::CV; // source view |
|
1527 params << dataArray; |
|
1528 params << MsgBaseView::ADD_AUDIO; |
|
1529 emit switchView(params); |
|
1530 } |
|
1531 |
|
1532 //--------------------------------------------------------------- |
|
1533 // MsgConversationView::handleKeyEvent |
|
1534 // @see header file |
|
1535 //--------------------------------------------------------------- |
|
1536 bool MsgConversationView::handleKeyEvent(int key) |
|
1537 { |
|
1538 bool eventHandled = false; |
|
1539 if (Qt::Key_Yes == key) { |
|
1540 //getting address of last sent/received msg. |
|
1541 const int rowCount = mMessageModel->rowCount(); |
|
1542 QModelIndex index = mMessageModel->index(rowCount - 1, 0); |
|
1543 QString address = index.data(ConversationAddress).toString(); |
|
1544 |
|
1545 if (!address.isEmpty()) { |
|
1546 call(address); |
|
1547 eventHandled = true; |
|
1548 } |
|
1549 } |
|
1550 return eventHandled; |
|
1551 } |
|
1552 |
|
1553 //--------------------------------------------------------------- |
|
1554 // MsgConversationView::call |
|
1555 // @see header |
|
1556 //--------------------------------------------------------------- |
|
1557 void MsgConversationView::call(const QString& address) |
|
1558 { |
|
1559 QString service("phoneui"); |
|
1560 QString interface("com.nokia.symbian.ICallDial"); |
|
1561 QString operation("dial(QString)"); |
|
1562 |
|
1563 XQApplicationManager appManager; |
|
1564 QScopedPointer<XQAiwRequest> request(appManager.create(service, interface, operation, false)); |
|
1565 if (request) { |
|
1566 QList<QVariant> args; |
|
1567 args << address; |
|
1568 request->setArguments(args); |
|
1569 request->send(); |
|
1570 } |
|
1571 } |
|
1572 |
1491 // EOF |
1573 // EOF |