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
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2014-10-06 15:35:56 +0000
+++ CMakeLists.txt 2014-10-09 08:40:33 +0000
@@ -564,6 +564,7 @@
564564
565 set(DEKKO_QML_UTILS565 set(DEKKO_QML_UTILS
566 ${DEKKO_QML_PATH}/Utils/Utils.js566 ${DEKKO_QML_PATH}/Utils/Utils.js
567 ${DEKKO_QML_PATH}/Utils/DummyNetworkStatus.qml
567 )568 )
568569
569 set(DEKKO_ICON_DIR570 set(DEKKO_ICON_DIR
570571
=== added file 'qml/Utils/DummyNetworkStatus.qml'
--- qml/Utils/DummyNetworkStatus.qml 1970-01-01 00:00:00 +0000
+++ qml/Utils/DummyNetworkStatus.qml 2014-10-09 08:40:33 +0000
@@ -0,0 +1,29 @@
1/* Copyright (C) 2014 Dan Chapman <dpniel@ubuntu.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*/
18import QtQuick 2.2
19
20/* The Idea here is to fake the NetworkingStatus singleton which we bind to
21 when we are running in a unity7 desktop session as we use the internal
22 SystemNetworkWatcher.*/
23Item {
24 id: dummyNetworkStatus
25 property var limitations
26 property bool limitedBandwith
27 property bool online
28 property var status
29}
030
=== modified file 'qml/main.qml'
--- qml/main.qml 2014-10-02 11:16:47 +0000
+++ qml/main.qml 2014-10-09 08:40:33 +0000
@@ -19,11 +19,13 @@
19import Ubuntu.Components 1.119import Ubuntu.Components 1.1
20import Ubuntu.Components.Popups 1.020import Ubuntu.Components.Popups 1.0
21import Ubuntu.Components.ListItems 1.0 as ListItems21import Ubuntu.Components.ListItems 1.0 as ListItems
22import Ubuntu.Connectivity 1.0
22import DekkoCore 0.123import DekkoCore 0.1
23import TrojitaCore 0.124import TrojitaCore 0.1
24import "./AccountsView"25import "./AccountsView"
25import "./Dialogs"26import "./Dialogs"
26import "./MailboxView"27import "./MailboxView"
28import "./Utils"
2729
28MainView{30MainView{
29 id: dekko31 id: dekko
@@ -317,6 +319,27 @@
317 // COMPONENTS / CHILD OBJECTS319 // COMPONENTS / CHILD OBJECTS
318 //-------------------------------320 //-------------------------------
319321
322 DummyNetworkStatus {
323 id: dummyNetworkStatus
324 }
325 Connections {
326 id: networkStatus
327 target: imapAccess.isRunningOnMir ? NetworkingStatus : dummyNetworkStatus
328 onStatusChanged: {
329 if (status === NetworkingStatus.Offline) {
330 imapAccess.networkWatcher.setNetworkOffline()
331 }
332 if (status === NetworkingStatus.Online) {
333 if (NetworkingStatus.limitedBandwith) {
334 imapAccess.networkWatcher.setNetworkExpensive()
335 } else {
336 imapAccess.networkWatcher.setNetworkOnline()
337 }
338 }
339 }
340 onLimitedBandwithChanged: NetworkingStatus.limitedBandwith ? imapAccess.networkWatcher.setNetworkExpensive() : imapAccess.networkWatcher.setNetworkOnline()
341 }
342
320 // TODO: Change this as sheets are going to be deprecated343 // TODO: Change this as sheets are going to be deprecated
321 Component{344 Component{
322 id: sslSheetPage345 id: sslSheetPage
323346
=== modified file 'src/3rdParty/trojita/Imap/Model/ImapAccess.cpp'
--- src/3rdParty/trojita/Imap/Model/ImapAccess.cpp 2014-10-02 11:28:53 +0000
+++ src/3rdParty/trojita/Imap/Model/ImapAccess.cpp 2014-10-09 08:40:33 +0000
@@ -208,13 +208,14 @@
208 }208 }
209 connect(m_imapModel, SIGNAL(needsSslDecision(QList<QSslCertificate>,QList<QSslError>)),209 connect(m_imapModel, SIGNAL(needsSslDecision(QList<QSslCertificate>,QList<QSslError>)),
210 this, SLOT(slotSslErrors(QList<QSslCertificate>,QList<QSslError>)));210 this, SLOT(slotSslErrors(QList<QSslCertificate>,QList<QSslError>)));
211211 // Here we use the SystemNetWatcher only if the settings say start online and we aren't
212// if (m_account->imapNeedsNetwork()) {212 // running on a mir/unity8 device. Otherwise we are going to use the NetworkingStatus qml plugin
213// m_netWatcher = new Imap::Mailbox::SystemNetworkWatcher(this, m_imapModel);213 // until we have access to libconnectivity-qt1 in the click chroot. So just use the dummy watcher instead
214// } else {214 if (m_account->imapNeedsNetwork() && !isRunningOnMir()) {
215// m_netWatcher = new Imap::Mailbox::DummyNetworkWatcher(this, m_imapModel);215 m_netWatcher = new Imap::Mailbox::SystemNetworkWatcher(this, m_imapModel);
216// }216 } else {
217 m_netWatcher = new Imap::Mailbox::DummyNetworkWatcher(this, m_imapModel);217 m_netWatcher = new Imap::Mailbox::DummyNetworkWatcher(this, m_imapModel);
218 }
218 QMetaObject::invokeMethod(m_netWatcher,219 QMetaObject::invokeMethod(m_netWatcher,
219 m_account->imapStartOffline() ?220 m_account->imapStartOffline() ?
220 "setNetworkOffline" : "setNetworkOnline",221 "setNetworkOffline" : "setNetworkOnline",
@@ -374,6 +375,11 @@
374 return m_sslInfoIcon;375 return m_sslInfoIcon;
375}376}
376377
378bool ImapAccess::isRunningOnMir() const
379{
380 return qgetenv("QT_QPA_PLATFORM") == "ubuntumirclient";
381}
382
377QString ImapAccess::mailboxListMailboxName() const383QString ImapAccess::mailboxListMailboxName() const
378{384{
379 return m_mailboxSubtreeModel->rootIndex().data(Imap::Mailbox::RoleMailboxName).toString();385 return m_mailboxSubtreeModel->rootIndex().data(Imap::Mailbox::RoleMailboxName).toString();
380386
=== modified file 'src/3rdParty/trojita/Imap/Model/ImapAccess.h'
--- src/3rdParty/trojita/Imap/Model/ImapAccess.h 2014-10-02 11:28:53 +0000
+++ src/3rdParty/trojita/Imap/Model/ImapAccess.h 2014-10-09 08:40:33 +0000
@@ -69,6 +69,7 @@
69 Q_PROPERTY(QStringList unfilteredCapabilities READ unfilteredCapabilities NOTIFY modelsChanged)69 Q_PROPERTY(QStringList unfilteredCapabilities READ unfilteredCapabilities NOTIFY modelsChanged)
70 Q_PROPERTY(UiUtils::PasswordWatcher *passwordWatcher READ passwordWatcher NOTIFY modelsChanged)70 Q_PROPERTY(UiUtils::PasswordWatcher *passwordWatcher READ passwordWatcher NOTIFY modelsChanged)
71 Q_PROPERTY(bool hasThreadingCapabilities READ hasThreadingCapabilities NOTIFY modelsChanged)71 Q_PROPERTY(bool hasThreadingCapabilities READ hasThreadingCapabilities NOTIFY modelsChanged)
72 Q_PROPERTY(bool isRunningOnMir READ isRunningOnMir CONSTANT)
72 Q_ENUMS(Imap::ImapAccess::ConnectionMethod)73 Q_ENUMS(Imap::ImapAccess::ConnectionMethod)
7374
74public:75public:
@@ -91,6 +92,7 @@
91 QString sslInfoTitle() const;92 QString sslInfoTitle() const;
92 QString sslInfoMessage() const;93 QString sslInfoMessage() const;
93 UiUtils::Formatting::IconType sslInfoIcon() const;94 UiUtils::Formatting::IconType sslInfoIcon() const;
95 bool isRunningOnMir() const;
9496
95 Q_INVOKABLE void openMessage(const QString &mailbox, const uint uid);97 Q_INVOKABLE void openMessage(const QString &mailbox, const uint uid);
96 Q_INVOKABLE QString prettySize(const uint bytes) const;98 Q_INVOKABLE QString prettySize(const uint bytes) const;

Subscribers

People subscribed via source and target branches

to all changes: