From 8220d45ae7b0215ac95e8ddefd5b48f0f5bcaf65 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Thu, 12 Jul 2018 14:21:22 +0200 Subject: [PATCH] feat(app): rename easily app with config.h (not deal with packages and executables) --- CMakeLists.txt | 4 +- cmake_builder/CMakeLists.txt | 2 +- cmake_builder/additional_steps.cmake | 80 +++++++++---------- config.h.cmake | 3 +- src/app/App.cpp | 4 +- src/app/AppController.cpp | 9 +-- src/app/logger/Logger.cpp | 4 +- src/app/paths/Paths.cpp | 6 +- src/components/calls/CallsListModel.cpp | 2 +- src/components/contacts/ContactsListModel.cpp | 2 +- src/components/core/CoreManager.cpp | 9 ++- .../settings/AccountSettingsModel.cpp | 8 +- 12 files changed, 70 insertions(+), 63 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 28eb5a05c..fb4a623a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ project(linphoneqt VERSION 4.1.1) set(APP_LIBRARY app-library) -set(EXECUTABLE_NAME linphone) +set(APPLICATION_NAME linphone) set(TARGET_NAME linphone-qt) set(CMAKE_CXX_STANDARD 11) @@ -370,7 +370,7 @@ endif () if (NOT WIN32) add_dependencies(update_translations check_qml) endif () -set_target_properties(${TARGET_NAME} PROPERTIES OUTPUT_NAME "${EXECUTABLE_NAME}") +set_target_properties(${TARGET_NAME} PROPERTIES OUTPUT_NAME "${APPLICATION_NAME}") set(INCLUDED_DIRECTORIES "${LINPHONECXX_INCLUDE_DIRS}" "${BELCARD_INCLUDE_DIRS}" "${BCTOOLBOX_INCLUDE_DIRS}" "${MEDIASTREAMER2_INCLUDE_DIRS}" "${MINIZIP_INCLUDE_DIRS}") set(LIBRARIES ${BCTOOLBOX_CORE_LIBRARIES} ${BELCARD_LIBRARIES} ${LINPHONECXX_LIBRARIES} ${MINIZIP_LIBRARIES}) diff --git a/cmake_builder/CMakeLists.txt b/cmake_builder/CMakeLists.txt index 26b117378..5454e5ebb 100644 --- a/cmake_builder/CMakeLists.txt +++ b/cmake_builder/CMakeLists.txt @@ -25,5 +25,5 @@ lcb_define_target("linphoneqt" "linphone" "ms2plugins") lcb_blacklist_dependencies("libxsd" "soci") # linphone do not need them for the moment. if(NOT WIN32 AND NOT APPLE) - lcb_blacklist_dependencies("turbo-jpeg") # turbo-jpeg is already provided by Qt5 so do not build it. + lcb_blacklist_dependencies("turbo-jpeg") # turbo-jpeg is already provided by Qt5 so do not build it. endif() diff --git a/cmake_builder/additional_steps.cmake b/cmake_builder/additional_steps.cmake index f21f715a4..d45f836f9 100644 --- a/cmake_builder/additional_steps.cmake +++ b/cmake_builder/additional_steps.cmake @@ -20,46 +20,46 @@ # ############################################################################ -if(LINPHONE_BUILDER_TARGET STREQUAL linphoneqt AND WIN32) - # Create a shortcut to linphone.exe in install prefix - set(SHORTCUT_PATH "${CMAKE_INSTALL_PREFIX}/linphone.lnk") - set(SHORTCUT_TARGET_PATH "${CMAKE_INSTALL_PREFIX}/bin/linphone.exe") - set(SHORTCUT_WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}") - configure_file("${CMAKE_CURRENT_LIST_DIR}/linphone_package/winshortcut.vbs.in" "${CMAKE_CURRENT_BINARY_DIR}/winshortcut.vbs" @ONLY) - add_custom_command(OUTPUT "${SHORTCUT_PATH}" COMMAND "cscript" "${CMAKE_CURRENT_BINARY_DIR}/winshortcut.vbs") - add_custom_target(linphoneqt_winshortcut ALL DEPENDS "${SHORTCUT_PATH}" TARGET_linphone_builder) +if (LINPHONE_BUILDER_TARGET STREQUAL linphoneqt AND WIN32) + # Create a shortcut to linphone.exe in install prefix + set(SHORTCUT_PATH "${CMAKE_INSTALL_PREFIX}/linphone.lnk") + set(SHORTCUT_TARGET_PATH "${CMAKE_INSTALL_PREFIX}/bin/linphone.exe") + set(SHORTCUT_WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}") + configure_file("${CMAKE_CURRENT_LIST_DIR}/linphone_package/winshortcut.vbs.in" "${CMAKE_CURRENT_BINARY_DIR}/winshortcut.vbs" @ONLY) + add_custom_command(OUTPUT "${SHORTCUT_PATH}" COMMAND "cscript" "${CMAKE_CURRENT_BINARY_DIR}/winshortcut.vbs") + add_custom_target(linphoneqt_winshortcut ALL DEPENDS "${SHORTCUT_PATH}" TARGET_linphone_builder) - # Create a shortcut to the solution file in the top directory - set(SHORTCUT_PATH "${CMAKE_SOURCE_DIR}/../../Project.sln.lnk") - set(SHORTCUT_TARGET_PATH "${LINPHONE_BUILDER_WORK_DIR}/cmake/Project.sln") - set(SHORTCUT_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/../..") - configure_file("${CMAKE_CURRENT_LIST_DIR}/linphone_package/winshortcut.vbs.in" "${CMAKE_CURRENT_BINARY_DIR}/solutionshortcut.vbs" @ONLY) - execute_process(COMMAND "cscript" "${CMAKE_CURRENT_BINARY_DIR}/solutionshortcut.vbs") -endif() + # Create a shortcut to the solution file in the top directory + set(SHORTCUT_PATH "${CMAKE_SOURCE_DIR}/../../Project.sln.lnk") + set(SHORTCUT_TARGET_PATH "${LINPHONE_BUILDER_WORK_DIR}/cmake/Project.sln") + set(SHORTCUT_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/../..") + configure_file("${CMAKE_CURRENT_LIST_DIR}/linphone_package/winshortcut.vbs.in" "${CMAKE_CURRENT_BINARY_DIR}/solutionshortcut.vbs" @ONLY) + execute_process(COMMAND "cscript" "${CMAKE_CURRENT_BINARY_DIR}/solutionshortcut.vbs") +endif () -# Packaging -if(ENABLE_PACKAGING) - get_cmake_property(_varnames VARIABLES) - set(ENABLE_VARIABLES ) - foreach(_varname ${_varnames}) - if(_varname MATCHES "^ENABLE_.*") - list(APPEND ENABLE_VARIABLES -D${_varname}=${${_varname}}) - endif() - endforeach() +# Packaging. +if (ENABLE_PACKAGING) + get_cmake_property(_varnames VARIABLES) + set(ENABLE_VARIABLES ) + foreach (_varname ${_varnames}) + if (_varname MATCHES "^ENABLE_.*") + list(APPEND ENABLE_VARIABLES -D${_varname}=${${_varname}}) + endif () + endforeach () - if(LINPHONE_BUILDER_TARGET STREQUAL linphoneqt) - # Linphone and linphone SDK packages - linphone_builder_apply_flags() - linphone_builder_set_ep_directories(linphone_package) - linphone_builder_expand_external_project_vars() - ExternalProject_Add(TARGET_linphone_package - DEPENDS TARGET_linphone_builder - TMP_DIR ${ep_tmp} - BINARY_DIR ${ep_build} - SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/linphone_package" - DOWNLOAD_COMMAND "" - CMAKE_GENERATOR ${CMAKE_GENERATOR} - CMAKE_ARGS ${LINPHONE_BUILDER_EP_ARGS} -DCMAKE_INSTALL_PREFIX=${LINPHONE_BUILDER_WORK_DIR}/PACKAGE -DTOOLS_DIR=${CMAKE_BINARY_DIR}/programs -DLINPHONE_OUTPUT_DIR=${CMAKE_INSTALL_PREFIX} -DLINPHONE_DESKTOP_DIR=${CMAKE_CURRENT_LIST_DIR}/.. -DLINPHONE_SOURCE_DIR=${EP_linphone_SOURCE_DIR} ${ENABLE_VARIABLES} -DOPENH264_VERSION=${OPENH264_VERSION} -DLINPHONE_BUILDER_SIGNING_IDENTITY=${LINPHONE_BUILDER_SIGNING_IDENTITY} - ) - endif() -endif() + if (LINPHONE_BUILDER_TARGET STREQUAL linphoneqt) + # Linphone and linphone SDK packages. + linphone_builder_apply_flags() + linphone_builder_set_ep_directories(linphone_package) + linphone_builder_expand_external_project_vars() + ExternalProject_Add(TARGET_linphone_package + DEPENDS TARGET_linphone_builder + TMP_DIR ${ep_tmp} + BINARY_DIR ${ep_build} + SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/linphone_package" + DOWNLOAD_COMMAND "" + CMAKE_GENERATOR ${CMAKE_GENERATOR} + CMAKE_ARGS ${LINPHONE_BUILDER_EP_ARGS} -DCMAKE_INSTALL_PREFIX=${LINPHONE_BUILDER_WORK_DIR}/PACKAGE -DTOOLS_DIR=${CMAKE_BINARY_DIR}/programs -DLINPHONE_OUTPUT_DIR=${CMAKE_INSTALL_PREFIX} -DLINPHONE_DESKTOP_DIR=${CMAKE_CURRENT_LIST_DIR}/.. -DLINPHONE_SOURCE_DIR=${EP_linphone_SOURCE_DIR} ${ENABLE_VARIABLES} -DOPENH264_VERSION=${OPENH264_VERSION} -DLINPHONE_BUILDER_SIGNING_IDENTITY=${LINPHONE_BUILDER_SIGNING_IDENTITY} + ) + endif () +endif () diff --git a/config.h.cmake b/config.h.cmake index 06a36e711..4c93d7980 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -20,5 +20,6 @@ * *******************************************************************************/ -#cmakedefine MSPLUGINS_DIR "${MSPLUGINS_DIR}" +#cmakedefine APPLICATION_NAME "${APPLICATION_NAME}" #cmakedefine ENABLE_UPDATE_CHECK 1 +#cmakedefine MSPLUGINS_DIR "${MSPLUGINS_DIR}" diff --git a/src/app/App.cpp b/src/app/App.cpp index cc9a92d45..c07aa1614 100644 --- a/src/app/App.cpp +++ b/src/app/App.cpp @@ -491,7 +491,7 @@ void App::setTrayIcon () { systemTrayIcon->setContextMenu(menu); systemTrayIcon->setIcon(QIcon(LinphoneUtils::WindowIconPath)); - systemTrayIcon->setToolTip("Linphone"); + systemTrayIcon->setToolTip(APPLICATION_NAME); systemTrayIcon->show(); mSystemTrayIcon = systemTrayIcon; @@ -546,7 +546,7 @@ QString App::getLocale () const { // ----------------------------------------------------------------------------- void App::openAppAfterInit (bool mustBeIconified) { - qInfo() << QStringLiteral("Open linphone app."); + qInfo() << QStringLiteral("Open " APPLICATION_NAME " app."); // Create other windows. mCallsWindow = createSubWindow(mEngine, QmlViewCallsWindow); diff --git a/src/app/AppController.cpp b/src/app/AppController.cpp index 4e16da4c7..7bfd836e2 100644 --- a/src/app/AppController.cpp +++ b/src/app/AppController.cpp @@ -25,6 +25,7 @@ #include #include +#include "config.h" #include "gitversion.h" #include "AppController.hpp" @@ -34,11 +35,7 @@ using namespace std; namespace { - // Must be unique. Used by `SingleApplication` and `Paths`. - constexpr char ApplicationName[] = "linphone"; - constexpr char ApplicationVersion[] = LINPHONE_QT_GIT_VERSION; constexpr char ApplicationMinimalQtVersion[] = "5.9.0"; - constexpr char DefaultFont[] = "Noto Sans"; } @@ -57,8 +54,8 @@ AppController::AppController (int &argc, char *argv[]) { // App creation. // --------------------------------------------------------------------------- - QCoreApplication::setApplicationName(ApplicationName); - QCoreApplication::setApplicationVersion(ApplicationVersion); + QCoreApplication::setApplicationName(APPLICATION_NAME); + QCoreApplication::setApplicationVersion(LINPHONE_QT_GIT_VERSION); mApp = new App(argc, argv); QQuickStyle::setStyle("Default"); diff --git a/src/app/logger/Logger.cpp b/src/app/logger/Logger.cpp index e13181fc4..243679dcb 100644 --- a/src/app/logger/Logger.cpp +++ b/src/app/logger/Logger.cpp @@ -25,6 +25,8 @@ #include #include +#include "config.h" + #include "components/settings/SettingsModel.hpp" #include "utils/Utils.hpp" @@ -109,7 +111,7 @@ private: stderr, format, getFormattedCurrentTime().constData(), - domain.empty() ? domain.c_str() : "linphone", + domain.empty() ? domain.c_str() : APPLICATION_NAME, message.c_str() ); diff --git a/src/app/paths/Paths.cpp b/src/app/paths/Paths.cpp index 214589c33..72a838e30 100644 --- a/src/app/paths/Paths.cpp +++ b/src/app/paths/Paths.cpp @@ -26,10 +26,10 @@ #include #include -#include "utils/Utils.hpp" - #include "config.h" +#include "utils/Utils.hpp" + #include "Paths.hpp" // ============================================================================= @@ -39,7 +39,7 @@ using namespace std; namespace { constexpr char PathAssistantConfig[] = "/linphone/assistant/"; constexpr char PathAvatars[] = "/avatars/"; - constexpr char PathCaptures[] = "/Linphone/captures/"; + constexpr char PathCaptures[] = "/" APPLICATION_NAME "/captures/"; constexpr char PathCodecs[] = "/codecs/"; constexpr char PathLogs[] = "/logs/"; constexpr char PathPlugins[] = "/plugins/"; diff --git a/src/components/calls/CallsListModel.cpp b/src/components/calls/CallsListModel.cpp index 0d961e8a3..f5f117945 100644 --- a/src/components/calls/CallsListModel.cpp +++ b/src/components/calls/CallsListModel.cpp @@ -254,7 +254,7 @@ void CallsListModel::removeCall (const shared_ptr &call) { } catch (const out_of_range &) { // The call model not exists because the linphone call state // `CallStateIncomingReceived`/`CallStateOutgoingInit` was not notified. - qWarning() << QStringLiteral("Unable to find linphone call:") << call.get(); + qWarning() << QStringLiteral("Unable to find call:") << call.get(); return; } diff --git a/src/components/contacts/ContactsListModel.cpp b/src/components/contacts/ContactsListModel.cpp index 5bebb4b08..a04344bb9 100644 --- a/src/components/contacts/ContactsListModel.cpp +++ b/src/components/contacts/ContactsListModel.cpp @@ -45,7 +45,7 @@ ContactsListModel::ContactsListModel (QObject *parent) : QAbstractListModel(pare } for (const auto &linphoneFriend : toRemove) { - qWarning() << QStringLiteral("Remove one linphone friend without vcard."); + qWarning() << QStringLiteral("Remove one friend without vcard."); mLinphoneFriends->removeFriend(linphoneFriend); } } diff --git a/src/components/core/CoreManager.cpp b/src/components/core/CoreManager.cpp index 895897d3e..1d57d6bae 100644 --- a/src/components/core/CoreManager.cpp +++ b/src/components/core/CoreManager.cpp @@ -25,6 +25,8 @@ #include #include +#include "config.h" + #include "app/paths/Paths.hpp" #include "components/calls/CallsListModel.hpp" #include "components/chat/ChatModel.hpp" @@ -227,7 +229,7 @@ void CoreManager::setResourcesPaths () { // ----------------------------------------------------------------------------- void CoreManager::createLinphoneCore (const QString &configPath) { - qInfo() << QStringLiteral("Launch async linphone core creation."); + qInfo() << QStringLiteral("Launch async core creation."); // Migration of configuration and database files from GTK version of Linphone. Paths::migrate(); @@ -242,7 +244,10 @@ void CoreManager::createLinphoneCore (const QString &configPath) { mCore->setVideoDisplayFilter("MSOGL"); mCore->usePreviewWindow(true); - mCore->setUserAgent("Linphone Desktop", Utils::appStringToCoreString(QCoreApplication::applicationVersion())); + mCore->setUserAgent( + APPLICATION_NAME " Desktop", + Utils::appStringToCoreString(QCoreApplication::applicationVersion()) + ); // Force capture/display. // Useful if the app was built without video support. diff --git a/src/components/settings/AccountSettingsModel.cpp b/src/components/settings/AccountSettingsModel.cpp index e8bffe252..325e7a291 100644 --- a/src/components/settings/AccountSettingsModel.cpp +++ b/src/components/settings/AccountSettingsModel.cpp @@ -20,6 +20,8 @@ * Author: Ronan Abhamon */ +#include "config.h" + #include "app/paths/Paths.hpp" #include "components/core/CoreHandlers.hpp" #include "components/core/CoreManager.hpp" @@ -286,9 +288,9 @@ void AccountSettingsModel::setPrimaryUsername (const QString &username) { shared_ptr core = CoreManager::getInstance()->getCore(); shared_ptr primary = core->getPrimaryContactParsed(); - primary->setUsername( - username.isEmpty() ? "linphone" : Utils::appStringToCoreString(username) - ); + primary->setUsername(Utils::appStringToCoreString( + username.isEmpty() ? APPLICATION_NAME : username + )); core->setPrimaryContact(primary->asString()); emit accountSettingsUpdated();