From ae7f10ca806974859ff8e627a3a92341327c5bf9 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 10 May 2017 11:55:42 +0200 Subject: [PATCH] feat(src/app/App): display app only when core is started (so after creation) --- linphone-desktop/src/app/App.cpp | 7 +++---- linphone-desktop/src/components/core/CoreHandlers.cpp | 9 +++++++++ linphone-desktop/src/components/core/CoreHandlers.hpp | 7 +++++++ linphone-desktop/src/components/core/CoreManager.cpp | 6 ++---- linphone-desktop/src/components/core/CoreManager.hpp | 2 -- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/linphone-desktop/src/app/App.cpp b/linphone-desktop/src/app/App.cpp index be9924c39..82665cb86 100644 --- a/linphone-desktop/src/app/App.cpp +++ b/linphone-desktop/src/app/App.cpp @@ -114,7 +114,7 @@ inline QQuickWindow *createSubWindow (App *app, const char *path) { inline void activeSplashScreen (App *app) { QQuickWindow *splashScreen = createSubWindow(app, QML_VIEW_SPLASH_SCREEN); - QObject::connect(CoreManager::getInstance(), &CoreManager::linphoneCoreCreated, splashScreen, [splashScreen] { + QObject::connect(CoreManager::getInstance()->getHandlers().get(), &CoreHandlers::coreStarted, splashScreen, [splashScreen] { splashScreen->close(); splashScreen->deleteLater(); }); @@ -179,8 +179,8 @@ void App::initContentApp () { activeSplashScreen(this); QObject::connect( - CoreManager::getInstance(), - &CoreManager::linphoneCoreCreated, + CoreManager::getInstance()->getHandlers().get(), + &CoreHandlers::coreStarted, this, mParser.isSet("selftest") ? &App::quit : &App::openAppAfterInit ); } @@ -441,7 +441,6 @@ void App::openAppAfterInit () { tryToUsePreferredLocale(); qInfo() << QStringLiteral("Linphone core created."); - CoreManager::getInstance()->enableHandlers(); #ifndef __APPLE__ // Enable TrayIconSystem. diff --git a/linphone-desktop/src/components/core/CoreHandlers.cpp b/linphone-desktop/src/components/core/CoreHandlers.cpp index 776a57a5f..e99c9c16a 100644 --- a/linphone-desktop/src/components/core/CoreHandlers.cpp +++ b/linphone-desktop/src/components/core/CoreHandlers.cpp @@ -52,6 +52,15 @@ void CoreHandlers::onCallStateChanged ( App::getInstance()->getNotifier()->notifyReceivedCall(call); } +void CoreHandlers::onGlobalStateChanged ( + const shared_ptr &, + linphone::GlobalState gstate, + const string & +) { + if (gstate == linphone::GlobalStateOn) + emit coreStarted (); +} + void CoreHandlers::onCallStatsUpdated ( const shared_ptr &, const shared_ptr &call, diff --git a/linphone-desktop/src/components/core/CoreHandlers.hpp b/linphone-desktop/src/components/core/CoreHandlers.hpp index a7e529d07..3c7b59ead 100644 --- a/linphone-desktop/src/components/core/CoreHandlers.hpp +++ b/linphone-desktop/src/components/core/CoreHandlers.hpp @@ -36,6 +36,7 @@ class CoreHandlers : signals: void authenticationRequested (const std::shared_ptr &authInfo); void callStateChanged (const std::shared_ptr &call, linphone::CallState state); + void coreStarted (); void messageReceived (const std::shared_ptr &message); void presenceReceived (const QString &sipAddress, const std::shared_ptr &presenceModel); void registrationStateChanged (const std::shared_ptr &proxyConfig, linphone::RegistrationState state); @@ -54,6 +55,12 @@ private: const std::string &message ) override; + void onGlobalStateChanged ( + const std::shared_ptr &core, + linphone::GlobalState gstate, + const std::string &message + ) override; + void onCallStatsUpdated ( const std::shared_ptr &core, const std::shared_ptr &call, diff --git a/linphone-desktop/src/components/core/CoreManager.cpp b/linphone-desktop/src/components/core/CoreManager.cpp index 546f28c47..aa49305a7 100644 --- a/linphone-desktop/src/components/core/CoreManager.cpp +++ b/linphone-desktop/src/components/core/CoreManager.cpp @@ -48,6 +48,8 @@ CoreManager::CoreManager (QObject *parent, const QString &configPath) : QObject( mInstance->mSettingsModel = new SettingsModel(mInstance); mInstance->mAccountSettingsModel = new AccountSettingsModel(mInstance); + mInstance->mCbsTimer->start(); + emit mInstance->linphoneCoreCreated(); } ); @@ -55,10 +57,6 @@ CoreManager::CoreManager (QObject *parent, const QString &configPath) : QObject( mPromiseWatcher.setFuture(mPromiseBuild); } -void CoreManager::enableHandlers () { - mCbsTimer->start(); -} - // ----------------------------------------------------------------------------- void CoreManager::init (QObject *parent, const QString &configPath) { diff --git a/linphone-desktop/src/components/core/CoreManager.hpp b/linphone-desktop/src/components/core/CoreManager.hpp index eaf9e564b..515342c65 100644 --- a/linphone-desktop/src/components/core/CoreManager.hpp +++ b/linphone-desktop/src/components/core/CoreManager.hpp @@ -47,8 +47,6 @@ class CoreManager : public QObject { public: ~CoreManager () = default; - void enableHandlers (); - std::shared_ptr getCore () { return mCore; }