mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 00:24:47 -07:00
added admin tab; server status message update
This commit is contained in:
parent
714a0eee50
commit
bd9e142d1d
20 changed files with 242 additions and 65 deletions
|
|
@ -192,15 +192,24 @@ ServerInfo_User *Servatrice::getUserData(const QString &name)
|
|||
} else
|
||||
return new ServerInfo_User(name, ServerInfo_User::IsUser);
|
||||
}
|
||||
|
||||
#include <QDebug>
|
||||
void Servatrice::updateLoginMessage()
|
||||
{
|
||||
checkSql();
|
||||
QSqlQuery query;
|
||||
query.prepare("select message from " + dbPrefix + "_servermessages order by timest desc limit 1");
|
||||
if (execSqlQuery(query))
|
||||
if (query.next())
|
||||
if (query.next()) {
|
||||
loginMessage = query.value(0).toString();
|
||||
|
||||
Event_ServerMessage *event = new Event_ServerMessage(loginMessage);
|
||||
QMapIterator<QString, Server_ProtocolHandler *> usersIterator(users);
|
||||
while (usersIterator.hasNext()) {
|
||||
usersIterator.next().value()->sendProtocolItem(event, false);
|
||||
qDebug() << "sent message to" << usersIterator.value()->getUserInfo()->getName();
|
||||
}
|
||||
delete event;
|
||||
}
|
||||
}
|
||||
|
||||
void Servatrice::statusUpdate()
|
||||
|
|
|
|||
|
|
@ -323,3 +323,12 @@ ResponseCode ServerSocketInterface::cmdDeckDownload(Command_DeckDownload *cmd, C
|
|||
cont->setResponse(new Response_DeckDownload(cont->getCmdId(), RespOk, deck));
|
||||
return RespNothing;
|
||||
}
|
||||
|
||||
// ADMIN FUNCTIONS.
|
||||
// Permission is checked by the calling function.
|
||||
|
||||
ResponseCode ServerSocketInterface::cmdUpdateServerMessage(Command_UpdateServerMessage *cmd, CommandContainer *cont)
|
||||
{
|
||||
servatrice->updateLoginMessage();
|
||||
return RespOk;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ private:
|
|||
ResponseCode cmdDeckUpload(Command_DeckUpload *cmd, CommandContainer *cont);
|
||||
DeckList *getDeckFromDatabase(int deckId);
|
||||
ResponseCode cmdDeckDownload(Command_DeckDownload *cmd, CommandContainer *cont);
|
||||
ResponseCode cmdUpdateServerMessage(Command_UpdateServerMessage *cmd, CommandContainer *cont);
|
||||
public:
|
||||
ServerSocketInterface(Servatrice *_server, QTcpSocket *_socket, QObject *parent = 0);
|
||||
~ServerSocketInterface();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue