We only need the local .desktop files in Verla and earlier :)

This commit is contained in:
Sebastian Wolf 2021-11-07 19:53:23 +01:00
parent a88abbb20f
commit f3242bf7db
No known key found for this signature in database
GPG key ID: CEA9522B5F38A90A
3 changed files with 39 additions and 32 deletions

View file

@ -12,7 +12,7 @@ Name: harbour-fernschreiber
Summary: Fernschreiber is a Telegram client for Sailfish OS Summary: Fernschreiber is a Telegram client for Sailfish OS
Version: 0.10 Version: 0.10
Release: 2 Release: 3
Group: Qt/Qt Group: Qt/Qt
License: LICENSE License: LICENSE
URL: http://werkwolf.eu/ URL: http://werkwolf.eu/

View file

@ -1,7 +1,7 @@
Name: harbour-fernschreiber Name: harbour-fernschreiber
Summary: Fernschreiber is a Telegram client for Sailfish OS Summary: Fernschreiber is a Telegram client for Sailfish OS
Version: 0.10 Version: 0.10
Release: 2 Release: 3
# The contents of the Group field should be one of the groups listed here: # The contents of the Group field should be one of the groups listed here:
# https://github.com/mer-tools/spectacle/blob/master/data/GROUPS # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS
Group: Qt/Qt Group: Qt/Qt

View file

@ -1901,15 +1901,19 @@ void TDLibWrapper::initializeOpenWith()
if (QFile::exists(openUrlFilePath)) { if (QFile::exists(openUrlFilePath)) {
LOG("Old open URL file exists, that needs to go away...!"); LOG("Old open URL file exists, that needs to go away...!");
QFile::remove(openUrlFilePath); QFile::remove(openUrlFilePath);
QProcess::startDetached("update-desktop-database " + applicationsLocation);
} }
const QString sailfishBrowserFilePath(applicationsLocation + "/sailfish-browser.desktop"); // Something special for Verla...
if (!QFile::exists(sailfishBrowserFilePath)) { if (sailfishOSMajorVersion == 4 && sailfishOSMinorVersion == 2) {
LOG("Copying standard Sailfish Browser desktop file to " << sailfishBrowserFilePath); const QString sailfishBrowserFilePath(applicationsLocation + "/sailfish-browser.desktop");
if (QFile::copy("/usr/share/applications/sailfish-browser.desktop", sailfishBrowserFilePath)) { if (!QFile::exists(sailfishBrowserFilePath)) {
LOG("Standard Sailfish Browser desktop file successfully copied to " << sailfishBrowserFilePath); LOG("Copying standard Sailfish Browser desktop file to " << sailfishBrowserFilePath);
QProcess::startDetached("update-desktop-database " + applicationsLocation); if (QFile::copy("/usr/share/applications/sailfish-browser.desktop", sailfishBrowserFilePath)) {
} else { LOG("Standard Sailfish Browser desktop file successfully copied to " << sailfishBrowserFilePath);
LOG("ERROR copying standard Sailfish Browser desktop file 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"); const QString desktopFilePath(applicationsLocation + "/harbour-fernschreiber-open-url.desktop");
QFile desktopFile(desktopFilePath); QFile desktopFile(desktopFilePath);
if (desktopFile.exists()) { if (desktopFile.exists()) {
LOG("Fernschreiber open-with file existing, removing and re-creating..."); LOG("Fernschreiber open-with file existing, removing...");
desktopFile.remove(); 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); 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"; QString dbusPathName = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/dbus-1/services";
QDir dbusPath(dbusPathName); QDir dbusPath(dbusPathName);