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