77 mLatestLoadingSize(QSize(0,0)), |
77 mLatestLoadingSize(QSize(0,0)), |
78 mAttaIndexUnderFetch(NmNotFoundError), |
78 mAttaIndexUnderFetch(NmNotFoundError), |
79 mAttaWidget(NULL), |
79 mAttaWidget(NULL), |
80 mViewReady(false), |
80 mViewReady(false), |
81 mWaitNoteCancelled(false), |
81 mWaitNoteCancelled(false), |
82 mErrorNote(NULL) |
82 mErrorNote(NULL), |
|
83 mAttachmentOpen(false) |
83 { |
84 { |
84 // Create documentloader |
85 // Create documentloader |
85 mDocumentLoader = new NmUiDocumentLoader(mMainWindow); |
86 mDocumentLoader = new NmUiDocumentLoader(mMainWindow); |
86 // Get screensize |
87 // Get screensize |
87 mScreenSize = mApplication.screenSize(); |
88 mScreenSize = mApplication.screenSize(); |
520 } |
523 } |
521 } |
524 } |
522 // attachment is fetched, open file |
525 // attachment is fetched, open file |
523 else if (messageParts[i]->partId() == attaId) { |
526 else if (messageParts[i]->partId() == attaId) { |
524 mAttaManager.cancelFetch(); |
527 mAttaManager.cancelFetch(); |
525 XQSharableFile file = mUiEngine.messagePartFile(mailboxId, folderId, |
528 mAttachmentOpen = true; |
526 messageId, attaId); |
529 QObject::disconnect(mAttaWidget, SIGNAL(itemActivated(int)), |
527 int error = NmUtilities::openFile(file); |
530 this, SLOT(openAttachment(int))); |
528 file.close(); |
531 // We need to fill the part before opening the attachment. |
529 if (error==NmNotFoundError){ |
532 mUiEngine.contentToMessagePart(mailboxId, folderId, messageId, *(messageParts[i])); |
|
533 int error = NmUtilities::openAttachment(messageParts[i],mTempFiles,this); |
|
534 if (error==NmGeneralError){ |
|
535 mAttachmentOpen = false; |
|
536 QObject::connect(mAttaWidget, SIGNAL(itemActivated(int)), |
|
537 this, SLOT(openAttachment(int))); |
530 delete mErrorNote; |
538 delete mErrorNote; |
531 mErrorNote=NULL; |
539 mErrorNote=NULL; |
532 mErrorNote = NmUtilities::displayWarningNote( |
540 mErrorNote = NmUtilities::displayWarningNote( |
533 hbTrId("txt_mail_dialog_unable_to_open_attachment_file_ty")); |
541 hbTrId("txt_mail_dialog_unable_to_open_attachment_file_ty")); |
534 } |
542 } |
548 QString msg = ""; |
556 QString msg = ""; |
549 if (mMessage) { |
557 if (mMessage) { |
550 NmMessagePart *html = mMessage->htmlBodyPart(); |
558 NmMessagePart *html = mMessage->htmlBodyPart(); |
551 if (html) { |
559 if (html) { |
552 msg += formatHtmlMessage(html); |
560 msg += formatHtmlMessage(html); |
|
561 // Remove DOCTYPE definition as it will break viewer layout |
|
562 if (msg.startsWith("<!DOCTYPE", Qt::CaseInsensitive)) { |
|
563 int doctypeTagEnd = msg.indexOf(">",0,Qt::CaseInsensitive); |
|
564 msg.remove(0,doctypeTagEnd+1); |
|
565 } |
553 } |
566 } |
554 else { |
567 else { |
555 NmMessagePart *plain = mMessage->plainTextBodyPart(); |
568 NmMessagePart *plain = mMessage->plainTextBodyPart(); |
556 if (plain) { |
569 if (plain) { |
557 msg += formatPlainTextMessage(plain); |
570 msg += formatPlainTextMessage(plain); |
631 HbFontSpec fontSpec(HbFontSpec::Secondary); |
644 HbFontSpec fontSpec(HbFontSpec::Secondary); |
632 fontSpec.setTextHeight(secondarySize); |
645 fontSpec.setTextHeight(secondarySize); |
633 currentFont.setPixelSize(fontSpec.font().pixelSize()); |
646 currentFont.setPixelSize(fontSpec.font().pixelSize()); |
634 } |
647 } |
635 document.setDefaultFont(currentFont); |
648 document.setDefaultFont(currentFont); |
636 // convert to html |
649 // convert to html with html and body tags |
|
650 // for background and text color |
637 document.setPlainText(plain->textContent()); |
651 document.setPlainText(plain->textContent()); |
638 msg = document.toHtml(); |
652 msg += "<html><body bgcolor=white text=black>"; |
639 |
653 msg += document.toHtml(); |
|
654 msg += "</body></html>"; |
|
655 |
640 if (qApp->layoutDirection()==Qt::RightToLeft){ |
656 if (qApp->layoutDirection()==Qt::RightToLeft){ |
641 // add right alignment to document css section |
657 // add right alignment to document css section |
642 QRegExp rx("(<style type=\"text/css\">)(.+)(</style>)", Qt::CaseInsensitive); |
658 QRegExp rx("(<style type=\"text/css\">)(.+)(</style>)", Qt::CaseInsensitive); |
643 rx.setMinimal(true); |
659 rx.setMinimal(true); |
644 int pos = rx.indexIn(msg); |
660 int pos = rx.indexIn(msg); |
807 link.scheme() == NmHttpsLinkScheme) { |
823 link.scheme() == NmHttpsLinkScheme) { |
808 mAttaManager.cancelFetch(); |
824 mAttaManager.cancelFetch(); |
809 QDesktopServices::openUrl(link); |
825 QDesktopServices::openUrl(link); |
810 } else if (link.scheme() == NmMailtoLinkScheme){ |
826 } else if (link.scheme() == NmMailtoLinkScheme){ |
811 mAttaManager.cancelFetch(); |
827 mAttaManager.cancelFetch(); |
812 QList<NmAddress*> *addrList = new QList<NmAddress*>(); |
828 |
813 NmAddress *mailtoAddr = new NmAddress(); |
829 NmUriParser uriParser; |
814 QString address = link.toString(QUrl::RemoveScheme); |
830 if (uriParser.extractData(link.toString())) { |
815 mailtoAddr->setAddress(address); |
831 // Create start parameters. Address list ownership |
816 mailtoAddr->setDisplayName(address); |
832 // is transferred to startparam object |
817 addrList->append(mailtoAddr); |
833 // The ownership of these is passed to NmApplication in launchEditorView() |
818 // Create start parameters. Address list ownership |
834 QList<NmAddress*> *toAddresses = NmUtilities::qstringListToNmAddressList(uriParser.toAddresses()); |
819 // is transferred to startparam object |
835 QList<NmAddress*> *ccAddresses = NmUtilities::qstringListToNmAddressList(uriParser.ccAddresses()); |
820 NmUiStartParam* param = new NmUiStartParam(NmUiViewMessageEditor, |
836 QList<NmAddress*> *bccAddresses = NmUtilities::qstringListToNmAddressList(uriParser.bccAddresses()); |
821 mStartParam->mailboxId(), |
837 |
822 mStartParam->folderId(), |
838 QString* subject = new QString(uriParser.subject()); |
823 0, |
839 QString* bodyText = new QString(uriParser.bodyText()); |
824 NmUiEditorMailto, |
840 |
825 addrList); |
841 NmUiStartParam* param = new NmUiStartParam(NmUiViewMessageEditor, |
826 mApplication.enterNmUiView(param); |
842 mStartParam->mailboxId(), |
|
843 mStartParam->folderId(), |
|
844 0, // message id |
|
845 NmUiEditorMailto, // editor start mode |
|
846 toAddresses, |
|
847 NULL, // attachment list |
|
848 false, // start as service |
|
849 subject, // message subject |
|
850 ccAddresses, // cc recipients |
|
851 bccAddresses, //bcc recipients |
|
852 bodyText // body text |
|
853 ); |
|
854 |
|
855 |
|
856 mApplication.enterNmUiView(param); |
|
857 } |
|
858 |
827 } |
859 } |
828 } |
860 } |
829 |
861 |
830 /*! |
862 /*! |
831 Function can be used to check whether mouse event has |
863 Function can be used to check whether mouse event has |
1051 progressValueChanged(mAttaIndexUnderFetch, value); |
1083 progressValueChanged(mAttaIndexUnderFetch, value); |
1052 } |
1084 } |
1053 } |
1085 } |
1054 } |
1086 } |
1055 |
1087 |
1056 /*! |
1088 |
1057 This is called when attachment fetch is completed |
1089 /*! |
|
1090 This method is called when fetching an attachment is either completed or |
|
1091 cancelled. |
|
1092 |
|
1093 \param result The result code (NmNoError if success). |
1058 */ |
1094 */ |
1059 void NmViewerView::fetchCompleted(int result) |
1095 void NmViewerView::fetchCompleted(int result) |
1060 { |
1096 { |
1061 if (mAttaWidget && mAttaIndexUnderFetch != NmNotFoundError) { |
1097 if (mAttaWidget && mAttaIndexUnderFetch != NmNotFoundError) { |
1062 if (result == NmNoError) { |
1098 if (result == NmNoError) { |
1063 progressValueChanged(mAttaIndexUnderFetch, NmProgressValueComplete); |
1099 progressValueChanged(mAttaIndexUnderFetch, NmProgressValueComplete); |
1064 openAttachment(mAttaIndexUnderFetch); |
1100 openAttachment(mAttaIndexUnderFetch); |
1065 } else { |
1101 } else { |
1066 mAttaWidget->hideProgressBar(mAttaIndexUnderFetch); |
1102 mAttaWidget->hideProgressBar(mAttaIndexUnderFetch); |
1067 } |
1103 |
1068 } |
1104 if (result == NmDiskFullError) { |
|
1105 // Display an error message. |
|
1106 delete mErrorNote; |
|
1107 mErrorNote = NmUtilities::displayWarningNote( |
|
1108 hbTrId("txt_mail_dialog_downloading_canceled")); |
|
1109 } |
|
1110 |
|
1111 } |
|
1112 } |
|
1113 |
1069 mAttaIndexUnderFetch = NmNotFoundError; |
1114 mAttaIndexUnderFetch = NmNotFoundError; |
1070 } |
1115 } |
|
1116 |
1071 |
1117 |
1072 /*! |
1118 /*! |
1073 externalDelete. From NmUiEngine, handles viewer shutdown when current message is deleted. |
1119 externalDelete. From NmUiEngine, handles viewer shutdown when current message is deleted. |
1074 */ |
1120 */ |
1075 void NmViewerView::messageDeleted(const NmId &mailboxId, const NmId &folderId, const NmId &messageId) |
1121 void NmViewerView::messageDeleted(const NmId &mailboxId, const NmId &folderId, const NmId &messageId) |