Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Adam <dev@robert-adam.de>2021-03-04 12:39:42 +0300
committerRobert Adam <dev@robert-adam.de>2021-03-06 20:57:22 +0300
commitd6f9e97ad64828066d5134c9d87e2673847eed79 (patch)
tree331c84ef78f47046f0eb46ffdf57ef40f12153d1 /src/mumble
parentd72cd32dae61dd2ec008698fc41dfc60f53df558 (diff)
REFAC(client): Remove global "g" macro
Defining a macro (global namespace) named "g" as a shortcut for accessing the Global struct never was a good idea. In order to avoid the problems this created (you must never name a variable "g" or include Global.h before a header that may have such a variable), the macro was removed and was instead replaced with a static function Global::get() that returns a reference to the Global struct. Just as with the old g macro, the existence of the respective pointer is not explicitly checked before dereferencing. It is assumed that everywhere where it is used, the Global struct has already been created.
Diffstat (limited to 'src/mumble')
-rw-r--r--src/mumble/ACLEditor.cpp22
-rw-r--r--src/mumble/ALSAAudio.cpp24
-rw-r--r--src/mumble/ASIOInput.cpp14
-rw-r--r--src/mumble/About.cpp4
-rw-r--r--src/mumble/Audio.cpp66
-rw-r--r--src/mumble/AudioConfigDialog.cpp14
-rw-r--r--src/mumble/AudioInput.cpp148
-rw-r--r--src/mumble/AudioOutput.cpp51
-rw-r--r--src/mumble/AudioOutputSpeech.cpp16
-rw-r--r--src/mumble/AudioStats.cpp20
-rw-r--r--src/mumble/AudioWizard.cpp215
-rw-r--r--src/mumble/BanEditor.cpp5
-rw-r--r--src/mumble/Cert.cpp9
-rw-r--r--src/mumble/ClientUser.cpp8
-rw-r--r--src/mumble/ConfigDialog.cpp24
-rw-r--r--src/mumble/ConnectDialog.cpp111
-rw-r--r--src/mumble/CoreAudio.mm29
-rw-r--r--src/mumble/CrashReporter.cpp8
-rw-r--r--src/mumble/CustomElements.cpp15
-rw-r--r--src/mumble/DBus.cpp51
-rw-r--r--src/mumble/Database.cpp14
-rw-r--r--src/mumble/DeveloperConsole.cpp9
-rw-r--r--src/mumble/Global.cpp4
-rw-r--r--src/mumble/Global.h8
-rw-r--r--src/mumble/GlobalShortcut.cpp37
-rw-r--r--src/mumble/GlobalShortcutButtons.cpp2
-rw-r--r--src/mumble/GlobalShortcut_macx.mm18
-rw-r--r--src/mumble/GlobalShortcut_unix.cpp13
-rw-r--r--src/mumble/GlobalShortcut_win.cpp31
-rw-r--r--src/mumble/JackAudio.cpp31
-rw-r--r--src/mumble/LCD.cpp15
-rw-r--r--src/mumble/ListenerLocalVolumeDialog.cpp4
-rw-r--r--src/mumble/Log.cpp59
-rw-r--r--src/mumble/Log_macx.mm3
-rw-r--r--src/mumble/Log_unix.cpp4
-rw-r--r--src/mumble/LookConfig.cpp7
-rw-r--r--src/mumble/MainWindow.cpp801
-rw-r--r--src/mumble/ManualPlugin.cpp15
-rw-r--r--src/mumble/Messages.cpp358
-rw-r--r--src/mumble/MumbleApplication.cpp15
-rw-r--r--src/mumble/NetworkConfig.cpp21
-rw-r--r--src/mumble/OSS.cpp21
-rw-r--r--src/mumble/Overlay.cpp19
-rw-r--r--src/mumble/OverlayClient.cpp89
-rw-r--r--src/mumble/OverlayConfig.cpp15
-rw-r--r--src/mumble/OverlayEditor.cpp25
-rw-r--r--src/mumble/OverlayEditorScene.cpp17
-rw-r--r--src/mumble/OverlayText.cpp4
-rw-r--r--src/mumble/OverlayUser.cpp9
-rw-r--r--src/mumble/OverlayUserGroup.cpp19
-rw-r--r--src/mumble/Overlay_macx.mm10
-rw-r--r--src/mumble/Overlay_win.cpp11
-rw-r--r--src/mumble/PAAudio.cpp15
-rw-r--r--src/mumble/PTTButtonWidget.cpp7
-rw-r--r--src/mumble/Plugins.cpp55
-rw-r--r--src/mumble/PulseAudio.cpp57
-rw-r--r--src/mumble/RichTextEditor.cpp25
-rw-r--r--src/mumble/ServerHandler.cpp59
-rw-r--r--src/mumble/Settings.cpp17
-rw-r--r--src/mumble/SocketRPC.cpp67
-rw-r--r--src/mumble/TalkingUI.cpp69
-rw-r--r--src/mumble/TalkingUIEntry.cpp9
-rw-r--r--src/mumble/TalkingUISelection.cpp17
-rw-r--r--src/mumble/TextToSpeech_macx.mm1
-rw-r--r--src/mumble/TextToSpeech_unix.cpp13
-rw-r--r--src/mumble/Themes.cpp13
-rw-r--r--src/mumble/Tokens.cpp11
-rw-r--r--src/mumble/Usage.cpp12
-rw-r--r--src/mumble/UserEdit.cpp7
-rw-r--r--src/mumble/UserInformation.cpp9
-rw-r--r--src/mumble/UserLocalNicknameDialog.cpp11
-rw-r--r--src/mumble/UserLocalVolumeDialog.cpp11
-rw-r--r--src/mumble/UserModel.cpp171
-rw-r--r--src/mumble/UserView.cpp19
-rw-r--r--src/mumble/VersionCheck.cpp39
-rw-r--r--src/mumble/VoiceRecorder.cpp15
-rw-r--r--src/mumble/VoiceRecorderDialog.cpp67
-rw-r--r--src/mumble/WASAPI.cpp49
-rw-r--r--src/mumble/WASAPINotificationClient.cpp7
-rw-r--r--src/mumble/WebFetch.cpp15
-rw-r--r--src/mumble/main.cpp164
-rw-r--r--src/mumble/os_macx.mm8
-rw-r--r--src/mumble/os_unix.cpp2
-rw-r--r--src/mumble/os_win.cpp13
84 files changed, 1708 insertions, 1908 deletions
diff --git a/src/mumble/ACLEditor.cpp b/src/mumble/ACLEditor.cpp
index b9f932687..c1863ecbe 100644
--- a/src/mumble/ACLEditor.cpp
+++ b/src/mumble/ACLEditor.cpp
@@ -19,8 +19,6 @@
# include <QtGui/QMessageBox>
#endif
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
#include "Global.h"
ACLGroup::ACLGroup(const QString &name) : Group(nullptr, name) {
@@ -60,7 +58,7 @@ ACLEditor::ACLEditor(int channelparentid, QWidget *p) : QDialog(p) {
qleChannelPassword->hide();
qlChannelPassword->hide();
- if (g.sh->uiVersion >= 0x010300) {
+ if (Global::get().sh->uiVersion >= 0x010300) {
qsbChannelMaxUsers->setRange(0, INT_MAX);
qsbChannelMaxUsers->setValue(0);
qsbChannelMaxUsers->setSpecialValueText(tr("Default server value"));
@@ -85,7 +83,7 @@ ACLEditor::ACLEditor(int channelid, const MumbleProto::ACL &mea, QWidget *p) : Q
iChannel = channelid;
Channel *pChannel = Channel::get(iChannel);
if (!pChannel) {
- g.l->log(Log::Warning, tr("Failed: Invalid channel"));
+ Global::get().l->log(Log::Warning, tr("Failed: Invalid channel"));
QDialog::reject();
return;
}
@@ -126,7 +124,7 @@ ACLEditor::ACLEditor(int channelid, const MumbleProto::ACL &mea, QWidget *p) : Q
qsbChannelPosition->setRange(INT_MIN, INT_MAX);
qsbChannelPosition->setValue(pChannel->iPosition);
- if (g.sh->uiVersion >= 0x010300) {
+ if (Global::get().sh->uiVersion >= 0x010300) {
qsbChannelMaxUsers->setRange(0, INT_MAX);
qsbChannelMaxUsers->setValue(pChannel->uiMaxUsers);
qsbChannelMaxUsers->setSpecialValueText(tr("Default server value"));
@@ -150,7 +148,7 @@ ACLEditor::ACLEditor(int channelid, const MumbleProto::ACL &mea, QWidget *p) : Q
if (!name.isEmpty()) {
// If the server's version is less than 1.4.0 then it won't support the new permission to reset a
// comment/avatar. Skipping this iteration of the loop prevents checkboxes for it being added to the UI.
- if ((g.sh->uiVersion < 0x010400) && (perm == ChanACL::ResetUserContent))
+ if ((Global::get().sh->uiVersion < 0x010400) && (perm == ChanACL::ResetUserContent))
continue;
QCheckBox *qcb;
@@ -285,7 +283,7 @@ void ACLEditor::accept() {
Channel *pChannel = Channel::get(iChannel);
if (!pChannel) {
// Channel gone while editing
- g.l->log(Log::Warning, tr("Failed: Invalid channel"));
+ Global::get().l->log(Log::Warning, tr("Failed: Invalid channel"));
QDialog::reject();
return;
}
@@ -299,7 +297,7 @@ void ACLEditor::accept() {
// Update channel state
if (bAddChannelMode) {
- g.sh->createChannel(iChannel, qleChannelName->text(), rteChannelDescription->text(),
+ Global::get().sh->createChannel(iChannel, qleChannelName->text(), rteChannelDescription->text(),
qsbChannelPosition->value(), qcbChannelTemporary->isChecked(), qsbChannelMaxUsers->value());
} else {
bool needs_update = false;
@@ -316,7 +314,7 @@ void ACLEditor::accept() {
const QString &descriptionText = rteChannelDescription->text();
mpcs.set_description(u8(descriptionText));
needs_update = true;
- g.db->setBlob(sha1(descriptionText), descriptionText.toUtf8());
+ Global::get().db->setBlob(sha1(descriptionText), descriptionText.toUtf8());
}
if (pChannel->iPosition != qsbChannelPosition->value()) {
mpcs.set_position(qsbChannelPosition->value());
@@ -327,7 +325,7 @@ void ACLEditor::accept() {
needs_update = true;
}
if (needs_update)
- g.sh->sendMessage(mpcs);
+ Global::get().sh->sendMessage(mpcs);
// Update ACL
msg.set_inherit_acls(bInheritACL);
@@ -363,7 +361,7 @@ void ACLEditor::accept() {
if (pid >= 0)
mpg->add_remove(pid);
}
- g.sh->sendMessage(msg);
+ Global::get().sh->sendMessage(msg);
}
QDialog::accept();
}
@@ -384,7 +382,7 @@ int ACLEditor::id(const QString &uname) {
if (!qhNameWait.contains(name)) {
MumbleProto::QueryUsers mpuq;
mpuq.add_names(u8(name));
- g.sh->sendMessage(mpuq);
+ Global::get().sh->sendMessage(mpuq);
iUnknown--;
qhNameWait.insert(name, iUnknown);
diff --git a/src/mumble/ALSAAudio.cpp b/src/mumble/ALSAAudio.cpp
index ec3828509..8c79c7c97 100644
--- a/src/mumble/ALSAAudio.cpp
+++ b/src/mumble/ALSAAudio.cpp
@@ -12,8 +12,6 @@
#include <alsa/asoundlib.h>
#include <sys/poll.h>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
#include "Global.h"
#define NBLOCKS 8
@@ -96,9 +94,9 @@ const QList< audioDevice > ALSAAudioInputRegistrar::getDeviceChoices() {
QStringList qlInputDevs = cards->qhInput.keys();
std::sort(qlInputDevs.begin(), qlInputDevs.end());
- if (qlInputDevs.contains(g.s.qsALSAInput)) {
- qlInputDevs.removeAll(g.s.qsALSAInput);
- qlInputDevs.prepend(g.s.qsALSAInput);
+ if (qlInputDevs.contains(Global::get().s.qsALSAInput)) {
+ qlInputDevs.removeAll(Global::get().s.qsALSAInput);
+ qlInputDevs.prepend(Global::get().s.qsALSAInput);
}
foreach (const QString &dev, qlInputDevs) {
@@ -130,9 +128,9 @@ const QList< audioDevice > ALSAAudioOutputRegistrar::getDeviceChoices() {
QStringList qlOutputDevs = cards->qhOutput.keys();
std::sort(qlOutputDevs.begin(), qlOutputDevs.end());
- if (qlOutputDevs.contains(g.s.qsALSAOutput)) {
- qlOutputDevs.removeAll(g.s.qsALSAOutput);
- qlOutputDevs.prepend(g.s.qsALSAOutput);
+ if (qlOutputDevs.contains(Global::get().s.qsALSAOutput)) {
+ qlOutputDevs.removeAll(Global::get().s.qsALSAOutput);
+ qlOutputDevs.prepend(Global::get().s.qsALSAOutput);
}
foreach (const QString &dev, qlOutputDevs) {
@@ -299,7 +297,7 @@ void ALSAAudioInput::run() {
QMutexLocker qml(&qmALSA);
snd_pcm_sframes_t readblapp;
- QByteArray device_name = g.s.qsALSAInput.toLatin1();
+ QByteArray device_name = Global::get().s.qsALSAInput.toLatin1();
snd_pcm_hw_params_t *hw_params = nullptr;
snd_pcm_t *capture_handle = nullptr;
@@ -351,7 +349,7 @@ void ALSAAudioInput::run() {
snd_pcm_close(capture_handle);
capture_handle = nullptr;
}
- g.mw->msgBox(
+ Global::get().mw->msgBox(
tr("Opening chosen ALSA Input failed: %1").arg(QString::fromLatin1(snd_strerror(err)).toHtmlEscaped()));
return;
}
@@ -420,7 +418,7 @@ void ALSAAudioOutput::run() {
snd_pcm_hw_params_t *hw_params = nullptr;
snd_pcm_sw_params_t *sw_params = nullptr;
- QByteArray device_name = g.s.qsALSAOutput.toLatin1();
+ QByteArray device_name = Global::get().s.qsALSAOutput.toLatin1();
snd_pcm_hw_params_alloca(&hw_params);
snd_pcm_sw_params_alloca(&sw_params);
@@ -444,7 +442,7 @@ void ALSAAudioOutput::run() {
unsigned int iOutputSize = (iFrameSize * rrate) / SAMPLE_RATE;
snd_pcm_uframes_t period_size = iOutputSize;
- snd_pcm_uframes_t buffer_size = iOutputSize * (g.s.iOutputDelay + 1);
+ snd_pcm_uframes_t buffer_size = iOutputSize * (Global::get().s.iOutputDelay + 1);
int dir = 1;
ALSA_ERRBAIL(snd_pcm_hw_params_set_period_size_near(pcm_handle, hw_params, &period_size, &dir));
@@ -487,7 +485,7 @@ void ALSAAudioOutput::run() {
snd_pcm_writei(pcm_handle, zerobuff, period_size);
if (!bOk) {
- g.mw->msgBox(
+ Global::get().mw->msgBox(
tr("Opening chosen ALSA Output failed: %1").arg(QString::fromLatin1(snd_strerror(err)).toHtmlEscaped()));
if (pcm_handle) {
snd_pcm_close(pcm_handle);
diff --git a/src/mumble/ASIOInput.cpp b/src/mumble/ASIOInput.cpp
index 4f3150506..9742499a5 100644
--- a/src/mumble/ASIOInput.cpp
+++ b/src/mumble/ASIOInput.cpp
@@ -12,8 +12,6 @@
#include <cmath>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
#include "Global.h"
// From os_win.cpp.
@@ -76,7 +74,7 @@ void ASIOInit::initialize() {
bool bFound = false;
- if (!g.s.bASIOEnable) {
+ if (!Global::get().s.bASIOEnable) {
qWarning("ASIOInput: ASIO forcefully disabled via 'asio/enable' config option.");
return;
}
@@ -410,7 +408,7 @@ void ASIOConfig::clearQuery() {
}
ASIOInput::ASIOInput() {
- QString qsCls = g.s.qsASIOclass;
+ QString qsCls = Global::get().s.qsASIOclass;
CLSID clsid;
iasio = nullptr;
@@ -419,8 +417,8 @@ ASIOInput::ASIOInput() {
// Sanity check things first.
- iNumMic = g.s.qlASIOmic.count();
- iNumSpeaker = g.s.qlASIOspeaker.count();
+ iNumMic = Global::get().s.qlASIOmic.count();
+ iNumSpeaker = Global::get().s.qlASIOspeaker.count();
if ((iNumMic == 0) || (iNumSpeaker == 0)) {
QMessageBox::warning(nullptr, QLatin1String("Mumble"),
@@ -482,7 +480,7 @@ ASIOInput::ASIOInput() {
int i, idx = 0;
for (i = 0; i < iNumMic; i++) {
abiInfo[idx].isInput = true;
- abiInfo[idx].channelNum = g.s.qlASIOmic[i].toInt();
+ abiInfo[idx].channelNum = Global::get().s.qlASIOmic[i].toInt();
aciInfo[idx].channel = abiInfo[idx].channelNum;
aciInfo[idx].isInput = true;
@@ -493,7 +491,7 @@ ASIOInput::ASIOInput() {
}
for (i = 0; i < iNumSpeaker; i++) {
abiInfo[idx].isInput = true;
- abiInfo[idx].channelNum = g.s.qlASIOspeaker[i].toInt();
+ abiInfo[idx].channelNum = Global::get().s.qlASIOspeaker[i].toInt();
aciInfo[idx].channel = abiInfo[idx].channelNum;
aciInfo[idx].isInput = true;
diff --git a/src/mumble/About.cpp b/src/mumble/About.cpp
index abf406a47..cfe211bb4 100644
--- a/src/mumble/About.cpp
+++ b/src/mumble/About.cpp
@@ -12,8 +12,6 @@
#include <QtWidgets/QPushButton>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
#include "Global.h"
#define DOQUOTE(arg) #arg
@@ -53,7 +51,7 @@ AboutDialog::AboutDialog(QWidget *p) : QDialog(p) {
QWidget *about = new QWidget(qtwTab);
QLabel *icon = new QLabel(about);
- icon->setPixmap(g.mw->qiIcon.pixmap(g.mw->qiIcon.actualSize(QSize(128, 128))));
+ icon->setPixmap(Global::get().mw->qiIcon.pixmap(Global::get().mw->qiIcon.actualSize(QSize(128, 128))));
QLabel *text = new QLabel(about);
text->setTextInteractionFlags(Qt::TextBrowserInteraction);
diff --git a/src/mumble/Audio.cpp b/src/mumble/Audio.cpp
index 2710e267d..498f0e845 100644
--- a/src/mumble/Audio.cpp
+++ b/src/mumble/Audio.cpp
@@ -13,12 +13,10 @@
#endif
#include "Log.h"
#include "PacketDataStream.h"
+#include "Global.h"
#include <QtCore/QObject>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
class CodecInit : public DeferInit {
public:
@@ -36,7 +34,7 @@ void CodecInit::initialize() {
OpusCodec *oCodec = new OpusCodec();
if (oCodec->isValid()) {
oCodec->report();
- g.oCodec = oCodec;
+ Global::get().oCodec = oCodec;
} else {
Log::logOrDefer(
Log::CriticalError,
@@ -45,7 +43,7 @@ void CodecInit::initialize() {
}
#endif
- if (g.s.bDisableCELT) {
+ if (Global::get().s.bDisableCELT) {
// Kill switch for CELT activated. Do not initialize it.
return;
}
@@ -56,7 +54,7 @@ void CodecInit::initialize() {
codec = new CELTCodecSBCELT();
if (codec->isValid()) {
codec->report();
- g.qmCodecs.insert(codec->bitstreamVersion(), codec);
+ Global::get().qmCodecs.insert(codec->bitstreamVersion(), codec);
} else {
delete codec;
}
@@ -64,13 +62,13 @@ void CodecInit::initialize() {
codec = new CELTCodec070(QLatin1String("0.7.0"));
if (codec->isValid()) {
codec->report();
- g.qmCodecs.insert(codec->bitstreamVersion(), codec);
+ Global::get().qmCodecs.insert(codec->bitstreamVersion(), codec);
} else {
delete codec;
codec = new CELTCodec070(QLatin1String("0.0.0"));
if (codec->isValid()) {
codec->report();
- g.qmCodecs.insert(codec->bitstreamVersion(), codec);
+ Global::get().qmCodecs.insert(codec->bitstreamVersion(), codec);
} else {
delete codec;
}
@@ -80,12 +78,12 @@ void CodecInit::initialize() {
void CodecInit::destroy() {
#ifdef USE_OPUS
- delete g.oCodec;
+ delete Global::get().oCodec;
#endif
- foreach (CELTCodec *codec, g.qmCodecs)
+ foreach (CELTCodec *codec, Global::get().qmCodecs)
delete codec;
- g.qmCodecs.clear();
+ Global::get().qmCodecs.clear();
}
LoopUser::LoopUser() {
@@ -101,7 +99,7 @@ LoopUser::LoopUser() {
}
void LoopUser::addFrame(const QByteArray &packet) {
- if (DOUBLE_RAND < g.s.dPacketLoss) {
+ if (DOUBLE_RAND < Global::get().s.dPacketLoss) {
qWarning("Drop");
return;
}
@@ -116,14 +114,14 @@ void LoopUser::addFrame(const QByteArray &packet) {
if (restart)
r = 0.0;
else
- r = DOUBLE_RAND * g.s.dMaxPacketDelay;
+ r = DOUBLE_RAND * Global::get().s.dMaxPacketDelay;
qmPackets.insert(static_cast< float >(time + r), packet);
}
// Restart check
if (qetLastFetch.elapsed() > 100) {
- AudioOutputPtr ao = g.ao;
+ AudioOutputPtr ao = Global::get().ao;
if (ao) {
MessageHandler::UDPMessageType msgType =
static_cast< MessageHandler::UDPMessageType >((packet.at(0) >> 5) & 0x7);
@@ -135,7 +133,7 @@ void LoopUser::addFrame(const QByteArray &packet) {
void LoopUser::fetchFrames() {
QMutexLocker l(&qmLock);
- AudioOutputPtr ao(g.ao);
+ AudioOutputPtr ao(Global::get().ao);
if (!ao || qmPackets.isEmpty()) {
return;
}
@@ -175,13 +173,13 @@ RecordUser::RecordUser() : LoopUser() {
}
RecordUser::~RecordUser() {
- AudioOutputPtr ao = g.ao;
+ AudioOutputPtr ao = Global::get().ao;
if (ao)
ao->removeBuffer(this);
}
void RecordUser::addFrame(const QByteArray &packet) {
- AudioOutputPtr ao(g.ao);
+ AudioOutputPtr ao(Global::get().ao);
if (!ao)
return;
@@ -203,18 +201,18 @@ void RecordUser::addFrame(const QByteArray &packet) {
}
void Audio::startOutput(const QString &output) {
- g.ao = AudioOutputRegistrar::newFromChoice(output);
- if (g.ao)
- g.ao->start(QThread::HighPriority);
+ Global::get().ao = AudioOutputRegistrar::newFromChoice(output);
+ if (Global::get().ao)
+ Global::get().ao->start(QThread::HighPriority);
}
void Audio::stopOutput() {
// Take a copy of the global AudioOutput shared pointer
// to keep a reference around.
- AudioOutputPtr ao = g.ao;
+ AudioOutputPtr ao = Global::get().ao;
// Reset the global AudioOutput shared pointer to the null pointer.
- g.ao.reset();
+ Global::get().ao.reset();
// Wait until our copy of the AudioOutput shared pointer (ao)
// is the only one left.
@@ -230,24 +228,24 @@ void Audio::stopOutput() {
// One such example is PulseAudioInput, whose destructor
// takes the PulseAudio mainloop lock. If the destructor
// is called inside one of the PulseAudio callbacks that
- // take copies of g.ai, the destructor will try to also
+ // take copies of Global::get().ai, the destructor will try to also
// take the mainloop lock, causing an abort().
ao.reset();
}
void Audio::startInput(const QString &input) {
- g.ai = AudioInputRegistrar::newFromChoice(input);
- if (g.ai)
- g.ai->start(QThread::HighestPriority);
+ Global::get().ai = AudioInputRegistrar::newFromChoice(input);
+ if (Global::get().ai)
+ Global::get().ai->start(QThread::HighestPriority);
}
void Audio::stopInput() {
// Take a copy of the global AudioInput shared pointer
// to keep a reference around.
- AudioInputPtr ai = g.ai;
+ AudioInputPtr ai = Global::get().ai;
// Reset the global AudioInput shared pointer to the null pointer.
- g.ai.reset();
+ Global::get().ai.reset();
// Wait until our copy of the AudioInput shared pointer (ai)
// is the only one left.
@@ -263,7 +261,7 @@ void Audio::stopInput() {
// One such example is PulseAudioInput, whose destructor
// takes the PulseAudio mainloop lock. If the destructor
// is called inside one of the PulseAudio callbacks that
- // take copies of g.ai, the destructor will try to also
+ // take copies of Global::get().ai, the destructor will try to also
// take the mainloop lock, causing an abort().
ai.reset();
}
@@ -277,13 +275,13 @@ void Audio::stop() {
// Take copies of the global AudioInput and AudioOutput
// shared pointers to keep a reference to each of them
// around.
- AudioInputPtr ai = g.ai;
- AudioOutputPtr ao = g.ao;
+ AudioInputPtr ai = Global::get().ai;
+ AudioOutputPtr ao = Global::get().ao;
// Reset the global AudioInput and AudioOutput shared pointers
// to the null pointer.
- g.ao.reset();
- g.ai.reset();
+ Global::get().ao.reset();
+ Global::get().ai.reset();
// Wait until our copies of the AudioInput and AudioOutput shared pointers
// (ai and ao) are the only ones left.
@@ -300,7 +298,7 @@ void Audio::stop() {
// One such example is PulseAudioInput, whose destructor
// takes the PulseAudio mainloop lock. If the destructor
// is called inside one of the PulseAudio callbacks that
- // take copies of g.ai, the destructor will try to also
+ // take copies of Global::get().ai, the destructor will try to also
// take the mainloop lock, causing an abort().
ai.reset();
ao.reset();
diff --git a/src/mumble/AudioConfigDialog.cpp b/src/mumble/AudioConfigDialog.cpp
index 224b48616..8891842a6 100644
--- a/src/mumble/AudioConfigDialog.cpp
+++ b/src/mumble/AudioConfigDialog.cpp
@@ -112,9 +112,9 @@ AudioInputDialog::AudioInputDialog(Settings &st) : ConfigWidget(st) {
qcbDevice->view()->setTextElideMode(Qt::ElideRight);
- on_qcbPushClick_clicked(g.s.bTxAudioCue);
+ on_qcbPushClick_clicked(Global::get().s.bTxAudioCue);
on_Tick_timeout();
- on_qcbIdleAction_currentIndexChanged(g.s.iaeIdleAction);
+ on_qcbIdleAction_currentIndexChanged(Global::get().s.iaeIdleAction);
// Hide the slider by default
showSpeexNoiseSuppressionSlider(false);
@@ -374,7 +374,7 @@ void AudioInputDialog::updateBitrate() {
if (NetworkConfig::TcpModeEnabled())
overhead += 100 * 8 * 12;
- if (g.s.bTransmitPosition)
+ if (Global::get().s.bTransmitPosition)
posrate = 12;
else
posrate = 0;
@@ -388,7 +388,7 @@ void AudioInputDialog::updateBitrate() {
QPalette pal;
- if (g.uiSession && (total > g.iMaxBandwidth)) {
+ if (Global::get().uiSession && (total > Global::get().iMaxBandwidth)) {
pal.setColor(qlBitrate->foregroundRole(), Qt::red);
}
@@ -431,7 +431,7 @@ void AudioInputDialog::on_qpbPushClickBrowseOff_clicked() {
}
void AudioInputDialog::on_qpbPushClickPreview_clicked() {
- AudioOutputPtr ao = g.ao;
+ AudioOutputPtr ao = Global::get().ao;
if (ao) {
AudioOutputSample *sample = ao->playSample(qlePushClickPathOn->text());
if (sample)
@@ -442,7 +442,7 @@ void AudioInputDialog::on_qpbPushClickPreview_clicked() {
}
void AudioInputDialog::continuePlayback() {
- AudioOutputPtr ao = g.ao;
+ AudioOutputPtr ao = Global::get().ao;
if (ao) {
ao->playSample(qlePushClickPathOff->text());
}
@@ -548,7 +548,7 @@ void AudioInputDialog::showSpeexNoiseSuppressionSlider(bool show) {
}
void AudioInputDialog::on_Tick_timeout() {
- AudioInputPtr ai = g.ai;
+ AudioInputPtr ai = Global::get().ai;
if (!ai.get() || !ai->sppPreprocess)
return;
diff --git a/src/mumble/AudioInput.cpp b/src/mumble/AudioInput.cpp
index 4e1790afe..5a4723c97 100644
--- a/src/mumble/AudioInput.cpp
+++ b/src/mumble/AudioInput.cpp
@@ -172,11 +172,11 @@ AudioInputPtr AudioInputRegistrar::newFromChoice(QString choice) {
return AudioInputPtr();
if (!choice.isEmpty() && qmNew->contains(choice)) {
- g.s.qsAudioInput = choice;
+ Global::get().s.qsAudioInput = choice;
current = choice;
return AudioInputPtr(qmNew->value(current)->create());
}
- choice = g.s.qsAudioInput;
+ choice = Global::get().s.qsAudioInput;
if (qmNew->contains(choice)) {
current = choice;
return AudioInputPtr(qmNew->value(choice)->create());
@@ -201,18 +201,18 @@ bool AudioInputRegistrar::isMicrophoneAccessDeniedByOS() {
return false;
}
-AudioInput::AudioInput() : opusBuffer(g.s.iFramesPerPacket * (SAMPLE_RATE / 100)) {
- bDebugDumpInput = g.bDebugDumpInput;
- resync.bDebugPrintQueue = g.bDebugPrintQueue;
+AudioInput::AudioInput() : opusBuffer(Global::get().s.iFramesPerPacket * (SAMPLE_RATE / 100)) {
+ bDebugDumpInput = Global::get().bDebugDumpInput;
+ resync.bDebugPrintQueue = Global::get().bDebugPrintQueue;
if (bDebugDumpInput) {
outMic.open("raw_microphone_dump", std::ios::binary);
outSpeaker.open("speaker_dump", std::ios::binary);
outProcessed.open("processed_microphone_dump", std::ios::binary);
}
- adjustBandwidth(g.iMaxBandwidth, iAudioQuality, iAudioFrames, bAllowLowDelay);
+ adjustBandwidth(Global::get().iMaxBandwidth, iAudioQuality, iAudioFrames, bAllowLowDelay);
- g.iAudioBandwidth = getNetworkBandwidth(iAudioQuality, iAudioFrames);
+ Global::get().iAudioBandwidth = getNetworkBandwidth(iAudioQuality, iAudioFrames);
umtType = MessageHandler::UDPVoiceCELTAlpha;
@@ -223,7 +223,7 @@ AudioInput::AudioInput() : opusBuffer(g.s.iFramesPerPacket * (SAMPLE_RATE / 100)
ceEncoder = nullptr;
#ifdef USE_OPUS
- oCodec = g.oCodec;
+ oCodec = Global::get().oCodec;
if (oCodec) {
if (bAllowLowDelay && iAudioQuality >= 64000) { // > 64 kbit/s bitrate and low delay allowed
opusState = oCodec->opus_encoder_create(SAMPLE_RATE, 1, OPUS_APPLICATION_RESTRICTED_LOWDELAY, nullptr);
@@ -274,14 +274,14 @@ AudioInput::AudioInput() : opusBuffer(g.s.iFramesPerPacket * (SAMPLE_RATE / 100)
iBitrate = 0;
dPeakSignal = dPeakSpeaker = dPeakMic = dPeakCleanMic = 0.0;
- if (g.uiSession) {
- setMaxBandwidth(g.iMaxBandwidth);
+ if (Global::get().uiSession) {
+ setMaxBandwidth(Global::get().iMaxBandwidth);
}
bRunning = true;
- connect(this, SIGNAL(doDeaf()), g.mw->qaAudioDeaf, SLOT(trigger()), Qt::QueuedConnection);
- connect(this, SIGNAL(doMute()), g.mw->qaAudioMute, SLOT(trigger()), Qt::QueuedConnection);
+ connect(this, SIGNAL(doDeaf()), Global::get().mw->qaAudioDeaf, SLOT(trigger()), Qt::QueuedConnection);
+ connect(this, SIGNAL(doMute()), Global::get().mw->qaAudioMute, SLOT(trigger()), Qt::QueuedConnection);
}
AudioInput::~AudioInput() {
@@ -514,7 +514,7 @@ void AudioInput::initializeMixer() {
pfMicInput = new float[iMicLength];
if (iEchoChannels > 0) {
- bEchoMulti = (g.s.echoOption == EchoCancelOptionID::SPEEX_MULTICHANNEL);
+ bEchoMulti = (Global::get().s.echoOption == EchoCancelOptionID::SPEEX_MULTICHANNEL);
if (iEchoFreq != iSampleRate)
srsEcho = speex_resampler_init(bEchoMulti ? iEchoChannels : 1, iEchoFreq, iSampleRate, 3, &err);
iEchoLength = (iFrameSize * iEchoFreq) / iSampleRate;
@@ -526,7 +526,7 @@ void AudioInput::initializeMixer() {
pfEchoInput = nullptr;
}
- uiMicChannelMask = g.s.uiAudioInputChannelMask;
+ uiMicChannelMask = Global::get().s.uiAudioInputChannelMask;
// There is no channel mask setting for the echo canceller, so allow all channels.
uiEchoChannelMask = 0xffffffffffffffffULL;
@@ -666,9 +666,9 @@ void AudioInput::addEcho(const void *data, unsigned int nsamp) {
}
void AudioInput::adjustBandwidth(int bitspersec, int &bitrate, int &frames, bool &allowLowDelay) {
- frames = g.s.iFramesPerPacket;
- bitrate = g.s.iQuality;
- allowLowDelay = g.s.bAllowLowDelay;
+ frames = Global::get().s.iFramesPerPacket;
+ bitrate = Global::get().s.iQuality;
+ allowLowDelay = Global::get().s.bAllowLowDelay;
if (bitspersec == -1) {
// No limit
@@ -692,7 +692,7 @@ void AudioInput::adjustBandwidth(int bitspersec, int &bitrate, int &frames, bool
}
void AudioInput::setMaxBandwidth(int bitspersec) {
- if (bitspersec == g.iMaxBandwidth)
+ if (bitspersec == Global::get().iMaxBandwidth)
return;
int frames;
@@ -700,20 +700,20 @@ void AudioInput::setMaxBandwidth(int bitspersec) {
bool allowLowDelay;
adjustBandwidth(bitspersec, bitrate, frames, allowLowDelay);
- g.iMaxBandwidth = bitspersec;
+ Global::get().iMaxBandwidth = bitspersec;
if (bitspersec != -1) {
- if ((bitrate != g.s.iQuality) || (frames != g.s.iFramesPerPacket))
- g.mw->msgBox(tr("Server maximum network bandwidth is only %1 kbit/s. Audio quality auto-adjusted to %2 "
+ if ((bitrate != Global::get().s.iQuality) || (frames != Global::get().s.iFramesPerPacket))
+ Global::get().mw->msgBox(tr("Server maximum network bandwidth is only %1 kbit/s. Audio quality auto-adjusted to %2 "
"kbit/s (%3 ms)")
.arg(bitspersec / 1000)
.arg(bitrate / 1000)
.arg(frames * 10));
}
- AudioInputPtr ai = g.ai;
+ AudioInputPtr ai = Global::get().ai;
if (ai) {
- g.iAudioBandwidth = getNetworkBandwidth(bitrate, frames);
+ Global::get().iAudioBandwidth = getNetworkBandwidth(bitrate, frames);
ai->iAudioQuality = bitrate;
ai->iAudioFrames = frames;
ai->bAllowLowDelay = allowLowDelay;
@@ -728,7 +728,7 @@ void AudioInput::setMaxBandwidth(int bitspersec) {
int AudioInput::getNetworkBandwidth(int bitrate, int frames) {
int overhead =
- 20 + 8 + 4 + 1 + 2 + (g.s.bTransmitPosition ? 12 : 0) + (NetworkConfig::TcpModeEnabled() ? 12 : 0) + frames;
+ 20 + 8 + 4 + 1 + 2 + (Global::get().s.bTransmitPosition ? 12 : 0) + (NetworkConfig::TcpModeEnabled() ? 12 : 0) + frames;
overhead *= (800 / frames);
int bw = overhead + bitrate;
@@ -758,7 +758,7 @@ void AudioInput::resetAudioProcessor() {
iArg = 30000;
speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_SET_AGC_TARGET, &iArg);
- float v = 30000.0f / static_cast< float >(g.s.iMinLoudness);
+ float v = 30000.0f / static_cast< float >(Global::get().s.iMinLoudness);
iArg = iroundf(floorf(20.0f * log10f(v)));
speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_SET_AGC_MAX_GAIN, &iArg);
@@ -766,7 +766,7 @@ void AudioInput::resetAudioProcessor() {
speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_SET_AGC_DECREMENT, &iArg);
if (noiseCancel == Settings::NoiseCancelSpeex) {
- iArg = g.s.iSpeexNoiseCancelStrength;
+ iArg = Global::get().s.iSpeexNoiseCancelStrength;
speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &iArg);
}
@@ -795,7 +795,7 @@ bool AudioInput::selectCodec() {
useOpus = (umtType == MessageHandler::UDPVoiceOpus);
} else {
#ifdef USE_OPUS
- if (g.bOpus || (g.s.lmLoopMode == Settings::Local)) {
+ if (Global::get().bOpus || (Global::get().s.lmLoopMode == Settings::Local)) {
useOpus = true;
}
#endif
@@ -803,23 +803,23 @@ bool AudioInput::selectCodec() {
if (!useOpus) {
CELTCodec *switchto = nullptr;
- if ((!g.uiSession || (g.s.lmLoopMode == Settings::Local)) && (!g.qmCodecs.isEmpty())) {
+ if ((!Global::get().uiSession || (Global::get().s.lmLoopMode == Settings::Local)) && (!Global::get().qmCodecs.isEmpty())) {
// Use latest for local loopback
- QMap< int, CELTCodec * >::const_iterator i = g.qmCodecs.constEnd();
+ QMap< int, CELTCodec * >::const_iterator i = Global::get().qmCodecs.constEnd();
--i;
switchto = i.value();
} else {
// Currently talking, don't switch unless you must.
if (cCodec && bPreviousVoice) {
int v = cCodec->bitstreamVersion();
- if ((v == g.iCodecAlpha) || (v == g.iCodecBeta))
+ if ((v == Global::get().iCodecAlpha) || (v == Global::get().iCodecBeta))
switchto = cCodec;
}
}
if (!switchto) {
- switchto = g.qmCodecs.value(g.bPreferAlpha ? g.iCodecAlpha : g.iCodecBeta);
+ switchto = Global::get().qmCodecs.value(Global::get().bPreferAlpha ? Global::get().iCodecAlpha : Global::get().iCodecBeta);
if (!switchto)
- switchto = g.qmCodecs.value(g.bPreferAlpha ? g.iCodecBeta : g.iCodecAlpha);
+ switchto = Global::get().qmCodecs.value(Global::get().bPreferAlpha ? Global::get().iCodecBeta : Global::get().iCodecAlpha);
}
if (switchto != cCodec) {
if (cCodec && ceEncoder) {
@@ -839,13 +839,13 @@ bool AudioInput::selectCodec() {
if (useOpus) {
umtType = MessageHandler::UDPVoiceOpus;
} else {
- if (!g.uiSession) {
+ if (!Global::get().uiSession) {
umtType = MessageHandler::UDPVoiceCELTAlpha;
} else {
int v = cCodec->bitstreamVersion();
- if (v == g.iCodecAlpha)
+ if (v == Global::get().iCodecAlpha)
umtType = MessageHandler::UDPVoiceCELTAlpha;
- else if (v == g.iCodecBeta)
+ else if (v == Global::get().iCodecBeta)
umtType = MessageHandler::UDPVoiceCELTBeta;
else {
qWarning() << "Couldn't find message type for codec version" << v;
@@ -863,7 +863,7 @@ bool AudioInput::selectCodec() {
}
void AudioInput::selectNoiseCancel() {
- noiseCancel = g.s.noiseCancelMode;
+ noiseCancel = Global::get().s.noiseCancelMode;
if (noiseCancel == Settings::NoiseCancelRNN || noiseCancel == Settings::NoiseCancelBoth) {
#ifdef USE_RNNOISE
@@ -950,12 +950,12 @@ void AudioInput::encodeAudioFrame(AudioChunk chunk) {
iFrameCounter++;
- // As g.iTarget is not protected by any locks, we avoid race-conditions by
+ // As Global::get().iTarget is not protected by any locks, we avoid race-conditions by
// copying it once at this point and stick to whatever value it is here. Thus
- // if the value of g.iTarget changes during the execution of this function,
+ // if the value of Global::get().iTarget changes during the execution of this function,
// it won't cause any inconsistencies and the change is reflected once this
// function is called again.
- int voiceTargetID = g.iTarget;
+ int voiceTargetID = Global::get().iTarget;
if (!bRunning)
return;
@@ -985,7 +985,7 @@ void AudioInput::encodeAudioFrame(AudioChunk chunk) {
speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_GET_AGC_GAIN, &iArg);
float gainValue = static_cast< float >(iArg);
if (noiseCancel == Settings::NoiseCancelSpeex || noiseCancel == Settings::NoiseCancelBoth) {
- iArg = g.s.iSpeexNoiseCancelStrength - iArg;
+ iArg = Global::get().s.iSpeexNoiseCancelStrength - iArg;
speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &iArg);
}
@@ -1035,41 +1035,41 @@ void AudioInput::encodeAudioFrame(AudioChunk chunk) {
// clean microphone level: peak of filtered signal attenuated by AGC gain
dPeakCleanMic = qMax(dPeakSignal - gainValue, -96.0f);
- float level = (g.s.vsVAD == Settings::SignalToNoise) ? fSpeechProb : (1.0f + dPeakCleanMic / 96.0f);
+ float level = (Global::get().s.vsVAD == Settings::SignalToNoise) ? fSpeechProb : (1.0f + dPeakCleanMic / 96.0f);
bool bIsSpeech = false;
- if (level > g.s.fVADmax) {
+ if (level > Global::get().s.fVADmax) {
// Voice-activation threshold has been reached
bIsSpeech = true;
- } else if (level > g.s.fVADmin && bPreviousVoice) {
+ } else if (level > Global::get().s.fVADmin && bPreviousVoice) {
// Voice-deactivation threshold has not yet been reached
bIsSpeech = true;
}
if (!bIsSpeech) {
iHoldFrames++;
- if (iHoldFrames < g.s.iVoiceHold)
+ if (iHoldFrames < Global::get().s.iVoiceHold)
bIsSpeech = true;
} else {
iHoldFrames = 0;
}
- if (g.s.atTransmit == Settings::Continuous) {
+ if (Global::get().s.atTransmit == Settings::Continuous) {
// Continous transmission is enabled
bIsSpeech = true;
- } else if (g.s.atTransmit == Settings::PushToTalk) {
+ } else if (Global::get().s.atTransmit == Settings::PushToTalk) {
// PTT is enabled, so check if it is currently active
bIsSpeech =
- g.s.uiDoublePush && ((g.uiDoublePush < g.s.uiDoublePush) || (g.tDoublePush.elapsed() < g.s.uiDoublePush));
+ Global::get().s.uiDoublePush && ((Global::get().uiDoublePush < Global::get().s.uiDoublePush) || (Global::get().tDoublePush.elapsed() < Global::get().s.uiDoublePush));
}
- // If g.iPushToTalk > 0 that means that we are currently in some sort of PTT action. For
+ // If Global::get().iPushToTalk > 0 that means that we are currently in some sort of PTT action. For
// instance this could mean we're currently whispering
- bIsSpeech = bIsSpeech || (g.iPushToTalk > 0);
+ bIsSpeech = bIsSpeech || (Global::get().iPushToTalk > 0);
- ClientUser *p = ClientUser::get(g.uiSession);
- if (g.s.bMute || ((g.s.lmLoopMode != Settings::Local) && p && (p->bMute || p->bSuppress)) || g.bPushToMute
+ ClientUser *p = ClientUser::get(Global::get().uiSession);
+ if (Global::get().s.bMute || ((Global::get().s.lmLoopMode != Settings::Local) && p && (p->bMute || p->bSuppress)) || Global::get().bPushToMute
|| (voiceTargetID < 0)) {
bIsSpeech = false;
}
@@ -1091,33 +1091,33 @@ void AudioInput::encodeAudioFrame(AudioChunk chunk) {
p->setTalking(Settings::Shouting);
}
- if (g.s.bTxAudioCue && g.uiSession != 0) {
- AudioOutputPtr ao = g.ao;
+ if (Global::get().s.bTxAudioCue && Global::get().uiSession != 0) {
+ AudioOutputPtr ao = Global::get().ao;
if (bIsSpeech && !bPreviousVoice && ao)
- ao->playSample(g.s.qsTxAudioCueOn);
+ ao->playSample(Global::get().s.qsTxAudioCueOn);
else if (ao && !bIsSpeech && bPreviousVoice)
- ao->playSample(g.s.qsTxAudioCueOff);
+ ao->playSample(Global::get().s.qsTxAudioCueOff);
}
if (!bIsSpeech && !bPreviousVoice) {
iBitrate = 0;
- if ((tIdle.elapsed() / 1000000ULL) > g.s.iIdleTime) {
+ if ((tIdle.elapsed() / 1000000ULL) > Global::get().s.iIdleTime) {
activityState = ActivityStateIdle;
tIdle.restart();
- if (g.s.iaeIdleAction == Settings::Deafen && !g.s.bDeaf) {
+ if (Global::get().s.iaeIdleAction == Settings::Deafen && !Global::get().s.bDeaf) {
emit doDeaf();
- } else if (g.s.iaeIdleAction == Settings::Mute && !g.s.bMute) {
+ } else if (Global::get().s.iaeIdleAction == Settings::Mute && !Global::get().s.bMute) {
emit doMute();
}
}
if (activityState == ActivityStateReturnedFromIdle) {
activityState = ActivityStateActive;
- if (g.s.iaeIdleAction != Settings::Nothing && g.s.bUndoIdleActionUponActivity) {
- if (g.s.iaeIdleAction == Settings::Deafen && g.s.bDeaf) {
+ if (Global::get().s.iaeIdleAction != Settings::Nothing && Global::get().s.bUndoIdleActionUponActivity) {
+ if (Global::get().s.iaeIdleAction == Settings::Deafen && Global::get().s.bDeaf) {
emit doDeaf();
- } else if (g.s.iaeIdleAction == Settings::Mute && g.s.bMute) {
+ } else if (Global::get().s.iaeIdleAction == Settings::Mute && Global::get().s.bMute) {
emit doMute();
}
}
@@ -1196,14 +1196,14 @@ void AudioInput::encodeAudioFrame(AudioChunk chunk) {
}
static void sendAudioFrame(const char *data, PacketDataStream &pds) {
- ServerHandlerPtr sh = g.sh;
+ ServerHandlerPtr sh = Global::get().sh;
if (sh) {
VoiceRecorderPtr recorder(sh->recorder);
if (recorder)
recorder->getRecordUser().addFrame(QByteArray(data, pds.size() + 1));
}
- if (g.s.lmLoopMode == Settings::Local)
+ if (Global::get().s.lmLoopMode == Settings::Local)
LoopUser::lpLoopy.addFrame(QByteArray(data, pds.size() + 1));
else if (sh)
sh->sendMessage(data, pds.size() + 1);
@@ -1219,21 +1219,21 @@ void AudioInput::flushCheck(const QByteArray &frame, bool terminator, int voiceT
if (voiceTargetID > 0) {
flags = voiceTargetID;
}
- if (terminator && g.iPrevTarget > 0) {
+ if (terminator && Global::get().iPrevTarget > 0) {
// If we have been whispering to some target but have just ended, terminator will be true. However
// in the case of whispering this means that we just released the whisper key so this here is the
- // last audio frame that is sent for whispering. The whisper key being released means that g.iTarget
+ // last audio frame that is sent for whispering. The whisper key being released means that Global::get().iTarget
// is reset to 0 by now. In order to send the last whisper frame correctly, we have to use
- // g.iPrevTarget which is set to whatever g.iTarget has been before its last change.
+ // Global::get().iPrevTarget which is set to whatever Global::get().iTarget has been before its last change.
- flags = g.iPrevTarget;
+ flags = Global::get().iPrevTarget;
- // We reset g.iPrevTarget as it has fulfilled its purpose for this whisper-action. It'll be set
+ // We reset Global::get().iPrevTarget as it has fulfilled its purpose for this whisper-action. It'll be set
// accordingly once the client whispers for the next time.
- g.iPrevTarget = 0;
+ Global::get().iPrevTarget = 0;
}
- if (g.s.lmLoopMode == Settings::Server)
+ if (Global::get().s.lmLoopMode == Settings::Server)
flags = 0x1f; // Server loopback
flags |= (umtType << 5);
@@ -1271,10 +1271,10 @@ void AudioInput::flushCheck(const QByteArray &frame, bool terminator, int voiceT
}
}
- if (g.s.bTransmitPosition && g.p && !g.bCenterPosition && g.p->fetch()) {
- pds << g.p->fPosition[0];
- pds << g.p->fPosition[1];
- pds << g.p->fPosition[2];
+ if (Global::get().s.bTransmitPosition && Global::get().p && !Global::get().bCenterPosition && Global::get().p->fetch()) {
+ pds << Global::get().p->fPosition[0];
+ pds << Global::get().p->fPosition[1];
+ pds << Global::get().p->fPosition[2];
}
sendAudioFrame(data, pds);
diff --git a/src/mumble/AudioOutput.cpp b/src/mumble/AudioOutput.cpp
index cb0ff6f62..a52cc393b 100644
--- a/src/mumble/AudioOutput.cpp
+++ b/src/mumble/AudioOutput.cpp
@@ -27,9 +27,6 @@
#include "User.h"
#include "Utils.h"
#include "VoiceRecorder.h"
-
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
#include "Global.h"
// Remember that we cannot use static member classes that are not pointers, as the constructor
@@ -55,11 +52,11 @@ AudioOutputPtr AudioOutputRegistrar::newFromChoice(QString choice) {
return AudioOutputPtr();
if (!choice.isEmpty() && qmNew->contains(choice)) {
- g.s.qsAudioOutput = choice;
+ Global::get().s.qsAudioOutput = choice;
current = choice;
return AudioOutputPtr(qmNew->value(choice)->create());
}
- choice = g.s.qsAudioOutput;
+ choice = Global::get().s.qsAudioOutput;
if (qmNew->contains(choice)) {
current = choice;
return AudioOutputPtr(qmNew->value(choice)->create());
@@ -109,23 +106,23 @@ float AudioOutput::calcGain(float dotproduct, float distance) {
// No distance attenuation
- if (g.s.fAudioMaxDistVolume > 0.99f) {
- att = qMin(1.0f, dotfactor + g.s.fAudioBloom);
- } else if (distance < g.s.fAudioMinDistance) {
- float bloomfac = g.s.fAudioBloom * (1.0f - distance / g.s.fAudioMinDistance);
+ if (Global::get().s.fAudioMaxDistVolume > 0.99f) {
+ att = qMin(1.0f, dotfactor + Global::get().s.fAudioBloom);
+ } else if (distance < Global::get().s.fAudioMinDistance) {
+ float bloomfac = Global::get().s.fAudioBloom * (1.0f - distance / Global::get().s.fAudioMinDistance);
att = qMin(1.0f, bloomfac + dotfactor);
} else {
float datt;
- if (distance >= g.s.fAudioMaxDistance) {
- datt = g.s.fAudioMaxDistVolume;
+ if (distance >= Global::get().s.fAudioMaxDistance) {
+ datt = Global::get().s.fAudioMaxDistVolume;
} else {
- float mvol = g.s.fAudioMaxDistVolume;
+ float mvol = Global::get().s.fAudioMaxDistVolume;
if (mvol < 0.01f)
mvol = 0.01f;
- float drel = (distance - g.s.fAudioMinDistance) / (g.s.fAudioMaxDistance - g.s.fAudioMinDistance);
+ float drel = (distance - Global::get().s.fAudioMinDistance) / (Global::get().s.fAudioMaxDistance - Global::get().s.fAudioMinDistance);
datt = powf(10.0f, log10f(mvol) * drel);
}
@@ -329,7 +326,7 @@ void AudioOutput::initializeMixer(const unsigned int *chanmasks, bool forceheadp
qWarning("AudioOutput: Unknown speaker %d: %08x", i, chanmasks[i]);
break;
}
- if (g.s.bPositionalHeadphone || forceheadphone) {
+ if (Global::get().s.bPositionalHeadphone || forceheadphone) {
s[1] = 0.0f;
s[2] = 0.0f;
if (s[0] == 0.0f)
@@ -366,17 +363,17 @@ bool AudioOutput::mix(void *outbuff, unsigned int frameCount) {
// A list of users that no longer have any audio to play and can thus be deleted
QList< AudioOutputUser * > qlDel;
- if (g.s.fVolume < 0.01f) {
+ if (Global::get().s.fVolume < 0.01f) {
return false;
}
const float adjustFactor = std::pow(10.f, -18.f / 20);
- const float mul = g.s.fVolume;
+ const float mul = Global::get().s.fVolume;
const unsigned int nchan = iChannels;
- ServerHandlerPtr sh = g.sh;
+ ServerHandlerPtr sh = Global::get().sh;
VoiceRecorderPtr recorder;
if (sh) {
- recorder = g.sh->recorder;
+ recorder = Global::get().sh->recorder;
}
qrwlOutputs.lockForRead();
@@ -400,7 +397,7 @@ bool AudioOutput::mix(void *outbuff, unsigned int frameCount) {
++it;
}
- if (g.prioritySpeakerActiveOverride) {
+ if (Global::get().prioritySpeakerActiveOverride) {
prioritySpeakerActive = true;
}
@@ -429,13 +426,13 @@ bool AudioOutput::mix(void *outbuff, unsigned int frameCount) {
for (unsigned int i = 0; i < iChannels; ++i)
svol[i] = mul * fSpeakerVolume[i];
- if (g.s.bPositionalAudio && (iChannels > 1) && g.p->fetch()
- && (g.bPosTest || g.p->fCameraPosition[0] != 0 || g.p->fCameraPosition[1] != 0
- || g.p->fCameraPosition[2] != 0)) {
+ if (Global::get().s.bPositionalAudio && (iChannels > 1) && Global::get().p->fetch()
+ && (Global::get().bPosTest || Global::get().p->fCameraPosition[0] != 0 || Global::get().p->fCameraPosition[1] != 0
+ || Global::get().p->fCameraPosition[2] != 0)) {
// Calculate the positional audio effects if it is enabled
- float front[3] = { g.p->fCameraFront[0], g.p->fCameraFront[1], g.p->fCameraFront[2] };
- float top[3] = { g.p->fCameraTop[0], g.p->fCameraTop[1], g.p->fCameraTop[2] };
+ float front[3] = { Global::get().p->fCameraFront[0], Global::get().p->fCameraFront[1], Global::get().p->fCameraFront[2] };
+ float top[3] = { Global::get().p->fCameraTop[0], Global::get().p->fCameraTop[1], Global::get().p->fCameraTop[2] };
// Front vector is dominant; if it's zero we presume all is zero.
@@ -528,7 +525,7 @@ bool AudioOutput::mix(void *outbuff, unsigned int frameCount) {
const ClientUser *user = speech->p;
volumeAdjustment *= user->getLocalVolumeAdjustments();
- if (user->cChannel && ChannelListener::isListening(g.uiSession, user->cChannel->iId)
+ if (user->cChannel && ChannelListener::isListening(Global::get().uiSession, user->cChannel->iId)
&& (speech->ucFlags & SpeechFlags::Listen)) {
// We are receiving this audio packet only because we are listening to the channel
// the speaking user is in. Thus we receive the audio via our "listener proxy".
@@ -583,8 +580,8 @@ bool AudioOutput::mix(void *outbuff, unsigned int frameCount) {
#endif
// If positional audio is enabled, calculate the respective audio effect here
- float dir[3] = { aop->fPos[0] - g.p->fCameraPosition[0], aop->fPos[1] - g.p->fCameraPosition[1],
- aop->fPos[2] - g.p->fCameraPosition[2] };
+ float dir[3] = { aop->fPos[0] - Global::get().p->fCameraPosition[0], aop->fPos[1] - Global::get().p->fCameraPosition[1],
+ aop->fPos[2] - Global::get().p->fCameraPosition[2] };
float len = sqrtf(dir[0] * dir[0] + dir[1] * dir[1] + dir[2] * dir[2]);
if (len > 0.0f) {
dir[0] /= len;
diff --git a/src/mumble/AudioOutputSpeech.cpp b/src/mumble/AudioOutputSpeech.cpp
index bc48ed858..a0f28579d 100644
--- a/src/mumble/AudioOutputSpeech.cpp
+++ b/src/mumble/AudioOutputSpeech.cpp
@@ -47,9 +47,9 @@ AudioOutputSpeech::AudioOutputSpeech(ClientUser *user, unsigned int freq, Messag
// opus's "frame" means different from normal audio term "frame"
// normally, a frame means a bundle of only one sample from each channel,
- // e.g. for a stereo stream, ...[LR]LRLRLR.... where the bracket indicates a frame
+ // e.Global::get(). for a stereo stream, ...[LR]LRLRLR.... where the bracket indicates a frame
// in opus term, a frame means samples that span a period of time, which can be either stereo or mono
- // e.g. ...[LRLR....LRLR].... or ...[MMMM....MMMM].... for mono stream
+ // e.Global::get(). ...[LRLR....LRLR].... or ...[MMMM....MMMM].... for mono stream
// opus supports frames with: 2.5, 5, 10, 20, 40 or 60 ms of audio data.
// sample rate / 100 means 10ms mono audio data per frame.
iFrameSizePerChannel = iFrameSize = iSampleRate / 100; // for mono stream
@@ -59,7 +59,7 @@ AudioOutputSpeech::AudioOutputSpeech(ClientUser *user, unsigned int freq, Messag
// Always pretend Stereo mode is true by default. since opus will convert mono stream to stereo stream.
// https://tools.ietf.org/html/rfc6716#section-2.1.2
bStereo = true;
- oCodec = g.oCodec;
+ oCodec = Global::get().oCodec;
if (oCodec) {
opusState = oCodec->opus_decoder_create(iSampleRate, bStereo ? 2 : 1, nullptr);
oCodec->opus_decoder_ctl(
@@ -123,7 +123,7 @@ AudioOutputSpeech::AudioOutputSpeech(ClientUser *user, unsigned int freq, Messag
ucFlags = SpeechFlags::Invalid;
jbJitter = jitter_buffer_init(iFrameSize);
- int margin = g.s.iJitterBufferSize * iFrameSize;
+ int margin = Global::get().s.iJitterBufferSize * iFrameSize;
jitter_buffer_ctl(jbJitter, JITTER_BUFFER_SET_MARGIN, &margin);
fFadeIn = new float[iFrameSizePerChannel];
@@ -343,9 +343,9 @@ bool AudioOutputSpeech::prepareSampleBuffer(unsigned int frameCount) {
QByteArray qba = qlFrames.takeFirst();
if (umtType == MessageHandler::UDPVoiceCELTAlpha || umtType == MessageHandler::UDPVoiceCELTBeta) {
- int wantversion = (umtType == MessageHandler::UDPVoiceCELTAlpha) ? g.iCodecAlpha : g.iCodecBeta;
- if ((p == &LoopUser::lpLoopy) && (!g.qmCodecs.isEmpty())) {
- QMap< int, CELTCodec * >::const_iterator i = g.qmCodecs.constEnd();
+ int wantversion = (umtType == MessageHandler::UDPVoiceCELTAlpha) ? Global::get().iCodecAlpha : Global::get().iCodecBeta;
+ if ((p == &LoopUser::lpLoopy) && (!Global::get().qmCodecs.isEmpty())) {
+ QMap< int, CELTCodec * >::const_iterator i = Global::get().qmCodecs.constEnd();
--i;
wantversion = i.key();
}
@@ -354,7 +354,7 @@ bool AudioOutputSpeech::prepareSampleBuffer(unsigned int frameCount) {
cdDecoder = nullptr;
}
if (!cCodec) {
- cCodec = g.qmCodecs.value(wantversion);
+ cCodec = Global::get().qmCodecs.value(wantversion);
if (cCodec) {
cdDecoder = cCodec->decoderCreate();
}
diff --git a/src/mumble/AudioStats.cpp b/src/mumble/AudioStats.cpp
index 798759ad5..1d2e30988 100644
--- a/src/mumble/AudioStats.cpp
+++ b/src/mumble/AudioStats.cpp
@@ -62,7 +62,7 @@ void AudioBar::paintEvent(QPaintEvent *) {
int min = iroundf(static_cast< float >(iMin) * scale + 0.5f);
int peak = iroundf(static_cast< float >(iPeak) * scale + 0.5f);
- if (g.s.bHighContrast) {
+ if (Global::get().s.bHighContrast) {
// Draw monochrome representation
QColor fg = QPalette().windowText().color();
@@ -146,7 +146,7 @@ void AudioEchoWidget::paintEvent(QPaintEvent *) {
paint.scale(width(), height());
paint.fillRect(rect(), Qt::black);
- AudioInputPtr ai = g.ai;
+ AudioInputPtr ai = Global::get().ai;
if (!ai || !ai->sesEcho)
return;
@@ -215,7 +215,7 @@ void AudioNoiseWidget::paintEvent(QPaintEvent *) {
paint.fillRect(rect(), pal.color(QPalette::Window));
- AudioInputPtr ai = g.ai;
+ AudioInputPtr ai = Global::get().ai;
if (!ai.get() || !ai->sppPreprocess)
return;
@@ -287,7 +287,7 @@ AudioStats::AudioStats(QWidget *p) : QDialog(p) {
anwNoise->setAccessibleName(tr("Power spectrum of input signal and noise estimate"));
aewEcho->setAccessibleName(tr("Weights of the echo canceller"));
- AudioInputPtr ai = g.ai;
+ AudioInputPtr ai = Global::get().ai;
if (ai && ai->sesEcho) {
qgbEcho->setVisible(true);
@@ -316,7 +316,7 @@ AudioStats::~AudioStats() {
# define FORMAT_TO_TXT(format, arg) txt.sprintf(format, arg)
#endif
void AudioStats::on_Tick_timeout() {
- AudioInputPtr ai = g.ai;
+ AudioInputPtr ai = Global::get().ai;
if (!ai.get() || !ai->sppPreprocess)
return;
@@ -376,16 +376,16 @@ void AudioStats::on_Tick_timeout() {
qlSpeechProb->setFont(f);
}
- if (g.uiDoublePush > 1000000)
+ if (Global::get().uiDoublePush > 1000000)
txt = tr(">1000 ms");
else
- FORMAT_TO_TXT("%04llu ms", g.uiDoublePush / 1000);
+ FORMAT_TO_TXT("%04llu ms", Global::get().uiDoublePush / 1000);
qlDoublePush->setText(txt);
- abSpeech->iBelow = iroundf(g.s.fVADmin * 32767.0f + 0.5f);
- abSpeech->iAbove = iroundf(g.s.fVADmax * 32767.0f + 0.5f);
+ abSpeech->iBelow = iroundf(Global::get().s.fVADmin * 32767.0f + 0.5f);
+ abSpeech->iAbove = iroundf(Global::get().s.fVADmax * 32767.0f + 0.5f);
- if (g.s.vsVAD == Settings::Amplitude) {
+ if (Global::get().s.vsVAD == Settings::Amplitude) {
abSpeech->iValue = iroundf((32767.f / 96.0f) * (96.0f + ai->dPeakCleanMic) + 0.5f);
} else {
abSpeech->iValue = iroundf(ai->fSpeechProb * 32767.0f + 0.5f);
diff --git a/src/mumble/AudioWizard.cpp b/src/mumble/AudioWizard.cpp
index ebbf55d48..885858b0a 100644
--- a/src/mumble/AudioWizard.cpp
+++ b/src/mumble/AudioWizard.cpp
@@ -12,20 +12,17 @@
#include "Utils.h"
#include "GlobalShortcut.h"
#include "GlobalShortcutButtons.h"
+#include "Global.h"
#include <QtGui/QMouseEvent>
#include <QtWidgets/QGraphicsEllipseItem>
#include <cmath>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
AudioWizard::AudioWizard(QWidget *p) : QWizard(p) {
bInit = true;
bLastActive = false;
- g.bInAudioWizard = true;
+ Global::get().bInAudioWizard = true;
ticker = new QTimer(this);
ticker->setObjectName(QLatin1String("Ticker"));
@@ -41,7 +38,7 @@ AudioWizard::AudioWizard(QWidget *p) : QWizard(p) {
qsVAD->setAccessibleName(tr("VAD level"));
// Done
- qcbUsage->setChecked(g.s.bUsage);
+ qcbUsage->setChecked(Global::get().s.bUsage);
// Device
if (AudioInputRegistrar::qmNew) {
@@ -52,7 +49,7 @@ AudioWizard::AudioWizard(QWidget *p) : QWizard(p) {
EchoCancelOptionID echoCancelOptionId = firstUsableEchoCancellation(air, qcbOutput->currentText());
if (echoCancelOptionId != EchoCancelOptionID::DISABLED) {
qcbEcho->setEnabled(true);
- qcbEcho->setChecked(g.s.echoOption != EchoCancelOptionID::DISABLED);
+ qcbEcho->setChecked(Global::get().s.echoOption != EchoCancelOptionID::DISABLED);
}
}
QList< audioDevice > ql = air->getDeviceChoices();
@@ -78,26 +75,26 @@ AudioWizard::AudioWizard(QWidget *p) : QWizard(p) {
qcbOutput->setEnabled(false);
}
- qcbHighContrast->setChecked(g.s.bHighContrast);
- on_qcbHighContrast_clicked(g.s.bHighContrast);
+ qcbHighContrast->setChecked(Global::get().s.bHighContrast);
+ on_qcbHighContrast_clicked(Global::get().s.bHighContrast);
#ifdef Q_OS_WIN
// On windows we can autodetect this
qcbHighContrast->setVisible(false);
#endif
// Settings
- if (g.s.iQuality == 16000 && g.s.iFramesPerPacket == 6)
+ if (Global::get().s.iQuality == 16000 && Global::get().s.iFramesPerPacket == 6)
qrbQualityLow->setChecked(true);
- else if (g.s.iQuality == 40000 && g.s.iFramesPerPacket == 2)
+ else if (Global::get().s.iQuality == 40000 && Global::get().s.iFramesPerPacket == 2)
qrbQualityBalanced->setChecked(true);
- else if (g.s.iQuality == 72000 && g.s.iFramesPerPacket == 1)
+ else if (Global::get().s.iQuality == 72000 && Global::get().s.iFramesPerPacket == 1)
qrbQualityUltra->setChecked(true);
else
qrbQualityCustom->setChecked(true);
quint32 iMessage = Settings::LogNone;
for (int i = Log::firstMsgType; i <= Log::lastMsgType; ++i) {
- iMessage |= (g.s.qmMessages[i] & (Settings::LogSoundfile | Settings::LogTTS));
+ iMessage |= (Global::get().s.qmMessages[i] & (Settings::LogSoundfile | Settings::LogTTS));
}
#ifdef USE_NO_TTS
@@ -107,7 +104,7 @@ AudioWizard::AudioWizard(QWidget *p) : QWizard(p) {
qrbNotificationTTS->setDisabled(true);
qrbNotificationSounds->setChecked(true);
#else
- if (iMessage == Settings::LogTTS && g.s.bTTS)
+ if (iMessage == Settings::LogTTS && Global::get().s.bTTS)
qrbNotificationTTS->setChecked(true);
else if (iMessage == Settings::LogSoundfile)
qrbNotificationSounds->setChecked(true);
@@ -119,8 +116,8 @@ AudioWizard::AudioWizard(QWidget *p) : QWizard(p) {
qrbQualityCustom->setVisible(qrbQualityCustom->isChecked());
qlQualityCustom->setVisible(qrbQualityCustom->isChecked());
- qcbPositional->setChecked(g.s.bPositionalAudio);
- qcbAttenuateOthers->setChecked(g.s.bAttenuateOthers);
+ qcbPositional->setChecked(Global::get().s.bPositionalAudio);
+ qcbAttenuateOthers->setChecked(Global::get().s.bAttenuateOthers);
on_qcbInput_activated(qcbInput->currentIndex());
on_qcbOutput_activated(qcbOutput->currentIndex());
@@ -129,16 +126,16 @@ AudioWizard::AudioWizard(QWidget *p) : QWizard(p) {
abAmplify->qcInside = Qt::green;
abAmplify->qcAbove = Qt::red;
- for (const auto &shortcut : g.s.qlShortcuts) {
- if (shortcut.iIndex == g.mw->gsPushTalk->idx) {
+ for (const auto &shortcut : Global::get().s.qlShortcuts) {
+ if (shortcut.iIndex == Global::get().mw->gsPushTalk->idx) {
pttButtons = shortcut.qlButtons;
break;
}
}
- if (g.s.atTransmit == Settings::PushToTalk)
+ if (Global::get().s.atTransmit == Settings::PushToTalk)
qrPTT->setChecked(true);
- else if (g.s.vsVAD == Settings::Amplitude)
+ else if (Global::get().s.vsVAD == Settings::Amplitude)
qrAmplitude->setChecked(true);
else
qrSNR->setChecked(true);
@@ -147,10 +144,10 @@ AudioWizard::AudioWizard(QWidget *p) : QWizard(p) {
abVAD->qcInside = Qt::yellow;
abVAD->qcAbove = Qt::green;
- qsVAD->setValue(iroundf(g.s.fVADmax * 32767.f + 0.5f));
+ qsVAD->setValue(iroundf(Global::get().s.fVADmax * 32767.f + 0.5f));
// Positional
- qcbHeadphone->setChecked(g.s.bPositionalHeadphone);
+ qcbHeadphone->setChecked(Global::get().s.bPositionalHeadphone);
fAngle = 0.0f;
fX = fY = 0.0f;
@@ -162,10 +159,10 @@ AudioWizard::AudioWizard(QWidget *p) : QWizard(p) {
qgvView->setRenderHints(QPainter::Antialiasing);
// Volume
- qsMaxAmp->setValue(g.s.iMinLoudness);
+ qsMaxAmp->setValue(Global::get().s.iMinLoudness);
// Device Tuning
- qsOutputDelay->setValue(g.s.iOutputDelay);
+ qsOutputDelay->setValue(Global::get().s.iOutputDelay);
on_qsOutputDelay_valueChanged(qsOutputDelay->value());
@@ -173,12 +170,12 @@ AudioWizard::AudioWizard(QWidget *p) : QWizard(p) {
resize(700, 500);
updateTriggerWidgets(qrPTT->isChecked());
- sOldSettings = g.s;
- g.s.lmLoopMode = Settings::Local;
- g.s.dPacketLoss = 0.0;
- g.s.dMaxPacketDelay = 0.0;
- g.s.bMute = true;
- g.s.bDeaf = false;
+ sOldSettings = Global::get().s;
+ Global::get().s.lmLoopMode = Settings::Local;
+ Global::get().s.dPacketLoss = 0.0;
+ Global::get().s.dMaxPacketDelay = 0.0;
+ Global::get().s.bMute = true;
+ Global::get().s.bDeaf = false;
bTransmitChanged = false;
@@ -238,14 +235,14 @@ void AudioWizard::on_qcbInputDevice_activated(int) {
AudioInputRegistrar *air = AudioInputRegistrar::qmNew->value(qcbInput->currentText());
int idx = qcbInputDevice->currentIndex();
if (idx > -1) {
- air->setDeviceChoice(qcbInputDevice->itemData(idx), g.s);
+ air->setDeviceChoice(qcbInputDevice->itemData(idx), Global::get().s);
}
EchoCancelOptionID echoCancelOptionId = firstUsableEchoCancellation(air, qcbOutput->currentText());
qcbEcho->setEnabled(echoCancelOptionId != EchoCancelOptionID::DISABLED);
- g.ai = AudioInputPtr(air->create());
- g.ai->start(QThread::HighestPriority);
+ Global::get().ai = AudioInputPtr(air->create());
+ Global::get().ai->start(QThread::HighestPriority);
}
void AudioWizard::on_qcbOutput_activated(int) {
@@ -278,7 +275,7 @@ void AudioWizard::on_qcbOutputDevice_activated(int) {
AudioOutputRegistrar *aor = AudioOutputRegistrar::qmNew->value(qcbOutput->currentText());
int idx = qcbOutputDevice->currentIndex();
if (idx > -1) {
- aor->setDeviceChoice(qcbOutputDevice->itemData(idx), g.s);
+ aor->setDeviceChoice(qcbOutputDevice->itemData(idx), Global::get().s);
bDelay = aor->usesOutputDelay();
}
@@ -286,18 +283,18 @@ void AudioWizard::on_qcbOutputDevice_activated(int) {
EchoCancelOptionID echoCancelOptionId = firstUsableEchoCancellation(air, qcbOutput->currentText());
qcbEcho->setEnabled(echoCancelOptionId != EchoCancelOptionID::DISABLED);
- g.ao = AudioOutputPtr(aor->create());
- g.ao->start(QThread::HighPriority);
+ Global::get().ao = AudioOutputPtr(aor->create());
+ Global::get().ao->start(QThread::HighPriority);
}
void AudioWizard::on_qsOutputDelay_valueChanged(int v) {
qlOutputDelay->setText(tr("%1 ms").arg(v * 10));
- g.s.iOutputDelay = v;
+ Global::get().s.iOutputDelay = v;
restartAudio();
}
void AudioWizard::on_qsMaxAmp_valueChanged(int v) {
- g.s.iMinLoudness = qMin(v, 30000);
+ Global::get().s.iMinLoudness = qMin(v, 30000);
}
void AudioWizard::showPage(int pageid) {
@@ -306,24 +303,24 @@ void AudioWizard::showPage(int pageid) {
CompletablePage *cp = qobject_cast< CompletablePage * >(currentPage());
- AudioOutputPtr ao = g.ao;
+ AudioOutputPtr ao = Global::get().ao;
if (ao)
ao->wipe();
aosSource = nullptr;
- g.bPosTest = false;
+ Global::get().bPosTest = false;
if (cp == qwpIntro) {
- g.s.bMute = true;
+ Global::get().s.bMute = true;
} else if (cp == qwpDone) {
- g.s.bMute = true;
+ Global::get().s.bMute = true;
} else if (cp == qwpDeviceTuning) {
- g.s.bMute = true;
+ Global::get().s.bMute = true;
playChord();
} else if (cp == qwpPositional) {
fX = fY = 0.0f;
- g.s.bMute = true;
- g.bPosTest = true;
+ Global::get().s.bMute = true;
+ Global::get().bPosTest = true;
if (qgsScene) {
delete qgsScene;
qgiSource = nullptr;
@@ -331,26 +328,26 @@ void AudioWizard::showPage(int pageid) {
}
playChord();
} else {
- g.s.bMute = false;
+ Global::get().s.bMute = false;
}
if ((cp == qwpTrigger) || (cp == qwpSettings)) {
if (!bTransmitChanged)
- g.s.atTransmit = sOldSettings.atTransmit;
+ Global::get().s.atTransmit = sOldSettings.atTransmit;
else if (qrPTT->isChecked())
- g.s.atTransmit = Settings::PushToTalk;
+ Global::get().s.atTransmit = Settings::PushToTalk;
else
- g.s.atTransmit = Settings::VAD;
+ Global::get().s.atTransmit = Settings::VAD;
} else {
- g.s.atTransmit = Settings::Continuous;
+ Global::get().s.atTransmit = Settings::Continuous;
}
}
int AudioWizard::nextId() const {
- AudioOutputPtr ao = g.ao;
+ AudioOutputPtr ao = Global::get().ao;
int nextid = QWizard::nextId();
- if (currentPage() == qwpSettings && !g.s.bPositionalAudio)
+ if (currentPage() == qwpSettings && !Global::get().s.bPositionalAudio)
nextid++;
else if ((currentPage() == qwpDevice) && !bDelay)
nextid++;
@@ -358,7 +355,7 @@ int AudioWizard::nextId() const {
}
void AudioWizard::playChord() {
- AudioOutputPtr ao = g.ao;
+ AudioOutputPtr ao = Global::get().ao;
if (!ao || aosSource || bInit)
return;
aosSource = ao->playSample(QLatin1String(":/wb_male.oga"), true);
@@ -369,8 +366,8 @@ void AudioWizard::restartAudio() {
Audio::stop();
- g.s.qsAudioInput = qcbInput->currentText();
- g.s.qsAudioOutput = qcbOutput->currentText();
+ Global::get().s.qsAudioInput = qcbInput->currentText();
+ Global::get().s.qsAudioOutput = qcbOutput->currentText();
Audio::start();
@@ -385,51 +382,51 @@ void AudioWizard::restartAudio() {
}
void AudioWizard::reject() {
- g.s = sOldSettings;
+ Global::get().s = sOldSettings;
- g.s.lmLoopMode = Settings::None;
+ Global::get().s.lmLoopMode = Settings::None;
restartAudio();
- AudioOutputPtr ao = g.ao;
+ AudioOutputPtr ao = Global::get().ao;
if (ao)
ao->wipe();
aosSource = nullptr;
- g.bInAudioWizard = false;
+ Global::get().bInAudioWizard = false;
QWizard::reject();
}
void AudioWizard::accept() {
if (!bTransmitChanged)
- g.s.atTransmit = sOldSettings.atTransmit;
+ Global::get().s.atTransmit = sOldSettings.atTransmit;
else if (qrPTT->isChecked())
- g.s.atTransmit = Settings::PushToTalk;
+ Global::get().s.atTransmit = Settings::PushToTalk;
else
- g.s.atTransmit = Settings::VAD;
+ Global::get().s.atTransmit = Settings::VAD;
- g.s.bMute = sOldSettings.bMute;
- g.s.bDeaf = sOldSettings.bDeaf;
- g.s.lmLoopMode = Settings::None;
+ Global::get().s.bMute = sOldSettings.bMute;
+ Global::get().s.bDeaf = sOldSettings.bDeaf;
+ Global::get().s.lmLoopMode = Settings::None;
// Switch TTS<->Sounds according to user selection
if (!qrbNotificationCustom->isChecked()) {
Settings::MessageLog mlReplace = qrbNotificationTTS->isChecked() ? Settings::LogSoundfile : Settings::LogTTS;
for (int i = Log::firstMsgType; i <= Log::lastMsgType; ++i) {
- if (g.s.qmMessages[i] & mlReplace)
- g.s.qmMessages[i] ^= Settings::LogSoundfile | Settings::LogTTS;
+ if (Global::get().s.qmMessages[i] & mlReplace)
+ Global::get().s.qmMessages[i] ^= Settings::LogSoundfile | Settings::LogTTS;
}
if (qrbNotificationTTS->isChecked()) {
- g.s.bTTS = true;
- g.mw->qaAudioTTS->setChecked(true);
+ Global::get().s.bTTS = true;
+ Global::get().mw->qaAudioTTS->setChecked(true);
}
}
- g.s.bUsage = qcbUsage->isChecked();
- g.bPosTest = false;
+ Global::get().s.bUsage = qcbUsage->isChecked();
+ Global::get().bPosTest = false;
restartAudio();
- g.bInAudioWizard = false;
+ Global::get().bInAudioWizard = false;
QWizard::accept();
}
@@ -442,8 +439,8 @@ bool AudioWizard::validateCurrentPage() {
}
void AudioWizard::on_Ticker_timeout() {
- AudioInputPtr ai = g.ai;
- AudioOutputPtr ao = g.ao;
+ AudioInputPtr ai = Global::get().ai;
+ AudioOutputPtr ao = Global::get().ao;
if (!ai || !ao)
return;
@@ -461,10 +458,10 @@ void AudioWizard::on_Ticker_timeout() {
abAmplify->iPeak = iMaxPeak;
abAmplify->update();
- abVAD->iBelow = iroundf(g.s.fVADmin * 32767.0f + 0.5f);
- abVAD->iAbove = iroundf(g.s.fVADmax * 32767.0f + 0.5f);
+ abVAD->iBelow = iroundf(Global::get().s.fVADmin * 32767.0f + 0.5f);
+ abVAD->iAbove = iroundf(Global::get().s.fVADmax * 32767.0f + 0.5f);
- if (g.s.vsVAD == Settings::Amplitude) {
+ if (Global::get().s.vsVAD == Settings::Amplitude) {
abVAD->iValue = iroundf((32767.f / 96.0f) * (96.0f + ai->dPeakCleanMic) + 0.5f);
} else {
abVAD->iValue = iroundf(ai->fSpeechProb * 32767.0f + 0.5f);
@@ -573,15 +570,15 @@ void AudioWizard::on_Ticker_timeout() {
void AudioWizard::on_qsVAD_valueChanged(int v) {
if (!bInit) {
- g.s.fVADmax = static_cast< float >(v) / 32767.0f;
- g.s.fVADmin = g.s.fVADmax * 0.9f;
+ Global::get().s.fVADmax = static_cast< float >(v) / 32767.0f;
+ Global::get().s.fVADmin = Global::get().s.fVADmax * 0.9f;
}
}
void AudioWizard::on_qrSNR_clicked(bool on) {
if (on) {
- g.s.vsVAD = Settings::SignalToNoise;
- g.s.atTransmit = Settings::VAD;
+ Global::get().s.vsVAD = Settings::SignalToNoise;
+ Global::get().s.atTransmit = Settings::VAD;
updateTriggerWidgets(false);
bTransmitChanged = true;
}
@@ -589,8 +586,8 @@ void AudioWizard::on_qrSNR_clicked(bool on) {
void AudioWizard::on_qrAmplitude_clicked(bool on) {
if (on) {
- g.s.vsVAD = Settings::Amplitude;
- g.s.atTransmit = Settings::VAD;
+ Global::get().s.vsVAD = Settings::Amplitude;
+ Global::get().s.atTransmit = Settings::VAD;
updateTriggerWidgets(false);
bTransmitChanged = true;
}
@@ -598,7 +595,7 @@ void AudioWizard::on_qrAmplitude_clicked(bool on) {
void AudioWizard::on_qrPTT_clicked(bool on) {
if (on) {
- g.s.atTransmit = Settings::PushToTalk;
+ Global::get().s.atTransmit = Settings::PushToTalk;
updateTriggerWidgets(true);
bTransmitChanged = true;
}
@@ -626,8 +623,8 @@ void AudioWizard::on_qpbPTT_clicked() {
QList< Shortcut > shortcuts;
bool found = false;
- for (auto &shortcut : g.s.qlShortcuts) {
- if (shortcut.iIndex == g.mw->gsPushTalk->idx) {
+ for (auto &shortcut : Global::get().s.qlShortcuts) {
+ if (shortcut.iIndex == Global::get().mw->gsPushTalk->idx) {
if (pttButtons.isEmpty()) {
continue;
}
@@ -643,13 +640,13 @@ void AudioWizard::on_qpbPTT_clicked() {
if (!found && !pttButtons.isEmpty()) {
Shortcut shortcut;
- shortcut.iIndex = g.mw->gsPushTalk->idx;
+ shortcut.iIndex = Global::get().mw->gsPushTalk->idx;
shortcut.qlButtons = pttButtons;
shortcut.bSuppress = false;
shortcuts << shortcut;
}
- g.s.qlShortcuts = shortcuts;
+ Global::get().s.qlShortcuts = shortcuts;
GlobalShortcutEngine::engine->bNeedRemap = true;
GlobalShortcutEngine::engine->needRemap();
}
@@ -657,21 +654,21 @@ void AudioWizard::on_qpbPTT_clicked() {
void AudioWizard::on_qcbEcho_clicked(bool on) {
if (on) {
AudioInputRegistrar *air = AudioInputRegistrar::qmNew->value(qcbInput->currentText());
- g.s.echoOption = firstUsableEchoCancellation(air, qcbOutput->currentText());
+ Global::get().s.echoOption = firstUsableEchoCancellation(air, qcbOutput->currentText());
} else {
- g.s.echoOption = EchoCancelOptionID::DISABLED;
+ Global::get().s.echoOption = EchoCancelOptionID::DISABLED;
}
restartAudio();
}
void AudioWizard::on_qcbHeadphone_clicked(bool on) {
- g.s.bPositionalHeadphone = on;
+ Global::get().s.bPositionalHeadphone = on;
restartAudio();
}
void AudioWizard::on_qcbPositional_clicked(bool on) {
- g.s.bPositionalAudio = on;
- g.s.bTransmitPosition = on;
+ Global::get().s.bPositionalAudio = on;
+ Global::get().s.bTransmitPosition = on;
restartAudio();
}
@@ -698,43 +695,43 @@ void AudioWizard::updateTriggerWidgets(bool ptt) {
}
void AudioWizard::on_qcbAttenuateOthers_clicked(bool checked) {
- g.s.bAttenuateOthers = checked;
+ Global::get().s.bAttenuateOthers = checked;
}
void AudioWizard::on_qcbHighContrast_clicked(bool on) {
- g.s.bHighContrast = on;
+ Global::get().s.bHighContrast = on;
- qliAmpTuningText->setVisible(!g.s.bHighContrast);
- qliAmpTuningTextHC->setVisible(g.s.bHighContrast);
+ qliAmpTuningText->setVisible(!Global::get().s.bHighContrast);
+ qliAmpTuningTextHC->setVisible(Global::get().s.bHighContrast);
- qliVolumeTuningText->setVisible(!g.s.bHighContrast);
- qliVolumeTuningTextHC->setVisible(g.s.bHighContrast);
+ qliVolumeTuningText->setVisible(!Global::get().s.bHighContrast);
+ qliVolumeTuningTextHC->setVisible(Global::get().s.bHighContrast);
- qliVadTuningText->setVisible(!g.s.bHighContrast);
- qliVadTuningTextHC->setVisible(g.s.bHighContrast);
+ qliVadTuningText->setVisible(!Global::get().s.bHighContrast);
+ qliVadTuningTextHC->setVisible(Global::get().s.bHighContrast);
}
void AudioWizard::on_qrbQualityLow_clicked() {
- g.s.iQuality = 16000;
- g.s.iFramesPerPacket = 6;
+ Global::get().s.iQuality = 16000;
+ Global::get().s.iFramesPerPacket = 6;
restartAudio();
}
void AudioWizard::on_qrbQualityBalanced_clicked() {
- g.s.iQuality = 40000;
- g.s.iFramesPerPacket = 2;
+ Global::get().s.iQuality = 40000;
+ Global::get().s.iFramesPerPacket = 2;
restartAudio();
}
void AudioWizard::on_qrbQualityUltra_clicked() {
- g.s.iQuality = 72000;
- g.s.iFramesPerPacket = 1;
+ Global::get().s.iQuality = 72000;
+ Global::get().s.iFramesPerPacket = 1;
restartAudio();
}
void AudioWizard::on_qrbQualityCustom_clicked() {
- g.s.iQuality = sOldSettings.iQuality;
- g.s.iFramesPerPacket = sOldSettings.iFramesPerPacket;
+ Global::get().s.iQuality = sOldSettings.iQuality;
+ Global::get().s.iFramesPerPacket = sOldSettings.iFramesPerPacket;
restartAudio();
}
diff --git a/src/mumble/BanEditor.cpp b/src/mumble/BanEditor.cpp
index 98bbe1e74..5e3f7cc42 100644
--- a/src/mumble/BanEditor.cpp
+++ b/src/mumble/BanEditor.cpp
@@ -8,9 +8,6 @@
#include "Ban.h"
#include "Channel.h"
#include "ServerHandler.h"
-
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
#include "Global.h"
BanEditor::BanEditor(const MumbleProto::BanList &msg, QWidget *p) : QDialog(p), maskDefaultValue(32) {
@@ -63,7 +60,7 @@ void BanEditor::accept() {
be->set_duration(b.iDuration);
}
- g.sh->sendMessage(msg);
+ Global::get().sh->sendMessage(msg);
QDialog::accept();
}
diff --git a/src/mumble/Cert.cpp b/src/mumble/Cert.cpp
index 76c96b0b9..929c2fc22 100644
--- a/src/mumble/Cert.cpp
+++ b/src/mumble/Cert.cpp
@@ -15,6 +15,7 @@
#include "SelfSignedCertificate.h"
#include "Utils.h"
+#include "Global.h"
#include <QtCore/QUrl>
#include <QtGui/QDesktopServices>
@@ -25,10 +26,6 @@
#include <openssl/pkcs12.h>
#include <openssl/x509.h>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
#define SSL_STRING(x) QString::fromLatin1(x).toUtf8().data()
CertView::CertView(QWidget *p) : QGroupBox(p) {
@@ -179,7 +176,7 @@ int CertWizard::nextId() const {
void CertWizard::initializePage(int id) {
if (id == 0) {
- kpCurrent = kpNew = g.s.kpCertificate;
+ kpCurrent = kpNew = Global::get().s.kpCertificate;
if (validateCert(kpCurrent)) {
qrbQuick->setEnabled(false);
@@ -278,7 +275,7 @@ bool CertWizard::validateCurrentPage() {
kpNew = imp;
}
if (currentPage() == qwpFinish) {
- g.s.kpCertificate = kpNew;
+ Global::get().s.kpCertificate = kpNew;
}
return QWizard::validateCurrentPage();
}
diff --git a/src/mumble/ClientUser.cpp b/src/mumble/ClientUser.cpp
index 724603335..a8cad0c5d 100644
--- a/src/mumble/ClientUser.cpp
+++ b/src/mumble/ClientUser.cpp
@@ -97,7 +97,7 @@ void ClientUser::remove(unsigned int uiSession) {
}
if (p) {
- AudioOutputPtr ao = g.ao;
+ AudioOutputPtr ao = Global::get().ao;
if (ao) {
// It is safe to call this function and to give the ClientUser pointer
// to it even though we don't hold the lock anymore as it will only take
@@ -253,7 +253,7 @@ void ClientUser::setLocalNickname(const QString &nickname) {
}
bool ClientUser::lessThanOverlay(const ClientUser *first, const ClientUser *second) {
- if (g.s.os.osSort == OverlaySettings::LastStateChange) {
+ if (Global::get().s.os.osSort == OverlaySettings::LastStateChange) {
// Talkers above non-talkers
if (first->tsState != Settings::Passive && second->tsState == Settings::Passive)
return true;
@@ -287,7 +287,7 @@ bool ClientUser::lessThanOverlay(const ClientUser *first, const ClientUser *seco
// When sorting for the overlay always place the local users
// channel above the others
- ClientUser *self = c_qmUsers.value(g.uiSession);
+ ClientUser *self = c_qmUsers.value(Global::get().uiSession);
if (self) {
if (self->cChannel == first->cChannel)
return true;
@@ -311,7 +311,7 @@ bool ClientUser::isActive() {
if (!tLastTalkStateChange.isStarted())
return false;
- return tLastTalkStateChange.elapsed() < g.s.os.uiActiveTime * 1000000U;
+ return tLastTalkStateChange.elapsed() < Global::get().s.os.uiActiveTime * 1000000U;
}
/* From Channel.h
diff --git a/src/mumble/ConfigDialog.cpp b/src/mumble/ConfigDialog.cpp
index 5e7fa5ade..c4c342aef 100644
--- a/src/mumble/ConfigDialog.cpp
+++ b/src/mumble/ConfigDialog.cpp
@@ -32,7 +32,7 @@ ConfigDialog::ConfigDialog(QWidget *p) : QDialog(p) {
}
- s = g.s;
+ s = Global::get().s;
unsigned int idx = 0;
ConfigWidgetNew cwn;
@@ -79,11 +79,11 @@ ConfigDialog::ConfigDialog(QWidget *p) : QDialog(p) {
restoreAllButton->setToolTip(tr("Restore all defaults"));
restoreAllButton->setWhatsThis(tr("This button will restore the defaults for all settings."));
- if (!g.s.qbaConfigGeometry.isEmpty()) {
+ if (!Global::get().s.qbaConfigGeometry.isEmpty()) {
#ifdef USE_OVERLAY
- if (!g.ocIntercept)
+ if (!Global::get().ocIntercept)
#endif
- restoreGeometry(g.s.qbaConfigGeometry);
+ restoreGeometry(Global::get().s.qbaConfigGeometry);
}
}
@@ -117,7 +117,7 @@ void ConfigDialog::addPage(ConfigWidget *cw, unsigned int idx) {
qswPages->addWidget(cw);
}
qmWidgets.insert(idx, cw);
- cw->load(g.s);
+ cw->load(Global::get().s);
}
ConfigDialog::~ConfigDialog() {
@@ -152,7 +152,7 @@ void ConfigDialog::on_pageButtonBox_clicked(QAbstractButton *b) {
break;
}
case QDialogButtonBox::Reset: {
- conf->load(g.s);
+ conf->load(Global::get().s);
break;
}
// standardButton returns NoButton for any custom buttons. The only custom button
@@ -246,16 +246,16 @@ void ConfigDialog::apply() {
foreach (ConfigWidget *cw, qmWidgets)
cw->save();
- g.s = s;
+ Global::get().s = s;
foreach (ConfigWidget *cw, qmWidgets)
cw->accept();
- if (!g.s.bAttenuateOthersOnTalk)
- g.bAttenuateOthers = false;
+ if (!Global::get().s.bAttenuateOthersOnTalk)
+ Global::get().bAttenuateOthers = false;
// They might have changed their keys.
- g.iPushToTalk = 0;
+ Global::get().iPushToTalk = 0;
Audio::start();
@@ -266,9 +266,9 @@ void ConfigDialog::accept() {
apply();
#ifdef USE_OVERLAY
- if (!g.ocIntercept)
+ if (!Global::get().ocIntercept)
#endif
- g.s.qbaConfigGeometry = saveGeometry();
+ Global::get().s.qbaConfigGeometry = saveGeometry();
QDialog::accept();
}
diff --git a/src/mumble/ConnectDialog.cpp b/src/mumble/ConnectDialog.cpp
index 2f3968a68..63ef64bf6 100644
--- a/src/mumble/ConnectDialog.cpp
+++ b/src/mumble/ConnectDialog.cpp
@@ -15,6 +15,7 @@
#include "ServerResolver.h"
#include "Utils.h"
#include "WebFetch.h"
+#include "Global.h"
#include <QtCore/QMimeData>
#include <QtCore/QUrlQuery>
@@ -40,10 +41,6 @@
# include <QRandomGenerator>
#endif
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
QMap< QString, QIcon > ServerItem::qmIcons;
QList< PublicInfo > ConnectDialog::qlPublicServers;
QString ConnectDialog::qsUserCountry, ConnectDialog::qsUserCountryCode, ConnectDialog::qsUserContinentCode;
@@ -109,7 +106,7 @@ ServerView::ServerView(QWidget *p) : QTreeWidget(p) {
siLAN = nullptr;
#endif
- if (!g.s.bDisablePublicList) {
+ if (!Global::get().s.bDisablePublicList) {
siPublic = new ServerItem(tr("Public Internet"), ServerItem::PublicType);
siPublic->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);
addTopLevelItem(siPublic);
@@ -407,19 +404,19 @@ ServerItem *ServerItem::fromUrl(QUrl url, QWidget *p) {
QUrlQuery query(url);
if (url.userName().isEmpty()) {
- if (g.s.qsUsername.isEmpty()) {
+ if (Global::get().s.qsUsername.isEmpty()) {
bool ok;
QString defUserName =
QInputDialog::getText(p, ConnectDialog::tr("Adding host %1").arg(url.host()),
- ConnectDialog::tr("Enter username"), QLineEdit::Normal, g.s.qsUsername, &ok)
+ ConnectDialog::tr("Enter username"), QLineEdit::Normal, Global::get().s.qsUsername, &ok)
.trimmed();
if (!ok)
return nullptr;
if (defUserName.isEmpty())
return nullptr;
- g.s.qsUsername = defUserName;
+ Global::get().s.qsUsername = defUserName;
}
- url.setUserName(g.s.qsUsername);
+ url.setUserName(Global::get().s.qsUsername);
}
ServerItem *si =
@@ -759,11 +756,11 @@ ConnectDialogEdit::ConnectDialogEdit(QWidget *parent) : QDialog(parent) {
if (!updateFromClipboard()) {
// If connected to a server assume the user wants to add it
- if (g.sh && g.sh->isRunning()) {
+ if (Global::get().sh && Global::get().sh->isRunning()) {
QString host, name, user, pw;
unsigned short port = DEFAULT_MUMBLE_PORT;
- g.sh->getConnectionInfo(host, port, user, pw);
+ Global::get().sh->getConnectionInfo(host, port, user, pw);
Channel *c = Channel::get(0);
if (c && c->qsName != QLatin1String("Root")) {
name = c->qsName;
@@ -776,7 +773,7 @@ ConnectDialogEdit::ConnectDialogEdit(QWidget *parent) : QDialog(parent) {
m_si = new ServerItem(name, host, port, user, pw);
}
}
- qleUsername->setText(g.s.qsUsername);
+ qleUsername->setText(Global::get().s.qsUsername);
}
void ConnectDialogEdit::init() {
@@ -940,10 +937,10 @@ ConnectDialog::ConnectDialog(QWidget *p, bool autoconnect) : QDialog(p), bAutoCo
siAutoConnect = nullptr;
- bAllowPing = g.s.ptProxyType == Settings::NoProxy;
- bAllowHostLookup = g.s.ptProxyType == Settings::NoProxy;
- bAllowZeroconf = g.s.ptProxyType == Settings::NoProxy;
- bAllowFilters = g.s.ptProxyType == Settings::NoProxy;
+ bAllowPing = Global::get().s.ptProxyType == Settings::NoProxy;
+ bAllowHostLookup = Global::get().s.ptProxyType == Settings::NoProxy;
+ bAllowZeroconf = Global::get().s.ptProxyType == Settings::NoProxy;
+ bAllowFilters = Global::get().s.ptProxyType == Settings::NoProxy;
if (tPublicServers.elapsed() >= 60 * 24 * 1000000ULL) {
qlPublicServers.clear();
@@ -966,12 +963,12 @@ ConnectDialog::ConnectDialog(QWidget *p, bool autoconnect) : QDialog(p), bAutoCo
connect(qpbEdit, SIGNAL(clicked()), qaFavoriteEdit, SIGNAL(triggered()));
qdbbButtonBox->addButton(qpbEdit, QDialogButtonBox::ActionRole);
- qpbAdd->setHidden(g.s.disableConnectDialogEditing);
- qpbEdit->setHidden(g.s.disableConnectDialogEditing);
+ qpbAdd->setHidden(Global::get().s.disableConnectDialogEditing);
+ qpbEdit->setHidden(Global::get().s.disableConnectDialogEditing);
qtwServers->setItemDelegate(new ServerViewDelegate());
- if (!g.s.bDisablePublicList) {
+ if (!Global::get().s.bDisablePublicList) {
const QIcon qiFlag = ServerItem::loadIcon(QLatin1String("skin:categories/applications-internet.svg"));
// Add continents and 'Unknown' to the location combobox
qcbSearchLocation->addItem(qiFlag, tr("All"), QLatin1String("all"));
@@ -1005,7 +1002,7 @@ ConnectDialog::ConnectDialog(QWidget *p, bool autoconnect) : QDialog(p), bAutoCo
SLOT(OnSortChanged(int, Qt::SortOrder)));
if (bAllowFilters) {
- switch (g.s.ssFilter) {
+ switch (Global::get().s.ssFilter) {
case Settings::ShowPopulated:
qcbFilter->setCurrentText(tr("Show Populated"));
break;
@@ -1023,7 +1020,7 @@ ConnectDialog::ConnectDialog(QWidget *p, bool autoconnect) : QDialog(p), bAutoCo
qmPopup = new QMenu(this);
QList< QTreeWidgetItem * > ql;
- QList< FavoriteServer > favorites = g.db->getFavorites();
+ QList< FavoriteServer > favorites = Global::get().db->getFavorites();
foreach (const FavoriteServer &fs, favorites) {
ServerItem *si = new ServerItem(fs);
@@ -1032,13 +1029,13 @@ ConnectDialog::ConnectDialog(QWidget *p, bool autoconnect) : QDialog(p), bAutoCo
qtwServers->siFavorite->addServerItem(si);
}
#ifdef USE_ZEROCONF
- if (bAllowZeroconf && g.zeroconf && g.zeroconf->isOk()) {
- connect(g.zeroconf, &Zeroconf::recordsChanged, this, &ConnectDialog::onUpdateLanList);
- connect(g.zeroconf, &Zeroconf::recordResolved, this, &ConnectDialog::onResolved);
- connect(g.zeroconf, &Zeroconf::resolveError, this, &ConnectDialog::onLanResolveError);
- onUpdateLanList(g.zeroconf->currentRecords());
+ if (bAllowZeroconf && Global::get().zeroconf && Global::get().zeroconf->isOk()) {
+ connect(Global::get().zeroconf, &Zeroconf::recordsChanged, this, &ConnectDialog::onUpdateLanList);
+ connect(Global::get().zeroconf, &Zeroconf::recordResolved, this, &ConnectDialog::onResolved);
+ connect(Global::get().zeroconf, &Zeroconf::resolveError, this, &ConnectDialog::onLanResolveError);
+ onUpdateLanList(Global::get().zeroconf->currentRecords());
- g.zeroconf->startBrowser(QLatin1String("_mumble._tcp"));
+ Global::get().zeroconf->startBrowser(QLatin1String("_mumble._tcp"));
}
#endif
qtPingTick = new QTimer(this);
@@ -1065,19 +1062,19 @@ ConnectDialog::ConnectDialog(QWidget *p, bool autoconnect) : QDialog(p), bAutoCo
qtwServers->setCurrentItem(nullptr);
bLastFound = false;
- qmPingCache = g.db->getPingCache();
+ qmPingCache = Global::get().db->getPingCache();
- if (!g.s.qbaConnectDialogGeometry.isEmpty())
- restoreGeometry(g.s.qbaConnectDialogGeometry);
- if (!g.s.qbaConnectDialogHeader.isEmpty())
- qtwServers->header()->restoreState(g.s.qbaConnectDialogHeader);
+ if (!Global::get().s.qbaConnectDialogGeometry.isEmpty())
+ restoreGeometry(Global::get().s.qbaConnectDialogGeometry);
+ if (!Global::get().s.qbaConnectDialogHeader.isEmpty())
+ qtwServers->header()->restoreState(Global::get().s.qbaConnectDialogHeader);
}
ConnectDialog::~ConnectDialog() {
#ifdef USE_ZEROCONF
- if (bAllowZeroconf && g.zeroconf && g.zeroconf->isOk()) {
- g.zeroconf->stopBrowser();
- g.zeroconf->cleanupResolvers();
+ if (bAllowZeroconf && Global::get().zeroconf && Global::get().zeroconf->isOk()) {
+ Global::get().zeroconf->stopBrowser();
+ Global::get().zeroconf->cleanupResolvers();
}
#endif
ServerItem::qmIcons.clear();
@@ -1093,11 +1090,11 @@ ConnectDialog::~ConnectDialog() {
continue;
ql << si->toFavoriteServer();
}
- g.db->setFavorites(ql);
- g.db->setPingCache(qmPingCache);
+ Global::get().db->setFavorites(ql);
+ Global::get().db->setPingCache(qmPingCache);
- g.s.qbaConnectDialogHeader = qtwServers->header()->saveState();
- g.s.qbaConnectDialogGeometry = saveGeometry();
+ Global::get().s.qbaConnectDialogHeader = qtwServers->header()->saveState();
+ Global::get().s.qbaConnectDialogGeometry = saveGeometry();
}
void ConnectDialog::accept() {
@@ -1114,16 +1111,16 @@ void ConnectDialog::accept() {
if (si->qsUsername.isEmpty()) {
bool ok;
QString defUserName = QInputDialog::getText(this, tr("Connecting to %1").arg(si->qsName), tr("Enter username"),
- QLineEdit::Normal, g.s.qsUsername, &ok)
+ QLineEdit::Normal, Global::get().s.qsUsername, &ok)
.trimmed();
if (!ok)
return;
- g.s.qsUsername = si->qsUsername = defUserName;
+ Global::get().s.qsUsername = si->qsUsername = defUserName;
}
qsUsername = si->qsUsername;
- g.s.qsLastServer = si->qsName;
+ Global::get().s.qsLastServer = si->qsName;
QDialog::accept();
}
@@ -1275,7 +1272,7 @@ void ConnectDialog::on_qtwServers_customContextMenuRequested(const QPoint &mpos)
}
if (si) {
- if (!g.s.disableConnectDialogEditing) {
+ if (!Global::get().s.disableConnectDialogEditing) {
if (si->itType == ServerItem::FavoriteType) {
qmPopup->addAction(qaFavoriteEdit);
qmPopup->addAction(qaFavoriteRemove);
@@ -1317,7 +1314,7 @@ void ConnectDialog::on_qtwServers_currentItemChanged(QTreeWidgetItem *item, QTre
void ConnectDialog::on_qtwServers_itemExpanded(QTreeWidgetItem *item) {
if (qtwServers->siPublic && item == qtwServers->siPublic) {
- if (!g.s.bPingServersDialogViewed) {
+ if (!Global::get().s.bPingServersDialogViewed) {
// Ask the user for consent to ping the servers. If the user does
// not give consent, disable the public server list and return.
int result = QMessageBox::question(
@@ -1327,9 +1324,9 @@ void ConnectDialog::on_qtwServers_itemExpanded(QTreeWidgetItem *item) {
"<p>Do you consent to the transmission of your IP address? If you answer no, the public server "
"list will be deactivated. However, you can reactivate it at any time in the network settings.</p>"),
QMessageBox::Yes | QMessageBox::No);
- g.s.bPingServersDialogViewed = true;
+ Global::get().s.bPingServersDialogViewed = true;
if (result == QMessageBox::No) {
- g.s.bDisablePublicList = true;
+ Global::get().s.bDisablePublicList = true;
item->setExpanded(false);
item->setHidden(true);
return;
@@ -1405,7 +1402,7 @@ void ConnectDialog::onUpdateLanList(const QList< BonjourRecord > &list) {
if (!found) {
ServerItem *si = new ServerItem(record);
qlItems << si;
- g.zeroconf->startResolver(record);
+ Global::get().zeroconf->startResolver(record);
startDns(si);
qtwServers->siLAN->addServerItem(si);
}
@@ -1466,13 +1463,13 @@ void ConnectDialog::fillList() {
}
void ConnectDialog::timeTick() {
- if (!bLastFound && !g.s.qsLastServer.isEmpty()) {
+ if (!bLastFound && !Global::get().s.qsLastServer.isEmpty()) {
QList< QTreeWidgetItem * > items =
- qtwServers->findItems(g.s.qsLastServer, Qt::MatchExactly | Qt::MatchRecursive);
+ qtwServers->findItems(Global::get().s.qsLastServer, Qt::MatchExactly | Qt::MatchRecursive);
if (!items.isEmpty()) {
bLastFound = true;
qtwServers->setCurrentItem(items.at(0));
- if (g.s.bAutoConnect && bAutoConnect) {
+ if (Global::get().s.bAutoConnect && bAutoConnect) {
siAutoConnect = static_cast< ServerItem * >(items.at(0));
if (!siAutoConnect->qlAddresses.isEmpty()) {
accept();
@@ -1562,7 +1559,7 @@ void ConnectDialog::timeTick() {
}
void ConnectDialog::filterPublicServerList() const {
- if (!g.s.bDisablePublicList) {
+ if (!Global::get().s.bDisablePublicList) {
foreach (ServerItem *const si, qtwServers->siPublic->qlChildren) { filterServer(si); }
}
}
@@ -1578,10 +1575,10 @@ void ConnectDialog::filterServer(ServerItem *const si) const {
return;
}
}
- if (g.s.ssFilter == Settings::ShowReachable && si->dPing == 0.0) {
+ if (Global::get().s.ssFilter == Settings::ShowReachable && si->dPing == 0.0) {
si->setHidden(true);
return;
- } else if (g.s.ssFilter == Settings::ShowPopulated && si->uiUsers == 0) {
+ } else if (Global::get().s.ssFilter == Settings::ShowPopulated && si->uiUsers == 0) {
si->setHidden(true);
return;
}
@@ -1637,7 +1634,7 @@ void ConnectDialog::startDns(ServerItem *si) {
#ifdef USE_ZEROCONF
if (bAllowZeroconf && si->qsHostname.isEmpty() && !si->zeroconfRecord.serviceName.isEmpty()) {
if (!qlBonjourActive.contains(si->zeroconfRecord)) {
- g.zeroconf->startResolver(si->zeroconfRecord);
+ Global::get().zeroconf->startResolver(si->zeroconfRecord);
qlBonjourActive.append(si->zeroconfRecord);
}
return;
@@ -1853,11 +1850,11 @@ void ConnectDialog::on_qcbSearchLocation_currentIndexChanged(int searchLocationI
void ConnectDialog::on_qcbFilter_currentIndexChanged(int filterIndex) {
const QString filter = qcbFilter->itemText(filterIndex);
if (filter == tr("Show All")) {
- g.s.ssFilter = Settings::ShowAll;
+ Global::get().s.ssFilter = Settings::ShowAll;
} else if (filter == tr("Show Reachable")) {
- g.s.ssFilter = Settings::ShowReachable;
+ Global::get().s.ssFilter = Settings::ShowReachable;
} else if (filter == tr("Show Populated")) {
- g.s.ssFilter = Settings::ShowPopulated;
+ Global::get().s.ssFilter = Settings::ShowPopulated;
}
filterPublicServerList();
diff --git a/src/mumble/CoreAudio.mm b/src/mumble/CoreAudio.mm
index 09331c128..6eece9a99 100644
--- a/src/mumble/CoreAudio.mm
+++ b/src/mumble/CoreAudio.mm
@@ -7,15 +7,12 @@
#include <IOKit/audio/IOAudioTypes.h>
#include <CoreAudio/AudioHardware.h>
#include "MainWindow.h"
+#include "Global.h"
#include <exception>
#include <sstream>
#include "CoreAudio.h"
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
// Ignore deprecation warnings for the whole file, for now.
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
@@ -420,7 +417,7 @@ void CoreAudioInit::destroy() {
}
const QList< audioDevice > CoreAudioSystem::getDeviceChoices(bool input) {
- bool doEcho = (g.s.echoOption == EchoCancelOptionID::APPLE_AEC);
+ bool doEcho = (Global::get().s.echoOption == EchoCancelOptionID::APPLE_AEC);
QHash< QString, QString > qhDevices = CoreAudioSystem::getDevices(input, doEcho);
QList< audioDevice > qlReturn;
QStringList qlDevices;
@@ -428,7 +425,7 @@ const QList< audioDevice > CoreAudioSystem::getDeviceChoices(bool input) {
qhDevices.insert(QString(), QObject::tr("Default Device"));
qlDevices = qhDevices.keys();
- const QString &qsDev = input ? g.s.qsCoreAudioInput : g.s.qsCoreAudioOutput;
+ const QString &qsDev = input ? Global::get().s.qsCoreAudioInput : Global::get().s.qsCoreAudioOutput;
if (qlDevices.contains(qsDev)) {
qlDevices.removeAll(qsDev);
qlDevices.prepend(qsDev);
@@ -529,7 +526,7 @@ bool CoreAudioInputRegistrar::isMicrophoneAccessDeniedByOS() {
case AVAuthorizationStatusDenied: {
// The user has previously denied access.
qWarning("CoreAudioInput: Microphone access has been previously denied by user.");
- g.mw->msgBox(QObject::tr("Access to the microphone was denied. Please allow Mumble to use the microphone "
+ Global::get().mw->msgBox(QObject::tr("Access to the microphone was denied. Please allow Mumble to use the microphone "
"by changing the settings in System Preferences -> Security & Privacy -> Privacy -> "
"Microphone."));
return true;
@@ -537,7 +534,7 @@ bool CoreAudioInputRegistrar::isMicrophoneAccessDeniedByOS() {
case AVAuthorizationStatusRestricted: {
// The user can't grant access due to restrictions.
qWarning("CoreAudioInput: Microphone access denied due to system restrictions.");
- g.mw->msgBox(QObject::tr("Access to the microphone was denied due to system restrictions. You will not be able"
+ Global::get().mw->msgBox(QObject::tr("Access to the microphone was denied due to system restrictions. You will not be able"
"to use the microphone in this session."));
return true;
}
@@ -736,7 +733,7 @@ void CoreAudioInput::run() {
AudioStreamBasicDescription fmt;
inputDevId = 0;
echoOutputDevId = 0;
- bool doEcho = (g.s.echoOption == EchoCancelOptionID::APPLE_AEC);
+ bool doEcho = (Global::get().s.echoOption == EchoCancelOptionID::APPLE_AEC);
auHAL = nullptr;
auVoip = nullptr;
@@ -744,16 +741,16 @@ void CoreAudioInput::run() {
memset(&buflist, 0, sizeof(AudioBufferList));
try {
- if (!g.s.qsCoreAudioInput.isEmpty()) {
- qWarning("CoreAudioInput: Set device to '%s'.", qPrintable(g.s.qsCoreAudioInput));
- inputDevId = core_audio_utils::GetDeviceID(g.s.qsCoreAudioInput, AUDirection::INPUT);
+ if (!Global::get().s.qsCoreAudioInput.isEmpty()) {
+ qWarning("CoreAudioInput: Set device to '%s'.", qPrintable(Global::get().s.qsCoreAudioInput));
+ inputDevId = core_audio_utils::GetDeviceID(Global::get().s.qsCoreAudioInput, AUDirection::INPUT);
} else {
qWarning("CoreAudioInput: Set device to 'Default Device'.");
inputDevId = core_audio_utils::GetDefaultDeviceID(AUDirection::INPUT);
}
if (doEcho) {
- echoOutputDevId = core_audio_utils::GetDeviceID(g.s.qsCoreAudioOutput, AUDirection::OUTPUT);
+ echoOutputDevId = core_audio_utils::GetDeviceID(Global::get().s.qsCoreAudioOutput, AUDirection::OUTPUT);
if (!openAUVoip(fmt)) { return; };
} else {
if (!openAUHAL(fmt)) { return; };
@@ -932,10 +929,10 @@ void CoreAudioOutput::run() {
kAudioObjectPropertyElementMaster };
try {
- if (!g.s.qsCoreAudioOutput.isEmpty()) {
- qWarning("CoreAudioOutput: Set device to '%s'.", qPrintable(g.s.qsCoreAudioOutput));
+ if (!Global::get().s.qsCoreAudioOutput.isEmpty()) {
+ qWarning("CoreAudioOutput: Set device to '%s'.", qPrintable(Global::get().s.qsCoreAudioOutput));
- devId = core_audio_utils::GetDeviceID(g.s.qsCoreAudioOutput, AUDirection::OUTPUT);
+ devId = core_audio_utils::GetDeviceID(Global::get().s.qsCoreAudioOutput, AUDirection::OUTPUT);
} else {
qWarning("CoreAudioOutput: Set device to 'Default Device'.");
diff --git a/src/mumble/CrashReporter.cpp b/src/mumble/CrashReporter.cpp
index 3b62b8891..5ab600c49 100644
--- a/src/mumble/CrashReporter.cpp
+++ b/src/mumble/CrashReporter.cpp
@@ -32,7 +32,7 @@ CrashReporter::CrashReporter(QWidget *p) : QDialog(p) {
QHBoxLayout *hbl = new QHBoxLayout();
- qleEmail = new QLineEdit(g.qs->value(QLatin1String("crashemail")).toString());
+ qleEmail = new QLineEdit(Global::get().qs->value(QLatin1String("crashemail")).toString());
l = new QLabel(tr("Email address (optional)"));
l->setBuddy(qleEmail);
@@ -66,7 +66,7 @@ CrashReporter::CrashReporter(QWidget *p) : QDialog(p) {
}
CrashReporter::~CrashReporter() {
- g.qs->setValue(QLatin1String("crashemail"), qleEmail->text());
+ Global::get().qs->setValue(QLatin1String("crashemail"), qleEmail->text());
delete qnrReply;
}
@@ -98,7 +98,7 @@ void CrashReporter::uploadProgress(qint64 sent, qint64 total) {
void CrashReporter::run() {
QByteArray qbaDumpContents;
- QFile qfCrashDump(g.qdBasePath.filePath(QLatin1String("mumble.dmp")));
+ QFile qfCrashDump(Global::get().qdBasePath.filePath(QLatin1String("mumble.dmp")));
if (!qfCrashDump.exists())
return;
@@ -224,7 +224,7 @@ void CrashReporter::run() {
QString::fromLatin1("multipart/form-data; boundary=%1").arg(boundary));
req.setHeader(QNetworkRequest::ContentLengthHeader, QString::number(post.size()));
Network::prepareRequest(req);
- qnrReply = g.nam->post(req, post);
+ qnrReply = Global::get().nam->post(req, post);
connect(qnrReply, SIGNAL(finished()), this, SLOT(uploadFinished()));
connect(qnrReply, SIGNAL(uploadProgress(qint64, qint64)), this, SLOT(uploadProgress(qint64, qint64)));
diff --git a/src/mumble/CustomElements.cpp b/src/mumble/CustomElements.cpp
index adea56ae4..9e51ae37e 100644
--- a/src/mumble/CustomElements.cpp
+++ b/src/mumble/CustomElements.cpp
@@ -9,6 +9,7 @@
#include "Log.h"
#include "MainWindow.h"
#include "Utils.h"
+#include "Global.h"
#include <QMimeData>
#include <QtCore/QTimer>
@@ -18,10 +19,6 @@
#include <QtGui/QKeyEvent>
#include <QtWidgets/QScrollBar>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
LogTextBrowser::LogTextBrowser(QWidget *p) : QTextBrowser(p) {
}
@@ -181,14 +178,14 @@ void ChatbarTextEdit::insertFromMimeData(const QMimeData *source) {
bool ChatbarTextEdit::sendImagesFromMimeData(const QMimeData *source) {
if ((source->hasImage() || source->hasUrls())) {
- if (g.bAllowHTML) {
+ if (Global::get().bAllowHTML) {
if (source->hasImage()) {
// Process the image pasted onto the chatbar.
QImage image = qvariant_cast<QImage>(source->imageData());
if (emitPastedImage(image)) {
return true;
} else {
- g.l->log(Log::Information, tr("Unable to send image: too large."));
+ Global::get().l->log(Log::Information, tr("Unable to send image: too large."));
return false;
}
@@ -206,21 +203,21 @@ bool ChatbarTextEdit::sendImagesFromMimeData(const QMimeData *source) {
if (emitPastedImage(image)) {
++count;
} else {
- g.l->log(Log::Information, tr("Unable to send image %1: too large.").arg(path));
+ Global::get().l->log(Log::Information, tr("Unable to send image %1: too large.").arg(path));
}
}
return (count > 0);
}
} else {
- g.l->log(Log::Information, tr("This server does not allow sending images."));
+ Global::get().l->log(Log::Information, tr("This server does not allow sending images."));
}
}
return false;
}
bool ChatbarTextEdit::emitPastedImage(QImage image) {
- QString processedImage = Log::imageToImg(image, g.uiImageLength);
+ QString processedImage = Log::imageToImg(image, Global::get().uiImageLength);
if (processedImage.length() > 0) {
QString imgHtml = QLatin1String("<br />") + processedImage;
emit pastedImage(imgHtml);
diff --git a/src/mumble/DBus.cpp b/src/mumble/DBus.cpp
index 5220de498..001c4242a 100644
--- a/src/mumble/DBus.cpp
+++ b/src/mumble/DBus.cpp
@@ -9,15 +9,12 @@
#include "ClientUser.h"
#include "MainWindow.h"
#include "ServerHandler.h"
+#include "Global.h"
#include <QtCore/QUrlQuery>
#include <QtDBus/QDBusConnection>
#include <QtDBus/QDBusMessage>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
MumbleDBus::MumbleDBus(QObject *mw) : QDBusAbstractAdaptor(mw) {
}
@@ -29,12 +26,12 @@ void MumbleDBus::openUrl(const QString &url, const QDBusMessage &msg) {
QDBusConnection::sessionBus().send(
msg.createErrorReply(QLatin1String("net.sourceforge.mumble.Error.url"), QLatin1String("Invalid URL")));
} else {
- g.mw->openUrl(u);
+ Global::get().mw->openUrl(u);
}
}
void MumbleDBus::getCurrentUrl(const QDBusMessage &msg) {
- if (!g.sh || !g.sh->isRunning() || !g.uiSession) {
+ if (!Global::get().sh || !Global::get().sh->isRunning() || !Global::get().uiSession) {
QDBusConnection::sessionBus().send(msg.createErrorReply(
QLatin1String("net.sourceforge.mumble.Error.connection"), QLatin1String("Not connected")));
return;
@@ -43,7 +40,7 @@ void MumbleDBus::getCurrentUrl(const QDBusMessage &msg) {
unsigned short port;
QUrl u;
- g.sh->getConnectionInfo(host, port, user, pw);
+ Global::get().sh->getConnectionInfo(host, port, user, pw);
u.setScheme(QLatin1String("mumble"));
u.setHost(host);
u.setPort(port);
@@ -54,7 +51,7 @@ void MumbleDBus::getCurrentUrl(const QDBusMessage &msg) {
u.setQuery(query);
QStringList path;
- Channel *c = ClientUser::get(g.uiSession)->cChannel;
+ Channel *c = ClientUser::get(Global::get().uiSession)->cChannel;
while (c->cParent) {
path.prepend(c->qsName);
c = c->cParent;
@@ -70,7 +67,7 @@ void MumbleDBus::getCurrentUrl(const QDBusMessage &msg) {
}
void MumbleDBus::getTalkingUsers(const QDBusMessage &msg) {
- if (!g.sh || !g.sh->isRunning() || !g.uiSession) {
+ if (!Global::get().sh || !Global::get().sh->isRunning() || !Global::get().uiSession) {
QDBusConnection::sessionBus().send(msg.createErrorReply(
QLatin1String("net.sourceforge.mumble.Error.connection"), QLatin1String("Not connected")));
return;
@@ -81,64 +78,64 @@ void MumbleDBus::getTalkingUsers(const QDBusMessage &msg) {
}
void MumbleDBus::focus() {
- g.mw->show();
- g.mw->raise();
- g.mw->activateWindow();
+ Global::get().mw->show();
+ Global::get().mw->raise();
+ Global::get().mw->activateWindow();
}
void MumbleDBus::setTransmitMode(unsigned int mode, const QDBusMessage &msg) {
switch (mode) {
case 0:
- g.s.atTransmit = Settings::Continuous;
+ Global::get().s.atTransmit = Settings::Continuous;
break;
case 1:
- g.s.atTransmit = Settings::VAD;
+ Global::get().s.atTransmit = Settings::VAD;
break;
case 2:
- g.s.atTransmit = Settings::PushToTalk;
+ Global::get().s.atTransmit = Settings::PushToTalk;
break;
default:
QDBusConnection::sessionBus().send(msg.createErrorReply(
QLatin1String("net.sourceforge.mumble.Error.transmitMode"), QLatin1String("Invalid transmit mode")));
return;
}
- QMetaObject::invokeMethod(g.mw, "updateTransmitModeComboBox", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(Global::get().mw, "updateTransmitModeComboBox", Qt::QueuedConnection);
}
unsigned int MumbleDBus::getTransmitMode() {
- return g.s.atTransmit;
+ return Global::get().s.atTransmit;
}
void MumbleDBus::toggleSelfMuted() {
- g.mw->qaAudioMute->trigger();
+ Global::get().mw->qaAudioMute->trigger();
}
void MumbleDBus::toggleSelfDeaf() {
- g.mw->qaAudioDeaf->trigger();
+ Global::get().mw->qaAudioDeaf->trigger();
}
void MumbleDBus::setSelfMuted(bool mute) {
- g.mw->qaAudioMute->setChecked(!mute);
- g.mw->qaAudioMute->trigger();
+ Global::get().mw->qaAudioMute->setChecked(!mute);
+ Global::get().mw->qaAudioMute->trigger();
}
void MumbleDBus::setSelfDeaf(bool deafen) {
- g.mw->qaAudioDeaf->setChecked(!deafen);
- g.mw->qaAudioDeaf->trigger();
+ Global::get().mw->qaAudioDeaf->setChecked(!deafen);
+ Global::get().mw->qaAudioDeaf->trigger();
}
bool MumbleDBus::isSelfMuted() {
- return g.s.bMute;
+ return Global::get().s.bMute;
}
bool MumbleDBus::isSelfDeaf() {
- return g.s.bDeaf;
+ return Global::get().s.bDeaf;
}
void MumbleDBus::startTalking() {
- g.mw->on_PushToTalk_triggered(true, QVariant());
+ Global::get().mw->on_PushToTalk_triggered(true, QVariant());
}
void MumbleDBus::stopTalking() {
- g.mw->on_PushToTalk_triggered(false, QVariant());
+ Global::get().mw->on_PushToTalk_triggered(false, QVariant());
}
diff --git a/src/mumble/Database.cpp b/src/mumble/Database.cpp
index 89d7eadaf..62b30c8f5 100644
--- a/src/mumble/Database.cpp
+++ b/src/mumble/Database.cpp
@@ -44,7 +44,7 @@ bool Database::findOrCreateDatabase() {
QSettings qs;
QStringList datapaths;
- datapaths << g.qdBasePath.absolutePath();
+ datapaths << Global::get().qdBasePath.absolutePath();
datapaths << QStandardPaths::writableLocation(QStandardPaths::DataLocation);
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
datapaths << QDir::homePath() + QLatin1String("/.config/Mumble");
@@ -90,19 +90,19 @@ bool Database::findOrCreateDatabase() {
Database::Database(const QString &dbname) {
db = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"), dbname);
- if (!g.s.qsDatabaseLocation.isEmpty()) {
- QFile configuredLocation(g.s.qsDatabaseLocation);
+ if (!Global::get().s.qsDatabaseLocation.isEmpty()) {
+ QFile configuredLocation(Global::get().s.qsDatabaseLocation);
if (configuredLocation.exists()) {
- db.setDatabaseName(g.s.qsDatabaseLocation);
+ db.setDatabaseName(Global::get().s.qsDatabaseLocation);
db.open();
} else {
int result = QMessageBox::critical(nullptr, QLatin1String("Mumble"),
tr("The database file '%1' set in the configuration file does not "
"exist. Do you want to create a new database file at this location?")
- .arg(g.s.qsDatabaseLocation),
+ .arg(Global::get().s.qsDatabaseLocation),
QMessageBox::Yes | QMessageBox::No);
if (result == QMessageBox::Yes) {
- db.setDatabaseName(g.s.qsDatabaseLocation);
+ db.setDatabaseName(Global::get().s.qsDatabaseLocation);
db.open();
} else {
qFatal("Database: File not found");
@@ -111,7 +111,7 @@ Database::Database(const QString &dbname) {
}
if (!db.isOpen()) {
if (findOrCreateDatabase()) {
- g.s.qsDatabaseLocation = db.databaseName();
+ Global::get().s.qsDatabaseLocation = db.databaseName();
} else {
QMessageBox::critical(nullptr, QLatin1String("Mumble"),
tr("Mumble failed to initialize a database in any of the possible locations."),
diff --git a/src/mumble/DeveloperConsole.cpp b/src/mumble/DeveloperConsole.cpp
index 4a1ee9ed8..de8c04953 100644
--- a/src/mumble/DeveloperConsole.cpp
+++ b/src/mumble/DeveloperConsole.cpp
@@ -6,15 +6,12 @@
#include "DeveloperConsole.h"
#include "LogEmitter.h"
+#include "Global.h"
#include <QtWidgets/QTextBrowser>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
DeveloperConsole::DeveloperConsole(QObject *parent) : QObject(parent) {
- connect(g.le.data(), SIGNAL(newLogEntry(const QString &)), this, SLOT(addLogMessage(const QString &)));
+ connect(Global::get().le.data(), SIGNAL(newLogEntry(const QString &)), this, SLOT(addLogMessage(const QString &)));
}
DeveloperConsole::~DeveloperConsole() {
@@ -31,7 +28,7 @@ void DeveloperConsole::show() {
mw->setCentralWidget(tb);
mw->setWindowTitle(tr("Developer Console"));
- connect(g.le.data(), SIGNAL(newLogEntry(const QString &)), tb, SLOT(append(const QString &)));
+ connect(Global::get().le.data(), SIGNAL(newLogEntry(const QString &)), tb, SLOT(append(const QString &)));
foreach (const QString &m, m_logEntries)
tb->append(m);
diff --git a/src/mumble/Global.cpp b/src/mumble/Global.cpp
index a8977e746..dcc14b445 100644
--- a/src/mumble/Global.cpp
+++ b/src/mumble/Global.cpp
@@ -17,6 +17,10 @@
Global *Global::g_global_struct;
+Global &Global::get() {
+ return *g_global_struct;
+}
+
#ifndef Q_OS_WIN
static void migrateDataDir() {
# ifdef Q_OS_MAC
diff --git a/src/mumble/Global.h b/src/mumble/Global.h
index 1da6253f8..618c30962 100644
--- a/src/mumble/Global.h
+++ b/src/mumble/Global.h
@@ -41,6 +41,8 @@ private:
Q_DISABLE_COPY(Global)
public:
static Global *g_global_struct;
+ static Global &get();
+
MainWindow *mw;
Settings s;
boost::shared_ptr< ServerHandler > sh;
@@ -137,10 +139,4 @@ public:
/// Special exit code which causes mumble to restart itself. The outward facing return code with be 0
const int MUMBLE_EXIT_CODE_RESTART = 64738;
-// -Wshadow is bugged. If an inline function of a class uses a variable or
-// parameter named 'g', that will generate a warning even if the class header
-// is included long before this definition.
-
-#define g (*Global::g_global_struct)
-
#endif
diff --git a/src/mumble/GlobalShortcut.cpp b/src/mumble/GlobalShortcut.cpp
index 5cfc88766..67dc1bf74 100644
--- a/src/mumble/GlobalShortcut.cpp
+++ b/src/mumble/GlobalShortcut.cpp
@@ -11,6 +11,7 @@
#include "Database.h"
#include "MainWindow.h"
#include "GlobalShortcutButtons.h"
+#include "Global.h"
#include <QtCore/QProcess>
#include <QtCore/QSortFilterProxyModel>
@@ -23,10 +24,6 @@
# include <QtCore/QOperatingSystemVersion>
#endif
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
const QString GlobalShortcutConfig::name = QLatin1String("GlobalShortcutConfig");
/**
@@ -140,7 +137,7 @@ ShortcutTargetDialog::ShortcutTargetDialog(const ShortcutTarget &st, QWidget *pw
qcbShoutSubchans->setChecked(st.bChildren);
// Insert all known friends into the possible targets list
- const QMap< QString, QString > &friends = g.db->getFriends();
+ const QMap< QString, QString > &friends = Global::get().db->getFriends();
if (!friends.isEmpty()) {
QMap< QString, QString >::const_iterator i;
for (i = friends.constBegin(); i != friends.constEnd(); ++i) {
@@ -151,13 +148,13 @@ ShortcutTargetDialog::ShortcutTargetDialog(const ShortcutTarget &st, QWidget *pw
}
// If we are connected to a server also add all connected players with certificates to the list
- if (g.uiSession) {
+ if (Global::get().uiSession) {
QMap< QString, QString > others;
QMap< QString, QString >::const_iterator i;
QReadLocker lock(&ClientUser::c_qrwlUsers);
foreach (ClientUser *p, ClientUser::c_qmUsers) {
- if ((p->uiSession != g.uiSession) && p->qsFriendName.isEmpty() && !p->qsHash.isEmpty()) {
+ if ((p->uiSession != Global::get().uiSession) && p->qsFriendName.isEmpty() && !p->qsHash.isEmpty()) {
others.insert(p->qsName, p->qsHash);
qmHashNames.insert(p->qsHash, p->qsName);
}
@@ -217,7 +214,7 @@ ShortcutTargetDialog::ShortcutTargetDialog(const ShortcutTarget &st, QWidget *pw
}
// And if we are connected add the channels on the current server
- if (g.uiSession) {
+ if (Global::get().uiSession) {
Channel *c = Channel::get(0);
QTreeWidgetItem *sroot = new QTreeWidgetItem(qtwChannels, QStringList(c->qsName));
qmTree.insert(0, sroot);
@@ -227,8 +224,8 @@ ShortcutTargetDialog::ShortcutTargetDialog(const ShortcutTarget &st, QWidget *pw
qtwChannels->sortByColumn(0, Qt::AscendingOrder);
QTreeWidgetItem *qtwi;
- if (g.uiSession) {
- qtwi = qmTree.value(ClientUser::get(g.uiSession)->cChannel->iId);
+ if (Global::get().uiSession) {
+ qtwi = qmTree.value(ClientUser::get(Global::get().uiSession)->cChannel->iId);
if (qtwi)
qtwChannels->scrollToItem(qtwi);
}
@@ -355,7 +352,7 @@ QString ShortcutTargetWidget::targetString(const ShortcutTarget &st) {
if (hashes.contains(hash)) {
name = hashes.value(hash);
} else {
- name = g.db->getFriend(hash);
+ name = Global::get().db->getFriend(hash);
if (name.isEmpty())
name = QString::fromLatin1("#%1").arg(hash);
}
@@ -559,7 +556,7 @@ GlobalShortcutConfig::GlobalShortcutConfig(Settings &st) : ConfigWidget(st) {
bool GlobalShortcutConfig::eventFilter(QObject * /*object*/, QEvent *e) {
#ifdef Q_OS_MAC
if (e->type() == QEvent::WindowActivate) {
- if (!g.s.bSuppressMacEventTapWarning) {
+ if (!Global::get().s.bSuppressMacEventTapWarning) {
qwWarningContainer->setVisible(showWarning());
}
}
@@ -598,7 +595,7 @@ void GlobalShortcutConfig::on_qpbOpenAccessibilityPrefs_clicked() {
void GlobalShortcutConfig::on_qpbSkipWarning_clicked() {
// Store to both global and local settings. The 'Skip' is live, as in
// we don't expect the user to click Apply for their choice to work.
- g.s.bSuppressMacEventTapWarning = s.bSuppressMacEventTapWarning = true;
+ Global::get().s.bSuppressMacEventTapWarning = s.bSuppressMacEventTapWarning = true;
qwWarningContainer->setVisible(false);
}
@@ -683,8 +680,8 @@ void GlobalShortcutConfig::load(const Settings &r) {
//
// To make this work well, we set the setting on load. This is to make 'Reset' and 'Restore Defaults'
// work as expected.
- g.s.bSuppressMacEventTapWarning = s.bSuppressMacEventTapWarning = r.bSuppressMacEventTapWarning;
- if (!g.s.bSuppressMacEventTapWarning) {
+ Global::get().s.bSuppressMacEventTapWarning = s.bSuppressMacEventTapWarning = r.bSuppressMacEventTapWarning;
+ if (!Global::get().s.bSuppressMacEventTapWarning) {
qwWarningContainer->setVisible(showWarning());
}
@@ -763,7 +760,7 @@ void GlobalShortcutConfig::reload() {
qtwShortcuts->addTopLevelItem(item);
}
#ifdef Q_OS_MAC
- if (!g.s.bSuppressMacEventTapWarning) {
+ if (!Global::get().s.bSuppressMacEventTapWarning) {
qwWarningContainer->setVisible(showWarning());
} else {
qwWarningContainer->setVisible(false);
@@ -774,7 +771,7 @@ void GlobalShortcutConfig::reload() {
void GlobalShortcutConfig::accept() const {
GlobalShortcutEngine::engine->bNeedRemap = true;
GlobalShortcutEngine::engine->needRemap();
- GlobalShortcutEngine::engine->setEnabled(g.s.bShortcutEnable);
+ GlobalShortcutEngine::engine->setEnabled(Global::get().s.bShortcutEnable);
}
@@ -818,7 +815,7 @@ void GlobalShortcutEngine::remap() {
qlShortcutList.clear();
qlDownButtons.clear();
- foreach (const Shortcut &sc, g.s.qlShortcuts) {
+ foreach (const Shortcut &sc, Global::get().s.qlShortcuts) {
GlobalShortcut *gs = qmShortcuts.value(sc.iIndex);
if (gs && !sc.qlButtons.isEmpty()) {
ShortcutKey *sk = new ShortcutKey;
@@ -889,7 +886,7 @@ bool GlobalShortcutEngine::handleButton(const QVariant &button, bool down) {
}
if (down) {
- AudioInputPtr ai = g.ai;
+ AudioInputPtr ai = Global::get().ai;
if (ai.get()) {
// XXX: This is a data race: we write to ai->activityState
// (accessed by the AudioInput thread) from the main thread.
@@ -946,7 +943,7 @@ bool GlobalShortcutEngine::handleButton(const QVariant &button, bool down) {
void GlobalShortcutEngine::add(GlobalShortcut *gs) {
if (!GlobalShortcutEngine::engine) {
GlobalShortcutEngine::engine = GlobalShortcutEngine::platformInit();
- GlobalShortcutEngine::engine->setEnabled(g.s.bShortcutEnable);
+ GlobalShortcutEngine::engine->setEnabled(Global::get().s.bShortcutEnable);
}
GlobalShortcutEngine::engine->qmShortcuts.insert(gs->idx, gs);
diff --git a/src/mumble/GlobalShortcutButtons.cpp b/src/mumble/GlobalShortcutButtons.cpp
index 214cc775c..8f480f75d 100644
--- a/src/mumble/GlobalShortcutButtons.cpp
+++ b/src/mumble/GlobalShortcutButtons.cpp
@@ -8,8 +8,6 @@
#include "GlobalShortcut.h"
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
#include "Global.h"
GlobalShortcutButtons::GlobalShortcutButtons(QWidget *parent) : QDialog(parent), m_ui(new Ui::GlobalShortcutButtons) {
diff --git a/src/mumble/GlobalShortcut_macx.mm b/src/mumble/GlobalShortcut_macx.mm
index aaa73d9a4..c3aba27b3 100644
--- a/src/mumble/GlobalShortcut_macx.mm
+++ b/src/mumble/GlobalShortcut_macx.mm
@@ -51,12 +51,12 @@ CGEventRef GlobalShortcutMac::callback(CGEventTapProxy proxy, CGEventType type,
case kCGEventRightMouseDragged:
case kCGEventOtherMouseDragged: {
#ifdef USE_OVERLAY
- if (g.ocIntercept) {
+ if (Global::get().ocIntercept) {
int64_t dx = CGEventGetIntegerValueField(event, kCGMouseEventDeltaX);
int64_t dy = CGEventGetIntegerValueField(event, kCGMouseEventDeltaY);
- g.ocIntercept->iMouseX = qBound<int>(0, g.ocIntercept->iMouseX + static_cast<int>(dx), g.ocIntercept->uiWidth - 1);
- g.ocIntercept->iMouseY = qBound<int>(0, g.ocIntercept->iMouseY + static_cast<int>(dy), g.ocIntercept->uiHeight - 1);
- QMetaObject::invokeMethod(g.ocIntercept, "updateMouse", Qt::QueuedConnection);
+ Global::get().ocIntercept->iMouseX = qBound<int>(0, Global::get().ocIntercept->iMouseX + static_cast<int>(dx), Global::get().ocIntercept->uiWidth - 1);
+ Global::get().ocIntercept->iMouseY = qBound<int>(0, Global::get().ocIntercept->iMouseY + static_cast<int>(dy), Global::get().ocIntercept->uiHeight - 1);
+ QMetaObject::invokeMethod(Global::get().ocIntercept, "updateMouse", Qt::QueuedConnection);
forward = true;
}
#endif
@@ -112,7 +112,7 @@ CGEventRef GlobalShortcutMac::callback(CGEventTapProxy proxy, CGEventType type,
}
#ifdef USE_OVERLAY
- if (forward && g.ocIntercept) {
+ if (forward && Global::get().ocIntercept) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSEvent *evt = [[NSEvent eventWithCGEvent:event] retain];
QMetaObject::invokeMethod(gs, "forwardEvent", Qt::QueuedConnection, Q_ARG(void *, evt));
@@ -237,12 +237,12 @@ void GlobalShortcutMac::forwardEvent(void *evt) {
#ifdef USE_OVERLAY
SEL sel = nil;
- if (! g.ocIntercept) {
+ if (! Global::get().ocIntercept) {
[event release];
return;
}
- QWidget *vp = g.ocIntercept->qgv.viewport();
+ QWidget *vp = Global::get().ocIntercept->qgv.viewport();
NSView *view = (NSView *) vp->winId();
switch ([event type]) {
@@ -288,8 +288,8 @@ void GlobalShortcutMac::forwardEvent(void *evt) {
}
if (sel) {
- NSPoint p; p.x = (CGFloat) g.ocIntercept->iMouseX;
- p.y = (CGFloat) (g.ocIntercept->uiHeight - g.ocIntercept->iMouseY);
+ NSPoint p; p.x = (CGFloat) Global::get().ocIntercept->iMouseX;
+ p.y = (CGFloat) (Global::get().ocIntercept->uiHeight - Global::get().ocIntercept->iMouseY);
NSEvent *mouseEvent = [NSEvent mouseEventWithType:[event type] location:p modifierFlags:[event modifierFlags] timestamp:[event timestamp]
windowNumber:0 context:nil eventNumber:[event eventNumber] clickCount:[event clickCount]
pressure:[event pressure]];
diff --git a/src/mumble/GlobalShortcut_unix.cpp b/src/mumble/GlobalShortcut_unix.cpp
index 9ae8c79fc..d8c1c8a46 100644
--- a/src/mumble/GlobalShortcut_unix.cpp
+++ b/src/mumble/GlobalShortcut_unix.cpp
@@ -6,6 +6,7 @@
#include "GlobalShortcut_unix.h"
#include "Settings.h"
+#include "Global.h"
#include <QtCore/QFileSystemWatcher>
#include <QtCore/QSocketNotifier>
@@ -23,10 +24,6 @@
# include <linux/input.h>
#endif
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last incl
-#include "Global.h"
-
// We have to use a global 'diagnostic ignored' pragmas because
// we still support old versions of GCC. (FreeBSD 9.3 ships with GCC 4.2)
#if defined(__GNUC__)
@@ -65,7 +62,7 @@ GlobalShortcutX::GlobalShortcutX() {
}
#ifdef Q_OS_LINUX
- if (g.s.bEnableEvdev) {
+ if (Global::get().s.bEnableEvdev) {
QString dir = QLatin1String("/dev/input");
QFileSystemWatcher *fsw = new QFileSystemWatcher(QStringList(dir), this);
connect(fsw, SIGNAL(directoryChanged(const QString &)), this, SLOT(directoryChanged(const QString &)));
@@ -91,7 +88,7 @@ GlobalShortcutX::GlobalShortcutX() {
#ifndef NO_XINPUT2
int evt, error;
- if (g.s.bEnableXInput2 && XQueryExtension(display, "XInputExtension", &iXIopcode, &evt, &error)) {
+ if (Global::get().s.bEnableXInput2 && XQueryExtension(display, "XInputExtension", &iXIopcode, &evt, &error)) {
int major = XI_2_Major;
int minor = XI_2_Minor;
int rc = XIQueryVersion(display, &major, &minor);
@@ -251,7 +248,7 @@ void GlobalShortcutX::displayReadyRead(int) {
// One of the raw /dev/input devices has ready input
void GlobalShortcutX::inputReadyRead(int) {
#ifdef Q_OS_LINUX
- if (!g.s.bEnableEvdev) {
+ if (!Global::get().s.bEnableEvdev) {
return;
}
@@ -303,7 +300,7 @@ void GlobalShortcutX::inputReadyRead(int) {
// The /dev/input directory changed
void GlobalShortcutX::directoryChanged(const QString &dir) {
#ifdef Q_OS_LINUX
- if (!g.s.bEnableEvdev) {
+ if (!Global::get().s.bEnableEvdev) {
return;
}
diff --git a/src/mumble/GlobalShortcut_win.cpp b/src/mumble/GlobalShortcut_win.cpp
index 7b949fa60..61c1834a5 100644
--- a/src/mumble/GlobalShortcut_win.cpp
+++ b/src/mumble/GlobalShortcut_win.cpp
@@ -7,6 +7,7 @@
#include "MainWindow.h"
#include "Utils.h"
+#include "Global.h"
// MinGW does not support std::future/std::promise
// at present. Use Boost's implementation for now.
@@ -23,10 +24,6 @@
// Used to detect screen readers
#include <tlhelp32.h>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
#undef FAILED
#define FAILED(Status) (static_cast< HRESULT >(Status) < 0)
@@ -122,7 +119,7 @@ GlobalShortcutWin::GlobalShortcutWin()
{
// Hidden setting to disable hooking
// Also disable hooking if a screen reader is running
- bHook = g.qs->value(QLatin1String("winhooks"), true).toBool() && !areScreenReadersActive();
+ bHook = Global::get().qs->value(QLatin1String("winhooks"), true).toBool() && !areScreenReadersActive();
moveToThread(this);
start(QThread::LowestPriority);
@@ -166,18 +163,18 @@ void GlobalShortcutWin::run() {
// Wait for MainWindow's constructor to finish before we enumerate DirectInput devices.
// We need to do this because adding a new device requires a Window handle. (SetCooperativeLevel())
- while (!g.mw)
+ while (!Global::get().mw)
this->yieldCurrentThread();
#ifdef USE_GKEY
- if (g.s.bEnableGKey) {
+ if (Global::get().s.bEnableGKey) {
gkey = new GKeyLibrary();
qWarning("GlobalShortcutWin: GKeys initialized, isValid: %d", gkey->isValid());
}
#endif
#ifdef USE_XBOXINPUT
- if (g.s.bEnableXboxInput) {
+ if (Global::get().s.bEnableXboxInput) {
xboxinput = new XboxInput();
ZeroMemory(&xboxinputLastPacket, sizeof(xboxinputLastPacket));
qWarning("GlobalShortcutWin: XboxInput initialized, isValid: %d", xboxinput->isValid());
@@ -319,7 +316,7 @@ bool GlobalShortcutWin::handleKeyboardMessage(DWORD scancode, DWORD vkcode, bool
keyid |= 0x8000U;
}
- // NumLock and Pause need special handling.
+ // NumLock and Pause need special handlinGlobal::get().
// For those keys, the method above of setting
// bit 15 high when the LLKHF_EXTENDED flag is
// set on the low-level key event does not work.
@@ -447,7 +444,7 @@ BOOL CALLBACK GlobalShortcutWin::EnumDeviceObjectsCallback(LPCDIDEVICEOBJECTINST
QString name = QString::fromUtf16(reinterpret_cast< const ushort * >(lpddoi->tszName));
id->qhNames[lpddoi->dwType] = name;
- if (g.s.bDirectInputVerboseLogging) {
+ if (Global::get().s.bDirectInputVerboseLogging) {
qWarning("GlobalShortcutWin: EnumObjects: device %s %s object 0x%.8lx %s",
qPrintable(QUuid(id->guid).toString()), qPrintable(id->name),
static_cast< unsigned long >(lpddoi->dwType), qPrintable(name));
@@ -605,8 +602,8 @@ BOOL GlobalShortcutWin::EnumDevicesCB(LPCDIDEVICEINSTANCE pdidi, LPVOID pContext
}
void GlobalShortcutWin::timeTicked() {
- if (g.mw->uiNewHardware != uiHardwareDevices) {
- uiHardwareDevices = g.mw->uiNewHardware;
+ if (Global::get().mw->uiNewHardware != uiHardwareDevices) {
+ uiHardwareDevices = Global::get().mw->uiNewHardware;
XInputCheck_ClearDeviceCache();
#ifdef USE_XBOXINPUT
@@ -653,7 +650,7 @@ void GlobalShortcutWin::timeTicked() {
// might have a misbehaving device.
if (timer.elapsed() > 1000) {
qWarning("GlobalShortcut_win: Poll() for device %s took %li msec. This is abnormal, the device is "
- "possibly misbehaving...",
+ "possibly misbehavinGlobal::get()...",
qPrintable(QUuid(id->guid).toString()), static_cast< long >(timer.elapsed()));
}
}
@@ -676,7 +673,7 @@ void GlobalShortcutWin::timeTicked() {
}
#ifdef USE_GKEY
- if (g.s.bEnableGKey && gkey && gkey->isValid()) {
+ if (Global::get().s.bEnableGKey && gkey && gkey->isValid()) {
for (int button = GKEY_MIN_MOUSE_BUTTON; button <= GKEY_MAX_MOUSE_BUTTON; button++) {
QList< QVariant > ql;
ql << button;
@@ -697,7 +694,7 @@ void GlobalShortcutWin::timeTicked() {
#endif
#ifdef USE_XBOXINPUT
- if (g.s.bEnableXboxInput && xboxinput && xboxinput->isValid() && nxboxinput > 0) {
+ if (Global::get().s.bEnableXboxInput && xboxinput && xboxinput->isValid() && nxboxinput > 0) {
XboxInputState state;
for (uint32_t i = 0; i < XBOXINPUT_MAX_DEVICES; i++) {
if (xboxinput->GetState(i, &state) == 0) {
@@ -807,7 +804,7 @@ GlobalShortcutWin::ButtonInfo GlobalShortcutWin::buttonInfo(const QVariant &v) {
info.device = guid.toString();
#ifdef USE_GKEY
- if (g.s.bEnableGKey && gkey && gkey->isValid()) {
+ if (Global::get().s.bEnableGKey && gkey && gkey->isValid()) {
bool isGKey = false;
if (guid == GKeyLibrary::quMouse) {
isGKey = true;
@@ -828,7 +825,7 @@ GlobalShortcutWin::ButtonInfo GlobalShortcutWin::buttonInfo(const QVariant &v) {
#endif
#ifdef USE_XBOXINPUT
- if (g.s.bEnableXboxInput && xboxinput && xboxinput->isValid() && guid == XboxInput::s_XboxInputGuid) {
+ if (Global::get().s.bEnableXboxInput && xboxinput && xboxinput->isValid() && guid == XboxInput::s_XboxInputGuid) {
uint32_t idx = (type >> 24) & 0xff;
uint32_t button = (type & 0x00ffffff);
diff --git a/src/mumble/JackAudio.cpp b/src/mumble/JackAudio.cpp
index d50b0a951..3ab7f7a57 100644
--- a/src/mumble/JackAudio.cpp
+++ b/src/mumble/JackAudio.cpp
@@ -6,9 +6,6 @@
#include "JackAudio.h"
#include "Utils.h"
-
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
#include "Global.h"
#ifdef Q_CC_GNU
@@ -148,9 +145,9 @@ const QList< audioDevice > JackAudioOutputRegistrar::getDeviceChoices() {
QStringList qlOutputDevs = jas->qhOutput.keys();
std::sort(qlOutputDevs.begin(), qlOutputDevs.end());
- if (qlOutputDevs.contains(g.s.qsJackAudioOutput)) {
- qlOutputDevs.removeAll(g.s.qsJackAudioOutput);
- qlOutputDevs.prepend(g.s.qsJackAudioOutput);
+ if (qlOutputDevs.contains(Global::get().s.qsJackAudioOutput)) {
+ qlOutputDevs.removeAll(Global::get().s.qsJackAudioOutput);
+ qlOutputDevs.prepend(Global::get().s.qsJackAudioOutput);
}
foreach (const QString &dev, qlOutputDevs) { qlReturn << audioDevice(jas->qhOutput.value(dev), dev); }
@@ -269,8 +266,8 @@ bool JackAudioSystem::initialize() {
}
jack_status_t status;
- client = jack_client_open(g.s.qsJackClientName.toStdString().c_str(),
- g.s.bJackStartServer ? JackNullOption : JackNoStartServer, &status);
+ client = jack_client_open(Global::get().s.qsJackClientName.toStdString().c_str(),
+ Global::get().s.bJackStartServer ? JackNullOption : JackNoStartServer, &status);
if (!client) {
const auto errors = jackStatusToStringList(status);
qWarning("JackAudioSystem: unable to open client due to %i errors:", errors.count());
@@ -395,7 +392,7 @@ bool JackAudioSystem::isOk() {
}
uint8_t JackAudioSystem::outPorts() {
- return static_cast< uint8_t >(qBound< unsigned >(1, g.s.qsJackAudioOutput.toUInt(), JACK_MAX_OUTPUT_PORTS));
+ return static_cast< uint8_t >(qBound< unsigned >(1, Global::get().s.qsJackAudioOutput.toUInt(), JACK_MAX_OUTPUT_PORTS));
}
jack_nframes_t JackAudioSystem::sampleRate() {
@@ -599,8 +596,8 @@ void JackAudioSystem::ringbufferWriteAdvance(jack_ringbuffer_t *buffer, const si
}
int JackAudioSystem::processCallback(jack_nframes_t frames, void *) {
- auto const jai = dynamic_cast< JackAudioInput * >(g.ai.get());
- auto const jao = dynamic_cast< JackAudioOutput * >(g.ao.get());
+ auto const jai = dynamic_cast< JackAudioInput * >(Global::get().ai.get());
+ auto const jao = dynamic_cast< JackAudioOutput * >(Global::get().ao.get());
const bool input = (jai && jai->isReady());
const bool output = (jao && jao->isReady());
@@ -617,8 +614,8 @@ int JackAudioSystem::processCallback(jack_nframes_t frames, void *) {
}
int JackAudioSystem::sampleRateCallback(jack_nframes_t, void *) {
- auto const jai = dynamic_cast< JackAudioInput * >(g.ai.get());
- auto const jao = dynamic_cast< JackAudioOutput * >(g.ao.get());
+ auto const jai = dynamic_cast< JackAudioInput * >(Global::get().ai.get());
+ auto const jao = dynamic_cast< JackAudioOutput * >(Global::get().ao.get());
if (jai) {
jai->activate();
@@ -632,8 +629,8 @@ int JackAudioSystem::sampleRateCallback(jack_nframes_t, void *) {
}
int JackAudioSystem::bufferSizeCallback(jack_nframes_t frames, void *) {
- auto const jai = dynamic_cast< JackAudioInput * >(g.ai.get());
- auto const jao = dynamic_cast< JackAudioOutput * >(g.ao.get());
+ auto const jai = dynamic_cast< JackAudioInput * >(Global::get().ai.get());
+ auto const jao = dynamic_cast< JackAudioOutput * >(Global::get().ao.get());
if (jai && !jai->allocBuffer(frames)) {
return 1;
@@ -822,7 +819,7 @@ void JackAudioInput::run() {
}
// Initialization
- if (g.s.bJackAutoConnect) {
+ if (Global::get().s.bJackAutoConnect) {
connectPorts();
}
@@ -1064,7 +1061,7 @@ void JackAudioOutput::run() {
}
// Initialization
- if (g.s.bJackAutoConnect) {
+ if (Global::get().s.bJackAutoConnect) {
connectPorts();
}
diff --git a/src/mumble/LCD.cpp b/src/mumble/LCD.cpp
index e5cde7bb8..a2248f0fe 100644
--- a/src/mumble/LCD.cpp
+++ b/src/mumble/LCD.cpp
@@ -10,13 +10,10 @@
#include "Message.h"
#include "ServerHandler.h"
#include "Utils.h"
+#include "Global.h"
#include <QtGui/QPainter>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
const QString LCDConfig::name = QLatin1String("LCDConfig");
QList< LCDEngineNew > *LCDEngineRegistrar::qlInitializers;
@@ -144,7 +141,7 @@ void LCDConfig::accept() const {
bool enabled = s.qmLCDDevices.value(d->name());
d->setEnabled(enabled);
}
- g.lcd->updateUserView();
+ Global::get().lcd->updateUserView();
}
void LCDConfig::on_qsMinColWidth_valueChanged(int v) {
@@ -189,7 +186,7 @@ LCD::LCD() : QObject() {
connect(qtTimer, SIGNAL(timeout()), this, SLOT(tick()));
foreach (LCDDevice *d, devmgr.qlDevices) {
- bool enabled = g.s.qmLCDDevices.contains(d->name()) ? g.s.qmLCDDevices.value(d->name()) : true;
+ bool enabled = Global::get().s.qmLCDDevices.contains(d->name()) ? Global::get().s.qmLCDDevices.value(d->name()) : true;
d->setEnabled(enabled);
}
qiLogo = QIcon(QLatin1String("skin:mumble.svg")).pixmap(48, 48).toImage().convertToFormat(QImage::Format_MonoLSB);
@@ -246,7 +243,7 @@ void LCD::updateUserView() {
return;
QStringList qslTalking;
- User *me = g.uiSession ? ClientUser::get(g.uiSession) : nullptr;
+ User *me = Global::get().uiSession ? ClientUser::get(Global::get().uiSession) : nullptr;
Channel *home = me ? me->cChannel : nullptr;
bool alert = false;
@@ -356,7 +353,7 @@ void LCD::updateUserView() {
const int iWidth = size.width();
const int iHeight = size.height();
const int iUsersPerColumn = iHeight / iFontHeight;
- const int iSplitterWidth = g.s.iLCDUserViewSplitterWidth;
+ const int iSplitterWidth = Global::get().s.iLCDUserViewSplitterWidth;
const int iUserColumns = (entries.count() + iUsersPerColumn - 1) / iUsersPerColumn;
int iColumns = iUserColumns;
@@ -364,7 +361,7 @@ void LCD::updateUserView() {
while (iColumns >= 1) {
iColumnWidth = (iWidth - (iColumns - 1) * iSplitterWidth) / iColumns;
- if (iColumnWidth >= g.s.iLCDUserViewMinColWidth)
+ if (iColumnWidth >= Global::get().s.iLCDUserViewMinColWidth)
break;
--iColumns;
}
diff --git a/src/mumble/ListenerLocalVolumeDialog.cpp b/src/mumble/ListenerLocalVolumeDialog.cpp
index 1607715bb..50ee97c24 100644
--- a/src/mumble/ListenerLocalVolumeDialog.cpp
+++ b/src/mumble/ListenerLocalVolumeDialog.cpp
@@ -12,10 +12,6 @@
#include <cmath>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
ListenerLocalVolumeDialog::ListenerLocalVolumeDialog(ClientUser *user, Channel *channel, QWidget *parent)
: QDialog(parent), m_user(user), m_channel(channel) {
setupUi(this);
diff --git a/src/mumble/Log.cpp b/src/mumble/Log.cpp
index f4f44135f..5ddf4a23d 100644
--- a/src/mumble/Log.cpp
+++ b/src/mumble/Log.cpp
@@ -17,6 +17,7 @@
# include "TextToSpeech.h"
#endif
#include "Utils.h"
+#include "Global.h"
#include <QSignalBlocker>
#include <QtCore/QMutexLocker>
@@ -27,10 +28,6 @@
#include <QtNetwork/QNetworkReply>
#include <QtWidgets/QDesktopWidget>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
const QString LogConfig::name = QLatin1String("LogConfig");
static ConfigWidget *LogConfigDialogNew(Settings &st) {
@@ -77,7 +74,7 @@ LogConfig::LogConfig(Settings &st) : ConfigWidget(st) {
QTreeWidgetItem *twi;
for (int i = Log::firstMsgType; i <= Log::lastMsgType; ++i) {
Log::MsgType t = Log::msgOrder[i];
- const QString messageName = g.l->msgName(t);
+ const QString messageName = Global::get().l->msgName(t);
twi = new QTreeWidgetItem(qtwMessages);
twi->setData(ColMessage, Qt::UserRole, static_cast< int >(t));
@@ -268,9 +265,9 @@ void LogConfig::save() const {
void LogConfig::accept() const {
#ifndef USE_NO_TTS
- g.l->tts->setVolume(s.iTTSVolume);
+ Global::get().l->tts->setVolume(s.iTTSVolume);
#endif
- g.mw->qteLog->document()->setMaximumBlockCount(s.iMaxLogBlocks);
+ Global::get().mw->qteLog->document()->setMaximumBlockCount(s.iMaxLogBlocks);
}
void LogConfig::on_qtwMessages_itemChanged(QTreeWidgetItem *i, int column) {
@@ -309,7 +306,7 @@ void LogConfig::on_qtwMessages_itemChanged(QTreeWidgetItem *i, int column) {
void LogConfig::on_qtwMessages_itemClicked(QTreeWidgetItem *item, int column) {
if (item && item != allMessagesItem && column == ColStaticSoundPath) {
- AudioOutputPtr ao = g.ao;
+ AudioOutputPtr ao = Global::get().ao;
if (ao) {
if (!ao->playSample(item->text(ColStaticSoundPath), false))
browseForAudioFile();
@@ -339,7 +336,7 @@ QVector< LogMessage > Log::qvDeferredLogs;
Log::Log(QObject *p) : QObject(p) {
#ifndef USE_NO_TTS
tts = new TextToSpeech(this);
- tts->setVolume(g.s.iTTSVolume);
+ tts->setVolume(Global::get().s.iTTSVolume);
#endif
uiLastId = 0;
qdDate = QDate::currentDate();
@@ -447,14 +444,14 @@ QString Log::formatChannel(::Channel *c) {
return QString::fromLatin1("<a href='channelid://%1/%3' class='log-channel'>%2</a>")
.arg(c->iId)
.arg(c->qsName.toHtmlEscaped())
- .arg(QString::fromLatin1(g.sh->qbaDigest.toBase64()));
+ .arg(QString::fromLatin1(Global::get().sh->qbaDigest.toBase64()));
}
void Log::logOrDefer(Log::MsgType mt, const QString &console, const QString &terse, bool ownMessage,
const QString &overrideTTS, bool ignoreTTS) {
- if (g.l) {
+ if (Global::get().l) {
// log directly as it seems the log-UI has been set-up already
- g.l->log(mt, console, terse, ownMessage, overrideTTS, ignoreTTS);
+ Global::get().l->log(mt, console, terse, ownMessage, overrideTTS, ignoreTTS);
} else {
// defer the log
QMutexLocker mLock(&Log::qmDeferredLogs);
@@ -478,7 +475,7 @@ QString Log::formatClientUser(ClientUser *cu, LogColorType t, const QString &dis
.arg(className)
.arg(cu->uiSession)
.arg(name)
- .arg(QString::fromLatin1(g.sh->qbaDigest.toBase64()));
+ .arg(QString::fromLatin1(Global::get().sh->qbaDigest.toBase64()));
} else {
return QString::fromLatin1("<a href='clientid://%2' class='log-user log-%1'>%3</a>")
.arg(className)
@@ -552,7 +549,7 @@ QString Log::imageToImg(QImage img, int maxSize) {
QString Log::validHtml(const QString &html, QTextCursor *tc) {
LogDocument qtd;
- QRectF qr = Screen::screenFromWidget(*g.mw)->availableGeometry();
+ QRectF qr = Screen::screenFromWidget(*Global::get().mw)->availableGeometry();
qtd.setTextWidth(qr.width() / 2);
qtd.setDefaultStyleSheet(qApp->styleSheet());
@@ -633,23 +630,23 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own
QString plain = QTextDocumentFragment::fromHtml(console).toPlainText();
- quint32 flags = g.s.qmMessages.value(mt);
+ quint32 flags = Global::get().s.qmMessages.value(mt);
// Message output on console
if ((flags & Settings::LogConsole)) {
- QTextCursor tc = g.mw->qteLog->textCursor();
+ QTextCursor tc = Global::get().mw->qteLog->textCursor();
// We copy the value from the settings in order to make sure that
// we use the same margin everywhere while in this method (even if
// the setting might change in that time).
- const int msgMargin = g.s.iChatMessageMargins;
+ const int msgMargin = Global::get().s.iChatMessageMargins;
QTextBlockFormat format = tc.blockFormat();
format.setTopMargin(msgMargin);
format.setBottomMargin(msgMargin);
tc.setBlockFormat(format);
- LogTextBrowser *tlog = g.mw->qteLog;
+ LogTextBrowser *tlog = Global::get().mw->qteLog;
const int oldscrollvalue = tlog->getLogScroll();
const bool scroll = (oldscrollvalue == tlog->getLogScrollMaximum());
@@ -685,12 +682,12 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own
tc.insertBlock();
}
- const QString timeString = dt.time().toString(QLatin1String(g.s.bLog24HourClock ? "HH:mm:ss" : "hh:mm:ss AP"));
+ const QString timeString = dt.time().toString(QLatin1String(Global::get().s.bLog24HourClock ? "HH:mm:ss" : "hh:mm:ss AP"));
tc.insertHtml(Log::msgColor(QString::fromLatin1("[%1] ").arg(timeString.toHtmlEscaped()), Log::Time));
validHtml(console, &tc);
tc.movePosition(QTextCursor::End);
- g.mw->qteLog->setTextCursor(tc);
+ Global::get().mw->qteLog->setTextCursor(tc);
if (scroll || ownMessage)
tlog->scrollLogToBottom();
@@ -699,10 +696,10 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own
}
if (!ownMessage) {
- if (!(g.mw->isActiveWindow() && g.mw->qdwLog->isVisible())) {
+ if (!(Global::get().mw->isActiveWindow() && Global::get().mw->qdwLog->isVisible())) {
// Message notification with window highlight
if (flags & Settings::LogHighlight) {
- QApplication::alert(g.mw);
+ QApplication::alert(Global::get().mw);
}
// Message notification with balloon tooltips
@@ -712,25 +709,25 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own
}
// Don't make any noise if we are self deafened (Unless it is the sound for activating self deaf)
- if (g.s.bDeaf && mt != Log::SelfDeaf) {
+ if (Global::get().s.bDeaf && mt != Log::SelfDeaf) {
return;
}
// Message notification with static sounds
if ((flags & Settings::LogSoundfile)) {
- QString sSound = g.s.qmMessageSounds.value(mt);
- AudioOutputPtr ao = g.ao;
+ QString sSound = Global::get().s.qmMessageSounds.value(mt);
+ AudioOutputPtr ao = Global::get().ao;
if (!ao || !ao->playSample(sSound, false)) {
qWarning() << "Sound file" << sSound << "is not a valid audio file, fallback to TTS.";
flags ^= Settings::LogSoundfile | Settings::LogTTS; // Fallback to TTS
}
}
- } else if (!g.s.bTTSMessageReadBack) {
+ } else if (!Global::get().s.bTTSMessageReadBack) {
return;
}
// Message notification with Text-To-Speech
- if (g.s.bDeaf || !g.s.bTTS || !(flags & Settings::LogTTS) || ignoreTTS) {
+ if (Global::get().s.bDeaf || !Global::get().s.bTTS || !(flags & Settings::LogTTS) || ignoreTTS) {
return;
}
@@ -772,9 +769,9 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own
#ifndef USE_NO_TTS
// TTS threshold limiter.
- if (plain.length() <= g.s.iTTSThreshold)
+ if (plain.length() <= Global::get().s.iTTSThreshold)
tts->say(plain);
- else if ((!terse.isEmpty()) && (terse.length() <= g.s.iTTSThreshold))
+ else if ((!terse.isEmpty()) && (terse.length() <= Global::get().s.iTTSThreshold))
tts->say(terse);
#else
// Mark as unused
@@ -794,7 +791,7 @@ void Log::processDeferredLogs() {
// Post a notification using the MainWindow's QSystemTrayIcon.
void Log::postQtNotification(MsgType mt, const QString &plain) {
- if (g.mw->qstiIcon->isSystemTrayAvailable() && g.mw->qstiIcon->supportsMessages()) {
+ if (Global::get().mw->qstiIcon->isSystemTrayAvailable() && Global::get().mw->qstiIcon->supportsMessages()) {
QSystemTrayIcon::MessageIcon msgIcon;
switch (mt) {
case DebugInfo:
@@ -808,7 +805,7 @@ void Log::postQtNotification(MsgType mt, const QString &plain) {
msgIcon = QSystemTrayIcon::Information;
break;
}
- g.mw->qstiIcon->showMessage(msgName(mt), plain, msgIcon);
+ Global::get().mw->qstiIcon->showMessage(msgName(mt), plain, msgIcon);
}
}
diff --git a/src/mumble/Log_macx.mm b/src/mumble/Log_macx.mm
index 42c6864cc..627af9d0a 100644
--- a/src/mumble/Log_macx.mm
+++ b/src/mumble/Log_macx.mm
@@ -9,7 +9,6 @@
#include <Foundation/Foundation.h>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name (like protobuf 3.7 does). As such, for now, we have to make this our last include.
#include "Global.h"
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
@@ -54,7 +53,7 @@ static bool growl_available() {
QStringList qslAllEvents;
for (int i = Log::firstMsgType; i <= Log::lastMsgType; ++i) {
Log::MsgType t = static_cast<Log::MsgType>(i);
- qslAllEvents << QString::fromLatin1("\"%1\"").arg(g.l->msgName(t));
+ qslAllEvents << QString::fromLatin1("\"%1\"").arg(Global::get().l->msgName(t));
}
QString qsScript = QString::fromLatin1(
"tell application \"GrowlHelperApp\"\n"
diff --git a/src/mumble/Log_unix.cpp b/src/mumble/Log_unix.cpp
index 0d9e4b043..371980937 100644
--- a/src/mumble/Log_unix.cpp
+++ b/src/mumble/Log_unix.cpp
@@ -11,10 +11,6 @@
# include <QtDBus/QDBusInterface>
#endif
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
void Log::postNotification(MsgType mt, const QString &plain) {
// Message notification with balloon tooltips
QString qsIcon;
diff --git a/src/mumble/LookConfig.cpp b/src/mumble/LookConfig.cpp
index c0d51a681..6c97d4b9c 100644
--- a/src/mumble/LookConfig.cpp
+++ b/src/mumble/LookConfig.cpp
@@ -9,15 +9,12 @@
#include "AudioInput.h"
#include "AudioOutput.h"
#include "MainWindow.h"
+#include "Global.h"
#include <QtCore/QFileSystemWatcher>
#include <QtCore/QStack>
#include <QtCore/QTimer>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
const QString LookConfig::name = QLatin1String("LookConfig");
static ConfigWidget *LookConfigNew(Settings &st) {
@@ -274,7 +271,7 @@ void LookConfig::save() const {
}
void LookConfig::accept() const {
- g.mw->setShowDockTitleBars((g.s.wlWindowLayout == Settings::LayoutCustom) && !g.s.bLockLayout);
+ Global::get().mw->setShowDockTitleBars((Global::get().s.wlWindowLayout == Settings::LayoutCustom) && !Global::get().s.bLockLayout);
}
void LookConfig::themeDirectoryChanged() {
diff --git a/src/mumble/MainWindow.cpp b/src/mumble/MainWindow.cpp
index 14f487df8..1b7723ed4 100644
--- a/src/mumble/MainWindow.cpp
+++ b/src/mumble/MainWindow.cpp
@@ -55,6 +55,7 @@
#include "VersionCheck.h"
#include "ViewCert.h"
#include "VoiceRecorderDialog.h"
+#include "Global.h"
#ifdef Q_OS_WIN
# include "TaskList.h"
@@ -82,10 +83,6 @@
# include <dbt.h>
#endif
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
MessageBoxEvent::MessageBoxEvent(QString m) : QEvent(static_cast< QEvent::Type >(MB_QEVENT)) {
msg = m;
}
@@ -174,7 +171,7 @@ MainWindow::MainWindow(QWidget *p) : QMainWindow(p) {
connect(qaShow, SIGNAL(triggered()), this, SLOT(showRaiseWindow()));
// Explicitely add actions to mainwindow so their shortcuts are available
- // if only the main window is visible (e.g. minimal mode)
+ // if only the main window is visible (e.Global::get(). minimal mode)
addActions(findChildren< QAction * >());
on_qmServer_aboutToShow();
@@ -184,9 +181,9 @@ MainWindow::MainWindow(QWidget *p) : QMainWindow(p) {
on_qmConfig_aboutToShow();
qmDeveloper->addAction(qaDeveloperConsole);
- setOnTop(g.s.aotbAlwaysOnTop == Settings::OnTopAlways
- || (g.s.bMinimalView && g.s.aotbAlwaysOnTop == Settings::OnTopInMinimal)
- || (!g.s.bMinimalView && g.s.aotbAlwaysOnTop == Settings::OnTopInNormal));
+ setOnTop(Global::get().s.aotbAlwaysOnTop == Settings::OnTopAlways
+ || (Global::get().s.bMinimalView && Global::get().s.aotbAlwaysOnTop == Settings::OnTopInMinimal)
+ || (!Global::get().s.bMinimalView && Global::get().s.aotbAlwaysOnTop == Settings::OnTopInNormal));
}
void MainWindow::createActions() {
@@ -232,7 +229,7 @@ void MainWindow::createActions() {
gsToggleOverlay->qsToolTip = tr("Toggle state of in-game overlay.", "Global Shortcut");
gsToggleOverlay->qsWhatsThis = tr("This will switch the states of the in-game overlay.", "Global Shortcut");
- connect(gsToggleOverlay, SIGNAL(down(QVariant)), g.o, SLOT(toggleShow()));
+ connect(gsToggleOverlay, SIGNAL(down(QVariant)), Global::get().o, SLOT(toggleShow()));
#endif
gsMinimal = new GlobalShortcut(this, idx++, tr("Toggle Minimal", "Global Shortcut"));
@@ -305,7 +302,7 @@ void MainWindow::setupGui() {
LogDocument *ld = new LogDocument(qteLog);
qteLog->setDocument(ld);
- qteLog->document()->setMaximumBlockCount(g.s.iMaxLogBlocks);
+ qteLog->document()->setMaximumBlockCount(Global::get().s.iMaxLogBlocks);
qteLog->document()->setDefaultStyleSheet(qApp->styleSheet());
pmModel = new UserModel(qtvUsers);
@@ -320,20 +317,20 @@ void MainWindow::setupGui() {
QObject::connect(&ChannelListener::get(), &ChannelListener::localVolumeAdjustmentsChanged, pmModel,
&UserModel::on_channelListenerLocalVolumeAdjustmentChanged);
- qaAudioMute->setChecked(g.s.bMute);
- qaAudioDeaf->setChecked(g.s.bDeaf);
+ qaAudioMute->setChecked(Global::get().s.bMute);
+ qaAudioDeaf->setChecked(Global::get().s.bDeaf);
#ifdef USE_NO_TTS
qaAudioTTS->setChecked(false);
qaAudioTTS->setDisabled(true);
#else
- qaAudioTTS->setChecked(g.s.bTTS);
+ qaAudioTTS->setChecked(Global::get().s.bTTS);
#endif
- qaFilterToggle->setChecked(g.s.bFilterActive);
+ qaFilterToggle->setChecked(Global::get().s.bFilterActive);
qaHelpWhatsThis->setShortcuts(QKeySequence::WhatsThis);
- qaConfigMinimal->setChecked(g.s.bMinimalView);
- qaConfigHideFrame->setChecked(g.s.bHideFrame);
+ qaConfigMinimal->setChecked(Global::get().s.bMinimalView);
+ qaConfigHideFrame->setChecked(Global::get().s.bHideFrame);
connect(gsResetAudio, SIGNAL(down(QVariant)), qaAudioReset, SLOT(trigger()));
connect(gsUnlink, SIGNAL(down(QVariant)), qaAudioUnlink, SLOT(trigger()));
@@ -353,7 +350,7 @@ void MainWindow::setupGui() {
qteChat->setDefaultText(tr("<center>Not connected</center>"), true);
qteChat->setEnabled(false);
- setShowDockTitleBars((g.s.wlWindowLayout == Settings::LayoutCustom) && !g.s.bLockLayout);
+ setShowDockTitleBars((Global::get().s.wlWindowLayout == Settings::LayoutCustom) && !Global::get().s.bLockLayout);
#ifdef Q_OS_MAC
// Workaround for QTBUG-3116 -- using a unified toolbar on Mac OS X
@@ -388,15 +385,15 @@ void MainWindow::setupGui() {
setupView(false);
#endif
- if (g.s.bMinimalView && !g.s.qbaMinimalViewGeometry.isNull())
- restoreGeometry(g.s.qbaMinimalViewGeometry);
- else if (!g.s.bMinimalView && !g.s.qbaMainWindowGeometry.isNull())
- restoreGeometry(g.s.qbaMainWindowGeometry);
+ if (Global::get().s.bMinimalView && !Global::get().s.qbaMinimalViewGeometry.isNull())
+ restoreGeometry(Global::get().s.qbaMinimalViewGeometry);
+ else if (!Global::get().s.bMinimalView && !Global::get().s.qbaMainWindowGeometry.isNull())
+ restoreGeometry(Global::get().s.qbaMainWindowGeometry);
- if (g.s.bMinimalView && !g.s.qbaMinimalViewState.isNull())
- restoreState(g.s.qbaMinimalViewState);
- else if (!g.s.bMinimalView && !g.s.qbaMainWindowState.isNull())
- restoreState(g.s.qbaMainWindowState);
+ if (Global::get().s.bMinimalView && !Global::get().s.qbaMinimalViewState.isNull())
+ restoreState(Global::get().s.qbaMinimalViewState);
+ else if (!Global::get().s.bMinimalView && !Global::get().s.qbaMainWindowState.isNull())
+ restoreState(Global::get().s.qbaMainWindowState);
setupView(false);
@@ -414,22 +411,22 @@ void MainWindow::setupGui() {
void MainWindow::updateWindowTitle() {
QString title;
- if (g.s.bMinimalView) {
+ if (Global::get().s.bMinimalView) {
title = tr("Mumble - Minimal View -- %1");
} else {
title = tr("Mumble -- %1");
}
- if (!g.windowTitlePostfix.isEmpty()) {
- title += QString::fromLatin1(" | %1").arg(g.windowTitlePostfix);
+ if (!Global::get().windowTitlePostfix.isEmpty()) {
+ title += QString::fromLatin1(" | %1").arg(Global::get().windowTitlePostfix);
}
setWindowTitle(title.arg(QLatin1String(MUMBLE_RELEASE)));
}
void MainWindow::updateToolbar() {
- bool layoutIsCustom = g.s.wlWindowLayout == Settings::LayoutCustom;
- qtIconToolbar->setMovable(layoutIsCustom && !g.s.bLockLayout);
+ bool layoutIsCustom = Global::get().s.wlWindowLayout == Settings::LayoutCustom;
+ qtIconToolbar->setMovable(layoutIsCustom && !Global::get().s.bLockLayout);
// Update the toolbar so the movable flag takes effect.
if (layoutIsCustom) {
@@ -473,8 +470,8 @@ bool MainWindow::nativeEvent(const QByteArray &, void *message, long *) {
void MainWindow::closeEvent(QCloseEvent *e) {
#ifndef Q_OS_MAC
- ServerHandlerPtr sh = g.sh;
- if (sh && sh->isRunning() && g.s.bAskOnQuit && !bSuppressAskOnQuit) {
+ ServerHandlerPtr sh = Global::get().sh;
+ if (sh && sh->isRunning() && Global::get().s.bAskOnQuit && !bSuppressAskOnQuit) {
QMessageBox mb(QMessageBox::Warning, QLatin1String("Mumble"),
tr("Mumble is currently connected to a server. Do you want to Close or Minimize it?"),
QMessageBox::NoButton, this);
@@ -496,20 +493,20 @@ void MainWindow::closeEvent(QCloseEvent *e) {
sh.reset();
#endif
- if (g.s.bMinimalView) {
- g.s.qbaMinimalViewGeometry = saveGeometry();
- g.s.qbaMinimalViewState = saveState();
+ if (Global::get().s.bMinimalView) {
+ Global::get().s.qbaMinimalViewGeometry = saveGeometry();
+ Global::get().s.qbaMinimalViewState = saveState();
} else {
- g.s.qbaMainWindowGeometry = saveGeometry();
- g.s.qbaMainWindowState = saveState();
- g.s.qbaHeaderState = qtvUsers->header()->saveState();
+ Global::get().s.qbaMainWindowGeometry = saveGeometry();
+ Global::get().s.qbaMainWindowState = saveState();
+ Global::get().s.qbaHeaderState = qtvUsers->header()->saveState();
}
- if (g.talkingUI && g.talkingUI->isVisible()) {
+ if (Global::get().talkingUI && Global::get().talkingUI->isVisible()) {
// Save the TalkingUI's position if it is visible
// Note that we explicitly don't save the whole geometry as the TalkingUI's size
// is a flexible thing that'll adjust automatically anyways.
- g.s.qpTalkingUI_Position = g.talkingUI->pos();
+ Global::get().s.qpTalkingUI_Position = Global::get().talkingUI->pos();
}
if (qwPTTButtonWidget) {
@@ -517,7 +514,7 @@ void MainWindow::closeEvent(QCloseEvent *e) {
qwPTTButtonWidget->deleteLater();
qwPTTButtonWidget = nullptr;
}
- g.bQuit = true;
+ Global::get().bQuit = true;
QMainWindow::closeEvent(e);
@@ -526,8 +523,8 @@ void MainWindow::closeEvent(QCloseEvent *e) {
void MainWindow::hideEvent(QHideEvent *e) {
#ifdef USE_OVERLAY
- if (g.ocIntercept) {
- QMetaObject::invokeMethod(g.ocIntercept, "hideGui", Qt::QueuedConnection);
+ if (Global::get().ocIntercept) {
+ QMetaObject::invokeMethod(Global::get().ocIntercept, "hideGui", Qt::QueuedConnection);
e->ignore();
return;
}
@@ -536,7 +533,7 @@ void MainWindow::hideEvent(QHideEvent *e) {
# ifdef Q_OS_UNIX
if (!qApp->activeModalWidget() && !qApp->activePopupWidget())
# endif
- if (g.s.bHideInTray && qstiIcon->isSystemTrayAvailable() && e->spontaneous())
+ if (Global::get().s.bHideInTray && qstiIcon->isSystemTrayAvailable() && e->spontaneous())
QMetaObject::invokeMethod(this, "hide", Qt::QueuedConnection);
#endif
QMainWindow::hideEvent(e);
@@ -547,7 +544,7 @@ void MainWindow::showEvent(QShowEvent *e) {
# ifdef Q_OS_UNIX
if (!qApp->activeModalWidget() && !qApp->activePopupWidget())
# endif
- if (g.s.bHideInTray && qstiIcon->isSystemTrayAvailable() && e->spontaneous())
+ if (Global::get().s.bHideInTray && qstiIcon->isSystemTrayAvailable() && e->spontaneous())
QMetaObject::invokeMethod(this, "show", Qt::QueuedConnection);
#endif
QMainWindow::showEvent(e);
@@ -563,7 +560,7 @@ void MainWindow::changeEvent(QEvent *e) {
// So, let's not do it on macOS.
#else
- if (isMinimized() && qstiIcon->isSystemTrayAvailable() && g.s.bHideInTray) {
+ if (isMinimized() && qstiIcon->isSystemTrayAvailable() && Global::get().s.bHideInTray) {
// Workaround http://qt-project.org/forums/viewthread/4423/P15/#50676
QTimer::singleShot(0, this, SLOT(hide()));
}
@@ -618,21 +615,21 @@ void MainWindow::focusNextMainWidget() {
}
void MainWindow::updateTrayIcon() {
- ClientUser *p = ClientUser::get(g.uiSession);
+ ClientUser *p = ClientUser::get(Global::get().uiSession);
- if (g.s.bDeaf) {
+ if (Global::get().s.bDeaf) {
qstiIcon->setIcon(qiIconDeafSelf);
} else if (p && p->bDeaf) {
qstiIcon->setIcon(qiIconDeafServer);
- } else if (g.s.bMute) {
+ } else if (Global::get().s.bMute) {
qstiIcon->setIcon(qiIconMuteSelf);
} else if (p && p->bMute) {
qstiIcon->setIcon(qiIconMuteServer);
} else if (p && p->bSuppress) {
qstiIcon->setIcon(qiIconMuteSuppressed);
- } else if (g.s.bStateInTray && g.bPushToMute) {
+ } else if (Global::get().s.bStateInTray && Global::get().bPushToMute) {
qstiIcon->setIcon(qiIconMutePushToMute);
- } else if (p && g.s.bStateInTray) {
+ } else if (p && Global::get().s.bStateInTray) {
switch (p->tsState) {
case Settings::Talking:
case Settings::MutedTalking:
@@ -660,7 +657,7 @@ void MainWindow::updateUserModel() {
}
void MainWindow::updateTransmitModeComboBox() {
- switch (g.s.atTransmit) {
+ switch (Global::get().s.atTransmit) {
case Settings::Continuous:
qcbTransmitMode->setCurrentIndex(0);
return;
@@ -674,7 +671,7 @@ void MainWindow::updateTransmitModeComboBox() {
}
QMenu *MainWindow::createPopupMenu() {
- if ((g.s.wlWindowLayout == Settings::LayoutCustom) && !g.s.bLockLayout) {
+ if ((Global::get().s.wlWindowLayout == Settings::LayoutCustom) && !Global::get().s.bLockLayout) {
return QMainWindow::createPopupMenu();
}
@@ -708,7 +705,7 @@ bool MainWindow::handleSpecialContextMenu(const QUrl &url, const QPoint &pos_, b
} else {
QByteArray qbaServerDigest = QByteArray::fromBase64(url.path().remove(0, 1).toLatin1());
cuContextUser = ClientUser::get(url.host().toInt(&ok, 10));
- ServerHandlerPtr sh = g.sh;
+ ServerHandlerPtr sh = Global::get().sh;
ok = ok && sh && (qbaServerDigest == sh->qbaDigest);
}
if (ok && cuContextUser) {
@@ -725,7 +722,7 @@ bool MainWindow::handleSpecialContextMenu(const QUrl &url, const QPoint &pos_, b
bool ok;
QByteArray qbaServerDigest = QByteArray::fromBase64(url.path().remove(0, 1).toLatin1());
cContextChannel = Channel::get(url.host().toInt(&ok, 10));
- ServerHandlerPtr sh = g.sh;
+ ServerHandlerPtr sh = Global::get().sh;
ok = ok && sh && (qbaServerDigest == sh->qbaDigest);
if (ok) {
if (focus) {
@@ -858,60 +855,60 @@ void MainWindow::saveImageAs() {
updateImagePath(fname);
if (!ok) {
- g.l->log(Log::Warning, tr("Could not save image: %1").arg(fname.toHtmlEscaped()));
+ Global::get().l->log(Log::Warning, tr("Could not save image: %1").arg(fname.toHtmlEscaped()));
}
}
QString MainWindow::getImagePath(QString filename) const {
- if (g.s.qsImagePath.isEmpty() || !QDir(g.s.qsImagePath).exists()) {
- g.s.qsImagePath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
+ if (Global::get().s.qsImagePath.isEmpty() || !QDir(Global::get().s.qsImagePath).exists()) {
+ Global::get().s.qsImagePath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
}
if (filename.isEmpty()) {
- return g.s.qsImagePath;
+ return Global::get().s.qsImagePath;
}
- return g.s.qsImagePath + QDir::separator() + filename;
+ return Global::get().s.qsImagePath + QDir::separator() + filename;
}
void MainWindow::updateImagePath(QString filepath) const {
QFileInfo fi(filepath);
- g.s.qsImagePath = fi.absolutePath();
+ Global::get().s.qsImagePath = fi.absolutePath();
}
static void recreateServerHandler() {
// New server connection, so the sync has not happened yet
ChannelListener::setInitialServerSyncDone(false);
- ServerHandlerPtr sh = g.sh;
+ ServerHandlerPtr sh = Global::get().sh;
if (sh && sh->isRunning()) {
- g.mw->on_qaServerDisconnect_triggered();
+ Global::get().mw->on_qaServerDisconnect_triggered();
sh->disconnect();
sh->wait();
QCoreApplication::instance()->processEvents();
}
- g.sh.reset();
+ Global::get().sh.reset();
while (sh && !sh.unique())
QThread::yieldCurrentThread();
sh.reset();
sh = ServerHandlerPtr(new ServerHandler());
sh->moveToThread(sh.get());
- g.sh = sh;
- g.mw->connect(sh.get(), SIGNAL(connected()), g.mw, SLOT(serverConnected()));
- g.mw->connect(sh.get(), SIGNAL(disconnected(QAbstractSocket::SocketError, QString)), g.mw,
+ Global::get().sh = sh;
+ Global::get().mw->connect(sh.get(), SIGNAL(connected()), Global::get().mw, SLOT(serverConnected()));
+ Global::get().mw->connect(sh.get(), SIGNAL(disconnected(QAbstractSocket::SocketError, QString)), Global::get().mw,
SLOT(serverDisconnected(QAbstractSocket::SocketError, QString)));
- g.mw->connect(sh.get(), SIGNAL(error(QAbstractSocket::SocketError, QString)), g.mw,
+ Global::get().mw->connect(sh.get(), SIGNAL(error(QAbstractSocket::SocketError, QString)), Global::get().mw,
SLOT(resolverError(QAbstractSocket::SocketError, QString)));
- QObject::connect(sh.get(), &ServerHandler::disconnected, g.talkingUI, &TalkingUI::on_serverDisconnected);
+ QObject::connect(sh.get(), &ServerHandler::disconnected, Global::get().talkingUI, &TalkingUI::on_serverDisconnected);
}
void MainWindow::openUrl(const QUrl &url) {
- g.l->log(Log::Information, tr("Opening URL %1").arg(url.toString(QUrl::RemovePassword).toHtmlEscaped()));
+ Global::get().l->log(Log::Information, tr("Opening URL %1").arg(url.toString(QUrl::RemovePassword).toHtmlEscaped()));
if (url.scheme() == QLatin1String("file")) {
QFile f(url.toLocalFile());
if (!f.exists() || !f.open(QIODevice::ReadOnly)) {
- g.l->log(Log::Warning, tr("File does not exist"));
+ Global::get().l->log(Log::Warning, tr("File does not exist"));
return;
}
f.close();
@@ -919,19 +916,19 @@ void MainWindow::openUrl(const QUrl &url) {
QSettings *qs = new QSettings(f.fileName(), QSettings::IniFormat);
qs->setIniCodec("UTF-8");
if (qs->status() != QSettings::NoError) {
- g.l->log(Log::Warning, tr("File is not a configuration file."));
+ Global::get().l->log(Log::Warning, tr("File is not a configuration file."));
} else {
- qSwap(qs, g.qs);
- g.s.load();
- qSwap(qs, g.qs);
+ qSwap(qs, Global::get().qs);
+ Global::get().s.load();
+ qSwap(qs, Global::get().qs);
- g.l->log(Log::Warning, tr("Settings merged from file."));
+ Global::get().l->log(Log::Warning, tr("Settings merged from file."));
}
delete qs;
return;
}
if (url.scheme() != QLatin1String("mumble")) {
- g.l->log(Log::Warning, tr("URL scheme is not 'mumble'"));
+ Global::get().l->log(Log::Warning, tr("URL scheme is not 'mumble'"));
return;
}
@@ -949,7 +946,7 @@ void MainWindow::openUrl(const QUrl &url) {
if (version.size() > 0) {
if (!MumbleVersion::get(&major, &minor, &patch, version)) {
// The version format is invalid
- g.l->log(Log::Warning, QObject::tr("The provided URL uses an invalid version format: \"%1\"").arg(version));
+ Global::get().l->log(Log::Warning, QObject::tr("The provided URL uses an invalid version format: \"%1\"").arg(version));
return;
}
}
@@ -965,7 +962,7 @@ void MainWindow::openUrl(const QUrl &url) {
|| (major == thismajor && minor == thisminor && patch > thispatch);
if (isPre_120 || isFuture) {
- g.l->log(Log::Warning, tr("This version of Mumble can't handle URLs for Mumble version %1.%2.%3")
+ Global::get().l->log(Log::Warning, tr("This version of Mumble can't handle URLs for Mumble version %1.%2.%3")
.arg(major)
.arg(minor)
.arg(patch));
@@ -982,11 +979,11 @@ void MainWindow::openUrl(const QUrl &url) {
if (query.hasQueryItem(QLatin1String("title")))
name = query.queryItemValue(QLatin1String("title"));
- if (g.sh && g.sh->isRunning()) {
+ if (Global::get().sh && Global::get().sh->isRunning()) {
QString oHost, oUser, oPw;
unsigned short oport;
- g.sh->getConnectionInfo(oHost, oport, oUser, oPw);
- ClientUser *p = ClientUser::get(g.uiSession);
+ Global::get().sh->getConnectionInfo(oHost, oport, oUser, oPw);
+ ClientUser *p = ClientUser::get(Global::get().uiSession);
if ((user.isEmpty() || (p && p->iId >= 0) || (user == oUser))
&& (host.isEmpty() || ((host == oHost) && (port == oport)))) {
@@ -995,15 +992,15 @@ void MainWindow::openUrl(const QUrl &url) {
}
}
- g.db->fuzzyMatch(name, user, pw, host, port);
+ Global::get().db->fuzzyMatch(name, user, pw, host, port);
if (user.isEmpty()) {
bool ok;
user = QInputDialog::getText(this, tr("Connecting to %1").arg(url.toString()), tr("Enter username"),
- QLineEdit::Normal, g.s.qsUsername, &ok);
+ QLineEdit::Normal, Global::get().s.qsUsername, &ok);
if (!ok || user.isEmpty())
return;
- g.s.qsUsername = user;
+ Global::get().s.qsUsername = user;
}
if (name.isEmpty())
@@ -1011,13 +1008,13 @@ void MainWindow::openUrl(const QUrl &url) {
recreateServerHandler();
- g.s.qsLastServer = name;
+ Global::get().s.qsLastServer = name;
rtLast = MumbleProto::Reject_RejectType_None;
bRetryServer = true;
qaServerDisconnect->setEnabled(true);
- g.l->log(Log::Information, tr("Connecting to server %1.").arg(Log::msgColor(host.toHtmlEscaped(), Log::Server)));
- g.sh->setConnectionInfo(host, port, user, pw);
- g.sh->start(QThread::TimeCriticalPriority);
+ Global::get().l->log(Log::Information, tr("Connecting to server %1.").arg(Log::msgColor(host.toHtmlEscaped(), Log::Server)));
+ Global::get().sh->setConnectionInfo(host, port, user, pw);
+ Global::get().sh->start(QThread::TimeCriticalPriority);
}
/**
@@ -1048,12 +1045,12 @@ void MainWindow::findDesiredChannel() {
}
}
if (found) {
- if (chan != ClientUser::get(g.uiSession)->cChannel) {
- g.sh->joinChannel(g.uiSession, chan->iId);
+ if (chan != ClientUser::get(Global::get().uiSession)->cChannel) {
+ Global::get().sh->joinChannel(Global::get().uiSession, chan->iId);
}
qtvUsers->setCurrentIndex(pmModel->index(chan));
- } else if (g.uiSession) {
- qtvUsers->setCurrentIndex(pmModel->index(ClientUser::get(g.uiSession)->cChannel));
+ } else if (Global::get().uiSession) {
+ qtvUsers->setCurrentIndex(pmModel->index(ClientUser::get(Global::get().uiSession)->cChannel));
}
updateMenuPermissions();
}
@@ -1071,9 +1068,9 @@ void MainWindow::setOnTop(bool top) {
}
void MainWindow::setupView(bool toggle_minimize) {
- bool showit = !g.s.bMinimalView;
+ bool showit = !Global::get().s.bMinimalView;
- switch (g.s.wlWindowLayout) {
+ switch (Global::get().s.wlWindowLayout) {
case Settings::LayoutClassic:
removeDockWidget(qdwLog);
addDockWidget(Qt::LeftDockWidgetArea, qdwLog);
@@ -1108,32 +1105,32 @@ void MainWindow::setupView(bool toggle_minimize) {
if (toggle_minimize) {
if (!showit) {
- g.s.qbaMainWindowGeometry = saveGeometry();
- g.s.qbaMainWindowState = saveState();
- g.s.qbaHeaderState = qtvUsers->header()->saveState();
+ Global::get().s.qbaMainWindowGeometry = saveGeometry();
+ Global::get().s.qbaMainWindowState = saveState();
+ Global::get().s.qbaHeaderState = qtvUsers->header()->saveState();
} else {
- g.s.qbaMinimalViewGeometry = saveGeometry();
- g.s.qbaMinimalViewState = saveState();
+ Global::get().s.qbaMinimalViewGeometry = saveGeometry();
+ Global::get().s.qbaMinimalViewState = saveState();
}
}
Qt::WindowFlags f = Qt::Window;
if (!showit) {
- if (g.s.bHideFrame) {
+ if (Global::get().s.bHideFrame) {
f |= Qt::FramelessWindowHint;
}
}
- if (g.s.aotbAlwaysOnTop == Settings::OnTopAlways
- || (g.s.bMinimalView && g.s.aotbAlwaysOnTop == Settings::OnTopInMinimal)
- || (!g.s.bMinimalView && g.s.aotbAlwaysOnTop == Settings::OnTopInNormal)) {
+ if (Global::get().s.aotbAlwaysOnTop == Settings::OnTopAlways
+ || (Global::get().s.bMinimalView && Global::get().s.aotbAlwaysOnTop == Settings::OnTopInMinimal)
+ || (!Global::get().s.bMinimalView && Global::get().s.aotbAlwaysOnTop == Settings::OnTopInNormal)) {
f |= Qt::WindowStaysOnTopHint;
}
if (!graphicsProxyWidget())
setWindowFlags(f);
- if (g.s.bShowContextMenuInMenuBar) {
+ if (Global::get().s.bShowContextMenuInMenuBar) {
bool found = false;
foreach (QAction *a, menuBar()->actions()) {
if (a == qmUser->menuAction()) {
@@ -1151,7 +1148,7 @@ void MainWindow::setupView(bool toggle_minimize) {
menuBar()->removeAction(qmChannel->menuAction());
}
- if (g.s.bEnableDeveloperMenu) {
+ if (Global::get().s.bEnableDeveloperMenu) {
bool found = false;
foreach (QAction *a, menuBar()->actions()) {
if (a == qmDeveloper->menuAction()) {
@@ -1176,15 +1173,15 @@ void MainWindow::setupView(bool toggle_minimize) {
if (toggle_minimize) {
if (!showit) {
- if (!g.s.qbaMinimalViewGeometry.isNull())
- restoreGeometry(g.s.qbaMinimalViewGeometry);
- if (!g.s.qbaMinimalViewState.isNull())
- restoreState(g.s.qbaMinimalViewState);
+ if (!Global::get().s.qbaMinimalViewGeometry.isNull())
+ restoreGeometry(Global::get().s.qbaMinimalViewGeometry);
+ if (!Global::get().s.qbaMinimalViewState.isNull())
+ restoreState(Global::get().s.qbaMinimalViewState);
} else {
- if (!g.s.qbaMainWindowGeometry.isNull())
- restoreGeometry(g.s.qbaMainWindowGeometry);
- if (!g.s.qbaMainWindowState.isNull())
- restoreState(g.s.qbaMainWindowState);
+ if (!Global::get().s.qbaMainWindowGeometry.isNull())
+ restoreGeometry(Global::get().s.qbaMainWindowGeometry);
+ if (!Global::get().s.qbaMainWindowState.isNull())
+ restoreState(Global::get().s.qbaMainWindowState);
}
} else {
QRect newgeom = frameGeometry();
@@ -1195,7 +1192,7 @@ void MainWindow::setupView(bool toggle_minimize) {
// Display the Transmit Mode Dropdown, if configured to do so, otherwise
// hide it.
- if (g.s.bShowTransmitModeComboBox) {
+ if (Global::get().s.bShowTransmitModeComboBox) {
qaTransmitMode->setVisible(true);
qaTransmitModeSeparator->setVisible(true);
} else {
@@ -1207,7 +1204,7 @@ void MainWindow::setupView(bool toggle_minimize) {
activateWindow();
// If activated show the PTT window
- if (g.s.bShowPTTButtonWindow && g.s.atTransmit == Settings::PushToTalk) {
+ if (Global::get().s.bShowPTTButtonWindow && Global::get().s.atTransmit == Settings::PushToTalk) {
if (qwPTTButtonWidget) {
qwPTTButtonWidget->show();
} else {
@@ -1237,23 +1234,23 @@ void MainWindow::on_qaServerConnect_triggered(bool autoconnect) {
rtLast = MumbleProto::Reject_RejectType_None;
bRetryServer = true;
qaServerDisconnect->setEnabled(true);
- g.l->log(Log::Information,
+ Global::get().l->log(Log::Information,
tr("Connecting to server %1.").arg(Log::msgColor(cd->qsServer.toHtmlEscaped(), Log::Server)));
- g.sh->setConnectionInfo(cd->qsServer, cd->usPort, cd->qsUsername, cd->qsPassword);
- g.sh->start(QThread::TimeCriticalPriority);
+ Global::get().sh->setConnectionInfo(cd->qsServer, cd->usPort, cd->qsUsername, cd->qsPassword);
+ Global::get().sh->start(QThread::TimeCriticalPriority);
}
delete cd;
}
void MainWindow::on_Reconnect_timeout() {
- if (g.sh->isRunning())
+ if (Global::get().sh->isRunning())
return;
- g.l->log(Log::Information, tr("Reconnecting."));
- g.sh->start(QThread::TimeCriticalPriority);
+ Global::get().l->log(Log::Information, tr("Reconnecting."));
+ Global::get().sh->start(QThread::TimeCriticalPriority);
}
void MainWindow::on_qmSelf_aboutToShow() {
- ClientUser *user = ClientUser::get(g.uiSession);
+ ClientUser *user = ClientUser::get(Global::get().uiSession);
qaServerTexture->setEnabled(user != nullptr);
qaSelfComment->setEnabled(user != nullptr);
@@ -1261,9 +1258,9 @@ void MainWindow::on_qmSelf_aboutToShow() {
qaServerTextureRemove->setEnabled(user && !user->qbaTextureHash.isEmpty());
qaSelfRegister->setEnabled(user && (user->iId < 0) && !user->qsHash.isEmpty()
- && (g.pPermissions & (ChanACL::SelfRegister | ChanACL::Write)));
- if (g.sh && g.sh->uiVersion >= 0x010203) {
- qaSelfPrioritySpeaker->setEnabled(user && g.pPermissions & (ChanACL::Write | ChanACL::MuteDeafen));
+ && (Global::get().pPermissions & (ChanACL::SelfRegister | ChanACL::Write)));
+ if (Global::get().sh && Global::get().sh->uiVersion >= 0x010203) {
+ qaSelfPrioritySpeaker->setEnabled(user && Global::get().pPermissions & (ChanACL::Write | ChanACL::MuteDeafen));
qaSelfPrioritySpeaker->setChecked(user && user->bPrioritySpeaker);
} else {
qaSelfPrioritySpeaker->setEnabled(false);
@@ -1272,17 +1269,17 @@ void MainWindow::on_qmSelf_aboutToShow() {
}
void MainWindow::on_qaSelfComment_triggered() {
- ClientUser *p = ClientUser::get(g.uiSession);
+ ClientUser *p = ClientUser::get(Global::get().uiSession);
if (!p)
return;
if (!p->qbaCommentHash.isEmpty() && p->qsComment.isEmpty()) {
- p->qsComment = QString::fromUtf8(g.db->blob(p->qbaCommentHash));
+ p->qsComment = QString::fromUtf8(Global::get().db->blob(p->qbaCommentHash));
if (p->qsComment.isEmpty()) {
pmModel->uiSessionComment = ~(p->uiSession);
MumbleProto::RequestBlob mprb;
mprb.add_session_comment(p->uiSession);
- g.sh->sendMessage(mprb);
+ Global::get().sh->sendMessage(mprb);
return;
}
}
@@ -1301,16 +1298,16 @@ void MainWindow::on_qaSelfComment_triggered() {
MumbleProto::UserState mpus;
mpus.set_session(session);
mpus.set_comment(u8(msg));
- g.sh->sendMessage(mpus);
+ Global::get().sh->sendMessage(mpus);
if (!msg.isEmpty())
- g.db->setBlob(sha1(msg), msg.toUtf8());
+ Global::get().db->setBlob(sha1(msg), msg.toUtf8());
}
delete texm;
}
void MainWindow::on_qaSelfRegister_triggered() {
- ClientUser *p = ClientUser::get(g.uiSession);
+ ClientUser *p = ClientUser::get(Global::get().uiSession);
if (!p)
return;
@@ -1324,24 +1321,24 @@ void MainWindow::on_qaSelfRegister_triggered() {
QMessageBox::Yes | QMessageBox::No);
if (result == QMessageBox::Yes)
- g.sh->registerUser(p->uiSession);
+ Global::get().sh->registerUser(p->uiSession);
}
void MainWindow::qcbTransmitMode_activated(int index) {
switch (index) {
case 0: // Continuous
- g.s.atTransmit = Settings::Continuous;
- g.l->log(Log::Information, tr("Transmit Mode set to Continuous"));
+ Global::get().s.atTransmit = Settings::Continuous;
+ Global::get().l->log(Log::Information, tr("Transmit Mode set to Continuous"));
return;
case 1: // Voice Activity
- g.s.atTransmit = Settings::VAD;
- g.l->log(Log::Information, tr("Transmit Mode set to Voice Activity"));
+ Global::get().s.atTransmit = Settings::VAD;
+ Global::get().l->log(Log::Information, tr("Transmit Mode set to Voice Activity"));
return;
case 2: // Push-to-Talk
- g.s.atTransmit = Settings::PushToTalk;
- g.l->log(Log::Information, tr("Transmit Mode set to Push-to-Talk"));
+ Global::get().s.atTransmit = Settings::PushToTalk;
+ Global::get().l->log(Log::Information, tr("Transmit Mode set to Push-to-Talk"));
return;
}
}
@@ -1365,10 +1362,10 @@ void MainWindow::on_qmServer_aboutToShow() {
#endif
qmServer->addAction(qaQuit);
- qaServerBanList->setEnabled(g.pPermissions & (ChanACL::Ban | ChanACL::Write));
- qaServerUserList->setEnabled(g.pPermissions & (ChanACL::Register | ChanACL::Write));
- qaServerInformation->setEnabled(g.uiSession != 0);
- qaServerTokens->setEnabled(g.uiSession != 0);
+ qaServerBanList->setEnabled(Global::get().pPermissions & (ChanACL::Ban | ChanACL::Write));
+ qaServerUserList->setEnabled(Global::get().pPermissions & (ChanACL::Register | ChanACL::Write));
+ qaServerInformation->setEnabled(Global::get().uiSession != 0);
+ qaServerTokens->setEnabled(Global::get().uiSession != 0);
if (!qlServerActions.isEmpty()) {
qmServer->addSeparator();
@@ -1382,12 +1379,12 @@ void MainWindow::on_qaServerDisconnect_triggered() {
qtReconnect->stop();
qaServerDisconnect->setEnabled(false);
}
- if (g.sh && g.sh->isRunning())
- g.sh->disconnect();
+ if (Global::get().sh && Global::get().sh->isRunning())
+ Global::get().sh->disconnect();
}
void MainWindow::on_qaServerBanList_triggered() {
- g.sh->requestBanList();
+ Global::get().sh->requestBanList();
if (banEdit) {
banEdit->reject();
@@ -1397,7 +1394,7 @@ void MainWindow::on_qaServerBanList_triggered() {
}
void MainWindow::on_qaServerUserList_triggered() {
- g.sh->requestUserList();
+ Global::get().sh->requestUserList();
if (userEdit) {
userEdit->reject();
@@ -1407,11 +1404,11 @@ void MainWindow::on_qaServerUserList_triggered() {
}
static const QString currentCodec() {
- if (g.bOpus)
+ if (Global::get().bOpus)
return QLatin1String("Opus");
- int v = g.bPreferAlpha ? g.iCodecAlpha : g.iCodecBeta;
- CELTCodec *cc = g.qmCodecs.value(v);
+ int v = Global::get().bPreferAlpha ? Global::get().iCodecAlpha : Global::get().iCodecBeta;
+ CELTCodec *cc = Global::get().qmCodecs.value(v);
if (cc)
return QString::fromLatin1("CELT %1").arg(cc->version());
else
@@ -1419,27 +1416,27 @@ static const QString currentCodec() {
}
void MainWindow::on_qaServerInformation_triggered() {
- ConnectionPtr c = g.sh->cConnection;
+ ConnectionPtr c = Global::get().sh->cConnection;
if (!c)
return;
- QSslCipher qsc = g.sh->qscCipher;
+ QSslCipher qsc = Global::get().sh->qscCipher;
- QString qsVersion = tr("<h2>Version</h2><p>Protocol %1</p>").arg(MumbleVersion::toString(g.sh->uiVersion));
+ QString qsVersion = tr("<h2>Version</h2><p>Protocol %1</p>").arg(MumbleVersion::toString(Global::get().sh->uiVersion));
- if (g.sh->qsRelease.isEmpty() || g.sh->qsOS.isEmpty() || g.sh->qsOSVersion.isEmpty()) {
+ if (Global::get().sh->qsRelease.isEmpty() || Global::get().sh->qsOS.isEmpty() || Global::get().sh->qsOSVersion.isEmpty()) {
qsVersion.append(tr("<p>No build information or OS version available</p>"));
} else {
qsVersion.append(
tr("<p>%1 (%2)<br />%3</p>")
- .arg(g.sh->qsRelease.toHtmlEscaped(), g.sh->qsOS.toHtmlEscaped(), g.sh->qsOSVersion.toHtmlEscaped()));
+ .arg(Global::get().sh->qsRelease.toHtmlEscaped(), Global::get().sh->qsOS.toHtmlEscaped(), Global::get().sh->qsOSVersion.toHtmlEscaped()));
}
QString host, uname, pw;
unsigned short port;
- g.sh->getConnectionInfo(host, port, uname, pw);
+ Global::get().sh->getConnectionInfo(host, port, uname, pw);
const SSLCipherInfo *ci = SSLCipherInfoLookupByOpenSSLName(qsc.name().toLatin1().constData());
@@ -1484,11 +1481,11 @@ void MainWindow::on_qaServerInformation_triggered() {
"<p>%4 ms average latency (%5 deviation)</p>"
"<p>Remote host %6 (port %7)</p>")
.arg(c->sessionProtocolString().toHtmlEscaped(), cipherDescription, cipherPFSInfo,
- QString::fromLatin1("%1").arg(boost::accumulators::mean(g.sh->accTCP), 0, 'f', 2),
- QString::fromLatin1("%1").arg(sqrt(boost::accumulators::variance(g.sh->accTCP)), 0, 'f', 2),
+ QString::fromLatin1("%1").arg(boost::accumulators::mean(Global::get().sh->accTCP), 0, 'f', 2),
+ QString::fromLatin1("%1").arg(sqrt(boost::accumulators::variance(Global::get().sh->accTCP)), 0, 'f', 2),
host.toHtmlEscaped(), QString::number(port));
- if (g.uiMaxUsers) {
- qsControl += tr("<p>Connected users: %1/%2</p>").arg(ModelItem::c_qhUsers.count()).arg(g.uiMaxUsers);
+ if (Global::get().uiMaxUsers) {
+ qsControl += tr("<p>Connected users: %1/%2</p>").arg(ModelItem::c_qhUsers.count()).arg(Global::get().uiMaxUsers);
}
QString qsVoice, qsCrypt, qsAudio;
@@ -1498,8 +1495,8 @@ void MainWindow::on_qaServerInformation_triggered() {
} else {
qsVoice = tr("<h2>Voice channel</h2><p>Encrypted with 128 bit OCB-AES128<br />%1 ms average latency (%4 "
"deviation)</p>")
- .arg(boost::accumulators::mean(g.sh->accUDP), 0, 'f', 2)
- .arg(sqrt(boost::accumulators::variance(g.sh->accUDP)), 0, 'f', 2);
+ .arg(boost::accumulators::mean(Global::get().sh->accUDP), 0, 'f', 2)
+ .arg(sqrt(boost::accumulators::variance(Global::get().sh->accUDP)), 0, 'f', 2);
qsCrypt = QString::fromLatin1("<h2>%1</h2><table><tr><th></th><th>%2</th><th>%3</th></tr>"
"<tr><th>%4</th><td>%8</td><td>%12</td></tr>"
"<tr><th>%5</th><td>%9</td><td>%13</td></tr>"
@@ -1523,8 +1520,8 @@ void MainWindow::on_qaServerInformation_triggered() {
.arg(c->csCrypt->uiResync);
}
qsAudio = tr("<h2>Audio bandwidth</h2><p>Maximum %1 kbit/s<br />Current %2 kbit/s<br />Codec: %3</p>")
- .arg(g.iMaxBandwidth / 1000.0, 0, 'f', 1)
- .arg(g.iAudioBandwidth / 1000.0, 0, 'f', 1)
+ .arg(Global::get().iMaxBandwidth / 1000.0, 0, 'f', 1)
+ .arg(Global::get().iAudioBandwidth / 1000.0, 0, 'f', 1)
.arg(currentCodec());
QMessageBox qmb(QMessageBox::Information, tr("Mumble Server Information"),
@@ -1535,7 +1532,7 @@ void MainWindow::on_qaServerInformation_triggered() {
QPushButton *qp = qmb.addButton(tr("&View Certificate"), QMessageBox::ActionRole);
int res = qmb.exec();
if ((res == 0) && (qmb.clickedButton() == qp)) {
- ViewCert vc(g.sh->qscCert, this);
+ ViewCert vc(Global::get().sh->qscCert, this);
vc.exec();
}
}
@@ -1548,11 +1545,11 @@ void MainWindow::on_qaServerTexture_triggered() {
const QImage &img = choice.second;
if ((img.height() <= 1024) && (img.width() <= 1024))
- g.sh->setUserTexture(g.uiSession, choice.first);
+ Global::get().sh->setUserTexture(Global::get().uiSession, choice.first);
}
void MainWindow::on_qaServerTextureRemove_triggered() {
- g.sh->setUserTexture(g.uiSession, QByteArray());
+ Global::get().sh->setUserTexture(Global::get().uiSession, QByteArray());
}
void MainWindow::on_qaServerTokens_triggered() {
@@ -1573,7 +1570,7 @@ void MainWindow::voiceRecorderDialog_finished(int) {
void MainWindow::qmUser_aboutToShow() {
ClientUser *p = nullptr;
- if (g.uiSession != 0) {
+ if (Global::get().uiSession != 0) {
QModelIndex idx;
if (!qpContextPosition.isNull())
idx = qtvUsers->indexAt(qpContextPosition);
@@ -1590,7 +1587,7 @@ void MainWindow::qmUser_aboutToShow() {
cuContextUser = p;
qpContextPosition = QPoint();
- const ClientUser *self = ClientUser::get(g.uiSession);
+ const ClientUser *self = ClientUser::get(Global::get().uiSession);
bool isSelf = p == self;
qmUser->clear();
@@ -1602,17 +1599,17 @@ void MainWindow::qmUser_aboutToShow() {
qmUser->addSeparator();
}
- if (g.pPermissions & (ChanACL::Kick | ChanACL::Ban | ChanACL::Write))
+ if (Global::get().pPermissions & (ChanACL::Kick | ChanACL::Ban | ChanACL::Write))
qmUser->addAction(qaUserKick);
- if (g.pPermissions & (ChanACL::Ban | ChanACL::Write))
+ if (Global::get().pPermissions & (ChanACL::Ban | ChanACL::Write))
qmUser->addAction(qaUserBan);
qmUser->addAction(qaUserMute);
qmUser->addAction(qaUserDeaf);
- if (g.sh && g.sh->uiVersion >= 0x010203)
+ if (Global::get().sh && Global::get().sh->uiVersion >= 0x010203)
qmUser->addAction(qaUserPrioritySpeaker);
qmUser->addAction(qaUserLocalMute);
qmUser->addAction(qaUserLocalIgnore);
- if (g.s.bTTS)
+ if (Global::get().s.bTTS)
qmUser->addAction(qaUserLocalIgnoreTTS);
qmUser->addAction(qaUserLocalVolume);
qmUser->addAction(qaUserLocalNickname);
@@ -1626,16 +1623,16 @@ void MainWindow::qmUser_aboutToShow() {
}
qmUser->addAction(qaUserTextMessage);
- if (g.sh && g.sh->uiVersion >= 0x010202)
+ if (Global::get().sh && Global::get().sh->uiVersion >= 0x010202)
qmUser->addAction(qaUserInformation);
if (p && (p->iId < 0) && !p->qsHash.isEmpty()
- && (g.pPermissions & ((isSelf ? ChanACL::SelfRegister : ChanACL::Register) | ChanACL::Write))) {
+ && (Global::get().pPermissions & ((isSelf ? ChanACL::SelfRegister : ChanACL::Register) | ChanACL::Write))) {
qmUser->addSeparator();
qmUser->addAction(qaUserRegister);
}
- if (p && !p->qsHash.isEmpty() && (!p->qsFriendName.isEmpty() || (p->uiSession != g.uiSession))) {
+ if (p && !p->qsHash.isEmpty() && (!p->qsFriendName.isEmpty() || (p->uiSession != Global::get().uiSession))) {
qmUser->addSeparator();
if (p->qsFriendName.isEmpty())
qmUser->addAction(qaUserFriendAdd);
@@ -1653,7 +1650,7 @@ void MainWindow::qmUser_aboutToShow() {
}
#ifndef Q_OS_MAC
- if (g.s.bMinimalView) {
+ if (Global::get().s.bMinimalView) {
qmUser->addSeparator();
qmUser->addMenu(qmServer);
qmUser->addMenu(qmSelf);
@@ -1691,16 +1688,16 @@ void MainWindow::qmUser_aboutToShow() {
qaUserLocalIgnoreTTS->setEnabled(!isSelf);
// If the server's version is less than 1.4.0 it won't support the new permission to reset a comment/avatar, so
// fall back to the old method
- if (g.sh->uiVersion < 0x010400) {
+ if (Global::get().sh->uiVersion < 0x010400) {
qaUserCommentReset->setEnabled(!p->qbaCommentHash.isEmpty()
- && (g.pPermissions & (ChanACL::Move | ChanACL::Write)));
+ && (Global::get().pPermissions & (ChanACL::Move | ChanACL::Write)));
qaUserTextureReset->setEnabled(!p->qbaTextureHash.isEmpty()
- && (g.pPermissions & (ChanACL::Move | ChanACL::Write)));
+ && (Global::get().pPermissions & (ChanACL::Move | ChanACL::Write)));
} else {
qaUserCommentReset->setEnabled(!p->qbaCommentHash.isEmpty()
- && (g.pPermissions & (ChanACL::ResetUserContent | ChanACL::Write)));
+ && (Global::get().pPermissions & (ChanACL::ResetUserContent | ChanACL::Write)));
qaUserTextureReset->setEnabled(!p->qbaTextureHash.isEmpty()
- && (g.pPermissions & (ChanACL::ResetUserContent | ChanACL::Write)));
+ && (Global::get().pPermissions & (ChanACL::ResetUserContent | ChanACL::Write)));
}
qaUserCommentView->setEnabled(!p->qbaCommentHash.isEmpty());
@@ -1716,7 +1713,7 @@ void MainWindow::qmUser_aboutToShow() {
void MainWindow::qmListener_aboutToShow() {
ClientUser *p = nullptr;
- if (g.uiSession != 0) {
+ if (Global::get().uiSession != 0) {
QModelIndex idx;
if (!qpContextPosition.isNull())
idx = qtvUsers->indexAt(qpContextPosition);
@@ -1733,7 +1730,7 @@ void MainWindow::qmListener_aboutToShow() {
cuContextUser = p;
qpContextPosition = QPoint();
- bool self = p && (p->uiSession == g.uiSession);
+ bool self = p && (p->uiSession == Global::get().uiSession);
qmListener->clear();
@@ -1741,7 +1738,7 @@ void MainWindow::qmListener_aboutToShow() {
qmListener->addAction(qaListenerLocalVolume);
if (cContextChannel) {
qmListener->addAction(qaChannelListen);
- qaChannelListen->setChecked(ChannelListener::isListening(g.uiSession, cContextChannel->iId));
+ qaChannelListen->setChecked(ChannelListener::isListening(Global::get().uiSession, cContextChannel->iId));
}
} else {
qmListener->addAction(qaEmpty);
@@ -1763,7 +1760,7 @@ void MainWindow::on_qaUserMute_triggered() {
} else {
mpus.set_mute(true);
}
- g.sh->sendMessage(mpus);
+ Global::get().sh->sendMessage(mpus);
}
void MainWindow::on_qaUserLocalMute_triggered() {
@@ -1776,7 +1773,7 @@ void MainWindow::on_qaUserLocalMute_triggered() {
p->setLocalMute(muted);
if (!p->qsHash.isEmpty()) {
- g.db->setLocalMuted(p->qsHash, muted);
+ Global::get().db->setLocalMuted(p->qsHash, muted);
} else {
logChangeNotPermanent(QObject::tr("Local Mute"), p);
}
@@ -1792,7 +1789,7 @@ void MainWindow::on_qaUserLocalIgnore_triggered() {
p->setLocalIgnore(ignored);
if (!p->qsHash.isEmpty()) {
- g.db->setLocalIgnored(p->qsHash, ignored);
+ Global::get().db->setLocalIgnored(p->qsHash, ignored);
} else {
logChangeNotPermanent(QObject::tr("Ignore Messages"), p);
}
@@ -1808,7 +1805,7 @@ void MainWindow::on_qaUserLocalIgnoreTTS_triggered() {
p->setLocalIgnoreTTS(ignoredTTS);
if (!p->qsHash.isEmpty()) {
- g.db->setLocalIgnoredTTS(p->qsHash, ignoredTTS);
+ Global::get().db->setLocalIgnoredTTS(p->qsHash, ignoredTTS);
} else {
logChangeNotPermanent(QObject::tr("Disable Text-To-Speech"), p);
}
@@ -1835,18 +1832,18 @@ void MainWindow::on_qaUserDeaf_triggered() {
MumbleProto::UserState mpus;
mpus.set_session(p->uiSession);
mpus.set_deaf(!p->bDeaf);
- g.sh->sendMessage(mpus);
+ Global::get().sh->sendMessage(mpus);
}
void MainWindow::on_qaSelfPrioritySpeaker_triggered() {
- ClientUser *p = ClientUser::get(g.uiSession);
+ ClientUser *p = ClientUser::get(Global::get().uiSession);
if (!p)
return;
MumbleProto::UserState mpus;
mpus.set_session(p->uiSession);
mpus.set_priority_speaker(!p->bPrioritySpeaker);
- g.sh->sendMessage(mpus);
+ Global::get().sh->sendMessage(mpus);
}
void MainWindow::on_qaUserPrioritySpeaker_triggered() {
@@ -1857,7 +1854,7 @@ void MainWindow::on_qaUserPrioritySpeaker_triggered() {
MumbleProto::UserState mpus;
mpus.set_session(p->uiSession);
mpus.set_priority_speaker(!p->bPrioritySpeaker);
- g.sh->sendMessage(mpus);
+ Global::get().sh->sendMessage(mpus);
}
void MainWindow::on_qaUserRegister_triggered() {
@@ -1869,7 +1866,7 @@ void MainWindow::on_qaUserRegister_triggered() {
QMessageBox::StandardButton result;
- if (session == g.uiSession)
+ if (session == Global::get().uiSession)
result = QMessageBox::question(
this, tr("Register yourself as %1").arg(p->qsName),
tr("<p>You are about to register yourself on this server. This action cannot be undone, and your username "
@@ -1891,7 +1888,7 @@ void MainWindow::on_qaUserRegister_triggered() {
p = ClientUser::get(session);
if (!p)
return;
- g.sh->registerUser(p->uiSession);
+ Global::get().sh->registerUser(p->uiSession);
}
}
@@ -1900,7 +1897,7 @@ void MainWindow::on_qaUserFriendAdd_triggered() {
if (!p)
return;
- g.db->addFriend(p->qsName, p->qsHash);
+ Global::get().db->addFriend(p->qsName, p->qsHash);
pmModel->setFriendName(p, p->qsName);
}
@@ -1913,7 +1910,7 @@ void MainWindow::on_qaUserFriendRemove_triggered() {
if (!p)
return;
- g.db->removeFriend(p->qsHash);
+ Global::get().db->removeFriend(p->qsHash);
pmModel->setFriendName(p, QString());
}
@@ -1933,7 +1930,7 @@ void MainWindow::on_qaUserKick_triggered() {
return;
if (ok) {
- g.sh->kickBanUser(p->uiSession, reason, false);
+ Global::get().sh->kickBanUser(p->uiSession, reason, false);
}
}
@@ -1952,7 +1949,7 @@ void MainWindow::on_qaUserBan_triggered() {
return;
if (ok) {
- g.sh->kickBanUser(p->uiSession, reason, true);
+ Global::get().sh->kickBanUser(p->uiSession, reason, true);
}
}
@@ -1979,8 +1976,8 @@ void MainWindow::openTextMessageDialog(ClientUser *p) {
QString msg = texm->message();
if (!msg.isEmpty()) {
- g.sh->sendUserTextMessage(p->uiSession, msg);
- g.l->log(Log::TextMessage, tr("To %1: %2").arg(Log::formatClientUser(p, Log::Target), texm->message()),
+ Global::get().sh->sendUserTextMessage(p->uiSession, msg);
+ Global::get().l->log(Log::TextMessage, tr("To %1: %2").arg(Log::formatClientUser(p, Log::Target), texm->message()),
tr("Message to %1").arg(p->qsName), true);
}
}
@@ -2010,12 +2007,12 @@ void MainWindow::on_qaUserCommentView_triggered() {
return;
if (!p->qbaCommentHash.isEmpty() && p->qsComment.isEmpty()) {
- p->qsComment = QString::fromUtf8(g.db->blob(p->qbaCommentHash));
+ p->qsComment = QString::fromUtf8(Global::get().db->blob(p->qbaCommentHash));
if (p->qsComment.isEmpty()) {
pmModel->uiSessionComment = ~(p->uiSession);
MumbleProto::RequestBlob mprb;
mprb.add_session_comment(p->uiSession);
- g.sh->sendMessage(mprb);
+ Global::get().sh->sendMessage(mprb);
return;
}
}
@@ -2042,7 +2039,7 @@ void MainWindow::on_qaUserCommentReset_triggered() {
tr("Are you sure you want to reset the comment of user %1?").arg(p->qsName.toHtmlEscaped()), QMessageBox::Yes,
QMessageBox::No);
if (ret == QMessageBox::Yes) {
- g.sh->setUserComment(session, QString());
+ Global::get().sh->setUserComment(session, QString());
}
}
@@ -2059,7 +2056,7 @@ void MainWindow::on_qaUserTextureReset_triggered() {
tr("Are you sure you want to reset the avatar of user %1?").arg(p->qsName.toHtmlEscaped()), QMessageBox::Yes,
QMessageBox::No);
if (ret == QMessageBox::Yes) {
- g.sh->setUserTexture(session, QByteArray());
+ Global::get().sh->setUserTexture(session, QByteArray());
}
}
@@ -2069,7 +2066,7 @@ void MainWindow::on_qaUserInformation_triggered() {
if (!p)
return;
- g.sh->requestUserStats(p->uiSession, false);
+ Global::get().sh->requestUserStats(p->uiSession, false);
}
void MainWindow::on_qaHide_triggered() {
@@ -2090,24 +2087,24 @@ void MainWindow::sendChatbarText(QString qsText) {
}
void MainWindow::sendChatbarMessage(QString qsMessage) {
- if (g.uiSession == 0)
+ if (Global::get().uiSession == 0)
return; // Check if text & connection is available
ClientUser *p = pmModel->getUser(qtvUsers->currentIndex());
Channel *c = pmModel->getChannel(qtvUsers->currentIndex());
- if (!g.s.bChatBarUseSelection || !p || p->uiSession == g.uiSession) {
+ if (!Global::get().s.bChatBarUseSelection || !p || p->uiSession == Global::get().uiSession) {
// Channel message
- if (!g.s.bChatBarUseSelection || !c) // If no channel selected fallback to current one
- c = ClientUser::get(g.uiSession)->cChannel;
+ if (!Global::get().s.bChatBarUseSelection || !c) // If no channel selected fallback to current one
+ c = ClientUser::get(Global::get().uiSession)->cChannel;
- g.sh->sendChannelTextMessage(c->iId, qsMessage, false);
- g.l->log(Log::TextMessage, tr("To %1: %2").arg(Log::formatChannel(c), qsMessage),
+ Global::get().sh->sendChannelTextMessage(c->iId, qsMessage, false);
+ Global::get().l->log(Log::TextMessage, tr("To %1: %2").arg(Log::formatChannel(c), qsMessage),
tr("Message to channel %1").arg(c->qsName), true);
} else {
// User message
- g.sh->sendUserTextMessage(p->uiSession, qsMessage);
- g.l->log(Log::TextMessage, tr("To %1: %2").arg(Log::formatClientUser(p, Log::Target), qsMessage),
+ Global::get().sh->sendUserTextMessage(p->uiSession, qsMessage);
+ Global::get().l->log(Log::TextMessage, tr("To %1: %2").arg(Log::formatClientUser(p, Log::Target), qsMessage),
tr("Message to %1").arg(p->qsName), true);
}
}
@@ -2150,10 +2147,10 @@ void MainWindow::on_qmConfig_aboutToShow() {
qmConfig->addSeparator();
qmConfig->addAction(qaConfigMinimal);
- qaTalkingUIToggle->setChecked(g.talkingUI && g.talkingUI->isVisible());
+ qaTalkingUIToggle->setChecked(Global::get().talkingUI && Global::get().talkingUI->isVisible());
qmConfig->addAction(qaTalkingUIToggle);
- if (g.s.bMinimalView)
+ if (Global::get().s.bMinimalView)
qmConfig->addAction(qaConfigHideFrame);
}
@@ -2161,7 +2158,7 @@ void MainWindow::qmChannel_aboutToShow() {
qmChannel->clear();
Channel *c = nullptr;
- if (g.uiSession != 0) {
+ if (Global::get().uiSession != 0) {
QModelIndex idx;
if (!qpContextPosition.isNull())
idx = qtvUsers->indexAt(qpContextPosition);
@@ -2178,17 +2175,17 @@ void MainWindow::qmChannel_aboutToShow() {
cContextChannel = c;
qpContextPosition = QPoint();
- if (c && c->iId != ClientUser::get(g.uiSession)->cChannel->iId) {
+ if (c && c->iId != ClientUser::get(Global::get().uiSession)->cChannel->iId) {
qmChannel->addAction(qaChannelJoin);
qmChannel->addSeparator();
}
- if (c && g.sh && g.sh->uiVersion >= 0x010400) {
+ if (c && Global::get().sh && Global::get().sh->uiVersion >= 0x010400) {
// If the server's version is less than 1.4, the listening feature is not supported yet
// and thus it doesn't make sense to show the action for it
qmChannel->addAction(qaChannelListen);
- qaChannelListen->setChecked(ChannelListener::isListening(g.uiSession, c->iId));
+ qaChannelListen->setChecked(ChannelListener::isListening(Global::get().uiSession, c->iId));
}
qmChannel->addSeparator();
@@ -2211,7 +2208,7 @@ void MainWindow::qmChannel_aboutToShow() {
}
#ifndef Q_OS_MAC
- if (g.s.bMinimalView) {
+ if (Global::get().s.bMinimalView) {
qmChannel->addSeparator();
qmChannel->addMenu(qmServer);
qmChannel->addMenu(qmSelf);
@@ -2229,12 +2226,12 @@ void MainWindow::qmChannel_aboutToShow() {
bool add, remove, acl, link, unlink, unlinkall, msg;
add = remove = acl = link = unlink = unlinkall = msg = false;
- if (g.uiSession != 0) {
+ if (Global::get().uiSession != 0) {
add = true;
acl = true;
msg = true;
- Channel *home = ClientUser::get(g.uiSession)->cChannel;
+ Channel *home = ClientUser::get(Global::get().uiSession)->cChannel;
if (c && c->iId != 0) {
remove = true;
@@ -2267,7 +2264,7 @@ void MainWindow::on_qaChannelJoin_triggered() {
Channel *c = getContextMenuChannel();
if (c) {
- g.sh->joinChannel(g.uiSession, c->iId);
+ Global::get().sh->joinChannel(Global::get().uiSession, c->iId);
}
}
@@ -2278,7 +2275,7 @@ void MainWindow::on_qaUserJoin_triggered() {
const Channel *channel = user->cChannel;
if (channel) {
- g.sh->joinChannel(g.uiSession, channel->iId);
+ Global::get().sh->joinChannel(Global::get().uiSession, channel->iId);
}
}
}
@@ -2288,9 +2285,9 @@ void MainWindow::on_qaChannelListen_triggered() {
if (c) {
if (qaChannelListen->isChecked()) {
- g.sh->startListeningToChannel(c->iId);
+ Global::get().sh->startListeningToChannel(c->iId);
} else {
- g.sh->stopListeningToChannel(c->iId);
+ Global::get().sh->stopListeningToChannel(c->iId);
}
}
}
@@ -2339,7 +2336,7 @@ void MainWindow::on_qaChannelRemove_triggered() {
return;
if (ret == QMessageBox::Yes) {
- g.sh->removeChannel(c->iId);
+ Global::get().sh->removeChannel(c->iId);
}
}
@@ -2350,15 +2347,15 @@ void MainWindow::on_qaChannelACL_triggered() {
int id = c->iId;
if (!c->qbaDescHash.isEmpty() && c->qsDesc.isEmpty()) {
- c->qsDesc = QString::fromUtf8(g.db->blob(c->qbaDescHash));
+ c->qsDesc = QString::fromUtf8(Global::get().db->blob(c->qbaDescHash));
if (c->qsDesc.isEmpty()) {
MumbleProto::RequestBlob mprb;
mprb.add_channel_description(id);
- g.sh->sendMessage(mprb);
+ Global::get().sh->sendMessage(mprb);
}
}
- g.sh->requestACL(id);
+ Global::get().sh->requestACL(id);
if (aclEdit) {
aclEdit->reject();
@@ -2368,31 +2365,31 @@ void MainWindow::on_qaChannelACL_triggered() {
}
void MainWindow::on_qaChannelLink_triggered() {
- Channel *c = ClientUser::get(g.uiSession)->cChannel;
+ Channel *c = ClientUser::get(Global::get().uiSession)->cChannel;
Channel *l = getContextMenuChannel();
if (!l)
l = Channel::get(0);
- g.sh->addChannelLink(c->iId, l->iId);
+ Global::get().sh->addChannelLink(c->iId, l->iId);
}
void MainWindow::on_qaChannelUnlink_triggered() {
- Channel *c = ClientUser::get(g.uiSession)->cChannel;
+ Channel *c = ClientUser::get(Global::get().uiSession)->cChannel;
Channel *l = getContextMenuChannel();
if (!l)
l = Channel::get(0);
- g.sh->removeChannelLink(c->iId, l->iId);
+ Global::get().sh->removeChannelLink(c->iId, l->iId);
}
void MainWindow::on_qaChannelUnlinkAll_triggered() {
- Channel *c = ClientUser::get(g.uiSession)->cChannel;
+ Channel *c = ClientUser::get(Global::get().uiSession)->cChannel;
MumbleProto::ChannelState mpcs;
mpcs.set_channel_id(c->iId);
foreach (Channel *l, c->qsPermLinks)
mpcs.add_links_remove(l->iId);
- g.sh->sendMessage(mpcs);
+ Global::get().sh->sendMessage(mpcs);
}
void MainWindow::on_qaChannelSendMessage_triggered() {
@@ -2409,13 +2406,13 @@ void MainWindow::on_qaChannelSendMessage_triggered() {
c = Channel::get(id);
if (c && (res == QDialog::Accepted)) {
- g.sh->sendChannelTextMessage(id, texm->message(), texm->bTreeMessage);
+ Global::get().sh->sendChannelTextMessage(id, texm->message(), texm->bTreeMessage);
if (texm->bTreeMessage)
- g.l->log(Log::TextMessage, tr("To %1 (Tree): %2").arg(Log::formatChannel(c), texm->message()),
+ Global::get().l->log(Log::TextMessage, tr("To %1 (Tree): %2").arg(Log::formatChannel(c), texm->message()),
tr("Message to tree %1").arg(c->qsName), true);
else
- g.l->log(Log::TextMessage, tr("To %1: %2").arg(Log::formatChannel(c), texm->message()),
+ Global::get().l->log(Log::TextMessage, tr("To %1: %2").arg(Log::formatChannel(c), texm->message()),
tr("Message to channel %1").arg(c->qsName), true);
}
delete texm;
@@ -2429,7 +2426,7 @@ void MainWindow::on_qaChannelCopyURL_triggered() {
if (!c)
return;
- g.sh->getConnectionInfo(host, port, uname, pw);
+ Global::get().sh->getConnectionInfo(host, port, uname, pw);
// walk back up the channel list to build the URL.
while (c->cParent) {
channel.prepend(c->qsName);
@@ -2463,7 +2460,7 @@ void MainWindow::updateMenuPermissions() {
ClientUser *cu = nullptr;
Channel *c = nullptr;
- if (g.uiSession) {
+ if (Global::get().uiSession) {
cu = getContextMenuUser();
if (!cu)
cu = pmModel->getUser(qtvUsers->currentIndex());
@@ -2476,9 +2473,9 @@ void MainWindow::updateMenuPermissions() {
ChanACL::Permissions p = c ? static_cast< ChanACL::Permissions >(c->uiPermissions) : ChanACL::None;
if (c && !p) {
- g.sh->requestChannelPermissions(c->iId);
+ Global::get().sh->requestChannelPermissions(c->iId);
if (c->iId == 0)
- p = g.pPermissions;
+ p = Global::get().pPermissions;
else
p = ChanACL::All;
@@ -2490,23 +2487,23 @@ void MainWindow::updateMenuPermissions() {
cparent ? static_cast< ChanACL::Permissions >(cparent->uiPermissions) : ChanACL::None;
if (cparent && !pparent) {
- g.sh->requestChannelPermissions(cparent->iId);
+ Global::get().sh->requestChannelPermissions(cparent->iId);
if (cparent->iId == 0)
- pparent = g.pPermissions;
+ pparent = Global::get().pPermissions;
else
pparent = ChanACL::All;
cparent->uiPermissions = pparent;
}
- ClientUser *user = g.uiSession ? ClientUser::get(g.uiSession) : nullptr;
+ ClientUser *user = Global::get().uiSession ? ClientUser::get(Global::get().uiSession) : nullptr;
Channel *homec = user ? user->cChannel : nullptr;
ChanACL::Permissions homep = homec ? static_cast< ChanACL::Permissions >(homec->uiPermissions) : ChanACL::None;
if (homec && !homep) {
- g.sh->requestChannelPermissions(homec->iId);
+ Global::get().sh->requestChannelPermissions(homec->iId);
if (homec->iId == 0)
- homep = g.pPermissions;
+ homep = Global::get().pPermissions;
else
homep = ChanACL::All;
@@ -2519,7 +2516,7 @@ void MainWindow::updateMenuPermissions() {
qaUserDeaf->setEnabled(p & (ChanACL::Write | ChanACL::MuteDeafen) && ((cu != user) || cu->bDeaf));
qaUserPrioritySpeaker->setEnabled(p & (ChanACL::Write | ChanACL::MuteDeafen));
qaUserTextMessage->setEnabled(p & (ChanACL::Write | ChanACL::TextMessage));
- qaUserInformation->setEnabled((g.pPermissions & (ChanACL::Write | ChanACL::Register))
+ qaUserInformation->setEnabled((Global::get().pPermissions & (ChanACL::Write | ChanACL::Register))
|| (p & (ChanACL::Write | ChanACL::Enter)) || (cu == user));
} else {
qaUserMute->setEnabled(false);
@@ -2548,14 +2545,14 @@ void MainWindow::updateMenuPermissions() {
}
void MainWindow::userStateChanged() {
- if (g.s.bStateInTray) {
+ if (Global::get().s.bStateInTray) {
updateTrayIcon();
}
- ClientUser *user = ClientUser::get(g.uiSession);
+ ClientUser *user = ClientUser::get(Global::get().uiSession);
if (!user) {
- g.bAttenuateOthers = false;
- g.prioritySpeakerActiveOverride = false;
+ Global::get().bAttenuateOthers = false;
+ Global::get().prioritySpeakerActiveOverride = false;
return;
}
@@ -2564,62 +2561,62 @@ void MainWindow::userStateChanged() {
case Settings::Talking:
case Settings::Whispering:
case Settings::Shouting:
- g.bAttenuateOthers = g.s.bAttenuateOthersOnTalk;
+ Global::get().bAttenuateOthers = Global::get().s.bAttenuateOthersOnTalk;
- g.prioritySpeakerActiveOverride = g.s.bAttenuateUsersOnPrioritySpeak && user->bPrioritySpeaker;
+ Global::get().prioritySpeakerActiveOverride = Global::get().s.bAttenuateUsersOnPrioritySpeak && user->bPrioritySpeaker;
break;
case Settings::Passive:
case Settings::MutedTalking:
default:
- g.bAttenuateOthers = false;
- g.prioritySpeakerActiveOverride = false;
+ Global::get().bAttenuateOthers = false;
+ Global::get().prioritySpeakerActiveOverride = false;
break;
}
}
void MainWindow::on_qaAudioReset_triggered() {
- AudioInputPtr ai = g.ai;
+ AudioInputPtr ai = Global::get().ai;
if (ai)
ai->bResetProcessor = true;
}
void MainWindow::on_qaFilterToggle_triggered() {
- g.s.bFilterActive = qaFilterToggle->isChecked();
+ Global::get().s.bFilterActive = qaFilterToggle->isChecked();
updateUserModel();
}
void MainWindow::on_qaAudioMute_triggered() {
- if (g.bInAudioWizard) {
+ if (Global::get().bInAudioWizard) {
qaAudioMute->setChecked(!qaAudioMute->isChecked());
return;
}
- AudioInputPtr ai = g.ai;
+ AudioInputPtr ai = Global::get().ai;
if (ai)
ai->tIdle.restart();
- g.s.bMute = qaAudioMute->isChecked();
+ Global::get().s.bMute = qaAudioMute->isChecked();
- if (!g.s.bMute && g.s.bDeaf) {
- g.s.bDeaf = false;
+ if (!Global::get().s.bMute && Global::get().s.bDeaf) {
+ Global::get().s.bDeaf = false;
qaAudioDeaf->setChecked(false);
- g.l->log(Log::SelfUndeaf, tr("Unmuted and undeafened."));
- } else if (!g.s.bMute) {
- g.l->log(Log::SelfUnmute, tr("Unmuted."));
+ Global::get().l->log(Log::SelfUndeaf, tr("Unmuted and undeafened."));
+ } else if (!Global::get().s.bMute) {
+ Global::get().l->log(Log::SelfUnmute, tr("Unmuted."));
} else {
- g.l->log(Log::SelfMute, tr("Muted."));
+ Global::get().l->log(Log::SelfMute, tr("Muted."));
}
- if (g.sh) {
- g.sh->setSelfMuteDeafState(g.s.bMute, g.s.bDeaf);
+ if (Global::get().sh) {
+ Global::get().sh->setSelfMuteDeafState(Global::get().s.bMute, Global::get().s.bDeaf);
}
updateTrayIcon();
}
void MainWindow::on_qaAudioDeaf_triggered() {
- if (g.bInAudioWizard) {
+ if (Global::get().bInAudioWizard) {
qaAudioDeaf->setChecked(!qaAudioDeaf->isChecked());
return;
}
@@ -2630,25 +2627,25 @@ void MainWindow::on_qaAudioDeaf_triggered() {
on_qaAudioMute_triggered();
return;
}
- AudioInputPtr ai = g.ai;
+ AudioInputPtr ai = Global::get().ai;
if (ai)
ai->tIdle.restart();
- g.s.bDeaf = qaAudioDeaf->isChecked();
- if (g.s.bDeaf && !g.s.bMute) {
+ Global::get().s.bDeaf = qaAudioDeaf->isChecked();
+ if (Global::get().s.bDeaf && !Global::get().s.bMute) {
bAutoUnmute = true;
- g.s.bMute = true;
+ Global::get().s.bMute = true;
qaAudioMute->setChecked(true);
- g.l->log(Log::SelfDeaf, tr("Muted and deafened."));
- } else if (g.s.bDeaf) {
- g.l->log(Log::SelfDeaf, tr("Deafened."));
+ Global::get().l->log(Log::SelfDeaf, tr("Muted and deafened."));
+ } else if (Global::get().s.bDeaf) {
+ Global::get().l->log(Log::SelfDeaf, tr("Deafened."));
bAutoUnmute = false;
} else {
- g.l->log(Log::SelfUndeaf, tr("Undeafened."));
+ Global::get().l->log(Log::SelfUndeaf, tr("Undeafened."));
}
- if (g.sh) {
- g.sh->setSelfMuteDeafState(g.s.bMute, g.s.bDeaf);
+ if (Global::get().sh) {
+ Global::get().sh->setSelfMuteDeafState(Global::get().s.bMute, Global::get().s.bDeaf);
}
updateTrayIcon();
@@ -2667,7 +2664,7 @@ void MainWindow::on_qaRecording_triggered() {
}
void MainWindow::on_qaAudioTTS_triggered() {
- g.s.bTTS = qaAudioTTS->isChecked();
+ Global::get().s.bTTS = qaAudioTTS->isChecked();
}
void MainWindow::on_qaAudioStats_triggered() {
@@ -2676,13 +2673,13 @@ void MainWindow::on_qaAudioStats_triggered() {
}
void MainWindow::on_qaAudioUnlink_triggered() {
- g.p->bUnlink = true;
+ Global::get().p->bUnlink = true;
}
void MainWindow::on_qaConfigDialog_triggered() {
ConfigDialog *dlg = new ConfigDialog(this);
- QObject::connect(dlg, &ConfigDialog::settingsAccepted, g.talkingUI, &TalkingUI::on_settingsChanged);
+ QObject::connect(dlg, &ConfigDialog::settingsAccepted, Global::get().talkingUI, &TalkingUI::on_settingsChanged);
if (dlg->exec() == QDialog::Accepted) {
setupView(false);
@@ -2690,8 +2687,8 @@ void MainWindow::on_qaConfigDialog_triggered() {
updateTrayIcon();
updateUserModel();
- if (g.s.requireRestartToApply) {
- if (g.s.requireRestartToApply
+ if (Global::get().s.requireRestartToApply) {
+ if (Global::get().s.requireRestartToApply
&& QMessageBox::question(
this, tr("Restart Mumble?"),
tr("Some settings will only apply after a restart of Mumble. Restart Mumble now?"),
@@ -2709,13 +2706,13 @@ void MainWindow::on_qaConfigDialog_triggered() {
}
void MainWindow::on_qaConfigMinimal_triggered() {
- g.s.bMinimalView = qaConfigMinimal->isChecked();
+ Global::get().s.bMinimalView = qaConfigMinimal->isChecked();
updateWindowTitle();
setupView();
}
void MainWindow::on_qaConfigHideFrame_triggered() {
- g.s.bHideFrame = qaConfigHideFrame->isChecked();
+ Global::get().s.bHideFrame = qaConfigHideFrame->isChecked();
setupView(false);
}
@@ -2732,7 +2729,7 @@ void MainWindow::on_qaAudioWizard_triggered() {
}
void MainWindow::on_qaDeveloperConsole_triggered() {
- g.c->show();
+ Global::get().c->show();
}
void MainWindow::on_qaHelpWhatsThis_triggered() {
@@ -2754,7 +2751,7 @@ void MainWindow::on_qaHelpVersionCheck_triggered() {
void MainWindow::on_gsMuteSelf_down(QVariant v) {
int val = v.toInt();
- if (((val > 0) && !g.s.bMute) || ((val < 0) && g.s.bMute) || (val == 0)) {
+ if (((val > 0) && !Global::get().s.bMute) || ((val < 0) && Global::get().s.bMute) || (val == 0)) {
qaAudioMute->setChecked(!qaAudioMute->isChecked());
on_qaAudioMute_triggered();
}
@@ -2762,56 +2759,56 @@ void MainWindow::on_gsMuteSelf_down(QVariant v) {
void MainWindow::on_gsDeafSelf_down(QVariant v) {
int val = v.toInt();
- if (((val > 0) && !g.s.bDeaf) || ((val < 0) && g.s.bDeaf) || (val == 0)) {
+ if (((val > 0) && !Global::get().s.bDeaf) || ((val < 0) && Global::get().s.bDeaf) || (val == 0)) {
qaAudioDeaf->setChecked(!qaAudioDeaf->isChecked());
on_qaAudioDeaf_triggered();
}
}
void MainWindow::on_PushToTalk_triggered(bool down, QVariant) {
- g.iPrevTarget = 0;
+ Global::get().iPrevTarget = 0;
if (down) {
- g.uiDoublePush = g.tDoublePush.restart();
- g.iPushToTalk++;
- } else if (g.iPushToTalk > 0) {
- QTimer::singleShot(static_cast< int >(g.s.pttHold), this, SLOT(pttReleased()));
+ Global::get().uiDoublePush = Global::get().tDoublePush.restart();
+ Global::get().iPushToTalk++;
+ } else if (Global::get().iPushToTalk > 0) {
+ QTimer::singleShot(static_cast< int >(Global::get().s.pttHold), this, SLOT(pttReleased()));
}
}
void MainWindow::pttReleased() {
- if (g.iPushToTalk > 0) {
- g.iPushToTalk--;
+ if (Global::get().iPushToTalk > 0) {
+ Global::get().iPushToTalk--;
}
}
void MainWindow::on_PushToMute_triggered(bool down, QVariant) {
- g.bPushToMute = down;
+ Global::get().bPushToMute = down;
updateTrayIcon();
updateUserModel();
}
void MainWindow::on_VolumeUp_triggered(bool down, QVariant) {
if (down) {
- float vol = g.s.fVolume + 0.1f;
+ float vol = Global::get().s.fVolume + 0.1f;
if (vol > 2.0f) {
vol = 2.0f;
}
- g.s.fVolume = vol;
+ Global::get().s.fVolume = vol;
}
}
void MainWindow::on_VolumeDown_triggered(bool down, QVariant) {
if (down) {
- float vol = g.s.fVolume - 0.1f;
+ float vol = Global::get().s.fVolume - 0.1f;
if (vol < 0.0f) {
vol = 0.0f;
}
- g.s.fVolume = vol;
+ Global::get().s.fVolume = vol;
}
}
Channel *MainWindow::mapChannel(int idx) const {
- if (!g.uiSession)
+ if (!Global::get().uiSession)
return nullptr;
Channel *c = nullptr;
@@ -2823,16 +2820,16 @@ Channel *MainWindow::mapChannel(int idx) const {
break;
case SHORTCUT_TARGET_PARENT:
case SHORTCUT_TARGET_CURRENT:
- c = ClientUser::get(g.uiSession)->cChannel;
+ c = ClientUser::get(Global::get().uiSession)->cChannel;
if (idx == SHORTCUT_TARGET_PARENT)
c = c->cParent;
break;
default:
if (idx <= SHORTCUT_TARGET_PARENT_SUBCHANNEL)
- c = pmModel->getSubChannel(ClientUser::get(g.uiSession)->cChannel->cParent,
+ c = pmModel->getSubChannel(ClientUser::get(Global::get().uiSession)->cChannel->cParent,
SHORTCUT_TARGET_PARENT_SUBCHANNEL - idx);
else
- c = pmModel->getSubChannel(ClientUser::get(g.uiSession)->cChannel,
+ c = pmModel->getSubChannel(ClientUser::get(Global::get().uiSession)->cChannel,
SHORTCUT_TARGET_SUBCHANNEL - idx);
break;
}
@@ -2843,11 +2840,11 @@ Channel *MainWindow::mapChannel(int idx) const {
}
void MainWindow::updateTarget() {
- g.iPrevTarget = g.iTarget;
+ Global::get().iPrevTarget = Global::get().iTarget;
if (qmCurrentTargets.isEmpty()) {
- g.bCenterPosition = false;
- g.iTarget = 0;
+ Global::get().bCenterPosition = false;
+ Global::get().iTarget = 0;
} else {
bool center = false;
QList< ShortcutTarget > ql;
@@ -2896,7 +2893,7 @@ void MainWindow::updateTarget() {
}
}
if (ql.isEmpty()) {
- g.iTarget = -1;
+ Global::get().iTarget = -1;
} else {
++iTargetCounter;
@@ -2941,7 +2938,7 @@ void MainWindow::updateTarget() {
t->set_group(u8(st.qsGroup));
}
}
- g.sh->sendMessage(mpvt);
+ Global::get().sh->sendMessage(mpvt);
// Store a mapping of the list of ShortcutTargets and the used targetID
qmTargets.insert(ql, idx);
@@ -2966,7 +2963,7 @@ void MainWindow::updateTarget() {
mpvt.Clear();
mpvt.set_id(oldidx);
- g.sh->sendMessage(mpvt);
+ Global::get().sh->sendMessage(mpvt);
break;
}
@@ -2982,8 +2979,8 @@ void MainWindow::updateTarget() {
// be the one that has been assigned most recently. This trick turns qmTargetUse (or rather qm) into
// something similar to a RingBuffer inside this method.
qmTargetUse.insert(idx, iTargetCounter);
- g.bCenterPosition = center;
- g.iTarget = idx;
+ Global::get().bCenterPosition = center;
+ Global::get().iTarget = idx;
}
}
}
@@ -2996,7 +2993,7 @@ void MainWindow::on_gsWhisper_triggered(bool down, QVariant scdata) {
if (!st.bUsers) {
Channel *c = mapChannel(st.iChannel);
if (c) {
- g.sh->joinChannel(g.uiSession, c->iId);
+ Global::get().sh->joinChannel(Global::get().uiSession, c->iId);
}
return;
}
@@ -3004,13 +3001,13 @@ void MainWindow::on_gsWhisper_triggered(bool down, QVariant scdata) {
if (gsLinkChannel->active()) {
if (!st.bUsers) {
- Channel *c = ClientUser::get(g.uiSession)->cChannel;
+ Channel *c = ClientUser::get(Global::get().uiSession)->cChannel;
Channel *l = mapChannel(st.iChannel);
if (l) {
if (c->qsPermLinks.contains(l)) {
- g.sh->removeChannelLink(c->iId, l->iId);
+ Global::get().sh->removeChannelLink(c->iId, l->iId);
} else {
- g.sh->addChannelLink(c->iId, l->iId);
+ Global::get().sh->addChannelLink(c->iId, l->iId);
}
}
return;
@@ -3020,11 +3017,11 @@ void MainWindow::on_gsWhisper_triggered(bool down, QVariant scdata) {
addTarget(&st);
updateTarget();
- g.iPushToTalk++;
- } else if (g.iPushToTalk > 0) {
+ Global::get().iPushToTalk++;
+ } else if (Global::get().iPushToTalk > 0) {
SignalCurry *fwd = new SignalCurry(scdata, true, this);
connect(fwd, SIGNAL(called(QVariant)), SLOT(whisperReleased(QVariant)));
- QTimer::singleShot(static_cast< int >(g.s.pttHold), fwd, SLOT(call()));
+ QTimer::singleShot(static_cast< int >(Global::get().s.pttHold), fwd, SLOT(call()));
}
}
@@ -3053,18 +3050,18 @@ void MainWindow::on_gsCycleTransmitMode_triggered(bool down, QVariant) {
if (down) {
QString qsNewMode;
- switch (g.s.atTransmit) {
+ switch (Global::get().s.atTransmit) {
case Settings::Continuous:
- g.s.atTransmit = Settings::VAD;
- g.l->log(Log::Information, tr("Transmit Mode set to Voice Activity"));
+ Global::get().s.atTransmit = Settings::VAD;
+ Global::get().l->log(Log::Information, tr("Transmit Mode set to Voice Activity"));
break;
case Settings::VAD:
- g.s.atTransmit = Settings::PushToTalk;
- g.l->log(Log::Information, tr("Transmit Mode set to Push-to-Talk"));
+ Global::get().s.atTransmit = Settings::PushToTalk;
+ Global::get().l->log(Log::Information, tr("Transmit Mode set to Push-to-Talk"));
break;
case Settings::PushToTalk:
- g.s.atTransmit = Settings::Continuous;
- g.l->log(Log::Information, tr("Transmit Mode set to Continuous"));
+ Global::get().s.atTransmit = Settings::Continuous;
+ Global::get().l->log(Log::Information, tr("Transmit Mode set to Continuous"));
break;
}
}
@@ -3074,18 +3071,18 @@ void MainWindow::on_gsCycleTransmitMode_triggered(bool down, QVariant) {
void MainWindow::on_gsToggleMainWindowVisibility_triggered(bool down, QVariant) {
if (down) {
- if (g.mw->isVisible()) {
- g.mw->hide();
+ if (Global::get().mw->isVisible()) {
+ Global::get().mw->hide();
} else {
- g.mw->show();
+ Global::get().mw->show();
}
}
}
void MainWindow::on_gsTransmitModePushToTalk_triggered(bool down, QVariant) {
if (down) {
- g.s.atTransmit = Settings::PushToTalk;
- g.l->log(Log::Information, tr("Transmit Mode set to Push-to-Talk"));
+ Global::get().s.atTransmit = Settings::PushToTalk;
+ Global::get().l->log(Log::Information, tr("Transmit Mode set to Push-to-Talk"));
}
updateTransmitModeComboBox();
@@ -3093,8 +3090,8 @@ void MainWindow::on_gsTransmitModePushToTalk_triggered(bool down, QVariant) {
void MainWindow::on_gsTransmitModeContinuous_triggered(bool down, QVariant) {
if (down) {
- g.s.atTransmit = Settings::Continuous;
- g.l->log(Log::Information, tr("Transmit Mode set to Continuous"));
+ Global::get().s.atTransmit = Settings::Continuous;
+ Global::get().l->log(Log::Information, tr("Transmit Mode set to Continuous"));
}
updateTransmitModeComboBox();
@@ -3102,15 +3099,15 @@ void MainWindow::on_gsTransmitModeContinuous_triggered(bool down, QVariant) {
void MainWindow::on_gsTransmitModeVAD_triggered(bool down, QVariant) {
if (down) {
- g.s.atTransmit = Settings::VAD;
- g.l->log(Log::Information, tr("Transmit Mode set to Voice Activity"));
+ Global::get().s.atTransmit = Settings::VAD;
+ Global::get().l->log(Log::Information, tr("Transmit Mode set to Voice Activity"));
}
updateTransmitModeComboBox();
}
void MainWindow::on_gsSendTextMessage_triggered(bool down, QVariant scdata) {
- if (!down || !g.sh || !g.sh->isRunning() || g.uiSession == 0) {
+ if (!down || !Global::get().sh || !Global::get().sh->isRunning() || Global::get().uiSession == 0) {
return;
}
@@ -3119,9 +3116,9 @@ void MainWindow::on_gsSendTextMessage_triggered(bool down, QVariant scdata) {
return;
}
- Channel *c = ClientUser::get(g.uiSession)->cChannel;
- g.sh->sendChannelTextMessage(c->iId, qsText, false);
- g.l->log(Log::TextMessage, tr("To %1: %2").arg(Log::formatChannel(c), qsText),
+ Channel *c = ClientUser::get(Global::get().uiSession)->cChannel;
+ Global::get().sh->sendChannelTextMessage(c->iId, qsText, false);
+ Global::get().l->log(Log::TextMessage, tr("To %1: %2").arg(Log::formatChannel(c), qsText),
tr("Message to channel %1").arg(c->qsName), true);
}
@@ -3136,12 +3133,12 @@ void MainWindow::on_gsSendClipboardTextMessage_triggered(bool down, QVariant) {
}
void MainWindow::whisperReleased(QVariant scdata) {
- if (g.iPushToTalk <= 0)
+ if (Global::get().iPushToTalk <= 0)
return;
ShortcutTarget st = scdata.value< ShortcutTarget >();
- g.iPushToTalk--;
+ Global::get().iPushToTalk--;
removeTarget(&st);
updateTarget();
@@ -3156,7 +3153,7 @@ void MainWindow::onResetAudio()
}
void MainWindow::viewCertificate(bool) {
- ViewCert vc(g.sh->qscCert, this);
+ ViewCert vc(Global::get().sh->qscCert, this);
vc.exec();
}
@@ -3165,29 +3162,29 @@ void MainWindow::viewCertificate(bool) {
* connection to the server is established but before the server Sync is complete.
*/
void MainWindow::serverConnected() {
- g.uiSession = 0;
- g.pPermissions = ChanACL::None;
- g.iCodecAlpha = 0x8000000b;
- g.bPreferAlpha = true;
+ Global::get().uiSession = 0;
+ Global::get().pPermissions = ChanACL::None;
+ Global::get().iCodecAlpha = 0x8000000b;
+ Global::get().bPreferAlpha = true;
#ifdef USE_OPUS
- g.bOpus = true;
+ Global::get().bOpus = true;
#else
- g.bOpus = false;
+ Global::get().bOpus = false;
#endif
- g.iCodecBeta = 0;
+ Global::get().iCodecBeta = 0;
#ifdef Q_OS_MAC
// Suppress AppNap while we're connected to a server.
MUSuppressAppNap(true);
#endif
- g.l->clearIgnore();
- g.l->setIgnore(Log::UserJoin);
- g.l->setIgnore(Log::OtherSelfMute);
+ Global::get().l->clearIgnore();
+ Global::get().l->setIgnore(Log::UserJoin);
+ Global::get().l->setIgnore(Log::OtherSelfMute);
QString host, uname, pw;
unsigned short port;
- g.sh->getConnectionInfo(host, port, uname, pw);
- g.l->log(Log::ServerConnected, tr("Connected."));
+ Global::get().sh->getConnectionInfo(host, port, uname, pw);
+ Global::get().l->log(Log::ServerConnected, tr("Connected."));
qaServerDisconnect->setEnabled(true);
qaServerInformation->setEnabled(true);
qaServerBanList->setEnabled(true);
@@ -3199,13 +3196,13 @@ void MainWindow::serverConnected() {
qtvUsers->setRowHidden(0, QModelIndex(), false);
- g.bAllowHTML = true;
- g.uiMessageLength = 5000;
- g.uiImageLength = 131072;
- g.uiMaxUsers = 0;
+ Global::get().bAllowHTML = true;
+ Global::get().uiMessageLength = 5000;
+ Global::get().uiImageLength = 131072;
+ Global::get().uiMaxUsers = 0;
- if (g.s.bMute || g.s.bDeaf) {
- g.sh->setSelfMuteDeafState(g.s.bMute, g.s.bDeaf);
+ if (Global::get().s.bMute || Global::get().s.bDeaf) {
+ Global::get().sh->setSelfMuteDeafState(Global::get().s.bMute, Global::get().s.bDeaf);
}
// Update QActions and menues
@@ -3216,13 +3213,13 @@ void MainWindow::serverConnected() {
on_qmConfig_aboutToShow();
#ifdef Q_OS_WIN
- TaskList::addToRecentList(g.s.qsLastServer, uname, host, port);
+ TaskList::addToRecentList(Global::get().s.qsLastServer, uname, host, port);
#endif
}
void MainWindow::serverDisconnected(QAbstractSocket::SocketError err, QString reason) {
- if (g.sh->hasSynchronized()) {
- // Note that the saving of the ChannelListeners has to be done, before resetting g.uiSession
+ if (Global::get().sh->hasSynchronized()) {
+ // Note that the saving of the ChannelListeners has to be done, before resetting Global::get().uiSession
// Save ChannelListeners
ChannelListener::saveToDB();
}
@@ -3230,9 +3227,9 @@ void MainWindow::serverDisconnected(QAbstractSocket::SocketError err, QString re
// clear ChannelListener
ChannelListener::clear();
- g.uiSession = 0;
- g.pPermissions = ChanACL::None;
- g.bAttenuateOthers = false;
+ Global::get().uiSession = 0;
+ Global::get().pPermissions = ChanACL::None;
+ Global::get().bAttenuateOthers = false;
qaServerDisconnect->setEnabled(false);
qaServerInformation->setEnabled(false);
qaServerBanList->setEnabled(false);
@@ -3247,13 +3244,13 @@ void MainWindow::serverDisconnected(QAbstractSocket::SocketError err, QString re
QString uname, pw, host;
unsigned short port;
- g.sh->getConnectionInfo(host, port, uname, pw);
+ Global::get().sh->getConnectionInfo(host, port, uname, pw);
- if (g.sh->hasSynchronized()) {
+ if (Global::get().sh->hasSynchronized()) {
// Only save server-specific shortcuts if the client and server have been synchronized before as only then
// did the client actually load them from the DB. If we store them without having loaded them, we will
// effectively clear the server-specific shortcuts for this server.
- if (g.db->setShortcuts(g.sh->qbaDigest, g.s.qlShortcuts)) {
+ if (Global::get().db->setShortcuts(Global::get().sh->qbaDigest, Global::get().s.qlShortcuts)) {
GlobalShortcutEngine::engine->bNeedRemap = true;
}
}
@@ -3311,16 +3308,16 @@ void MainWindow::serverDisconnected(QAbstractSocket::SocketError err, QString re
qmUser_aboutToShow();
on_qmConfig_aboutToShow();
- if (!g.sh->qlErrors.isEmpty()) {
- foreach (QSslError e, g.sh->qlErrors)
- g.l->log(Log::Warning, tr("SSL Verification failed: %1").arg(e.errorString().toHtmlEscaped()));
- if (!g.sh->qscCert.isEmpty()) {
- QSslCertificate c = g.sh->qscCert.at(0);
+ if (!Global::get().sh->qlErrors.isEmpty()) {
+ foreach (QSslError e, Global::get().sh->qlErrors)
+ Global::get().l->log(Log::Warning, tr("SSL Verification failed: %1").arg(e.errorString().toHtmlEscaped()));
+ if (!Global::get().sh->qscCert.isEmpty()) {
+ QSslCertificate c = Global::get().sh->qscCert.at(0);
QString basereason;
QString actual_digest = QString::fromLatin1(c.digest(QCryptographicHash::Sha1).toHex());
QString digests_section =
tr("<li>Server certificate digest (SHA-1):\t%1</li>").arg(ViewCert::prettifyDigest(actual_digest));
- QString expected_digest = g.db->getDigest(host, port);
+ QString expected_digest = Global::get().db->getDigest(host, port);
if (!expected_digest.isNull()) {
basereason =
tr("<b>WARNING:</b> The server presented a certificate that was different from the stored one.");
@@ -3330,7 +3327,7 @@ void MainWindow::serverDisconnected(QAbstractSocket::SocketError err, QString re
basereason = tr("Server presented a certificate which failed verification.");
}
QStringList qsl;
- foreach (QSslError e, g.sh->qlErrors)
+ foreach (QSslError e, Global::get().sh->qlErrors)
qsl << QString::fromLatin1("<li>%1</li>").arg(e.errorString().toHtmlEscaped());
QMessageBox qmb(QMessageBox::Warning, QLatin1String("Mumble"),
@@ -3350,11 +3347,11 @@ void MainWindow::serverDisconnected(QAbstractSocket::SocketError err, QString re
int res = qmb.exec();
if ((res == 0) && (qmb.clickedButton() == qp)) {
- ViewCert vc(g.sh->qscCert, this);
+ ViewCert vc(Global::get().sh->qscCert, this);
vc.exec();
continue;
} else if (res == QMessageBox::Yes) {
- g.db->setDigest(host, port, QString::fromLatin1(c.digest(QCryptographicHash::Sha1).toHex()));
+ Global::get().db->setDigest(host, port, QString::fromLatin1(c.digest(QCryptographicHash::Sha1).toHex()));
qaServerDisconnect->setEnabled(true);
on_Reconnect_timeout();
}
@@ -3371,9 +3368,9 @@ void MainWindow::serverDisconnected(QAbstractSocket::SocketError err, QString re
if (!reason.isEmpty()) {
- g.l->log(Log::ServerDisconnected, tr("Server connection failed: %1.").arg(reason.toHtmlEscaped()));
+ Global::get().l->log(Log::ServerDisconnected, tr("Server connection failed: %1.").arg(reason.toHtmlEscaped()));
} else {
- g.l->log(Log::ServerDisconnected, tr("Disconnected from server."));
+ Global::get().l->log(Log::ServerDisconnected, tr("Disconnected from server."));
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
@@ -3415,12 +3412,12 @@ void MainWindow::serverDisconnected(QAbstractSocket::SocketError err, QString re
break;
}
if (ok && matched) {
- if (!g.s.bSuppressIdentity)
- g.db->setPassword(host, port, uname, pw);
+ if (!Global::get().s.bSuppressIdentity)
+ Global::get().db->setPassword(host, port, uname, pw);
qaServerDisconnect->setEnabled(true);
- g.sh->setConnectionInfo(host, port, uname, pw);
+ Global::get().sh->setConnectionInfo(host, port, uname, pw);
on_Reconnect_timeout();
- } else if (!matched && g.s.bReconnect && !reason.isEmpty()) {
+ } else if (!matched && Global::get().s.bReconnect && !reason.isEmpty()) {
qaServerDisconnect->setEnabled(true);
if (bRetryServer) {
qtReconnect->start();
@@ -3433,12 +3430,12 @@ void MainWindow::serverDisconnected(QAbstractSocket::SocketError err, QString re
void MainWindow::resolverError(QAbstractSocket::SocketError, QString reason) {
if (!reason.isEmpty()) {
- g.l->log(Log::ServerDisconnected, tr("Server connection failed: %1.").arg(reason.toHtmlEscaped()));
+ Global::get().l->log(Log::ServerDisconnected, tr("Server connection failed: %1.").arg(reason.toHtmlEscaped()));
} else {
- g.l->log(Log::ServerDisconnected, tr("Server connection failed."));
+ Global::get().l->log(Log::ServerDisconnected, tr("Server connection failed."));
}
- if (g.s.bReconnect) {
+ if (Global::get().s.bReconnect) {
qaServerDisconnect->setEnabled(true);
if (bRetryServer) {
qtReconnect->start();
@@ -3504,14 +3501,14 @@ void MainWindow::on_Icon_activated(QSystemTrayIcon::ActivationReason reason) {
}
void MainWindow::on_qaTalkingUIToggle_triggered() {
- if (!g.talkingUI) {
+ if (!Global::get().talkingUI) {
qCritical("MainWindow: Attempting to show Talking UI before it has been created!");
return;
}
- g.talkingUI->setVisible(!g.talkingUI->isVisible());
+ Global::get().talkingUI->setVisible(!Global::get().talkingUI->isVisible());
- g.s.bShowTalkingUI = g.talkingUI->isVisible();
+ Global::get().s.bShowTalkingUI = Global::get().talkingUI->isVisible();
}
/**
@@ -3526,12 +3523,12 @@ void MainWindow::updateChatBar() {
User *p = pmModel->getUser(qtvUsers->currentIndex());
Channel *c = pmModel->getChannel(qtvUsers->currentIndex());
- if (g.uiSession == 0) {
+ if (Global::get().uiSession == 0) {
qteChat->setDefaultText(tr("<center>Not connected</center>"), true);
- } else if (!g.s.bChatBarUseSelection || !p || p->uiSession == g.uiSession) {
+ } else if (!Global::get().s.bChatBarUseSelection || !p || p->uiSession == Global::get().uiSession) {
// Channel tree target
- if (!g.s.bChatBarUseSelection || !c) // If no channel selected fallback to current one
- c = ClientUser::get(g.uiSession)->cChannel;
+ if (!Global::get().s.bChatBarUseSelection || !c) // If no channel selected fallback to current one
+ c = ClientUser::get(Global::get().uiSession)->cChannel;
qteChat->setDefaultText(
tr("<center>Type message to channel '%1' here</center>").arg(c->qsName.toHtmlEscaped()));
@@ -3546,7 +3543,7 @@ void MainWindow::updateChatBar() {
void MainWindow::customEvent(QEvent *evt) {
if (evt->type() == MB_QEVENT) {
MessageBoxEvent *mbe = static_cast< MessageBoxEvent * >(evt);
- g.l->log(Log::Information, mbe->msg);
+ Global::get().l->log(Log::Information, mbe->msg);
return;
} else if (evt->type() == OU_QEVENT) {
OpenURLEvent *oue = static_cast< OpenURLEvent * >(evt);
@@ -3593,7 +3590,7 @@ void MainWindow::on_qteLog_anchorClicked(const QUrl &url) {
// the user can't click on anything before they dismiss the overlay
// by hitting their toggle hotkey), so let's disallow clicking links
// when embedded into the overlay for now.
- if (g.ocIntercept)
+ if (Global::get().ocIntercept)
return;
#endif
if (url.scheme() != QLatin1String("file") && url.scheme() != QLatin1String("qrc") && !url.isRelative())
@@ -3626,7 +3623,7 @@ void MainWindow::context_triggered() {
mpca.set_session(p->uiSession);
if (c)
mpca.set_channel_id(c->iId);
- g.sh->sendMessage(mpca);
+ Global::get().sh->sendMessage(mpca);
}
/**
@@ -3681,7 +3678,7 @@ QPair< QByteArray, QImage > MainWindow::openImageFile() {
}
void MainWindow::logChangeNotPermanent(const QString &actionName, ClientUser *const p) const {
- g.l->log(Log::Warning,
+ Global::get().l->log(Log::Warning,
QObject::tr(
"\"%1\" could not be saved permanently and is lost on restart because %2 does not have a certificate.")
.arg(actionName)
diff --git a/src/mumble/ManualPlugin.cpp b/src/mumble/ManualPlugin.cpp
index 4b90d05e1..ef1a4746d 100644
--- a/src/mumble/ManualPlugin.cpp
+++ b/src/mumble/ManualPlugin.cpp
@@ -16,9 +16,6 @@
#include <float.h>
#include "../../plugins/mumble_plugin.h"
-
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
#include "Global.h"
static QPointer< Manual > mDlg = nullptr;
@@ -85,7 +82,7 @@ Manual::Manual(QWidget *p) : QDialog(p) {
my.context = defaultContext.toStdString();
my.identity = defaultIdentity.toStdWString();
- qsbSilentUserDisplaytime->setValue(g.s.manualPlugin_silentUserDisplaytime);
+ qsbSilentUserDisplaytime->setValue(Global::get().s.manualPlugin_silentUserDisplaytime);
updateLoopRunning.store(false);
}
@@ -210,7 +207,7 @@ void Manual::on_buttonBox_clicked(QAbstractButton *button) {
}
void Manual::on_qsbSilentUserDisplaytime_valueChanged(int value) {
- g.s.manualPlugin_silentUserDisplaytime = value;
+ Global::get().s.manualPlugin_silentUserDisplaytime = value;
}
void Manual::on_speakerPositionUpdate(QHash< unsigned int, Position2D > positions) {
@@ -251,7 +248,7 @@ void Manual::on_speakerPositionUpdate(QHash< unsigned int, Position2D > position
} else {
// Remove the stale item
speakerIt.remove();
- if (g.s.manualPlugin_silentUserDisplaytime == 0) {
+ if (Global::get().s.manualPlugin_silentUserDisplaytime == 0) {
// Delete it immediately
delete speakerItem;
} else {
@@ -296,14 +293,14 @@ void Manual::on_updateStaleSpeakers() {
double elapsedTime =
static_cast< std::chrono::duration< double > >(std::chrono::steady_clock::now() - entry.staleSince).count();
- if (elapsedTime >= g.s.manualPlugin_silentUserDisplaytime) {
+ if (elapsedTime >= Global::get().s.manualPlugin_silentUserDisplaytime) {
// The item has been around long enough - remove it now
staleIt.remove();
delete entry.staleItem;
} else {
// Let the item fade out
- double opacity = (g.s.manualPlugin_silentUserDisplaytime - elapsedTime)
- / static_cast< double >(g.s.manualPlugin_silentUserDisplaytime);
+ double opacity = (Global::get().s.manualPlugin_silentUserDisplaytime - elapsedTime)
+ / static_cast< double >(Global::get().s.manualPlugin_silentUserDisplaytime);
entry.staleItem->setOpacity(opacity);
}
}
diff --git a/src/mumble/Messages.cpp b/src/mumble/Messages.cpp
index 49575849a..72fea881e 100644
--- a/src/mumble/Messages.cpp
+++ b/src/mumble/Messages.cpp
@@ -35,12 +35,10 @@
#include "VersionCheck.h"
#include "ViewCert.h"
#include "crypto/CryptState.h"
-#include <QTextDocumentFragment>
-
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
#include "Global.h"
+#include <QTextDocumentFragment>
+
#define ACTOR_INIT \
ClientUser *pSrc = nullptr; \
if (msg.has_actor()) \
@@ -55,9 +53,9 @@
}
#define SELF_INIT \
- ClientUser *pSelf = ClientUser::get(g.uiSession); \
+ ClientUser *pSelf = ClientUser::get(Global::get().uiSession); \
if (!pSelf) { \
- qWarning("MainWindow: Received message outside of session (sid %d).", g.uiSession); \
+ qWarning("MainWindow: Received message outside of session (sid %d).", Global::get().uiSession); \
return; \
}
@@ -108,8 +106,8 @@ void MainWindow::msgReject(const MumbleProto::Reject &msg) {
break;
}
- g.l->log(Log::ServerDisconnected, tr("Server connection rejected: %1.").arg(reason));
- g.l->setIgnore(Log::ServerDisconnected, 1);
+ Global::get().l->log(Log::ServerDisconnected, tr("Server connection rejected: %1.").arg(reason));
+ Global::get().l->setIgnore(Log::ServerDisconnected, 1);
}
/// This message is being received when the server has authenticated the user and finished synchronizing the server
@@ -121,20 +119,20 @@ void MainWindow::msgReject(const MumbleProto::Reject &msg) {
void MainWindow::msgServerSync(const MumbleProto::ServerSync &msg) {
const ClientUser *user = ClientUser::get(msg.session());
if (!user) {
- g.l->log(Log::CriticalError, tr("Server sync protocol violation. No user profile received."));
- g.sh->disconnect();
+ Global::get().l->log(Log::CriticalError, tr("Server sync protocol violation. No user profile received."));
+ Global::get().sh->disconnect();
return;
}
- g.uiSession = msg.session();
+ Global::get().uiSession = msg.session();
- g.sh->sendPing(); // Send initial ping to establish UDP connection
+ Global::get().sh->sendPing(); // Send initial ping to establish UDP connection
- g.pPermissions = ChanACL::Permissions(static_cast< unsigned int >(msg.permissions()));
- g.l->clearIgnore();
+ Global::get().pPermissions = ChanACL::Permissions(static_cast< unsigned int >(msg.permissions()));
+ Global::get().l->clearIgnore();
if (msg.has_welcome_text()) {
QString str = u8(msg.welcome_text());
if (!str.isEmpty()) {
- g.l->log(Log::Information, tr("Welcome message: %1").arg(str));
+ Global::get().l->log(Log::Information, tr("Welcome message: %1").arg(str));
}
}
pmModel->ensureSelfVisible();
@@ -157,15 +155,15 @@ void MainWindow::msgServerSync(const MumbleProto::ServerSync &msg) {
QString host, uname, pw;
unsigned short port;
- g.sh->getConnectionInfo(host, port, uname, pw);
+ Global::get().sh->getConnectionInfo(host, port, uname, pw);
- QList< Shortcut > sc = g.db->getShortcuts(g.sh->qbaDigest);
+ QList< Shortcut > sc = Global::get().db->getShortcuts(Global::get().sh->qbaDigest);
if (!sc.isEmpty()) {
for (int i = 0; i < sc.count(); ++i) {
Shortcut &s = sc[i];
- s.iIndex = g.mw->gsWhisper->idx;
+ s.iIndex = Global::get().mw->gsWhisper->idx;
}
- g.s.qlShortcuts << sc;
+ Global::get().s.qlShortcuts << sc;
GlobalShortcutEngine::engine->bNeedRemap = true;
}
@@ -187,11 +185,11 @@ void MainWindow::msgServerSync(const MumbleProto::ServerSync &msg) {
updateTrayIcon();
// Set-up all ChannelListeners and their volume adjustments as before for this server
- QList< int > localListeners = g.db->getChannelListeners(g.sh->qbaDigest);
+ QList< int > localListeners = Global::get().db->getChannelListeners(Global::get().sh->qbaDigest);
if (!localListeners.isEmpty()) {
ChannelListener::setInitialServerSyncDone(false);
- g.sh->startListeningToChannels(localListeners);
+ Global::get().sh->startListeningToChannels(localListeners);
} else {
// If there are no listeners, then no synchronization is needed in the first place
ChannelListener::setInitialServerSyncDone(true);
@@ -205,7 +203,7 @@ void MainWindow::msgServerSync(const MumbleProto::ServerSync &msg) {
// Therefore we block all signals while setting the volume adjustments.
const QSignalBlocker blocker(ChannelListener::get());
- QHash< int, float > volumeMap = g.db->getChannelListenerLocalVolumeAdjustments(g.sh->qbaDigest);
+ QHash< int, float > volumeMap = Global::get().db->getChannelListenerLocalVolumeAdjustments(Global::get().sh->qbaDigest);
QHashIterator< int, float > it(volumeMap);
while (it.hasNext()) {
it.next();
@@ -214,7 +212,7 @@ void MainWindow::msgServerSync(const MumbleProto::ServerSync &msg) {
}
- g.sh->setServerSynchronized(true);
+ Global::get().sh->setServerSynchronized(true);
emit serverSynchronized();
}
@@ -228,19 +226,19 @@ void MainWindow::msgServerConfig(const MumbleProto::ServerConfig &msg) {
if (msg.has_welcome_text()) {
QString str = u8(msg.welcome_text());
if (!str.isEmpty()) {
- g.l->log(Log::Information, tr("Welcome message: %1").arg(str));
+ Global::get().l->log(Log::Information, tr("Welcome message: %1").arg(str));
}
}
if (msg.has_max_bandwidth())
AudioInput::setMaxBandwidth(msg.max_bandwidth());
if (msg.has_allow_html())
- g.bAllowHTML = msg.allow_html();
+ Global::get().bAllowHTML = msg.allow_html();
if (msg.has_message_length())
- g.uiMessageLength = msg.message_length();
+ Global::get().uiMessageLength = msg.message_length();
if (msg.has_image_message_length())
- g.uiImageLength = msg.image_message_length();
+ Global::get().uiImageLength = msg.image_message_length();
if (msg.has_max_users())
- g.uiMaxUsers = msg.max_users();
+ Global::get().uiMaxUsers = msg.max_users();
}
/// This message is being received when the server denied the permission to perform a requested action. This function
@@ -259,90 +257,90 @@ void MainWindow::msgPermissionDenied(const MumbleProto::PermissionDenied &msg) {
QString pname = ChanACL::permName(permission);
if ((permission == ChanACL::Perm::Enter) && c->hasEnterRestrictions.load()) {
- g.l->log(
+ Global::get().l->log(
Log::PermissionDenied,
tr("Unable to %1 into %2 - Adding the respective access (password) token might grant you access.")
.arg(Log::msgColor(pname, Log::Privilege))
.arg(Log::formatChannel(c)));
} else {
if (pDst == pSelf)
- g.l->log(Log::PermissionDenied, tr("You were denied %1 privileges in %2.")
+ Global::get().l->log(Log::PermissionDenied, tr("You were denied %1 privileges in %2.")
.arg(Log::msgColor(pname, Log::Privilege))
.arg(Log::formatChannel(c)));
else
- g.l->log(Log::PermissionDenied, tr("%3 was denied %1 privileges in %2.")
+ Global::get().l->log(Log::PermissionDenied, tr("%3 was denied %1 privileges in %2.")
.arg(Log::msgColor(pname, Log::Privilege))
.arg(Log::formatChannel(c))
.arg(Log::formatClientUser(pDst, Log::Target)));
}
} break;
case MumbleProto::PermissionDenied_DenyType_SuperUser: {
- g.l->log(Log::PermissionDenied, tr("Denied: Cannot modify SuperUser."));
+ Global::get().l->log(Log::PermissionDenied, tr("Denied: Cannot modify SuperUser."));
} break;
case MumbleProto::PermissionDenied_DenyType_ChannelName: {
- g.l->log(Log::PermissionDenied, tr("Denied: Invalid channel name."));
+ Global::get().l->log(Log::PermissionDenied, tr("Denied: Invalid channel name."));
} break;
case MumbleProto::PermissionDenied_DenyType_TextTooLong: {
- g.l->log(Log::PermissionDenied, tr("Denied: Text message too long."));
+ Global::get().l->log(Log::PermissionDenied, tr("Denied: Text message too long."));
} break;
case MumbleProto::PermissionDenied_DenyType_H9K: {
- if (g.bHappyEaster) {
- bool bold = g.s.bDeaf;
- bool bold2 = g.s.bTTS;
- g.s.bDeaf = false;
- g.s.bTTS = true;
- quint32 oflags = g.s.qmMessages.value(Log::PermissionDenied);
- g.s.qmMessages[Log::PermissionDenied] = (oflags | Settings::LogTTS) & (~Settings::LogSoundfile);
- g.l->log(Log::PermissionDenied,
- QString::fromUtf8(g.ccHappyEaster + 39).arg(g.s.qsUsername.toHtmlEscaped()));
- g.s.qmMessages[Log::PermissionDenied] = oflags;
- g.s.bDeaf = bold;
- g.s.bTTS = bold2;
- g.mw->setWindowIcon(QIcon(QString::fromUtf8(g.ccHappyEaster)));
- g.mw->setStyleSheet(QString::fromUtf8(g.ccHappyEaster + 82));
+ if (Global::get().bHappyEaster) {
+ bool bold = Global::get().s.bDeaf;
+ bool bold2 = Global::get().s.bTTS;
+ Global::get().s.bDeaf = false;
+ Global::get().s.bTTS = true;
+ quint32 oflags = Global::get().s.qmMessages.value(Log::PermissionDenied);
+ Global::get().s.qmMessages[Log::PermissionDenied] = (oflags | Settings::LogTTS) & (~Settings::LogSoundfile);
+ Global::get().l->log(Log::PermissionDenied,
+ QString::fromUtf8(Global::get().ccHappyEaster + 39).arg(Global::get().s.qsUsername.toHtmlEscaped()));
+ Global::get().s.qmMessages[Log::PermissionDenied] = oflags;
+ Global::get().s.bDeaf = bold;
+ Global::get().s.bTTS = bold2;
+ Global::get().mw->setWindowIcon(QIcon(QString::fromUtf8(Global::get().ccHappyEaster)));
+ Global::get().mw->setStyleSheet(QString::fromUtf8(Global::get().ccHappyEaster + 82));
qWarning() << "Happy Easter";
}
} break;
case MumbleProto::PermissionDenied_DenyType_TemporaryChannel: {
- g.l->log(Log::PermissionDenied, tr("Denied: Operation not permitted in temporary channel."));
+ Global::get().l->log(Log::PermissionDenied, tr("Denied: Operation not permitted in temporary channel."));
} break;
case MumbleProto::PermissionDenied_DenyType_MissingCertificate: {
VICTIM_INIT;
SELF_INIT;
if (pDst == pSelf)
- g.l->log(Log::PermissionDenied, tr("You need a certificate to perform this operation."));
+ Global::get().l->log(Log::PermissionDenied, tr("You need a certificate to perform this operation."));
else
- g.l->log(Log::PermissionDenied,
+ Global::get().l->log(Log::PermissionDenied,
tr("%1 does not have a certificate.").arg(Log::formatClientUser(pDst, Log::Target)));
} break;
case MumbleProto::PermissionDenied_DenyType_UserName: {
if (msg.has_name())
- g.l->log(Log::PermissionDenied, tr("Invalid username: %1.").arg(u8(msg.name()).toHtmlEscaped()));
+ Global::get().l->log(Log::PermissionDenied, tr("Invalid username: %1.").arg(u8(msg.name()).toHtmlEscaped()));
else
- g.l->log(Log::PermissionDenied, tr("Invalid username."));
+ Global::get().l->log(Log::PermissionDenied, tr("Invalid username."));
} break;
case MumbleProto::PermissionDenied_DenyType_ChannelFull: {
- g.l->log(Log::PermissionDenied, tr("Channel is full."));
+ Global::get().l->log(Log::PermissionDenied, tr("Channel is full."));
} break;
case MumbleProto::PermissionDenied_DenyType_NestingLimit: {
- g.l->log(Log::PermissionDenied, tr("Channel nesting limit reached."));
+ Global::get().l->log(Log::PermissionDenied, tr("Channel nesting limit reached."));
} break;
case MumbleProto::PermissionDenied_DenyType_ChannelCountLimit: {
- g.l->log(Log::PermissionDenied,
+ Global::get().l->log(Log::PermissionDenied,
tr("Channel count limit reached. Need to delete channels before creating new ones."));
} break;
case MumbleProto::PermissionDenied_DenyType_ChannelListenerLimit: {
- g.l->log(Log::PermissionDenied, tr("No more listeners allowed in this channel."));
+ Global::get().l->log(Log::PermissionDenied, tr("No more listeners allowed in this channel."));
} break;
case MumbleProto::PermissionDenied_DenyType_UserListenerLimit: {
- g.l->log(Log::PermissionDenied,
+ Global::get().l->log(Log::PermissionDenied,
tr("You are not allowed to listen to more channels than you currently are."));
} break;
default: {
if (msg.has_reason())
- g.l->log(Log::PermissionDenied, tr("Denied: %1.").arg(u8(msg.reason()).toHtmlEscaped()));
+ Global::get().l->log(Log::PermissionDenied, tr("Denied: %1.").arg(u8(msg.reason()).toHtmlEscaped()));
else
- g.l->log(Log::PermissionDenied, tr("Permission denied."));
+ Global::get().l->log(Log::PermissionDenied, tr("Permission denied."));
} break;
}
}
@@ -359,7 +357,7 @@ void MainWindow::msgUDPTunnel(const MumbleProto::UDPTunnel &) {
/// @param msg The message object containing the respective information
void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
ACTOR_INIT;
- ClientUser *pSelf = ClientUser::get(g.uiSession);
+ ClientUser *pSelf = ClientUser::get(Global::get().uiSession);
ClientUser *pDst = ClientUser::get(msg.session());
Channel *channel = nullptr;
@@ -379,8 +377,8 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
pDst = pmModel->addUser(msg.session(), u8(msg.name()));
- connect(pDst, &ClientUser::talkingStateChanged, g.talkingUI, &TalkingUI::on_talkingStateChanged);
- connect(pDst, &ClientUser::muteDeafStateChanged, g.talkingUI, &TalkingUI::on_muteDeafStateChanged);
+ connect(pDst, &ClientUser::talkingStateChanged, Global::get().talkingUI, &TalkingUI::on_talkingStateChanged);
+ connect(pDst, &ClientUser::muteDeafStateChanged, Global::get().talkingUI, &TalkingUI::on_muteDeafStateChanged);
if (channel) {
pmModel->moveUser(pDst, channel);
@@ -392,10 +390,10 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
if (pSelf) {
if (pDst->cChannel == pSelf->cChannel) {
- g.l->log(Log::ChannelJoinConnect,
+ Global::get().l->log(Log::ChannelJoinConnect,
tr("%1 connected and entered channel.").arg(Log::formatClientUser(pDst, Log::Source)));
} else {
- g.l->log(Log::UserJoin, tr("%1 connected.").arg(Log::formatClientUser(pDst, Log::Source)));
+ Global::get().l->log(Log::UserJoin, tr("%1 connected.").arg(Log::formatClientUser(pDst, Log::Source)));
}
}
}
@@ -409,54 +407,54 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
if (channel != oldChannel) {
pmModel->moveUser(pDst, channel);
- if (g.talkingUI) {
+ if (Global::get().talkingUI) {
// Pass the pointer as QObject in order to avoid having to register ClientUser as a QMetaType
- QMetaObject::invokeMethod(g.talkingUI, "on_channelChanged", Qt::QueuedConnection,
+ QMetaObject::invokeMethod(Global::get().talkingUI, "on_channelChanged", Qt::QueuedConnection,
Q_ARG(QObject *, pDst));
}
if (pSelf) {
if (pDst == pSelf) {
- g.mw->updateChatBar();
+ Global::get().mw->updateChatBar();
qsDesiredChannel = channel->getPath();
}
if (pDst == pSelf) {
if (pSrc == pSelf) {
- g.l->log(Log::SelfChannelJoin, tr("You joined %1.").arg(Log::formatChannel(channel)));
+ Global::get().l->log(Log::SelfChannelJoin, tr("You joined %1.").arg(Log::formatChannel(channel)));
} else {
- g.l->log(Log::SelfChannelJoinOther, tr("You were moved to %1 by %2.")
+ Global::get().l->log(Log::SelfChannelJoinOther, tr("You were moved to %1 by %2.")
.arg(Log::formatChannel(channel))
.arg(Log::formatClientUser(pSrc, Log::Source)));
}
} else if (pSrc == pSelf) {
if (channel == pSelf->cChannel) {
- g.l->log(Log::ChannelJoin, tr("You moved %1 to %2.")
+ Global::get().l->log(Log::ChannelJoin, tr("You moved %1 to %2.")
.arg(Log::formatClientUser(pDst, Log::Target))
.arg(Log::formatChannel(channel)));
} else {
- g.l->log(Log::ChannelLeave, tr("You moved %1 to %2.")
+ Global::get().l->log(Log::ChannelLeave, tr("You moved %1 to %2.")
.arg(Log::formatClientUser(pDst, Log::Target))
.arg(Log::formatChannel(channel)));
}
} else if ((channel == pSelf->cChannel) || (oldChannel == pSelf->cChannel)) {
if (pDst == pSrc) {
if (channel == pSelf->cChannel) {
- g.l->log(Log::ChannelJoin,
+ Global::get().l->log(Log::ChannelJoin,
tr("%1 entered channel.").arg(Log::formatClientUser(pDst, Log::Target)));
} else {
- g.l->log(Log::ChannelLeave, tr("%1 moved to %2.")
+ Global::get().l->log(Log::ChannelLeave, tr("%1 moved to %2.")
.arg(Log::formatClientUser(pDst, Log::Target))
.arg(Log::formatChannel(channel)));
}
} else {
if (channel == pSelf->cChannel) {
- g.l->log(Log::ChannelJoin, tr("%1 moved in from %2 by %3.")
+ Global::get().l->log(Log::ChannelJoin, tr("%1 moved in from %2 by %3.")
.arg(Log::formatClientUser(pDst, Log::Target))
.arg(Log::formatChannel(oldChannel))
.arg(Log::formatClientUser(pSrc, Log::Source)));
} else {
- g.l->log(Log::ChannelLeave, tr("%1 moved to %2 by %3.")
+ Global::get().l->log(Log::ChannelLeave, tr("%1 moved to %2 by %3.")
.arg(Log::formatClientUser(pDst, Log::Target))
.arg(Log::formatChannel(channel))
.arg(Log::formatClientUser(pSrc, Log::Source)));
@@ -465,7 +463,7 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
}
if ((channel == pSelf->cChannel) && pDst->bRecording) {
- g.l->log(Log::Recording, tr("%1 is recording").arg(Log::formatClientUser(pDst, Log::Target)));
+ Global::get().l->log(Log::Recording, tr("%1 is recording").arg(Log::formatClientUser(pDst, Log::Target)));
}
}
}
@@ -498,7 +496,7 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
}
if (!logMsg.isEmpty()) {
- g.l->log(Log::ChannelListeningAdd, logMsg);
+ Global::get().l->log(Log::ChannelListeningAdd, logMsg);
}
}
for (int i = 0; i < msg.listening_channel_remove_size(); i++) {
@@ -520,7 +518,7 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
}
if (!logMsg.isEmpty()) {
- g.l->log(Log::ChannelListeningRemove, logMsg);
+ Global::get().l->log(Log::ChannelListeningRemove, logMsg);
}
}
@@ -530,12 +528,12 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
pmModel->renameUser(pDst, newName);
if (!oldName.isNull() && oldName != newName) {
if (pSrc != pDst) {
- g.l->log(Log::UserRenamed, tr("%1 renamed to %2 by %3.")
+ Global::get().l->log(Log::UserRenamed, tr("%1 renamed to %2 by %3.")
.arg(Log::formatClientUser(pDst, Log::Target, oldName))
.arg(Log::formatClientUser(pDst, Log::Target))
.arg(Log::formatClientUser(pSrc, Log::Source)));
} else {
- g.l->log(Log::UserRenamed, tr("%1 renamed to %2.")
+ Global::get().l->log(Log::UserRenamed, tr("%1 renamed to %2.")
.arg(Log::formatClientUser(pDst, Log::Target, oldName),
Log::formatClientUser(pDst, Log::Target)));
}
@@ -543,17 +541,17 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
}
if (!pDst->qsHash.isEmpty()) {
- const QString &name = g.db->getFriend(pDst->qsHash);
+ const QString &name = Global::get().db->getFriend(pDst->qsHash);
if (!name.isEmpty())
pmModel->setFriendName(pDst, name);
- if (g.db->isLocalMuted(pDst->qsHash))
+ if (Global::get().db->isLocalMuted(pDst->qsHash))
pDst->setLocalMute(true);
- if (g.db->isLocalIgnored(pDst->qsHash))
+ if (Global::get().db->isLocalIgnored(pDst->qsHash))
pDst->setLocalIgnore(true);
- if (g.db->isLocalIgnoredTTS(pDst->qsHash))
+ if (Global::get().db->isLocalIgnoredTTS(pDst->qsHash))
pDst->setLocalIgnoreTTS(true);
- pDst->setLocalVolumeAdjustment(g.db->getUserLocalVolume(pDst->qsHash));
- pDst->setLocalNickname(g.db->getUserLocalNickname(pDst->qsHash));
+ pDst->setLocalVolumeAdjustment(Global::get().db->getUserLocalVolume(pDst->qsHash));
+ pDst->setLocalNickname(Global::get().db->getUserLocalNickname(pDst->qsHash));
}
if (msg.has_self_deaf() || msg.has_self_mute()) {
@@ -565,12 +563,12 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
if (pSelf && pDst != pSelf
&& ((pDst->cChannel == pSelf->cChannel) || pDst->cChannel->allLinks().contains(pSelf->cChannel))) {
if (pDst->bSelfMute && pDst->bSelfDeaf)
- g.l->log(Log::OtherSelfMute,
+ Global::get().l->log(Log::OtherSelfMute,
tr("%1 is now muted and deafened.").arg(Log::formatClientUser(pDst, Log::Target)));
else if (pDst->bSelfMute)
- g.l->log(Log::OtherSelfMute, tr("%1 is now muted.").arg(Log::formatClientUser(pDst, Log::Target)));
+ Global::get().l->log(Log::OtherSelfMute, tr("%1 is now muted.").arg(Log::formatClientUser(pDst, Log::Target)));
else
- g.l->log(Log::OtherSelfMute, tr("%1 is now unmuted.").arg(Log::formatClientUser(pDst, Log::Target)));
+ Global::get().l->log(Log::OtherSelfMute, tr("%1 is now unmuted.").arg(Log::formatClientUser(pDst, Log::Target)));
}
}
@@ -581,15 +579,15 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
if (pSelf) {
if (pDst == pSelf) {
if (pDst->bRecording) {
- g.l->log(Log::Recording, tr("Recording started"));
+ Global::get().l->log(Log::Recording, tr("Recording started"));
} else {
- g.l->log(Log::Recording, tr("Recording stopped"));
+ Global::get().l->log(Log::Recording, tr("Recording stopped"));
}
} else if (pDst->cChannel->allLinks().contains(pSelf->cChannel)) {
if (pDst->bRecording) {
- g.l->log(Log::Recording, tr("%1 started recording.").arg(Log::formatClientUser(pDst, Log::Source)));
+ Global::get().l->log(Log::Recording, tr("%1 started recording.").arg(Log::formatClientUser(pDst, Log::Source)));
} else {
- g.l->log(Log::Recording, tr("%1 stopped recording.").arg(Log::formatClientUser(pDst, Log::Source)));
+ Global::get().l->log(Log::Recording, tr("%1 stopped recording.").arg(Log::formatClientUser(pDst, Log::Source)));
}
}
}
@@ -601,44 +599,44 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
|| (pSrc == pSelf))) {
if ((pSrc == pDst) && (pSrc == pSelf)) {
if (pDst->bPrioritySpeaker) {
- g.l->log(Log::YouMuted, tr("You revoked your priority speaker status."));
+ Global::get().l->log(Log::YouMuted, tr("You revoked your priority speaker status."));
} else {
- g.l->log(Log::YouMuted, tr("You assumed priority speaker status."));
+ Global::get().l->log(Log::YouMuted, tr("You assumed priority speaker status."));
}
} else if ((pSrc != pSelf) && (pDst == pSelf)) {
if (pDst->bPrioritySpeaker) {
- g.l->log(
+ Global::get().l->log(
Log::YouMutedOther,
tr("%1 revoked your priority speaker status.").arg(Log::formatClientUser(pSrc, Log::Source)));
} else {
- g.l->log(Log::YouMutedOther,
+ Global::get().l->log(Log::YouMutedOther,
tr("%1 gave you priority speaker status.").arg(Log::formatClientUser(pSrc, Log::Source)));
}
} else if ((pSrc == pSelf) && (pSrc != pDst)) {
if (pDst->bPrioritySpeaker) {
- g.l->log(Log::YouMutedOther, tr("You revoked priority speaker status for %1.")
+ Global::get().l->log(Log::YouMutedOther, tr("You revoked priority speaker status for %1.")
.arg(Log::formatClientUser(pDst, Log::Target)));
} else {
- g.l->log(
+ Global::get().l->log(
Log::YouMutedOther,
tr("You gave priority speaker status to %1.").arg(Log::formatClientUser(pDst, Log::Target)));
}
} else if ((pSrc == pDst) && (pSrc != pSelf)) {
if (pDst->bPrioritySpeaker) {
- g.l->log(
+ Global::get().l->log(
Log::OtherMutedOther,
tr("%1 revoked own priority speaker status.").arg(Log::formatClientUser(pSrc, Log::Source)));
} else {
- g.l->log(Log::OtherMutedOther,
+ Global::get().l->log(Log::OtherMutedOther,
tr("%1 assumed priority speaker status.").arg(Log::formatClientUser(pSrc, Log::Source)));
}
} else if ((pSrc != pSelf) && (pDst != pSelf)) {
if (pDst->bPrioritySpeaker) {
- g.l->log(Log::OtherMutedOther, tr("%1 revoked priority speaker status for %2.")
+ Global::get().l->log(Log::OtherMutedOther, tr("%1 revoked priority speaker status for %2.")
.arg(Log::formatClientUser(pSrc, Log::Source),
Log::formatClientUser(pDst, Log::Target)));
} else if (!pDst->bPrioritySpeaker) {
- g.l->log(Log::OtherMutedOther, tr("%1 gave priority speaker status to %2.")
+ Global::get().l->log(Log::OtherMutedOther, tr("%1 gave priority speaker status to %2.")
.arg(Log::formatClientUser(pSrc, Log::Source),
Log::formatClientUser(pDst, Log::Target)));
}
@@ -661,37 +659,37 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
|| (pSrc == pSelf))) {
if (pDst == pSelf) {
if (msg.has_mute() && msg.has_deaf() && pDst->bMute && pDst->bDeaf) {
- g.l->log(Log::YouMuted,
+ Global::get().l->log(Log::YouMuted,
tr("You were muted and deafened by %1.").arg(Log::formatClientUser(pSrc, Log::Source)));
} else if (msg.has_mute() && msg.has_deaf() && !pDst->bMute && !pDst->bDeaf) {
- g.l->log(
+ Global::get().l->log(
Log::YouMuted,
tr("You were unmuted and undeafened by %1.").arg(Log::formatClientUser(pSrc, Log::Source)));
} else {
if (msg.has_mute()) {
if (pDst->bMute)
- g.l->log(Log::YouMuted,
+ Global::get().l->log(Log::YouMuted,
tr("You were muted by %1.").arg(Log::formatClientUser(pSrc, Log::Source)));
else
- g.l->log(Log::YouMuted,
+ Global::get().l->log(Log::YouMuted,
tr("You were unmuted by %1.").arg(Log::formatClientUser(pSrc, Log::Source)));
}
if (msg.has_deaf()) {
if (!pDst->bDeaf)
- g.l->log(Log::YouMuted,
+ Global::get().l->log(Log::YouMuted,
tr("You were undeafened by %1.").arg(Log::formatClientUser(pSrc, Log::Source)));
}
}
if (msg.has_suppress()) {
if (pDst->bSuppress)
- g.l->log(Log::YouMuted, tr("You were suppressed."));
+ Global::get().l->log(Log::YouMuted, tr("You were suppressed."));
else {
if (msg.has_channel_id())
- g.l->log(Log::YouMuted, tr("You were unsuppressed."));
+ Global::get().l->log(Log::YouMuted, tr("You were unsuppressed."));
else
- g.l->log(Log::YouMuted,
+ Global::get().l->log(Log::YouMuted,
tr("You were unsuppressed by %1.").arg(Log::formatClientUser(pSrc, Log::Source)));
}
}
@@ -699,24 +697,24 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
updateTrayIcon();
} else if (pSrc == pSelf) {
if (msg.has_mute() && msg.has_deaf() && pDst->bMute && pDst->bDeaf) {
- g.l->log(Log::YouMutedOther,
+ Global::get().l->log(Log::YouMutedOther,
tr("You muted and deafened %1.").arg(Log::formatClientUser(pDst, Log::Target)));
} else if (msg.has_mute() && msg.has_deaf() && !pDst->bMute && !pDst->bDeaf) {
- g.l->log(Log::YouMutedOther,
+ Global::get().l->log(Log::YouMutedOther,
tr("You unmuted and undeafened %1.").arg(Log::formatClientUser(pDst, Log::Target)));
} else {
if (msg.has_mute()) {
if (pDst->bMute)
- g.l->log(Log::YouMutedOther,
+ Global::get().l->log(Log::YouMutedOther,
tr("You muted %1.").arg(Log::formatClientUser(pDst, Log::Target)));
else
- g.l->log(Log::YouMutedOther,
+ Global::get().l->log(Log::YouMutedOther,
tr("You unmuted %1.").arg(Log::formatClientUser(pDst, Log::Target)));
}
if (msg.has_deaf()) {
if (!pDst->bDeaf)
- g.l->log(Log::YouMutedOther,
+ Global::get().l->log(Log::YouMutedOther,
tr("You undeafened %1.").arg(Log::formatClientUser(pDst, Log::Target)));
}
}
@@ -724,37 +722,37 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
if (msg.has_suppress()) {
if (!msg.has_channel_id()) {
if (pDst->bSuppress)
- g.l->log(Log::YouMutedOther,
+ Global::get().l->log(Log::YouMutedOther,
tr("You suppressed %1.").arg(Log::formatClientUser(pDst, Log::Target)));
else
- g.l->log(Log::YouMutedOther,
+ Global::get().l->log(Log::YouMutedOther,
tr("You unsuppressed %1.").arg(Log::formatClientUser(pDst, Log::Target)));
}
}
} else {
if (msg.has_mute() && msg.has_deaf() && pDst->bMute && pDst->bDeaf) {
- g.l->log(Log::OtherMutedOther, tr("%1 muted and deafened by %2.")
+ Global::get().l->log(Log::OtherMutedOther, tr("%1 muted and deafened by %2.")
.arg(Log::formatClientUser(pDst, Log::Target),
Log::formatClientUser(pSrc, Log::Source)));
} else if (msg.has_mute() && msg.has_deaf() && !pDst->bMute && !pDst->bDeaf) {
- g.l->log(Log::OtherMutedOther, tr("%1 unmuted and undeafened by %2.")
+ Global::get().l->log(Log::OtherMutedOther, tr("%1 unmuted and undeafened by %2.")
.arg(Log::formatClientUser(pDst, Log::Target),
Log::formatClientUser(pSrc, Log::Source)));
} else {
if (msg.has_mute()) {
if (pDst->bMute)
- g.l->log(Log::OtherMutedOther, tr("%1 muted by %2.")
+ Global::get().l->log(Log::OtherMutedOther, tr("%1 muted by %2.")
.arg(Log::formatClientUser(pDst, Log::Target),
Log::formatClientUser(pSrc, Log::Source)));
else
- g.l->log(Log::OtherMutedOther, tr("%1 unmuted by %2.")
+ Global::get().l->log(Log::OtherMutedOther, tr("%1 unmuted by %2.")
.arg(Log::formatClientUser(pDst, Log::Target),
Log::formatClientUser(pSrc, Log::Source)));
}
if (msg.has_deaf()) {
if (!pDst->bDeaf)
- g.l->log(Log::OtherMutedOther, tr("%1 undeafened by %2.")
+ Global::get().l->log(Log::OtherMutedOther, tr("%1 undeafened by %2.")
.arg(Log::formatClientUser(pDst, Log::Target),
Log::formatClientUser(pSrc, Log::Source)));
}
@@ -763,11 +761,11 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
if (msg.has_suppress()) {
if (!msg.has_channel_id()) {
if (pDst->bSuppress)
- g.l->log(Log::OtherMutedOther, tr("%1 suppressed by %2.")
+ Global::get().l->log(Log::OtherMutedOther, tr("%1 suppressed by %2.")
.arg(Log::formatClientUser(pDst, Log::Target),
Log::formatClientUser(pSrc, Log::Source)));
else
- g.l->log(Log::OtherMutedOther, tr("%1 unsuppressed by %2.")
+ Global::get().l->log(Log::OtherMutedOther, tr("%1 unsuppressed by %2.")
.arg(Log::formatClientUser(pDst, Log::Target),
Log::formatClientUser(pSrc, Log::Source)));
}
@@ -780,7 +778,7 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
pDst->qbaTextureHash = blob(msg.texture_hash());
pDst->qbaTexture = QByteArray();
#ifdef USE_OVERLAY
- g.o->verifyTexture(pDst);
+ Global::get().o->verifyTexture(pDst);
#endif
}
if (msg.has_texture()) {
@@ -789,10 +787,10 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
pDst->qbaTextureHash = QByteArray();
} else {
pDst->qbaTextureHash = sha1(pDst->qbaTexture);
- g.db->setBlob(pDst->qbaTextureHash, pDst->qbaTexture);
+ Global::get().db->setBlob(pDst->qbaTextureHash, pDst->qbaTexture);
}
#ifdef USE_OVERLAY
- g.o->verifyTexture(pDst);
+ Global::get().o->verifyTexture(pDst);
#endif
}
if (msg.has_comment_hash())
@@ -817,38 +815,38 @@ void MainWindow::msgUserRemove(const MumbleProto::UserRemove &msg) {
if (pDst == pSelf) {
bRetryServer = false;
if (msg.ban())
- g.l->log(Log::YouKicked, tr("You were kicked and banned from the server by %1: %2.")
+ Global::get().l->log(Log::YouKicked, tr("You were kicked and banned from the server by %1: %2.")
.arg(Log::formatClientUser(pSrc, Log::Source))
.arg(reason));
else
- g.l->log(Log::YouKicked, tr("You were kicked from the server by %1: %2.")
+ Global::get().l->log(Log::YouKicked, tr("You were kicked from the server by %1: %2.")
.arg(Log::formatClientUser(pSrc, Log::Source))
.arg(reason));
} else if (pSrc) {
if (msg.ban())
- g.l->log((pSrc == pSelf) ? Log::YouKicked : Log::UserKicked,
+ Global::get().l->log((pSrc == pSelf) ? Log::YouKicked : Log::UserKicked,
tr("%3 was kicked and banned from the server by %1: %2.")
.arg(Log::formatClientUser(pSrc, Log::Source))
.arg(reason)
.arg(Log::formatClientUser(pDst, Log::Target)));
else
- g.l->log((pSrc == pSelf) ? Log::YouKicked : Log::UserKicked,
+ Global::get().l->log((pSrc == pSelf) ? Log::YouKicked : Log::UserKicked,
tr("%3 was kicked from the server by %1: %2.")
.arg(Log::formatClientUser(pSrc, Log::Source))
.arg(reason)
.arg(Log::formatClientUser(pDst, Log::Target)));
} else {
if (pDst->cChannel == pSelf->cChannel || pDst->cChannel->allLinks().contains(pSelf->cChannel)) {
- g.l->log(Log::ChannelLeaveDisconnect,
+ Global::get().l->log(Log::ChannelLeaveDisconnect,
tr("%1 left channel and disconnected.").arg(Log::formatClientUser(pDst, Log::Source)));
} else {
- g.l->log(Log::UserLeave, tr("%1 disconnected.").arg(Log::formatClientUser(pDst, Log::Source)));
+ Global::get().l->log(Log::UserLeave, tr("%1 disconnected.").arg(Log::formatClientUser(pDst, Log::Source)));
}
}
if (pDst != pSelf)
pmModel->removeUser(pDst);
- QMetaObject::invokeMethod(g.talkingUI, "on_clientDisconnected", Qt::QueuedConnection,
+ QMetaObject::invokeMethod(Global::get().talkingUI, "on_clientDisconnected", Qt::QueuedConnection,
Q_ARG(unsigned int, pDst->uiSession));
}
@@ -870,9 +868,9 @@ void MainWindow::msgChannelState(const MumbleProto::ChannelState &msg) {
c->bTemporary = msg.temporary();
p = nullptr; // No need to move it later
- ServerHandlerPtr sh = g.sh;
+ ServerHandlerPtr sh = Global::get().sh;
if (sh)
- c->bFiltered = g.db->isChannelFiltered(sh->qbaDigest, c->iId);
+ c->bFiltered = Global::get().db->isChannelFiltered(sh->qbaDigest, c->iId);
} else {
qWarning("Server attempted state change on nonexistent channel");
@@ -965,14 +963,14 @@ void MainWindow::msgChannelRemove(const MumbleProto::ChannelRemove &msg) {
Channel *c = Channel::get(msg.channel_id());
if (c && (c->iId != 0)) {
if (c->bFiltered) {
- ServerHandlerPtr sh = g.sh;
+ ServerHandlerPtr sh = Global::get().sh;
if (sh)
- g.db->setChannelFiltered(sh->qbaDigest, c->iId, false);
+ Global::get().db->setChannelFiltered(sh->qbaDigest, c->iId, false);
c->bFiltered = false;
}
if (!pmModel->removeChannel(c, true)) {
- g.l->log(Log::CriticalError, tr("Protocol violation. Server sent remove for occupied channel."));
- g.sh->disconnect();
+ Global::get().l->log(Log::CriticalError, tr("Protocol violation. Server sent remove for occupied channel."));
+ Global::get().sh->disconnect();
return;
}
}
@@ -1005,20 +1003,20 @@ void MainWindow::msgTextMessage(const MumbleProto::TextMessage &msg) {
// If NoScope or NoAuthor is selected generate a new string to pass to TTS
const QString overrideTTS = [&]() {
- if (!g.s.bTTSNoScope && !g.s.bTTSNoAuthor) {
+ if (!Global::get().s.bTTSNoScope && !Global::get().s.bTTSNoAuthor) {
return QString();
}
const QString plainMessage = QTextDocumentFragment::fromHtml(u8(msg.message())).toPlainText();
- if (g.s.bTTSNoScope && g.s.bTTSNoAuthor) {
+ if (Global::get().s.bTTSNoScope && Global::get().s.bTTSNoAuthor) {
return plainMessage;
}
- const QString prefixTTS = g.s.bTTSNoScope ? plainName : target;
+ const QString prefixTTS = Global::get().s.bTTSNoScope ? plainName : target;
return tr("%1: %2").arg(prefixTTS).arg(plainMessage);
}();
const QString prefixMessage = target.isEmpty() ? name : tr("(%1) %2").arg(target).arg(name);
- g.l->log(privateMessage ? Log::PrivateTextMessage : Log::TextMessage,
+ Global::get().l->log(privateMessage ? Log::PrivateTextMessage : Log::TextMessage,
tr("%1: %2").arg(prefixMessage).arg(u8(msg.message())), tr("Message from %1").arg(plainName), false,
overrideTTS, pSrc ? pSrc->bLocalIgnoreTTS : false);
}
@@ -1053,7 +1051,7 @@ void MainWindow::msgPing(const MumbleProto::Ping &) {
}
void MainWindow::msgCryptSetup(const MumbleProto::CryptSetup &msg) {
- ConnectionPtr c = g.sh->cConnection;
+ ConnectionPtr c = Global::get().sh->cConnection;
if (!c)
return;
if (msg.has_key() && msg.has_client_nonce() && msg.has_server_nonce()) {
@@ -1074,7 +1072,7 @@ void MainWindow::msgCryptSetup(const MumbleProto::CryptSetup &msg) {
} else {
MumbleProto::CryptSetup mpcs;
mpcs.set_client_nonce(c->csCrypt->getEncryptIV());
- g.sh->sendMessage(mpcs);
+ Global::get().sh->sendMessage(mpcs);
}
}
@@ -1097,7 +1095,7 @@ void MainWindow::msgContextActionModify(const MumbleProto::ContextActionModify &
if (msg.has_operation() && msg.operation() != MumbleProto::ContextActionModify_Operation_Add)
return;
- QAction *a = new QAction(u8(msg.text()), g.mw);
+ QAction *a = new QAction(u8(msg.text()), Global::get().mw);
a->setData(u8(msg.action()));
connect(a, SIGNAL(triggered()), this, SLOT(context_triggered()));
unsigned int ctx = msg.context();
@@ -1144,13 +1142,13 @@ void MainWindow::removeContextAction(const MumbleProto::ContextActionModify &msg
/// @param msg The message object with the respective information
void MainWindow::msgVersion(const MumbleProto::Version &msg) {
if (msg.has_version())
- g.sh->uiVersion = msg.version();
+ Global::get().sh->uiVersion = msg.version();
if (msg.has_release())
- g.sh->qsRelease = u8(msg.release());
+ Global::get().sh->qsRelease = u8(msg.release());
if (msg.has_os()) {
- g.sh->qsOS = u8(msg.os());
+ Global::get().sh->qsOS = u8(msg.os());
if (msg.has_os_version())
- g.sh->qsOSVersion = u8(msg.os_version());
+ Global::get().sh->qsOSVersion = u8(msg.os_version());
}
}
@@ -1185,7 +1183,7 @@ void MainWindow::msgPermissionQuery(const MumbleProto::PermissionQuery &msg) {
// We always need the permissions of the current focus channel
if (current && current->iId != static_cast< int >(msg.channel_id())) {
- g.sh->requestChannelPermissions(current->iId);
+ Global::get().sh->requestChannelPermissions(current->iId);
current->uiPermissions = ChanACL::All;
}
@@ -1194,7 +1192,7 @@ void MainWindow::msgPermissionQuery(const MumbleProto::PermissionQuery &msg) {
if (c) {
c->uiPermissions = msg.permissions();
if (c->iId == 0)
- g.pPermissions = static_cast< ChanACL::Permissions >(c->uiPermissions);
+ Global::get().pPermissions = static_cast< ChanACL::Permissions >(c->uiPermissions);
if (c == current) {
updateMenuPermissions();
}
@@ -1212,41 +1210,41 @@ void MainWindow::msgCodecVersion(const MumbleProto::CodecVersion &msg) {
#ifdef USE_OPUS
static bool warnedOpus = false;
- g.bOpus = msg.opus();
+ Global::get().bOpus = msg.opus();
- if (!g.oCodec && !warnedOpus) {
- g.l->log(Log::CriticalError, tr("Failed to load Opus, it will not be available for audio encoding/decoding."));
+ if (!Global::get().oCodec && !warnedOpus) {
+ Global::get().l->log(Log::CriticalError, tr("Failed to load Opus, it will not be available for audio encoding/decoding."));
warnedOpus = true;
}
#endif
// Workaround for broken 1.2.2 servers
- if (g.sh && g.sh->uiVersion == 0x010202 && alpha != -1 && alpha == beta) {
+ if (Global::get().sh && Global::get().sh->uiVersion == 0x010202 && alpha != -1 && alpha == beta) {
if (pref)
- beta = g.iCodecBeta;
+ beta = Global::get().iCodecBeta;
else
- alpha = g.iCodecAlpha;
+ alpha = Global::get().iCodecAlpha;
}
- if ((alpha != -1) && (alpha != g.iCodecAlpha)) {
- g.iCodecAlpha = alpha;
- if (pref && !g.qmCodecs.contains(alpha))
+ if ((alpha != -1) && (alpha != Global::get().iCodecAlpha)) {
+ Global::get().iCodecAlpha = alpha;
+ if (pref && !Global::get().qmCodecs.contains(alpha))
pref = !pref;
}
- if ((beta != -1) && (beta != g.iCodecBeta)) {
- g.iCodecBeta = beta;
- if (!pref && !g.qmCodecs.contains(beta))
+ if ((beta != -1) && (beta != Global::get().iCodecBeta)) {
+ Global::get().iCodecBeta = beta;
+ if (!pref && !Global::get().qmCodecs.contains(beta))
pref = !pref;
}
- g.bPreferAlpha = pref;
+ Global::get().bPreferAlpha = pref;
- int willuse = pref ? g.iCodecAlpha : g.iCodecBeta;
+ int willuse = pref ? Global::get().iCodecAlpha : Global::get().iCodecBeta;
static bool warnedCELT = false;
- if (!g.qmCodecs.contains(willuse)) {
+ if (!Global::get().qmCodecs.contains(willuse)) {
if (!warnedCELT) {
- g.l->log(Log::CriticalError, tr("Unable to find matching CELT codecs with other clients. You will not be "
+ Global::get().l->log(Log::CriticalError, tr("Unable to find matching CELT codecs with other clients. You will not be "
"able to talk to all users."));
warnedCELT = true;
}
@@ -1264,7 +1262,7 @@ void MainWindow::msgUserStats(const MumbleProto::UserStats &msg) {
ui->update(msg);
} else {
#ifdef USE_OVERLAY
- ui = new UserInformation(msg, g.ocIntercept ? g.mw : nullptr);
+ ui = new UserInformation(msg, Global::get().ocIntercept ? Global::get().mw : nullptr);
#else
ui = new UserInformation(msg, nullptr);
#endif
@@ -1277,7 +1275,7 @@ void MainWindow::msgUserStats(const MumbleProto::UserStats &msg) {
}
/// This message is only ever sent by the client in order to request binary data that otherwise
-/// wouldn't be included in the normal messages (e.g. big images). Thus this implementation does
+/// wouldn't be included in the normal messages (e.Global::get(). big images). Thus this implementation does
/// nothing.
void MainWindow::msgRequestBlob(const MumbleProto::RequestBlob &) {
}
@@ -1288,19 +1286,19 @@ void MainWindow::msgRequestBlob(const MumbleProto::RequestBlob &) {
/// @param msg The message object containing the suggestions
void MainWindow::msgSuggestConfig(const MumbleProto::SuggestConfig &msg) {
if (msg.has_version() && (msg.version() > MumbleVersion::getRaw())) {
- g.l->log(Log::Warning,
+ Global::get().l->log(Log::Warning,
tr("The server requests minimum client version %1").arg(MumbleVersion::toString(msg.version())));
}
- if (msg.has_positional() && (msg.positional() != g.s.doPositionalAudio())) {
+ if (msg.has_positional() && (msg.positional() != Global::get().s.doPositionalAudio())) {
if (msg.positional())
- g.l->log(Log::Warning, tr("The server requests positional audio be enabled."));
+ Global::get().l->log(Log::Warning, tr("The server requests positional audio be enabled."));
else
- g.l->log(Log::Warning, tr("The server requests positional audio be disabled."));
+ Global::get().l->log(Log::Warning, tr("The server requests positional audio be disabled."));
}
- if (msg.has_push_to_talk() && (msg.push_to_talk() != (g.s.atTransmit == Settings::PushToTalk))) {
+ if (msg.has_push_to_talk() && (msg.push_to_talk() != (Global::get().s.atTransmit == Settings::PushToTalk))) {
if (msg.push_to_talk())
- g.l->log(Log::Warning, tr("The server requests Push-to-Talk be enabled."));
+ Global::get().l->log(Log::Warning, tr("The server requests Push-to-Talk be enabled."));
else
- g.l->log(Log::Warning, tr("The server requests Push-to-Talk be disabled."));
+ Global::get().l->log(Log::Warning, tr("The server requests Push-to-Talk be disabled."));
}
}
diff --git a/src/mumble/MumbleApplication.cpp b/src/mumble/MumbleApplication.cpp
index 005f2c124..eb78b40b3 100644
--- a/src/mumble/MumbleApplication.cpp
+++ b/src/mumble/MumbleApplication.cpp
@@ -8,6 +8,7 @@
#include "EnvUtils.h"
#include "MainWindow.h"
#include "GlobalShortcut.h"
+#include "Global.h"
#if defined(Q_OS_WIN)
# include "GlobalShortcut_win.h"
@@ -15,10 +16,6 @@
#include <QtGui/QFileOpenEvent>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
MumbleApplication *MumbleApplication::instance() {
return static_cast< MumbleApplication * >(QCoreApplication::instance());
}
@@ -38,9 +35,9 @@ QString MumbleApplication::applicationVersionRootPath() {
void MumbleApplication::onCommitDataRequest(QSessionManager &) {
// Make sure the config is saved and supress the ask on quit message
- if (g.mw) {
- g.s.save();
- g.mw->bSuppressAskOnQuit = true;
+ if (Global::get().mw) {
+ Global::get().s.save();
+ Global::get().mw->bSuppressAskOnQuit = true;
qWarning() << "Session likely ending. Suppressing ask on quit";
}
}
@@ -48,10 +45,10 @@ void MumbleApplication::onCommitDataRequest(QSessionManager &) {
bool MumbleApplication::event(QEvent *e) {
if (e->type() == QEvent::FileOpen) {
QFileOpenEvent *foe = static_cast< QFileOpenEvent * >(e);
- if (!g.mw) {
+ if (!Global::get().mw) {
this->quLaunchURL = foe->url();
} else {
- g.mw->openUrl(foe->url());
+ Global::get().mw->openUrl(foe->url());
}
return true;
}
diff --git a/src/mumble/NetworkConfig.cpp b/src/mumble/NetworkConfig.cpp
index d5bc0feb3..59b8fbf9a 100644
--- a/src/mumble/NetworkConfig.cpp
+++ b/src/mumble/NetworkConfig.cpp
@@ -7,6 +7,7 @@
#include "MainWindow.h"
#include "OSInfo.h"
+#include "Global.h"
#include <QSignalBlocker>
#include <QtNetwork/QHostAddress>
@@ -17,10 +18,6 @@
# include <QMessageBox>
#endif
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
const QString NetworkConfig::name = QLatin1String("NetworkConfig");
static ConfigWidget *NetworkConfigNew(Settings &st) {
@@ -114,11 +111,11 @@ static QNetworkProxy::ProxyType local_to_qt_proxy(Settings::ProxyType pt) {
void NetworkConfig::SetupProxy() {
QNetworkProxy proxy;
- proxy.setType(local_to_qt_proxy(g.s.ptProxyType));
- proxy.setHostName(g.s.qsProxyHost);
- proxy.setPort(g.s.usProxyPort);
- proxy.setUser(g.s.qsProxyUsername);
- proxy.setPassword(g.s.qsProxyPassword);
+ proxy.setType(local_to_qt_proxy(Global::get().s.ptProxyType));
+ proxy.setHostName(Global::get().s.qsProxyHost);
+ proxy.setPort(Global::get().s.usProxyPort);
+ proxy.setUser(Global::get().s.qsProxyUsername);
+ proxy.setPassword(Global::get().s.qsProxyPassword);
QNetworkProxy::setApplicationProxy(proxy);
}
@@ -138,7 +135,7 @@ bool NetworkConfig::TcpModeEnabled() {
* itself already is a potential latency killer.
*/
- return g.s.ptProxyType != Settings::NoProxy || g.s.bTCPCompat;
+ return Global::get().s.ptProxyType != Settings::NoProxy || Global::get().s.bTCPCompat;
}
void NetworkConfig::accept() const {
@@ -181,14 +178,14 @@ void NetworkConfig::on_qcbAutoUpdate_stateChanged(int state) {
QNetworkReply *Network::get(const QUrl &url) {
QNetworkRequest req(url);
prepareRequest(req);
- return g.nam->get(req);
+ return Global::get().nam->get(req);
}
void Network::prepareRequest(QNetworkRequest &req) {
req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
// Do not send OS information if the corresponding privacy setting is enabled
- if (g.s.bHideOS) {
+ if (Global::get().s.bHideOS) {
req.setRawHeader(QString::fromLatin1("User-Agent").toUtf8(),
QString::fromLatin1("Mozilla/5.0 Mumble/%1 %2")
.arg(QLatin1String(MUMTEXT(MUMBLE_VERSION)), QLatin1String(MUMBLE_RELEASE))
diff --git a/src/mumble/OSS.cpp b/src/mumble/OSS.cpp
index ac86950ff..ac37a3d33 100644
--- a/src/mumble/OSS.cpp
+++ b/src/mumble/OSS.cpp
@@ -12,9 +12,6 @@
#include "MainWindow.h"
#include "User.h"
-
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
#include "Global.h"
#define NBLOCKS 8
@@ -74,9 +71,9 @@ const QList< audioDevice > OSSInputRegistrar::getDeviceChoices() {
QStringList qlInputDevs = cards->qhInput.keys();
std::sort(qlInputDevs.begin(), qlInputDevs.end());
- if (qlInputDevs.contains(g.s.qsOSSInput)) {
- qlInputDevs.removeAll(g.s.qsOSSInput);
- qlInputDevs.prepend(g.s.qsOSSInput);
+ if (qlInputDevs.contains(Global::get().s.qsOSSInput)) {
+ qlInputDevs.removeAll(Global::get().s.qsOSSInput);
+ qlInputDevs.prepend(Global::get().s.qsOSSInput);
}
foreach (const QString &dev, qlInputDevs) { qlReturn << audioDevice(cards->qhInput.value(dev), dev); }
@@ -105,9 +102,9 @@ const QList< audioDevice > OSSOutputRegistrar::getDeviceChoices() {
QStringList qlOutputDevs = cards->qhOutput.keys();
std::sort(qlOutputDevs.begin(), qlOutputDevs.end());
- if (qlOutputDevs.contains(g.s.qsOSSOutput)) {
- qlOutputDevs.removeAll(g.s.qsOSSOutput);
- qlOutputDevs.prepend(g.s.qsOSSOutput);
+ if (qlOutputDevs.contains(Global::get().s.qsOSSOutput)) {
+ qlOutputDevs.removeAll(Global::get().s.qsOSSOutput);
+ qlOutputDevs.prepend(Global::get().s.qsOSSOutput);
}
foreach (const QString &dev, qlOutputDevs) { qlReturn << audioDevice(cards->qhOutput.value(dev), dev); }
@@ -175,7 +172,7 @@ OSSInput::~OSSInput() {
}
void OSSInput::run() {
- QByteArray device = cards->qhDevices.value(g.s.qsOSSInput).toLatin1();
+ QByteArray device = cards->qhDevices.value(Global::get().s.qsOSSInput).toLatin1();
if (device.isEmpty()) {
qWarning("OSSInput: Stored device not found, falling back to default");
device = cards->qhDevices.value(QString()).toLatin1();
@@ -249,7 +246,7 @@ OSSOutput::~OSSOutput() {
}
void OSSOutput::run() {
- QByteArray device = cards->qhDevices.value(g.s.qsOSSOutput).toLatin1();
+ QByteArray device = cards->qhDevices.value(Global::get().s.qsOSSOutput).toLatin1();
if (device.isEmpty()) {
qWarning("OSSOutput: Stored device not found, falling back to default");
device = cards->qhDevices.value(QString()).toLatin1();
@@ -263,7 +260,7 @@ void OSSOutput::run() {
int ival;
- ival = (g.s.iOutputDelay + 1) << 16 | 11;
+ ival = (Global::get().s.iOutputDelay + 1) << 16 | 11;
if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &ival) == -1) {
qWarning("OSSOutput: Failed to set fragment");
diff --git a/src/mumble/Overlay.cpp b/src/mumble/Overlay.cpp
index 6782ba949..30e928c08 100644
--- a/src/mumble/Overlay.cpp
+++ b/src/mumble/Overlay.cpp
@@ -18,6 +18,7 @@
#include "Utils.h"
#include "WebFetch.h"
#include "GlobalShortcut.h"
+#include "Global.h"
#include <QtCore/QProcessEnvironment>
#include <QtCore/QtEndian>
@@ -36,10 +37,6 @@
# include <CoreFoundation/CoreFoundation.h>
#endif
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
QString OverlayAppInfo::applicationIdentifierForPath(const QString &path) {
#ifdef Q_OS_MAC
QString qsIdentifier;
@@ -312,8 +309,8 @@ bool Overlay::isActive() const {
}
void Overlay::toggleShow() {
- if (g.ocIntercept) {
- g.ocIntercept->hideGui();
+ if (Global::get().ocIntercept) {
+ Global::get().ocIntercept->hideGui();
} else {
foreach (OverlayClient *oc, qlClients) {
if (oc->uiPid) {
@@ -348,11 +345,11 @@ void Overlay::forceSettings() {
void Overlay::verifyTexture(ClientUser *cp, bool allowupdate) {
qsQueried.remove(cp->uiSession);
- ClientUser *self = ClientUser::get(g.uiSession);
+ ClientUser *self = ClientUser::get(Global::get().uiSession);
allowupdate = allowupdate && self && self->cChannel->isLinked(cp->cChannel);
if (allowupdate && !cp->qbaTextureHash.isEmpty() && cp->qbaTexture.isEmpty())
- cp->qbaTexture = g.db->blob(cp->qbaTextureHash);
+ cp->qbaTexture = Global::get().db->blob(cp->qbaTextureHash);
if (!cp->qbaTexture.isEmpty()) {
bool valid = true;
@@ -458,7 +455,7 @@ void Overlay::verifyTexture(ClientUser *cp, bool allowupdate) {
typedef QPair< QString, quint32 > qpChanCol;
void Overlay::updateOverlay() {
- if (!g.uiSession)
+ if (!Global::get().uiSession)
qsQueried.clear();
if (qlClients.isEmpty())
@@ -481,13 +478,13 @@ void Overlay::updateOverlay() {
qsQueried.insert(session);
mprb.add_session_texture(session);
}
- g.sh->sendMessage(mprb);
+ Global::get().sh->sendMessage(mprb);
}
}
void Overlay::requestTexture(ClientUser *cu) {
if (cu->qbaTexture.isEmpty() && !qsQueried.contains(cu->uiSession)) {
- cu->qbaTexture = g.db->blob(cu->qbaTextureHash);
+ cu->qbaTexture = Global::get().db->blob(cu->qbaTextureHash);
if (cu->qbaTexture.isEmpty())
qsQuery.insert(cu->uiSession);
else
diff --git a/src/mumble/OverlayClient.cpp b/src/mumble/OverlayClient.cpp
index 7e3cdfc78..24b229b95 100644
--- a/src/mumble/OverlayClient.cpp
+++ b/src/mumble/OverlayClient.cpp
@@ -17,6 +17,7 @@
#include "User.h"
#include "Utils.h"
#include "GlobalShortcut.h"
+#include "Global.h"
#ifdef Q_OS_WIN
# include <QtGui/QBitmap>
@@ -29,12 +30,8 @@
# include <psapi.h>
#endif
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
OverlayClient::OverlayClient(QLocalSocket *socket, QObject *p)
- : QObject(p), framesPerSecond(0), ougUsers(&g.s.os), iMouseX(0), iMouseY(0) {
+ : QObject(p), framesPerSecond(0), ougUsers(&Global::get().s.os), iMouseX(0), iMouseY(0) {
qlsSocket = socket;
qlsSocket->setParent(nullptr);
connect(qlsSocket, SIGNAL(readyRead()), this, SLOT(readyRead()));
@@ -63,15 +60,15 @@ OverlayClient::OverlayClient(QLocalSocket *socket, QObject *p)
qgs.addItem(&ougUsers);
ougUsers.show();
- qgpiFPS.reset(new OverlayPositionableItem(&g.s.os.qrfFps));
+ qgpiFPS.reset(new OverlayPositionableItem(&Global::get().s.os.qrfFps));
qgs.addItem(qgpiFPS.data());
- qgpiFPS->setPos(g.s.os.qrfFps.x(), g.s.os.qrfFps.y());
+ qgpiFPS->setPos(Global::get().s.os.qrfFps.x(), Global::get().s.os.qrfFps.y());
qgpiFPS->show();
// Time
- qgpiTime.reset(new OverlayPositionableItem(&g.s.os.qrfTime));
+ qgpiTime.reset(new OverlayPositionableItem(&Global::get().s.os.qrfTime));
qgs.addItem(qgpiTime.data());
- qgpiTime->setPos(g.s.os.qrfTime.x(), g.s.os.qrfTime.y());
+ qgpiTime->setPos(Global::get().s.os.qrfTime.x(), Global::get().s.os.qrfTime.y());
qgpiTime->show();
iOffsetX = iOffsetY = 0;
@@ -100,10 +97,10 @@ bool OverlayClient::eventFilter(QObject *o, QEvent *e) {
}
void OverlayClient::updateFPS() {
- if (g.s.os.bFps) {
+ if (Global::get().s.os.bFps) {
const BasepointPixmap &pm =
- OverlayTextLine(QString(QLatin1String("%1")).arg(iroundf(framesPerSecond + 0.5f)), g.s.os.qfFps)
- .createPixmap(g.s.os.qcFps);
+ OverlayTextLine(QString(QLatin1String("%1")).arg(iroundf(framesPerSecond + 0.5f)), Global::get().s.os.qfFps)
+ .createPixmap(Global::get().s.os.qcFps);
qgpiFPS->setVisible(true);
qgpiFPS->setPixmap(pm);
// offset to use basepoint
@@ -116,10 +113,10 @@ void OverlayClient::updateFPS() {
}
void OverlayClient::updateTime() {
- if (g.s.os.bTime) {
+ if (Global::get().s.os.bTime) {
const BasepointPixmap &pm =
- OverlayTextLine(QString(QLatin1String("%1")).arg(QTime::currentTime().toString()), g.s.os.qfFps)
- .createPixmap(g.s.os.qcFps);
+ OverlayTextLine(QString(QLatin1String("%1")).arg(QTime::currentTime().toString()), Global::get().s.os.qfFps)
+ .createPixmap(Global::get().s.os.qcFps);
qgpiTime->setVisible(true);
qgpiTime->setPixmap(pm);
qgpiTime->setOffset(-pm.qpBasePoint + QPoint(0, pm.iAscent));
@@ -195,7 +192,7 @@ void OverlayClient::showGui() {
{
QWidgetList widgets = qApp->topLevelWidgets();
foreach (QWidget *w, widgets) {
- if (w->isHidden() && (w != g.mw))
+ if (w->isHidden() && (w != Global::get().mw))
continue;
count++;
}
@@ -204,34 +201,34 @@ void OverlayClient::showGui() {
if (count > 1)
return;
- g.ocIntercept = this;
+ Global::get().ocIntercept = this;
- bWasVisible = !g.mw->isHidden();
+ bWasVisible = !Global::get().mw->isHidden();
if (bWasVisible) {
- if (g.s.bMinimalView) {
- g.s.qbaMinimalViewGeometry = g.mw->saveGeometry();
- g.s.qbaMinimalViewState = g.mw->saveState();
+ if (Global::get().s.bMinimalView) {
+ Global::get().s.qbaMinimalViewGeometry = Global::get().mw->saveGeometry();
+ Global::get().s.qbaMinimalViewState = Global::get().mw->saveState();
} else {
- g.s.qbaMainWindowGeometry = g.mw->saveGeometry();
- g.s.qbaMainWindowState = g.mw->saveState();
- g.s.qbaHeaderState = g.mw->qtvUsers->header()->saveState();
+ Global::get().s.qbaMainWindowGeometry = Global::get().mw->saveGeometry();
+ Global::get().s.qbaMainWindowState = Global::get().mw->saveState();
+ Global::get().s.qbaHeaderState = Global::get().mw->qtvUsers->header()->saveState();
}
}
{
outer:
QWidgetList widgets = qApp->topLevelWidgets();
- widgets.removeAll(g.mw);
- widgets.prepend(g.mw);
+ widgets.removeAll(Global::get().mw);
+ widgets.prepend(Global::get().mw);
foreach (QWidget *w, widgets) {
if (!w->graphicsProxyWidget()) {
- if ((w == g.mw) || (!w->isHidden())) {
+ if ((w == Global::get().mw) || (!w->isHidden())) {
QGraphicsProxyWidget *qgpw = new QGraphicsProxyWidget(nullptr, Qt::Window);
qgpw->setOpacity(0.90f);
qgpw->setWidget(w);
- if (w == g.mw) {
+ if (w == Global::get().mw) {
qgpw->setPos(uiWidth / 10, uiHeight / 10);
qgpw->resize((uiWidth * 8) / 10, (uiHeight * 8) / 10);
}
@@ -256,9 +253,9 @@ void OverlayClient::showGui() {
qgs.setFocus();
#ifndef Q_OS_MAC
- g.mw->qteChat->activateWindow();
+ Global::get().mw->qteChat->activateWindow();
#endif
- g.mw->qteChat->setFocus();
+ Global::get().mw->qteChat->setFocus();
qgv.setAttribute(Qt::WA_WState_Hidden, false);
qApp->setActiveWindow(&qgv);
@@ -268,9 +265,9 @@ void OverlayClient::showGui() {
#ifdef Q_OS_MAC
qApp->setAttribute(Qt::AA_DontUseNativeMenuBar);
- g.mw->setUnifiedTitleAndToolBarOnMac(false);
- if (!g.s.os.qsStyle.isEmpty())
- qApp->setStyle(g.s.os.qsStyle);
+ Global::get().mw->setUnifiedTitleAndToolBarOnMac(false);
+ if (!Global::get().s.os.qsStyle.isEmpty())
+ qApp->setStyle(Global::get().s.os.qsStyle);
#endif
setupScene(true);
@@ -282,7 +279,7 @@ void OverlayClient::showGui() {
om.omin.state = true;
qlsSocket->write(om.headerbuffer, sizeof(OverlayMsgHeader) + om.omh.iLength);
- g.o->updateOverlay();
+ Global::get().o->updateOverlay();
}
void OverlayClient::hideGui() {
@@ -309,8 +306,8 @@ void OverlayClient::hideGui() {
}
}
- if (g.ocIntercept == this)
- g.ocIntercept = nullptr;
+ if (Global::get().ocIntercept == this)
+ Global::get().ocIntercept = nullptr;
foreach (QWidget *w, widgetlist) {
if (bWasVisible)
@@ -318,18 +315,18 @@ void OverlayClient::hideGui() {
}
if (bWasVisible) {
- if (g.s.bMinimalView && !g.s.qbaMinimalViewGeometry.isNull()) {
- g.mw->restoreGeometry(g.s.qbaMinimalViewGeometry);
- g.mw->restoreState(g.s.qbaMinimalViewState);
- } else if (!g.s.bMinimalView && !g.s.qbaMainWindowGeometry.isNull()) {
- g.mw->restoreGeometry(g.s.qbaMainWindowGeometry);
- g.mw->restoreState(g.s.qbaMainWindowState);
+ if (Global::get().s.bMinimalView && !Global::get().s.qbaMinimalViewGeometry.isNull()) {
+ Global::get().mw->restoreGeometry(Global::get().s.qbaMinimalViewGeometry);
+ Global::get().mw->restoreState(Global::get().s.qbaMinimalViewState);
+ } else if (!Global::get().s.bMinimalView && !Global::get().s.qbaMainWindowGeometry.isNull()) {
+ Global::get().mw->restoreGeometry(Global::get().s.qbaMainWindowGeometry);
+ Global::get().mw->restoreState(Global::get().s.qbaMainWindowState);
}
}
#ifdef Q_OS_MAC
qApp->setAttribute(Qt::AA_DontUseNativeMenuBar, false);
- g.mw->setUnifiedTitleAndToolBarOnMac(true);
+ Global::get().mw->setUnifiedTitleAndToolBarOnMac(true);
Themes::apply();
#endif
@@ -344,7 +341,7 @@ void OverlayClient::hideGui() {
om.omin.state = false;
qlsSocket->write(om.headerbuffer, sizeof(OverlayMsgHeader) + om.omh.iLength);
- g.o->updateOverlay();
+ Global::get().o->updateOverlay();
if (bDelete)
deleteLater();
@@ -474,7 +471,7 @@ void OverlayClient::reset() {
ougUsers.reset();
- setupScene(g.ocIntercept == this);
+ setupScene(Global::get().ocIntercept == this);
}
void OverlayClient::setupScene(bool show) {
@@ -651,7 +648,7 @@ void OverlayClient::render() {
}
void OverlayClient::openEditor() {
- OverlayEditor oe(g.mw, &ougUsers);
+ OverlayEditor oe(Global::get().mw, &ougUsers);
connect(&oe, SIGNAL(applySettings()), this, SLOT(updateLayout()));
oe.exec();
diff --git a/src/mumble/OverlayConfig.cpp b/src/mumble/OverlayConfig.cpp
index 8b16f0aa0..13f9b1dab 100644
--- a/src/mumble/OverlayConfig.cpp
+++ b/src/mumble/OverlayConfig.cpp
@@ -19,6 +19,7 @@
#include "ServerHandler.h"
#include "User.h"
#include "GlobalShortcut.h"
+#include "Global.h"
#ifdef Q_OS_WIN
# include "../../overlay/overlay_blacklist.h"
@@ -33,10 +34,6 @@
#include <QtWidgets/QFileDialog>
#include <QtWidgets/QFontDialog>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
const QString OverlayConfig::name = QLatin1String("OverlayConfig");
static const int OVERLAYCONFIG_PATH_ROLE = Qt::UserRole;
@@ -533,18 +530,18 @@ void OverlayConfig::save() const {
}
}
- g.qs->beginGroup(QLatin1String("overlay"));
+ Global::get().qs->beginGroup(QLatin1String("overlay"));
s.os.save();
- g.qs->endGroup();
+ Global::get().qs->endGroup();
#ifdef Q_OS_WIN
// On MS windows force sync so the registry is updated.
- g.qs->sync();
+ Global::get().qs->sync();
#endif
}
void OverlayConfig::accept() const {
- g.o->forceSettings();
- g.o->setActive(s.os.bEnable);
+ Global::get().o->forceSettings();
+ Global::get().o->setActive(s.os.bEnable);
}
bool OverlayConfig::eventFilter(QObject *obj, QEvent *evt) {
diff --git a/src/mumble/OverlayEditor.cpp b/src/mumble/OverlayEditor.cpp
index a37cddd52..e35ad417a 100644
--- a/src/mumble/OverlayEditor.cpp
+++ b/src/mumble/OverlayEditor.cpp
@@ -16,18 +16,15 @@
#include "User.h"
#include "Utils.h"
#include "GlobalShortcut.h"
+#include "Global.h"
#include <QtWidgets/QGraphicsProxyWidget>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
OverlayEditor::OverlayEditor(QWidget *p, QGraphicsItem *qgi, OverlaySettings *osptr)
- : QDialog(p), qgiPromote(qgi), oes(g.s.os) {
+ : QDialog(p), qgiPromote(qgi), oes(Global::get().s.os) {
setupUi(this);
qsZoom->setAccessibleName(tr("Zoom level"));
- os = osptr ? osptr : &g.s.os;
+ os = osptr ? osptr : &Global::get().s.os;
connect(qdbbBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply()));
connect(qdbbBox->button(QDialogButtonBox::Reset), SIGNAL(clicked()), this, SLOT(reset()));
@@ -35,11 +32,11 @@ OverlayEditor::OverlayEditor(QWidget *p, QGraphicsItem *qgi, OverlaySettings *os
QGraphicsProxyWidget *qgpw = graphicsProxyWidget();
if (qgpw) {
qgpw->setFlag(QGraphicsItem::ItemIgnoresParentOpacity);
- if (g.ocIntercept) {
- qgpw->setPos(iroundf(static_cast< float >(g.ocIntercept->uiWidth) / 16.0f + 0.5f),
- iroundf(static_cast< float >(g.ocIntercept->uiHeight) / 16.0f + 0.5f));
- qgpw->resize(iroundf(static_cast< float >(g.ocIntercept->uiWidth) * 14.0f / 16.0f + 0.5f),
- iroundf(static_cast< float >(g.ocIntercept->uiHeight) * 14.0f / 16.0f + 0.5f));
+ if (Global::get().ocIntercept) {
+ qgpw->setPos(iroundf(static_cast< float >(Global::get().ocIntercept->uiWidth) / 16.0f + 0.5f),
+ iroundf(static_cast< float >(Global::get().ocIntercept->uiHeight) / 16.0f + 0.5f));
+ qgpw->resize(iroundf(static_cast< float >(Global::get().ocIntercept->uiWidth) * 14.0f / 16.0f + 0.5f),
+ iroundf(static_cast< float >(Global::get().ocIntercept->uiHeight) * 14.0f / 16.0f + 0.5f));
}
}
@@ -49,7 +46,7 @@ OverlayEditor::OverlayEditor(QWidget *p, QGraphicsItem *qgi, OverlaySettings *os
}
OverlayEditor::~OverlayEditor() {
- QGraphicsProxyWidget *qgpw = g.mw->graphicsProxyWidget();
+ QGraphicsProxyWidget *qgpw = Global::get().mw->graphicsProxyWidget();
if (qgpw)
qgpw->setOpacity(0.9f);
if (qgiPromote)
@@ -57,7 +54,7 @@ OverlayEditor::~OverlayEditor() {
}
void OverlayEditor::enterEvent(QEvent *e) {
- QGraphicsProxyWidget *qgpw = g.mw->graphicsProxyWidget();
+ QGraphicsProxyWidget *qgpw = Global::get().mw->graphicsProxyWidget();
if (qgpw)
qgpw->setOpacity(0.9f);
@@ -72,7 +69,7 @@ void OverlayEditor::enterEvent(QEvent *e) {
}
void OverlayEditor::leaveEvent(QEvent *e) {
- QGraphicsProxyWidget *qgpw = g.mw->graphicsProxyWidget();
+ QGraphicsProxyWidget *qgpw = Global::get().mw->graphicsProxyWidget();
if (qgpw)
qgpw->setOpacity(0.3f);
diff --git a/src/mumble/OverlayEditorScene.cpp b/src/mumble/OverlayEditorScene.cpp
index a2bae4b63..2d4cb6f7b 100644
--- a/src/mumble/OverlayEditorScene.cpp
+++ b/src/mumble/OverlayEditorScene.cpp
@@ -17,6 +17,7 @@
#include "User.h"
#include "Utils.h"
#include "GlobalShortcut.h"
+#include "Global.h"
#include <QtGui/QImageReader>
#include <QtWidgets/QColorDialog>
@@ -24,16 +25,12 @@
#include <QtWidgets/QGraphicsProxyWidget>
#include <QtWidgets/QGraphicsSceneMouseEvent>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
OverlayEditorScene::OverlayEditorScene(const OverlaySettings &srcos, QObject *p) : QGraphicsScene(p), os(srcos) {
tsColor = Settings::Talking;
uiZoom = 2;
- if (g.ocIntercept)
- uiSize = g.ocIntercept->uiHeight;
+ if (Global::get().ocIntercept)
+ uiSize = Global::get().ocIntercept->uiHeight;
else
uiSize = 1080.f;
@@ -518,8 +515,8 @@ void OverlayEditorScene::updateCursorShape(const QPointF &point) {
QGraphicsProxyWidget *qgpw = p->graphicsProxyWidget();
if (qgpw) {
qgpw->setCursor(cs);
- if (g.ocIntercept)
- g.ocIntercept->updateMouse();
+ if (Global::get().ocIntercept)
+ Global::get().ocIntercept->updateMouse();
}
}
}
@@ -778,7 +775,7 @@ void OverlayEditorScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *e) {
qfd.setWindowTitle(tr("Pick font"));
int ret;
- if (g.ocIntercept) {
+ if (Global::get().ocIntercept) {
QGraphicsProxyWidget *qgpw = new QGraphicsProxyWidget(nullptr, Qt::Window);
qgpw->setWidget(&qfd);
@@ -795,7 +792,7 @@ void OverlayEditorScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *e) {
qgpw->setWidget(nullptr);
delete qgpw;
} else {
- Qt::WindowFlags wf = g.mw->windowFlags();
+ Qt::WindowFlags wf = Global::get().mw->windowFlags();
if (wf.testFlag(Qt::WindowStaysOnTopHint))
qfd.setWindowFlags(qfd.windowFlags() | Qt::WindowStaysOnTopHint);
ret = qfd.exec();
diff --git a/src/mumble/OverlayText.cpp b/src/mumble/OverlayText.cpp
index 50b5cbc72..4ba0bcf1e 100644
--- a/src/mumble/OverlayText.cpp
+++ b/src/mumble/OverlayText.cpp
@@ -12,10 +12,6 @@
#include <QtGui/QPainter>
#include <QtGui/QPen>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
BasepointPixmap::BasepointPixmap() : qpBasePoint(0, 0), iAscent(-1), iDescent(-1) {
}
diff --git a/src/mumble/OverlayUser.cpp b/src/mumble/OverlayUser.cpp
index 01660405f..59f210f14 100644
--- a/src/mumble/OverlayUser.cpp
+++ b/src/mumble/OverlayUser.cpp
@@ -16,13 +16,10 @@
#include "User.h"
#include "Utils.h"
#include "GlobalShortcut.h"
+#include "Global.h"
#include <QtGui/QImageReader>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
OverlayUser::OverlayUser(ClientUser *cu, unsigned int height, OverlaySettings *osptr)
: OverlayGroup(), os(osptr), uiSize(height), cuUser(cu), tsColor(Settings::Passive) {
setup();
@@ -194,7 +191,7 @@ void OverlayUser::updateUser() {
QImage img;
if (!qbaAvatar.isNull() && cuUser->qbaTexture.isEmpty()) {
- g.o->requestTexture(cuUser);
+ Global::get().o->requestTexture(cuUser);
} else if (qbaAvatar.isNull()) {
QImageReader qir(QLatin1String("skin:default_avatar.svg"));
QSize sz = qir.size();
@@ -220,7 +217,7 @@ void OverlayUser::updateUser() {
qgpiAvatar->setVisible(os->bAvatar);
if (cuUser) {
- ClientUser *self = ClientUser::get(g.uiSession);
+ ClientUser *self = ClientUser::get(Global::get().uiSession);
if (os->bMutedDeafened) {
if (cuUser->bDeaf || cuUser->bSelfDeaf) {
diff --git a/src/mumble/OverlayUserGroup.cpp b/src/mumble/OverlayUserGroup.cpp
index 005cbcab9..d8dff48fa 100644
--- a/src/mumble/OverlayUserGroup.cpp
+++ b/src/mumble/OverlayUserGroup.cpp
@@ -19,16 +19,13 @@
#include "User.h"
#include "Utils.h"
#include "GlobalShortcut.h"
+#include "Global.h"
#include <QtGui/QImageReader>
#include <QtWidgets/QGraphicsSceneContextMenuEvent>
#include <QtWidgets/QGraphicsSceneWheelEvent>
#include <QtWidgets/QInputDialog>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
template< typename T > QRectF OverlayGroup::boundingRect() const {
QRectF qr;
foreach (const QGraphicsItem *item, childItems())
@@ -67,14 +64,14 @@ void OverlayUserGroup::contextMenuEvent(QGraphicsSceneContextMenuEvent *e) {
e->accept();
#ifdef Q_OS_MAC
- bool embed = g.ocIntercept;
+ bool embed = Global::get().ocIntercept;
QMenu qm(embed ? nullptr : e->widget());
if (embed) {
- QGraphicsScene *scene = g.ocIntercept->qgv.scene();
+ QGraphicsScene *scene = Global::get().ocIntercept->qgv.scene();
scene->addWidget(&qm);
}
#else
- QMenu qm(g.ocIntercept ? g.mw : e->widget());
+ QMenu qm(Global::get().ocIntercept ? Global::get().mw : e->widget());
#endif
QMenu *qmShow = qm.addMenu(OverlayClient::tr("Filter"));
@@ -142,8 +139,8 @@ void OverlayUserGroup::contextMenuEvent(QGraphicsSceneContextMenuEvent *e) {
return;
if (act == qaEdit) {
- if (g.ocIntercept) {
- QMetaObject::invokeMethod(g.ocIntercept, "openEditor", Qt::QueuedConnection);
+ if (Global::get().ocIntercept) {
+ QMetaObject::invokeMethod(Global::get().ocIntercept, "openEditor", Qt::QueuedConnection);
} else {
OverlayEditor oe(qApp->activeModalWidget(), nullptr, os);
connect(&oe, SIGNAL(applySettings()), this, SLOT(updateLayout()));
@@ -286,10 +283,10 @@ void OverlayUserGroup::updateUsers() {
qgeiHandle = nullptr;
}
- ClientUser *self = ClientUser::get(g.uiSession);
+ ClientUser *self = ClientUser::get(Global::get().uiSession);
if (self) {
QList< ClientUser * > showusers;
- Channel *home = ClientUser::get(g.uiSession)->cChannel;
+ Channel *home = ClientUser::get(Global::get().uiSession)->cChannel;
switch (os->osShow) {
case OverlaySettings::LinkedChannels:
diff --git a/src/mumble/Overlay_macx.mm b/src/mumble/Overlay_macx.mm
index 5aa01f51e..ae884dc98 100644
--- a/src/mumble/Overlay_macx.mm
+++ b/src/mumble/Overlay_macx.mm
@@ -6,6 +6,7 @@
#include "OverlayConfig.h"
#include "OverlayClient.h"
#include "MainWindow.h"
+#include "Global.h"
#include <QtCore/QProcess>
#include <QtCore/QXmlStreamReader>
@@ -14,9 +15,6 @@
#import <Cocoa/Cocoa.h>
#include <Carbon/Carbon.h>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
extern "C" {
#include <xar/xar.h>
}
@@ -90,20 +88,20 @@ pid_t getForegroundProcessId() {
QString qsBundleIdentifier = QString::fromUtf8([bundleId UTF8String]);
- switch (g.s.os.oemOverlayExcludeMode) {
+ switch (Global::get().s.os.oemOverlayExcludeMode) {
case OverlaySettings::LauncherFilterExclusionMode: {
qWarning("Overlay_macx: launcher filter mode not implemented on macOS, allowing everything");
overlayEnabled = YES;
break;
}
case OverlaySettings::WhitelistExclusionMode: {
- if (g.s.os.qslWhitelist.contains(qsBundleIdentifier)) {
+ if (Global::get().s.os.qslWhitelist.contains(qsBundleIdentifier)) {
overlayEnabled = YES;
}
break;
}
case OverlaySettings::BlacklistExclusionMode: {
- if (! g.s.os.qslBlacklist.contains(qsBundleIdentifier)) {
+ if (! Global::get().s.os.qslBlacklist.contains(qsBundleIdentifier)) {
overlayEnabled = YES;
}
break;
diff --git a/src/mumble/Overlay_win.cpp b/src/mumble/Overlay_win.cpp
index 6520137e2..873242df5 100644
--- a/src/mumble/Overlay_win.cpp
+++ b/src/mumble/Overlay_win.cpp
@@ -10,15 +10,12 @@
#include "MumbleApplication.h"
#include "OverlayConfig.h"
#include "User.h"
+#include "Global.h"
#include "Overlay_win.h"
#include "../../overlay/overlay_exe/overlay_exe.h"
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
// Used by the overlay to detect whether we injected into ourselves.
//
// A similar declaration can be found in mumble_exe's Overlay.cpp,
@@ -90,7 +87,7 @@ OverlayPrivateWin::OverlayPrivateWin(QObject *p)
m_helper_restart_timer->setSingleShot(true);
connect(m_helper_restart_timer, SIGNAL(timeout()), this, SLOT(onDelayedRestartTimerTriggered()));
- if (!g.s.bOverlayWinHelperX86Enable) {
+ if (!Global::get().s.bOverlayWinHelperX86Enable) {
qWarning("OverlayPrivateWin: mumble_ol_helper.exe (32-bit overlay helper) disabled via "
"'overlay_win/enable_x86_helper' config option.");
m_helper_enabled = false;
@@ -117,7 +114,7 @@ OverlayPrivateWin::OverlayPrivateWin(QObject *p)
qWarning("OverlayPrivateWin: mumble_ol_helper_x64.exe (64-bit overlay helper) disabled because the host is not "
"x64 capable.");
m_helper64_enabled = false;
- } else if (!g.s.bOverlayWinHelperX64Enable) {
+ } else if (!Global::get().s.bOverlayWinHelperX64Enable) {
qWarning("OverlayPrivateWin: mumble_ol_helper_x64.exe (64-bit overlay helper) disabled via "
"'overlay_win/enable_x64_helper' config option.");
m_helper64_enabled = false;
@@ -274,7 +271,7 @@ void OverlayPrivateWin::onHelperProcessExited(int exitCode, QProcess::ExitStatus
// We could be hitting a crash bug in the helper,
// and we don't want to do too much harm in that
// case by spawning thousands of processes.
- qint64 cooldownMsec = (qint64) g.s.iOverlayWinHelperRestartCooldownMsec;
+ qint64 cooldownMsec = (qint64) Global::get().s.iOverlayWinHelperRestartCooldownMsec;
if (elapsedMsec < cooldownMsec) {
qint64 delayMsec = cooldownMsec - elapsedMsec;
qWarning("OverlayPrivateWin: waiting %llu seconds until restarting helper process '%s'. last restart was "
diff --git a/src/mumble/PAAudio.cpp b/src/mumble/PAAudio.cpp
index 03b9f5da7..a97fabd5b 100644
--- a/src/mumble/PAAudio.cpp
+++ b/src/mumble/PAAudio.cpp
@@ -4,9 +4,6 @@
// Mumble source tree or at <https://www.mumble.info/LICENSE>.
#include "PAAudio.h"
-
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
#include "Global.h"
#ifdef Q_CC_GNU
@@ -65,7 +62,7 @@ AudioInput *PortAudioInputRegistrar::create() {
}
const QList< audioDevice > PortAudioInputRegistrar::getDeviceChoices() {
- return pas->enumerateDevices(true, g.s.iPortAudioInput);
+ return pas->enumerateDevices(true, Global::get().s.iPortAudioInput);
}
void PortAudioInputRegistrar::setDeviceChoice(const QVariant &choice, Settings &s) {
@@ -84,7 +81,7 @@ AudioOutput *PortAudioOutputRegistrar::create() {
}
const QList< audioDevice > PortAudioOutputRegistrar::getDeviceChoices() {
- return pas->enumerateDevices(false, g.s.iPortAudioOutput);
+ return pas->enumerateDevices(false, Global::get().s.iPortAudioOutput);
}
void PortAudioOutputRegistrar::setDeviceChoice(const QVariant &choice, Settings &s) {
@@ -341,14 +338,14 @@ bool PortAudioSystem::stopStream(PaStream *stream) {
int PortAudioSystem::streamCallback(const void *input, void *output, unsigned long frames,
const PaStreamCallbackTimeInfo *, PaStreamCallbackFlags, void *isInput) {
if (isInput) {
- auto const pai = dynamic_cast< PortAudioInput * >(g.ai.get());
+ auto const pai = dynamic_cast< PortAudioInput * >(Global::get().ai.get());
if (!pai) {
return paAbort;
}
pai->process(frames, input);
} else {
- auto const pao = dynamic_cast< PortAudioOutput * >(g.ao.get());
+ auto const pao = dynamic_cast< PortAudioOutput * >(Global::get().ao.get());
if (!pao) {
return paAbort;
}
@@ -360,7 +357,7 @@ int PortAudioSystem::streamCallback(const void *input, void *output, unsigned lo
}
PortAudioInput::PortAudioInput() : stream(nullptr) {
- iMicChannels = pas->openStream(&stream, g.s.iPortAudioInput, iFrameSize, true);
+ iMicChannels = pas->openStream(&stream, Global::get().s.iPortAudioInput, iFrameSize, true);
if (!iMicChannels) {
qWarning("PortAudioInput: failed to open stream");
return;
@@ -411,7 +408,7 @@ void PortAudioInput::run() {
}
PortAudioOutput::PortAudioOutput() : stream(nullptr) {
- iChannels = pas->openStream(&stream, g.s.iPortAudioOutput, iFrameSize, false);
+ iChannels = pas->openStream(&stream, Global::get().s.iPortAudioOutput, iFrameSize, false);
if (!iChannels) {
qWarning("PortAudioOutput: failed to open stream");
return;
diff --git a/src/mumble/PTTButtonWidget.cpp b/src/mumble/PTTButtonWidget.cpp
index c5584dd20..7acdcf28a 100644
--- a/src/mumble/PTTButtonWidget.cpp
+++ b/src/mumble/PTTButtonWidget.cpp
@@ -4,7 +4,6 @@
// Mumble source tree or at <https://www.mumble.info/LICENSE>.
#include "PTTButtonWidget.h"
-
#include "Global.h"
PTTButtonWidget::PTTButtonWidget(QWidget *p) : QWidget(p) {
@@ -12,13 +11,13 @@ PTTButtonWidget::PTTButtonWidget(QWidget *p) : QWidget(p) {
setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint);
- if (!g.s.qbaPTTButtonWindowGeometry.isEmpty()) {
- restoreGeometry(g.s.qbaPTTButtonWindowGeometry);
+ if (!Global::get().s.qbaPTTButtonWindowGeometry.isEmpty()) {
+ restoreGeometry(Global::get().s.qbaPTTButtonWindowGeometry);
}
}
void PTTButtonWidget::closeEvent(QCloseEvent *e) {
- g.s.qbaPTTButtonWindowGeometry = saveGeometry();
+ Global::get().s.qbaPTTButtonWindowGeometry = saveGeometry();
QWidget::closeEvent(e);
}
diff --git a/src/mumble/Plugins.cpp b/src/mumble/Plugins.cpp
index 057912b25..43e848734 100644
--- a/src/mumble/Plugins.cpp
+++ b/src/mumble/Plugins.cpp
@@ -16,6 +16,7 @@
#ifdef USE_MANUAL_PLUGIN
# include "ManualPlugin.h"
#endif
+#include "Global.h"
#include <QtCore/QLibrary>
#include <QtCore/QUrlQuery>
@@ -32,10 +33,6 @@
# include <tlhelp32.h>
#endif
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
const QString PluginConfig::name = QLatin1String("PluginConfig");
static ConfigWidget *PluginConfigDialogNew(Settings &st) {
@@ -101,7 +98,7 @@ void PluginConfig::load(const Settings &r) {
}
void PluginConfig::save() const {
- QReadLocker lock(&g.p->qrwlPlugins);
+ QReadLocker lock(&Global::get().p->qrwlPlugins);
s.bTransmitPosition = qcbTransmit->isChecked();
s.qmPositionalAudioPlugins.clear();
@@ -120,7 +117,7 @@ void PluginConfig::save() const {
PluginInfo *PluginConfig::pluginForItem(QTreeWidgetItem *i) const {
if (i) {
- foreach (PluginInfo *pi, g.p->qlPlugins) {
+ foreach (PluginInfo *pi, Global::get().p->qlPlugins) {
if (pi->filename == i->data(0, Qt::UserRole).toString())
return pi;
}
@@ -131,7 +128,7 @@ PluginInfo *PluginConfig::pluginForItem(QTreeWidgetItem *i) const {
void PluginConfig::on_qpbConfig_clicked() {
PluginInfo *pi;
{
- QReadLocker lock(&g.p->qrwlPlugins);
+ QReadLocker lock(&Global::get().p->qrwlPlugins);
pi = pluginForItem(qtwPlugins->currentItem());
}
@@ -151,7 +148,7 @@ void PluginConfig::on_qpbConfig_clicked() {
void PluginConfig::on_qpbAbout_clicked() {
PluginInfo *pi;
{
- QReadLocker lock(&g.p->qrwlPlugins);
+ QReadLocker lock(&Global::get().p->qrwlPlugins);
pi = pluginForItem(qtwPlugins->currentItem());
}
@@ -169,15 +166,15 @@ void PluginConfig::on_qpbAbout_clicked() {
}
void PluginConfig::on_qpbReload_clicked() {
- g.p->rescanPlugins();
+ Global::get().p->rescanPlugins();
refillPluginList();
}
void PluginConfig::refillPluginList() {
- QReadLocker lock(&g.p->qrwlPlugins);
+ QReadLocker lock(&Global::get().p->qrwlPlugins);
qtwPlugins->clear();
- foreach (PluginInfo *pi, g.p->qlPlugins) {
+ foreach (PluginInfo *pi, Global::get().p->qlPlugins) {
QTreeWidgetItem *i = new QTreeWidgetItem(qtwPlugins);
i->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
i->setCheckState(1, pi->enabled ? Qt::Checked : Qt::Unchecked);
@@ -191,7 +188,7 @@ void PluginConfig::refillPluginList() {
}
void PluginConfig::on_qtwPlugins_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *) {
- QReadLocker lock(&g.p->qrwlPlugins);
+ QReadLocker lock(&Global::get().p->qrwlPlugins);
PluginInfo *pi = pluginForItem(current);
if (pi) {
@@ -240,7 +237,7 @@ Plugins::Plugins(QObject *p) : QObject(p) {
qsSystemPlugins = QLatin1String(MUMTEXT(MUMBLE_PLUGIN_PATH));
# endif
- qsUserPlugins = g.qdBasePath.absolutePath() + QLatin1String("/Plugins");
+ qsUserPlugins = Global::get().qdBasePath.absolutePath() + QLatin1String("/Plugins");
#else
# ifdef MUMBLE_PLUGIN_PATH
qsSystemPlugins = QLatin1String(MUMTEXT(MUMBLE_PLUGIN_PATH));
@@ -287,7 +284,7 @@ Plugins::~Plugins() {
}
void Plugins::clearPlugins() {
- QWriteLocker lock(&g.p->qrwlPlugins);
+ QWriteLocker lock(&Global::get().p->qrwlPlugins);
foreach (PluginInfo *pi, qlPlugins) {
if (pi->locked)
pi->p->unlock();
@@ -300,7 +297,7 @@ void Plugins::clearPlugins() {
void Plugins::rescanPlugins() {
clearPlugins();
- QWriteLocker lock(&g.p->qrwlPlugins);
+ QWriteLocker lock(&Global::get().p->qrwlPlugins);
prevlocked = locked = nullptr;
bValid = false;
@@ -329,7 +326,7 @@ void Plugins::rescanPlugins() {
if (pi->p && pi->p->magic == MUMBLE_PLUGIN_MAGIC && pi->p->shortname != L"Retracted") {
pi->description = QString::fromStdWString(pi->p->description);
pi->shortname = QString::fromStdWString(pi->p->shortname);
- pi->enabled = g.s.qmPositionalAudioPlugins.value(pi->filename, true);
+ pi->enabled = Global::get().s.qmPositionalAudioPlugins.value(pi->filename, true);
mumblePlugin2Func mpf2 =
reinterpret_cast< mumblePlugin2Func >(pi->lib.resolve("getMumblePlugin2"));
@@ -371,14 +368,14 @@ void Plugins::rescanPlugins() {
pi->pqt = ManualPlugin_getMumblePluginQt();
pi->description = QString::fromStdWString(pi->p->description);
pi->shortname = QString::fromStdWString(pi->p->shortname);
- pi->enabled = g.s.qmPositionalAudioPlugins.value(pi->filename, true);
+ pi->enabled = Global::get().s.qmPositionalAudioPlugins.value(pi->filename, true);
qlPlugins << pi;
#endif
}
}
bool Plugins::fetch() {
- if (g.bPosTest) {
+ if (Global::get().bPosTest) {
fPosition[0] = fPosition[1] = fPosition[2] = 0.0f;
fFront[0] = 0.0f;
fFront[1] = 0.0f;
@@ -440,7 +437,7 @@ void Plugins::on_Timer_timeout() {
QReadLocker lock(&qrwlPlugins);
if (prevlocked) {
- g.l->log(Log::Information, tr("%1 lost link.").arg(prevlocked->shortname.toHtmlEscaped()));
+ Global::get().l->log(Log::Information, tr("%1 lost link.").arg(prevlocked->shortname.toHtmlEscaped()));
prevlocked = nullptr;
}
@@ -457,12 +454,12 @@ void Plugins::on_Timer_timeout() {
if (locked)
context.assign(u8(QString::fromStdWString(locked->p->shortname)) + static_cast< char >(0) + ssContext);
- if (!g.uiSession) {
+ if (!Global::get().uiSession) {
ssContextSent.clear();
swsIdentitySent.clear();
} else if ((context != ssContextSent) || (swsIdentity != swsIdentitySent)) {
MumbleProto::UserState mpus;
- mpus.set_session(g.uiSession);
+ mpus.set_session(Global::get().uiSession);
if (context != ssContextSent) {
ssContextSent.assign(context);
mpus.set_plugin_context(context);
@@ -471,8 +468,8 @@ void Plugins::on_Timer_timeout() {
swsIdentitySent.assign(swsIdentity);
mpus.set_plugin_identity(u8(QString::fromStdWString(swsIdentitySent)));
}
- if (g.sh)
- g.sh->sendMessage(mpus);
+ if (Global::get().sh)
+ Global::get().sh->sendMessage(mpus);
}
}
@@ -480,7 +477,7 @@ void Plugins::on_Timer_timeout() {
return;
}
- if (!g.s.bTransmitPosition)
+ if (!Global::get().s.bTransmitPosition)
return;
lock.unlock();
@@ -564,7 +561,7 @@ void Plugins::on_Timer_timeout() {
if (pi->enabled) {
if (pi->p2 ? pi->p2->trylock(pids) : pi->p->trylock()) {
pi->shortname = QString::fromStdWString(pi->p->shortname);
- g.l->log(Log::Information, tr("%1 linked.").arg(pi->shortname.toHtmlEscaped()));
+ Global::get().l->log(Log::Information, tr("%1 linked.").arg(pi->shortname.toHtmlEscaped()));
pi->locked = true;
bUnlink = false;
locked = pi;
@@ -604,7 +601,7 @@ void Plugins::checkUpdates() {
WebFetch::fetch(QLatin1String("update"), url, this, SLOT(fetchedUpdatePAPlugins(QByteArray, QUrl)));
#else
- g.mw->msgBox(tr("Skipping plugin update in debug mode."));
+ Global::get().mw->msgBox(tr("Skipping plugin update in debug mode."));
#endif
}
@@ -773,15 +770,15 @@ void Plugins::fetchedPAPluginDL(QByteArray data, QUrl url) {
if (f.open(QIODevice::WriteOnly)) {
f.write(data);
f.close();
- g.mw->msgBox(tr("Downloaded new or updated plugin to %1.").arg(f.fileName().toHtmlEscaped()));
+ Global::get().mw->msgBox(tr("Downloaded new or updated plugin to %1.").arg(f.fileName().toHtmlEscaped()));
} else {
f.setFileName(qsUserPlugins + QLatin1String("/") + fname);
if (f.open(QIODevice::WriteOnly)) {
f.write(data);
f.close();
- g.mw->msgBox(tr("Downloaded new or updated plugin to %1.").arg(f.fileName().toHtmlEscaped()));
+ Global::get().mw->msgBox(tr("Downloaded new or updated plugin to %1.").arg(f.fileName().toHtmlEscaped()));
} else {
- g.mw->msgBox(tr("Failed to install new plugin to %1.").arg(f.fileName().toHtmlEscaped()));
+ Global::get().mw->msgBox(tr("Failed to install new plugin to %1.").arg(f.fileName().toHtmlEscaped()));
}
}
diff --git a/src/mumble/PulseAudio.cpp b/src/mumble/PulseAudio.cpp
index 1527ca444..5bb0baf79 100644
--- a/src/mumble/PulseAudio.cpp
+++ b/src/mumble/PulseAudio.cpp
@@ -8,9 +8,6 @@
#include "MainWindow.h"
#include "Timer.h"
#include "User.h"
-
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
#include "Global.h"
#ifdef Q_CC_GNU
@@ -148,7 +145,7 @@ PulseAudioSystem::~PulseAudioSystem() {
}
QString PulseAudioSystem::outputDevice() const {
- QString odev = g.s.qsPulseAudioOutput;
+ QString odev = Global::get().s.qsPulseAudioOutput;
if (odev.isEmpty()) {
odev = qsDefaultOutput;
}
@@ -159,7 +156,7 @@ QString PulseAudioSystem::outputDevice() const {
}
QString PulseAudioSystem::inputDevice() const {
- QString idev = g.s.qsPulseAudioInput;
+ QString idev = Global::get().s.qsPulseAudioInput;
if (idev.isEmpty()) {
idev = qsDefaultInput;
}
@@ -192,8 +189,8 @@ void PulseAudioSystem::eventCallback(pa_mainloop_api *api, pa_defer_event *) {
if (!bSourceDone || !bSinkDone || !bServerDone)
return;
- AudioInputPtr ai = g.ai;
- AudioOutputPtr ao = g.ao;
+ AudioInputPtr ai = Global::get().ai;
+ AudioOutputPtr ao = Global::get().ao;
AudioInput *raw_ai = ai.get();
AudioOutput *raw_ao = ao.get();
PulseAudioInput *pai = dynamic_cast< PulseAudioInput * >(raw_ai);
@@ -231,7 +228,7 @@ void PulseAudioSystem::eventCallback(pa_mainloop_api *api, pa_defer_event *) {
do_start = true;
break;
case PA_STREAM_READY: {
- if (g.s.iOutputDelay != iDelayCache) {
+ if (Global::get().s.iOutputDelay != iDelayCache) {
do_stop = true;
} else if (odev != qsOutputCache) {
do_stop = true;
@@ -252,13 +249,13 @@ void PulseAudioSystem::eventCallback(pa_mainloop_api *api, pa_defer_event *) {
const pa_sample_spec *pss = m_pulseAudio.stream_get_sample_spec(pasOutput);
const size_t sampleSize = (pss->format == PA_SAMPLE_FLOAT32NE) ? sizeof(float) : sizeof(short);
const unsigned int iBlockLen = pao->iFrameSize * pss->channels * static_cast< unsigned int >(sampleSize);
- buff.tlength = iBlockLen * (g.s.iOutputDelay + 1);
+ buff.tlength = iBlockLen * (Global::get().s.iOutputDelay + 1);
buff.minreq = iBlockLen;
buff.maxlength = -1;
buff.prebuf = -1;
buff.fragsize = iBlockLen;
- iDelayCache = g.s.iOutputDelay;
+ iDelayCache = Global::get().s.iOutputDelay;
qsOutputCache = odev;
m_pulseAudio.stream_connect_playback(pasOutput, qPrintable(odev), &buff, PA_STREAM_ADJUST_LATENCY, nullptr,
@@ -334,9 +331,9 @@ void PulseAudioSystem::eventCallback(pa_mainloop_api *api, pa_defer_event *) {
bool do_stop = false;
bool do_start = false;
- if ((!pai || g.s.echoOption == EchoCancelOptionID::DISABLED) && (est == PA_STREAM_READY)) {
+ if ((!pai || Global::get().s.echoOption == EchoCancelOptionID::DISABLED) && (est == PA_STREAM_READY)) {
do_stop = true;
- } else if (pai && g.s.echoOption != EchoCancelOptionID::DISABLED) {
+ } else if (pai && Global::get().s.echoOption != EchoCancelOptionID::DISABLED) {
switch (est) {
case PA_STREAM_TERMINATED: {
if (pasSpeaker)
@@ -347,7 +344,7 @@ void PulseAudioSystem::eventCallback(pa_mainloop_api *api, pa_defer_event *) {
if ((pss.format != PA_SAMPLE_FLOAT32NE) && (pss.format != PA_SAMPLE_S16NE))
pss.format = PA_SAMPLE_FLOAT32NE;
pss.rate = SAMPLE_RATE;
- if ((pss.channels == 0) || (g.s.echoOption != EchoCancelOptionID::SPEEX_MULTICHANNEL))
+ if ((pss.channels == 0) || (Global::get().s.echoOption != EchoCancelOptionID::SPEEX_MULTICHANNEL))
pss.channels = 1;
pasSpeaker =
@@ -360,7 +357,7 @@ void PulseAudioSystem::eventCallback(pa_mainloop_api *api, pa_defer_event *) {
do_start = true;
break;
case PA_STREAM_READY: {
- if ((g.s.echoOption == EchoCancelOptionID::SPEEX_MULTICHANNEL) != bEchoMultiCache) {
+ if ((Global::get().s.echoOption == EchoCancelOptionID::SPEEX_MULTICHANNEL) != bEchoMultiCache) {
do_stop = true;
} else if (edev != qsEchoCache) {
do_stop = true;
@@ -386,7 +383,7 @@ void PulseAudioSystem::eventCallback(pa_mainloop_api *api, pa_defer_event *) {
buff.prebuf = -1;
buff.fragsize = iBlockLen;
- bEchoMultiCache = (g.s.echoOption == EchoCancelOptionID::SPEEX_MULTICHANNEL);
+ bEchoMultiCache = (Global::get().s.echoOption == EchoCancelOptionID::SPEEX_MULTICHANNEL);
qsEchoCache = edev;
m_pulseAudio.stream_connect_record(pasSpeaker, qPrintable(edev), &buff, PA_STREAM_ADJUST_LATENCY);
@@ -483,7 +480,7 @@ void PulseAudioSystem::write_stream_callback(pa_stream *s, void *userdata) {
}
const pa_buffer_attr *bufferAttr;
if ((bufferAttr = pa.stream_get_buffer_attr(s))) {
- g.ao->setBufferSize(bufferAttr->maxlength);
+ Global::get().ao->setBufferSize(bufferAttr->maxlength);
}
pas->wakeup();
}
@@ -518,7 +515,7 @@ void PulseAudioSystem::read_callback(pa_stream *s, size_t bytes, void *userdata)
return;
}
- AudioInputPtr ai = g.ai;
+ AudioInputPtr ai = Global::get().ai;
PulseAudioInput *pai = dynamic_cast< PulseAudioInput * >(ai.get());
if (!pai) {
if (length > 0) {
@@ -569,7 +566,7 @@ void PulseAudioSystem::write_callback(pa_stream *s, size_t bytes, void *userdata
PulseAudioSystem *pas = reinterpret_cast< PulseAudioSystem * >(userdata);
Q_ASSERT(s == pas->pasOutput);
- AudioOutputPtr ao = g.ao;
+ AudioOutputPtr ao = Global::get().ao;
PulseAudioOutput *pao = dynamic_cast< PulseAudioOutput * >(ao.get());
if (!pao) {
@@ -643,13 +640,13 @@ void PulseAudioSystem::write_callback(pa_stream *s, size_t bytes, void *userdata
// do we have some mixed output?
if (pao->mix(buffer, samples)) {
// attenuate if instructed to or it's in settings
- pas->bAttenuating = (g.bAttenuateOthers || g.s.bAttenuateOthers);
+ pas->bAttenuating = (Global::get().bAttenuateOthers || Global::get().s.bAttenuateOthers);
} else {
memset(buffer, 0, bytes);
// attenuate if intructed to (self-activated)
- pas->bAttenuating = g.bAttenuateOthers;
+ pas->bAttenuating = Global::get().bAttenuateOthers;
}
// if the attenuation state has changed
@@ -668,16 +665,16 @@ void PulseAudioSystem::volume_sink_input_list_callback(pa_context *c, const pa_s
if (eol == 0) {
// If we're using the default of "enable attenuation on all ouputs" and output from an application is
// loopbacked, both the loopback and the application will be attenuated leading to double attenuation.
- if (!g.s.bOnlyAttenuateSameOutput && pas->iSinkId > -1 && !strcmp(i->driver, "module-loopback.c")) {
+ if (!Global::get().s.bOnlyAttenuateSameOutput && pas->iSinkId > -1 && !strcmp(i->driver, "module-loopback.c")) {
return;
}
// If we're not attenuating different sinks and the input is not on this sink, don't attenuate. Or,
// if the input is a loopback module and connected to Mumble's sink, also ignore it (loopbacks are used to
// connect sinks). An attenuated loopback means an indirect application attenuation.
- if (g.s.bOnlyAttenuateSameOutput && pas->iSinkId > -1) {
+ if (Global::get().s.bOnlyAttenuateSameOutput && pas->iSinkId > -1) {
if (int(i->sink) != pas->iSinkId
|| (int(i->sink) == pas->iSinkId && !strcmp(i->driver, "module-loopback.c")
- && !g.s.bAttenuateLoopbacks)) {
+ && !Global::get().s.bAttenuateLoopbacks)) {
return;
}
}
@@ -691,7 +688,7 @@ void PulseAudioSystem::volume_sink_input_list_callback(pa_context *c, const pa_s
patt.normal_volume = i->volume;
// calculate the attenuated volume
- pa_volume_t adj = static_cast< pa_volume_t >(PA_VOLUME_NORM * g.s.fOtherVolume);
+ pa_volume_t adj = static_cast< pa_volume_t >(PA_VOLUME_NORM * Global::get().s.fOtherVolume);
pa.sw_cvolume_multiply_scalar(&patt.attenuated_volume, &i->volume, adj);
// set it on the sink input
@@ -908,9 +905,9 @@ const QList< audioDevice > PulseAudioInputRegistrar::getDeviceChoices() {
QStringList qlInputDevs = pasys->qhInput.keys();
std::sort(qlInputDevs.begin(), qlInputDevs.end());
- if (qlInputDevs.contains(g.s.qsPulseAudioInput)) {
- qlInputDevs.removeAll(g.s.qsPulseAudioInput);
- qlInputDevs.prepend(g.s.qsPulseAudioInput);
+ if (qlInputDevs.contains(Global::get().s.qsPulseAudioInput)) {
+ qlInputDevs.removeAll(Global::get().s.qsPulseAudioInput);
+ qlInputDevs.prepend(Global::get().s.qsPulseAudioInput);
}
foreach (const QString &dev, qlInputDevs) { qlReturn << audioDevice(pasys->qhInput.value(dev), dev); }
@@ -940,9 +937,9 @@ const QList< audioDevice > PulseAudioOutputRegistrar::getDeviceChoices() {
QStringList qlOutputDevs = pasys->qhOutput.keys();
std::sort(qlOutputDevs.begin(), qlOutputDevs.end());
- if (qlOutputDevs.contains(g.s.qsPulseAudioOutput)) {
- qlOutputDevs.removeAll(g.s.qsPulseAudioOutput);
- qlOutputDevs.prepend(g.s.qsPulseAudioOutput);
+ if (qlOutputDevs.contains(Global::get().s.qsPulseAudioOutput)) {
+ qlOutputDevs.removeAll(Global::get().s.qsPulseAudioOutput);
+ qlOutputDevs.prepend(Global::get().s.qsPulseAudioOutput);
}
foreach (const QString &dev, qlOutputDevs) { qlReturn << audioDevice(pasys->qhOutput.value(dev), dev); }
diff --git a/src/mumble/RichTextEditor.cpp b/src/mumble/RichTextEditor.cpp
index c18eb1b87..5d361059d 100644
--- a/src/mumble/RichTextEditor.cpp
+++ b/src/mumble/RichTextEditor.cpp
@@ -8,6 +8,7 @@
#include "Log.h"
#include "MainWindow.h"
#include "XMLTools.h"
+#include "Global.h"
#include <QtCore/QMimeData>
#include <QtGui/QImageReader>
@@ -20,10 +21,6 @@
# include <shlobj.h>
#endif
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
RichTextHtmlEdit::RichTextHtmlEdit(QWidget *p) : QTextEdit(p) {
m_document = new LogDocument(this);
m_document->setDefaultStyleSheet(qApp->styleSheet());
@@ -231,17 +228,17 @@ void RichTextEditor::on_qaLink_triggered() {
}
void RichTextEditor::on_qaImage_triggered() {
- QPair< QByteArray, QImage > choice = g.mw->openImageFile();
+ QPair< QByteArray, QImage > choice = Global::get().mw->openImageFile();
QByteArray &qba = choice.first;
if (qba.isEmpty())
return;
- if ((g.uiImageLength > 0) && (static_cast< unsigned int >(qba.length()) > g.uiImageLength)) {
+ if ((Global::get().uiImageLength > 0) && (static_cast< unsigned int >(qba.length()) > Global::get().uiImageLength)) {
QMessageBox::warning(this, tr("Failed to load image"),
tr("Image file too large to embed in document. Please use images smaller than %1 kB.")
- .arg(g.uiImageLength / 1024));
+ .arg(Global::get().uiImageLength / 1024));
return;
}
@@ -276,7 +273,7 @@ void RichTextEditor::on_qteRichText_textChanged() {
bChanged = true;
updateActions();
- if (!g.uiMessageLength)
+ if (!Global::get().uiMessageLength)
return;
richToPlain();
@@ -288,9 +285,9 @@ void RichTextEditor::on_qteRichText_textChanged() {
unsigned int imagelength = plainText.length();
- if (g.uiMessageLength && imagelength <= g.uiMessageLength) {
+ if (Global::get().uiMessageLength && imagelength <= Global::get().uiMessageLength) {
over = false;
- } else if (g.uiImageLength && imagelength > g.uiImageLength) {
+ } else if (Global::get().uiImageLength && imagelength > Global::get().uiImageLength) {
over = true;
} else {
QString qsOut;
@@ -317,7 +314,7 @@ void RichTextEditor::on_qteRichText_textChanged() {
break;
}
}
- over = (static_cast< unsigned int >(qsOut.length()) > g.uiMessageLength);
+ over = (static_cast< unsigned int >(qsOut.length()) > Global::get().uiMessageLength);
}
@@ -404,9 +401,9 @@ void RichTextEditor::richToPlain() {
}
void RichTextEditor::setText(const QString &txt, bool readonly) {
- qtbToolBar->setEnabled(!readonly && g.bAllowHTML);
- qtbToolBar->setVisible(!readonly && g.bAllowHTML);
- qptePlainText->setReadOnly(readonly || !g.bAllowHTML);
+ qtbToolBar->setEnabled(!readonly && Global::get().bAllowHTML);
+ qtbToolBar->setVisible(!readonly && Global::get().bAllowHTML);
+ qptePlainText->setReadOnly(readonly || !Global::get().bAllowHTML);
qteRichText->setReadOnly(readonly);
qteRichText->setHtml(txt);
diff --git a/src/mumble/ServerHandler.cpp b/src/mumble/ServerHandler.cpp
index 59e8a1436..5f40ba59c 100644
--- a/src/mumble/ServerHandler.cpp
+++ b/src/mumble/ServerHandler.cpp
@@ -29,6 +29,7 @@
#include "ServerResolverRecord.h"
#include "User.h"
#include "Utils.h"
+#include "Global.h"
#include <QtCore/QtEndian>
#include <QtGui/QImageReader>
@@ -56,10 +57,6 @@
# include <sys/socket.h>
#endif
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
ServerHandlerMessageEvent::ServerHandlerMessageEvent(const QByteArray &msg, unsigned int mtype, bool flush)
: QEvent(static_cast< QEvent::Type >(SERVERSEND_EVENT)) {
qbaMsg = msg;
@@ -126,11 +123,11 @@ ServerHandler::ServerHandler() : database(new Database(QLatin1String("ServerHand
MumbleSSL::addSystemCA();
{
- QList< QSslCipher > ciphers = MumbleSSL::ciphersFromOpenSSLCipherString(g.s.qsSslCiphers);
+ QList< QSslCipher > ciphers = MumbleSSL::ciphersFromOpenSSLCipherString(Global::get().s.qsSslCiphers);
if (ciphers.isEmpty()) {
qFatal("Invalid 'net/sslciphers' config option. Either the cipher string is invalid or none of the ciphers "
"are available:: \"%s\"",
- qPrintable(g.s.qsSslCiphers));
+ qPrintable(Global::get().s.qsSslCiphers));
}
QSslConfiguration config = QSslConfiguration::defaultConfiguration();
@@ -253,8 +250,8 @@ void ServerHandler::handleVoicePacket(unsigned int msgFlags, PacketDataStream &p
unsigned int uiSession;
pds >> uiSession;
ClientUser *p = ClientUser::get(uiSession);
- AudioOutputPtr ao = g.ao;
- if (ao && p && !(((msgFlags & 0x1f) == 2) && g.s.bWhisperFriends && p->qsFriendName.isEmpty())) {
+ AudioOutputPtr ao = Global::get().ao;
+ if (ao && p && !(((msgFlags & 0x1f) == 2) && Global::get().s.bWhisperFriends && p->qsFriendName.isEmpty())) {
unsigned int iSeq;
pds >> iSeq;
QByteArray qba;
@@ -374,12 +371,12 @@ void ServerHandler::run() {
qtsSock = new QSslSocket(this);
qtsSock->setPeerVerifyName(qsHostName);
- if (!g.s.bSuppressIdentity && CertWizard::validateCert(g.s.kpCertificate)) {
- qtsSock->setPrivateKey(g.s.kpCertificate.second);
- qtsSock->setLocalCertificate(g.s.kpCertificate.first.at(0));
+ if (!Global::get().s.bSuppressIdentity && CertWizard::validateCert(Global::get().s.kpCertificate)) {
+ qtsSock->setPrivateKey(Global::get().s.kpCertificate.second);
+ qtsSock->setLocalCertificate(Global::get().s.kpCertificate.first.at(0));
QSslConfiguration config = qtsSock->sslConfiguration();
QList< QSslCertificate > certs = config.caCertificates();
- certs << g.s.kpCertificate.first;
+ certs << Global::get().s.kpCertificate.first;
config.setCaCertificates(certs);
qtsSock->setSslConfiguration(config);
}
@@ -426,9 +423,9 @@ void ServerHandler::run() {
// Setup ping timer;
QTimer *ticker = new QTimer(this);
connect(ticker, SIGNAL(timeout()), this, SLOT(sendPing()));
- ticker->start(g.s.iPingIntervalMsec);
+ ticker->start(Global::get().s.iPingIntervalMsec);
- g.mw->rtLast = MumbleProto::Reject_RejectType_None;
+ Global::get().mw->rtLast = MumbleProto::Reject_RejectType_None;
accUDP = accTCP = accClean;
@@ -545,7 +542,7 @@ void ServerHandler::sendPingInternal() {
return;
}
- if (g.s.iMaxInFlightTCPPings > 0 && iInFlightTCPPings >= g.s.iMaxInFlightTCPPings) {
+ if (Global::get().s.iMaxInFlightTCPPings > 0 && iInFlightTCPPings >= Global::get().s.iMaxInFlightTCPPings) {
serverConnectionClosed(QAbstractSocket::UnknownSocketError, tr("Server is not responding to TCP pings"));
return;
}
@@ -629,19 +626,19 @@ void ServerHandler::message(unsigned int msgType, const QByteArray &qbaMsg) {
bUdp = false;
if (!NetworkConfig::TcpModeEnabled()) {
if ((connection->csCrypt->uiRemoteGood == 0) && (connection->csCrypt->uiGood == 0))
- g.mw->msgBox(
+ Global::get().mw->msgBox(
tr("UDP packets cannot be sent to or received from the server. Switching to TCP mode."));
else if (connection->csCrypt->uiRemoteGood == 0)
- g.mw->msgBox(tr("UDP packets cannot be sent to the server. Switching to TCP mode."));
+ Global::get().mw->msgBox(tr("UDP packets cannot be sent to the server. Switching to TCP mode."));
else
- g.mw->msgBox(tr("UDP packets cannot be received from the server. Switching to TCP mode."));
+ Global::get().mw->msgBox(tr("UDP packets cannot be received from the server. Switching to TCP mode."));
database->setUdp(qbaDigest, false);
}
} else if (!bUdp && (connection->csCrypt->uiRemoteGood > 3) && (connection->csCrypt->uiGood > 3)) {
bUdp = true;
if (!NetworkConfig::TcpModeEnabled()) {
- g.mw->msgBox(
+ Global::get().mw->msgBox(
tr("UDP packets can be sent to and received from the server. Switching back to UDP mode."));
database->setUdp(qbaDigest, true);
@@ -650,7 +647,7 @@ void ServerHandler::message(unsigned int msgType, const QByteArray &qbaMsg) {
}
} else {
ServerHandlerMessageEvent *shme = new ServerHandlerMessageEvent(qbaMsg, msgType, false);
- QApplication::postEvent(g.mw, shme);
+ QApplication::postEvent(Global::get().mw, shme);
}
}
@@ -669,7 +666,7 @@ void ServerHandler::serverConnectionClosed(QAbstractSocket::SocketError err, con
return;
c->bDisconnectedEmitted = true;
- AudioOutputPtr ao = g.ao;
+ AudioOutputPtr ao = Global::get().ao;
if (ao)
ao->wipe();
@@ -705,7 +702,7 @@ void ServerHandler::serverConnectionStateChanged(QAbstractSocket::SocketState st
tConnectionTimeoutTimer = new QTimer();
connect(tConnectionTimeoutTimer, SIGNAL(timeout()), this, SLOT(serverConnectionTimeoutOnConnect()));
tConnectionTimeoutTimer->setSingleShot(true);
- tConnectionTimeoutTimer->start(g.s.iConnectionTimeoutDurationMsec);
+ tConnectionTimeoutTimer->start(Global::get().s.iConnectionTimeoutDurationMsec);
} else if (state == QAbstractSocket::ConnectedState) {
// Start TLS handshake
qtsSock->startClientEncryption();
@@ -721,7 +718,7 @@ void ServerHandler::serverConnectionConnected() {
tConnectionTimeoutTimer->stop();
- if (g.s.bQoS)
+ if (Global::get().s.bQoS)
connection->setToS();
qscCert = connection->peerCertificateChain();
@@ -746,7 +743,7 @@ void ServerHandler::serverConnectionConnected() {
mpv.set_version(version);
}
- if (!g.s.bHideOS) {
+ if (!Global::get().s.bHideOS) {
mpv.set_os(u8(OSInfo::getOS()));
mpv.set_os_version(u8(OSInfo::getOSDisplayableVersion()));
}
@@ -762,7 +759,7 @@ void ServerHandler::serverConnectionConnected() {
mpa.add_tokens(u8(qs));
QMap< int, CELTCodec * >::const_iterator i;
- for (i = g.qmCodecs.constBegin(); i != g.qmCodecs.constEnd(); ++i)
+ for (i = Global::get().qmCodecs.constBegin(); i != Global::get().qmCodecs.constEnd(); ++i)
mpa.add_celt_versions(i.key());
#ifdef USE_OPUS
mpa.set_opus(true);
@@ -785,7 +782,7 @@ void ServerHandler::serverConnectionConnected() {
if (!qusUdp) {
qFatal("ServerHandler: qusUdp is unexpectedly a null addr");
}
- if (g.s.bUdpForceTcpAddr) {
+ if (Global::get().s.bUdpForceTcpAddr) {
qusUdp->bind(qhaLocal, 0);
} else {
if (qhaRemote.protocol() == QAbstractSocket::IPv6Protocol) {
@@ -797,7 +794,7 @@ void ServerHandler::serverConnectionConnected() {
connect(qusUdp, SIGNAL(readyRead()), this, SLOT(udpReady()));
- if (g.s.bQoS) {
+ if (Global::get().s.bQoS) {
#if defined(Q_OS_UNIX)
int val = 0xe0;
if (setsockopt(static_cast< int >(qusUdp->socketDescriptor()), IPPROTO_IP, IP_TOS, &val, sizeof(val))) {
@@ -892,7 +889,7 @@ void ServerHandler::startListeningToChannels(const QList< int > &channelIDs) {
}
MumbleProto::UserState mpus;
- mpus.set_session(g.uiSession);
+ mpus.set_session(Global::get().uiSession);
foreach (int currentChannel, channelIDs) {
// The naming of the function is a bit unfortunate but what this does is to add
@@ -913,7 +910,7 @@ void ServerHandler::stopListeningToChannels(const QList< int > &channelIDs) {
}
MumbleProto::UserState mpus;
- mpus.set_session(g.uiSession);
+ mpus.set_session(Global::get().uiSession);
foreach (int currentChannel, channelIDs) {
// The naming of the function is a bit unfortunate but what this does is to add
@@ -983,8 +980,8 @@ void ServerHandler::sendChannelTextMessage(unsigned int channel, const QString &
} else {
mptm.add_channel_id(channel);
- if (message_ == QString::fromUtf8(g.ccHappyEaster + 10))
- g.bHappyEaster = true;
+ if (message_ == QString::fromUtf8(Global::get().ccHappyEaster + 10))
+ Global::get().bHappyEaster = true;
}
mptm.set_message(u8(message_));
sendMessage(mptm);
diff --git a/src/mumble/Settings.cpp b/src/mumble/Settings.cpp
index 6ff90c752..797dbc169 100644
--- a/src/mumble/Settings.cpp
+++ b/src/mumble/Settings.cpp
@@ -9,6 +9,7 @@
#include "Cert.h"
#include "Log.h"
#include "SSL.h"
+#include "Global.h"
#include "../../overlay/overlay.h"
@@ -24,10 +25,6 @@
#include <limits>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
const QPoint Settings::UNSPECIFIED_POSITION =
@@ -557,8 +554,8 @@ bool Settings::doEcho() const {
if (AudioInputRegistrar::qmNew) {
AudioInputRegistrar *air = AudioInputRegistrar::qmNew->value(qsAudioInput);
if (air) {
- if ((g.s.echoOption != EchoCancelOptionID::DISABLED)
- && air->canEcho(g.s.echoOption, qsAudioOutput))
+ if ((Global::get().s.echoOption != EchoCancelOptionID::DISABLED)
+ && air->canEcho(Global::get().s.echoOption, qsAudioOutput))
return true;
}
}
@@ -626,7 +623,7 @@ BOOST_TYPEOF_REGISTER_TEMPLATE(QList, 1)
#endif
void OverlaySettings::load() {
- load(g.qs);
+ load(Global::get().qs);
}
void OverlaySettings::load(QSettings *settings_ptr) {
@@ -699,7 +696,7 @@ void OverlaySettings::load(QSettings *settings_ptr) {
}
void Settings::load() {
- load(g.qs);
+ load(Global::get().qs);
}
void Settings::load(QSettings *settings_ptr) {
@@ -1032,7 +1029,7 @@ void Settings::load(QSettings *settings_ptr) {
#define DEPRECATED(name) settings_ptr->remove(QLatin1String(name))
void OverlaySettings::save() {
- save(g.qs);
+ save(Global::get().qs);
}
void OverlaySettings::save(QSettings *settings_ptr) {
@@ -1119,7 +1116,7 @@ void OverlaySettings::save(QSettings *settings_ptr) {
}
void Settings::save() {
- QSettings *settings_ptr = g.qs;
+ QSettings *settings_ptr = Global::get().qs;
Settings def;
// Config updates
diff --git a/src/mumble/SocketRPC.cpp b/src/mumble/SocketRPC.cpp
index 25121c7a3..7c950ab57 100644
--- a/src/mumble/SocketRPC.cpp
+++ b/src/mumble/SocketRPC.cpp
@@ -9,16 +9,13 @@
#include "ClientUser.h"
#include "MainWindow.h"
#include "ServerHandler.h"
+#include "Global.h"
#include <QtCore/QProcessEnvironment>
#include <QtCore/QUrlQuery>
#include <QtNetwork/QLocalServer>
#include <QtXml/QDomDocument>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
SocketRPCClient::SocketRPCClient(QLocalSocket *s, QObject *p) : QObject(p), qlsSocket(s), qbBuffer(nullptr) {
qlsSocket->setParent(this);
@@ -103,82 +100,82 @@ void SocketRPCClient::processXml() {
qmReply.insert(iter.key(), iter.value());
if (request.nodeName() == QLatin1String("focus")) {
- g.mw->show();
- g.mw->raise();
- g.mw->activateWindow();
+ Global::get().mw->show();
+ Global::get().mw->raise();
+ Global::get().mw->activateWindow();
ack = true;
} else if (request.nodeName() == QLatin1String("self")) {
iter = qmRequest.find(QLatin1String("mute"));
if (iter != qmRequest.constEnd()) {
bool set = iter.value().toBool();
- if (set != g.s.bMute) {
- g.mw->qaAudioMute->setChecked(!set);
- g.mw->qaAudioMute->trigger();
+ if (set != Global::get().s.bMute) {
+ Global::get().mw->qaAudioMute->setChecked(!set);
+ Global::get().mw->qaAudioMute->trigger();
}
}
iter = qmRequest.find(QLatin1String("unmute"));
if (iter != qmRequest.constEnd()) {
bool set = iter.value().toBool();
- if (set == g.s.bMute) {
- g.mw->qaAudioMute->setChecked(set);
- g.mw->qaAudioMute->trigger();
+ if (set == Global::get().s.bMute) {
+ Global::get().mw->qaAudioMute->setChecked(set);
+ Global::get().mw->qaAudioMute->trigger();
}
}
iter = qmRequest.find(QLatin1String("togglemute"));
if (iter != qmRequest.constEnd()) {
bool set = iter.value().toBool();
- if (set == g.s.bMute) {
- g.mw->qaAudioMute->setChecked(set);
- g.mw->qaAudioMute->trigger();
+ if (set == Global::get().s.bMute) {
+ Global::get().mw->qaAudioMute->setChecked(set);
+ Global::get().mw->qaAudioMute->trigger();
} else {
- g.mw->qaAudioMute->setChecked(!set);
- g.mw->qaAudioMute->trigger();
+ Global::get().mw->qaAudioMute->setChecked(!set);
+ Global::get().mw->qaAudioMute->trigger();
}
}
iter = qmRequest.find(QLatin1String("deaf"));
if (iter != qmRequest.constEnd()) {
bool set = iter.value().toBool();
- if (set != g.s.bDeaf) {
- g.mw->qaAudioDeaf->setChecked(!set);
- g.mw->qaAudioDeaf->trigger();
+ if (set != Global::get().s.bDeaf) {
+ Global::get().mw->qaAudioDeaf->setChecked(!set);
+ Global::get().mw->qaAudioDeaf->trigger();
}
}
iter = qmRequest.find(QLatin1String("undeaf"));
if (iter != qmRequest.constEnd()) {
bool set = iter.value().toBool();
- if (set == g.s.bDeaf) {
- g.mw->qaAudioDeaf->setChecked(set);
- g.mw->qaAudioDeaf->trigger();
+ if (set == Global::get().s.bDeaf) {
+ Global::get().mw->qaAudioDeaf->setChecked(set);
+ Global::get().mw->qaAudioDeaf->trigger();
}
}
iter = qmRequest.find(QLatin1String("toggledeaf"));
if (iter != qmRequest.constEnd()) {
bool set = iter.value().toBool();
- if (set == g.s.bDeaf) {
- g.mw->qaAudioDeaf->setChecked(set);
- g.mw->qaAudioDeaf->trigger();
+ if (set == Global::get().s.bDeaf) {
+ Global::get().mw->qaAudioDeaf->setChecked(set);
+ Global::get().mw->qaAudioDeaf->trigger();
} else {
- g.mw->qaAudioDeaf->setChecked(!set);
- g.mw->qaAudioDeaf->trigger();
+ Global::get().mw->qaAudioDeaf->setChecked(!set);
+ Global::get().mw->qaAudioDeaf->trigger();
}
}
iter = qmRequest.find(QLatin1String("starttalking"));
if (iter != qmRequest.constEnd()) {
- g.mw->on_PushToTalk_triggered(true, QVariant());
+ Global::get().mw->on_PushToTalk_triggered(true, QVariant());
}
iter = qmRequest.find(QLatin1String("stoptalking"));
if (iter != qmRequest.constEnd()) {
- g.mw->on_PushToTalk_triggered(false, QVariant());
+ Global::get().mw->on_PushToTalk_triggered(false, QVariant());
}
ack = true;
} else if (request.nodeName() == QLatin1String("url")) {
- if (g.sh && g.sh->isRunning() && g.uiSession) {
+ if (Global::get().sh && Global::get().sh->isRunning() && Global::get().uiSession) {
QString host, user, pw;
unsigned short port;
QUrl u;
- g.sh->getConnectionInfo(host, port, user, pw);
+ Global::get().sh->getConnectionInfo(host, port, user, pw);
u.setScheme(QLatin1String("mumble"));
u.setHost(host);
u.setPort(port);
@@ -189,7 +186,7 @@ void SocketRPCClient::processXml() {
u.setQuery(query);
QStringList path;
- Channel *c = ClientUser::get(g.uiSession)->cChannel;
+ Channel *c = ClientUser::get(Global::get().uiSession)->cChannel;
while (c->cParent) {
path.prepend(c->qsName);
c = c->cParent;
@@ -203,7 +200,7 @@ void SocketRPCClient::processXml() {
QUrl u = iter.value().toUrl();
if (u.isValid() && u.scheme() == QLatin1String("mumble")) {
OpenURLEvent *oue = new OpenURLEvent(u);
- qApp->postEvent(g.mw, oue);
+ qApp->postEvent(Global::get().mw, oue);
ack = true;
}
} else {
diff --git a/src/mumble/TalkingUI.cpp b/src/mumble/TalkingUI.cpp
index 9417ccc68..0aec811b6 100644
--- a/src/mumble/TalkingUI.cpp
+++ b/src/mumble/TalkingUI.cpp
@@ -11,6 +11,7 @@
#include "TalkingUIComponent.h"
#include "UserModel.h"
#include "widgets/MultiStyleWidgetWrapper.h"
+#include "Global.h"
#include <QGroupBox>
#include <QGuiApplication>
@@ -31,10 +32,6 @@
#include <algorithm>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
TalkingUI::TalkingUI(QWidget *parent) : QWidget(parent), m_containers(), m_currentSelection(nullptr) {
setupUI();
}
@@ -233,12 +230,12 @@ void TalkingUI::setupUI() {
// properly and as the TalkingUI doesn't provide context help anyways, this is not a big loss.
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
- connect(g.mw->qtvUsers->selectionModel(), &QItemSelectionModel::currentChanged, this,
+ connect(Global::get().mw->qtvUsers->selectionModel(), &QItemSelectionModel::currentChanged, this,
&TalkingUI::on_mainWindowSelectionChanged);
}
void TalkingUI::setFontSize(MultiStyleWidgetWrapper &widgetWrapper) {
- const double fontFactor = g.s.iTalkingUI_RelativeFontSize / 100.0;
+ const double fontFactor = Global::get().s.iTalkingUI_RelativeFontSize / 100.0;
const int origLineHeight = QFontMetrics(font()).height();
if (font().pixelSize() >= 0) {
@@ -333,10 +330,10 @@ void TalkingUI::addChannel(const Channel *channel) {
if (findContainer(channel->iId, ContainerType::CHANNEL) < 0) {
// Create a QGroupBox for this channel
const QString channelName =
- createChannelName(channel, g.s.bTalkingUI_AbbreviateChannelNames, g.s.iTalkingUI_PrefixCharCount,
- g.s.iTalkingUI_PostfixCharCount, g.s.iTalkingUI_MaxChannelNameLength,
- g.s.iTalkingUI_ChannelHierarchyDepth, g.s.qsTalkingUI_ChannelSeparator,
- g.s.qsTalkingUI_AbbreviationReplacement, g.s.bTalkingUI_AbbreviateCurrentChannel);
+ createChannelName(channel, Global::get().s.bTalkingUI_AbbreviateChannelNames, Global::get().s.iTalkingUI_PrefixCharCount,
+ Global::get().s.iTalkingUI_PostfixCharCount, Global::get().s.iTalkingUI_MaxChannelNameLength,
+ Global::get().s.iTalkingUI_ChannelHierarchyDepth, Global::get().s.qsTalkingUI_ChannelSeparator,
+ Global::get().s.qsTalkingUI_AbbreviationReplacement, Global::get().s.bTalkingUI_AbbreviateCurrentChannel);
std::unique_ptr< TalkingUIChannel > channelContainer =
std::make_unique< TalkingUIChannel >(channel->iId, channelName, *this);
@@ -380,7 +377,7 @@ TalkingUIUser *TalkingUI::findOrAddUser(const ClientUser *user) {
if (!oldUserEntry || !nameMatches) {
// Create an entry for this user
- bool isSelf = g.uiSession == user->uiSession;
+ bool isSelf = Global::get().uiSession == user->uiSession;
int channelIndex = findContainer(user->cChannel->iId, ContainerType::CHANNEL);
if (channelIndex) {
@@ -397,9 +394,9 @@ TalkingUIUser *TalkingUI::findOrAddUser(const ClientUser *user) {
TalkingUIUser *newUserEntry = userEntry.get();
// * 1000 as the setting is in seconds whereas the timer expects milliseconds
- userEntry->setLifeTime(g.s.iTalkingUI_SilentUserLifeTime * 1000);
+ userEntry->setLifeTime(Global::get().s.iTalkingUI_SilentUserLifeTime * 1000);
- userEntry->restrictLifetime(!isSelf || !g.s.bTalkingUI_LocalUserStaysVisible);
+ userEntry->restrictLifetime(!isSelf || !Global::get().s.bTalkingUI_LocalUserStaysVisible);
userEntry->setPriority(isSelf ? EntryPriority::HIGH : EntryPriority::DEFAULT);
@@ -407,7 +404,7 @@ TalkingUIUser *TalkingUI::findOrAddUser(const ClientUser *user) {
&TalkingUI::on_userLocalVolumeAdjustmentsChanged);
// If this user is currently selected, mark him/her as such
- if (g.mw && g.mw->pmModel && g.mw->pmModel->getSelectedUser() == user) {
+ if (Global::get().mw && Global::get().mw->pmModel && Global::get().mw->pmModel->getSelectedUser() == user) {
setSelection(UserSelection(userEntry->getWidget(), userEntry->getAssociatedUserSession()));
}
@@ -546,7 +543,7 @@ void TalkingUI::mousePressEvent(QMouseEvent *event) {
}
if (foundTarget) {
- if (event->button() == Qt::RightButton && g.mw) {
+ if (event->button() == Qt::RightButton && Global::get().mw) {
// If an entry is selected and the right mouse button was clicked, we pretend as if the user had clicked on
// the client in the MainWindow. For this to work we map the global mouse position to the local coordinate
// system of the UserView in the MainWindow. The function will use some internal logic to determine the user
@@ -554,8 +551,8 @@ void TalkingUI::mousePressEvent(QMouseEvent *event) {
// currently selected item. This item we have updated to the correct one with the setSelection() call above
// resulting in the proper context menu being shown at the position of the mouse which in this case is in
// the TalkingUI.
- QMetaObject::invokeMethod(g.mw, "on_qtvUsers_customContextMenuRequested", Qt::QueuedConnection,
- Q_ARG(QPoint, g.mw->qtvUsers->mapFromGlobal(event->globalPos())), Q_ARG(bool, false));
+ QMetaObject::invokeMethod(Global::get().mw, "on_qtvUsers_customContextMenuRequested", Qt::QueuedConnection,
+ Q_ARG(QPoint, Global::get().mw->qtvUsers->mapFromGlobal(event->globalPos())), Q_ARG(bool, false));
}
} else {
// Clear selection
@@ -619,13 +616,13 @@ void TalkingUI::on_mainWindowSelectionChanged(const QModelIndex &current, const
Q_UNUSED(previous);
// Sync the selection in the MainWindow to the TalkingUI
- if (g.mw && g.mw->pmModel) {
+ if (Global::get().mw && Global::get().mw->pmModel) {
bool clearSelection = true;
- const ClientUser *user = g.mw->pmModel->getUser(current);
- const Channel *channel = g.mw->pmModel->getChannel(current);
+ const ClientUser *user = Global::get().mw->pmModel->getUser(current);
+ const Channel *channel = Global::get().mw->pmModel->getChannel(current);
- if (g.mw->pmModel->isChannelListener(current)) {
+ if (Global::get().mw->pmModel->isChannelListener(current)) {
TalkingUIChannelListener *listenerEntry = findListener(user->uiSession, channel->iId);
if (listenerEntry) {
@@ -668,11 +665,11 @@ void TalkingUI::on_mainWindowSelectionChanged(const QModelIndex &current, const
}
void TalkingUI::on_serverSynchronized() {
- if (g.s.bTalkingUI_LocalUserStaysVisible) {
+ if (Global::get().s.bTalkingUI_LocalUserStaysVisible) {
// According to the settings the local user should always be visible and as we
// can't count on it to change its talking state right after it has connected to
// a server, we have to add it manually.
- ClientUser *self = ClientUser::get(g.uiSession);
+ ClientUser *self = ClientUser::get(Global::get().uiSession);
findOrAddUser(self);
}
}
@@ -729,10 +726,10 @@ void TalkingUI::on_settingsChanged() {
if (channel) {
// Update
channelContainer->setName(
- createChannelName(channel, g.s.bTalkingUI_AbbreviateChannelNames, g.s.iTalkingUI_PrefixCharCount,
- g.s.iTalkingUI_PostfixCharCount, g.s.iTalkingUI_MaxChannelNameLength,
- g.s.iTalkingUI_ChannelHierarchyDepth, g.s.qsTalkingUI_ChannelSeparator,
- g.s.qsTalkingUI_AbbreviationReplacement, g.s.bTalkingUI_AbbreviateCurrentChannel));
+ createChannelName(channel, Global::get().s.bTalkingUI_AbbreviateChannelNames, Global::get().s.iTalkingUI_PrefixCharCount,
+ Global::get().s.iTalkingUI_PostfixCharCount, Global::get().s.iTalkingUI_MaxChannelNameLength,
+ Global::get().s.iTalkingUI_ChannelHierarchyDepth, Global::get().s.qsTalkingUI_ChannelSeparator,
+ Global::get().s.qsTalkingUI_AbbreviationReplacement, Global::get().s.bTalkingUI_AbbreviateCurrentChannel));
} else {
qCritical("TalkingUI: Can't find channel for stored ID");
}
@@ -748,20 +745,20 @@ void TalkingUI::on_settingsChanged() {
// The time that a silent user may stick around might have changed as well
// * 1000 as the setting is in seconds whereas the timer expects milliseconds
- userEntry->setLifeTime(g.s.iTalkingUI_SilentUserLifeTime * 1000);
+ userEntry->setLifeTime(Global::get().s.iTalkingUI_SilentUserLifeTime * 1000);
}
}
}
- const ClientUser *self = ClientUser::get(g.uiSession);
+ const ClientUser *self = ClientUser::get(Global::get().uiSession);
// Whether or not the current user should always be displayed might also have changed,
// so we'll have to update that as well.
- TalkingUIUser *localUserEntry = findUser(g.uiSession);
+ TalkingUIUser *localUserEntry = findUser(Global::get().uiSession);
if (localUserEntry) {
- localUserEntry->restrictLifetime(!g.s.bTalkingUI_LocalUserStaysVisible);
+ localUserEntry->restrictLifetime(!Global::get().s.bTalkingUI_LocalUserStaysVisible);
} else {
- if (self && g.s.bTalkingUI_LocalUserStaysVisible) {
+ if (self && Global::get().s.bTalkingUI_LocalUserStaysVisible) {
// Add the local user as it is requested to be displayed
findOrAddUser(self);
}
@@ -771,7 +768,7 @@ void TalkingUI::on_settingsChanged() {
// Furthermore whether or not to display the local user's listeners might have changed -> clear all
// listeners from the TalkingUI and add them again if appropriate
removeAllListeners();
- if (g.s.bTalkingUI_ShowLocalListeners) {
+ if (Global::get().s.bTalkingUI_ShowLocalListeners) {
if (self) {
const QSet< int > channels = ChannelListener::getListenedChannelsForUser(self->uiSession);
@@ -811,7 +808,7 @@ void TalkingUI::on_userLocalVolumeAdjustmentsChanged(float, float) {
}
void TalkingUI::on_channelListenerAdded(const ClientUser *user, const Channel *channel) {
- if (user->uiSession == g.uiSession && g.s.bTalkingUI_ShowLocalListeners) {
+ if (user->uiSession == Global::get().uiSession && Global::get().s.bTalkingUI_ShowLocalListeners) {
addListener(user, channel);
}
}
@@ -821,10 +818,10 @@ void TalkingUI::on_channelListenerRemoved(const ClientUser *user, const Channel
}
void TalkingUI::on_channelListenerLocalVolumeAdjustmentChanged(int channelID, float, float) {
- TalkingUIChannelListener *listenerEntry = findListener(g.uiSession, channelID);
+ TalkingUIChannelListener *listenerEntry = findListener(Global::get().uiSession, channelID);
const Channel *channel = Channel::get(channelID);
- const ClientUser *self = ClientUser::get(g.uiSession);
+ const ClientUser *self = ClientUser::get(Global::get().uiSession);
if (listenerEntry && channel && self) {
listenerEntry->setDisplayString(UserModel::createDisplayString(*self, true, channel));
diff --git a/src/mumble/TalkingUIEntry.cpp b/src/mumble/TalkingUIEntry.cpp
index 7d9966cb0..0a95b4923 100644
--- a/src/mumble/TalkingUIEntry.cpp
+++ b/src/mumble/TalkingUIEntry.cpp
@@ -9,6 +9,7 @@
#include "TalkingUI.h"
#include "TalkingUIContainer.h"
#include "UserModel.h"
+#include "Global.h"
#include <QHBoxLayout>
#include <QLabel>
@@ -18,10 +19,6 @@
#include <QVariant>
#include <QWidget>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
TalkingUIEntry::TalkingUIEntry(unsigned int associatedUserSession) : m_associatedUserSession(associatedUserSession) {
}
@@ -136,7 +133,7 @@ TalkingUIUser::TalkingUIUser(const ClientUser &user)
QObject::connect(&m_timer, &QTimer::timeout, [this]() {
if (getContainer()) {
// We let the TalkingUI handle the removing in order for it to do the necessary
- // housekeeping (e.g. making sure there is no active selection for this user).
+ // housekeeping (e.Global::get(). making sure there is no active selection for this user).
getContainer()->m_talkingUI.removeUser(getAssociatedUserSession());
}
});
@@ -257,7 +254,7 @@ void TalkingUIUser::setIconSize(int size) {
}
void TalkingUIUser::setDisplayString(const QString &displayString) {
- if (g.uiSession == getAssociatedUserSession()) {
+ if (Global::get().uiSession == getAssociatedUserSession()) {
// Display own name in bold
m_nameLabel->setText(QString::fromLatin1("<b>%1</b>").arg(displayString));
} else {
diff --git a/src/mumble/TalkingUISelection.cpp b/src/mumble/TalkingUISelection.cpp
index bcdecd8b4..12f1f25ff 100644
--- a/src/mumble/TalkingUISelection.cpp
+++ b/src/mumble/TalkingUISelection.cpp
@@ -6,14 +6,11 @@
#include "TalkingUISelection.h"
#include "MainWindow.h"
#include "UserModel.h"
+#include "Global.h"
#include <QVariant>
#include <QWidget>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
TalkingUISelection::TalkingUISelection(QWidget *widget) : m_widget(widget) {
}
@@ -56,8 +53,8 @@ UserSelection::UserSelection(QWidget *widget, unsigned int userSession)
}
void UserSelection::syncToMainWindow() const {
- if (g.mw && g.mw->pmModel) {
- g.mw->pmModel->setSelectedUser(m_userSession);
+ if (Global::get().mw && Global::get().mw->pmModel) {
+ Global::get().mw->pmModel->setSelectedUser(m_userSession);
}
}
@@ -72,8 +69,8 @@ ChannelSelection::ChannelSelection(QWidget *widget, int channelID)
}
void ChannelSelection::syncToMainWindow() const {
- if (g.mw && g.mw->pmModel) {
- g.mw->pmModel->setSelectedChannel(m_channelID);
+ if (Global::get().mw && Global::get().mw->pmModel) {
+ Global::get().mw->pmModel->setSelectedChannel(m_channelID);
}
}
@@ -88,8 +85,8 @@ ListenerSelection::ListenerSelection(QWidget *widget, unsigned int userSession,
}
void ListenerSelection::syncToMainWindow() const {
- if (g.mw && g.mw->pmModel) {
- g.mw->pmModel->setSelectedChannelListener(m_userSession, m_channelID);
+ if (Global::get().mw && Global::get().mw->pmModel) {
+ Global::get().mw->pmModel->setSelectedChannelListener(m_userSession, m_channelID);
}
}
diff --git a/src/mumble/TextToSpeech_macx.mm b/src/mumble/TextToSpeech_macx.mm
index 83533540c..35d033445 100644
--- a/src/mumble/TextToSpeech_macx.mm
+++ b/src/mumble/TextToSpeech_macx.mm
@@ -38,7 +38,6 @@
#import <AppKit/AppKit.h>
-#include "Global.h"
#include "TextToSpeech.h"
@interface MUSpeechSynthesizerPrivateHelper : NSObject {
diff --git a/src/mumble/TextToSpeech_unix.cpp b/src/mumble/TextToSpeech_unix.cpp
index 30d8db377..8c4b5fe7c 100644
--- a/src/mumble/TextToSpeech_unix.cpp
+++ b/src/mumble/TextToSpeech_unix.cpp
@@ -4,6 +4,7 @@
// Mumble source tree or at <https://www.mumble.info/LICENSE>.
#include "TextToSpeech.h"
+#include "Global.h"
#ifdef USE_SPEECHD
# ifdef USE_SPEECHD_PKGCONFIG
@@ -15,10 +16,6 @@
#include <QtCore/QLocale>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
class TextToSpeechPrivate {
#ifdef USE_SPEECHD
protected:
@@ -60,10 +57,10 @@ void TextToSpeechPrivate::ensureInitialized() {
qWarning("TextToSpeech: Failed to contact speech dispatcher.");
} else {
QString lang;
- if (!g.s.qsTTSLanguage.isEmpty()) {
- lang = g.s.qsTTSLanguage;
- } else if (!g.s.qsLanguage.isEmpty()) {
- QLocale locale(g.s.qsLanguage);
+ if (!Global::get().s.qsTTSLanguage.isEmpty()) {
+ lang = Global::get().s.qsTTSLanguage;
+ } else if (!Global::get().s.qsLanguage.isEmpty()) {
+ QLocale locale(Global::get().s.qsLanguage);
lang = locale.bcp47Name();
} else {
QLocale systemLocale;
diff --git a/src/mumble/Themes.cpp b/src/mumble/Themes.cpp
index 34d350ce9..aba833d0b 100644
--- a/src/mumble/Themes.cpp
+++ b/src/mumble/Themes.cpp
@@ -6,9 +6,6 @@
#include "Themes.h"
#include "MainWindow.h"
#include "MumbleApplication.h"
-
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
#include "Global.h"
boost::optional< ThemeInfo::StyleInfo > Themes::getConfiguredStyle(const Settings &settings) {
@@ -58,7 +55,7 @@ void Themes::applyFallback() {
}
bool Themes::applyConfigured() {
- boost::optional< ThemeInfo::StyleInfo > style = Themes::getConfiguredStyle(g.s);
+ boost::optional< ThemeInfo::StyleInfo > style = Themes::getConfiguredStyle(Global::get().s);
if (!style) {
return false;
}
@@ -102,8 +99,8 @@ bool Themes::apply() {
applyFallback();
}
- if (g.mw) {
- g.mw->qteLog->document()->setDefaultStyleSheet(qApp->styleSheet());
+ if (Global::get().mw) {
+ Global::get().mw->qteLog->document()->setDefaultStyleSheet(qApp->styleSheet());
}
return result;
}
@@ -113,7 +110,7 @@ ThemeMap Themes::getThemes() {
}
QDir Themes::getUserThemesDirectory() {
- return QDir(g.qdBasePath.absolutePath() + QLatin1String("/Themes"));
+ return QDir(Global::get().qdBasePath.absolutePath() + QLatin1String("/Themes"));
}
QVector< QDir > Themes::getSearchDirectories() {
@@ -131,7 +128,7 @@ QVector< QDir > Themes::getSearchDirectories() {
}
QString Themes::userStylesheetPath() {
- return g.qdBasePath.absolutePath() + QLatin1String("/user.qss");
+ return Global::get().qdBasePath.absolutePath() + QLatin1String("/user.qss");
}
bool Themes::readStylesheet(const QString &stylesheetFn, QString &stylesheetContent) {
diff --git a/src/mumble/Tokens.cpp b/src/mumble/Tokens.cpp
index 514b2d6d9..38ba16fac 100644
--- a/src/mumble/Tokens.cpp
+++ b/src/mumble/Tokens.cpp
@@ -7,17 +7,14 @@
#include "Database.h"
#include "ServerHandler.h"
-
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
#include "Global.h"
Tokens::Tokens(QWidget *p) : QDialog(p) {
setupUi(this);
qlwTokens->setAccessibleName(tr("Tokens"));
- qbaDigest = g.sh->qbaDigest;
- QStringList tokens = g.db->getTokens(qbaDigest);
+ qbaDigest = Global::get().sh->qbaDigest;
+ QStringList tokens = Global::get().db->getTokens(qbaDigest);
tokens.sort();
foreach (const QString &qs, tokens) {
QListWidgetItem *qlwi = new QListWidgetItem(qs);
@@ -35,8 +32,8 @@ void Tokens::accept() {
if (!text.isEmpty())
qsl << text;
}
- g.db->setTokens(qbaDigest, qsl);
- g.sh->setTokens(qsl);
+ Global::get().db->setTokens(qbaDigest, qsl);
+ Global::get().sh->setTokens(qsl);
QDialog::accept();
}
diff --git a/src/mumble/Usage.cpp b/src/mumble/Usage.cpp
index 95b7c2a68..7a7ef83ca 100644
--- a/src/mumble/Usage.cpp
+++ b/src/mumble/Usage.cpp
@@ -29,8 +29,8 @@ Usage::Usage(QObject *p) : QObject(p) {
}
void Usage::registerUsage() {
- if (!g.s.bUsage
- || g.s.uiUpdateCounter == 0) // Only register usage if allowed by the user and first wizard run has finished
+ if (!Global::get().s.bUsage
+ || Global::get().s.uiUpdateCounter == 0) // Only register usage if allowed by the user and first wizard run has finished
return;
QDomDocument doc;
@@ -44,17 +44,17 @@ void Usage::registerUsage() {
tag = doc.createElement(QLatin1String("in"));
root.appendChild(tag);
- t = doc.createTextNode(g.s.qsAudioInput);
+ t = doc.createTextNode(Global::get().s.qsAudioInput);
tag.appendChild(t);
tag = doc.createElement(QLatin1String("out"));
root.appendChild(tag);
- t = doc.createTextNode(g.s.qsAudioOutput);
+ t = doc.createTextNode(Global::get().s.qsAudioOutput);
tag.appendChild(t);
tag = doc.createElement(QLatin1String("lcd"));
root.appendChild(tag);
- t = doc.createTextNode(QString::number(g.lcd->hasDevices() ? 1 : 0));
+ t = doc.createTextNode(QString::number(Global::get().lcd->hasDevices() ? 1 : 0));
tag.appendChild(t);
QBuffer *qb = new QBuffer();
@@ -65,7 +65,7 @@ void Usage::registerUsage() {
Network::prepareRequest(req);
req.setHeader(QNetworkRequest::ContentTypeHeader, QLatin1String("text/xml"));
- QNetworkReply *rep = g.nam->post(req, qb);
+ QNetworkReply *rep = Global::get().nam->post(req, qb);
qb->setParent(rep);
connect(rep, SIGNAL(finished()), rep, SLOT(deleteLater()));
diff --git a/src/mumble/UserEdit.cpp b/src/mumble/UserEdit.cpp
index c23fd746b..e0da4a1ff 100644
--- a/src/mumble/UserEdit.cpp
+++ b/src/mumble/UserEdit.cpp
@@ -9,14 +9,11 @@
#include "ServerHandler.h"
#include "User.h"
#include "UserListModel.h"
+#include "Global.h"
#include <QtCore/QItemSelectionModel>
#include <QtWidgets/QMenu>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
UserEdit::UserEdit(const MumbleProto::UserList &userList, QWidget *p)
: QDialog(p), m_model(new UserListModel(userList, this)), m_filter(new UserListFilterProxyModel(this)) {
setupUi(this);
@@ -58,7 +55,7 @@ UserEdit::UserEdit(const MumbleProto::UserList &userList, QWidget *p)
void UserEdit::accept() {
if (m_model->isUserListDirty()) {
MumbleProto::UserList userList = m_model->getUserListUpdate();
- g.sh->sendMessage(userList);
+ Global::get().sh->sendMessage(userList);
}
QDialog::accept();
diff --git a/src/mumble/UserInformation.cpp b/src/mumble/UserInformation.cpp
index a5780a81b..f234169c7 100644
--- a/src/mumble/UserInformation.cpp
+++ b/src/mumble/UserInformation.cpp
@@ -10,13 +10,10 @@
#include "HostAddress.h"
#include "ServerHandler.h"
#include "ViewCert.h"
+#include "Global.h"
#include <QtCore/QUrl>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
static QString decode_utf8_qssl_string(const QString &input) {
QString i = input;
return QUrl::fromPercentEncoding(i.replace(QLatin1String("\\x"), QLatin1String("%")).toLatin1());
@@ -58,7 +55,7 @@ void UserInformation::tick() {
bRequested = true;
- g.sh->requestUserStats(uiSession, true);
+ Global::get().sh->requestUserStats(uiSession, true);
}
void UserInformation::on_qpbCertificate_clicked() {
@@ -150,7 +147,7 @@ void UserInformation::update(const MumbleProto::UserStats &msg) {
QStringList qsl;
for (int i = 0; i < msg.celt_versions_size(); ++i) {
int v = msg.celt_versions(i);
- CELTCodec *cc = g.qmCodecs.value(v);
+ CELTCodec *cc = Global::get().qmCodecs.value(v);
if (cc)
qsl << cc->version();
else
diff --git a/src/mumble/UserLocalNicknameDialog.cpp b/src/mumble/UserLocalNicknameDialog.cpp
index 6c31a9cbb..14a9489ad 100644
--- a/src/mumble/UserLocalNicknameDialog.cpp
+++ b/src/mumble/UserLocalNicknameDialog.cpp
@@ -7,14 +7,11 @@
#include "ClientUser.h"
#include "Database.h"
#include "MainWindow.h"
+#include "Global.h"
#include <QtGui/QCloseEvent>
#include <QtWidgets/QPushButton>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
UserLocalNicknameDialog::UserLocalNicknameDialog(
unsigned int sessionId,
std::unordered_map< unsigned int, NicknameDialogPtr > &qmUserNicknameTracker)
@@ -35,7 +32,7 @@ UserLocalNicknameDialog::UserLocalNicknameDialog(
m_originalNickname = qleUserLocalNickname->text();
}
- if (g.mw && g.mw->windowFlags() & Qt::WindowStaysOnTopHint) {
+ if (Global::get().mw && Global::get().mw->windowFlags() & Qt::WindowStaysOnTopHint) {
// If the main window is set to always be on top of other windows, we should make the
// nickname dialog behave the same in order for it to not get hidden behind the main window.
setWindowFlags(Qt::WindowStaysOnTopHint);
@@ -76,9 +73,9 @@ void UserLocalNicknameDialog::on_qbbUserLocalNickname_clicked(QAbstractButton *b
ClientUser *user = ClientUser::get(m_clientSession);
if (user) {
if (!user->qsHash.isEmpty()) {
- g.db->setUserLocalNickname(user->qsHash, user->getLocalNickname());
+ Global::get().db->setUserLocalNickname(user->qsHash, user->getLocalNickname());
} else {
- g.mw->logChangeNotPermanent(QObject::tr("Local Nickname Adjustment..."), user);
+ Global::get().mw->logChangeNotPermanent(QObject::tr("Local Nickname Adjustment..."), user);
}
}
UserLocalNicknameDialog::close();
diff --git a/src/mumble/UserLocalVolumeDialog.cpp b/src/mumble/UserLocalVolumeDialog.cpp
index 20ddea688..a4f5981a1 100644
--- a/src/mumble/UserLocalVolumeDialog.cpp
+++ b/src/mumble/UserLocalVolumeDialog.cpp
@@ -38,16 +38,13 @@
#include "ClientUser.h"
#include "Database.h"
#include "MainWindow.h"
+#include "Global.h"
#include <QtGui/QCloseEvent>
#include <QtWidgets/QPushButton>
#include <cmath>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
UserLocalVolumeDialog::UserLocalVolumeDialog(unsigned int sessionId,
QMap< unsigned int, UserLocalVolumeDialog * > *qmUserVolTracker)
: QDialog(nullptr), m_clientSession(sessionId), m_qmUserVolTracker(qmUserVolTracker) {
@@ -63,7 +60,7 @@ UserLocalVolumeDialog::UserLocalVolumeDialog(unsigned int sessionId,
m_originalVolumeAdjustmentDecibel = qsUserLocalVolume->value();
}
- if (g.mw && g.mw->windowFlags() & Qt::WindowStaysOnTopHint) {
+ if (Global::get().mw && Global::get().mw->windowFlags() & Qt::WindowStaysOnTopHint) {
// If the main window is set to always be on top of other windows, we should make the
// volume dialog behave the same in order for it to not get hidden behind the main window.
setWindowFlags(Qt::WindowStaysOnTopHint);
@@ -107,9 +104,9 @@ void UserLocalVolumeDialog::on_qbbUserLocalVolume_clicked(QAbstractButton *butto
ClientUser *user = ClientUser::get(m_clientSession);
if (user) {
if (!user->qsHash.isEmpty()) {
- g.db->setUserLocalVolume(user->qsHash, user->getLocalVolumeAdjustments());
+ Global::get().db->setUserLocalVolume(user->qsHash, user->getLocalVolumeAdjustments());
} else {
- g.mw->logChangeNotPermanent(QObject::tr("Local Volume Adjustment..."), user);
+ Global::get().mw->logChangeNotPermanent(QObject::tr("Local Volume Adjustment..."), user);
}
}
UserLocalVolumeDialog::close();
diff --git a/src/mumble/UserModel.cpp b/src/mumble/UserModel.cpp
index b1253f48d..14b681b71 100644
--- a/src/mumble/UserModel.cpp
+++ b/src/mumble/UserModel.cpp
@@ -19,6 +19,7 @@
#include "ServerHandler.h"
#include "Usage.h"
#include "User.h"
+#include "Global.h"
#include <QtCore/QMimeData>
#include <QtCore/QStack>
@@ -27,10 +28,6 @@
#include <QtWidgets/QToolTip>
#include <QtWidgets/QWhatsThis>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
QHash< const Channel *, ModelItem * > ModelItem::c_qhChannels;
QHash< const ClientUser *, ModelItem * > ModelItem::c_qhUsers;
QHash< const ClientUser *, QList< ModelItem * > > ModelItem::s_userProxies;
@@ -223,10 +220,10 @@ QString ModelItem::hash() const {
chash.addData(cChan->qsName.toUtf8());
chash.addData(QString::number(cChan->iId).toUtf8());
- if (g.sh && g.sh->isRunning()) {
+ if (Global::get().sh && Global::get().sh->isRunning()) {
QString host, user, pw;
unsigned short port;
- g.sh->getConnectionInfo(host, port, user, pw);
+ Global::get().sh->getConnectionInfo(host, port, user, pw);
chash.addData(host.toUtf8());
chash.addData(QString::number(port).toUtf8());
}
@@ -262,7 +259,7 @@ UserModel::UserModel(QObject *p) : QAbstractItemModel(p) {
qiLock_unlocked = QIcon(QLatin1String("skin:lock_unlocked.svg"));
qiEar = QIcon(QLatin1String("skin:ear.svg"));
- ModelItem::bUsersTop = g.s.bUserTop;
+ ModelItem::bUsersTop = Global::get().s.bUserTop;
uiSessionComment = 0;
iChannelDescription = -1;
@@ -401,7 +398,7 @@ QString UserModel::stringIndex(const QModelIndex &idx) const {
}
QModelIndex UserModel::getSelectedIndex() const {
- QTreeView *v = g.mw->qtvUsers;
+ QTreeView *v = Global::get().mw->qtvUsers;
if (v) {
QItemSelectionModel *sel = v->selectionModel();
@@ -419,7 +416,7 @@ QVariant UserModel::data(const QModelIndex &idx, int role) const {
Channel *c = item->cChan;
ClientUser *p = item->pUser;
- ClientUser *pSelf = ClientUser::get(g.uiSession);
+ ClientUser *pSelf = ClientUser::get(Global::get().uiSession);
if (!c && !p) {
return QVariant();
@@ -464,14 +461,14 @@ QVariant UserModel::data(const QModelIndex &idx, int role) const {
}
break;
case Qt::FontRole:
- if ((idx.column() == 0) && (p->uiSession == g.uiSession)) {
- QFont f = g.mw->font();
+ if ((idx.column() == 0) && (p->uiSession == Global::get().uiSession)) {
+ QFont f = Global::get().mw->font();
f.setBold(!f.bold());
f.setItalic(item->isListener);
return f;
}
if (item->isListener) {
- QFont f = g.mw->font();
+ QFont f = Global::get().mw->font();
f.setItalic(true);
return f;
}
@@ -496,7 +493,7 @@ QVariant UserModel::data(const QModelIndex &idx, int role) const {
// ClientUser doesn't contain a push-to-mute
// state because it isn't sent to the server.
// We can show the icon only for the local user.
- if (p == pSelf && g.bPushToMute && !item->isListener)
+ if (p == pSelf && Global::get().bPushToMute && !item->isListener)
l << qiMutedPushToMute;
if (p->bMute || item->isListener)
l << qiMutedServer;
@@ -524,8 +521,8 @@ QVariant UserModel::data(const QModelIndex &idx, int role) const {
switch (role) {
case Qt::DecorationRole:
if (idx.column() == 0) {
- if (g.uiSession && qsLinked.contains(c)) {
- if (ClientUser::get(g.uiSession)->cChannel == c)
+ if (Global::get().uiSession && qsLinked.contains(c)) {
+ if (ClientUser::get(Global::get().uiSession)->cChannel == c)
return qiActiveChannel;
else
return qiLinkedChannel;
@@ -535,7 +532,7 @@ QVariant UserModel::data(const QModelIndex &idx, int role) const {
break;
case Qt::DisplayRole:
if (idx.column() == 0) {
- if (!g.s.bShowUserCount || item->iUsers == 0)
+ if (!Global::get().s.bShowUserCount || item->iUsers == 0)
return c->qsName;
return QString::fromLatin1("%1 (%2)").arg(c->qsName).arg(item->iUsers);
@@ -556,11 +553,11 @@ QVariant UserModel::data(const QModelIndex &idx, int role) const {
}
return l;
case Qt::FontRole:
- if (g.uiSession) {
- Channel *home = ClientUser::get(g.uiSession)->cChannel;
+ if (Global::get().uiSession) {
+ Channel *home = ClientUser::get(Global::get().uiSession)->cChannel;
if ((c == home) || qsLinked.contains(c)) {
- QFont f = g.mw->font();
+ QFont f = Global::get().mw->font();
if (qsLinked.count() > 1)
f.setItalic(!f.italic());
if (c == home)
@@ -570,7 +567,7 @@ QVariant UserModel::data(const QModelIndex &idx, int role) const {
}
break;
case Qt::BackgroundRole:
- if ((c->iId == 0) && g.sh && g.sh->isStrong()) {
+ if ((c->iId == 0) && Global::get().sh && Global::get().sh->isStrong()) {
QColor qc(Qt::green);
qc.setAlpha(32);
return qc;
@@ -611,14 +608,14 @@ QVariant UserModel::otherRoles(const QModelIndex &idx, int role) const {
QString qsImage;
if (!p->qbaTextureHash.isEmpty()) {
if (p->qbaTexture.isEmpty()) {
- p->qbaTexture = g.db->blob(p->qbaTextureHash);
+ p->qbaTexture = Global::get().db->blob(p->qbaTextureHash);
if (p->qbaTexture.isEmpty()) {
MumbleProto::RequestBlob mprb;
mprb.add_session_texture(p->uiSession);
- g.sh->sendMessage(mprb);
+ Global::get().sh->sendMessage(mprb);
} else {
#ifdef USE_OVERLAY
- g.o->verifyTexture(p);
+ Global::get().o->verifyTexture(p);
#endif
}
}
@@ -647,13 +644,13 @@ QVariant UserModel::otherRoles(const QModelIndex &idx, int role) const {
return p->qsName;
} else {
if (p->qsComment.isEmpty()) {
- p->qsComment = QString::fromUtf8(g.db->blob(p->qbaCommentHash));
+ p->qsComment = QString::fromUtf8(Global::get().db->blob(p->qbaCommentHash));
if (p->qsComment.isEmpty()) {
const_cast< UserModel * >(this)->uiSessionComment = p->uiSession;
MumbleProto::RequestBlob mprb;
mprb.add_session_comment(p->uiSession);
- g.sh->sendMessage(mprb);
+ Global::get().sh->sendMessage(mprb);
return QVariant();
}
}
@@ -670,13 +667,13 @@ QVariant UserModel::otherRoles(const QModelIndex &idx, int role) const {
return c->qsName;
} else {
if (c->qsDesc.isEmpty()) {
- c->qsDesc = QString::fromUtf8(g.db->blob(c->qbaDescHash));
+ c->qsDesc = QString::fromUtf8(Global::get().db->blob(c->qbaDescHash));
if (c->qsDesc.isEmpty()) {
const_cast< UserModel * >(this)->iChannelDescription = c->iId;
MumbleProto::RequestBlob mprb;
mprb.add_channel_description(c->iId);
- g.sh->sendMessage(mprb);
+ Global::get().sh->sendMessage(mprb);
return QVariant();
}
}
@@ -871,7 +868,7 @@ ModelItem *UserModel::moveItem(ModelItem *oldparent, ModelItem *newparent, Model
// Check whether the moved item is currently selected and if so, store it as a persistent
// model index in active. Also clear the selection as we're going to mess with the active
// item.
- QTreeView *v = g.mw->qtvUsers;
+ QTreeView *v = Global::get().mw->qtvUsers;
QItemSelectionModel *sel = v->selectionModel();
QPersistentModelIndex active;
QModelIndex oindex = createIndex(oldrow, 0, oldItem);
@@ -967,7 +964,7 @@ void UserModel::expandAll(Channel *c) {
}
while (!chans.isEmpty()) {
c = chans.pop();
- g.mw->qtvUsers->setExpanded(index(c), true);
+ Global::get().mw->qtvUsers->setExpanded(index(c), true);
}
}
@@ -975,7 +972,7 @@ void UserModel::collapseEmpty(Channel *c) {
while (c) {
ModelItem *mi = ModelItem::c_qhChannels.value(c);
if (mi->iUsers == 0)
- g.mw->qtvUsers->setExpanded(index(c), false);
+ Global::get().mw->qtvUsers->setExpanded(index(c), false);
else
break;
c = c->cParent;
@@ -983,17 +980,17 @@ void UserModel::collapseEmpty(Channel *c) {
}
void UserModel::ensureSelfVisible() {
- if (!g.uiSession)
+ if (!Global::get().uiSession)
return;
- g.mw->qtvUsers->scrollTo(index(ClientUser::get(g.uiSession)));
+ Global::get().mw->qtvUsers->scrollTo(index(ClientUser::get(Global::get().uiSession)));
}
void UserModel::recheckLinks() {
- if (!g.uiSession)
+ if (!Global::get().uiSession)
return;
- ClientUser *clientUser = ClientUser::get(g.uiSession);
+ ClientUser *clientUser = ClientUser::get(Global::get().uiSession);
if (!clientUser)
return;
@@ -1062,8 +1059,8 @@ void UserModel::removeUser(ClientUser *p) {
// First remove all listener proxies this user has at the moment
removeChannelListener(p);
- if (g.uiSession && p->uiSession == g.uiSession)
- g.uiSession = 0;
+ if (Global::get().uiSession && p->uiSession == Global::get().uiSession)
+ Global::get().uiSession = 0;
Channel *c = p->cChannel;
ModelItem *item = ModelItem::c_qhUsers.value(p);
ModelItem *citem = ModelItem::c_qhChannels.value(c);
@@ -1085,7 +1082,7 @@ void UserModel::removeUser(ClientUser *p) {
citem = citem->parent;
}
- if (g.s.ceExpand == Settings::ChannelsWithUsers)
+ if (Global::get().s.ceExpand == Settings::ChannelsWithUsers)
collapseEmpty(c);
updateOverlay();
@@ -1102,7 +1099,7 @@ void UserModel::moveUser(ClientUser *p, Channel *np) {
item = moveItem(opi, pi, item);
- if (p->uiSession == g.uiSession) {
+ if (p->uiSession == Global::get().uiSession) {
ensureSelfVisible();
recheckLinks();
}
@@ -1116,7 +1113,7 @@ void UserModel::moveUser(ClientUser *p, Channel *np) {
pi = pi->parent;
}
- if (g.s.ceExpand == Settings::ChannelsWithUsers) {
+ if (Global::get().s.ceExpand == Settings::ChannelsWithUsers) {
expandAll(np);
collapseEmpty(oc);
}
@@ -1166,27 +1163,27 @@ void UserModel::setComment(ClientUser *cu, const QString &comment) {
cu->qsComment = comment;
if (!comment.isEmpty()) {
- g.db->setBlob(cu->qbaCommentHash, cu->qsComment.toUtf8());
+ Global::get().db->setBlob(cu->qbaCommentHash, cu->qsComment.toUtf8());
if (cu->uiSession == uiSessionComment) {
uiSessionComment = 0;
item->bCommentSeen = false;
if (bClicked) {
- QRect r = g.mw->qtvUsers->visualRect(index(cu));
- QWhatsThis::showText(g.mw->qtvUsers->viewport()->mapToGlobal(r.bottomRight()),
- data(index(cu, 0), Qt::ToolTipRole).toString(), g.mw->qtvUsers);
+ QRect r = Global::get().mw->qtvUsers->visualRect(index(cu));
+ QWhatsThis::showText(Global::get().mw->qtvUsers->viewport()->mapToGlobal(r.bottomRight()),
+ data(index(cu, 0), Qt::ToolTipRole).toString(), Global::get().mw->qtvUsers);
} else {
- QToolTip::showText(QCursor::pos(), data(index(cu, 0), Qt::ToolTipRole).toString(), g.mw->qtvUsers);
+ QToolTip::showText(QCursor::pos(), data(index(cu, 0), Qt::ToolTipRole).toString(), Global::get().mw->qtvUsers);
}
} else if (cu->uiSession == ~uiSessionComment) {
uiSessionComment = 0;
- if (cu->uiSession == g.uiSession) {
- QTimer::singleShot(0, g.mw, SLOT(on_qaSelfComment_triggered()));
+ if (cu->uiSession == Global::get().uiSession) {
+ QTimer::singleShot(0, Global::get().mw, SLOT(on_qaSelfComment_triggered()));
} else {
- g.mw->cuContextUser = cu;
- QTimer::singleShot(0, g.mw, SLOT(on_qaUserCommentView_triggered()));
+ Global::get().mw->cuContextUser = cu;
+ QTimer::singleShot(0, Global::get().mw, SLOT(on_qaUserCommentView_triggered()));
}
} else {
- item->bCommentSeen = g.db->seenComment(item->hash(), cu->qbaCommentHash);
+ item->bCommentSeen = Global::get().db->seenComment(item->hash(), cu->qbaCommentHash);
newstate = item->bCommentSeen ? 2 : 1;
}
} else {
@@ -1209,7 +1206,7 @@ void UserModel::setCommentHash(ClientUser *cu, const QByteArray &hash) {
cu->qsComment = QString();
cu->qbaCommentHash = hash;
- item->bCommentSeen = g.db->seenComment(item->hash(), cu->qbaCommentHash);
+ item->bCommentSeen = Global::get().db->seenComment(item->hash(), cu->qbaCommentHash);
newstate = item->bCommentSeen ? 2 : 1;
if (oldstate != newstate) {
@@ -1230,20 +1227,20 @@ void UserModel::setComment(Channel *c, const QString &comment) {
c->qsDesc = comment;
if (!comment.isEmpty()) {
- g.db->setBlob(c->qbaDescHash, c->qsDesc.toUtf8());
+ Global::get().db->setBlob(c->qbaDescHash, c->qsDesc.toUtf8());
if (c->iId == iChannelDescription) {
iChannelDescription = -1;
item->bCommentSeen = false;
if (bClicked) {
- QRect r = g.mw->qtvUsers->visualRect(index(c));
- QWhatsThis::showText(g.mw->qtvUsers->viewport()->mapToGlobal(r.bottomRight()),
- data(index(c, 0), Qt::ToolTipRole).toString(), g.mw->qtvUsers);
+ QRect r = Global::get().mw->qtvUsers->visualRect(index(c));
+ QWhatsThis::showText(Global::get().mw->qtvUsers->viewport()->mapToGlobal(r.bottomRight()),
+ data(index(c, 0), Qt::ToolTipRole).toString(), Global::get().mw->qtvUsers);
} else {
- QToolTip::showText(QCursor::pos(), data(index(c, 0), Qt::ToolTipRole).toString(), g.mw->qtvUsers);
+ QToolTip::showText(QCursor::pos(), data(index(c, 0), Qt::ToolTipRole).toString(), Global::get().mw->qtvUsers);
}
} else {
- item->bCommentSeen = g.db->seenComment(item->hash(), c->qbaDescHash);
+ item->bCommentSeen = Global::get().db->seenComment(item->hash(), c->qbaDescHash);
newstate = item->bCommentSeen ? 2 : 1;
}
} else {
@@ -1266,7 +1263,7 @@ void UserModel::setCommentHash(Channel *c, const QByteArray &hash) {
c->qsDesc = QString();
c->qbaDescHash = hash;
- item->bCommentSeen = g.db->seenComment(item->hash(), hash);
+ item->bCommentSeen = Global::get().db->seenComment(item->hash(), hash);
newstate = item->bCommentSeen ? 2 : 1;
if (oldstate != newstate) {
@@ -1288,9 +1285,9 @@ void UserModel::seenComment(const QModelIndex &idx) {
emit dataChanged(idx, idx);
if (item->pUser)
- g.db->setSeenComment(item->hash(), item->pUser->qbaCommentHash);
+ Global::get().db->setSeenComment(item->hash(), item->pUser->qbaCommentHash);
else
- g.db->setSeenComment(item->hash(), item->cChan->qbaDescHash);
+ Global::get().db->setSeenComment(item->hash(), item->cChan->qbaDescHash);
}
void UserModel::renameChannel(Channel *c, const QString &name) {
@@ -1341,8 +1338,8 @@ Channel *UserModel::addChannel(int id, Channel *p, const QString &name) {
citem->qlChildren.insert(row, item);
endInsertRows();
- if (g.s.ceExpand == Settings::AllChannels)
- g.mw->qtvUsers->setExpanded(index(item), true);
+ if (Global::get().s.ceExpand == Settings::AllChannels)
+ Global::get().mw->qtvUsers->setExpanded(index(item), true);
return c;
}
@@ -1418,7 +1415,7 @@ void UserModel::setSelectedChannelListener(unsigned int userSession, int channel
return;
}
- QTreeView *v = g.mw->qtvUsers;
+ QTreeView *v = Global::get().mw->qtvUsers;
if (v) {
v->setCurrentIndex(idx);
}
@@ -1461,7 +1458,7 @@ void UserModel::removeChannelListener(ModelItem *item, ModelItem *citem) {
citem = citem->parent;
}
- if (g.s.ceExpand == Settings::ChannelsWithUsers)
+ if (Global::get().s.ceExpand == Settings::ChannelsWithUsers)
collapseEmpty(c);
updateOverlay();
@@ -1527,7 +1524,7 @@ void UserModel::moveChannel(Channel *c, Channel *p) {
ensureSelfVisible();
- if (g.s.ceExpand == Settings::ChannelsWithUsers) {
+ if (Global::get().s.ceExpand == Settings::ChannelsWithUsers) {
collapseEmpty(oc);
}
}
@@ -1609,7 +1606,7 @@ void UserModel::setSelectedUser(unsigned int session) {
return;
}
- QTreeView *v = g.mw->qtvUsers;
+ QTreeView *v = Global::get().mw->qtvUsers;
if (v) {
v->setCurrentIndex(idx);
}
@@ -1653,7 +1650,7 @@ void UserModel::setSelectedChannel(int id) {
return;
}
- QTreeView *v = g.mw->qtvUsers;
+ QTreeView *v = Global::get().mw->qtvUsers;
if (v) {
v->setCurrentIndex(idx);
}
@@ -1690,7 +1687,7 @@ void UserModel::on_channelListenerLocalVolumeAdjustmentChanged(int channelID, fl
Q_UNUSED(oldValue);
Q_UNUSED(newValue);
- const QModelIndex idx = channelListenerIndex(ClientUser::get(g.uiSession), Channel::get(channelID));
+ const QModelIndex idx = channelListenerIndex(ClientUser::get(Global::get().uiSession), Channel::get(channelID));
emit dataChanged(idx, idx);
}
@@ -1699,8 +1696,8 @@ void UserModel::toggleChannelFiltered(Channel *c) {
if (c) {
c->bFiltered = !c->bFiltered;
- ServerHandlerPtr sh = g.sh;
- g.db->setChannelFiltered(sh->qbaDigest, c->iId, c->bFiltered);
+ ServerHandlerPtr sh = Global::get().sh;
+ Global::get().db->setChannelFiltered(sh->qbaDigest, c->iId, c->bFiltered);
idx = index(c);
}
@@ -1774,17 +1771,17 @@ bool UserModel::dropMimeData(const QMimeData *md, Qt::DropAction, int row, int c
if (!isChannel) {
// User dropped somewhere
int ret;
- switch (g.s.ceUserDrag) {
+ switch (Global::get().s.ceUserDrag) {
case Settings::Ask:
ret =
- QMessageBox::question(g.mw, QLatin1String("Mumble"), tr("Are you sure you want to drag this user?"),
+ QMessageBox::question(Global::get().mw, QLatin1String("Mumble"), tr("Are you sure you want to drag this user?"),
QMessageBox::Yes, QMessageBox::No);
if (ret == QMessageBox::No)
return false;
break;
case Settings::DoNothing:
- g.l->log(Log::Information,
+ Global::get().l->log(Log::Information,
MainWindow::tr("You have User Dragging set to \"Do Nothing\" so the user wasn't moved."));
return false;
break;
@@ -1794,13 +1791,13 @@ bool UserModel::dropMimeData(const QMimeData *md, Qt::DropAction, int row, int c
MumbleProto::UserState mpus;
mpus.set_session(uiSession);
mpus.set_channel_id(c->iId);
- g.sh->sendMessage(mpus);
+ Global::get().sh->sendMessage(mpus);
} else if (c->iId != iId) {
// Channel dropped somewhere (not on itself)
int ret;
- switch (g.s.ceChannelDrag) {
+ switch (Global::get().s.ceChannelDrag) {
case Settings::Ask:
- ret = QMessageBox::question(g.mw, QLatin1String("Mumble"),
+ ret = QMessageBox::question(Global::get().mw, QLatin1String("Mumble"),
tr("Are you sure you want to drag this channel?"), QMessageBox::Yes,
QMessageBox::No);
@@ -1808,7 +1805,7 @@ bool UserModel::dropMimeData(const QMimeData *md, Qt::DropAction, int row, int c
return false;
break;
case Settings::DoNothing:
- g.l->log(
+ Global::get().l->log(
Log::Information,
MainWindow::tr("You have Channel Dragging set to \"Do Nothing\" so the channel wasn't moved."));
return false;
@@ -1816,7 +1813,7 @@ bool UserModel::dropMimeData(const QMimeData *md, Qt::DropAction, int row, int c
case Settings::Move:
break;
default:
- g.l->log(Log::CriticalError, MainWindow::tr("Unknown Channel Drag mode in UserModel::dropMimeData."));
+ Global::get().l->log(Log::CriticalError, MainWindow::tr("Unknown Channel Drag mode in UserModel::dropMimeData."));
return false;
break;
}
@@ -1905,7 +1902,7 @@ bool UserModel::dropMimeData(const QMimeData *md, Qt::DropAction, int row, int c
} else {
// Not enough space, other channels have to be moved
if (static_cast< long long >(pi->channelAt(ilast)->iPosition) + 40 > INT_MAX) {
- QMessageBox::critical(g.mw, QLatin1String("Mumble"),
+ QMessageBox::critical(Global::get().mw, QLatin1String("Mumble"),
tr("Cannot perform this movement automatically, please reset the "
"numeric sorting indicators or adjust it manually."));
return false;
@@ -1916,7 +1913,7 @@ bool UserModel::dropMimeData(const QMimeData *md, Qt::DropAction, int row, int c
MumbleProto::ChannelState mpcs;
mpcs.set_channel_id(tmp->iId);
mpcs.set_position(tmp->iPosition + 40);
- g.sh->sendMessage(mpcs);
+ Global::get().sh->sendMessage(mpcs);
}
}
inewpos = upper->iPosition + 20;
@@ -1926,7 +1923,7 @@ bool UserModel::dropMimeData(const QMimeData *md, Qt::DropAction, int row, int c
}
if (inewpos > INT_MAX || inewpos < INT_MIN) {
- QMessageBox::critical(g.mw, QLatin1String("Mumble"),
+ QMessageBox::critical(Global::get().mw, QLatin1String("Mumble"),
tr("Cannot perform this movement automatically, please reset the numeric sorting "
"indicators or adjust it manually."));
return false;
@@ -1937,7 +1934,7 @@ bool UserModel::dropMimeData(const QMimeData *md, Qt::DropAction, int row, int c
if (dropped->parent() != c)
mpcs.set_parent(c->iId);
mpcs.set_position(static_cast< int >(inewpos));
- g.sh->sendMessage(mpcs);
+ Global::get().sh->sendMessage(mpcs);
}
return true;
@@ -1945,9 +1942,9 @@ bool UserModel::dropMimeData(const QMimeData *md, Qt::DropAction, int row, int c
void UserModel::updateOverlay() const {
#ifdef USE_OVERLAY
- g.o->updateOverlay();
+ Global::get().o->updateOverlay();
#endif
- g.lcd->updateUserView();
+ Global::get().lcd->updateUserView();
}
@@ -1957,7 +1954,7 @@ QString UserModel::createDisplayString(const ClientUser &user, bool isChannelLis
// the volume adjustment differently.
float volumeAdjustment = 1.0f;
if (isChannelListener) {
- if (parentChannel && user.uiSession == g.uiSession) {
+ if (parentChannel && user.uiSession == Global::get().uiSession) {
// Only the listener of the local user can have a volume adjustment
volumeAdjustment = ChannelListener::getListenerLocalVolumeAdjustment(parentChannel->iId);
}
@@ -1980,12 +1977,12 @@ QString UserModel::createDisplayString(const ClientUser &user, bool isChannelLis
// Create a tag that indicates the volume adjustments
QString volumeTag;
- if (std::abs(localVolumeDecibel) > 0 && g.s.bShowVolumeAdjustments) {
+ if (std::abs(localVolumeDecibel) > 0 && Global::get().s.bShowVolumeAdjustments) {
volumeTag = QString::asprintf("|%+d|", localVolumeDecibel);
}
QString displayString;
- if (!g.s.bShowNicknamesOnly || nickname.isEmpty()) {
+ if (!Global::get().s.bShowNicknamesOnly || nickname.isEmpty()) {
displayString += user.qsName;
} else {
displayString += nickname;
@@ -1995,7 +1992,7 @@ QString UserModel::createDisplayString(const ClientUser &user, bool isChannelLis
displayString += " " + friendTag;
}
- if (!g.s.bShowNicknamesOnly && !nickname.isEmpty() && user.qsName.compare(nickname, Qt::CaseInsensitive) != 0) {
+ if (!Global::get().s.bShowNicknamesOnly && !nickname.isEmpty() && user.qsName.compare(nickname, Qt::CaseInsensitive) != 0) {
displayString += " " + QString::fromLatin1("[%1]").arg(nickname);
}
diff --git a/src/mumble/UserView.cpp b/src/mumble/UserView.cpp
index 57b885636..7767b966a 100644
--- a/src/mumble/UserView.cpp
+++ b/src/mumble/UserView.cpp
@@ -11,16 +11,13 @@
#include "MainWindow.h"
#include "ServerHandler.h"
#include "UserModel.h"
+#include "Global.h"
#include <QtGui/QDesktopServices>
#include <QtGui/QHelpEvent>
#include <QtGui/QPainter>
#include <QtWidgets/QWhatsThis>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
const int UserDelegate::FLAG_ICON_DIMENSION = 16;
const int UserDelegate::FLAG_ICON_PADDING = 1;
const int UserDelegate::FLAG_DIMENSION = 18;
@@ -139,7 +136,7 @@ bool UserView::event(QEvent *evt) {
/**
* This function is used to create custom behaviour when clicking
- * on user/channel flags (e.g. showing the comment)
+ * on user/channel flags (e.Global::get(). showing the comment)
*/
void UserView::mouseReleaseEvent(QMouseEvent *evt) {
QPoint clickPosition = evt->pos();
@@ -227,14 +224,14 @@ void UserView::nodeActivated(const QModelIndex &idx) {
UserModel *um = static_cast< UserModel * >(model());
ClientUser *p = um->getUser(idx);
if (p) {
- g.mw->openTextMessageDialog(p);
+ Global::get().mw->openTextMessageDialog(p);
return;
}
Channel *c = um->getChannel(idx);
if (c) {
// if a channel is activated join it
- g.sh->joinChannel(g.uiSession, c->iId);
+ Global::get().sh->joinChannel(Global::get().uiSession, c->iId);
}
}
@@ -345,14 +342,14 @@ void UserView::updateChannel(const QModelIndex &idx) {
}
if (c && idx.parent().isValid()) {
- if (g.s.bFilterActive == false) {
+ if (Global::get().s.bFilterActive == false) {
setRowHidden(idx.row(), idx.parent(), false);
} else {
bool isChannelUserIsIn = false;
// Check whether user resides in this channel or a subchannel
- if (g.uiSession != 0) {
- const ClientUser *user = ClientUser::get(g.uiSession);
+ if (Global::get().uiSession != 0) {
+ const ClientUser *user = ClientUser::get(Global::get().uiSession);
if (user) {
Channel *chan = user->cChannel;
while (chan) {
@@ -368,7 +365,7 @@ void UserView::updateChannel(const QModelIndex &idx) {
if (channelFiltered(c) && !isChannelUserIsIn) {
setRowHidden(idx.row(), idx.parent(), true);
} else {
- if (g.s.bFilterHidesEmptyChannels && !channelHasUsers(c)) {
+ if (Global::get().s.bFilterHidesEmptyChannels && !channelHasUsers(c)) {
setRowHidden(idx.row(), idx.parent(), true);
} else {
setRowHidden(idx.row(), idx.parent(), false);
diff --git a/src/mumble/VersionCheck.cpp b/src/mumble/VersionCheck.cpp
index c001873ee..fab59f446 100644
--- a/src/mumble/VersionCheck.cpp
+++ b/src/mumble/VersionCheck.cpp
@@ -8,6 +8,7 @@
#include "MainWindow.h"
#include "Utils.h"
#include "WebFetch.h"
+#include "Global.h"
#ifdef Q_OS_WIN
# include "win.h"
@@ -24,10 +25,6 @@
# include <softpub.h>
#endif
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
VersionCheck::VersionCheck(bool autocheck, QObject *p, bool focus) : QObject(p), m_preparationWatcher() {
connect(&m_preparationWatcher, &QFutureWatcher< void >::finished, this, &VersionCheck::performRequest);
@@ -52,13 +49,13 @@ VersionCheck::VersionCheck(bool autocheck, QObject *p, bool focus) : QObject(p),
#else
queryItems << qMakePair(QString::fromLatin1("os"), QString::fromLatin1("Unix"));
#endif
- if (!g.s.bUsage)
+ if (!Global::get().s.bUsage)
queryItems << qMakePair(QString::fromLatin1("nousage"), QString::fromLatin1("1"));
if (autocheck)
queryItems << qMakePair(QString::fromLatin1("auto"), QString::fromLatin1("1"));
queryItems << qMakePair(QString::fromLatin1("locale"),
- g.s.qsLanguage.isEmpty() ? QLocale::system().name() : g.s.qsLanguage);
+ Global::get().s.qsLanguage.isEmpty() ? QLocale::system().name() : Global::get().s.qsLanguage);
QFile f(qApp->applicationFilePath());
if (!f.open(QIODevice::ReadOnly)) {
@@ -91,10 +88,10 @@ void VersionCheck::fetched(QByteArray a, QUrl url) {
if (!a.isEmpty()) {
#ifdef SNAPSHOT_BUILD
if (url.path() == QLatin1String("/v1/banner")) {
- g.mw->msgBox(QString::fromUtf8(a));
+ Global::get().mw->msgBox(QString::fromUtf8(a));
} else if (url.path() == QLatin1String("/v1/version-check")) {
# ifndef Q_OS_WIN
- g.mw->msgBox(QString::fromUtf8(a));
+ Global::get().mw->msgBox(QString::fromUtf8(a));
# else
QDomDocument qdd;
qdd.setContent(a);
@@ -106,10 +103,10 @@ void VersionCheck::fetched(QByteArray a, QUrl url) {
fetch.setHost(QString());
fetch.setScheme(QString());
if (!fetch.isValid()) {
- g.mw->msgBox(QString::fromUtf8(a));
+ Global::get().mw->msgBox(QString::fromUtf8(a));
} else {
QString filename =
- g.qdBasePath.absoluteFilePath(QLatin1String("Snapshots/") + QFileInfo(fetch.path()).fileName());
+ Global::get().qdBasePath.absoluteFilePath(QLatin1String("Snapshots/") + QFileInfo(fetch.path()).fileName());
QFile qf(filename);
if (qf.exists()) {
@@ -136,7 +133,7 @@ void VersionCheck::fetched(QByteArray a, QUrl url) {
if (ts == 0) {
if (QMessageBox::question(
- g.mw, tr("Upgrade Mumble"),
+ Global::get().mw, tr("Upgrade Mumble"),
tr("A new version of Mumble has been detected and automatically downloaded. It is "
"recommended that you either upgrade to this version, or downgrade to the "
"latest stable release. Do you want to launch the installer now?"),
@@ -152,22 +149,22 @@ void VersionCheck::fetched(QByteArray a, QUrl url) {
execinfo.nShow = SW_NORMAL;
if (ShellExecuteExW(&execinfo)) {
- g.mw->bSuppressAskOnQuit = true;
+ Global::get().mw->bSuppressAskOnQuit = true;
qApp->closeAllWindows();
} else {
- g.mw->msgBox(tr("Failed to launch snapshot installer."));
+ Global::get().mw->msgBox(tr("Failed to launch snapshot installer."));
}
}
} else {
- g.mw->msgBox(tr("Corrupt download of new version detected. Automatically removed."));
+ Global::get().mw->msgBox(tr("Corrupt download of new version detected. Automatically removed."));
qf.remove();
}
// Delete all but the N most recent snapshots
size_t numberOfSnapshotsToKeep = 1;
- QDir snapdir(g.qdBasePath.absolutePath() + QLatin1String("/Snapshots/"), QString(), QDir::Name,
+ QDir snapdir(Global::get().qdBasePath.absolutePath() + QLatin1String("/Snapshots/"), QString(), QDir::Name,
QDir::Files);
foreach (const QFileInfo fileInfo,
@@ -182,7 +179,7 @@ void VersionCheck::fetched(QByteArray a, QUrl url) {
file.remove();
}
} else {
- g.mw->msgBox(tr("Downloading new snapshot from %1 to %2")
+ Global::get().mw->msgBox(tr("Downloading new snapshot from %1 to %2")
.arg(fetch.toString().toHtmlEscaped(), filename.toHtmlEscaped()));
WebFetch::fetch(QLatin1String("dl"), fetch, this, SLOT(fetched(QByteArray, QUrl)));
return;
@@ -190,25 +187,25 @@ void VersionCheck::fetched(QByteArray a, QUrl url) {
}
} else {
QString filename =
- g.qdBasePath.absoluteFilePath(QLatin1String("Snapshots/") + QFileInfo(url.path()).fileName());
+ Global::get().qdBasePath.absoluteFilePath(QLatin1String("Snapshots/") + QFileInfo(url.path()).fileName());
QFile qf(filename);
if (qf.open(QIODevice::WriteOnly)) {
qf.write(a);
qf.close();
- new VersionCheck(true, g.mw);
+ new VersionCheck(true, Global::get().mw);
} else {
- g.mw->msgBox(tr("Failed to write new version to disk."));
+ Global::get().mw->msgBox(tr("Failed to write new version to disk."));
}
# endif
}
#else
Q_UNUSED(url);
- g.mw->msgBox(QString::fromUtf8(a));
+ Global::get().mw->msgBox(QString::fromUtf8(a));
#endif
}
} else {
- g.mw->msgBox(tr("Mumble failed to retrieve version information from the central server."));
+ Global::get().mw->msgBox(tr("Mumble failed to retrieve version information from the central server."));
}
deleteLater();
diff --git a/src/mumble/VoiceRecorder.cpp b/src/mumble/VoiceRecorder.cpp
index 2d3cffdb9..bba6bf34b 100644
--- a/src/mumble/VoiceRecorder.cpp
+++ b/src/mumble/VoiceRecorder.cpp
@@ -8,15 +8,12 @@
#include "AudioOutput.h"
#include "ClientUser.h"
#include "ServerHandler.h"
+#include "Global.h"
#include "../Timer.h"
#include <boost/make_shared.hpp>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
VoiceRecorder::RecordBuffer::RecordBuffer(int recordInfoIndex_, boost::shared_array< float > buffer_, int samples_,
quint64 absoluteStartSample_)
@@ -97,10 +94,10 @@ QString VoiceRecorder::expandTemplateVariables(const QString &path, const QStrin
QString time(m_recordingStartTime.time().toString(QLatin1String("hh-mm-ss")));
QString hostname(QLatin1String("Unknown"));
- if (g.sh && g.uiSession != 0) {
+ if (Global::get().sh && Global::get().uiSession != 0) {
unsigned short port;
QString uname, pw;
- g.sh->getConnectionInfo(hostname, port, uname, pw);
+ Global::get().sh->getConnectionInfo(hostname, port, uname, pw);
}
// Create hash which stores the names of the variables with the corresponding values.
@@ -167,7 +164,7 @@ SF_INFO VoiceRecorder::createSoundFileInfo() const {
Q_ASSERT(m_config.sampleRate != 0);
// When adding new formats make sure to properly configure needed additional
- // behavior after opening the file handle (e.g. to enable clipping).
+ // behavior after opening the file handle (e.Global::get(). to enable clipping).
// Convert |fmFormat| to a SF_INFO structure for libsndfile.
SF_INFO sfinfo;
@@ -283,7 +280,7 @@ bool VoiceRecorder::ensureFileIsOpenedFor(SF_INFO &soundFileInfo, boost::shared_
void VoiceRecorder::run() {
Q_ASSERT(!m_recording);
- if (g.sh && g.sh->uiVersion < 0x010203)
+ if (Global::get().sh && Global::get().sh->uiVersion < 0x010203)
return;
SF_INFO soundFileInfo = createSoundFileInfo();
@@ -296,7 +293,7 @@ void VoiceRecorder::run() {
m_sleepLock.lock();
m_sleepCondition.wait(&m_sleepLock);
- if (!m_recording || m_abort || (g.sh && g.sh->uiVersion < 0x010203)) {
+ if (!m_recording || m_abort || (Global::get().sh && Global::get().sh->uiVersion < 0x010203)) {
m_sleepLock.unlock();
break;
}
diff --git a/src/mumble/VoiceRecorderDialog.cpp b/src/mumble/VoiceRecorderDialog.cpp
index b3103f0c0..e3d9ddc12 100644
--- a/src/mumble/VoiceRecorderDialog.cpp
+++ b/src/mumble/VoiceRecorderDialog.cpp
@@ -8,15 +8,12 @@
#include "AudioOutput.h"
#include "ServerHandler.h"
#include "VoiceRecorder.h"
+#include "Global.h"
#include <QtGui/QCloseEvent>
#include <QtWidgets/QFileDialog>
#include <QtWidgets/QMessageBox>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
VoiceRecorderDialog::VoiceRecorderDialog(QWidget *p) : QDialog(p), qtTimer(new QTimer(this)) {
qtTimer->setObjectName(QLatin1String("qtTimer"));
qtTimer->setInterval(200);
@@ -25,10 +22,10 @@ VoiceRecorderDialog::VoiceRecorderDialog(QWidget *p) : QDialog(p), qtTimer(new Q
qleTargetDirectory->setAccessibleName(tr("Target directory"));
qleFilename->setAccessibleName(tr("Filename"));
- qleTargetDirectory->setText(g.s.qsRecordingPath);
- qleFilename->setText(g.s.qsRecordingFile);
- qrbDownmix->setChecked(g.s.rmRecordingMode == Settings::RecordingMixdown);
- qrbMultichannel->setChecked(g.s.rmRecordingMode == Settings::RecordingMultichannel);
+ qleTargetDirectory->setText(Global::get().s.qsRecordingPath);
+ qleFilename->setText(Global::get().s.qsRecordingFile);
+ qrbDownmix->setChecked(Global::get().s.rmRecordingMode == Settings::RecordingMixdown);
+ qrbMultichannel->setChecked(Global::get().s.rmRecordingMode == Settings::RecordingMultichannel);
QString qsTooltip = QString::fromLatin1("%1"
"<table>"
@@ -64,10 +61,10 @@ VoiceRecorderDialog::VoiceRecorderDialog(QWidget *p) : QDialog(p), qtTimer(new Q
qcbFormat->addItem(VoiceRecorderFormat::getFormatDescription(static_cast< VoiceRecorderFormat::Format >(fm)));
}
- if (g.s.iRecordingFormat < 0 || g.s.iRecordingFormat > VoiceRecorderFormat::kEnd)
- g.s.iRecordingFormat = 0;
+ if (Global::get().s.iRecordingFormat < 0 || Global::get().s.iRecordingFormat > VoiceRecorderFormat::kEnd)
+ Global::get().s.iRecordingFormat = 0;
- qcbFormat->setCurrentIndex(g.s.iRecordingFormat);
+ qcbFormat->setCurrentIndex(Global::get().s.iRecordingFormat);
}
VoiceRecorderDialog::~VoiceRecorderDialog() {
@@ -75,8 +72,8 @@ VoiceRecorderDialog::~VoiceRecorderDialog() {
}
void VoiceRecorderDialog::closeEvent(QCloseEvent *evt) {
- if (g.sh) {
- VoiceRecorderPtr recorder(g.sh->recorder);
+ if (Global::get().sh) {
+ VoiceRecorderPtr recorder(Global::get().sh->recorder);
if (recorder && recorder->isRunning()) {
int ret = QMessageBox::warning(this, tr("Recorder still running"),
tr("Closing the recorder without stopping it will discard unwritten audio. "
@@ -92,15 +89,15 @@ void VoiceRecorderDialog::closeEvent(QCloseEvent *evt) {
}
}
- g.s.qsRecordingPath = qleTargetDirectory->text();
- g.s.qsRecordingFile = qleFilename->text();
+ Global::get().s.qsRecordingPath = qleTargetDirectory->text();
+ Global::get().s.qsRecordingFile = qleFilename->text();
if (qrbDownmix->isChecked())
- g.s.rmRecordingMode = Settings::RecordingMixdown;
+ Global::get().s.rmRecordingMode = Settings::RecordingMixdown;
else
- g.s.rmRecordingMode = Settings::RecordingMultichannel;
+ Global::get().s.rmRecordingMode = Settings::RecordingMultichannel;
int i = qcbFormat->currentIndex();
- g.s.iRecordingFormat = (i == -1) ? 0 : i;
+ Global::get().s.iRecordingFormat = (i == -1) ? 0 : i;
reset();
evt->accept();
@@ -109,13 +106,13 @@ void VoiceRecorderDialog::closeEvent(QCloseEvent *evt) {
}
void VoiceRecorderDialog::on_qpbStart_clicked() {
- if (!g.uiSession || !g.sh) {
+ if (!Global::get().uiSession || !Global::get().sh) {
QMessageBox::critical(this, tr("Recorder"), tr("Unable to start recording. Not connected to a server."));
reset();
return;
}
- if (g.sh->uiVersion < 0x010203) {
+ if (Global::get().sh->uiVersion < 0x010203) {
QMessageBox::critical(this, tr("Recorder"),
tr("The server you are currently connected to is version 1.2.2 or older. "
"For privacy reasons, recording on servers of versions older than 1.2.3 "
@@ -124,7 +121,7 @@ void VoiceRecorderDialog::on_qpbStart_clicked() {
return;
}
- if (g.sh->recorder) {
+ if (Global::get().sh->recorder) {
QMessageBox::information(this, tr("Recorder"), tr("There is already a recorder active for this server."));
return;
}
@@ -158,11 +155,11 @@ void VoiceRecorderDialog::on_qpbStart_clicked() {
qleFilename->setText(basename);
- AudioOutputPtr ao(g.ao);
+ AudioOutputPtr ao(Global::get().ao);
if (!ao)
return;
- g.sh->announceRecordingState(true);
+ Global::get().sh->announceRecordingState(true);
// Create the recorder
VoiceRecorder::Config config;
@@ -171,8 +168,8 @@ void VoiceRecorderDialog::on_qpbStart_clicked() {
config.mixDownMode = qrbDownmix->isChecked();
config.recordingFormat = static_cast< VoiceRecorderFormat::Format >(ifm);
- g.sh->recorder.reset(new VoiceRecorder(this, config));
- VoiceRecorderPtr recorder(g.sh->recorder);
+ Global::get().sh->recorder.reset(new VoiceRecorder(this, config));
+ VoiceRecorderPtr recorder(Global::get().sh->recorder);
// Wire it up
connect(&*recorder, SIGNAL(recording_started()), this, SLOT(onRecorderStarted()));
@@ -188,12 +185,12 @@ void VoiceRecorderDialog::on_qpbStart_clicked() {
}
void VoiceRecorderDialog::on_qpbStop_clicked() {
- if (!g.sh) {
+ if (!Global::get().sh) {
reset();
return;
}
- VoiceRecorderPtr recorder(g.sh->recorder);
+ VoiceRecorderPtr recorder(Global::get().sh->recorder);
if (!recorder) {
reset();
return;
@@ -209,18 +206,18 @@ void VoiceRecorderDialog::on_qpbStop_clicked() {
}
void VoiceRecorderDialog::on_qtTimer_timeout() {
- if (!g.sh) {
+ if (!Global::get().sh) {
reset();
return;
}
- if (!g.uiSession) {
+ if (!Global::get().uiSession) {
reset(false);
return;
}
- VoiceRecorderPtr recorder(g.sh->recorder);
- if (!g.sh->recorder) {
+ VoiceRecorderPtr recorder(Global::get().sh->recorder);
+ if (!Global::get().sh->recorder) {
reset();
return;
}
@@ -239,11 +236,11 @@ void VoiceRecorderDialog::on_qpbTargetDirectoryBrowse_clicked() {
void VoiceRecorderDialog::reset(bool resettimer) {
qtTimer->stop();
- if (g.sh) {
- VoiceRecorderPtr recorder(g.sh->recorder);
+ if (Global::get().sh) {
+ VoiceRecorderPtr recorder(Global::get().sh->recorder);
if (recorder) {
- g.sh->recorder.reset();
- g.sh->announceRecordingState(false);
+ Global::get().sh->recorder.reset();
+ Global::get().sh->announceRecordingState(false);
}
}
diff --git a/src/mumble/WASAPI.cpp b/src/mumble/WASAPI.cpp
index f73b061cf..f41204abd 100644
--- a/src/mumble/WASAPI.cpp
+++ b/src/mumble/WASAPI.cpp
@@ -16,9 +16,6 @@
#include "MainWindow.h"
#include "Utils.h"
-
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
#include "Global.h"
// Now that Win7 is published, which includes public versions of these
@@ -37,7 +34,7 @@ IAudioSessionQuery : public IUnknown {
/// Convert the configured 'wasapi/role' to an ERole.
static ERole WASAPIRoleFromSettings() {
- QString role = g.s.qsWASAPIRole.toLower().trimmed();
+ QString role = Global::get().s.qsWASAPIRole.toLower().trimmed();
if (role == QLatin1String("console")) {
return eConsole;
@@ -201,7 +198,7 @@ AudioInput *WASAPIInputRegistrar::create() {
}
const QList< audioDevice > WASAPIInputRegistrar::getDeviceChoices() {
- return WASAPISystem::mapToDevice(WASAPISystem::getInputDevices(), g.s.qsWASAPIInput);
+ return WASAPISystem::mapToDevice(WASAPISystem::getInputDevices(), Global::get().s.qsWASAPIInput);
}
void WASAPIInputRegistrar::setDeviceChoice(const QVariant &choice, Settings &s) {
@@ -225,7 +222,7 @@ AudioOutput *WASAPIOutputRegistrar::create() {
}
const QList< audioDevice > WASAPIOutputRegistrar::getDeviceChoices() {
- return WASAPISystem::mapToDevice(WASAPISystem::getOutputDevices(), g.s.qsWASAPIOutput);
+ return WASAPISystem::mapToDevice(WASAPISystem::getOutputDevices(), Global::get().s.qsWASAPIOutput);
}
void WASAPIOutputRegistrar::setDeviceChoice(const QVariant &choice, Settings &s) {
@@ -406,7 +403,7 @@ void WASAPIInput::run() {
HANDLE hMmThread;
float *tbuff = nullptr;
short *sbuff = nullptr;
- bool doecho = g.s.doEcho();
+ bool doecho = Global::get().s.doEcho();
REFERENCE_TIME def, min, latency, want;
bool exclusive = false;
@@ -420,13 +417,13 @@ void WASAPIInput::run() {
}
// Open mic device.
- pMicDevice = openNamedOrDefaultDevice(g.s.qsWASAPIInput, eCapture, WASAPIRoleFromSettings());
+ pMicDevice = openNamedOrDefaultDevice(Global::get().s.qsWASAPIInput, eCapture, WASAPIRoleFromSettings());
if (!pMicDevice)
goto cleanup;
// Open echo capture device.
if (doecho) {
- pEchoDevice = openNamedOrDefaultDevice(g.s.qsWASAPIOutput, eRender, WASAPIRoleFromSettings());
+ pEchoDevice = openNamedOrDefaultDevice(Global::get().s.qsWASAPIOutput, eRender, WASAPIRoleFromSettings());
if (!pEchoDevice)
doecho = false;
}
@@ -444,7 +441,7 @@ void WASAPIInput::run() {
want = qMax< REFERENCE_TIME >(min, 100000);
qWarning("WASAPIInput: Latencies %lld %lld => %lld", def, min, want);
- if (g.s.bExclusiveInput && !doecho) {
+ if (Global::get().s.bExclusiveInput && !doecho) {
for (int channels = 1; channels <= 2; ++channels) {
ZeroMemory(&wfe, sizeof(wfe));
wfe.Format.cbSize = 0;
@@ -473,7 +470,7 @@ void WASAPIInput::run() {
}
if (!micpwfxe) {
- if (g.s.bExclusiveInput)
+ if (Global::get().s.bExclusiveInput)
qWarning("WASAPIInput: Failed to open exclusive mode.");
if (!getAndCheckMixFormat("WASAPIInput", "Mic", pMicAudioClient, &micpwfx, &micpwfxe, &eMicFormat)) {
@@ -486,7 +483,7 @@ void WASAPIInput::run() {
qWarning("WASAPIInput: Mic Initialize failed: hr=0x%08lx", hr);
if (hr == E_ACCESSDENIED) {
WASAPIInputRegistrar::hasOSPermissionDenied = true;
- g.mw->msgBox(tr("Access to the microphone was denied. Please check that your operating system's "
+ Global::get().mw->msgBox(tr("Access to the microphone was denied. Please check that your operating system's "
"microphone settings allow Mumble to use the microphone."));
}
goto cleanup;
@@ -719,7 +716,7 @@ void WASAPIOutput::setVolumes(IMMDevice *pDevice, bool talking) {
DWORD dwMumble = GetCurrentProcessId();
qmVolumes.clear();
- if (qFuzzyCompare(g.s.fOtherVolume, 1.0f))
+ if (qFuzzyCompare(Global::get().s.fOtherVolume, 1.0f))
return;
// FIXME: Try to keep the session object around when returning volume.
@@ -791,7 +788,7 @@ bool WASAPIOutput::setVolumeForSessionControl2(IAudioSessionControl2 *control2,
if (SUCCEEDED(hr = pVolume->GetMute(&bMute)) && !bMute) {
float fVolume = 1.0f;
if (SUCCEEDED(hr = pVolume->GetMasterVolume(&fVolume)) && !qFuzzyCompare(fVolume, 0.0f)) {
- float fSetVolume = fVolume * g.s.fOtherVolume;
+ float fSetVolume = fVolume * Global::get().s.fOtherVolume;
if (SUCCEEDED(hr = pVolume->SetMasterVolume(fSetVolume, nullptr))) {
hr = pVolume->GetMasterVolume(&fSetVolume);
qmVolumes.insert(pVolume, VolumePair(fVolume, fSetVolume));
@@ -887,7 +884,7 @@ void WASAPIOutput::run() {
unsigned int chanmasks[32];
QMap< DWORD, float > qmVolumes;
bool lastspoke = false;
- REFERENCE_TIME bufferDuration = (g.s.iOutputDelay > 1) ? (g.s.iOutputDelay + 1) * 100000 : 0;
+ REFERENCE_TIME bufferDuration = (Global::get().s.iOutputDelay > 1) ? (Global::get().s.iOutputDelay + 1) * 100000 : 0;
bool exclusive = false;
bool mixed = false;
@@ -901,7 +898,7 @@ void WASAPIOutput::run() {
}
// Open the output device.
- pDevice = openNamedOrDefaultDevice(g.s.qsWASAPIOutput, eRender, WASAPIRoleFromSettings());
+ pDevice = openNamedOrDefaultDevice(Global::get().s.qsWASAPIOutput, eRender, WASAPIRoleFromSettings());
if (!pDevice)
goto cleanup;
@@ -918,7 +915,7 @@ void WASAPIOutput::run() {
want = qMax< REFERENCE_TIME >(min, 100000);
qWarning("WASAPIOutput: Latencies %lld %lld => %lld", def, min, want);
- if (g.s.bExclusiveOutput) {
+ if (Global::get().s.bExclusiveOutput) {
hr = pAudioClient->GetMixFormat(&pwfx);
if (FAILED(hr)) {
qWarning("WASAPIOutput: GetMixFormat failed: hr=0x%08lx", hr);
@@ -929,7 +926,7 @@ void WASAPIOutput::run() {
pwfxe = reinterpret_cast< WAVEFORMATEXTENSIBLE * >(pwfx);
}
- if (!g.s.bPositionalAudio) {
+ if (!Global::get().s.bPositionalAudio) {
// Override mix format and request stereo
pwfx->nChannels = 2;
if (pwfxe) {
@@ -963,14 +960,14 @@ void WASAPIOutput::run() {
}
if (!pwfx) {
- if (g.s.bExclusiveOutput)
+ if (Global::get().s.bExclusiveOutput)
qWarning("WASAPIOutput: Failed to open exclusive mode.");
if (!getAndCheckMixFormat("WASAPIOutput", "Output", pAudioClient, &pwfx, &pwfxe, &eSampleFormat)) {
goto cleanup;
}
- if (!g.s.bPositionalAudio) {
+ if (!Global::get().s.bPositionalAudio) {
pwfx->nChannels = 2;
pwfx->nBlockAlign = pwfx->nChannels * pwfx->wBitsPerSample / 8;
pwfx->nAvgBytesPerSec = pwfx->nBlockAlign * pwfx->nSamplesPerSec;
@@ -1016,7 +1013,7 @@ void WASAPIOutput::run() {
iMixerFreq = pwfx->nSamplesPerSec;
qWarning("WASAPIOutput: Periods %lldus %lldus (latency %lldus)", def / 10LL, min / 10LL, latency / 10LL);
- qWarning("WASAPIOutput: Buffer is %dus (%d)", (bufferFrameCount * 1000000) / iMixerFreq, g.s.iOutputDelay);
+ qWarning("WASAPIOutput: Buffer is %dus (%d)", (bufferFrameCount * 1000000) / iMixerFreq, Global::get().s.iOutputDelay);
hr = pAudioClient->GetService(__uuidof(IAudioRenderClient), (void **) &pRenderClient);
if (FAILED(hr)) {
@@ -1062,8 +1059,8 @@ void WASAPIOutput::run() {
while (bRunning && !FAILED(hr)) {
if (!exclusive) {
// Attenuate stream volumes.
- if (lastspoke != (g.bAttenuateOthers || mixed)) {
- lastspoke = g.bAttenuateOthers || mixed;
+ if (lastspoke != (Global::get().bAttenuateOthers || mixed)) {
+ lastspoke = Global::get().bAttenuateOthers || mixed;
setVolumes(pDevice, lastspoke);
}
@@ -1097,12 +1094,12 @@ void WASAPIOutput::run() {
if (exclusive)
break;
- if (!g.s.bAttenuateOthers && !g.bAttenuateOthers) {
+ if (!Global::get().s.bAttenuateOthers && !Global::get().bAttenuateOthers) {
mixed = false;
}
- if (lastspoke != (g.bAttenuateOthers || mixed)) {
- lastspoke = g.bAttenuateOthers || mixed;
+ if (lastspoke != (Global::get().bAttenuateOthers || mixed)) {
+ lastspoke = Global::get().bAttenuateOthers || mixed;
setVolumes(pDevice, lastspoke);
}
diff --git a/src/mumble/WASAPINotificationClient.cpp b/src/mumble/WASAPINotificationClient.cpp
index 28c8c5708..342128655 100644
--- a/src/mumble/WASAPINotificationClient.cpp
+++ b/src/mumble/WASAPINotificationClient.cpp
@@ -6,14 +6,11 @@
#include "MainWindow.h"
#include "WASAPINotificationClient.h"
+#include "Global.h"
#include <QtCore/QMutexLocker>
#include <boost/thread/once.hpp>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
HRESULT STDMETHODCALLTYPE WASAPINotificationClient::OnDefaultDeviceChanged(EDataFlow flow, ERole role,
LPCWSTR pwstrDefaultDevice) {
const QString device = QString::fromWCharArray(pwstrDefaultDevice);
@@ -169,7 +166,7 @@ WASAPINotificationClient::WASAPINotificationClient() : QObject(), pEnumerator(0)
return;
}
- g.mw->connect(this, SIGNAL(doResetAudio()), SLOT(onResetAudio()), Qt::QueuedConnection);
+ Global::get().mw->connect(this, SIGNAL(doResetAudio()), SLOT(onResetAudio()), Qt::QueuedConnection);
pEnumerator->RegisterEndpointNotificationCallback(this);
}
diff --git a/src/mumble/WebFetch.cpp b/src/mumble/WebFetch.cpp
index 1bd8c53a6..60339c247 100644
--- a/src/mumble/WebFetch.cpp
+++ b/src/mumble/WebFetch.cpp
@@ -6,18 +6,15 @@
#include "WebFetch.h"
#include "NetworkConfig.h"
+#include "Global.h"
#include <QtNetwork/QNetworkReply>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
WebFetch::WebFetch(QString service, QUrl url, QObject *obj, const char *slot)
: QObject(), qoObject(obj), cpSlot(slot), m_service(service) {
url.setScheme(QLatin1String("https"));
- if (!g.s.qsServicePrefix.isEmpty()) {
+ if (!Global::get().s.qsServicePrefix.isEmpty()) {
url.setHost(prefixedServiceHost());
} else {
url.setHost(serviceHost());
@@ -29,10 +26,10 @@ WebFetch::WebFetch(QString service, QUrl url, QObject *obj, const char *slot)
}
QString WebFetch::prefixedServiceHost() const {
- if (g.s.qsServicePrefix.isEmpty()) {
+ if (Global::get().s.qsServicePrefix.isEmpty()) {
return serviceHost();
}
- return QString::fromLatin1("%1-%2.mumble.info").arg(g.s.qsServicePrefix, m_service);
+ return QString::fromLatin1("%1-%2.mumble.info").arg(Global::get().s.qsServicePrefix, m_service);
}
QString WebFetch::serviceHost() const {
@@ -70,7 +67,7 @@ void WebFetch::finished() {
if (name == QLatin1String("Use-Service-Prefix")) {
QRegExp servicePrefixRegExp(QLatin1String("^[a-zA-Z]+$"));
if (servicePrefixRegExp.exactMatch(value)) {
- g.s.qsServicePrefix = value.toLower();
+ Global::get().s.qsServicePrefix = value.toLower();
}
}
}
@@ -79,7 +76,7 @@ void WebFetch::finished() {
emit fetched(a, url, headers);
deleteLater();
} else if (url.host() == prefixedServiceHost() && url.host() != serviceHost()) {
- // We have tried to fetch from a local service domain (e.g. de-update.mumble.info)
+ // We have tried to fetch from a local service domain (e.Global::get(). de-update.mumble.info)
// which has failed, so naturally we want to try the non-local one (update.mumble.info)
// as well as maybe that one will work.
// This of course only makes sense, if prefixedServiceHost() and serviceHost() are in fact
diff --git a/src/mumble/main.cpp b/src/mumble/main.cpp
index 0801d9b3b..12b3ddf6d 100644
--- a/src/mumble/main.cpp
+++ b/src/mumble/main.cpp
@@ -59,8 +59,6 @@
# include <shellapi.h>
#endif
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
#include "Global.h"
#ifdef BOOST_NO_EXCEPTIONS
@@ -95,14 +93,14 @@ bool positionIsOnScreen(QPoint point) {
QPoint getTalkingUIPosition() {
QPoint talkingUIPos = QPoint(0, 0);
- if (g.s.qpTalkingUI_Position != Settings::UNSPECIFIED_POSITION && positionIsOnScreen(g.s.qpTalkingUI_Position)) {
+ if (Global::get().s.qpTalkingUI_Position != Settings::UNSPECIFIED_POSITION && positionIsOnScreen(Global::get().s.qpTalkingUI_Position)) {
// Restore last position
- talkingUIPos = g.s.qpTalkingUI_Position;
+ talkingUIPos = Global::get().s.qpTalkingUI_Position;
} else {
// Place the TalkingUI next to the MainWindow by default
- const QPoint mainWindowPos = g.mw->pos();
+ const QPoint mainWindowPos = Global::get().mw->pos();
const int horizontalBuffer = 10;
- const QPoint defaultPos = QPoint(mainWindowPos.x() + g.mw->size().width() + horizontalBuffer, mainWindowPos.y());
+ const QPoint defaultPos = QPoint(mainWindowPos.x() + Global::get().mw->size().width() + horizontalBuffer, mainWindowPos.y());
if (positionIsOnScreen(defaultPos)) {
talkingUIPos = defaultPos;
@@ -111,8 +109,8 @@ QPoint getTalkingUIPosition() {
// We have to ask the TalkingUI to adjust its size in order to get a proper
// size from it (instead of a random default one).
- g.talkingUI->adjustSize();
- const QSize talkingUISize = g.talkingUI->size();
+ Global::get().talkingUI->adjustSize();
+ const QSize talkingUISize = Global::get().talkingUI->size();
// The screen should always be found at this point as we have chosen to pos to be on a screen
const QScreen *screen = screenAt(talkingUIPos);
@@ -217,8 +215,8 @@ int main(int argc, char **argv) {
qsrand(QDateTime::currentDateTime().toTime_t());
#endif
- g.le = QSharedPointer< LogEmitter >(new LogEmitter());
- g.c = new DeveloperConsole();
+ Global::get().le = QSharedPointer< LogEmitter >(new LogEmitter());
+ Global::get().c = new DeveloperConsole();
os_init();
@@ -319,10 +317,10 @@ int main(int argc, char **argv) {
bAllowMultiple = true;
} else if (args.at(i) == QLatin1String("-n") || args.at(i) == QLatin1String("--noidentity")) {
suppressIdentity = true;
- g.s.bSuppressIdentity = true;
+ Global::get().s.bSuppressIdentity = true;
} else if (args.at(i) == QLatin1String("-jn") || args.at(i) == QLatin1String("--jackname")) {
if (i + 1 < args.count()) {
- g.s.qsJackClientName = QString(args.at(i + 1));
+ Global::get().s.qsJackClientName = QString(args.at(i + 1));
customJackClientName = true;
++i;
} else {
@@ -331,7 +329,7 @@ int main(int argc, char **argv) {
}
} else if (args.at(i) == QLatin1String("--window-title-ext")) {
if (i + 1 < args.count()) {
- g.windowTitlePostfix = QString(args.at(i + 1));
+ Global::get().windowTitlePostfix = QString(args.at(i + 1));
++i;
} else {
qCritical("Missing argument for --window-title-ext!");
@@ -361,9 +359,9 @@ int main(int argc, char **argv) {
return 1;
}
} else if (args.at(i) == QLatin1String("--dump-input-streams")) {
- g.bDebugDumpInput = true;
+ Global::get().bDebugDumpInput = true;
} else if (args.at(i) == QLatin1String("--print-echocancel-queue")) {
- g.bDebugPrintQueue = true;
+ Global::get().bDebugPrintQueue = true;
} else {
if (!bRpcMode) {
QUrl u = QUrl::fromEncoded(args.at(i).toUtf8());
@@ -466,7 +464,7 @@ int main(int argc, char **argv) {
// modes enabled. This gives us exclusive access to the file.
// If another Mumble instance attempts to open the file, it will fail,
// and that instance will know to terminate itself.
- UserLockFile userLockFile(g.qdBasePath.filePath(QLatin1String("mumble.lock")));
+ UserLockFile userLockFile(Global::get().qdBasePath.filePath(QLatin1String("mumble.lock")));
if (!bAllowMultiple) {
if (!userLockFile.acquire()) {
qWarning("Another process has already acquired the lock file at '%s'. Terminating...",
@@ -477,7 +475,7 @@ int main(int argc, char **argv) {
#endif
// Load preferences
- g.s.load();
+ Global::get().s.load();
// Check whether we need to enable accessibility features
#ifdef Q_OS_WIN
@@ -488,7 +486,7 @@ int main(int argc, char **argv) {
SystemParametersInfo(SPI_GETHIGHCONTRAST, sizeof(HIGHCONTRAST), &hc, 0);
if (hc.dwFlags & HCF_HIGHCONTRASTON)
- g.s.bHighContrast = true;
+ Global::get().s.bHighContrast = true;
}
#endif
@@ -507,7 +505,7 @@ int main(int argc, char **argv) {
}
#endif
- const QString locale = g.s.qsLanguage.isEmpty() ? qsSystemLocale : g.s.qsLanguage;
+ const QString locale = Global::get().s.qsLanguage.isEmpty() ? qsSystemLocale : Global::get().s.qsLanguage;
qWarning("Locale is \"%s\" (System: \"%s\")", qPrintable(locale), qPrintable(qsSystemLocale));
QTranslator translator;
@@ -550,7 +548,7 @@ int main(int argc, char **argv) {
// Initialize proxy settings
NetworkConfig::SetupProxy();
- g.nam = new QNetworkAccessManager();
+ Global::get().nam = new QNetworkAccessManager();
#ifndef NO_CRASH_REPORT
CrashReporter *cr = new CrashReporter();
@@ -559,19 +557,19 @@ int main(int argc, char **argv) {
#endif
// Initialize database
- g.db = new Database(QLatin1String("main"));
+ Global::get().db = new Database(QLatin1String("main"));
#ifdef USE_ZEROCONF
// Initialize zeroconf
- g.zeroconf = new Zeroconf();
+ Global::get().zeroconf = new Zeroconf();
#endif
#ifdef USE_OVERLAY
- g.o = new Overlay();
- g.o->setActive(g.s.os.bEnable);
+ Global::get().o = new Overlay();
+ Global::get().o->setActive(Global::get().s.os.bEnable);
#endif
- g.lcd = new LCD();
+ Global::get().lcd = new LCD();
// Process any waiting events before initializing our MainWindow.
// The mumble:// URL support for Mac OS X happens through AppleEvents,
@@ -579,31 +577,31 @@ int main(int argc, char **argv) {
a.processEvents();
// Main Window
- g.mw = new MainWindow(nullptr);
- g.mw->show();
+ Global::get().mw = new MainWindow(nullptr);
+ Global::get().mw->show();
- g.talkingUI = new TalkingUI();
+ Global::get().talkingUI = new TalkingUI();
// Set TalkingUI's position
- g.talkingUI->move(getTalkingUIPosition());
+ Global::get().talkingUI->move(getTalkingUIPosition());
// By setting the TalkingUI's position **before** making it visible tends to more reliably include the
// window's frame to be included in the positioning calculation on X11 (at least using KDE Plasma)
- g.talkingUI->setVisible(g.s.bShowTalkingUI);
+ Global::get().talkingUI->setVisible(Global::get().s.bShowTalkingUI);
- QObject::connect(g.mw, &MainWindow::userAddedChannelListener, g.talkingUI, &TalkingUI::on_channelListenerAdded);
- QObject::connect(g.mw, &MainWindow::userRemovedChannelListener, g.talkingUI, &TalkingUI::on_channelListenerRemoved);
- QObject::connect(&ChannelListener::get(), &ChannelListener::localVolumeAdjustmentsChanged, g.talkingUI,
+ QObject::connect(Global::get().mw, &MainWindow::userAddedChannelListener, Global::get().talkingUI, &TalkingUI::on_channelListenerAdded);
+ QObject::connect(Global::get().mw, &MainWindow::userRemovedChannelListener, Global::get().talkingUI, &TalkingUI::on_channelListenerRemoved);
+ QObject::connect(&ChannelListener::get(), &ChannelListener::localVolumeAdjustmentsChanged, Global::get().talkingUI,
&TalkingUI::on_channelListenerLocalVolumeAdjustmentChanged);
- QObject::connect(g.mw, &MainWindow::serverSynchronized, g.talkingUI, &TalkingUI::on_serverSynchronized);
+ QObject::connect(Global::get().mw, &MainWindow::serverSynchronized, Global::get().talkingUI, &TalkingUI::on_serverSynchronized);
// Initialize logger
// Log::log() needs the MainWindow to already exist. Thus creating the Log instance
// before the MainWindow one, does not make sense. if you need logging before this
// point, use Log::logOrDefer()
- g.l = new Log();
- g.l->processDeferredLogs();
+ Global::get().l = new Log();
+ Global::get().l->processDeferredLogs();
#ifdef Q_OS_WIN
// Set mumble_mw_hwnd in os_win.cpp.
@@ -612,18 +610,18 @@ int main(int argc, char **argv) {
#endif
#ifdef USE_DBUS
- new MumbleDBus(g.mw);
- QDBusConnection::sessionBus().registerObject(QLatin1String("/"), g.mw);
+ new MumbleDBus(Global::get().mw);
+ QDBusConnection::sessionBus().registerObject(QLatin1String("/"), Global::get().mw);
QDBusConnection::sessionBus().registerService(QLatin1String("net.sourceforge.mumble.mumble"));
#endif
SocketRPC *srpc = new SocketRPC(QLatin1String("Mumble"));
- g.l->log(Log::Information, MainWindow::tr("Welcome to Mumble."));
+ Global::get().l->log(Log::Information, MainWindow::tr("Welcome to Mumble."));
// Plugins
- g.p = new Plugins(nullptr);
- g.p->rescanPlugins();
+ Global::get().p = new Plugins(nullptr);
+ Global::get().p->rescanPlugins();
Audio::start();
@@ -631,98 +629,98 @@ int main(int argc, char **argv) {
// Configuration updates
bool runaudiowizard = false;
- if (g.s.uiUpdateCounter == 0) {
+ if (Global::get().s.uiUpdateCounter == 0) {
// Previous version was an pre 1.2.3 release or this is the first run
runaudiowizard = true;
- } else if (g.s.uiUpdateCounter == 1) {
+ } else if (Global::get().s.uiUpdateCounter == 1) {
// Previous versions used old idle action style, convert it
- if (g.s.iIdleTime == 5 * 60) { // New default
- g.s.iaeIdleAction = Settings::Nothing;
+ if (Global::get().s.iIdleTime == 5 * 60) { // New default
+ Global::get().s.iaeIdleAction = Settings::Nothing;
} else {
- g.s.iIdleTime = 60 * qRound(g.s.iIdleTime / 60.); // Round to minutes
- g.s.iaeIdleAction = Settings::Deafen; // Old behavior
+ Global::get().s.iIdleTime = 60 * qRound(Global::get().s.iIdleTime / 60.); // Round to minutes
+ Global::get().s.iaeIdleAction = Settings::Deafen; // Old behavior
}
}
if (runaudiowizard) {
- AudioWizard *aw = new AudioWizard(g.mw);
+ AudioWizard *aw = new AudioWizard(Global::get().mw);
aw->exec();
delete aw;
}
- g.s.uiUpdateCounter = 2;
+ Global::get().s.uiUpdateCounter = 2;
- if (!CertWizard::validateCert(g.s.kpCertificate)) {
+ if (!CertWizard::validateCert(Global::get().s.kpCertificate)) {
QDir qd(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation));
QFile qf(qd.absoluteFilePath(QLatin1String("MumbleAutomaticCertificateBackup.p12")));
if (qf.open(QIODevice::ReadOnly | QIODevice::Unbuffered)) {
Settings::KeyPair kp = CertWizard::importCert(qf.readAll());
qf.close();
if (CertWizard::validateCert(kp))
- g.s.kpCertificate = kp;
+ Global::get().s.kpCertificate = kp;
}
- if (!CertWizard::validateCert(g.s.kpCertificate)) {
- CertWizard *cw = new CertWizard(g.mw);
+ if (!CertWizard::validateCert(Global::get().s.kpCertificate)) {
+ CertWizard *cw = new CertWizard(Global::get().mw);
cw->exec();
delete cw;
- if (!CertWizard::validateCert(g.s.kpCertificate)) {
- g.s.kpCertificate = CertWizard::generateNewCert();
+ if (!CertWizard::validateCert(Global::get().s.kpCertificate)) {
+ Global::get().s.kpCertificate = CertWizard::generateNewCert();
if (qf.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Unbuffered)) {
- qf.write(CertWizard::exportCert(g.s.kpCertificate));
+ qf.write(CertWizard::exportCert(Global::get().s.kpCertificate));
qf.close();
}
}
}
}
- if (QDateTime::currentDateTime().daysTo(g.s.kpCertificate.first.first().expiryDate()) < 14)
- g.l->log(Log::Warning,
+ if (QDateTime::currentDateTime().daysTo(Global::get().s.kpCertificate.first.first().expiryDate()) < 14)
+ Global::get().l->log(Log::Warning,
CertWizard::tr("<b>Certificate Expiry:</b> Your certificate is about to expire. You need to renew it, "
"or you will no longer be able to connect to servers you are registered on."));
#ifdef QT_NO_DEBUG
// Only perform the version-check for non-debug builds
- if (g.s.bUpdateCheck) {
+ if (Global::get().s.bUpdateCheck) {
// Use different settings for the version checks depending on whether this is a snapshot build
// or a normal release build
# ifndef SNAPSHOT_BUILD
// release build
- new VersionCheck(true, g.mw);
+ new VersionCheck(true, Global::get().mw);
# else
// snapshot build
- new VersionCheck(false, g.mw, true);
+ new VersionCheck(false, Global::get().mw, true);
# endif
}
#else
- g.mw->msgBox(MainWindow::tr("Skipping version check in debug mode."));
+ Global::get().mw->msgBox(MainWindow::tr("Skipping version check in debug mode."));
#endif
- if (g.s.bPluginCheck) {
- g.p->checkUpdates();
+ if (Global::get().s.bPluginCheck) {
+ Global::get().p->checkUpdates();
}
if (url.isValid()) {
OpenURLEvent *oue = new OpenURLEvent(url);
- qApp->postEvent(g.mw, oue);
+ qApp->postEvent(Global::get().mw, oue);
#ifdef Q_OS_MAC
} else if (!a.quLaunchURL.isEmpty()) {
OpenURLEvent *oue = new OpenURLEvent(a.quLaunchURL);
- qApp->postEvent(g.mw, oue);
+ qApp->postEvent(Global::get().mw, oue);
#endif
} else {
- g.mw->on_qaServerConnect_triggered(true);
+ Global::get().mw->on_qaServerConnect_triggered(true);
}
- if (!g.bQuit)
+ if (!Global::get().bQuit)
res = a.exec();
- g.s.save();
+ Global::get().s.save();
url.clear();
- ServerHandlerPtr sh = g.sh;
+ ServerHandlerPtr sh = Global::get().sh;
if (sh) {
if (sh->isRunning()) {
url = sh->getServerURL();
@@ -745,31 +743,31 @@ int main(int argc, char **argv) {
delete srpc;
- g.sh.reset();
+ Global::get().sh.reset();
while (sh && !sh.unique())
QThread::yieldCurrentThread();
sh.reset();
- delete g.talkingUI;
- delete g.mw;
+ delete Global::get().talkingUI;
+ delete Global::get().mw;
- delete g.nam;
- delete g.lcd;
+ delete Global::get().nam;
+ delete Global::get().lcd;
- delete g.db;
- delete g.p;
- delete g.l;
+ delete Global::get().db;
+ delete Global::get().p;
+ delete Global::get().l;
#ifdef USE_ZEROCONF
- delete g.zeroconf;
+ delete Global::get().zeroconf;
#endif
#ifdef USE_OVERLAY
- delete g.o;
+ delete Global::get().o;
#endif
- delete g.c;
- g.le.clear();
+ delete Global::get().c;
+ Global::get().le.clear();
DeferInit::run_destroyers();
@@ -811,7 +809,7 @@ int main(int argc, char **argv) {
if (suppressIdentity)
arguments << QLatin1String("--noidentity");
if (customJackClientName)
- arguments << QLatin1String("--jackname ") + g.s.qsJackClientName;
+ arguments << QLatin1String("--jackname ") + Global::get().s.qsJackClientName;
if (!url.isEmpty())
arguments << url.toString();
diff --git a/src/mumble/os_macx.mm b/src/mumble/os_macx.mm
index cab6c4c83..c33b7a6d0 100644
--- a/src/mumble/os_macx.mm
+++ b/src/mumble/os_macx.mm
@@ -9,12 +9,10 @@
# include "Overlay.h"
#endif
#include "Utils.h"
+#include "Global.h"
#include <CoreFoundation/CoreFoundation.h>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
char *os_lang = nullptr;
static FILE *fConsole = nullptr;
@@ -117,7 +115,7 @@ static void crashhandler_signals_restore() {
}
static void crashhandler_init() {
- QString dump = g.qdBasePath.filePath(QLatin1String("mumble.dmp"));
+ QString dump = Global::get().qdBasePath.filePath(QLatin1String("mumble.dmp"));
if (strncpy(crashhandler_fn, dump.toUtf8().data(), PATH_MAX)) {
crashhandler_signals_setup();
/* todo: Change the behavior of the Apple crash dialog? Maybe? */
@@ -140,7 +138,7 @@ void os_init() {
// Make a copy of the global LogEmitter, such that
// os_macx.mm doesn't have to consider the deletion
// of the Global object and its LogEmitter object.
- le = g.le;
+ le = Global::get().le;
if (home) {
size_t len = strlen(home) + strlen(logpath) + 1;
diff --git a/src/mumble/os_unix.cpp b/src/mumble/os_unix.cpp
index a8fadb3b1..4c86ad0df 100644
--- a/src/mumble/os_unix.cpp
+++ b/src/mumble/os_unix.cpp
@@ -49,7 +49,7 @@ void os_init() {
// Make a copy of the global LogEmitter, such that
// os_unix.cpp doesn't have to consider the deletion
// of the Global object and its LogEmitter object.
- le = g.le;
+ le = Global::get().le;
qInstallMessageHandler(mumbleMessageOutputWithContext);
}
diff --git a/src/mumble/os_win.cpp b/src/mumble/os_win.cpp
index a148b291a..317183bb9 100644
--- a/src/mumble/os_win.cpp
+++ b/src/mumble/os_win.cpp
@@ -12,6 +12,7 @@
#include "Version.h"
#include "win.h"
+#include "Global.h"
#include <cfloat>
#include <cmath>
@@ -29,10 +30,6 @@
#include <shlobj.h>
#include <shobjidl.h>
-// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
-// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
-#include "Global.h"
-
extern "C" {
void __cpuid(int a[4], int b);
void mumble_speex_init();
@@ -258,10 +255,10 @@ void os_init() {
// Make a copy of the global LogEmitter, such that
// os_win.cpp doesn't have to consider the deletion
// of the Global object and its LogEmitter object.
- le = g.le;
+ le = Global::get().le;
#ifdef QT_NO_DEBUG
- QString console = g.qdBasePath.filePath(QLatin1String("Console.txt"));
+ QString console = Global::get().qdBasePath.filePath(QLatin1String("Console.txt"));
fConsole = _wfsopen(console.toStdWString().c_str(), L"a+", _SH_DENYWR);
if (fConsole) {
@@ -290,7 +287,7 @@ void os_init() {
musComment.Buffer = wcComment;
musComment.BufferSize = static_cast< ULONG >(wcslen(wcComment) * sizeof(wchar_t));
- QString dump = g.qdBasePath.filePath(QLatin1String("mumble.dmp"));
+ QString dump = Global::get().qdBasePath.filePath(QLatin1String("mumble.dmp"));
QFileInfo fi(dump);
QDir::root().mkpath(fi.absolutePath());
@@ -300,7 +297,7 @@ void os_init() {
#endif
- g.qdBasePath.mkpath(QLatin1String("Snapshots"));
+ Global::get().qdBasePath.mkpath(QLatin1String("Snapshots"));
if (bIsWin7)
SetCurrentProcessExplicitAppUserModelID(L"net.sourceforge.mumble.Mumble");
}