diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/gui.cpp | 44 | ||||
-rw-r--r-- | src/userintf.cpp | 4 | ||||
-rw-r--r-- | src/userintf.h | 3 |
3 files changed, 35 insertions, 16 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 743f15f..97b621e 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -811,7 +811,9 @@ void t_gui::run(void) { restore_state(); // Initialize phone functions - phone->init(); + run_on_event_queue([=]() { + phone->init(); + }); // Set controls in correct status mainWindow->updateState(); @@ -2830,26 +2832,32 @@ string t_gui::get_name_from_abook(t_user *user_config, const t_url &u) { // User invoked actions on the phone object void t_gui::action_register(list<t_user *> user_list) { - for (list<t_user *>::iterator i = user_list.begin(); i != user_list.end(); i++) { - phone->pub_registration(*i, REG_REGISTER, - DUR_REGISTRATION(*i)); - } + run_on_event_queue([=]() { + for (list<t_user *>::const_iterator i = user_list.begin(); i != user_list.end(); i++) { + phone->pub_registration(*i, REG_REGISTER, + DUR_REGISTRATION(*i)); + } + }); } void t_gui::action_deregister(list<t_user *> user_list, bool dereg_all) { - for (list<t_user *>::iterator i = user_list.begin(); i != user_list.end(); i++) { - if (dereg_all) { - phone->pub_registration(*i, REG_DEREGISTER_ALL); - } else { - phone->pub_registration(*i, REG_DEREGISTER); + run_on_event_queue([=]() { + for (list<t_user *>::const_iterator i = user_list.begin(); i != user_list.end(); i++) { + if (dereg_all) { + phone->pub_registration(*i, REG_DEREGISTER_ALL); + } else { + phone->pub_registration(*i, REG_DEREGISTER); + } } - } + }); } void t_gui::action_show_registrations(list<t_user *> user_list) { - for (list<t_user *>::iterator i = user_list.begin(); i != user_list.end(); i++) { - phone->pub_registration(*i, REG_QUERY); - } + run_on_event_queue([=]() { + for (list<t_user *>::const_iterator i = user_list.begin(); i != user_list.end(); i++) { + phone->pub_registration(*i, REG_QUERY); + } + }); } void t_gui::action_invite(t_user *user_config, const t_url &destination, @@ -2885,7 +2893,9 @@ void t_gui::action_invite(t_user *user_config, const t_url &destination, displaySubject(subject.c_str()); - phone->pub_invite(user_config, destination, display, subject.c_str(), anonymous); + run_on_event_queue([=]() { + phone->pub_invite(user_config, destination, display, subject.c_str(), anonymous); + }); } void t_gui::action_answer(void) { @@ -2967,7 +2977,9 @@ void t_gui::action_options(void) { } void t_gui::action_options(t_user *user_config, const t_url &contact) { - phone->pub_options(user_config, contact); + run_on_event_queue([=]() { + phone->pub_options(user_config, contact); + }); } void t_gui::action_dtmf(const string &digits) { diff --git a/src/userintf.cpp b/src/userintf.cpp index bbd7fe6..edd0d0b 100644 --- a/src/userintf.cpp +++ b/src/userintf.cpp @@ -2226,6 +2226,10 @@ void t_userintf::run(void) { cout << endl; } +void t_userintf::run_on_event_queue(std::function<void()> fn) { + evq_ui_events.push_fncall(fn); +} + void t_userintf::process_events(void) { t_event *event; t_event_ui *ui_event; diff --git a/src/userintf.h b/src/userintf.h index fc45866..e9b5606 100644 --- a/src/userintf.h +++ b/src/userintf.h @@ -437,6 +437,9 @@ public: // Get all command names const list<string>& get_all_commands(void); + // Asynchronously run a function on this class' event queue + void run_on_event_queue(std::function<void()> fn); + }; void *process_events_main(void *arg); |