diff options
author | Thorvald Natvig <slicer@users.sourceforge.net> | 2010-01-28 15:33:21 +0300 |
---|---|---|
committer | Thorvald Natvig <slicer@users.sourceforge.net> | 2010-01-28 15:33:21 +0300 |
commit | 7a2061c651b715359c0ff7e95cca3a01579da413 (patch) | |
tree | bc90acaee4ace011e1a8110944dad0c4577b43bf | |
parent | 7d8100275d9e530e869b1a47201089192e1af76b (diff) |
Propagate a few server config options to the client
-rw-r--r-- | src/Message.h | 3 | ||||
-rw-r--r-- | src/Mumble.proto | 9 | ||||
-rw-r--r-- | src/mumble/Messages.cpp | 3 | ||||
-rw-r--r-- | src/murmur/Messages.cpp | 13 | ||||
-rw-r--r-- | src/murmur/Server.cpp | 71 |
5 files changed, 83 insertions, 16 deletions
diff --git a/src/Message.h b/src/Message.h index 7980606ca..8b65fe3a1 100644 --- a/src/Message.h +++ b/src/Message.h @@ -58,7 +58,8 @@ MUMBLE_MH_MSG(PermissionQuery) \ MUMBLE_MH_MSG(CodecVersion) \ MUMBLE_MH_MSG(UserStats) \ - MUMBLE_MH_MSG(RequestBlob) + MUMBLE_MH_MSG(RequestBlob) \ + MUMBLE_MH_MSG(ServerConfig) class MessageHandler { public: diff --git a/src/Mumble.proto b/src/Mumble.proto index 071b5e992..62ccdccce 100644 --- a/src/Mumble.proto +++ b/src/Mumble.proto @@ -49,12 +49,19 @@ message Reject { optional string reason = 2; } +message ServerConfig { + optional uint32 max_bandwidth = 1; + optional string welcome_text = 2; + optional bool allow_html = 3; + optional uint32 message_length = 4; + optional uint32 image_message_length = 5; +} + message ServerSync { optional uint32 session = 1; optional uint32 max_bandwidth = 2; optional string welcome_text = 3; optional uint64 permissions = 4; - optional bool allow_html = 5 [default = true]; } message ChannelRemove { diff --git a/src/mumble/Messages.cpp b/src/mumble/Messages.cpp index e0610691d..5d616109a 100644 --- a/src/mumble/Messages.cpp +++ b/src/mumble/Messages.cpp @@ -683,3 +683,6 @@ void MainWindow::msgUserStats(const MumbleProto::UserStats &msg) { void MainWindow::msgRequestBlob(const MumbleProto::RequestBlob &) { } + +void MainWindow::msgServerConfig(const MumbleProto::ServerConfig &) { +} diff --git a/src/murmur/Messages.cpp b/src/murmur/Messages.cpp index b54d6f07d..e5966bf3d 100644 --- a/src/murmur/Messages.cpp +++ b/src/murmur/Messages.cpp @@ -345,8 +345,7 @@ void Server::msgAuthenticate(ServerUser *uSource, MumbleProto::Authenticate &msg if (! qsWelcomeText.isEmpty()) mpss.set_welcome_text(u8(qsWelcomeText)); mpss.set_max_bandwidth(iMaxBandwidth); - mpss.set_allow_html(bAllowHTML); - + if (uSource->iId == 0) { mpss.set_permissions(ChanACL::All); } else { @@ -356,6 +355,13 @@ void Server::msgAuthenticate(ServerUser *uSource, MumbleProto::Authenticate &msg } sendMessage(uSource, mpss); + + MumbleProto::ServerConfig mpsc; + mpsc.set_allow_html(bAllowHTML); + mpsc.set_message_length(iMaxTextMessageLength); + mpsc.set_image_message_length(iMaxImageMessageLength); + sendMessage(uSource, mpsc); + log(uSource, "Authenticated"); emit userConnected(uSource); @@ -1509,3 +1515,6 @@ void Server::msgRequestBlob(ServerUser *uSource, MumbleProto::RequestBlob &msg) } } } + +void Server::msgServerConfig(ServerUser *, MumbleProto::ServerConfig &) { +} diff --git a/src/murmur/Server.cpp b/src/murmur/Server.cpp index 72c800c13..e886dc6e3 100644 --- a/src/murmur/Server.cpp +++ b/src/murmur/Server.cpp @@ -368,24 +368,71 @@ void Server::setLiveConf(const QString &key, const QString &value) { qsPassword = !v.isNull() ? v : Meta::mp.qsPassword; else if (key == "timeout") iTimeout = i ? i : Meta::mp.iTimeout; - else if (key == "bandwidth") - iMaxBandwidth = i ? i : Meta::mp.iMaxBandwidth; + else if (key == "bandwidth") { + int length = i ? i : Meta::mp.iMaxBandwidth; + if (length != iMaxBandwidth) { + iMaxBandwidth = length; + MumbleProto::ServerConfig mpsc; + mpsc.set_max_bandwidth(length); + sendAll(mpsc); + } + } else if (key == "users") iMaxUsers = i ? i : Meta::mp.iMaxUsers; else if (key == "usersperchannel") iMaxUsersPerChannel = i ? i : Meta::mp.iMaxUsersPerChannel; - else if (key == "textmessagelength") - iMaxTextMessageLength = i ? i : Meta::mp.iMaxTextMessageLength; - else if (key == "imagemessagelength") - iMaxImageMessageLength = i ? i : Meta::mp.iMaxImageMessageLength; - else if (key == "allowhtml") - bAllowHTML = !v.isNull() ? QVariant(v).toBool() : Meta::mp.bAllowHTML; + else if (key == "textmessagelength") { + int length = i ? i : Meta::mp.iMaxTextMessageLength; + if (length != iMaxTextMessageLength) { + iMaxTextMessageLength = length; + MumbleProto::ServerConfig mpsc; + mpsc.set_message_length(length); + sendAll(mpsc); + } + } + else if (key == "imagemessagelength") { + int length = i ? i : Meta::mp.iMaxImageMessageLength; + if (length != iMaxImageMessageLength) { + iMaxImageMessageLength = length; + MumbleProto::ServerConfig mpsc; + mpsc.set_image_message_length(length); + sendAll(mpsc); + } + } + else if (key == "allowhtml") { + bool allow = !v.isNull() ? QVariant(v).toBool() : Meta::mp.bAllowHTML; + if (allow != bAllowHTML) { + bAllowHTML = allow; + MumbleProto::ServerConfig mpsc; + mpsc.set_allow_html(bAllowHTML); + sendAll(mpsc); + } + } else if (key == "defaultchannel") iDefaultChan = i ? i : Meta::mp.iDefaultChan; - else if (key == "welcometext") - qsWelcomeText = !v.isNull() ? v : Meta::mp.qsWelcomeText; - else if (key == "registername") - qsRegName = !v.isNull() ? v : Meta::mp.qsRegName; + else if (key == "welcometext") { + QString text = !v.isNull() ? v : Meta::mp.qsWelcomeText; + if (text != qsWelcomeText) { + qsWelcomeText = text; + if (! qsWelcomeText.isEmpty()) { + MumbleProto::ServerConfig mpsc; + mpsc.set_welcome_text(u8(qsWelcomeText)); + sendAll(mpsc); + } + } + } + else if (key == "registername") { + QString text = !v.isNull() ? v : Meta::mp.qsRegName; + if (text != qsRegName) { + qsRegName = text; + if (! qsRegName.isEmpty()) { + MumbleProto::ChannelState mpcs; + mpcs.set_channel_id(0); + mpcs.set_name(u8(qsRegName)); + sendAll(mpcs); + } + } + } else if (key == "registerpassword") qsRegPassword = !v.isNull() ? v : Meta::mp.qsRegPassword; else if (key == "registerhostname") |