1 // Copyright 2005-2019 The Mumble Developers. All rights reserved. 2 // Use of this source code is governed by a BSD-style license 3 // that can be found in the LICENSE file at the root of the 4 // Mumble source tree or at <https://www.mumble.info/LICENSE>. 5 6 #ifndef MUMBLE_MUMBLE_SETTINGS_H_ 7 #define MUMBLE_MUMBLE_SETTINGS_H_ 8 9 #include <QtCore/QVariant> 10 #include <QtCore/QList> 11 #include <QtCore/QPair> 12 #include <QtCore/QRectF> 13 #include <QtCore/QSettings> 14 #include <QtCore/QStringList> 15 #include <QtGui/QColor> 16 #include <QtGui/QFont> 17 #include <QtNetwork/QSslCertificate> 18 #include <QtNetwork/QSslKey> 19 20 // Global helper classes to spread variables around across threads 21 // especially helpful to initialize things like the stored 22 // preference for audio transmission, since the GUI elements 23 // will be created long before the AudioInput object, and the 24 // latter lives in a separate thread and so cannot touch the 25 // GUI. 26 27 struct Shortcut { 28 int iIndex; 29 QList<QVariant> qlButtons; 30 QVariant qvData; 31 bool bSuppress; 32 bool operator <(const Shortcut &) const; 33 bool isServerSpecific() const; 34 bool operator ==(const Shortcut &) const; 35 }; 36 37 struct ShortcutTarget { 38 bool bUsers; 39 QStringList qlUsers; 40 QList<unsigned int> qlSessions; 41 int iChannel; 42 QString qsGroup; 43 bool bLinks; 44 bool bChildren; 45 bool bForceCenter; 46 ShortcutTarget(); 47 bool isServerSpecific() const; 48 bool operator <(const ShortcutTarget &) const; 49 bool operator ==(const ShortcutTarget &) const; 50 }; 51 52 quint32 qHash(const ShortcutTarget &); 53 quint32 qHash(const QList<ShortcutTarget> &); 54 55 QDataStream &operator<<(QDataStream &, const ShortcutTarget &); 56 QDataStream &operator>>(QDataStream &, ShortcutTarget &); 57 Q_DECLARE_METATYPE(ShortcutTarget) 58 59 struct OverlaySettings { 60 enum OverlayPresets { AvatarAndName, LargeSquareAvatar }; 61 62 enum OverlayShow { Talking, Active, HomeChannel, LinkedChannels }; 63 64 enum OverlaySort { Alphabetical, LastStateChange }; 65 66 enum OverlayExclusionMode { LauncherFilterExclusionMode, WhitelistExclusionMode, BlacklistExclusionMode }; 67 68 bool bEnable; 69 70 QString qsStyle; 71 72 OverlayShow osShow; 73 bool bAlwaysSelf; 74 int uiActiveTime; // Time in seconds for a user to stay active after talking 75 OverlaySort osSort; 76 77 float fX; 78 float fY; 79 80 qreal fZoom; 81 unsigned int uiColumns; 82 83 QColor qcUserName[4]; 84 QFont qfUserName; 85 86 QColor qcChannel; 87 QFont qfChannel; 88 89 QColor qcFps; 90 QFont qfFps; 91 92 qreal fBoxPad; 93 qreal fBoxPenWidth; 94 QColor qcBoxPen; 95 QColor qcBoxFill; 96 97 bool bUserName; 98 bool bChannel; 99 bool bMutedDeafened; 100 bool bAvatar; 101 bool bBox; 102 bool bFps; 103 bool bTime; 104 105 qreal fUserName; 106 qreal fChannel; 107 qreal fMutedDeafened; 108 qreal fAvatar; 109 qreal fUser[4]; 110 qreal fFps; 111 112 QRectF qrfUserName; 113 QRectF qrfChannel; 114 QRectF qrfMutedDeafened; 115 QRectF qrfAvatar; 116 QRectF qrfFps; 117 QRectF qrfTime; 118 119 Qt::Alignment qaUserName; 120 Qt::Alignment qaChannel; 121 Qt::Alignment qaMutedDeafened; 122 Qt::Alignment qaAvatar; 123 124 OverlayExclusionMode oemOverlayExcludeMode; 125 QStringList qslLaunchers; 126 QStringList qslLaunchersExclude; 127 QStringList qslWhitelist; 128 QStringList qslWhitelistExclude; 129 QStringList qslPaths; 130 QStringList qslPathsExclude; 131 QStringList qslBlacklist; 132 QStringList qslBlacklistExclude; 133 134 OverlaySettings(); 135 void setPreset(const OverlayPresets preset = AvatarAndName); 136 137 void load(); 138 void load(QSettings*); 139 void save(); 140 void save(QSettings*); 141 }; 142 143 struct Settings { 144 enum AudioTransmit { Continuous, VAD, PushToTalk }; 145 enum VADSource { Amplitude, SignalToNoise }; 146 enum LoopMode { None, Local, Server }; 147 enum ChannelExpand { NoChannels, ChannelsWithUsers, AllChannels }; 148 enum ChannelDrag { Ask, DoNothing, Move }; 149 enum ServerShow { ShowPopulated, ShowReachable, ShowAll }; 150 enum TalkState { Passive, Talking, Whispering, Shouting }; 151 enum IdleAction { Nothing, Deafen, Mute }; 152 typedef QPair<QList<QSslCertificate>, QSslKey> KeyPair; 153 154 AudioTransmit atTransmit; 155 quint64 uiDoublePush; 156 quint64 pttHold; 157 158 /// Removed. This was previously used to configure whether the Mumble 159 /// ConfigDialog should show advanced options or not. 160 bool bExpert; 161 162 bool bTxAudioCue; 163 static const QString cqsDefaultPushClickOn; 164 static const QString cqsDefaultPushClickOff; 165 QString qsTxAudioCueOn; 166 QString qsTxAudioCueOff; 167 168 bool bTransmitPosition; 169 bool bMute, bDeaf; 170 bool bTTS; 171 bool bUserTop; 172 bool bWhisperFriends; 173 bool bTTSMessageReadBack; 174 int iTTSVolume, iTTSThreshold; 175 /// The Text-to-Speech language to use. This setting overrides 176 /// the default language for the Text-to-Speech engine, which 177 /// is usually inferred from the current locale. 178 /// 179 /// The language is expected to be in BCP47 form. 180 /// 181 /// The setting is currently only supported by the speech-dispatcher 182 ///backend. 183 QString qsTTSLanguage; 184 int iQuality, iMinLoudness, iVoiceHold, iJitterBufferSize; 185 int iNoiseSuppress; 186 bool bDenoise; 187 quint64 uiAudioInputChannelMask; 188 189 // Idle auto actions 190 unsigned int iIdleTime; 191 IdleAction iaeIdleAction; 192 bool bUndoIdleActionUponActivity; 193 194 VADSource vsVAD; 195 float fVADmin, fVADmax; 196 int iFramesPerPacket; 197 QString qsAudioInput, qsAudioOutput; 198 float fVolume; 199 float fOtherVolume; 200 bool bAttenuateOthersOnTalk; 201 bool bAttenuateOthers; 202 bool bAttenuateUsersOnPrioritySpeak; 203 bool bOnlyAttenuateSameOutput; 204 bool bAttenuateLoopbacks; 205 int iOutputDelay; 206 bool bUseOpusMusicEncoding; 207 208 QString qsALSAInput, qsALSAOutput; 209 QString qsPulseAudioInput, qsPulseAudioOutput; 210 QString qsJackClientName, qsJackAudioOutput; 211 bool bJackStartServer, bJackAutoConnect; 212 QString qsOSSInput, qsOSSOutput; 213 int iPortAudioInput, iPortAudioOutput; 214 215 bool bASIOEnable; 216 QString qsASIOclass; 217 QList<QVariant> qlASIOmic; 218 QList<QVariant> qlASIOspeaker; 219 220 QString qsCoreAudioInput, qsCoreAudioOutput; 221 222 QString qsWASAPIInput, qsWASAPIOutput; 223 /// qsWASAPIRole is configured via 'wasapi/role'. 224 /// It is a string explaining Mumble's purpose for opening 225 /// the audio device. This can be used to force Windows 226 /// to not treat Mumble as a communications program 227 /// (the default). 228 /// 229 /// The default is "communications". When this is set, 230 /// Windows treats Mumble as a telephony app, including 231 /// potential audio ducking. 232 /// 233 /// Other values include: 234 /// 235 /// "console", which should be used for games, system 236 /// notification sounds, and voice commands. 237 /// 238 /// "multimedia", which should be used for music, movies, 239 /// narration, and live music recording. 240 /// 241 /// This is practically a direct mapping of the ERole enum 242 /// from Windows: https://msdn.microsoft.com/en-us/library/windows/desktop/dd370842 243 QString qsWASAPIRole; 244 245 QByteArray qbaDXInput, qbaDXOutput; 246 247 bool bExclusiveInput, bExclusiveOutput; 248 bool bEcho; 249 bool bEchoMulti; 250 bool bPositionalAudio; 251 bool bPositionalHeadphone; 252 float fAudioMinDistance, fAudioMaxDistance, fAudioMaxDistVolume, fAudioBloom; 253 QMap<QString, bool> qmPositionalAudioPlugins; 254 255 OverlaySettings os; 256 257 int iOverlayWinHelperRestartCooldownMsec; 258 bool bOverlayWinHelperX86Enable; 259 bool bOverlayWinHelperX64Enable; 260 261 int iLCDUserViewMinColWidth; 262 int iLCDUserViewSplitterWidth; 263 QMap<QString, bool> qmLCDDevices; 264 265 bool bShortcutEnable; 266 bool bSuppressMacEventTapWarning; 267 bool bEnableEvdev; 268 bool bEnableXInput2; 269 bool bEnableGKey; 270 bool bEnableXboxInput; 271 bool bEnableWinHooks; 272 /// Enable verbose logging in GlobalShortcutWin's DirectInput backend. 273 bool bDirectInputVerboseLogging; 274 /// Enable use of UIAccess (Windows's UI automation feature). This allows 275 /// Mumble greater access to global shortcuts. 276 bool bEnableUIAccess; 277 QList<Shortcut> qlShortcuts; 278 279 enum MessageLog { LogNone = 0x00, LogConsole = 0x01, LogTTS = 0x02, LogBalloon = 0x04, LogSoundfile = 0x08, LogHighlight = 0x10 }; 280 int iMaxLogBlocks; 281 QMap<int, QString> qmMessageSounds; 282 QMap<int, quint32> qmMessages; 283 284 QString qsLanguage; 285 286 /// Name of the theme to use. @see Themes 287 QString themeName; 288 /// Name of the style to use from theme. @see Themes 289 QString themeStyleName; 290 291 QByteArray qbaMainWindowGeometry, qbaMainWindowState, qbaMinimalViewGeometry, qbaMinimalViewState, qbaSplitterState, qbaHeaderState; 292 QByteArray qbaConfigGeometry; 293 enum WindowLayout { LayoutClassic, LayoutStacked, LayoutHybrid, LayoutCustom }; 294 WindowLayout wlWindowLayout; 295 ChannelExpand ceExpand; 296 ChannelDrag ceChannelDrag; 297 ChannelDrag ceUserDrag; 298 bool bMinimalView; 299 bool bHideFrame; 300 enum AlwaysOnTopBehaviour { OnTopNever, OnTopAlways, OnTopInMinimal, OnTopInNormal }; 301 AlwaysOnTopBehaviour aotbAlwaysOnTop; 302 bool bAskOnQuit; 303 bool bEnableDeveloperMenu; 304 bool bLockLayout; 305 bool bHideInTray; 306 bool bStateInTray; 307 bool bUsage; 308 bool bShowUserCount; 309 bool bChatBarUseSelection; 310 bool bFilterHidesEmptyChannels; 311 bool bFilterActive; 312 QByteArray qbaConnectDialogHeader, qbaConnectDialogGeometry; 313 bool bShowContextMenuInMenuBar; 314 315 QString qsUsername; 316 QString qsLastServer; 317 ServerShow ssFilter; 318 319 QString qsImagePath; 320 321 bool bUpdateCheck; 322 bool bPluginCheck; 323 324 // PTT Button window 325 bool bShowPTTButtonWindow; 326 QByteArray qbaPTTButtonWindowGeometry; 327 328 // Network settings 329 enum ProxyType { NoProxy, HttpProxy, Socks5Proxy }; 330 bool bTCPCompat; 331 bool bReconnect; 332 bool bAutoConnect; 333 bool bQoS; 334 ProxyType ptProxyType; 335 QString qsProxyHost, qsProxyUsername, qsProxyPassword; 336 unsigned short usProxyPort; 337 338 /// The ping interval in milliseconds. The Mumble client 339 /// will regularly send TCP and UDP pings to the remote 340 /// server. This setting specifies the time (in milliseconds) 341 /// between each ping message. 342 int iPingIntervalMsec; 343 344 /// The connection timeout duration in milliseconds. 345 /// If a connection is not fully established to the 346 /// server within this duration, the client will 347 /// forcefully disconnect. 348 int iConnectionTimeoutDurationMsec; 349 350 /// bUdpForceTcpAddr forces Mumble to bind its UDP 351 /// socket to the same address as its TCP 352 /// connection is using. 353 bool bUdpForceTcpAddr; 354 355 /// iMaxInFlightTCPPings specifies the maximum 356 /// number of ping messages that the client has 357 /// sent, but not yet recieved a response for 358 /// from the server. This value is checked when 359 /// the client sends its next ping message. If 360 /// the maximum is reached, the connection will 361 /// be closed. 362 /// If this setting is assigned a value of 0 or 363 /// a negative number, the TCP ping check is 364 /// disabled. 365 int iMaxInFlightTCPPings; 366 367 /// The service prefix that the WebFetch class will use 368 /// when it constructs its fully-qualified URL. If this 369 /// is empty, no prefix is used. 370 /// 371 /// When the WebFetch class receives a HTTP response which 372 /// includes the header "Use-Service-Prefix", this setting 373 /// is updated to reflect the received service prefix. 374 /// 375 /// For more information, see the documentation for WebFetch::fetch(). 376 QString qsServicePrefix; 377 378 // Network settings - SSL 379 QString qsSslCiphers; 380 381 // Privacy settings 382 bool bHideOS; 383 384 int iMaxImageWidth; 385 int iMaxImageHeight; 386 KeyPair kpCertificate; 387 bool bSuppressIdentity; 388 389 bool bShowTransmitModeComboBox; 390 391 // Accessibility 392 bool bHighContrast; 393 394 // Recording 395 QString qsRecordingPath; 396 QString qsRecordingFile; 397 enum RecordingMode { RecordingMixdown, RecordingMultichannel }; 398 RecordingMode rmRecordingMode; 399 int iRecordingFormat; 400 401 // Special configuration options not exposed to UI 402 403 /// Codec kill-switch 404 bool bDisableCELT; 405 406 /// Disables the "Public Internet" section in the connect dialog if set. 407 bool disablePublicList; 408 409 /// Removes the add and edit options in the connect dialog if set. 410 bool disableConnectDialogEditing; 411 412 // Config updates 413 unsigned int uiUpdateCounter; 414 415 // Nonsaved 416 LoopMode lmLoopMode; 417 float dPacketLoss; 418 float dMaxPacketDelay; 419 /// If true settings in this structure require a client restart to apply fully 420 bool requireRestartToApply; 421 422 bool doEcho() const; 423 bool doPositionalAudio() const; 424 425 Settings(); 426 void load(); 427 void load(QSettings*); 428 void save(); 429 }; 430 431 #endif 432