mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-28 01:09:19 +00:00
feat(src/components/core/CoreHandlers): create a emitApp macro to emit a signal in the app context
This commit is contained in:
parent
3647ed9c2b
commit
f90b8b5b4e
1 changed files with 20 additions and 12 deletions
|
|
@ -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 (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue