Commit 3647ed9c authored by Ronan Abhamon's avatar Ronan Abhamon

feat(src/components/core/CoreManager): schedule global state emit in the app thread

parent 9ee13e18
......@@ -21,6 +21,7 @@
*/
#include <QtDebug>
#include <QTimer>
#include "../../app/App.hpp"
#include "../../Utils.hpp"
......@@ -32,6 +33,10 @@ using namespace std;
// =============================================================================
inline void logGlobalState (linphone::GlobalState gstate) {
qInfo() << QStringLiteral("Global state: %1.").arg(gstate);
}
void CoreHandlers::onAuthenticationRequested (
const shared_ptr<linphone::Core> &,
const shared_ptr<linphone::AuthInfo> &authInfo,
......@@ -57,10 +62,15 @@ void CoreHandlers::onGlobalStateChanged (
linphone::GlobalState gstate,
const string &
) {
qInfo() << QStringLiteral("Global state: %1.").arg(gstate);
if (gstate == linphone::GlobalStateOn)
emit coreStarted ();
if (gstate == linphone::GlobalStateOn) {
QTimer::singleShot(
0, App::getInstance(), [this, gstate]() {
logGlobalState(gstate);
emit coreStarted();
}
);
} else
logGlobalState(gstate);
}
void CoreHandlers::onCallStatsUpdated (
......
......@@ -51,7 +51,7 @@ CoreManager::CoreManager (QObject *parent, const QString &configPath) : QObject(
qInfo() << QStringLiteral("Core created. Enable iterate.");
mInstance->mCbsTimer->start();
emit mInstance->linphoneCoreCreated();
emit mInstance->coreCreated();
}
);
......@@ -88,6 +88,8 @@ VcardModel *CoreManager::createDetachedVcardModel () {
}
void CoreManager::forceRefreshRegisters () {
Q_ASSERT(mCore != nullptr);
qInfo() << QStringLiteral("Refresh registers.");
mCore->refreshRegisters();
}
......
......@@ -48,10 +48,12 @@ public:
~CoreManager () = default;
std::shared_ptr<linphone::Core> getCore () {
Q_ASSERT(mCore != nullptr);
return mCore;
}
std::shared_ptr<CoreHandlers> getHandlers () {
Q_ASSERT(mHandlers != nullptr);
return mHandlers;
}
......@@ -72,22 +74,27 @@ public:
// ---------------------------------------------------------------------------
CallsListModel *getCallsListModel () const {
Q_ASSERT(mCallsListModel != nullptr);
return mCallsListModel;
}
ContactsListModel *getContactsListModel () const {
Q_ASSERT(mContactsListModel != nullptr);
return mContactsListModel;
}
SipAddressesModel *getSipAddressesModel () const {
Q_ASSERT(mSipAddressesModel != nullptr);
return mSipAddressesModel;
}
SettingsModel *getSettingsModel () const {
Q_ASSERT(mSettingsModel != nullptr);
return mSettingsModel;
}
AccountSettingsModel *getAccountSettingsModel () const {
Q_ASSERT(mAccountSettingsModel != nullptr);
return mAccountSettingsModel;
}
......@@ -99,6 +106,7 @@ public:
static void uninit ();
static CoreManager *getInstance () {
Q_ASSERT(mInstance != nullptr);
return mInstance;
}
......@@ -111,7 +119,7 @@ public:
Q_INVOKABLE void forceRefreshRegisters ();
signals:
void linphoneCoreCreated ();
void coreCreated ();
private:
CoreManager (QObject *parent, const QString &configPath);
......
......@@ -60,7 +60,7 @@ ApplicationWindow {
Connections {
target: CoreManager
onLinphoneCoreCreated: mainLoader.active = true
onCoreCreated: mainLoader.active = true
}
Shortcut {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment