From f3242bf7db9fee8c829359a22c1bfbb656626d9b Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sun, 7 Nov 2021 19:53:23 +0100 Subject: [PATCH] We only need the local .desktop files in Verla and earlier :) --- rpm/harbour-fernschreiber.spec | 2 +- rpm/harbour-fernschreiber.yaml | 2 +- src/tdlibwrapper.cpp | 67 +++++++++++++++++++--------------- 3 files changed, 39 insertions(+), 32 deletions(-) diff --git a/rpm/harbour-fernschreiber.spec b/rpm/harbour-fernschreiber.spec index f21b0da..eebbbe0 100644 --- a/rpm/harbour-fernschreiber.spec +++ b/rpm/harbour-fernschreiber.spec @@ -12,7 +12,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.10 -Release: 2 +Release: 3 Group: Qt/Qt License: LICENSE URL: http://werkwolf.eu/ diff --git a/rpm/harbour-fernschreiber.yaml b/rpm/harbour-fernschreiber.yaml index 60bf759..366f10b 100644 --- a/rpm/harbour-fernschreiber.yaml +++ b/rpm/harbour-fernschreiber.yaml @@ -1,7 +1,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.10 -Release: 2 +Release: 3 # The contents of the Group field should be one of the groups listed here: # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS Group: Qt/Qt diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index 72434cf..f3d97be 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -1901,15 +1901,19 @@ void TDLibWrapper::initializeOpenWith() if (QFile::exists(openUrlFilePath)) { LOG("Old open URL file exists, that needs to go away...!"); QFile::remove(openUrlFilePath); + QProcess::startDetached("update-desktop-database " + applicationsLocation); } - const QString sailfishBrowserFilePath(applicationsLocation + "/sailfish-browser.desktop"); - if (!QFile::exists(sailfishBrowserFilePath)) { - LOG("Copying standard Sailfish Browser desktop file to " << sailfishBrowserFilePath); - if (QFile::copy("/usr/share/applications/sailfish-browser.desktop", sailfishBrowserFilePath)) { - LOG("Standard Sailfish Browser desktop file successfully copied to " << sailfishBrowserFilePath); - QProcess::startDetached("update-desktop-database " + applicationsLocation); - } else { - LOG("ERROR copying standard Sailfish Browser desktop file to " << sailfishBrowserFilePath); + // Something special for Verla... + if (sailfishOSMajorVersion == 4 && sailfishOSMinorVersion == 2) { + const QString sailfishBrowserFilePath(applicationsLocation + "/sailfish-browser.desktop"); + if (!QFile::exists(sailfishBrowserFilePath)) { + LOG("Copying standard Sailfish Browser desktop file to " << sailfishBrowserFilePath); + if (QFile::copy("/usr/share/applications/sailfish-browser.desktop", sailfishBrowserFilePath)) { + LOG("Standard Sailfish Browser desktop file successfully copied to " << sailfishBrowserFilePath); + QProcess::startDetached("update-desktop-database " + applicationsLocation); + } else { + LOG("ERROR copying standard Sailfish Browser desktop file to " << sailfishBrowserFilePath); + } } } } @@ -1917,31 +1921,34 @@ void TDLibWrapper::initializeOpenWith() const QString desktopFilePath(applicationsLocation + "/harbour-fernschreiber-open-url.desktop"); QFile desktopFile(desktopFilePath); if (desktopFile.exists()) { - LOG("Fernschreiber open-with file existing, removing and re-creating..."); + LOG("Fernschreiber open-with file existing, removing..."); desktopFile.remove(); - } - LOG("Creating Fernschreiber open-with file at " << desktopFile.fileName()); - if (desktopFile.open(QIODevice::WriteOnly | QIODevice::Text)) { - QTextStream fileOut(&desktopFile); - fileOut.setCodec("UTF-8"); - fileOut << QString("[Desktop Entry]").toUtf8() << "\n"; - fileOut << QString("Type=Application").toUtf8() << "\n"; - fileOut << QString("Name=Fernschreiber").toUtf8() << "\n"; - fileOut << QString("Icon=harbour-fernschreiber").toUtf8() << "\n"; - fileOut << QString("NotShowIn=X-MeeGo;").toUtf8() << "\n"; - if (sailfishOSMajorVersion < 4 || ( sailfishOSMajorVersion == 4 && sailfishOSMinorVersion < 1 )) { - fileOut << QString("MimeType=text/html;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/tg;").toUtf8() << "\n"; - } else { - fileOut << QString("MimeType=x-url-handler/t.me;x-scheme-handler/tg;").toUtf8() << "\n"; - } - fileOut << QString("X-Maemo-Service=de.ygriega.fernschreiber").toUtf8() << "\n"; - fileOut << QString("X-Maemo-Object-Path=/de/ygriega/fernschreiber").toUtf8() << "\n"; - fileOut << QString("X-Maemo-Method=de.ygriega.fernschreiber.openUrl").toUtf8() << "\n"; - fileOut << QString("Hidden=true;").toUtf8() << "\n"; - fileOut.flush(); - desktopFile.close(); QProcess::startDetached("update-desktop-database " + applicationsLocation); } + if (sailfishOSMajorVersion < 4 || (sailfishOSMajorVersion == 4 && sailfishOSMinorVersion < 3)) { + LOG("Creating Fernschreiber open-with file at " << desktopFile.fileName()); + if (desktopFile.open(QIODevice::WriteOnly | QIODevice::Text)) { + QTextStream fileOut(&desktopFile); + fileOut.setCodec("UTF-8"); + fileOut << QString("[Desktop Entry]").toUtf8() << "\n"; + fileOut << QString("Type=Application").toUtf8() << "\n"; + fileOut << QString("Name=Fernschreiber").toUtf8() << "\n"; + fileOut << QString("Icon=harbour-fernschreiber").toUtf8() << "\n"; + fileOut << QString("NotShowIn=X-MeeGo;").toUtf8() << "\n"; + if (sailfishOSMajorVersion < 4 || ( sailfishOSMajorVersion == 4 && sailfishOSMinorVersion < 1 )) { + fileOut << QString("MimeType=text/html;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/tg;").toUtf8() << "\n"; + } else { + fileOut << QString("MimeType=x-url-handler/t.me;x-scheme-handler/tg;").toUtf8() << "\n"; + } + fileOut << QString("X-Maemo-Service=de.ygriega.fernschreiber").toUtf8() << "\n"; + fileOut << QString("X-Maemo-Object-Path=/de/ygriega/fernschreiber").toUtf8() << "\n"; + fileOut << QString("X-Maemo-Method=de.ygriega.fernschreiber.openUrl").toUtf8() << "\n"; + fileOut << QString("Hidden=true;").toUtf8() << "\n"; + fileOut.flush(); + desktopFile.close(); + QProcess::startDetached("update-desktop-database " + applicationsLocation); + } + } QString dbusPathName = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/dbus-1/services"; QDir dbusPath(dbusPathName);