From 0f3c42ca3119af0fb4d28986c73f57c926b7f8e2 Mon Sep 17 00:00:00 2001 From: Robert Adam Date: Sat, 12 Jun 2021 13:56:42 +0200 Subject: [PATCH] FIX(client, plugin-api): requestLocalUserTransmissionMode This particular API function was implemented to only set the respective settings variable. However this would not notify any other code part about the change resulting in a potential inconsistency between the UI and the actual settings. Therefore the implementation now delegates the actual setting of the transmission mode to MainWindow::setTransmission mode that takes care of emitting the appropriate signal and informs the user about a change in transmission mode. --- plugins/MumbleAPI_v_1_0_x.h | 2 +- src/mumble/API_v_1_0_x.cpp | 30 +++++++++++++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/plugins/MumbleAPI_v_1_0_x.h b/plugins/MumbleAPI_v_1_0_x.h index 4471680a1..5128fd4a0 100644 --- a/plugins/MumbleAPI_v_1_0_x.h +++ b/plugins/MumbleAPI_v_1_0_x.h @@ -15,7 +15,7 @@ // API version #define MUMBLE_PLUGIN_API_MAJOR_MACRO 1 #define MUMBLE_PLUGIN_API_MINOR_MACRO 0 -#define MUMBLE_PLUGIN_API_PATCH_MACRO 0 +#define MUMBLE_PLUGIN_API_PATCH_MACRO 1 const int32_t MUMBLE_PLUGIN_API_MAJOR = MUMBLE_PLUGIN_API_MAJOR_MACRO; const int32_t MUMBLE_PLUGIN_API_MINOR = MUMBLE_PLUGIN_API_MINOR_MACRO; diff --git a/src/mumble/API_v_1_0_x.cpp b/src/mumble/API_v_1_0_x.cpp index 0f78c6855..440d5c15c 100644 --- a/src/mumble/API_v_1_0_x.cpp +++ b/src/mumble/API_v_1_0_x.cpp @@ -636,19 +636,35 @@ void MumbleAPI::requestLocalUserTransmissionMode_v_1_0_x(mumble_plugin_id_t call VERIFY_PLUGIN_ID(callerID); + Settings::AudioTransmit mode; + bool identifiedTransmissionMode = false; + switch (transmissionMode) { case MUMBLE_TM_CONTINOUS: - Global::get().s.atTransmit = Settings::AudioTransmit::Continuous; - EXIT_WITH(MUMBLE_STATUS_OK); + mode = Settings::Continuous; + identifiedTransmissionMode = true; + break; case MUMBLE_TM_VOICE_ACTIVATION: - Global::get().s.atTransmit = Settings::AudioTransmit::VAD; - EXIT_WITH(MUMBLE_STATUS_OK); + mode = Settings::VAD; + identifiedTransmissionMode = true; + break; case MUMBLE_TM_PUSH_TO_TALK: - Global::get().s.atTransmit = Settings::AudioTransmit::PushToTalk; - EXIT_WITH(MUMBLE_STATUS_OK); + mode = Settings::PushToTalk; + identifiedTransmissionMode = true; + break; } - EXIT_WITH(MUMBLE_EC_UNKNOWN_TRANSMISSION_MODE); + if (identifiedTransmissionMode) { + if (!Global::get().mw) { + EXIT_WITH(MUMBLE_EC_INTERNAL_ERROR); + } + + Global::get().mw->setTransmissionMode(mode); + + EXIT_WITH(MUMBLE_STATUS_OK); + } else { + EXIT_WITH(MUMBLE_EC_UNKNOWN_TRANSMISSION_MODE); + } } void MumbleAPI::getUserComment_v_1_0_x(mumble_plugin_id_t callerID, mumble_connection_t connection,