From 406fbb04a462fddaea071cad9f8333bef37d230f Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Tue, 9 Nov 2021 22:42:54 +0100 Subject: [PATCH] MIME handling under SFOS is quite complicated --- harbour-fernschreiber.desktop | 4 -- rpm/harbour-fernschreiber.spec | 4 +- rpm/harbour-fernschreiber.yaml | 4 +- src/tdlibwrapper.cpp | 78 ++++++++++++++++++++-------------- 4 files changed, 50 insertions(+), 40 deletions(-) diff --git a/harbour-fernschreiber.desktop b/harbour-fernschreiber.desktop index bc67e03..db85a62 100644 --- a/harbour-fernschreiber.desktop +++ b/harbour-fernschreiber.desktop @@ -4,7 +4,3 @@ X-Nemo-Application-Type=generic Icon=harbour-fernschreiber Exec=harbour-fernschreiber Name=Fernschreiber -MimeType=x-url-handler/t.me;x-scheme-handler/tg; -X-Maemo-Service=de.ygriega.fernschreiber -X-Maemo-Object-Path=/de/ygriega/fernschreiber -X-Maemo-Method=de.ygriega.fernschreiber.openUrl diff --git a/rpm/harbour-fernschreiber.spec b/rpm/harbour-fernschreiber.spec index eebbbe0..1f7dd19 100644 --- a/rpm/harbour-fernschreiber.spec +++ b/rpm/harbour-fernschreiber.spec @@ -11,8 +11,8 @@ Name: harbour-fernschreiber # << macros Summary: Fernschreiber is a Telegram client for Sailfish OS -Version: 0.10 -Release: 3 +Version: 0.10.1 +Release: 1 Group: Qt/Qt License: LICENSE URL: http://werkwolf.eu/ diff --git a/rpm/harbour-fernschreiber.yaml b/rpm/harbour-fernschreiber.yaml index 366f10b..0c425c8 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: 3 +Version: 0.10.1 +Release: 1 # 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 f3d97be..6a6b62d 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -1853,7 +1853,7 @@ void TDLibWrapper::setInitialParameters() QSettings hardwareSettings("/etc/hw-release", QSettings::NativeFormat); initialParameters.insert("device_model", hardwareSettings.value("NAME", "Unknown Mobile Device").toString()); initialParameters.insert("system_version", QSysInfo::prettyProductName()); - initialParameters.insert("application_version", "0.10"); + initialParameters.insert("application_version", "0.10.1"); initialParameters.insert("enable_storage_optimizer", appSettings->storageOptimizer()); // initialParameters.insert("use_test_dc", true); requestObject.insert("parameters", initialParameters); @@ -1898,6 +1898,12 @@ void TDLibWrapper::initializeOpenWith() QProcess::startDetached("update-desktop-database " + applicationsLocation); } } else { + const QString sailfishBrowserFilePath(applicationsLocation + "/sailfish-browser.desktop"); + if (QFile::exists(sailfishBrowserFilePath)) { + LOG("Removing existing local Sailfish browser file, that was not working as expected in 0.10...!"); + QFile::remove(sailfishBrowserFilePath); + QProcess::startDetached("update-desktop-database " + applicationsLocation); + } if (QFile::exists(openUrlFilePath)) { LOG("Old open URL file exists, that needs to go away...!"); QFile::remove(openUrlFilePath); @@ -1905,15 +1911,25 @@ void TDLibWrapper::initializeOpenWith() } // 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); - } + LOG("Creating open URL file at " << openUrlFilePath); + QFile openUrlFile(openUrlFilePath); + if (openUrlFile.open(QIODevice::WriteOnly | QIODevice::Text)) { + QTextStream fileOut(&openUrlFile); + fileOut.setCodec("UTF-8"); + fileOut << QString("[Desktop Entry]").toUtf8() << "\n"; + fileOut << QString("Type=Application").toUtf8() << "\n"; + fileOut << QString("Name=Browser").toUtf8() << "\n"; + fileOut << QString("Icon=icon-launcher-browser").toUtf8() << "\n"; + fileOut << QString("NoDisplay=true").toUtf8() << "\n"; + fileOut << QString("X-MeeGo-Logical-Id=sailfish-browser-ap-name").toUtf8() << "\n"; + fileOut << QString("X-MeeGo-Translation-Catalog=sailfish-browser").toUtf8() << "\n"; + fileOut << QString("MimeType=text/html;x-scheme-handler/http;x-scheme-handler/https;").toUtf8() << "\n"; + fileOut << QString("X-Maemo-Service=org.sailfishos.browser.ui").toUtf8() << "\n"; + fileOut << QString("X-Maemo-Object-Path=/ui").toUtf8() << "\n"; + fileOut << QString("X-Maemo-Method=org.sailfishos.browser.ui.openUrl").toUtf8() << "\n"; + fileOut.flush(); + openUrlFile.close(); + QProcess::startDetached("update-desktop-database " + applicationsLocation); } } } @@ -1925,29 +1941,27 @@ void TDLibWrapper::initializeOpenWith() desktopFile.remove(); 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); + 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";