From 0b804e5b215f94a924f0d516da25dc46a81e710d Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 18 Nov 2015 18:10:58 -0800 Subject: Location service: make message delivery configurable Instead of directly using the status output for the QML UI, set up the function used to display messages to the user as part of the constructor. Signed-off-by: Dirk Hohndel --- qt-mobile/gpslocation.cpp | 7 ++++--- qt-mobile/gpslocation.h | 3 ++- qt-mobile/qmlmanager.cpp | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'qt-mobile') diff --git a/qt-mobile/gpslocation.cpp b/qt-mobile/gpslocation.cpp index b109a01a3..a07239b45 100644 --- a/qt-mobile/gpslocation.cpp +++ b/qt-mobile/gpslocation.cpp @@ -1,5 +1,4 @@ #include "qt-mobile/gpslocation.h" -#include "qt-mobile/qmlmanager.h" #include "pref.h" #include "dive.h" #include "helpers.h" @@ -14,8 +13,9 @@ #define GPS_FIX_ADD_URL "http://api.subsurface-divelog.org/api/dive/add/" #define GET_WEBSERVICE_UID_URL "https://cloud.subsurface-divelog.org/webuserid/" -GpsLocation::GpsLocation(QObject *parent) +GpsLocation::GpsLocation(void (*showMsgCB)(const char *), QObject *parent) { + showMessageCB = showMsgCB; // create a QSettings object that's separate from the main application settings geoSettings = new QSettings(QSettings::NativeFormat, QSettings::UserScope, QString("org.subsurfacedivelog"), QString("subsurfacelocation"), this); @@ -80,7 +80,8 @@ void GpsLocation::updateTimeout() void GpsLocation::status(QString msg) { qDebug() << msg; - qmlUiShowMessage(qPrintable(msg)); + if (showMessageCB) + (*showMessageCB)(qPrintable(msg)); } QString GpsLocation::getUserid(QString user, QString passwd) diff --git a/qt-mobile/gpslocation.h b/qt-mobile/gpslocation.h index 82cab8082..55b47f07e 100644 --- a/qt-mobile/gpslocation.h +++ b/qt-mobile/gpslocation.h @@ -13,7 +13,7 @@ class GpsLocation : QObject { Q_OBJECT public: - GpsLocation(QObject *parent); + GpsLocation(void (*showMsgCB)(const char *msg), QObject *parent); bool applyLocations(); int getGpsNum() const; QString getUserid(QString user, QString passwd); @@ -25,6 +25,7 @@ private: QSettings *geoSettings; QNetworkReply *reply; QString userAgent; + void (*showMessageCB)(const char *msg); signals: diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp index da6b01b1c..82ecc847a 100644 --- a/qt-mobile/qmlmanager.cpp +++ b/qt-mobile/qmlmanager.cpp @@ -19,7 +19,7 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false) { // create location manager service - locationProvider = new GpsLocation(this); + locationProvider = new GpsLocation(&qmlUiShowMessage, this); // Initialize cloud credentials. setCloudUserName(prefs.cloud_storage_email); -- cgit v1.2.3-70-g09d2