don't pm people ignoring you
This commit is contained in:
parent
0afdbc7222
commit
1bee788210
9 changed files with 36 additions and 5 deletions
|
@ -45,10 +45,18 @@ void TabMessage::sendMessage()
|
||||||
if (sayEdit->text().isEmpty() || !userOnline)
|
if (sayEdit->text().isEmpty() || !userOnline)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
client->sendCommand(new Command_Message(userName, sayEdit->text()));
|
Command_Message *cmd = new Command_Message(userName, sayEdit->text());
|
||||||
|
connect(cmd, SIGNAL(finished(ProtocolResponse *)), this, SLOT(messageSent(ProtocolResponse *)));
|
||||||
|
client->sendCommand(cmd);
|
||||||
sayEdit->clear();
|
sayEdit->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabMessage::messageSent(ProtocolResponse *response)
|
||||||
|
{
|
||||||
|
if (response->getResponseCode() == RespInIgnoreList)
|
||||||
|
chatView->appendMessage(QString(), tr("This user is ignoring you."));
|
||||||
|
}
|
||||||
|
|
||||||
void TabMessage::actLeave()
|
void TabMessage::actLeave()
|
||||||
{
|
{
|
||||||
deleteLater();
|
deleteLater();
|
||||||
|
|
|
@ -7,6 +7,7 @@ class AbstractClient;
|
||||||
class ChatView;
|
class ChatView;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class Event_Message;
|
class Event_Message;
|
||||||
|
class ProtocolResponse;
|
||||||
|
|
||||||
class TabMessage : public Tab {
|
class TabMessage : public Tab {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -24,6 +25,7 @@ signals:
|
||||||
private slots:
|
private slots:
|
||||||
void sendMessage();
|
void sendMessage();
|
||||||
void actLeave();
|
void actLeave();
|
||||||
|
void messageSent(ProtocolResponse *response);
|
||||||
public:
|
public:
|
||||||
TabMessage(TabSupervisor *_tabSupervisor, AbstractClient *_client, const QString &_ownName, const QString &_userName);
|
TabMessage(TabSupervisor *_tabSupervisor, AbstractClient *_client, const QString &_ownName, const QString &_userName);
|
||||||
~TabMessage();
|
~TabMessage();
|
||||||
|
|
|
@ -80,7 +80,7 @@ void GameSelector::checkResponse(ResponseCode response)
|
||||||
case RespNameNotFound: QMessageBox::critical(this, tr("Error"), tr("The game does not exist any more.")); break;
|
case RespNameNotFound: QMessageBox::critical(this, tr("Error"), tr("The game does not exist any more.")); break;
|
||||||
case RespUserLevelTooLow: QMessageBox::critical(this, tr("Error"), tr("This game is only open to registered users.")); break;
|
case RespUserLevelTooLow: QMessageBox::critical(this, tr("Error"), tr("This game is only open to registered users.")); break;
|
||||||
case RespOnlyBuddies: QMessageBox::critical(this, tr("Error"), tr("This game is only open to its creator's buddies.")); break;
|
case RespOnlyBuddies: QMessageBox::critical(this, tr("Error"), tr("This game is only open to its creator's buddies.")); break;
|
||||||
case RespOnIgnoreList: QMessageBox::critical(this, tr("Error"), tr("You are being ignored by the creator of this game.")); break;
|
case RespInIgnoreList: QMessageBox::critical(this, tr("Error"), tr("You are being ignored by the creator of this game.")); break;
|
||||||
default: ;
|
default: ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,7 +266,7 @@ void ProtocolResponse::initializeHash()
|
||||||
responseHash.insert("spectators_not_allowed", RespSpectatorsNotAllowed);
|
responseHash.insert("spectators_not_allowed", RespSpectatorsNotAllowed);
|
||||||
responseHash.insert("only_buddies", RespOnlyBuddies);
|
responseHash.insert("only_buddies", RespOnlyBuddies);
|
||||||
responseHash.insert("user_level_too_low", RespUserLevelTooLow);
|
responseHash.insert("user_level_too_low", RespUserLevelTooLow);
|
||||||
responseHash.insert("on_ignore_list", RespOnIgnoreList);
|
responseHash.insert("in_ignore_list", RespInIgnoreList);
|
||||||
}
|
}
|
||||||
|
|
||||||
Response_JoinRoom::Response_JoinRoom(int _cmdId, ResponseCode _responseCode, ServerInfo_Room *_roomInfo)
|
Response_JoinRoom::Response_JoinRoom(int _cmdId, ResponseCode _responseCode, ServerInfo_Room *_roomInfo)
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
class DeckList;
|
class DeckList;
|
||||||
|
|
||||||
enum ResponseCode { RespNothing, RespOk, RespInternalError, RespInvalidCommand, RespInvalidData, RespNameNotFound, RespLoginNeeded, RespFunctionNotAllowed, RespGameNotStarted, RespGameFull, RespContextError, RespWrongPassword, RespSpectatorsNotAllowed, RespOnlyBuddies, RespUserLevelTooLow, RespOnIgnoreList };
|
enum ResponseCode { RespNothing, RespOk, RespInternalError, RespInvalidCommand, RespInvalidData, RespNameNotFound, RespLoginNeeded, RespFunctionNotAllowed, RespGameNotStarted, RespGameFull, RespContextError, RespWrongPassword, RespSpectatorsNotAllowed, RespOnlyBuddies, RespUserLevelTooLow, RespInIgnoreList };
|
||||||
|
|
||||||
// PrivateZone: Contents of the zone are always visible to the owner,
|
// PrivateZone: Contents of the zone are always visible to the owner,
|
||||||
// but not to anyone else.
|
// but not to anyone else.
|
||||||
|
|
|
@ -183,7 +183,7 @@ ResponseCode Server_Game::checkJoin(ServerInfo_User *user, const QString &_passw
|
||||||
if (!static_cast<Server_Room *>(parent())->getServer()->getBuddyList(creatorInfo->getName()).contains(user->getName()))
|
if (!static_cast<Server_Room *>(parent())->getServer()->getBuddyList(creatorInfo->getName()).contains(user->getName()))
|
||||||
return RespOnlyBuddies;
|
return RespOnlyBuddies;
|
||||||
if (static_cast<Server_Room *>(parent())->getServer()->getIgnoreList(creatorInfo->getName()).contains(user->getName()))
|
if (static_cast<Server_Room *>(parent())->getServer()->getIgnoreList(creatorInfo->getName()).contains(user->getName()))
|
||||||
return RespOnIgnoreList;
|
return RespInIgnoreList;
|
||||||
if (spectator) {
|
if (spectator) {
|
||||||
if (!spectatorsAllowed)
|
if (!spectatorsAllowed)
|
||||||
return RespSpectatorsNotAllowed;
|
return RespSpectatorsNotAllowed;
|
||||||
|
|
|
@ -281,6 +281,8 @@ ResponseCode Server_ProtocolHandler::cmdMessage(Command_Message *cmd, CommandCon
|
||||||
Server_ProtocolHandler *userHandler = server->getUsers().value(receiver);
|
Server_ProtocolHandler *userHandler = server->getUsers().value(receiver);
|
||||||
if (!userHandler)
|
if (!userHandler)
|
||||||
return RespNameNotFound;
|
return RespNameNotFound;
|
||||||
|
if (userHandler->getIgnoreList().contains(userInfo->getName()))
|
||||||
|
return RespInIgnoreList;
|
||||||
|
|
||||||
cont->enqueueItem(new Event_Message(userInfo->getName(), receiver, cmd->getText()));
|
cont->enqueueItem(new Event_Message(userInfo->getName(), receiver, cmd->getText()));
|
||||||
userHandler->sendProtocolItem(new Event_Message(userInfo->getName(), receiver, cmd->getText()));
|
userHandler->sendProtocolItem(new Event_Message(userInfo->getName(), receiver, cmd->getText()));
|
||||||
|
|
|
@ -128,3 +128,16 @@ CREATE TABLE `cockatrice_servermessages` (
|
||||||
`message` text,
|
`message` text,
|
||||||
PRIMARY KEY (`timest`)
|
PRIMARY KEY (`timest`)
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
CREATE TABLE `cockatrice_ignorelist` (
|
||||||
|
`id_user1` int(7) unsigned NOT NULL,
|
||||||
|
`id_user2` int(7) unsigned NOT NULL,
|
||||||
|
UNIQUE KEY `key` (`id_user1`, `id_user2`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
CREATE TABLE `cockatrice_buddylist` (
|
||||||
|
`id_user1` int(7) unsigned NOT NULL,
|
||||||
|
`id_user2` int(7) unsigned NOT NULL,
|
||||||
|
UNIQUE KEY `key` (`id_user1`, `id_user2`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,9 @@ int ServerSocketInterface::getUserIdInDB(const QString &name) const
|
||||||
|
|
||||||
ResponseCode ServerSocketInterface::cmdAddToList(Command_AddToList *cmd, CommandContainer *cont)
|
ResponseCode ServerSocketInterface::cmdAddToList(Command_AddToList *cmd, CommandContainer *cont)
|
||||||
{
|
{
|
||||||
|
if (authState != PasswordRight)
|
||||||
|
return RespFunctionNotAllowed;
|
||||||
|
|
||||||
QString list = cmd->getList();
|
QString list = cmd->getList();
|
||||||
QString user = cmd->getUserName();
|
QString user = cmd->getUserName();
|
||||||
|
|
||||||
|
@ -148,6 +151,9 @@ ResponseCode ServerSocketInterface::cmdAddToList(Command_AddToList *cmd, Command
|
||||||
|
|
||||||
ResponseCode ServerSocketInterface::cmdRemoveFromList(Command_RemoveFromList *cmd, CommandContainer *cont)
|
ResponseCode ServerSocketInterface::cmdRemoveFromList(Command_RemoveFromList *cmd, CommandContainer *cont)
|
||||||
{
|
{
|
||||||
|
if (authState != PasswordRight)
|
||||||
|
return RespFunctionNotAllowed;
|
||||||
|
|
||||||
QString list = cmd->getList();
|
QString list = cmd->getList();
|
||||||
QString user = cmd->getUserName();
|
QString user = cmd->getUserName();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue