Merge lp:~bobo-324/dekko/customScheme into lp:dekko/0.3

Proposed by Boren Zhang
Status: Merged
Merged at revision: 172
Proposed branch: lp:~bobo-324/dekko/customScheme
Merge into: lp:dekko/0.3
Diff against target: 197 lines (+106/-3)
8 files modified
CMakeLists.txt (+1/-0)
qml/MessageView/HtmlPart.qml (+5/-1)
qml/MessageView/ImagePart.qml (+3/-2)
qml/MessageView/OneMessagePage.qml (+1/-0)
src/app/Network/MsgPartNetAccessManagerFactory.cpp (+45/-0)
src/app/Network/MsgPartNetAccessManagerFactory.h (+43/-0)
src/app/PartWidget/NewPartWidget.cpp (+3/-0)
src/app/main.cpp (+5/-0)
To merge this branch: bzr merge lp:~bobo-324/dekko/customScheme
Reviewer Review Type Date Requested Status
Dan Chapman  Approve
Review via email: mp+243318@code.launchpad.net

Description of the change

This patch let you view cid image in html message by registering a networkAccessManagerFactory( MsgPartNetworkAccessFactory) to QMLEngin.

MsgPartNetworkAccessFactory is register as a context property "msgPartNetworkAccessFactory", so that we can set message modelIndex using function "msgPartNetworkAccessFactory.setMessageIndex()" in QML before displaying html message.

Using msgPartNetworkAccessFactory.setMessageIndex() will send messageIndex to all networkAccessManager that has been created. Because they will reuse networkAccessManager for different account.

Previewing image should also work now.

To post a comment you must log in.
Revision history for this message
Dan Chapman  (dpniel) wrote :

LGTM and works as expected. We should get a bug filed though for oxide not liking the the text/html; charset... bug. It would be much better to just give oxide the trojita-imap url here. Anyway it's working for now :-D \o/ no more QtWebkit in our future!!

