MIME handling under SFOS is quite complicated

This commit is contained in:
Sebastian Wolf 2021-11-09 22:42:54 +01:00
parent f43364a71a
commit 406fbb04a4
No known key found for this signature in database
GPG key ID: CEA9522B5F38A90A
4 changed files with 50 additions and 40 deletions

View file

@ -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

View file

@ -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/

View file

@ -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

View file

@ -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);
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);
} else {
LOG("ERROR copying standard Sailfish Browser desktop file to " << sailfishBrowserFilePath);
}
}
}
}
@ -1925,7 +1941,6 @@ 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);
@ -1948,7 +1963,6 @@ void TDLibWrapper::initializeOpenWith()
desktopFile.close();
QProcess::startDetached("update-desktop-database " + applicationsLocation);
}
}
QString dbusPathName = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/dbus-1/services";
QDir dbusPath(dbusPathName);