Merge lp:~dpniel/dekko/fixOnlineDetection into lp:dekko/0.3

Proposed by Dan Chapman 
Status: Merged
Approved by: Dan Chapman 
Approved revision: 103
Merged at revision: 103
Proposed branch: lp:~dpniel/dekko/fixOnlineDetection
Merge into: lp:dekko/0.3
Diff against target: 149 lines (+68/-7)
5 files modified
CMakeLists.txt (+1/-0)
qml/Utils/DummyNetworkStatus.qml (+29/-0)
qml/main.qml (+23/-0)
src/3rdParty/trojita/Imap/Model/ImapAccess.cpp (+13/-7)
src/3rdParty/trojita/Imap/Model/ImapAccess.h (+2/-0)
To merge this branch: bzr merge lp:~dpniel/dekko/fixOnlineDetection
Reviewer Review Type Date Requested Status
Dan Chapman  Approve
Review via email: mp+237736@code.launchpad.net

Description of the change

THis is a temporary fix for detecting network changes on the device.

Ideally i want to use the c++ bindings but there has been some issues getting
them installed inside the click chroot.

This uses the NetworkingStatus qml component to work around this for now.

To post a comment you must log in.
Revision history for this message
Dan Chapman  (dpniel) :
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-10-06 15:35:56 +0000
3+++ CMakeLists.txt 2014-10-09 08:40:33 +0000
4@@ -564,6 +564,7 @@
5
6 set(DEKKO_QML_UTILS
7 ${DEKKO_QML_PATH}/Utils/Utils.js
8+ ${DEKKO_QML_PATH}/Utils/DummyNetworkStatus.qml
9 )
10
11 set(DEKKO_ICON_DIR
12
13=== added file 'qml/Utils/DummyNetworkStatus.qml'
14--- qml/Utils/DummyNetworkStatus.qml 1970-01-01 00:00:00 +0000
15+++ qml/Utils/DummyNetworkStatus.qml 2014-10-09 08:40:33 +0000
16@@ -0,0 +1,29 @@
17+/* Copyright (C) 2014 Dan Chapman <dpniel@ubuntu.com>
18+
19+ This file is part of Dekko email client for Ubuntu Devices/
20+
21+ This program is free software; you can redistribute it and/or
22+ modify it under the terms of the GNU General Public License as
23+ published by the Free Software Foundation; either version 2 of
24+ the License or (at your option) version 3
25+
26+ This program is distributed in the hope that it will be useful,
27+ but WITHOUT ANY WARRANTY; without even the implied warranty of
28+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29+ GNU General Public License for more details.
30+
31+ You should have received a copy of the GNU General Public License
32+ along with this program. If not, see <http://www.gnu.org/licenses/>.
33+*/
34+import QtQuick 2.2
35+
36+/* The Idea here is to fake the NetworkingStatus singleton which we bind to
37+ when we are running in a unity7 desktop session as we use the internal
38+ SystemNetworkWatcher.*/
39+Item {
40+ id: dummyNetworkStatus
41+ property var limitations
42+ property bool limitedBandwith
43+ property bool online
44+ property var status
45+}
46
47=== modified file 'qml/main.qml'
48--- qml/main.qml 2014-10-02 11:16:47 +0000
49+++ qml/main.qml 2014-10-09 08:40:33 +0000
50@@ -19,11 +19,13 @@
51 import Ubuntu.Components 1.1
52 import Ubuntu.Components.Popups 1.0
53 import Ubuntu.Components.ListItems 1.0 as ListItems
54+import Ubuntu.Connectivity 1.0
55 import DekkoCore 0.1
56 import TrojitaCore 0.1
57 import "./AccountsView"
58 import "./Dialogs"
59 import "./MailboxView"
60+import "./Utils"
61
62 MainView{
63 id: dekko
64@@ -317,6 +319,27 @@
65 // COMPONENTS / CHILD OBJECTS
66 //-------------------------------
67
68+ DummyNetworkStatus {
69+ id: dummyNetworkStatus
70+ }
71+ Connections {
72+ id: networkStatus
73+ target: imapAccess.isRunningOnMir ? NetworkingStatus : dummyNetworkStatus
74+ onStatusChanged: {
75+ if (status === NetworkingStatus.Offline) {
76+ imapAccess.networkWatcher.setNetworkOffline()
77+ }
78+ if (status === NetworkingStatus.Online) {
79+ if (NetworkingStatus.limitedBandwith) {
80+ imapAccess.networkWatcher.setNetworkExpensive()
81+ } else {
82+ imapAccess.networkWatcher.setNetworkOnline()
83+ }
84+ }
85+ }
86+ onLimitedBandwithChanged: NetworkingStatus.limitedBandwith ? imapAccess.networkWatcher.setNetworkExpensive() : imapAccess.networkWatcher.setNetworkOnline()
87+ }
88+
89 // TODO: Change this as sheets are going to be deprecated
90 Component{
91 id: sslSheetPage
92
93=== modified file 'src/3rdParty/trojita/Imap/Model/ImapAccess.cpp'
94--- src/3rdParty/trojita/Imap/Model/ImapAccess.cpp 2014-10-02 11:28:53 +0000
95+++ src/3rdParty/trojita/Imap/Model/ImapAccess.cpp 2014-10-09 08:40:33 +0000
96@@ -208,13 +208,14 @@
97 }
98 connect(m_imapModel, SIGNAL(needsSslDecision(QList<QSslCertificate>,QList<QSslError>)),
99 this, SLOT(slotSslErrors(QList<QSslCertificate>,QList<QSslError>)));
100-
101-// if (m_account->imapNeedsNetwork()) {
102-// m_netWatcher = new Imap::Mailbox::SystemNetworkWatcher(this, m_imapModel);
103-// } else {
104-// m_netWatcher = new Imap::Mailbox::DummyNetworkWatcher(this, m_imapModel);
105-// }
106- m_netWatcher = new Imap::Mailbox::DummyNetworkWatcher(this, m_imapModel);
107+ // Here we use the SystemNetWatcher only if the settings say start online and we aren't
108+ // running on a mir/unity8 device. Otherwise we are going to use the NetworkingStatus qml plugin
109+ // until we have access to libconnectivity-qt1 in the click chroot. So just use the dummy watcher instead
110+ if (m_account->imapNeedsNetwork() && !isRunningOnMir()) {
111+ m_netWatcher = new Imap::Mailbox::SystemNetworkWatcher(this, m_imapModel);
112+ } else {
113+ m_netWatcher = new Imap::Mailbox::DummyNetworkWatcher(this, m_imapModel);
114+ }
115 QMetaObject::invokeMethod(m_netWatcher,
116 m_account->imapStartOffline() ?
117 "setNetworkOffline" : "setNetworkOnline",
118@@ -374,6 +375,11 @@
119 return m_sslInfoIcon;
120 }
121
122+bool ImapAccess::isRunningOnMir() const
123+{
124+ return qgetenv("QT_QPA_PLATFORM") == "ubuntumirclient";
125+}
126+
127 QString ImapAccess::mailboxListMailboxName() const
128 {
129 return m_mailboxSubtreeModel->rootIndex().data(Imap::Mailbox::RoleMailboxName).toString();
130
131=== modified file 'src/3rdParty/trojita/Imap/Model/ImapAccess.h'
132--- src/3rdParty/trojita/Imap/Model/ImapAccess.h 2014-10-02 11:28:53 +0000
133+++ src/3rdParty/trojita/Imap/Model/ImapAccess.h 2014-10-09 08:40:33 +0000
134@@ -69,6 +69,7 @@
135 Q_PROPERTY(QStringList unfilteredCapabilities READ unfilteredCapabilities NOTIFY modelsChanged)
136 Q_PROPERTY(UiUtils::PasswordWatcher *passwordWatcher READ passwordWatcher NOTIFY modelsChanged)
137 Q_PROPERTY(bool hasThreadingCapabilities READ hasThreadingCapabilities NOTIFY modelsChanged)
138+ Q_PROPERTY(bool isRunningOnMir READ isRunningOnMir CONSTANT)
139 Q_ENUMS(Imap::ImapAccess::ConnectionMethod)
140
141 public:
142@@ -91,6 +92,7 @@
143 QString sslInfoTitle() const;
144 QString sslInfoMessage() const;
145 UiUtils::Formatting::IconType sslInfoIcon() const;
146+ bool isRunningOnMir() const;
147
148 Q_INVOKABLE void openMessage(const QString &mailbox, const uint uid);
149 Q_INVOKABLE QString prettySize(const uint bytes) const;

Subscribers

People subscribed via source and target branches

to all changes: