diff --git a/.gitmodules b/.gitmodules index da73dfb..a3c9cae 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,3 @@ -[submodule "ts3_plugin/deps/DSPFilters"] - path = ts3_plugin/deps/DSPFilters - url = https://github.com/vinniefalco/DSPFilters -[submodule "ts3_plugin/deps/teamspeak-plugin-qt-common"] - path = ts3_plugin/deps/teamspeak-plugin-qt-common - url = https://github.com/thorwe/teamspeak-plugin-qt-common [submodule "ts3_plugin/deps/Simple-WebSocket-Server"] path = ts3_plugin/deps/Simple-WebSocket-Server url = https://gitlab.com/eidheim/Simple-WebSocket-Server @@ -13,3 +7,6 @@ [submodule "ts3_plugin/deps/json"] path = ts3_plugin/deps/json url = https://github.com/nlohmann/json.git +[submodule "ts3_plugin/deps/teamspeak-plugin-radiofx"] + path = ts3_plugin/deps/teamspeak-plugin-radiofx + url = https://github.com/Itokoyamato/teamspeak-plugin-radiofx diff --git a/ts3_plugin/CMakeLists.txt b/ts3_plugin/CMakeLists.txt index 55ff112..07acb7f 100644 --- a/ts3_plugin/CMakeLists.txt +++ b/ts3_plugin/CMakeLists.txt @@ -3,15 +3,14 @@ cmake_minimum_required (VERSION 3.6) project (TokoVoip LANGUAGES CXX) add_definitions(-DASIO_STANDALONE -DUSE_STANDALONE_ASIO) -find_package(Qt5 COMPONENTS Gui Widgets REQUIRED) -link_libraries(Qt5::Gui Qt5::Widgets) - set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) +find_package(Qt5 COMPONENTS Core Sql REQUIRED) +link_libraries(Qt5::Core Qt5::Sql) + include_directories( "src" - "deps/DSPFilters/shared/DSPFilters/include" "deps/openssl/include" "deps/asio/asio/include" "deps/Simple-WebSocket-Server" @@ -19,54 +18,15 @@ include_directories( "deps/curl/include/curl" ) -set (DSP_FILTERS - "deps/DSPFilters/shared/DSPFilters/source/Bessel.cpp" - "deps/DSPFilters/shared/DSPFilters/source/Biquad.cpp" - "deps/DSPFilters/shared/DSPFilters/source/Butterworth.cpp" - "deps/DSPFilters/shared/DSPFilters/source/Cascade.cpp" - "deps/DSPFilters/shared/DSPFilters/source/ChebyshevI.cpp" - "deps/DSPFilters/shared/DSPFilters/source/ChebyshevII.cpp" - "deps/DSPFilters/shared/DSPFilters/source/Custom.cpp" - "deps/DSPFilters/shared/DSPFilters/source/Design.cpp" - "deps/DSPFilters/shared/DSPFilters/source/Documentation.cpp" - "deps/DSPFilters/shared/DSPFilters/source/Elliptic.cpp" - "deps/DSPFilters/shared/DSPFilters/source/Filter.cpp" - "deps/DSPFilters/shared/DSPFilters/source/Legendre.cpp" - "deps/DSPFilters/shared/DSPFilters/source/Param.cpp" - "deps/DSPFilters/shared/DSPFilters/source/PoleFilter.cpp" - "deps/DSPFilters/shared/DSPFilters/source/RBJ.cpp" - "deps/DSPFilters/shared/DSPFilters/source/RootFinder.cpp" - "deps/DSPFilters/shared/DSPFilters/source/State.cpp" -) -source_group("DSPFilters" FILES ${DSP_FILTERS}) - -set (PLUGIN_SRC - "src/config_radio.h" - "src/config_radio.cpp" - "src/config_radio.ui" - "src/config_radio_groupbox.h" - "src/config_radio_groupbox.cpp" - "src/config_radio_groupbox.ui" - "src/dsp_radio.h" - "src/dsp_radio.cpp" - "src/mod_radio.h" - "src/mod_radio.cpp" - "src/plugin.h" - "src/plugin.cpp" - "src/plugin_qt.h" - "src/plugin_qt.cpp" - "src/settings_radio.h" - "src/settings_radio.cpp" +set (TOKOVOIP_SRC "src/tokovoip.cpp" "src/tokovoip.h" - - "radiofx.qrc" ) -source_group("plugin" FILES ${PLUGIN_SRC}) +source_group("tokovoip" FILES ${TOKOVOIP_SRC}) # Create named folders for the sources within the .vcproj # Empty name lists them directly under the .vcproj -#source_group("" FILES ${PLUGIN_SRC}) +#source_group("" FILES ${TOKOVOIP_SRC}) # Turn on the ability to create folders to organize projects (.vcproj) # It creates "CMakePredefinedTargets" folder by default and adds CMake @@ -82,12 +42,9 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON) # message ("cxx Flags:" ${CMAKE_CXX_FLAGS}) # Sub-directories where more CMakeLists.txt exist -#add_subdirectory(app) -#add_subdirectory (math) -set(WITH_VOLUME true) -set(WITH_VOLUME_WIDGETS true) -#add_subdirectory(../teamspeak-plugin-qt-common common_out) -include(deps/teamspeak-plugin-qt-common/CMakeLists.txt) +include(deps/teamspeak-plugin-radiofx/CMakeLists.txt) + +project (TokoVoip LANGUAGES CXX) if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4") link_directories(deps/curl/x86/lib) @@ -98,7 +55,7 @@ ENDIF() link_directories(deps/openssl/) add_library(TokoVoip SHARED - ${PLUGIN_SRC} ${TS_QT_CORE} ${TS_QT_VOLUME} ${DSP_FILTERS}) + ${TOKOVOIP_SRC} ${PLUGIN_SRC} ${TS_QT_CORE} ${TS_QT_VOLUME} ${DSP_FILTERS}) if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4") target_link_libraries(TokoVoip libcurl_a wldap32.lib crypt32.lib normaliz.lib libcrypto32MD.lib) @@ -106,4 +63,7 @@ if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4") ELSE() target_link_libraries(TokoVoip libcurl_a wldap32.lib crypt32.lib normaliz.lib libcrypto64MD.lib) set_target_properties(TokoVoip PROPERTIES OUTPUT_NAME "tokovoip_win64") -ENDIF() \ No newline at end of file +ENDIF() + +set_property(TARGET TokoVoip PROPERTY CXX_STANDARD 17) +set_property(TARGET TokoVoip PROPERTY CXX_STANDARD_REQUIRED ON) \ No newline at end of file diff --git a/ts3_plugin/deps/DSPFilters b/ts3_plugin/deps/DSPFilters deleted file mode 160000 index acc4917..0000000 --- a/ts3_plugin/deps/DSPFilters +++ /dev/null @@ -1 +0,0 @@ -Subproject commit acc49170e79a94fcb9c04b8a2116e9f8dffd1c7d diff --git a/ts3_plugin/deps/teamspeak-plugin-qt-common b/ts3_plugin/deps/teamspeak-plugin-qt-common deleted file mode 160000 index ff1159a..0000000 --- a/ts3_plugin/deps/teamspeak-plugin-qt-common +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ff1159a14a43a82b8ac4657cf9f1910a2dfe9ad6 diff --git a/ts3_plugin/deps/teamspeak-plugin-radiofx b/ts3_plugin/deps/teamspeak-plugin-radiofx new file mode 160000 index 0000000..5302dc5 --- /dev/null +++ b/ts3_plugin/deps/teamspeak-plugin-radiofx @@ -0,0 +1 @@ +Subproject commit 5302dc549a78f70e5b1ddf96f42790e9070050c4 diff --git a/ts3_plugin/misc/screenie.png b/ts3_plugin/misc/screenie.png deleted file mode 100644 index 66f64a7..0000000 Binary files a/ts3_plugin/misc/screenie.png and /dev/null differ diff --git a/ts3_plugin/misc/walkie_talkie.pdn b/ts3_plugin/misc/walkie_talkie.pdn deleted file mode 100644 index 9373a9f..0000000 Binary files a/ts3_plugin/misc/walkie_talkie.pdn and /dev/null differ diff --git a/ts3_plugin/radiofx.qrc b/ts3_plugin/radiofx.qrc deleted file mode 100644 index da22033..0000000 --- a/ts3_plugin/radiofx.qrc +++ /dev/null @@ -1,8 +0,0 @@ - - - res/radiofx_de_DE.qm - - - res/16x16_delete.png - - diff --git a/ts3_plugin/res/16x16_delete.png b/ts3_plugin/res/16x16_delete.png deleted file mode 100644 index 56cbc35..0000000 Binary files a/ts3_plugin/res/16x16_delete.png and /dev/null differ diff --git a/ts3_plugin/res/ct_16x16.png b/ts3_plugin/res/ct_16x16.png deleted file mode 100644 index 3aa553b..0000000 Binary files a/ts3_plugin/res/ct_16x16.png and /dev/null differ diff --git a/ts3_plugin/res/ct_logo_60.png b/ts3_plugin/res/ct_logo_60.png deleted file mode 100644 index eafa96c..0000000 Binary files a/ts3_plugin/res/ct_logo_60.png and /dev/null differ diff --git a/ts3_plugin/res/package.ini b/ts3_plugin/res/package.ini deleted file mode 100644 index fc2b6d7..0000000 --- a/ts3_plugin/res/package.ini +++ /dev/null @@ -1,6 +0,0 @@ -Name = RadioFx Plugin -Type = Plugin -Author = Thorsten Weinz -Version = 1.0.2 -Platforms = win64 -Description = "This plugin features Radio effects on incoming audio streams.\n" \ No newline at end of file diff --git a/ts3_plugin/res/radar_16.png b/ts3_plugin/res/radar_16.png deleted file mode 100644 index 5db1cbb..0000000 Binary files a/ts3_plugin/res/radar_16.png and /dev/null differ diff --git a/ts3_plugin/res/radiofx_de_DE.qm b/ts3_plugin/res/radiofx_de_DE.qm deleted file mode 100644 index a58eb10..0000000 Binary files a/ts3_plugin/res/radiofx_de_DE.qm and /dev/null differ diff --git a/ts3_plugin/res/walkie_talkie_16.png b/ts3_plugin/res/walkie_talkie_16.png deleted file mode 100644 index 8b2b1b9..0000000 Binary files a/ts3_plugin/res/walkie_talkie_16.png and /dev/null differ diff --git a/ts3_plugin/src/config_radio.cpp b/ts3_plugin/src/config_radio.cpp deleted file mode 100644 index 5f7d7e1..0000000 --- a/ts3_plugin/src/config_radio.cpp +++ /dev/null @@ -1,137 +0,0 @@ -#include "config_radio.h" - -#include "core/ts_helpers_qt.h" -#include -#include -#include "core/ts_logging_qt.h" - -ConfigRadio::ConfigRadio(QWidget *parent, QString server_name, QString channel_name) : - QDialog(parent), - m_title(channel_name) -{ - setAttribute( Qt::WA_DeleteOnClose ); -} - -ConfigRadio::~ConfigRadio() -{} - -void ConfigRadio::UpdateEnabled(QString name, bool val) -{ - auto channel_strip = GetChannelStrip(name); - channel_strip->blockSignals(true); - channel_strip->setChecked(val); - channel_strip->blockSignals(false); -} - -void ConfigRadio::UpdateBandpassInLowFrequency(QString name, double val) -{ - auto channel_strip = GetChannelStrip(name); - channel_strip->blockSignals(true); - channel_strip->onInLoValueChanged(val); - channel_strip->blockSignals(false); -} - -void ConfigRadio::UpdateBandpassInHighFrequency(QString name, double val) -{ - auto channel_strip = GetChannelStrip(name); - channel_strip->blockSignals(true); - channel_strip->onInHiValueChanged(val); - channel_strip->blockSignals(false); -} - -void ConfigRadio::UpdateDestruction(QString name, double val) -{ - auto channel_strip = GetChannelStrip(name); - channel_strip->blockSignals(true); - channel_strip->onDestrValueChanged(val); - channel_strip->blockSignals(false); -} - -void ConfigRadio::UpdateRingModFrequency(QString name, double val) -{ - auto channel_strip = GetChannelStrip(name); - channel_strip->blockSignals(true); - channel_strip->onRingModFrequencyValueChanged(val); - channel_strip->blockSignals(false); -} - -void ConfigRadio::UpdateRingModMix(QString name, double val) -{ - auto channel_strip = GetChannelStrip(name); - channel_strip->blockSignals(true); - channel_strip->onRingModMixValueChanged(val); - channel_strip->blockSignals(false); -} - -void ConfigRadio::UpdateBandpassOutLowFrequency(QString name, double val) -{ - auto channel_strip = GetChannelStrip(name); - channel_strip->blockSignals(true); - channel_strip->onOutLoValueChanged(val); - channel_strip->blockSignals(false); -} - -void ConfigRadio::UpdateBandpassOutHighFrequency(QString name, double val) -{ - auto channel_strip = GetChannelStrip(name); - channel_strip->blockSignals(true); - channel_strip->onOutHiValueChanged(val); - channel_strip->blockSignals(false); -} - -ConfigRadioGroupBox* ConfigRadio::GetChannelStrip(QString name) -{ - if (m_channelstrips.contains(name)) - return m_channelstrips.value(name); - - auto channel_strip = new ConfigRadioGroupBox; - channel_strip->setObjectName(name); - channel_strip->setTitle((m_title.isEmpty()) ? name : m_title); - - connect(channel_strip, &ConfigRadioGroupBox::EnabledSet, this, &ConfigRadio::EnabledSet); - connect(channel_strip, &ConfigRadioGroupBox::InLoFreqSet, this, &ConfigRadio::InLoFreqSet); - connect(channel_strip, &ConfigRadioGroupBox::InHiFreqSet, this, &ConfigRadio::InHiFreqSet); - connect(channel_strip, &ConfigRadioGroupBox::DestructionSet, this, &ConfigRadio::DestructionSet); - connect(channel_strip, &ConfigRadioGroupBox::RingModFrequencySet, this, &ConfigRadio::RingModFrequencySet); - connect(channel_strip, &ConfigRadioGroupBox::RingModMixSet, this, &ConfigRadio::RingModMixSet); - connect(channel_strip, &ConfigRadioGroupBox::OutLoFreqSet, this, &ConfigRadio::OutLoFreqSet); - connect(channel_strip, &ConfigRadioGroupBox::OutHiFreqSet, this, &ConfigRadio::OutHiFreqSet); - - setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); - if (m_title.isEmpty()) - { - if (!layout()) - { - setWindowTitle("Radio FX"); - setLayout(new QHBoxLayout); - } - - layout()->addWidget(channel_strip); - } - else - { - setWindowTitle(" "); - setLayout(new QVBoxLayout); - TSLogging::Log(QString("title: %1").arg(m_title), LogLevel_DEVEL); - layout()->addWidget(channel_strip); - auto remove_button = new QPushButton; - QIcon remove_icon(QStringLiteral(":/icons/delete.png")); - remove_button->setIcon(remove_icon); - remove_button->setAccessibleName("Delete"); - remove_button->setText("Delete"); - connect(remove_button, &QPushButton::clicked, this, [this] (bool checked) - { - Q_UNUSED(checked); - // since the x button occupies Rejected, our bool means isDelete - this->done(QDialog::DialogCode::Accepted); - }); - layout()->addWidget(remove_button); - connect(this, &ConfigRadio::finished, this, [this, name](int r) - { - emit channel_closed(r, name); - }); - } - m_channelstrips.insert(name, channel_strip); - setFixedSize(this->sizeHint()); - return channel_strip; -} diff --git a/ts3_plugin/src/config_radio.h b/ts3_plugin/src/config_radio.h deleted file mode 100644 index 687b124..0000000 --- a/ts3_plugin/src/config_radio.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -#include -#include - -#include "config_radio_groupbox.h" - -class ConfigRadio : public QDialog -{ - Q_OBJECT - -public: - explicit ConfigRadio( - QWidget *parent = 0, - QString server_name = QString::null, - QString channel_name = QString::null - ); - ~ConfigRadio(); - - // For Settings initialization and updating from other sources of interaction - void UpdateEnabled(QString name, bool val); - void UpdateBandpassInLowFrequency(QString name, double val); - void UpdateBandpassInHighFrequency(QString name, double val); - void UpdateDestruction(QString name, double val); - void UpdateRingModFrequency(QString name, double val); - void UpdateRingModMix(QString name, double val); - void UpdateBandpassOutLowFrequency(QString name, double val); - void UpdateBandpassOutHighFrequency(QString name, double val); - -signals: - void EnabledSet(QString,bool); - void InLoFreqSet(QString,double); - void InHiFreqSet(QString,double); - void DestructionSet(QString,double); - void RingModFrequencySet(QString,double); - void RingModMixSet(QString,double); - void OutLoFreqSet(QString,double); - void OutHiFreqSet(QString,double); - - // Accepted: isDeleteButton Rejected: is x button - void channel_closed(int, QString); // custom channel setting - -private: - QHash m_channelstrips; - ConfigRadioGroupBox* GetChannelStrip(QString name); - QString m_title; // for channel ident -}; diff --git a/ts3_plugin/src/config_radio.ui b/ts3_plugin/src/config_radio.ui deleted file mode 100644 index 2911b81..0000000 --- a/ts3_plugin/src/config_radio.ui +++ /dev/null @@ -1,54 +0,0 @@ - - - ConfigRadio - - - - 0 - 0 - 470 - 560 - - - - CrossTalk: Radio FX - - - - - 10 - 70 - 451 - 481 - - - - - - - - 0 - 0 - 470 - 62 - - - - QFrame::Panel - - - QFrame::Raised - - - - - - BannerFrame - QFrame -
banner_frame.h
- 1 -
-
- - -
diff --git a/ts3_plugin/src/config_radio_groupbox.cpp b/ts3_plugin/src/config_radio_groupbox.cpp deleted file mode 100644 index b4846d5..0000000 --- a/ts3_plugin/src/config_radio_groupbox.cpp +++ /dev/null @@ -1,89 +0,0 @@ -#include "config_radio_groupbox.h" -#include "ui_config_radio_groupbox.h" - -ConfigRadioGroupBox::ConfigRadioGroupBox(QWidget *parent) : - QGroupBox(parent), - ui(new Ui::ConfigRadioGroupBox) -{ - ui->setupUi(this); - - connect(ui->dial_in_lo, &QDial::valueChanged, [=](int val){ ui->doubleSpinBox_in_lo->setValue(static_cast< double > (val)); }); - connect(ui->dial_in_hi, &QDial::valueChanged, [=](int val){ ui->doubleSpinBox_in_hi->setValue(static_cast< double > (val)); }); - connect(ui->dial_out_lo, &QDial::valueChanged, [=](int val){ ui->doubleSpinBox_out_lo->setValue(static_cast< double > (val)); }); - connect(ui->dial_out_hi, &QDial::valueChanged, [=](int val){ ui->doubleSpinBox_out_hi->setValue(static_cast< double > (val)); }); - connect(ui->dial_destr, &QDial::valueChanged, [=](int val){ ui->doubleSpinBox_destr->setValue(static_cast< double > (val)); }); - connect(ui->dial_rm, &QDial::valueChanged, [=](int val){ ui->doubleSpinBox_rm->setValue(static_cast< double > (val)); }); - connect(ui->dial_rm_mix, &QDial::valueChanged, [=](int val){ ui->doubleSpinBox_rm_mix->setValue((static_cast< double > (val)) / 100.0f); }); - - // QT5 on overloaded functions ain't pretty - connect(ui->doubleSpinBox_in_lo, static_cast(&QDoubleSpinBox::valueChanged), this, &ConfigRadioGroupBox::onInLoValueChanged); - connect(ui->doubleSpinBox_in_hi, static_cast(&QDoubleSpinBox::valueChanged), this, &ConfigRadioGroupBox::onInHiValueChanged); - connect(ui->doubleSpinBox_out_lo, static_cast(&QDoubleSpinBox::valueChanged), this, &ConfigRadioGroupBox::onOutLoValueChanged); - connect(ui->doubleSpinBox_out_hi,static_cast(&QDoubleSpinBox::valueChanged), this, &ConfigRadioGroupBox::onOutHiValueChanged); - connect(ui->doubleSpinBox_destr, static_cast(&QDoubleSpinBox::valueChanged), this, &ConfigRadioGroupBox::onDestrValueChanged); - connect(ui->doubleSpinBox_rm, static_cast(&QDoubleSpinBox::valueChanged), this, &ConfigRadioGroupBox::onRingModFrequencyValueChanged); - connect(ui->doubleSpinBox_rm_mix, static_cast(&QDoubleSpinBox::valueChanged), this, &ConfigRadioGroupBox::onRingModMixValueChanged); - - connect(this, &ConfigRadioGroupBox::toggled, this, [this](bool val) { emit EnabledSet(this->objectName(),val); }); -} - -ConfigRadioGroupBox::~ConfigRadioGroupBox() -{ - delete ui; -} - -void ConfigRadioGroupBox::onInLoValueChanged(double val) -{ - if (!(ui->dial_in_lo->isSliderDown())) // loop breaker - ui->dial_in_lo->setValue(static_cast< int >(val)); - - emit InLoFreqSet(this->objectName(),val); -} - -void ConfigRadioGroupBox::onInHiValueChanged(double val) -{ - if (!(ui->dial_in_hi->isSliderDown())) // loop breaker - ui->dial_in_hi->setValue(static_cast< int >(val)); - - emit InHiFreqSet(this->objectName(),val); -} - -void ConfigRadioGroupBox::onDestrValueChanged(double val) -{ - if (!(ui->dial_destr->isSliderDown())) // loop breaker - ui->dial_destr->setValue(static_cast< int >(val)); - - emit DestructionSet(this->objectName(),val); -} - -void ConfigRadioGroupBox::onRingModFrequencyValueChanged(double val) -{ - if (!(ui->dial_rm->isSliderDown())) // loop breaker - ui->dial_rm->setValue(static_cast< int >(val)); - - emit RingModFrequencySet(this->objectName(),val); -} - -void ConfigRadioGroupBox::onRingModMixValueChanged(double val) -{ - if (!(ui->dial_rm_mix->isSliderDown())) // loop breaker - ui->dial_rm_mix->setValue(static_cast< int >(val * 100)); - - emit RingModMixSet(this->objectName(),val); -} - -void ConfigRadioGroupBox::onOutLoValueChanged(double val) -{ - if (!(ui->dial_out_lo->isSliderDown())) // loop breaker - ui->dial_out_lo->setValue(static_cast< int >(val)); - - emit OutLoFreqSet(this->objectName(),val); -} - -void ConfigRadioGroupBox::onOutHiValueChanged(double val) -{ - if (!(ui->dial_out_hi->isSliderDown())) // loop breaker - ui->dial_out_hi->setValue(static_cast< int >(val)); - - emit OutHiFreqSet(this->objectName(),val); -} diff --git a/ts3_plugin/src/config_radio_groupbox.h b/ts3_plugin/src/config_radio_groupbox.h deleted file mode 100644 index fb44be6..0000000 --- a/ts3_plugin/src/config_radio_groupbox.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -#include - -namespace Ui -{ -class ConfigRadioGroupBox; -} - -class ConfigRadioGroupBox : public QGroupBox -{ - Q_OBJECT - -public: - explicit ConfigRadioGroupBox(QWidget *parent = 0); - ~ConfigRadioGroupBox(); - -public slots: - - void onInLoValueChanged(double val); - void onInHiValueChanged(double val); - void onDestrValueChanged(double val); - void onRingModFrequencyValueChanged(double val); - void onRingModMixValueChanged(double val); - void onOutLoValueChanged(double val); - void onOutHiValueChanged(double val); - -signals: - void EnabledSet(QString,bool); - void InLoFreqSet(QString,double); - void InHiFreqSet(QString,double); - void DestructionSet(QString,double); - void RingModFrequencySet(QString,double); - void RingModMixSet(QString,double); - void OutLoFreqSet(QString, double); - void OutHiFreqSet(QString, double); - -private: - Ui::ConfigRadioGroupBox *ui; -}; diff --git a/ts3_plugin/src/config_radio_groupbox.ui b/ts3_plugin/src/config_radio_groupbox.ui deleted file mode 100644 index 96a5f46..0000000 --- a/ts3_plugin/src/config_radio_groupbox.ui +++ /dev/null @@ -1,532 +0,0 @@ - - - ConfigRadioGroupBox - - - - 0 - 0 - 146 - 475 - - - - - 0 - 0 - - - - - 146 - 475 - - - - - 146 - 475 - - - - - 146 - 475 - - - - GroupBox - - - GroupBox - - - true - - - false - - - - - 7 - 110 - 131 - 20 - - - - Qt::Horizontal - - - - - - 10 - 30 - 50 - 64 - - - - 60 - - - 999 - - - 10 - - - 100 - - - 60 - - - 9.699999999999999 - - - true - - - - - - 80 - 30 - 50 - 64 - - - - 1000 - - - 6000 - - - 10 - - - 100 - - - 9.699999999999999 - - - true - - - - - - 10 - 20 - 121 - 16 - - - - - 50 - true - false - - - - - - - Frequency Range In - - - - - - 80 - 90 - 54 - 22 - - - - - - - 0 - - - 1000.000000000000000 - - - 6000.000000000000000 - - - 10.000000000000000 - - - - - - 10 - 90 - 54 - 22 - - - - 0 - - - 60.000000000000000 - - - 999.000000000000000 - - - 10.000000000000000 - - - 60.000000000000000 - - - - - - 10 - 240 - 71 - 16 - - - - - true - - - - Destruction - - - - - - 35 - 247 - 71 - 91 - - - - 20 - - - 9.699999999999999 - - - true - - - - - - 45 - 332 - 54 - 20 - - - - 2 - - - 20.000000000000000 - - - - - - 7 - 220 - 131 - 20 - - - - Qt::Horizontal - - - - - - 10 - 130 - 101 - 16 - - - - - true - - - - Ring Modulator - - - - - - 10 - 140 - 50 - 64 - - - - Modulator Frequency - - - 10000 - - - 10 - - - 100 - - - 9.699999999999999 - - - true - - - - - - 10 - 200 - 54 - 20 - - - - Hz - - - 0 - - - 10000.000000000000000 - - - 100.000000000000000 - - - - - - 80 - 140 - 50 - 64 - - - - Mix - - - 0 - - - 100 - - - 10 - - - 100 - - - 0 - - - 9.699999999999999 - - - true - - - - - - 80 - 200 - 54 - 22 - - - - - - - 2 - - - 0.000000000000000 - - - 1.000000000000000 - - - 0.100000000000000 - - - - - - 7 - 350 - 131 - 20 - - - - Qt::Horizontal - - - - - - 10 - 370 - 121 - 16 - - - - - 50 - true - false - - - - Frequency Range Out - - - - - - 10 - 440 - 54 - 22 - - - - 0 - - - 60.000000000000000 - - - 999.000000000000000 - - - 10.000000000000000 - - - 60.000000000000000 - - - - - - 10 - 380 - 50 - 64 - - - - 60 - - - 999 - - - 10 - - - 100 - - - 60 - - - 9.699999999999999 - - - true - - - - - - 80 - 380 - 50 - 64 - - - - 1000 - - - 6000 - - - 10 - - - 100 - - - 9.699999999999999 - - - true - - - - - - 80 - 440 - 54 - 22 - - - - - - - 0 - - - 1000.000000000000000 - - - 6000.000000000000000 - - - 10.000000000000000 - - - - - - diff --git a/ts3_plugin/src/dsp_radio.cpp b/ts3_plugin/src/dsp_radio.cpp deleted file mode 100644 index 4b32452..0000000 --- a/ts3_plugin/src/dsp_radio.cpp +++ /dev/null @@ -1,306 +0,0 @@ -#include "dsp_radio.h" - -#include - -#ifndef M_PI -#define M_PI 3.14159265358979323846f -#endif -const double TWO_PI_OVER_SAMPLE_RATE = 2*M_PI/48000; - -DspRadio::DspRadio(QObject *parent) : - QObject(parent) -{ - Dsp::Params params; - params[0] = 48000; // sample rate - params[1] = 4; // order - params[2] = 1600; // center frequency - params[3] = 1300; // band width - f_m->setParams(params); - f_s->setParams(params); - f_m_o->setParams(params); - f_s_o->setParams(params); -} - -void DspRadio::setEnabled(QString name, bool val) -{ - if (name.isEmpty() || (name == m_channel_type)) - { - if (m_enabled == val) - return; - - m_enabled = val; - } -} - -void DspRadio::setFudge(QString name, double val) -{ - if (name.isEmpty() || (name == m_channel_type)) - { - if (m_fudge == val) - return; - - m_fudge = val; - emit fudgeChanged(m_fudge); - } -} - -void DspRadio::setBandpassEqInCenterFrequency(QString name, double val) -{ - if (name.isEmpty() || (name == m_channel_type)) - { - if (f_m) - f_m->setParam(2, val); - if (f_s) - f_s->setParam(2, val); - - emit bandpassEqInCenterFrequencyChanged(val); - } -} - -void DspRadio::setBandpassEqInBandWidth(QString name, double val) -{ - if (name.isEmpty() || (name == m_channel_type)) - { - if (f_m) - f_m->setParam(3, val); - if (f_s) - f_s->setParam(3, val); - - emit bandpassEqInBandWidthChanged(val); - } -} - -void DspRadio::setRmModFreq(QString name, double val) -{ - if (name.isEmpty() || (name == m_channel_type)) - { - if (m_rm_mod_freq == val) - return; - - m_rm_mod_freq = val; - - emit ringModFrequencyChanged(val); - } -} - -void DspRadio::setRmMix(QString name, double val) -{ - if (name.isEmpty() || (name == m_channel_type)) - { - if (m_rm_mix == val) - return; - - m_rm_mix = val; - - emit ringModMixChanged(val); - } -} - -void DspRadio::setBandpassEqOutCenterFrequency(QString name, double val) -{ - if (name.isEmpty() || (name == m_channel_type)) - { - if (f_m_o) - f_m_o->setParam(2, val); - if (f_s_o) - f_s_o->setParam(2, val); - - emit bandpassEqOutCenterFrequencyChanged(val); - } -} - -void DspRadio::setBandpassEqOutBandWidth(QString name, double val) -{ - if (name.isEmpty() || (name == m_channel_type)) - { - if (f_m_o) - f_m_o->setParam(3, val); - if (f_s_o) - f_s_o->setParam(3, val); - - emit bandpassEqOutBandWidthChanged(val); - } -} - -void DspRadio::do_process(float *samples, int sampleCount, float &volFollow) -{ - // ALL INPUTS AND OUTPUTS IN THIS ARE -1.0f and +1.0f - // Find volume of current block of frames... - float vol = 0.0f; - // float min = 1.0f, max = -1.0f; - for (int i = 0; i < sampleCount; i++) - { - vol += (samples[i] * samples[i]); - } - vol /= (float)sampleCount; - - // Fudge factor, inrease for more noise - vol *= (float)getFudge(); - - // Smooth follow from last frame, both multiplies add up to 1... - volFollow = volFollow * 0.5f + vol * 0.5f; - - // Between -1.0f and 1.0f... - float random = (((float)(rand()&32767)) / 16384.0f) - 1.0f; - - // Between 1 and 128... - int count = (rand() & 127) + 1; - float temp; - for (int i = 0; i < sampleCount; i++) - { - if (!count--) - { -// // Between -1.0f and 1.0f... - random = (((float)(rand()&32767)) / 16384.0f) - 1.0f; -// // Between 1 and 128... - count = (rand() & 127) + 1; - } - // Add random to inputs * by current volume; - temp = samples[i] + random * volFollow; - - // Make it an integer between -60 and 60 - temp = (int)(temp * 40.0f); - - // Drop it back down but massively quantised and too high - temp = (temp / 40.0f); - temp *= 0.05 * (float)getFudge(); - temp += samples[i] * (1 - (0.05 * (float)getFudge())); - samples[i] = qBound(-1.0f,temp,1.0f); - } -} - -void DspRadio::do_process_ring_mod(float *samples, int sampleCount, double &modAngle) -{ - if ((m_rm_mod_freq != 0.0f) && (m_rm_mix != 0.0f)) - { - for (int i=0; i < sampleCount; ++i) - { - float sample = samples[i]; - sample = (sample * (1-m_rm_mix)) + (m_rm_mix * (sample * sin(modAngle))); - samples[i] = qBound(-1.0f,sample,1.0f); - modAngle += m_rm_mod_freq * TWO_PI_OVER_SAMPLE_RATE; - } - } -} - -void DspRadio::process(short *samples, int sampleCount, int channels) -{ -// Dsp::Filter* f = (channels==1)?f_m:f_s; - - if (!getEnabled()) - return; - - if (channels == 1) - { - QVarLengthArray data(sampleCount); //Test has been 480 - for (int i=0; iprocess(sampleCount, audioData); - - do_process_ring_mod(data.data(), sampleCount, m_rm_mod_angle); - - if (getFudge() > 0.0f) - do_process(data.data(), sampleCount, m_vol_follow); - - f_m_o->process(sampleCount, audioData); - - dsp_volume_agmu.process(samples, sampleCount, channels); - - for(int i=0; i < sampleCount; ++i) - samples[i] = (short)(data[i] * 32768.f); - - } - else if (channels == 2) - { - // Extract from interleaved and convert to QVarLengthArray - QVarLengthArray c_data_left(sampleCount); - QVarLengthArray c_data_right(sampleCount); - for(int i=0; i < sampleCount; ++i) - { - c_data_left[i] = samples[i*2] / 32768.f; - c_data_right[i] = samples[1 + (i*2)] / 32768.f; - } - - float* audioData[2]; - audioData[0] = c_data_left.data(); - audioData[1] = c_data_right.data(); - f_s->process(sampleCount, audioData); - - do_process_ring_mod(c_data_left.data(), sampleCount, m_rm_mod_angle); - do_process_ring_mod(c_data_right.data(), sampleCount, m_rm_mod_angle_r); - - if (getFudge() > 0.0f) - { - do_process(c_data_left.data(), sampleCount, m_vol_follow); - do_process(c_data_right.data(), sampleCount, m_vol_follow_r); - } - - f_s_o->process(sampleCount, audioData); - - dsp_volume_agmu.process(samples, sampleCount, channels); - - for(int i=0; i < sampleCount; ++i) - { - samples[i*2] = (short)(c_data_left[i] * 32768.f); - samples[1 + (i*2)] = (short)(c_data_right[i] * 32768.f); - } - } -} - -void DspRadio::setChannelType(QString name) -{ - m_channel_type = name; -} - -float DspRadio::getFudge() const -{ - return m_fudge; -} - -double DspRadio::getBandpassEqInCenterFrequency() const -{ - if (f_m) - return f_m->getParam(2); - else if (f_s) - return f_s->getParam(2); - else - return -1; -} - -double DspRadio::getBandpassEqInBandWidth() const -{ - if (f_m) - return f_m->getParam(3); - else if (f_s) - return f_s->getParam(3); - else - return -1; -} - -double DspRadio::getRmModFreq() const -{ - return m_rm_mod_freq; -} - -double DspRadio::getBandpassEqOutCenterFrequency() const -{ - if (f_m_o) - return f_m_o->getParam(2); - else if (f_s_o) - return f_s_o->getParam(2); - else - return -1; -} - -double DspRadio::getBandpassEqOutBandWidth() const -{ - if (f_m_o) - return f_m_o->getParam(3); - else if (f_s_o) - return f_s_o->getParam(3); - else - return -1; -} diff --git a/ts3_plugin/src/dsp_radio.h b/ts3_plugin/src/dsp_radio.h deleted file mode 100644 index d4e0baa..0000000 --- a/ts3_plugin/src/dsp_radio.h +++ /dev/null @@ -1,78 +0,0 @@ -#pragma once - -#include -#include -#include -#include "volume/dsp_volume_agmu.h" - -class DspRadio : public QObject -{ - Q_OBJECT - - Q_PROPERTY(bool enabled READ getEnabled NOTIFY enabledSet) - Q_PROPERTY(double fudge READ getFudge NOTIFY fudgeChanged) - Q_PROPERTY(double eq_bp_center_frequency READ getBandpassEqInCenterFrequency NOTIFY bandpassEqInCenterFrequencyChanged) - Q_PROPERTY(double eq_bp_band_width READ getBandpassEqInBandWidth NOTIFY bandpassEqInBandWidthChanged) - Q_PROPERTY(double rm_modFreq READ getRmModFreq NOTIFY ringModFrequencyChanged) - -public: - explicit DspRadio(QObject *parent = 0); - - void process(short* samples, int sampleCount, int channels); - - void setChannelType(QString name); - - bool getEnabled() const {return m_enabled;} - float getFudge() const; - double getBandpassEqInCenterFrequency() const; - double getBandpassEqInBandWidth() const; - double getRmModFreq() const; - double getBandpassEqOutCenterFrequency() const; - double getBandpassEqOutBandWidth() const; - -signals: - void enabledSet(bool); - void fudgeChanged(double); - void bandpassEqInCenterFrequencyChanged(double); - void bandpassEqInBandWidthChanged(double); - void ringModFrequencyChanged(double); - void ringModMixChanged(double); - void bandpassEqOutCenterFrequencyChanged(double); - void bandpassEqOutBandWidthChanged(double); - -public slots: - void setEnabled(QString name, bool val); - void setFudge(QString name, double val); - void setBandpassEqInCenterFrequency(QString name, double val); - void setBandpassEqInBandWidth(QString name, double val); - void setRmModFreq(QString name, double val); - void setRmMix(QString name, double val); - void setBandpassEqOutCenterFrequency(QString name, double val); - void setBandpassEqOutBandWidth(QString name, double val); - -private: - void do_process(float *samples, int sampleCount, float &volFollow); - void do_process_ring_mod(float *samples, int sampleCount, double &modAngle); - - QString m_channel_type; - - float m_vol_follow = 0.0f; - float m_vol_follow_r = 0.0f; - - bool m_enabled; - double m_fudge = 0.0f; - - std::unique_ptr f_m = std::make_unique< Dsp::SmoothedFilterDesign, 1, Dsp::DirectFormII> >(1024); - std::unique_ptr f_s = std::make_unique< Dsp::SmoothedFilterDesign, 2, Dsp::DirectFormII> >(1024); - - std::unique_ptr f_m_o = std::make_unique< Dsp::SmoothedFilterDesign, 1, Dsp::DirectFormII> >(1024); - std::unique_ptr f_s_o = std::make_unique< Dsp::SmoothedFilterDesign, 2, Dsp::DirectFormII> >(1024); - - //RingMod - double m_rm_mod_freq = 0.0f; - double m_rm_mod_angle = 0.0f; - double m_rm_mod_angle_r = 0.0f; - double m_rm_mix = 0.0f; - - DspVolumeAGMU dsp_volume_agmu; -}; diff --git a/ts3_plugin/src/mod_radio.cpp b/ts3_plugin/src/mod_radio.cpp deleted file mode 100644 index 152d12b..0000000 --- a/ts3_plugin/src/mod_radio.cpp +++ /dev/null @@ -1,381 +0,0 @@ -#include "mod_radio.h" - -#include "core/ts_helpers_qt.h" -#include "core/ts_serversinfo.h" -#include -#include "plugin.h" -#include "teamspeak/public_errors.h" -#include "tokovoip.h" - -Radio::Radio(TSServersInfo& servers_info, Talkers& talkers, const char* plugin_id, QObject* parent) - : m_servers_info(servers_info) - , m_talkers(talkers) -{ - setParent(parent); - setObjectName("Radio"); - m_isPrintEnabled = false; - tokovoip.initialize((char *)plugin_id); -} - -void Radio::setHomeId(uint64 serverConnectionHandlerID) -{ - if (m_homeId == serverConnectionHandlerID) - return; - - m_homeId = serverConnectionHandlerID; - - if (m_homeId == 0) - return; - - if (isRunning()) - m_talkers.DumpTalkStatusChanges(this, true); -} - -void Radio::setChannelStripEnabled(QString name, bool val) -{ - if (m_SettingsMap.contains(name)) - { - if (m_SettingsMap.value(name).enabled != val) - m_SettingsMap[name].enabled = val; - } - else - { - auto setting = RadioFX_Settings(); - setting.name = name; - setting.enabled = val; - m_SettingsMap.insert(name, setting); - } - //Log(QString("%1 enabled %2").arg(name).arg(val),LogLevel_DEBUG); - emit ChannelStripEnabledSet(name, val); -} - -void Radio::setFudge(QString name, double val) -{ - if (m_SettingsMap.contains(name)) - { - if (m_SettingsMap.value(name).fudge != val) - m_SettingsMap[name].fudge = val; - } - else - { - auto setting = RadioFX_Settings(); - setting.name = name; - setting.fudge = val; - m_SettingsMap.insert(name, setting); - } - //Log(QString("%1 fudge %2").arg(name).arg(val),LogLevel_DEBUG); - emit FudgeChanged(name, val); -} - -void Radio::setInLoFreq(QString name, double val) -{ - if (m_SettingsMap.contains(name)) - { - if (m_SettingsMap.value(name).freq_low != val) - m_SettingsMap[name].freq_low = val; - } - else - { - auto setting = RadioFX_Settings(); - setting.name = name; - setting.freq_low = val; - m_SettingsMap.insert(name, setting); - } - emit InBpCenterFreqSet(name, getCenterFrequencyIn(m_SettingsMap.value(name))); - emit InBpBandwidthSet(name, getBandWidthIn(m_SettingsMap.value(name))); - - //Log(QString("%1 low_freq %2").arg(name).arg(val),LogLevel_DEBUG); - emit InLoFreqSet(name,val); -} - -void Radio::setInHiFreq(QString name, double val) -{ - if (m_SettingsMap.contains(name)) - { - if (m_SettingsMap.value(name).freq_hi != val) - m_SettingsMap[name].freq_hi = val; - } - else - { - auto setting = RadioFX_Settings(); - setting.name = name; - setting.freq_hi = val; - m_SettingsMap.insert(name, setting); - } - emit InBpCenterFreqSet(name, getCenterFrequencyIn(m_SettingsMap.value(name))); - emit InBpBandwidthSet(name, getBandWidthIn(m_SettingsMap.value(name))); - - //Log(QString("%1 hi_freq %2").arg(name).arg(val),LogLevel_DEBUG); - emit InHiFreqSet(name,val); -} - -void Radio::setRingModFrequency(QString name, double val) -{ - if (m_SettingsMap.contains(name)) - { - if (m_SettingsMap.value(name).rm_mod_freq != val) - m_SettingsMap[name].rm_mod_freq = val; - } - else - { - auto setting = RadioFX_Settings(); - setting.name = name; - setting.rm_mod_freq = val; - m_SettingsMap.insert(name, setting); - } - //Log(QString("%1 rm_mod_freq %2").arg(name).arg(val),LogLevel_DEBUG); - emit RingModFrequencyChanged(name,val); -} - -void Radio::setRingModMix(QString name, double val) -{ - if (m_SettingsMap.contains(name)) - { - if (m_SettingsMap.value(name).rm_mix != val) - m_SettingsMap[name].rm_mix = val; - } - else - { - auto setting = RadioFX_Settings(); - setting.name = name; - setting.rm_mix = val; - m_SettingsMap.insert(name,setting); - } - //Log(QString("%1 rm_mix %2").arg(name).arg(val),LogLevel_DEBUG); - emit RingModMixChanged(name,val); -} - -void Radio::setOutLoFreq(QString name, double val) -{ - if (m_SettingsMap.contains(name)) - { - if (m_SettingsMap.value(name).o_freq_lo != val) - m_SettingsMap[name].o_freq_lo = val; - } - else - { - auto setting = RadioFX_Settings(); - setting.name = name; - setting.o_freq_lo = val; - m_SettingsMap.insert(name, setting); - } - emit OutBpCenterFreqSet(name, getCenterFrequencyOut(m_SettingsMap.value(name))); - emit OutBpBandwidthSet(name, getBandWidthOut(m_SettingsMap.value(name))); - - emit OutLoFreqSet(name,val); -} - -void Radio::setOutHiFreq(QString name, double val) -{ - if (m_SettingsMap.contains(name)) - { - if (m_SettingsMap.value(name).o_freq_hi != val) - m_SettingsMap[name].o_freq_hi = val; - } - else - { - auto setting = RadioFX_Settings(); - setting.name = name; - setting.o_freq_hi = val; - m_SettingsMap.insert(name, setting); - } - emit OutBpCenterFreqSet(name, getCenterFrequencyOut(m_SettingsMap.value(name))); - emit OutBpBandwidthSet(name, getBandWidthOut(m_SettingsMap.value(name))); - - //Log(QString("%1 rm_mix %2").arg(name).arg(val),LogLevel_DEBUG); - emit OutHiFreqSet(name, val); -} - -void Radio::ToggleClientBlacklisted(uint64 serverConnectionHandlerID, anyID clientID) -{ - if (m_ClientBlacklist.contains(serverConnectionHandlerID, clientID)) - m_ClientBlacklist.remove(serverConnectionHandlerID, clientID); - else - m_ClientBlacklist.insert(serverConnectionHandlerID, clientID); - - if (!(isRunning())) - return; - - if (!(m_talkers_dspradios.contains(serverConnectionHandlerID))) - return; - - auto sDspRadios = m_talkers_dspradios.value(serverConnectionHandlerID); - if (sDspRadios->contains(clientID)) - sDspRadios->value(clientID)->setEnabled(QString::null,!isClientBlacklisted(serverConnectionHandlerID, clientID)); -} - -bool Radio::isClientBlacklisted(uint64 serverConnectionHandlerID, anyID clientID) -{ - return m_ClientBlacklist.contains(serverConnectionHandlerID,clientID); -} - -void Radio::onRunningStateChanged(bool value) -{ - m_talkers.DumpTalkStatusChanges(this, ((value) ? STATUS_TALKING : STATUS_NOT_TALKING)); //FlushTalkStatusChanges((value)?STATUS_TALKING:STATUS_NOT_TALKING); - Log(QString("enabled: %1").arg((value)?"true":"false")); -} - -//! Returns true iff it will or has been an active processing -bool Radio::onTalkStatusChanged(uint64 serverConnectionHandlerID, int status, bool isReceivedWhisper, anyID clientID, bool isMe) -{ - if (isMe && status == STATUS_TALKING) - sendCallback("startedtalking"); - if (isMe && status == STATUS_NOT_TALKING) - sendCallback("stoppedtalking"); - if (isMe || !isRunning()) - return false; - - if (status == STATUS_TALKING) - { // Robust against multiple STATUS_TALKING in a row to be able to use it when the user changes settings - - unsigned int error = ERROR_ok; - uint64 channel_id; - if (!isReceivedWhisper) - { // Filter talk events outside of our channel - anyID my_id; - if ((error = ts3Functions.getClientID(serverConnectionHandlerID, &my_id)) != ERROR_ok) - this->Error("Error getting my id", serverConnectionHandlerID, error); - - uint64 my_channel_id; - if ((error = ts3Functions.getChannelOfClient(serverConnectionHandlerID, my_id, &my_channel_id)) != ERROR_ok) - this->Error("Error getting my channel id", serverConnectionHandlerID, error); - - if ((error = ts3Functions.getChannelOfClient(serverConnectionHandlerID, clientID, &channel_id)) != ERROR_ok) - this->Error("Error getting my channel id", serverConnectionHandlerID, error); - - if (channel_id != my_channel_id) - return false; - } - - DspRadio* dsp_obj; - auto isNewDspObj = true; - if (!(m_talkers_dspradios.contains(serverConnectionHandlerID))) - { - dsp_obj = new DspRadio(this); - auto sDspRadios = new QHash; - sDspRadios->insert(clientID, dsp_obj); - m_talkers_dspradios.insert(serverConnectionHandlerID, sDspRadios); - } - else - { - auto sDspRadios = m_talkers_dspradios.value(serverConnectionHandlerID); - if (sDspRadios->contains(clientID)) - { - dsp_obj = sDspRadios->value(clientID); - isNewDspObj = false; - } - else - { - dsp_obj = new DspRadio(this); - sDspRadios->insert(clientID, dsp_obj); - } - } - - if (!isNewDspObj) - this->disconnect(dsp_obj); - - RadioFX_Settings settings; - if (isReceivedWhisper) - settings = m_SettingsMap.value("Whisper"); - else - { - // get channel - auto server_id = m_servers_info.get_server_info(serverConnectionHandlerID, true)->getUniqueId(); - auto channel_path = TSHelpers::GetChannelPath(serverConnectionHandlerID, channel_id); - - QString settings_map_key(server_id + channel_path); - //this->Log(settings_map_key); - // if (error == ERROR_ok && (!channel_path.isEmpty()) && m_SettingsMap.contains(settings_map_key)) - // { - // //this->Log("Applying custom setting"); - // settings = m_SettingsMap.value(settings_map_key); - // } - if (serverConnectionHandlerID == m_homeId) - settings = m_SettingsMap.value("Home"); - else - settings = m_SettingsMap.value("Other"); - } - - dsp_obj->setChannelType(settings.name); - dsp_obj->setEnabled(settings.name, settings.enabled); - dsp_obj->setBandpassEqInCenterFrequency(settings.name, getCenterFrequencyIn(settings)); - dsp_obj->setBandpassEqInBandWidth(settings.name, getBandWidthIn(settings)); - dsp_obj->setFudge(settings.name, settings.fudge); - dsp_obj->setRmModFreq(settings.name, settings.rm_mod_freq); - dsp_obj->setRmMix(settings.name, settings.rm_mix); - dsp_obj->setBandpassEqOutCenterFrequency(settings.name, getCenterFrequencyOut(settings)); - dsp_obj->setBandpassEqOutBandWidth(settings.name, getBandWidthOut(settings)); - connect(this, &Radio::ChannelStripEnabledSet, dsp_obj, &DspRadio::setEnabled, Qt::UniqueConnection); - connect(this, &Radio::FudgeChanged, dsp_obj, &DspRadio::setFudge, Qt::UniqueConnection); - connect(this, &Radio::InBpCenterFreqSet, dsp_obj, &DspRadio::setBandpassEqInCenterFrequency, Qt::UniqueConnection); - connect(this, &Radio::InBpBandwidthSet, dsp_obj, &DspRadio::setBandpassEqInBandWidth, Qt::UniqueConnection); - connect(this, &Radio::RingModFrequencyChanged, dsp_obj, &DspRadio::setRmModFreq, Qt::UniqueConnection); - connect(this, &Radio::RingModMixChanged, dsp_obj, &DspRadio::setRmMix, Qt::UniqueConnection); - connect(this, &Radio::OutBpCenterFreqSet, dsp_obj, &DspRadio::setBandpassEqOutCenterFrequency, Qt::UniqueConnection); - connect(this, &Radio::OutBpBandwidthSet, dsp_obj, &DspRadio::setBandpassEqOutBandWidth, Qt::UniqueConnection); - - return settings.enabled; - } - else if (status == STATUS_NOT_TALKING) - { - // Removing does not need to be robust against multiple STATUS_NOT_TALKING in a row, since that doesn't happen on user setting change - if (!m_talkers_dspradios.contains(serverConnectionHandlerID)) - return false; // return silent bec. of ChannelMuter implementation - - auto server_dsp_radios = m_talkers_dspradios.value(serverConnectionHandlerID); - if (!(server_dsp_radios->contains(clientID))) - return false; - - auto dsp_obj = server_dsp_radios->value(clientID); - dsp_obj->blockSignals(true); - const auto kIsEnabled = dsp_obj->getEnabled(); - dsp_obj->deleteLater(); - server_dsp_radios->remove(clientID); - return kIsEnabled; - } - return false; -} - -//! Routes the arguments of the event to the corresponding volume object -/*! - * \brief Radio::onEditPlaybackVoiceDataEvent pre-processing voice event - * \param serverConnectionHandlerID the connection id of the server - * \param clientID the client-side runtime-id of the sender - * \param samples the sample array to manipulate - * \param sampleCount amount of samples in the array - * \param channels amount of channels - */ -void Radio::onEditPlaybackVoiceDataEvent(uint64 serverConnectionHandlerID, anyID clientID, short *samples, int sampleCount, int channels) -{ - DWORD error; - if (!(isRunning())) - return; - - if (!(m_talkers_dspradios.contains(serverConnectionHandlerID))) - return; - - auto server_dsp_radios = m_talkers_dspradios.value(serverConnectionHandlerID); - if (!(server_dsp_radios->contains(clientID))) - return; - - char *UUID; - if ((error = ts3Functions.getClientVariableAsString(ts3Functions.getCurrentServerConnectionHandlerID(), clientID, CLIENT_UNIQUE_IDENTIFIER, &UUID)) != ERROR_ok) { - outputLog("Error getting client UUID", error); - } - else - { - if (tokovoip.getRadioData(UUID)) - server_dsp_radios->value(clientID)->process(samples, sampleCount, channels); - ts3Functions.freeMemory(UUID); - } -} - -QHash Radio::GetSettingsMap() const -{ - return m_SettingsMap; -} - -QHash& Radio::GetSettingsMapRef() -{ - return m_SettingsMap; -} diff --git a/ts3_plugin/src/mod_radio.h b/ts3_plugin/src/mod_radio.h deleted file mode 100644 index 8a8ddf3..0000000 --- a/ts3_plugin/src/mod_radio.h +++ /dev/null @@ -1,101 +0,0 @@ -#pragma once - -#include -#include - -#include "core/module.h" -#include "core/talkers.h" -#include "dsp_radio.h" -#include "core/ts_serversinfo.h" -#include "core/talkers.h" -#include "tokovoip.h" - -struct RadioFX_Settings -{ - QString name = ""; - bool enabled = false; - double freq_low = 0.0; - double freq_hi = 0.0; - double fudge = 0.0; - double rm_mod_freq = 0.0; - double rm_mix = 0.0; - double o_freq_lo = 0.0; - double o_freq_hi = 0.0; -}; - -class Radio : public Module, public TalkInterface -{ - Q_OBJECT - Q_INTERFACES(TalkInterface) - Q_PROPERTY(uint64 homeId READ homeId WRITE setHomeId) - -public: - explicit Radio(TSServersInfo& servers_info, Talkers& talkers, const char* plugin_id, QObject* parent = nullptr); - - bool onTalkStatusChanged(uint64 serverConnectionHandlerID, int status, bool isReceivedWhisper, anyID clientID, bool isMe); - - void setHomeId(uint64 serverConnectionHandlerID); - uint64 homeId() {return m_homeId;} - - bool isClientBlacklisted(uint64 serverConnectionHandlerID, anyID clientID); - - // events forwarded from plugin.cpp - void onEditPlaybackVoiceDataEvent(uint64 serverConnectionHandlerID, anyID clientID, short* samples, int sampleCount, int channels); - - QHash GetSettingsMap() const; - QHash& GetSettingsMapRef(); - - Tokovoip getTokovoip() { return tokovoip; }; - -signals: - void ChannelStripEnabledSet(QString, bool); - void FudgeChanged(QString, double); - void InLoFreqSet(QString, double); - void InHiFreqSet(QString, double); - void RingModFrequencyChanged(QString, double); - void RingModMixChanged(QString,double); - void OutLoFreqSet(QString, double); - void OutHiFreqSet(QString, double); - // connected to dsp_radio - void InBpCenterFreqSet(QString, double); - void InBpBandwidthSet(QString,double); - void OutBpCenterFreqSet(QString, double); - void OutBpBandwidthSet(QString, double); - -public slots: - void setChannelStripEnabled(QString name, bool val); - void setFudge(QString name, double val); - void setInLoFreq(QString name, double val); - void setInHiFreq(QString name, double val); - void setRingModFrequency(QString name, double val); - void setRingModMix(QString name, double val); - void setOutLoFreq(QString name, double val); - void setOutHiFreq(QString name, double val); - - void ToggleClientBlacklisted(uint64 serverConnectionHandlerID, anyID clientID); - - //void saveSettings(int r); - -private: - Tokovoip tokovoip; - uint64 m_homeId = 0; - - TSServersInfo& m_servers_info; - Talkers& m_talkers; - - QHash* > m_talkers_dspradios; - - QHash m_SettingsMap; - - // QMultiMap is reported to be faster than QMultiHash until up to 10 entries in 4.x, oh I dunno - QMultiMap m_ClientBlacklist; - - //we have low, hi freq as input, convert them here - static double getCenterFrequencyIn(RadioFX_Settings setting) {return setting.freq_low + (getBandWidthIn(setting) / 2.0);} - static double getBandWidthIn(RadioFX_Settings setting) {return setting.freq_hi - setting.freq_low;} - static double getCenterFrequencyOut(RadioFX_Settings setting) {return setting.o_freq_lo + (getBandWidthOut(setting) / 2.0);} - static double getBandWidthOut(RadioFX_Settings setting) {return setting.o_freq_hi - setting.o_freq_lo;} - -protected: - void onRunningStateChanged(bool value); -}; diff --git a/ts3_plugin/src/plugin.cpp b/ts3_plugin/src/plugin.cpp deleted file mode 100644 index b616db0..0000000 --- a/ts3_plugin/src/plugin.cpp +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Author: Thorsten Weinz (philosound@gmail.com) - */ - -#ifdef _WIN32 -#pragma warning (disable : 4100) /* Disable Unreferenced parameter warning */ -#endif - -#include - -#include -#include -#include -#include - -#include - -#include "teamspeak/public_errors.h" -#include "teamspeak/public_errors_rare.h" -#include "teamspeak/public_definitions.h" -#include "teamspeak/public_rare_definitions.h" -#include "ts3_functions.h" -#include "plugin.h" -#include "plugin_qt.h" - -#include "core/ts_logging_qt.h" -#include "core/ts_settings_qt.h" -#include "core/ts_helpers_qt.h" -#include "tokovoip.h" - -struct TS3Functions ts3Functions; - -std::unique_ptr plugin; - -#ifdef _WIN32 -#define _strcpy(dest, destSize, src) strcpy_s(dest, destSize, src) -#define snprintf sprintf_s -#else -#define _strcpy(dest, destSize, src) { strncpy(dest, src, destSize-1); dest[destSize-1] = '\0'; } -#endif - -#define PATH_BUFSIZE 512 -#define COMMAND_BUFSIZE 128 -#define SERVERINFO_BUFSIZE 256 -#define CHANNELINFO_BUFSIZE 512 -#define RETURNCODE_BUFSIZE 128 - -QMutex command_mutex; - -/*********************************** Required functions ************************************/ -/* - * If any of these required functions is not implemented, TS3 will refuse to load the plugin - */ - -/* Unique name identifying this plugin */ -const char* ts3plugin_name() { return plugin->kPluginName; } - -/* Plugin version */ -const char* ts3plugin_version() { return plugin->kPluginVersion; } - -/* Plugin API version. Must be the same as the clients API major version, else the plugin fails to load. */ -int ts3plugin_apiVersion() { return plugin->kPluginApiVersion; } - -/* Plugin author */ -const char* ts3plugin_author() { return plugin->kPluginAuthor; } - -/* Plugin description */ -const char* ts3plugin_description() { return plugin->kPluginDescription; } - -/* Set TeamSpeak 3 callback functions */ -void ts3plugin_setFunctionPointers(const struct TS3Functions funcs) { - ts3Functions = funcs; -} - -/* - * Custom code called right after loading the plugin. Returns 0 on success, 1 on failure. - * If the function returns 1 on failure, the plugin will be unloaded again. - */ -int ts3plugin_init() { return plugin->init(); /* 0 = success, 1 = failure */ } - -/* Custom code called right before the plugin is unloaded */ -void ts3plugin_shutdown() -{ - plugin->shutdown(); - plugin.release(); -} - -/****************************** Optional functions ********************************/ -/* - * Following functions are optional, if not needed you don't need to implement them. - */ - -/* Tell client if plugin offers a configuration window. If this function is not implemented, it's an assumed "does not offer" (PLUGIN_OFFERS_NO_CONFIGURE). */ -int ts3plugin_offersConfigure() { return plugin->kPluginOffersConfigure; } - -/* - * If the plugin wants to use error return codes or plugin commands, it needs to register a command ID. This function will be automatically - * called after the plugin was initialized. This function is optional. If you don't use error return codes or plugin commands, the function - * can be omitted. - * Note the passed pluginID parameter is no longer valid after calling this function, so you must copy it and store it in the plugin. - */ -void ts3plugin_registerPluginID(const char* id) { - plugin = std::make_unique(id); -} - -/* Plugin command keyword. Return NULL or "" if not used. */ -const char* ts3plugin_commandKeyword() { - return "tokovoip"; -} - -/* Plugin processes console command. Return 0 if plugin handled the command, 1 if not handled. */ -int ts3plugin_processCommand(uint64 serverConnectionHandlerID, const char* command) { return 0; } - -/* - * Initialize plugin menus. - * This function is called after ts3plugin_init and ts3plugin_registerPluginID. A pluginID is required for plugin menus to work. - * Both ts3plugin_registerPluginID and ts3plugin_freeMemory must be implemented to use menus. - * If plugin menus are not used by a plugin, do not implement this function or return NULL. - */ -void ts3plugin_initMenus(struct PluginMenuItem*** menuItems, char** menuIcon) -{ - plugin->context_menu().onInitMenus(menuItems, menuIcon); - /* - * Create the menus - * There are three types of menu items: - * - PLUGIN_MENU_TYPE_CLIENT: Client context menu - * - PLUGIN_MENU_TYPE_CHANNEL: Channel context menu - * - PLUGIN_MENU_TYPE_GLOBAL: "Plugins" menu in menu bar of main window - * - * Menu IDs are used to identify the menu item when ts3plugin_onMenuItemEvent is called - * - * The menu text is required, max length is 128 characters - * - * The icon is optional, max length is 128 characters. When not using icons, just pass an empty string. - * Icons are loaded from a subdirectory in the TeamSpeak client plugins folder. The subdirectory must be named like the - * plugin filename, without dll/so/dylib suffix - * e.g. for "test_plugin.dll", icon "1.png" is loaded from \plugins\test_plugin\1.png - */ - - /* - * Menus can be enabled or disabled with: ts3Functions.setPluginMenuEnabled(pluginID, menuID, 0|1); - * Test it with plugin command: /test enablemenu <0|1> - * Menus are enabled by default. Please note that shown menus will not automatically enable or disable when calling this function to - * ensure Qt menus are not modified by any thread other the UI thread. The enabled or disable state will change the next time a - * menu is displayed. - */ - /* For example, this would disable MENU_ID_GLOBAL_2: */ - /* ts3Functions.setPluginMenuEnabled(pluginID, MENU_ID_GLOBAL_2, 0); */ - - /* All memory allocated in this function will be automatically released by the TeamSpeak client later by calling ts3plugin_freeMemory */ -} - -/* -* Implement the following three functions when the plugin should display a line in the server,channel,client info. -* If any of ts3plugin_infoTitle, ts3plugin_infoData or ts3plugin_freeMemory is missing, the info text will not be displayed. -*/ - -/* Static title shown in the left column in the info frame */ -const char* ts3plugin_infoTitle() { return ts3plugin_name(); } - -/* - * Dynamic content shown in the right column in the info frame. Memory for the data string needs to be allocated in this - * function. The client will call ts3plugin_freeMemory once done with the string to release the allocated memory again. - * Check the parameter "type" if you want to implement this feature only for specific item types. Set the parameter - * "data" to NULL to have the client ignore the info data. - */ -void ts3plugin_infoData(uint64 serverConnectionHandlerID, uint64 id, enum PluginItemType type, char** data) -{ - plugin->info_data().onInfoData(serverConnectionHandlerID, id, type, data); - //don't add code here when using infoData. It's all been done. -} - -/* Required to release the memory for parameter "data" allocated in ts3plugin_infoData */ -void ts3plugin_freeMemory(void* data) { - free(data); -} - -/* Show an error message if the plugin failed to load */ -void ts3plugin_onConnectStatusChangeEvent(uint64 serverConnectionHandlerID, int newStatus, unsigned int errorNumber) -{ - plugin->onConnectStatusChangeEvent(serverConnectionHandlerID, newStatus, errorNumber); -} - -void ts3plugin_onClientMoveEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, const char* moveMessage) -{ - plugin->onClientMoveEvent(serverConnectionHandlerID, clientID, oldChannelID, newChannelID, visibility, moveMessage); -} - -void ts3plugin_onClientMoveTimeoutEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, const char* timeoutMessage) -{ - plugin->onClientMoveTimeoutEvent(serverConnectionHandlerID, clientID, oldChannelID, newChannelID, visibility, timeoutMessage); -} - -void ts3plugin_onClientMoveMovedEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, anyID moverID, const char* moverName, const char* moverUniqueIdentifier, const char* moveMessage) -{ - plugin->onClientMoveMovedEvent(serverConnectionHandlerID, clientID, oldChannelID, newChannelID, visibility, moverID, moverName, moverUniqueIdentifier, moveMessage); -} - -int ts3plugin_onServerErrorEvent(uint64 serverConnectionHandlerID, const char* errorMessage, unsigned int error, const char* returnCode, const char* extraMessage) -{ - //TSLogging::Print(QString("onServerErrorEvent: %1 %2 %3").arg((returnCode ? returnCode : "")).arg(error).arg(errorMessage),serverConnectionHandlerID,LogLevel_DEBUG); - int isHandledError = 0; - if (returnCode) - { - //TSLogging::Print("have returnCode"); -// /* A plugin could now check the returnCode with previously (when calling a function) remembered returnCodes and react accordingly */ -// /* In case of using a a plugin return code, the plugin can return: -// * 0: Client will continue handling this error (print to chat tab) -// * 1: Client will ignore this error, the plugin announces it has handled it */ - - return 0; - } - - return isHandledError; /* If no plugin return code was used, the return value of this function is ignored */ -} - -void ts3plugin_onTalkStatusChangeEvent(uint64 serverConnectionHandlerID, int status, int isReceivedWhisper, anyID clientID) -{ - plugin->onTalkStatusChangeEvent(serverConnectionHandlerID, status, isReceivedWhisper, clientID); -} - -void ts3plugin_onEditPlaybackVoiceDataEvent(uint64 serverConnectionHandlerID, anyID clientID, short* samples, int sampleCount, int channels) -{ - plugin->onEditPlaybackVoiceDataEvent(serverConnectionHandlerID, clientID, samples, sampleCount, channels); -} - -/* Clientlib rare */ -void ts3plugin_onClientSelfVariableUpdateEvent(uint64 serverConnectionHandlerID, int flag, const char* oldValue, const char* newValue) -{ - // seems to be equal to a ts3plugin_currentServerConnectionChanged when initiated by the user - // except that this version will fire when returning from a cross server ptt event - // (ts3plugin_currentServerConnectionChanged is not even fired when ptt-switching for whatever reason) - // Furtunately, we can make use of that difference. -} - -/* Client changed current server connection handler */ -void ts3plugin_currentServerConnectionChanged(uint64 serverConnectionHandlerID) -{ - plugin->currentServerConnectionChanged(serverConnectionHandlerID); -} - -/* Client UI callbacks */ - -/* - * Called when a plugin menu item (see ts3plugin_initMenus) is triggered. Optional function, when not using plugin menus, do not implement this. - * - * Parameters: - * - serverConnectionHandlerID: ID of the current server tab - * - type: Type of the menu (PLUGIN_MENU_TYPE_CHANNEL, PLUGIN_MENU_TYPE_CLIENT or PLUGIN_MENU_TYPE_GLOBAL) - * - menuItemID: Id used when creating the menu item - * - selectedItemID: Channel or Client ID in the case of PLUGIN_MENU_TYPE_CHANNEL and PLUGIN_MENU_TYPE_CLIENT. 0 for PLUGIN_MENU_TYPE_GLOBAL. - */ -void ts3plugin_onMenuItemEvent(uint64 serverConnectionHandlerID, enum PluginMenuType type, int menuItemID, uint64 selectedItemID) -{ - plugin->onMenuItemEvent(serverConnectionHandlerID, type, menuItemID, selectedItemID); -} - -/*void ts3plugin_onPluginCommandEvent(uint64 serverConnectionHandlerID, const char* pluginName, const char* pluginCommand) -{ - // pluginName is the dll name minus _someOS, not ts3plugin_name(); - // if the user for whatever reason renames the dll, this breaks the code - if (QString(pluginName) != QString(ts3plugin_name()).toLower()) - return; -}*/ - -void ts3plugin_onServerGroupListEvent(uint64 serverConnectionHandlerID, uint64 serverGroupID, const char* name, int type, int iconID, int saveDB) -{ - plugin->on_server_group_list(serverConnectionHandlerID, serverGroupID, name, type, iconID, saveDB); -} - -void ts3plugin_onServerGroupListFinishedEvent(uint64 serverConnectionHandlerID) -{ - plugin->on_server_group_list_finished(serverConnectionHandlerID); -} - -void ts3plugin_onChannelGroupListEvent(uint64 serverConnectionHandlerID, uint64 channelGroupID, const char* name, int type, int iconID, int saveDB) -{ - plugin->on_channel_group_list(serverConnectionHandlerID, channelGroupID, name, type, iconID, saveDB); -} - -void ts3plugin_onChannelGroupListFinishedEvent(uint64 serverConnectionHandlerID) -{ - plugin->on_channel_group_list_finished(serverConnectionHandlerID); -} diff --git a/ts3_plugin/src/plugin.h b/ts3_plugin/src/plugin.h deleted file mode 100644 index 9c2a843..0000000 --- a/ts3_plugin/src/plugin.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * TeamSpeak RadioFX plugin - * - * Author: Thorsten Weinz (philosound@gmail.com) - */ - -#pragma once - -#ifdef WIN32 -#define PLUGINS_EXPORTDLL __declspec(dllexport) -#else -#define PLUGINS_EXPORTDLL __attribute__ ((visibility("default"))) -#endif - -#include "teamspeak/public_definitions.h" -#include "plugin_definitions.h" - -extern struct TS3Functions ts3Functions; - -#ifdef __cplusplus -extern "C" { -#endif - -/* Required functions */ -PLUGINS_EXPORTDLL const char* ts3plugin_name(); -PLUGINS_EXPORTDLL const char* ts3plugin_version(); -PLUGINS_EXPORTDLL int ts3plugin_apiVersion(); -PLUGINS_EXPORTDLL const char* ts3plugin_author(); -PLUGINS_EXPORTDLL const char* ts3plugin_description(); -PLUGINS_EXPORTDLL void ts3plugin_setFunctionPointers(const struct TS3Functions funcs); -PLUGINS_EXPORTDLL int ts3plugin_init(); -PLUGINS_EXPORTDLL void ts3plugin_shutdown(); - -/* Optional functions */ -PLUGINS_EXPORTDLL int ts3plugin_offersConfigure(); -PLUGINS_EXPORTDLL void ts3plugin_registerPluginID(const char* id); -PLUGINS_EXPORTDLL const char* ts3plugin_commandKeyword(); -PLUGINS_EXPORTDLL int ts3plugin_processCommand(uint64 serverConnectionHandlerID, const char* command); -PLUGINS_EXPORTDLL void ts3plugin_currentServerConnectionChanged(uint64 serverConnectionHandlerID); -PLUGINS_EXPORTDLL const char* ts3plugin_infoTitle(); -PLUGINS_EXPORTDLL void ts3plugin_infoData(uint64 serverConnectionHandlerID, uint64 id, enum PluginItemType type, char** data); -PLUGINS_EXPORTDLL void ts3plugin_freeMemory(void* data); -PLUGINS_EXPORTDLL void ts3plugin_initMenus(struct PluginMenuItem*** menuItems, char** menuIcon); - -/* Clientlib */ -PLUGINS_EXPORTDLL void ts3plugin_onConnectStatusChangeEvent(uint64 serverConnectionHandlerID, int newStatus, unsigned int errorNumber); -PLUGINS_EXPORTDLL void ts3plugin_onClientMoveEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, const char* moveMessage); -PLUGINS_EXPORTDLL void ts3plugin_onClientMoveTimeoutEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, const char* timeoutMessage); -PLUGINS_EXPORTDLL void ts3plugin_onClientMoveMovedEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, anyID moverID, const char* moverName, const char* moverUniqueIdentifier, const char* moveMessage); -PLUGINS_EXPORTDLL int ts3plugin_onServerErrorEvent(uint64 serverConnectionHandlerID, const char* errorMessage, unsigned int error, const char* returnCode, const char* extraMessage); -PLUGINS_EXPORTDLL void ts3plugin_onTalkStatusChangeEvent(uint64 serverConnectionHandlerID, int status, int isReceivedWhisper, anyID clientID); -PLUGINS_EXPORTDLL void ts3plugin_onEditPlaybackVoiceDataEvent(uint64 serverConnectionHandlerID, anyID clientID, short* samples, int sampleCount, int channels); - -/* Clientlib rare */ -PLUGINS_EXPORTDLL void ts3plugin_onClientSelfVariableUpdateEvent(uint64 serverConnectionHandlerID, int flag, const char* oldValue, const char* newValue); -PLUGINS_EXPORTDLL void ts3plugin_onServerGroupListEvent(uint64 serverConnectionHandlerID, uint64 serverGroupID, const char* name, int type, int iconID, int saveDB); -PLUGINS_EXPORTDLL void ts3plugin_onServerGroupListFinishedEvent(uint64 serverConnectionHandlerID); -PLUGINS_EXPORTDLL void ts3plugin_onChannelGroupListEvent(uint64 serverConnectionHandlerID, uint64 channelGroupID, const char* name, int type, int iconID, int saveDB); -PLUGINS_EXPORTDLL void ts3plugin_onChannelGroupListFinishedEvent(uint64 serverConnectionHandlerID); - -/* Client UI callbacks */ -PLUGINS_EXPORTDLL void ts3plugin_onMenuItemEvent(uint64 serverConnectionHandlerID, enum PluginMenuType type, int menuItemID, uint64 selectedItemID); - -#ifdef __cplusplus -} -#endif diff --git a/ts3_plugin/src/plugin_qt.cpp b/ts3_plugin/src/plugin_qt.cpp deleted file mode 100644 index 15c6300..0000000 --- a/ts3_plugin/src/plugin_qt.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include "plugin_qt.h" - -#include "teamspeak/clientlib_publicdefinitions.h" - -#include "core/ts_serversinfo.h" - -#include "mod_radio.h" -#include "settings_radio.h" - -const char* Plugin::kPluginName = "TokoVoip"; -const char* Plugin::kPluginVersion = "1.2.4"; -const char* Plugin::kPluginAuthor = "Itokoyamato, Thorsten Weinz"; -const char* Plugin::kPluginDescription = "Features:\n- TokoVoip\n- Radio FX\n"; - -Plugin::Plugin(const char* plugin_id, QObject *parent) - : Plugin_Base(plugin_id, parent) - , m_servers_info(new TSServersInfo(this)) - , m_radio(new Radio(*m_servers_info, talkers(), plugin_id, this)) - , m_settings_radio(new SettingsRadio(*m_servers_info, this)) -{} - -/* required functions */ - -int Plugin::initialize() -{ - context_menu().setMainIcon("ct_16x16.png"); - translator().update(); - m_settings_radio->Init(m_radio); - return 0; -} - -void Plugin::shutdown() -{ - m_radio->getTokovoip().shutdown(); - m_settings_radio->shutdown(); -} - -/* optional functions */ - -void Plugin::on_current_server_connection_changed(uint64 sch_id) -{ - m_radio->setHomeId(sch_id); -} - -void Plugin::on_connect_status_changed(uint64 sch_id, int new_status, unsigned int error_number) -{ - m_servers_info->onConnectStatusChangeEvent(sch_id, new_status, error_number); -} - -void Plugin::on_client_move(uint64 sch_id, anyID client_id, uint64 old_channel_id, uint64 new_channel_id, int visibility, anyID my_id, const char * move_message) -{ - Q_UNUSED(move_message); - // TODO -} - -void Plugin::on_client_move_timeout(uint64 sch_id, anyID client_id, uint64 old_channel_id, anyID my_id, const char * timeout_message) -{ - Q_UNUSED(timeout_message); - // TODO -} - -void Plugin::on_client_move_moved(uint64 sch_id, anyID client_id, uint64 old_channel_id, uint64 new_channel_id, int visibility, anyID my_id, anyID mover_id, const char * mover_name, const char * mover_unique_id, const char * move_message) -{ - Q_UNUSED(mover_id); - Q_UNUSED(mover_name); - Q_UNUSED(mover_unique_id); - Q_UNUSED(move_message); - // TODO -} - -void Plugin::on_talk_status_changed(uint64 sch_id, int status, int is_received_whisper, anyID client_id, bool is_me) -{ - /*const auto kIsRadioProcessing =*/ m_radio->onTalkStatusChanged(sch_id, status, is_received_whisper, client_id, is_me); -} - -void Plugin::on_playback_pre_process(uint64 sch_id, anyID client_id, short* samples, int frame_count, int channels) -{ - m_radio->onEditPlaybackVoiceDataEvent(sch_id, client_id, samples, frame_count, channels); - //agmu.onEditPlaybackVoiceDataEvent(sch_id, client_id, samples, frame_count, channels); -} - -void Plugin::on_server_group_list(uint64 sch_id, uint64 server_group_id, const char * name, int type, int icon_id, int save_db) -{ - m_servers_info->onServerGroupListEvent(sch_id, server_group_id, name, type, icon_id, save_db); -} - -void Plugin::on_server_group_list_finished(uint64 sch_id) -{ - m_servers_info->onServerGroupListFinishedEvent(sch_id); -} - -void Plugin::on_channel_group_list(uint64 sch_id, uint64 channel_group_id, const char * name, int type, int icon_id, int save_db) -{ - m_servers_info->onChannelGroupListEvent(sch_id, channel_group_id, name, type, icon_id, save_db); -} - -void Plugin::on_channel_group_list_finished(uint64 sch_id) -{ - m_servers_info->onChannelGroupListFinishedEvent(sch_id); -} diff --git a/ts3_plugin/src/plugin_qt.h b/ts3_plugin/src/plugin_qt.h deleted file mode 100644 index 552718d..0000000 --- a/ts3_plugin/src/plugin_qt.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#include "core/plugin_base.h" - -class TSServersInfo; -class Radio; -class SettingsRadio; - -class Plugin : public Plugin_Base -{ - Q_OBJECT - -public: - Plugin(const char* plugin_id, QObject *parent = nullptr); - - static const char* kPluginName; - static const char* kPluginVersion; - static const int kPluginApiVersion = 23; - static const char* kPluginAuthor; - static const char* kPluginDescription; - - int initialize() override; - void shutdown() override; - - /* optional */ - static const int kPluginOffersConfigure = PLUGIN_OFFERS_NO_CONFIGURE; - - void on_current_server_connection_changed(uint64 sch_id) override; - - /* ClientLib */ - void on_connect_status_changed(uint64 sch_id, int new_status, unsigned int error_number) override; - void on_client_move(uint64 sch_id, anyID client_id, uint64 old_channel_id, uint64 new_channel_id, int visibility, anyID my_id, const char* move_message) override; - void on_client_move_timeout(uint64 sch_id, anyID client_id, uint64 old_channel_id, anyID my_id, const char* timeout_message) override; - void on_client_move_moved(uint64 sch_id, anyID client_id, uint64 old_channel_id, uint64 new_channel_id, int visibility, anyID my_id, anyID mover_id, const char* mover_name, const char* mover_unique_id, const char* move_message) override; - - void on_talk_status_changed(uint64 sch_id, int status, int is_received_whisper, anyID client_id, bool is_me) override; - void on_playback_pre_process(uint64 sch_id, anyID client_id, short* samples, int frame_count, int channels) override; - - void on_server_group_list(uint64 sch_id, uint64 server_group_id, const char* name, int type, int icon_id, int save_db) override; - void on_server_group_list_finished(uint64 sch_id) override; - void on_channel_group_list(uint64 sch_id, uint64 channel_group_id, const char* name, int type, int icon_id, int save_db) override; - void on_channel_group_list_finished(uint64 sch_id) override; - -private: - TSServersInfo* m_servers_info = nullptr; - Radio* m_radio = nullptr; - SettingsRadio* m_settings_radio = nullptr; -}; diff --git a/ts3_plugin/src/settings_radio.cpp b/ts3_plugin/src/settings_radio.cpp deleted file mode 100644 index ccecfc0..0000000 --- a/ts3_plugin/src/settings_radio.cpp +++ /dev/null @@ -1,352 +0,0 @@ -#include "settings_radio.h" - -#include -#include "core/ts_helpers_qt.h" -#include "core/ts_logging_qt.h" - -#include "plugin.h" //pluginID -#include "ts3_functions.h" -#include "core/ts_serversinfo.h" -#include - -#include "core/plugin_base.h" -#include "tokovoip.h" - -SettingsRadio::SettingsRadio(TSServersInfo& servers_info, QObject* parent) - : QObject(parent) - , m_servers_info(servers_info) -{ - setObjectName("SettingsRadio"); -} - -void SettingsRadio::Init(Radio *radio) -{ - if (m_ContextMenuUi == -1) - { - auto plugin = qobject_cast(parent()); - auto& context_menu = plugin->context_menu(); - m_ContextMenuUi = context_menu.Register(this, PLUGIN_MENU_TYPE_GLOBAL, "Radio FX", "walkie_talkie_16.png"); - m_ContextMenuUnmute = context_menu.Register(this, PLUGIN_MENU_TYPE_GLOBAL, "Unmute All", ""); - // m_ContextMenuChannelUi = context_menu.Register(this,PLUGIN_MENU_TYPE_CHANNEL,"Radio FX (Channel)","walkie_talkie_16.png"); - m_ContextMenuToggleClientBlacklisted = context_menu.Register(this,PLUGIN_MENU_TYPE_CLIENT, "Radio FX: Toggle Client Blacklisted [temp]", "walkie_talkie_16.png"); - connect(&context_menu, &TSContextMenu::MenusInitialized, this, [=]() - { - if (m_ContextMenuUi == -1) - TSLogging::Error(QString("%1: Menu wasn't registered.").arg(this->objectName())); - - if (m_ContextMenuUnmute == -1) - TSLogging::Error(QString("%1: Menu unmute wasn't registered.").arg(this->objectName())); - - // if (m_ContextMenuChannelUi == -1) - // TSLogging::Error(QString("%1: Channel Menu wasn't registered.").arg(this->objectName())); - - if (m_ContextMenuToggleClientBlacklisted == -1) - TSLogging::Error(QString("%1: Toggle Client Blacklisted menu item wasn't registered.").arg(this->objectName())); - }); - connect(&context_menu, &TSContextMenu::FireContextMenuEvent, this, &SettingsRadio::onContextMenuEvent); - - auto& info_data = plugin->info_data(); - info_data.Register(this, true, 1); - } - - connect(this, &SettingsRadio::EnabledSet, radio, &Radio::setChannelStripEnabled); - connect(this, &SettingsRadio::InLoFreqSet, radio, &Radio::setInLoFreq); - connect(this, &SettingsRadio::InHiFreqSet, radio, &Radio::setInHiFreq); - connect(this, &SettingsRadio::DestructionSet, radio, &Radio::setFudge); - connect(this, &SettingsRadio::RingModFrequencySet, radio, &Radio::setRingModFrequency); - connect(this, &SettingsRadio::RingModMixSet, radio, &Radio::setRingModMix); - connect(this, &SettingsRadio::OutLoFreqSet, radio, &Radio::setOutLoFreq); - connect(this, &SettingsRadio::OutHiFreqSet, radio, &Radio::setOutHiFreq); - - connect(this, &SettingsRadio::ToggleClientBlacklisted, radio, &Radio::ToggleClientBlacklisted); - - QSettings cfg(TSHelpers::GetFullConfigPath(), QSettings::IniFormat); - cfg.beginGroup(radio->objectName()); - - const auto kStringList = cfg.childGroups().isEmpty() ? QStringList{"Home", "Whisper", "Other"} : cfg.childGroups(); - for (int i = 0; i < kStringList.size(); ++i) - { - auto name = kStringList.at(i); - cfg.beginGroup(name); - if (name == "HomeTab") - name = "Home"; - - radio->setChannelStripEnabled(name, cfg.value("enabled", true).toBool()); - radio->setInLoFreq(name, cfg.value("low_freq", 300.0f).toDouble()); - radio->setInHiFreq(name, cfg.value("high_freq", 3000.0f).toDouble()); - radio->setFudge(name, cfg.value("fudge", 2.0f).toDouble()); - cfg.beginGroup("RingMod"); - radio->setRingModFrequency(name, cfg.value("rm_mod_freq", 0.0f).toDouble()); - radio->setRingModMix(name, cfg.value("rm_mix", 0.0f).toDouble()); - cfg.endGroup(); - radio->setOutLoFreq(name, cfg.value("o_freq_lo", 300.0f).toDouble()); - radio->setOutHiFreq(name, cfg.value("o_freq_hi", 3000.0f).toDouble()); - cfg.endGroup(); - } - - radio->setEnabled(true); - mP_radio = radio; -} - -void SettingsRadio::shutdown() -{ - if (m_config) - { - m_config->done(QDialog::Rejected); // will save anyways - delete m_config; - } - for (auto config : m_channel_configs) - { - config->done(QDialog::Rejected); - delete config; - } - m_channel_configs.clear(); -} - -bool SettingsRadio::onInfoDataChanged(uint64 serverConnectionHandlerID, uint64 id, PluginItemType type, uint64 mine, QTextStream &data) -{ - auto isDirty = false; - if (type == PLUGIN_CLIENT) - { - if (m_ContextMenuToggleClientBlacklisted != -1) - { - auto plugin = qobject_cast(parent()); - ts3Functions.setPluginMenuEnabled(plugin->id().c_str(), m_ContextMenuToggleClientBlacklisted, (id != mine) ? 1 : 0); - } - - if ((id != mine) && mP_radio && mP_radio->isClientBlacklisted(serverConnectionHandlerID,(anyID)id)) - { - data << mP_radio->objectName() << ":"; - isDirty = true; - data << "blacklisted [temp]"; - } - } - return isDirty; -} - -void SettingsRadio::onContextMenuEvent(uint64 serverConnectionHandlerID, PluginMenuType type, int menuItemID, uint64 selectedItemID) -{ - if (type == PLUGIN_MENU_TYPE_GLOBAL) - { - if (menuItemID == m_ContextMenuUi) - { - if (m_config) - m_config->activateWindow(); - else if (mP_radio) - { - auto p_config = new ConfigRadio(TSHelpers::GetMainWindow()); //has delete on close attribute - - QSettings cfg(TSHelpers::GetFullConfigPath(), QSettings::IniFormat); - cfg.beginGroup(mP_radio->objectName()); - - QStringList stringList {"HomeTab", "Whisper", "Other"}; - for (int i = 0; i < stringList.size(); ++i) - { - auto name = stringList.at(i); - cfg.beginGroup(name); - if (name == "HomeTab") - name = "Home"; - - p_config->UpdateEnabled(name, cfg.value("enabled", true).toBool()); - p_config->UpdateBandpassInLowFrequency(name, cfg.value("low_freq", 300.0).toDouble()); - p_config->UpdateBandpassInHighFrequency(name, cfg.value("high_freq", 3000.0).toDouble()); - p_config->UpdateDestruction(name, cfg.value("fudge", 2.0).toDouble()); - cfg.beginGroup("RingMod"); - p_config->UpdateRingModFrequency(name, cfg.value("rm_mod_freq", 0.0f).toDouble()); - p_config->UpdateRingModMix(name, cfg.value("rm_mix", 0.0f).toDouble()); - cfg.endGroup(); - p_config->UpdateBandpassOutLowFrequency(name, cfg.value("o_freq_lo", 300.0).toDouble()); - p_config->UpdateBandpassOutHighFrequency(name, cfg.value("o_freq_hi", 3000.0).toDouble()); - cfg.endGroup(); - } - - connect(p_config, &ConfigRadio::EnabledSet, this, &SettingsRadio::EnabledSet); - connect(p_config, &ConfigRadio::InLoFreqSet, this, &SettingsRadio::InLoFreqSet); - connect(p_config, &ConfigRadio::InHiFreqSet, this, &SettingsRadio::InHiFreqSet); - connect(p_config, &ConfigRadio::DestructionSet, this, &SettingsRadio::DestructionSet); - connect(p_config, &ConfigRadio::RingModFrequencySet, this, &SettingsRadio::RingModFrequencySet); - connect(p_config, &ConfigRadio::RingModMixSet, this, &SettingsRadio::RingModMixSet); - connect(p_config, &ConfigRadio::OutLoFreqSet, this, &SettingsRadio::OutLoFreqSet); - connect(p_config, &ConfigRadio::OutHiFreqSet, this, &SettingsRadio::OutHiFreqSet); - - connect(p_config, &ConfigRadio::finished, this, &SettingsRadio::saveSettings); - p_config->show(); - m_config = p_config; - } - } - if (menuItemID == m_ContextMenuUnmute) - { - unmuteAll(ts3Functions.getCurrentServerConnectionHandlerID()); - resetVolumeAll(ts3Functions.getCurrentServerConnectionHandlerID()); - } - } - else if (type == PLUGIN_MENU_TYPE_CHANNEL) - { - if (menuItemID == m_ContextMenuChannelUi) - { - auto server_channel = qMakePair (serverConnectionHandlerID, selectedItemID); - if (m_channel_configs.contains(server_channel) && m_channel_configs.value(server_channel)) - { - m_channel_configs.value(server_channel)->activateWindow(); - return; - } - - if (!mP_radio) - return; - - unsigned int error; - - char* channel_name_c; - if ((error = ts3Functions.getChannelVariableAsString(serverConnectionHandlerID, selectedItemID, CHANNEL_NAME, &channel_name_c)) != ERROR_ok) - { - TSLogging::Error(QString("%1: Could not get channel name").arg(this->objectName())); - return; - } - const auto kChannelName = QString::fromUtf8(channel_name_c); - ts3Functions.freeMemory(channel_name_c); - - auto p_config = new ConfigRadio(TSHelpers::GetMainWindow(), m_servers_info.get_server_info(serverConnectionHandlerID, true)->getName(), kChannelName); //has delete on close attribute - QSettings cfg(TSHelpers::GetFullConfigPath(), QSettings::IniFormat); - cfg.beginGroup(mP_radio->objectName()); - - const auto kCustomChannelId = m_servers_info.get_server_info(serverConnectionHandlerID, true)->getUniqueId() + TSHelpers::GetChannelPath(serverConnectionHandlerID, selectedItemID); - cfg.beginGroup(kCustomChannelId); - - // also push temp default setting to radio - mP_radio->setChannelStripEnabled(kCustomChannelId, cfg.value("enabled",false).toBool()); - mP_radio->setInLoFreq(kCustomChannelId, cfg.value("low_freq",300.0).toDouble()); - mP_radio->setInHiFreq(kCustomChannelId, cfg.value("high_freq",3000.0).toDouble()); - mP_radio->setFudge(kCustomChannelId, cfg.value("fudge",2.0).toDouble()); - p_config->UpdateEnabled(kCustomChannelId, cfg.value("enabled",false).toBool()); - p_config->UpdateBandpassInLowFrequency(kCustomChannelId, cfg.value("low_freq",300.0).toDouble()); - p_config->UpdateBandpassInHighFrequency(kCustomChannelId, cfg.value("high_freq",3000.0).toDouble()); - p_config->UpdateDestruction(kCustomChannelId, cfg.value("fudge",2.0).toDouble()); - cfg.beginGroup("RingMod"); - mP_radio->setRingModFrequency(kCustomChannelId, cfg.value("rm_mod_freq",0.0f).toDouble()); - mP_radio->setRingModMix(kCustomChannelId, cfg.value("rm_mix",0.0f).toDouble()); - p_config->UpdateRingModFrequency(kCustomChannelId, cfg.value("rm_mod_freq",0.0f).toDouble()); - p_config->UpdateRingModMix(kCustomChannelId, cfg.value("rm_mix",0.0f).toDouble()); - cfg.endGroup(); - mP_radio->setOutLoFreq(kCustomChannelId, cfg.value("o_freq_lo",300.0).toDouble()); - mP_radio->setOutHiFreq(kCustomChannelId, cfg.value("o_freq_hi",3000.0).toDouble()); - p_config->UpdateBandpassOutLowFrequency(kCustomChannelId, cfg.value("o_freq_lo",300.0).toDouble()); - p_config->UpdateBandpassOutHighFrequency(kCustomChannelId, cfg.value("o_freq_hi",3000.0).toDouble()); - - cfg.endGroup(); // Channel - cfg.endGroup(); // radio module - - connect(p_config, &ConfigRadio::EnabledSet, this, &SettingsRadio::EnabledSet); - connect(p_config, &ConfigRadio::InLoFreqSet, this, &SettingsRadio::InLoFreqSet); - connect(p_config, &ConfigRadio::InHiFreqSet, this, &SettingsRadio::InHiFreqSet); - connect(p_config, &ConfigRadio::DestructionSet, this, &SettingsRadio::DestructionSet); - connect(p_config, &ConfigRadio::RingModFrequencySet, this, &SettingsRadio::RingModFrequencySet); - connect(p_config, &ConfigRadio::RingModMixSet, this, &SettingsRadio::RingModMixSet); - connect(p_config, &ConfigRadio::OutLoFreqSet, this, &SettingsRadio::OutLoFreqSet); - connect(p_config, &ConfigRadio::OutHiFreqSet, this, &SettingsRadio::OutHiFreqSet); - - connect(p_config, &ConfigRadio::channel_closed, this, &SettingsRadio::on_channel_settings_finished); - p_config->show(); - m_channel_configs.insert(server_channel,p_config); - } - } - else if (type == PLUGIN_MENU_TYPE_CLIENT) - { - if (menuItemID == m_ContextMenuToggleClientBlacklisted) - emit ToggleClientBlacklisted(serverConnectionHandlerID, (anyID)selectedItemID); - } -} - -void SettingsRadio::saveSettings(int r) -{ - Q_UNUSED(r); - if (mP_radio) - { - QSettings cfg(TSHelpers::GetFullConfigPath(), QSettings::IniFormat); - cfg.beginGroup(mP_radio->objectName()); - { - auto settings_map = mP_radio->GetSettingsMap(); - for (auto i = settings_map.constBegin(); i != settings_map.constEnd(); ++i) - { - QString name = i.key(); - if (name == "Home") - name = "HomeTab"; - - cfg.beginGroup(name); - auto settings = i.value(); - cfg.setValue("enabled",settings.enabled); - cfg.setValue("low_freq",settings.freq_low); - cfg.setValue("high_freq",settings.freq_hi); - cfg.setValue("o_freq_lo",settings.o_freq_lo); - cfg.setValue("o_freq_hi",settings.o_freq_hi); - cfg.setValue("fudge",settings.fudge); - cfg.beginGroup("RingMod"); - cfg.setValue("rm_mod_freq",settings.rm_mod_freq); - cfg.setValue("rm_mix",settings.rm_mix); - cfg.endGroup(); - cfg.endGroup(); - } - } - cfg.endGroup(); - } -} - -void SettingsRadio::on_channel_settings_finished(int r, QString setting_id) -{ - // clean up and close widget - const auto kSchId = m_servers_info.find_server_by_unique_id(setting_id.left(28)); // 28 length always? or always ends with = ? - if (kSchId) - { - auto channel_id = TSHelpers::GetChannelIDFromPath(kSchId, setting_id.right(setting_id.length() - 28)); - if (channel_id) - { - //TSLogging::Log(QString("serverid: %1 channelid: %2").arg(serverConnectionHandlerID).arg(channel_id)); - - auto server_channel = qMakePair(kSchId, channel_id); - if (!m_channel_configs.contains(server_channel)) - { - TSLogging::Error("Could not remove setting dialog from map"); - } - else - m_channel_configs.remove(server_channel); - } - } - - // Settings - auto do_save = true; - QSettings cfg(TSHelpers::GetFullConfigPath(), QSettings::IniFormat); - cfg.beginGroup(mP_radio->objectName()); - - if (r == QDialog::DialogCode::Accepted) // delete button - { - TSLogging::Log(QString("Removing setting %1").arg(setting_id)); - - // remove from setting - cfg.remove(setting_id); - - // This makes me wish for a redesign - auto& settings_map = mP_radio->GetSettingsMapRef(); - if (settings_map.contains(setting_id)) - settings_map.remove(setting_id); - - // TODO Update all current talkers - } - else // save / create - { - TSLogging::Log(QString("Save channel settings: %1").arg(setting_id)); - - if (!(cfg.childGroups().contains(setting_id))) - { // if not enabled remove setting (aka don't create setting) to not pollute for every dialog open - // This makes me wish for a redesign - auto& settings_map = mP_radio->GetSettingsMapRef(); - if ((settings_map.contains(setting_id)) && (!settings_map.value(setting_id).enabled)) - { - settings_map.remove(setting_id); - do_save = false; - } - } - } - - cfg.endGroup(); - if (do_save) - this->saveSettings(NULL); -} diff --git a/ts3_plugin/src/settings_radio.h b/ts3_plugin/src/settings_radio.h deleted file mode 100644 index 3656cf6..0000000 --- a/ts3_plugin/src/settings_radio.h +++ /dev/null @@ -1,57 +0,0 @@ -#pragma once - -#include -#include -#include - -#include "core/ts_context_menu_qt.h" -#include "config_radio.h" -#include "mod_radio.h" -#include "core/ts_infodata_qt.h" - -class Plugin_Base; - -class SettingsRadio : public QObject, public InfoDataInterface, public ContextMenuInterface -{ - Q_OBJECT - Q_INTERFACES(InfoDataInterface ContextMenuInterface) - -public: - SettingsRadio(TSServersInfo& servers_info, QObject* parent = nullptr); - - void Init(Radio *radio); - void shutdown(); - bool onInfoDataChanged(uint64 serverConnectionHandlerID, uint64 id, enum PluginItemType type, uint64 mine, QTextStream &data); - -signals: - void EnabledSet(QString,bool); - void InLoFreqSet(QString,double); - void InHiFreqSet(QString,double); - void DestructionSet(QString,double); - void RingModFrequencySet(QString,double); - void RingModMixSet(QString,double); - void OutLoFreqSet(QString,double); - void OutHiFreqSet(QString,double); - - void ToggleClientBlacklisted(uint64, anyID); - -public slots: - void onContextMenuEvent(uint64 serverConnectionHandlerID, PluginMenuType type, int menuItemID, uint64 selectedItemID); - -private slots: - void saveSettings(int); - void on_channel_settings_finished(int r, QString setting_id); - -private: - TSServersInfo& m_servers_info; - - int m_ContextMenuUi = -1; - int m_ContextMenuChannelUi = -1; - int m_ContextMenuToggleClientBlacklisted = -1; - int m_ContextMenuUnmute = -1; - QPointer m_config; - - QPointer mP_radio; - - QHash,QPointer > m_channel_configs; -}; diff --git a/ts3_plugin/src/tokovoip.cpp b/ts3_plugin/src/tokovoip.cpp index 10da9b9..189baa5 100644 --- a/ts3_plugin/src/tokovoip.cpp +++ b/ts3_plugin/src/tokovoip.cpp @@ -38,7 +38,6 @@ bool isTalking = false; char* originalName = ""; time_t lastPingTick = 0; int pluginStatus = 0; -bool processingMessage = false; time_t lastNameSetTick = 0; string mainChannel = ""; string waitChannel = ""; @@ -55,7 +54,7 @@ DWORD WINAPI ServiceThread(LPVOID lpParam) echo.on_message = [](shared_ptr connection, shared_ptr message) { - processingMessage = true; + tokovoip->setProcessingState(true); lastPingTick = time(nullptr); pluginStatus = 1; ServerConnection = connection; @@ -66,7 +65,7 @@ DWORD WINAPI ServiceThread(LPVOID lpParam) if (!isConnected(ts3Functions.getCurrentServerConnectionHandlerID())) { - processingMessage = false; + tokovoip->setProcessingState(false); return (0); } @@ -81,7 +80,7 @@ DWORD WINAPI ServiceThread(LPVOID lpParam) // Check if connected to any channel if (thisChannelName == "") { - processingMessage = false; + tokovoip->setProcessingState(false); return (0); } @@ -91,7 +90,7 @@ DWORD WINAPI ServiceThread(LPVOID lpParam) json json_data = json::parse(message_str.c_str(), nullptr, false); if (json_data.is_discarded()) { ts3Functions.logMessage("Invalid JSON data", LogLevel_INFO, "TokoVOIP", 0); - processingMessage = false; + tokovoip->setProcessingState(false); return (0); } @@ -114,7 +113,7 @@ DWORD WINAPI ServiceThread(LPVOID lpParam) if (isChannelWhitelisted(json_data, thisChannelName)) { resetClientsAll(); pluginStatus = 3; - processingMessage = false; + tokovoip->setProcessingState(false); return (0); } @@ -156,14 +155,14 @@ DWORD WINAPI ServiceThread(LPVOID lpParam) { setClientMuteStatus(serverId, *clientIdIterator, true); } - processingMessage = false; + tokovoip->setProcessingState(false); return (0); } lastChannelJoin = time(nullptr); if ((error = ts3Functions.requestClientMove(serverId, getMyId(serverId), channelId, channelPass.c_str(), NULL)) != ERROR_ok) { outputLog("Can't join channel", error); pluginStatus = 2; - processingMessage = false; + tokovoip->setProcessingState(false); return (0); } else @@ -181,7 +180,7 @@ DWORD WINAPI ServiceThread(LPVOID lpParam) { resetClientsAll(); pluginStatus = 2; - processingMessage = false; + tokovoip->setProcessingState(false); return (0); } } @@ -192,7 +191,7 @@ DWORD WINAPI ServiceThread(LPVOID lpParam) if (originalName == "") if ((error = ts3Functions.getClientVariableAsString(serverId, getMyId(serverId), CLIENT_NICKNAME, &originalName)) != ERROR_ok) { outputLog("Error getting client nickname", error); - processingMessage = false; + tokovoip->setProcessingState(false); return (0); } @@ -283,7 +282,7 @@ DWORD WINAPI ServiceThread(LPVOID lpParam) } } pluginStatus = 3; - processingMessage = false; + tokovoip->setProcessingState(false); //-------------------------------------------------------- @@ -348,7 +347,7 @@ DWORD WINAPI TimeoutThread(LPVOID lpParam) if ((error = ts3Functions.requestClientMove(serverId, getMyId(serverId), channelId, "", NULL)) != ERROR_ok) { outputLog("Can't join channel", error); pluginStatus = 2; - processingMessage = false; + tokovoip->setProcessingState(false); return (0); } else @@ -378,9 +377,8 @@ DWORD WINAPI TimeoutThread(LPVOID lpParam) DWORD WINAPI SendDataThread(LPVOID lpParam) { - while (!exitSendDataThread) - { - if (processingMessage == false) { + while (!exitSendDataThread) { + if (tokovoip->getProcessingState() == false) { sendCallback("TokoVOIP version:" + (string)ts3plugin_version()); sendCallback("TokoVOIP status:" + to_string(pluginStatus)); @@ -392,7 +390,7 @@ DWORD WINAPI SendDataThread(LPVOID lpParam) free(UUID); } } - if (processingMessage == false) + if (tokovoip->getProcessingState() == false) Sleep(1000); else Sleep(50); @@ -532,14 +530,14 @@ int Tokovoip::initialize(char *id) { return (0); outputLog("TokoVOIP initialized", 0); resetClientsAll(); + checkUpdate(); + isRunning = false; + tokovoip = this; exitTimeoutThread = false; exitSendDataThread = false; threadService = CreateThread(NULL, 0, ServiceThread, NULL, 0, NULL); threadTimeout = CreateThread(NULL, 0, TimeoutThread, NULL, 0, NULL); threadSendData = CreateThread(NULL, 0, SendDataThread, NULL, 0, NULL); - checkUpdate(); - isRunning = false; - tokovoip = this; return (1); } diff --git a/ts3_plugin/src/tokovoip.h b/ts3_plugin/src/tokovoip.h index 0402a2b..21e5d95 100644 --- a/ts3_plugin/src/tokovoip.h +++ b/ts3_plugin/src/tokovoip.h @@ -10,33 +10,6 @@ using json = nlohmann::json; typedef unsigned long DWORD; #endif -class Tokovoip { - private: - map radioData; - char *plugin_id; - char *plugin_path; - - public: - int initialize(char* id); - void shutdown(); - void setRadioData(string uuid, bool state) { - radioData[uuid] = state; - } - - char *getPluginID() { - return plugin_id; - } - - bool getRadioData(string uuid) - { - if (radioData.find(uuid) != radioData.end()) { - if (radioData[uuid] == true) return (true); - } - return false; - } -}; - - void resetVolumeAll(uint64 serverConnectionHandlerID); void unmuteAll(uint64 serverConnectionHandlerID); void resetPositionAll(uint64 serverConnectionHandlerID); @@ -57,3 +30,52 @@ void setClientName(string name); void setClientTalking(bool status); void setClientMuteStatus(uint64 serverConnectionHandlerID, anyID clientId, bool status); void playWavFile(const char* fileNameWithoutExtension); + +class Tokovoip { +private: + map radioData; + map safeRadioData; + bool processingState = false; + char *plugin_id; + char *plugin_path; + +public: + int initialize(char* id); + void shutdown(); + + char *getPluginID() { + return plugin_id; + } + + void setRadioData(string uuid, bool state) { + radioData[uuid] = state; + } + bool getRadioData(string uuid) { + if (radioData.find(uuid) != radioData.end()) { + if (radioData[uuid] == true) return (true); + } + return false; + } + + bool getSafeRadioData(string uuid) { + if (safeRadioData.find(uuid) != safeRadioData.end()) { + if (safeRadioData[uuid] == true) return (true); + } + return false; + } + + void setProcessingState(bool state) { + processingState = state; + if (state == false) { + map updatedRadioData; + for (const auto &data : radioData) { + updatedRadioData[data.first] = radioData[data.first]; + } + safeRadioData = updatedRadioData; + } + } + + bool getProcessingState() { + return processingState; + } +}; \ No newline at end of file diff --git a/ts3_plugin/src/translator.cpp b/ts3_plugin/src/translator.cpp deleted file mode 100644 index 991039b..0000000 --- a/ts3_plugin/src/translator.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "translator.h" - -#include "ts_logging_qt.h" -#include "ts_helpers_qt.h" - -Translator* Translator::m_Instance = 0; - -Translator::Translator(){} - -bool Translator::InitLocalization() -{ - const auto kLang = TSHelpers::GetLanguage(); - if (kLang.isEmpty()) - return false; - - translator = new QTranslator(this); - const auto kIsTranslate = translator->load(QStringLiteral(":/locales/radiofx_") + kLang); - if (!kIsTranslate) - TSLogging::Log("No translation available."); - - return kIsTranslate; -} diff --git a/ts3_plugin/src/translator.h b/ts3_plugin/src/translator.h deleted file mode 100644 index 99a8e75..0000000 --- a/ts3_plugin/src/translator.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -#include -#include -#include - -class Translator : public QObject -{ - Q_OBJECT - -public: - static Translator* instance() { - static QMutex mutex; - if(!m_Instance) { - mutex.lock(); - - if(!m_Instance) - m_Instance = new Translator; - - mutex.unlock(); - } - return m_Instance; - } - - static void drop() { - static QMutex mutex; - mutex.lock(); - delete m_Instance; - m_Instance = 0; - mutex.unlock(); - } - - bool InitLocalization(); - QTranslator* translator; - -signals: - -public slots: - -private: - explicit Translator(); - ~Translator() = default; - static Translator* m_Instance; - Translator(const Translator &); - Translator& operator=(const Translator &); -};