diff --git a/application_info.cmake b/application_info.cmake index 617e2a8ad..9d7375c39 100644 --- a/application_info.cmake +++ b/application_info.cmake @@ -1,4 +1,5 @@ set(APPLICATION_DESCRIPTION "A libre SIP client") +set(APPLICATION_ID "com.belledonnecommunications.linphone") set(APPLICATION_NAME Linphone) set(APPLICATION_URL "https://www.linphone.org") set(APPLICATION_VENDOR "Belledonne Communications") diff --git a/cmake_builder/linphone_package/macos/Info.plist.in b/cmake_builder/linphone_package/macos/Info.plist.in index ee84b69f1..6e4b7c817 100644 --- a/cmake_builder/linphone_package/macos/Info.plist.in +++ b/cmake_builder/linphone_package/macos/Info.plist.in @@ -36,7 +36,7 @@ CFBundleURLName - com.belledonnecommunications.linphone + @APPLICATION_ID@ CFBundleURLSchemes sip diff --git a/src/app/App.cpp b/src/app/App.cpp index 681f4315d..72886dbbe 100644 --- a/src/app/App.cpp +++ b/src/app/App.cpp @@ -76,13 +76,13 @@ namespace { constexpr char AssistantViewName[] = "Assistant"; #ifdef Q_OS_LINUX - QString AutoStartDirectory( - QStandardPaths::standardLocations(QStandardPaths::ConfigLocation).at(0) + QLatin1String("/autostart/") - ); + const QString AutoStartDirectory(QDir::homePath().append(QStringLiteral("/.config/autostart/"))); #elif defined(Q_OS_MACOS) - QString OsascriptExecutable("osascript"); + const QString OsascriptExecutable(QStringLiteral("osascript")); #else - QString AutoStartSettingsFilePath("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"); + const QString AutoStartSettingsFilePath( + QStringLiteral("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run") + ); #endif // ifdef Q_OS_LINUX } @@ -673,7 +673,9 @@ void App::setAutoStart (bool enabled) { return; } - QFile file(AutoStartDirectory + EXECUTABLE_NAME ".desktop"); + const QString confPath(AutoStartDirectory + EXECUTABLE_NAME ".desktop"); + qInfo() << QStringLiteral("Updating `%1`...").arg(confPath); + QFile file(confPath); if (!enabled) { if (file.exists() && !file.remove()) { @@ -691,20 +693,25 @@ void App::setAutoStart (bool enabled) { return; } - QString fileContent( + const QString binPath(applicationFilePath()); + const QString exec( + binPath.startsWith("/app") + ? QStringLiteral("flatpak run " APPLICATION_ID) + : binPath + ); + + QTextStream(&file) << QString( "[Desktop Entry]\n" "Name=" APPLICATION_NAME "\n" "GenericName=SIP Phone\n" "Comment=" APPLICATION_DESCRIPTION "\n" "Type=Application\n" - "Exec=" + applicationFilePath() + "\n" + "Exec=" + exec + "\n" "Icon=\n" "Terminal=false\n" "Categories=Network;Telephony;\n" "MimeType=x-scheme-handler/sip-linphone;x-scheme-handler/sip;x-scheme-handler/sips-linphone;x-scheme-handler/sips;\n" ); - QTextStream out(&file); - out << fileContent; mAutoStart = enabled; emit autoStartChanged(enabled); diff --git a/src/config.h.cmake b/src/config.h.cmake index 7c64f7c94..02462415f 100644 --- a/src/config.h.cmake +++ b/src/config.h.cmake @@ -20,8 +20,9 @@ * *******************************************************************************/ -#cmakedefine APPLICATION_NAME "${APPLICATION_NAME}" #cmakedefine APPLICATION_DESCRIPTION "${APPLICATION_DESCRIPTION}" +#cmakedefine APPLICATION_ID "${APPLICATION_ID}" +#cmakedefine APPLICATION_NAME "${APPLICATION_NAME}" #cmakedefine ENABLE_UPDATE_CHECK 1 #cmakedefine EXECUTABLE_NAME "${EXECUTABLE_NAME}" #cmakedefine MSPLUGINS_DIR "${MSPLUGINS_DIR}"