mirror of
https://github.com/mumble-voip/mumble.git
synced 2025-10-26 11:19:16 +00:00
Allow creating channel with a set maximum number of users
Fixes mumble-voip/mumble#1913
This commit is contained in:
parent
b0c9521e4b
commit
c0879e57bf
@ -63,8 +63,14 @@ ACLEditor::ACLEditor(int channelparentid, QWidget *p) : QDialog(p) {
|
||||
qleChannelPassword->hide();
|
||||
qlChannelPassword->hide();
|
||||
|
||||
qlChannelMaxUsers->hide();
|
||||
qsbChannelMaxUsers->hide();
|
||||
if (g.sh->uiVersion >= 0x010300) {
|
||||
qsbChannelMaxUsers->setRange(0, INT_MAX);
|
||||
qsbChannelMaxUsers->setValue(0);
|
||||
qsbChannelMaxUsers->setSpecialValueText(tr("Default server value"));
|
||||
} else {
|
||||
qlChannelMaxUsers->hide();
|
||||
qsbChannelMaxUsers->hide();
|
||||
}
|
||||
|
||||
qlChannelID->hide();
|
||||
|
||||
@ -272,7 +278,7 @@ void ACLEditor::accept() {
|
||||
|
||||
// Update channel state
|
||||
if (bAddChannelMode) {
|
||||
g.sh->createChannel(iChannel, qleChannelName->text(), rteChannelDescription->text(), qsbChannelPosition->value(), qcbChannelTemporary->isChecked());
|
||||
g.sh->createChannel(iChannel, qleChannelName->text(), rteChannelDescription->text(), qsbChannelPosition->value(), qcbChannelTemporary->isChecked(), qsbChannelMaxUsers->value());
|
||||
} else {
|
||||
bool needs_update = false;
|
||||
|
||||
|
||||
@ -680,13 +680,14 @@ void ServerHandler::joinChannel(unsigned int uiSession, unsigned int channel) {
|
||||
sendMessage(mpus);
|
||||
}
|
||||
|
||||
void ServerHandler::createChannel(unsigned int parent_id, const QString &name, const QString &description, unsigned int position, bool temporary) {
|
||||
void ServerHandler::createChannel(unsigned int parent_id, const QString &name, const QString &description, unsigned int position, bool temporary, unsigned int maxUsers) {
|
||||
MumbleProto::ChannelState mpcs;
|
||||
mpcs.set_parent(parent_id);
|
||||
mpcs.set_name(u8(name));
|
||||
mpcs.set_description(u8(description));
|
||||
mpcs.set_position(position);
|
||||
mpcs.set_temporary(temporary);
|
||||
mpcs.set_max_users(maxUsers);
|
||||
sendMessage(mpcs);
|
||||
}
|
||||
|
||||
|
||||
@ -129,7 +129,7 @@ class ServerHandler : public QThread {
|
||||
|
||||
void requestUserStats(unsigned int uiSession, bool statsOnly);
|
||||
void joinChannel(unsigned int uiSession, unsigned int channel);
|
||||
void createChannel(unsigned int parent_id, const QString &name, const QString &description, unsigned int position, bool temporary);
|
||||
void createChannel(unsigned int parent_id, const QString &name, const QString &description, unsigned int position, bool temporary, unsigned int maxUsers);
|
||||
void requestBanList();
|
||||
void requestUserList();
|
||||
void requestACL(unsigned int channel);
|
||||
|
||||
@ -906,7 +906,7 @@ void Server::msgChannelState(ServerUser *uSource, MumbleProto::ChannelState &msg
|
||||
return;
|
||||
}
|
||||
|
||||
c = addChannel(p, qsName, msg.temporary(), msg.position());
|
||||
c = addChannel(p, qsName, msg.temporary(), msg.position(), msg.max_users());
|
||||
hashAssign(c->qsDesc, c->qbaDescHash, qsDesc);
|
||||
|
||||
if (uSource->iId >= 0) {
|
||||
|
||||
@ -336,7 +336,7 @@ class Server : public QThread {
|
||||
// Database / DBus functions. Implementation in ServerDB.cpp
|
||||
void initialize();
|
||||
int authenticate(QString &name, const QString &pw, int sessionId = 0, const QStringList &emails = QStringList(), const QString &certhash = QString(), bool bStrongCert = false, const QList<QSslCertificate> & = QList<QSslCertificate>());
|
||||
Channel *addChannel(Channel *c, const QString &name, bool temporary = false, int position = 0);
|
||||
Channel *addChannel(Channel *c, const QString &name, bool temporary = false, int position = 0, unsigned int maxUsers = 0);
|
||||
void removeChannelDB(const Channel *c);
|
||||
void readChannels(Channel *p = NULL);
|
||||
void readLinks();
|
||||
|
||||
@ -1311,7 +1311,7 @@ void Server::removeLink(Channel *c, Channel *l) {
|
||||
SQLEXEC();
|
||||
}
|
||||
|
||||
Channel *Server::addChannel(Channel *p, const QString &name, bool temporary, int position) {
|
||||
Channel *Server::addChannel(Channel *p, const QString &name, bool temporary, int position, unsigned int maxUsers) {
|
||||
TransactionHolder th;
|
||||
|
||||
QSqlQuery &query = *th.qsqQuery;
|
||||
@ -1348,11 +1348,19 @@ Channel *Server::addChannel(Channel *p, const QString &name, bool temporary, int
|
||||
query.addBindValue(ServerDB::Channel_Position);
|
||||
query.addBindValue(QVariant(position).toString());
|
||||
SQLEXEC();
|
||||
|
||||
// Update channel maximum users
|
||||
query.addBindValue(iServerNum);
|
||||
query.addBindValue(id);
|
||||
query.addBindValue(ServerDB::Channel_Max_Users);
|
||||
query.addBindValue(QVariant(maxUsers).toString());
|
||||
SQLEXEC();
|
||||
}
|
||||
|
||||
Channel *c = new Channel(id, name, p);
|
||||
c->bTemporary = temporary;
|
||||
c->iPosition = position;
|
||||
c->uiMaxUsers = maxUsers;
|
||||
qhChannels.insert(id, c);
|
||||
return c;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user