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
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-11-21 05:16:54 +0000
3+++ CMakeLists.txt 2014-12-01 18:56:12 +0000
4@@ -480,6 +480,7 @@
5 ${DEKKO_UBUNTU_PATH}/app/PartWidget/SectionType.cpp
6 ${DEKKO_UBUNTU_PATH}/app/Utils/Path.cpp
7 ${DEKKO_UBUNTU_PATH}/app/Utils/PlainTextFormatter.cpp
8+ ${DEKKO_UBUNTU_PATH}/app/Network/MsgPartNetAccessManagerFactory.cpp
9 )
10
11 set(DEKKO_QML_COMPOSER
12
13=== modified file 'qml/MessageView/HtmlPart.qml'
14--- qml/MessageView/HtmlPart.qml 2014-11-07 18:25:29 +0000
15+++ qml/MessageView/HtmlPart.qml 2014-12-01 18:56:12 +0000
16@@ -18,7 +18,8 @@
17 import QtQuick 2.2
18 import Ubuntu.Components 1.1
19 import Ubuntu.Components.Popups 1.0
20-import Ubuntu.Web 0.2
21+//import Ubuntu.Web 0.2
22+import com.canonical.Oxide 1.3
23 import DekkoCore 0.1
24
25 WebView {
26@@ -35,6 +36,9 @@
27
28 property alias msgPartIndex: plainTextFormatter.msgPartIndex
29
30+ context: WebContext {
31+ allowedExtraUrlSchemes: ["cid"]
32+ }
33 //swtich section while webview is scrolling will crash
34 function disableSectionForAWhile() {
35 oneMessagePage.head.sections.enabled = false;
36
37=== modified file 'qml/MessageView/ImagePart.qml'
38--- qml/MessageView/ImagePart.qml 2014-10-31 17:59:05 +0000
39+++ qml/MessageView/ImagePart.qml 2014-12-01 18:56:12 +0000
40@@ -20,7 +20,8 @@
41 import Ubuntu.Components.Popups 1.0
42
43 Image {
44- Label {
45- text: "previewing image not supported"
46+ onSourceSizeChanged: {
47+ width = Math.min(oneMessagePage.width - units.gu(6), sourceSize.width)
48+ height = width * sourceSize.height / sourceSize.width;
49 }
50 }
51
52=== modified file 'qml/MessageView/OneMessagePage.qml'
53--- qml/MessageView/OneMessagePage.qml 2014-11-07 19:19:24 +0000
54+++ qml/MessageView/OneMessagePage.qml 2014-12-01 18:56:12 +0000
55@@ -146,6 +146,7 @@
56 right: parent.right
57 }
58 Component.onCompleted: {
59+ msgPartNetAccessManagerFactory.setMessageIndex(imapAccess.oneMessageModel.messageIndex);
60 partWidgetFactory.setNetAccessManager(imapAccess.msgQNAM);
61 partWidgetFactory.setNetWatcher(imapAccess.networkWatcher);
62 partWidgetFactory.create(imapAccess.oneMessageModel.messageFirstChildIndex,
63
64=== added directory 'src/app/Network'
65=== added file 'src/app/Network/MsgPartNetAccessManagerFactory.cpp'
66--- src/app/Network/MsgPartNetAccessManagerFactory.cpp 1970-01-01 00:00:00 +0000
67+++ src/app/Network/MsgPartNetAccessManagerFactory.cpp 2014-12-01 18:56:12 +0000
68@@ -0,0 +1,45 @@
69+/* Copyright (C) 2014 Boren Zhang <bobo1993324@gmail.com>
70+
71+ This file is part of Dekko email client for Ubuntu Devices/
72+
73+ This program is free software; you can redistribute it and/or
74+ modify it under the terms of the GNU General Public License as
75+ published by the Free Software Foundation; either version 2 of
76+ the License or (at your option) version 3
77+
78+ This program is distributed in the hope that it will be useful,
79+ but WITHOUT ANY WARRANTY; without even the implied warranty of
80+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
81+ GNU General Public License for more details.
82+
83+ You should have received a copy of the GNU General Public License
84+ along with this program. If not, see <http://www.gnu.org/licenses/>.
85+*/
86+
87+#include "MsgPartNetAccessManagerFactory.h"
88+
89+namespace Dekko {
90+
91+void MsgPartNetAccessManagerFactory::setMessageIndex(const QModelIndex &messageIndex)
92+{
93+ m_messageIndex = messageIndex;
94+ for (int i = 0; i < m_mpnamList.length(); i++) {
95+ m_mpnamList[i]->setModelMessage(messageIndex);
96+ }
97+}
98+
99+QNetworkAccessManager *MsgPartNetAccessManagerFactory::create(QObject *parent)
100+{
101+ Imap::Network::MsgPartNetAccessManager * mpnam = new Imap::Network::MsgPartNetAccessManager(parent);
102+ mpnam->setModelMessage(m_messageIndex);
103+ connect(mpnam, SIGNAL(destroyed(QObject*)), this, SLOT(handleManagerDestroyed(QObject *)));
104+ m_mpnamList.append(mpnam);
105+ return mpnam;
106+}
107+
108+void MsgPartNetAccessManagerFactory::handleManagerDestroyed(QObject *destroyedObject)
109+{
110+ m_mpnamList.removeOne(qobject_cast<Imap::Network::MsgPartNetAccessManager *>(destroyedObject));
111+}
112+
113+}
114
115=== added file 'src/app/Network/MsgPartNetAccessManagerFactory.h'
116--- src/app/Network/MsgPartNetAccessManagerFactory.h 1970-01-01 00:00:00 +0000
117+++ src/app/Network/MsgPartNetAccessManagerFactory.h 2014-12-01 18:56:12 +0000
118@@ -0,0 +1,43 @@
119+/* Copyright (C) 2014 Boren Zhang <bobo1993324@gmail.com>
120+
121+ This file is part of Dekko email client for Ubuntu Devices/
122+
123+ This program is free software; you can redistribute it and/or
124+ modify it under the terms of the GNU General Public License as
125+ published by the Free Software Foundation; either version 2 of
126+ the License or (at your option) version 3
127+
128+ This program is distributed in the hope that it will be useful,
129+ but WITHOUT ANY WARRANTY; without even the implied warranty of
130+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
131+ GNU General Public License for more details.
132+
133+ You should have received a copy of the GNU General Public License
134+ along with this program. If not, see <http://www.gnu.org/licenses/>.
135+*/
136+
137+#ifndef MSGPARTNETACCESSMANAGERFACTORY_H
138+#define MSGPARTNETACCESSMANAGERFACTORY_H
139+
140+#include <QQmlNetworkAccessManagerFactory>
141+#include <QModelIndex>
142+
143+#include "Imap/Network/MsgPartNetAccessManager.h"
144+
145+namespace Dekko {
146+
147+class MsgPartNetAccessManagerFactory : public QObject, public QQmlNetworkAccessManagerFactory
148+{
149+ Q_OBJECT
150+public:
151+ Q_INVOKABLE void setMessageIndex(const QModelIndex &messageIndex);
152+ virtual QNetworkAccessManager *create(QObject *parent);
153+public slots:
154+ void handleManagerDestroyed(QObject * destroyedObject);
155+private:
156+ QList<Imap::Network::MsgPartNetAccessManager *> m_mpnamList;
157+ QModelIndex m_messageIndex;
158+};
159+
160+}
161+#endif // MSGPARTNETACCESSMANAGERFACTORY_H
162
163=== modified file 'src/app/PartWidget/NewPartWidget.cpp'
164--- src/app/PartWidget/NewPartWidget.cpp 2014-11-07 17:31:19 +0000
165+++ src/app/PartWidget/NewPartWidget.cpp 2014-12-01 18:56:12 +0000
166@@ -202,6 +202,9 @@
167
168 if (isPlainText || isHtml) {
169 item->setProperty("msgPartIndex", partIndex);
170+ //BUG: if set url in here, Oxide will display pure html text, it seems that it doesn't recognize mimeType "text/html; charset=utf8"
171+// } else if (isHtml) {
172+// item->setProperty("url", url);
173 } else {
174 item->setProperty("source", url);
175 }
176
177=== modified file 'src/app/main.cpp'
178--- src/app/main.cpp 2014-11-07 17:31:19 +0000
179+++ src/app/main.cpp 2014-12-01 18:56:12 +0000
180@@ -41,6 +41,7 @@
181 #include "app/PartWidget/SectionType.h"
182 #include "app/Utils/Path.h"
183 #include "app/Utils/PlainTextFormatter.h"
184+#include "app/Network/MsgPartNetAccessManagerFactory.h"
185 #include "Imap/Model/ImapAccess.h"
186 #include "Imap/Model/ThreadingMsgListModel.h"
187 #include "MSA/Account.h"
188@@ -135,6 +136,10 @@
189 .arg(QDir::homePath()));
190 qQuickViewer->engine()->rootContext()->setContextProperty(QLatin1String("addressbookStoreLocation"), QVariant::fromValue(addressbookStoreLocation));
191
192+ Dekko::MsgPartNetAccessManagerFactory msgPartNetAccessManagerFactory;
193+ qQuickViewer->engine()->setNetworkAccessManagerFactory(&msgPartNetAccessManagerFactory);
194+ qQuickViewer->engine()->rootContext()->setContextProperty(QLatin1String("msgPartNetAccessManagerFactory"), &msgPartNetAccessManagerFactory);
195+
196 registerDekkoTypes("DekkoCore");
197 registerTrojitaCoreTypes("TrojitaCore");
198

Subscribers

People subscribed via source and target branches

to all changes: