Commit f90b8b5b authored by Ronan Abhamon's avatar Ronan Abhamon

feat(src/components/core/CoreHandlers): create a emitApp macro to emit a signal in the app context

parent 3647ed9c
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
*/ */
#include <QtDebug> #include <QtDebug>
#include <QThread>
#include <QTimer> #include <QTimer>
#include "../../app/App.hpp" #include "../../app/App.hpp"
...@@ -33,9 +34,21 @@ using namespace std; ...@@ -33,9 +34,21 @@ using namespace std;
// ============================================================================= // =============================================================================
inline void logGlobalState (linphone::GlobalState gstate) { // Emit a signal in the app context.
qInfo() << QStringLiteral("Global state: %1.").arg(gstate); #define emitApp(EMIT) \
} do { \
App *app = App::getInstance(); \
if (QThread::currentThread() != app->thread()) { \
QTimer::singleShot( \
0, app, [this]() { \
(EMIT); \
} \
); \
} else \
(EMIT); \
} while (0)
// -----------------------------------------------------------------------------
void CoreHandlers::onAuthenticationRequested ( void CoreHandlers::onAuthenticationRequested (
const shared_ptr<linphone::Core> &, const shared_ptr<linphone::Core> &,
...@@ -62,15 +75,10 @@ void CoreHandlers::onGlobalStateChanged ( ...@@ -62,15 +75,10 @@ void CoreHandlers::onGlobalStateChanged (
linphone::GlobalState gstate, linphone::GlobalState gstate,
const string & const string &
) { ) {
if (gstate == linphone::GlobalStateOn) { qInfo() << QStringLiteral("Global state: %1.").arg(gstate);
QTimer::singleShot(
0, App::getInstance(), [this, gstate]() { if (gstate == linphone::GlobalStateOn)
logGlobalState(gstate); emitApp(coreStarted());
emit coreStarted();
}
);
} else
logGlobalState(gstate);
} }
void CoreHandlers::onCallStatsUpdated ( void CoreHandlers::onCallStatsUpdated (
......
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