Thanks for your work on this

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2014-11-21 05:16:54 +0000
+++ CMakeLists.txt 2014-12-01 18:56:12 +0000
@@ -480,6 +480,7 @@
480 ${DEKKO_UBUNTU_PATH}/app/PartWidget/SectionType.cpp480 ${DEKKO_UBUNTU_PATH}/app/PartWidget/SectionType.cpp
481 ${DEKKO_UBUNTU_PATH}/app/Utils/Path.cpp481 ${DEKKO_UBUNTU_PATH}/app/Utils/Path.cpp
482 ${DEKKO_UBUNTU_PATH}/app/Utils/PlainTextFormatter.cpp482 ${DEKKO_UBUNTU_PATH}/app/Utils/PlainTextFormatter.cpp
483 ${DEKKO_UBUNTU_PATH}/app/Network/MsgPartNetAccessManagerFactory.cpp
483 )484 )
484485
485 set(DEKKO_QML_COMPOSER486 set(DEKKO_QML_COMPOSER
486487
=== modified file 'qml/MessageView/HtmlPart.qml'
--- qml/MessageView/HtmlPart.qml 2014-11-07 18:25:29 +0000
+++ qml/MessageView/HtmlPart.qml 2014-12-01 18:56:12 +0000
@@ -18,7 +18,8 @@
18import QtQuick 2.218import QtQuick 2.2
19import Ubuntu.Components 1.119import Ubuntu.Components 1.1
20import Ubuntu.Components.Popups 1.020import Ubuntu.Components.Popups 1.0
21import Ubuntu.Web 0.221//import Ubuntu.Web 0.2
22import com.canonical.Oxide 1.3
22import DekkoCore 0.123import DekkoCore 0.1
2324
24WebView {25WebView {
@@ -35,6 +36,9 @@
3536
36 property alias msgPartIndex: plainTextFormatter.msgPartIndex37 property alias msgPartIndex: plainTextFormatter.msgPartIndex
3738
39 context: WebContext {
40 allowedExtraUrlSchemes: ["cid"]
41 }
38 //swtich section while webview is scrolling will crash42 //swtich section while webview is scrolling will crash
39 function disableSectionForAWhile() {43 function disableSectionForAWhile() {
40 oneMessagePage.head.sections.enabled = false;44 oneMessagePage.head.sections.enabled = false;
4145
=== modified file 'qml/MessageView/ImagePart.qml'
--- qml/MessageView/ImagePart.qml 2014-10-31 17:59:05 +0000
+++ qml/MessageView/ImagePart.qml 2014-12-01 18:56:12 +0000
@@ -20,7 +20,8 @@
20import Ubuntu.Components.Popups 1.020import Ubuntu.Components.Popups 1.0
2121
22Image {22Image {
23 Label {23 onSourceSizeChanged: {
24 text: "previewing image not supported"24 width = Math.min(oneMessagePage.width - units.gu(6), sourceSize.width)
25 height = width * sourceSize.height / sourceSize.width;
25 }26 }
26}27}
2728
=== modified file 'qml/MessageView/OneMessagePage.qml'
--- qml/MessageView/OneMessagePage.qml 2014-11-07 19:19:24 +0000
+++ qml/MessageView/OneMessagePage.qml 2014-12-01 18:56:12 +0000
@@ -146,6 +146,7 @@
146 right: parent.right146 right: parent.right
147 }147 }
148 Component.onCompleted: {148 Component.onCompleted: {
149 msgPartNetAccessManagerFactory.setMessageIndex(imapAccess.oneMessageModel.messageIndex);
149 partWidgetFactory.setNetAccessManager(imapAccess.msgQNAM);150 partWidgetFactory.setNetAccessManager(imapAccess.msgQNAM);
150 partWidgetFactory.setNetWatcher(imapAccess.networkWatcher);151 partWidgetFactory.setNetWatcher(imapAccess.networkWatcher);
151 partWidgetFactory.create(imapAccess.oneMessageModel.messageFirstChildIndex,152 partWidgetFactory.create(imapAccess.oneMessageModel.messageFirstChildIndex,
152153
=== added directory 'src/app/Network'
=== added file 'src/app/Network/MsgPartNetAccessManagerFactory.cpp'
--- src/app/Network/MsgPartNetAccessManagerFactory.cpp 1970-01-01 00:00:00 +0000
+++ src/app/Network/MsgPartNetAccessManagerFactory.cpp 2014-12-01 18:56:12 +0000
@@ -0,0 +1,45 @@
1/* Copyright (C) 2014 Boren Zhang <bobo1993324@gmail.com>
2
3 This file is part of Dekko email client for Ubuntu Devices/
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of
8 the License or (at your option) version 3
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#include "MsgPartNetAccessManagerFactory.h"
20
21namespace Dekko {
22
23void MsgPartNetAccessManagerFactory::setMessageIndex(const QModelIndex &messageIndex)
24{
25 m_messageIndex = messageIndex;
26 for (int i = 0; i < m_mpnamList.length(); i++) {
27 m_mpnamList[i]->setModelMessage(messageIndex);
28 }
29}
30
31QNetworkAccessManager *MsgPartNetAccessManagerFactory::create(QObject *parent)
32{
33 Imap::Network::MsgPartNetAccessManager * mpnam = new Imap::Network::MsgPartNetAccessManager(parent);
34 mpnam->setModelMessage(m_messageIndex);
35 connect(mpnam, SIGNAL(destroyed(QObject*)), this, SLOT(handleManagerDestroyed(QObject *)));
36 m_mpnamList.append(mpnam);
37 return mpnam;
38}
39
40void MsgPartNetAccessManagerFactory::handleManagerDestroyed(QObject *destroyedObject)
41{
42 m_mpnamList.removeOne(qobject_cast<Imap::Network::MsgPartNetAccessManager *>(destroyedObject));
43}
44
45}
046
=== added file 'src/app/Network/MsgPartNetAccessManagerFactory.h'
--- src/app/Network/MsgPartNetAccessManagerFactory.h 1970-01-01 00:00:00 +0000
+++ src/app/Network/MsgPartNetAccessManagerFactory.h 2014-12-01 18:56:12 +0000
@@ -0,0 +1,43 @@
1/* Copyright (C) 2014 Boren Zhang <bobo1993324@gmail.com>
2
3 This file is part of Dekko email client for Ubuntu Devices/
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of
8 the License or (at your option) version 3
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifndef MSGPARTNETACCESSMANAGERFACTORY_H
20#define MSGPARTNETACCESSMANAGERFACTORY_H
21
22#include <QQmlNetworkAccessManagerFactory>
23#include <QModelIndex>
24
25#include "Imap/Network/MsgPartNetAccessManager.h"
26
27namespace Dekko {
28
29class MsgPartNetAccessManagerFactory : public QObject, public QQmlNetworkAccessManagerFactory
30{
31 Q_OBJECT
32public:
33 Q_INVOKABLE void setMessageIndex(const QModelIndex &messageIndex);
34 virtual QNetworkAccessManager *create(QObject *parent);
35public slots:
36 void handleManagerDestroyed(QObject * destroyedObject);
37private:
38 QList<Imap::Network::MsgPartNetAccessManager *> m_mpnamList;
39 QModelIndex m_messageIndex;
40};
41
42}
43#endif // MSGPARTNETACCESSMANAGERFACTORY_H
044
=== modified file 'src/app/PartWidget/NewPartWidget.cpp'
--- src/app/PartWidget/NewPartWidget.cpp 2014-11-07 17:31:19 +0000
+++ src/app/PartWidget/NewPartWidget.cpp 2014-12-01 18:56:12 +0000
@@ -202,6 +202,9 @@
202202
203 if (isPlainText || isHtml) {203 if (isPlainText || isHtml) {
204 item->setProperty("msgPartIndex", partIndex);204 item->setProperty("msgPartIndex", partIndex);
205 //BUG: if set url in here, Oxide will display pure html text, it seems that it doesn't recognize mimeType "text/html; charset=utf8"
206// } else if (isHtml) {
207// item->setProperty("url", url);
205 } else {208 } else {
206 item->setProperty("source", url);209 item->setProperty("source", url);
207 }210 }
208211
=== modified file 'src/app/main.cpp'
--- src/app/main.cpp 2014-11-07 17:31:19 +0000
+++ src/app/main.cpp 2014-12-01 18:56:12 +0000
@@ -41,6 +41,7 @@
41#include "app/PartWidget/SectionType.h"41#include "app/PartWidget/SectionType.h"
42#include "app/Utils/Path.h"42#include "app/Utils/Path.h"
43#include "app/Utils/PlainTextFormatter.h"43#include "app/Utils/PlainTextFormatter.h"
44#include "app/Network/MsgPartNetAccessManagerFactory.h"
44#include "Imap/Model/ImapAccess.h"45#include "Imap/Model/ImapAccess.h"
45#include "Imap/Model/ThreadingMsgListModel.h"46#include "Imap/Model/ThreadingMsgListModel.h"
46#include "MSA/Account.h"47#include "MSA/Account.h"
@@ -135,6 +136,10 @@
135 .arg(QDir::homePath()));136 .arg(QDir::homePath()));
136 qQuickViewer->engine()->rootContext()->setContextProperty(QLatin1String("addressbookStoreLocation"), QVariant::fromValue(addressbookStoreLocation));137 qQuickViewer->engine()->rootContext()->setContextProperty(QLatin1String("addressbookStoreLocation"), QVariant::fromValue(addressbookStoreLocation));
137138
139 Dekko::MsgPartNetAccessManagerFactory msgPartNetAccessManagerFactory;
140 qQuickViewer->engine()->setNetworkAccessManagerFactory(&msgPartNetAccessManagerFactory);
141 qQuickViewer->engine()->rootContext()->setContextProperty(QLatin1String("msgPartNetAccessManagerFactory"), &msgPartNetAccessManagerFactory);
142
138 registerDekkoTypes("DekkoCore");143 registerDekkoTypes("DekkoCore");
139 registerTrojitaCoreTypes("TrojitaCore");144 registerTrojitaCoreTypes("TrojitaCore");
140145

Subscribers

People subscribed via source and target branches

to all changes: