diff --git a/linphone-desktop/CMakeLists.txt b/linphone-desktop/CMakeLists.txt index fc4acde5d..849747104 100644 --- a/linphone-desktop/CMakeLists.txt +++ b/linphone-desktop/CMakeLists.txt @@ -62,7 +62,7 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DQT_QML_DEBUG -DQT_DECLARAT # Define packages, libs, sources, headers, resources and languages. # ------------------------------------------------------------------------------ -set(QT5_PACKAGES Core Gui Quick Widgets QuickControls2 Svg LinguistTools) +set(QT5_PACKAGES Core Gui Quick Widgets QuickControls2 Svg LinguistTools Network) find_package(Linphone REQUIRED) find_package(LinphoneCxx REQUIRED) diff --git a/linphone-desktop/src/app/App.cpp b/linphone-desktop/src/app/App.cpp index d42e8426d..886886808 100644 --- a/linphone-desktop/src/app/App.cpp +++ b/linphone-desktop/src/app/App.cpp @@ -60,7 +60,7 @@ inline bool installLocale (App &app, QTranslator &translator, const QLocale &loc return translator.load(locale, LANGUAGES_PATH) && app.installTranslator(&translator); } -App::App (int &argc, char **argv) : QApplication(argc, argv) { +App::App (int &argc, char *argv[]) : SingleApplication(argc, argv) { setApplicationVersion("4.0"); setWindowIcon(QIcon(WINDOW_ICON_PATH)); diff --git a/linphone-desktop/src/app/App.hpp b/linphone-desktop/src/app/App.hpp index d103740de..c93171b93 100644 --- a/linphone-desktop/src/app/App.hpp +++ b/linphone-desktop/src/app/App.hpp @@ -25,16 +25,17 @@ #include "../components/notifier/Notifier.hpp" -#include #include #include #include +#include "../externals/single-application/SingleApplication.hpp" + // ============================================================================= class DefaultTranslator; -class App : public QApplication { +class App : public SingleApplication { Q_OBJECT; Q_PROPERTY(QString configLocale READ getConfigLocale WRITE setConfigLocale NOTIFY configLocaleChanged); @@ -42,7 +43,7 @@ class App : public QApplication { Q_PROPERTY(QVariantList availableLocales READ getAvailableLocales CONSTANT); public: - App (int &argc, char **argv); + App (int &argc, char *argv[]); ~App (); void initContentApp (); diff --git a/linphone-desktop/src/externals/single-application/SingleApplication.cpp b/linphone-desktop/src/externals/single-application/SingleApplication.cpp index 465c68747..21a6e160b 100644 --- a/linphone-desktop/src/externals/single-application/SingleApplication.cpp +++ b/linphone-desktop/src/externals/single-application/SingleApplication.cpp @@ -65,7 +65,7 @@ SingleApplicationPrivate::~SingleApplicationPrivate () { delete socket; } memory->lock(); - InstancesInfo *inst = (InstancesInfo *)memory->data(); + InstancesInfo *inst = static_cast(memory->data()); if (server != nullptr) { server->close(); delete server; @@ -78,19 +78,19 @@ SingleApplicationPrivate::~SingleApplicationPrivate () { void SingleApplicationPrivate::genBlockServerName (int timeout) { QCryptographicHash appData(QCryptographicHash::Sha256); appData.addData("SingleApplication", 17); - appData.addData(SingleApplication::app_t::applicationName().toUtf8()); - appData.addData(SingleApplication::app_t::organizationName().toUtf8()); - appData.addData(SingleApplication::app_t::organizationDomain().toUtf8()); + appData.addData(QApplication::applicationName().toUtf8()); + appData.addData(QApplication::organizationName().toUtf8()); + appData.addData(QApplication::organizationDomain().toUtf8()); if (!(options & SingleApplication::Mode::ExcludeAppVersion)) { - appData.addData(SingleApplication::app_t::applicationVersion().toUtf8()); + appData.addData(QApplication::applicationVersion().toUtf8()); } if (!(options & SingleApplication::Mode::ExcludeAppPath)) { #ifdef Q_OS_WIN - appData.addData(SingleApplication::app_t::applicationFilePath().toLower().toUtf8()); + appData.addData(QApplication::applicationFilePath().toLower().toUtf8()); #else - appData.addData(SingleApplication::app_t::applicationFilePath().toUtf8()); + appData.addData(QApplication::applicationFilePath().toUtf8()); #endif // ifdef Q_OS_WIN } @@ -157,7 +157,7 @@ void SingleApplicationPrivate::startPrimary (bool resetMemory) { // Reset the number of connections memory->lock(); - InstancesInfo *inst = (InstancesInfo *)memory->data(); + InstancesInfo *inst = static_cast(memory->data()); if (resetMemory) { inst->primary = true; @@ -207,7 +207,7 @@ void SingleApplicationPrivate::connectToPrimary (int msecs, char connectionType) QByteArray initMsg = blockServerName.toLatin1(); initMsg.append(connectionType); - initMsg.append((const char *)&instanceNumber, sizeof(quint32)); + initMsg.append(reinterpret_cast(&instanceNumber), sizeof(quint32)); initMsg.append(QByteArray::number(qChecksum(initMsg.constData(), initMsg.length()), 256)); socket->write(initMsg); @@ -283,7 +283,7 @@ void SingleApplicationPrivate::slotConnectionEstablished () { initMsg += connectionType; tmp = nextConnSocket->read(sizeof(quint32)); const char *data = tmp.constData(); - instanceId = (quint32) * data; + instanceId = static_cast(*data); initMsg += tmp; // Verify the checksum of the initMsg QByteArray checksum = QByteArray::number( @@ -356,7 +356,7 @@ void SingleApplicationPrivate::slotClientConnectionClosed (QLocalSocket *closedS * @param {bool} allowSecondaryInstances */ SingleApplication::SingleApplication (int &argc, char *argv[], bool allowSecondary, Options options, int timeout) - : app_t(argc, argv), d_ptr(new SingleApplicationPrivate(this)) { + : QApplication(argc, argv), d_ptr(new SingleApplicationPrivate(this)) { Q_D(SingleApplication); // Store the current mode of the program @@ -384,7 +384,7 @@ SingleApplication::SingleApplication (int &argc, char *argv[], bool allowSeconda // Attempt to attach to the memory segment if (d->memory->attach()) { d->memory->lock(); - InstancesInfo *inst = (InstancesInfo *)d->memory->data(); + InstancesInfo *inst = static_cast(d->memory->data()); if (!inst->primary) { d->startPrimary(false); diff --git a/linphone-desktop/src/externals/single-application/SingleApplication.hpp b/linphone-desktop/src/externals/single-application/SingleApplication.hpp index 23b043d41..e57150a5b 100644 --- a/linphone-desktop/src/externals/single-application/SingleApplication.hpp +++ b/linphone-desktop/src/externals/single-application/SingleApplication.hpp @@ -25,15 +25,10 @@ #ifndef SINGLE_APPLICATION_H #define SINGLE_APPLICATION_H +#include #include #include -#ifndef QAPPLICATION_CLASS - #define QAPPLICATION_CLASS QCoreApplication -#endif // ifndef QAPPLICATION_CLASS - -#include QT_STRINGIFY(QAPPLICATION_CLASS) - // ============================================================================= class SingleApplicationPrivate; @@ -43,11 +38,9 @@ class SingleApplicationPrivate; * Application * @see QCoreApplication */ -class SingleApplication : public QAPPLICATION_CLASS { +class SingleApplication : public QApplication { Q_OBJECT - typedef QAPPLICATION_CLASS app_t; - public: /** * @brief Mode of operation of SingleApplication. @@ -90,7 +83,7 @@ public: * @see See the corresponding QAPPLICATION_CLASS constructor for reference */ explicit SingleApplication (int &argc, char *argv[], bool allowSecondary = false, Options options = Mode::User, int timeout = 100); - ~SingleApplication (); + virtual ~SingleApplication (); /** * @brief Returns if the instance is the primary instance diff --git a/linphone-desktop/src/main.cpp b/linphone-desktop/src/main.cpp index 0888684f2..ea726ff37 100644 --- a/linphone-desktop/src/main.cpp +++ b/linphone-desktop/src/main.cpp @@ -21,6 +21,7 @@ */ #include + #include "app/App.hpp" #include "app/Logger.hpp"