From b2f2ee545321ac5cdfce84512e9a15e2f55a0833 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Thu, 18 Feb 2021 22:48:01 +0100 Subject: [PATCH] Disable contacts sync on Sailfish OS 4.x --- qml/pages/NewChatPage.qml | 18 ++++++++++++++++-- src/fernschreiberutils.cpp | 6 ++++++ src/fernschreiberutils.h | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/qml/pages/NewChatPage.qml b/qml/pages/NewChatPage.qml index 917d7ea..b9e5aba 100644 --- a/qml/pages/NewChatPage.qml +++ b/qml/pages/NewChatPage.qml @@ -21,12 +21,14 @@ import Sailfish.Silica 1.0 import "../components" import "../js/twemoji.js" as Emoji import "../js/functions.js" as Functions +import "../js/debug.js" as Debug Page { id: newChatPage allowedOrientations: Orientation.All property bool isLoading: true; + property bool syncSupported: false; function resetFocus() { contactsSearchField.focus = false; @@ -39,7 +41,6 @@ Page { newChatPage.isLoading = false; } - onStatusChanged: { if (status === PageStatus.Active) { reloadContacts(); @@ -54,13 +55,26 @@ Page { } } + Component.onCompleted: { + // With Sailfish OS 4 we can't get up-to-date contacts andmore. We might need to enter Sailjail eventually... + // Details see https://forum.sailfishos.org/t/4-0-1-45-non-jailed-contacts-sqlite-database-no-longer-updated/4724 + var sailfishOSVersion = fernschreiberUtils.getSailfishOSVersion().split("."); + if (parseInt(sailfishOSVersion[0]) < 4) { + Debug.log("Sailfish OS version 3.x - contact sync should still be possible...") + newChatPage.syncSupported = true; + } else { + Debug.log("Sailfish OS version 4.x - contact sync no longer supported...") + newChatPage.syncSupported = false; + } + } + SilicaFlickable { id: newChatContainer contentHeight: newChatPage.height anchors.fill: parent PullDownMenu { - visible: contactsModel.canSynchronizeContacts() + visible: contactsModel.canSynchronizeContacts() && newChatPage.syncSupported MenuItem { onClicked: { newChatPage.isLoading = true; diff --git a/src/fernschreiberutils.cpp b/src/fernschreiberutils.cpp index b7d9af9..0f85cd8 100644 --- a/src/fernschreiberutils.cpp +++ b/src/fernschreiberutils.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #define DEBUG_MODULE FernschreiberUtils #include "debuglog.h" @@ -246,6 +247,11 @@ bool FernschreiberUtils::supportsGeoLocation() return this->geoPositionInfoSource; } +QString FernschreiberUtils::getSailfishOSVersion() +{ + return QSysInfo::productVersion(); +} + void FernschreiberUtils::handleAudioRecorderStatusChanged(QMediaRecorder::Status status) { LOG("Audio recorder status changed:" << status); diff --git a/src/fernschreiberutils.h b/src/fernschreiberutils.h index ce3bc3b..a8ee7ea 100644 --- a/src/fernschreiberutils.h +++ b/src/fernschreiberutils.h @@ -52,6 +52,7 @@ public: Q_INVOKABLE void startGeoLocationUpdates(); Q_INVOKABLE void stopGeoLocationUpdates(); Q_INVOKABLE bool supportsGeoLocation(); + Q_INVOKABLE QString getSailfishOSVersion(); signals: void voiceNoteDurationChanged(qlonglong duration);