PB: more client files compile

This commit is contained in:
Max-Wilhelm Bruker 2011-12-30 22:29:57 +01:00
parent d3b96b1a88
commit c4eb7ba6cf
18 changed files with 120 additions and 124 deletions

View file

@ -1,4 +1,5 @@
#include "carddragitem.h"
#include "carditem.h"
#include "cardzone.h"
#include "tablezone.h"
#include "zoneviewzone.h"

View file

@ -12,7 +12,6 @@
#include "player.h"
#include "arrowitem.h"
#include "main.h"
#include "protocol_datastructures.h"
#include "settingscache.h"
#include "tab_game.h"

View file

@ -6,8 +6,8 @@
#include "carditem.h"
#include "player.h"
#include "zoneviewzone.h"
#include "protocol_datastructures.h"
#include "pb/command_move_card.pb.h"
#include "pb/serverinfo_user.pb.h"
CardZone::CardZone(Player *_p, const QString &_name, bool _hasCardAttr, bool _isShufflable, bool _contentsKnown, QGraphicsItem *parent, bool isView)
: AbstractGraphicsItem(parent), player(_p), name(_name), cards(_contentsKnown), view(NULL), menu(NULL), doubleClickAction(0), hasCardAttr(_hasCardAttr), isShufflable(_isShufflable)
@ -47,7 +47,7 @@ void CardZone::clearContents()
QString CardZone::getTranslatedName(bool hisOwn, GrammaticalCase gc) const
{
QString ownerName = player->getName();
bool female = player->getUserInfo()->getGender() == ServerInfo_User::Female;
bool female = player->getUserInfo()->gender() == ServerInfo_User::Female;
if (name == "hand")
switch (gc) {
case CaseNominative: return female ? (hisOwn ? tr("her hand", "nominative, female owner") : tr("%1's hand", "nominative, female owner").arg(ownerName)) : (hisOwn ? tr("his hand", "nominative, male owner") : tr("%1's hand", "nominative, male owner").arg(ownerName));

View file

@ -3,7 +3,6 @@
#include <QString>
#include "cardlist.h"
#include "carditem.h"
#include "abstractgraphicsitem.h"
#include "translation.h"

View file

@ -10,9 +10,10 @@
#include "dlg_creategame.h"
#include "gameselector.h"
#include "gamesmodel.h"
#include "tab_room.h"
#include "pending_command.h"
#include "pb/room_commands.pb.h"
#include "pb/serverinfo_game.pb.h"
GameSelector::GameSelector(AbstractClient *_client, TabSupervisor *_tabSupervisor, TabRoom *_room, const QMap<int, QString> &_rooms, const QMap<int, GameTypeMap> &_gameTypes, QWidget *parent)
: QGroupBox(parent), client(_client), tabSupervisor(_tabSupervisor), room(_room)
@ -89,7 +90,7 @@ void GameSelector::actCreate()
dlg.exec();
}
void GameSelector::checkResponse(ResponseCode response)
void GameSelector::checkResponse(Response::ResponseCode response)
{
if (createButton)
createButton->setEnabled(true);
@ -97,14 +98,14 @@ void GameSelector::checkResponse(ResponseCode response)
spectateButton->setEnabled(true);
switch (response) {
case RespNotInRoom: QMessageBox::critical(this, tr("Error"), tr("Please join the appropriate room first.")); break;
case RespWrongPassword: QMessageBox::critical(this, tr("Error"), tr("Wrong password.")); break;
case RespSpectatorsNotAllowed: QMessageBox::critical(this, tr("Error"), tr("Spectators are not allowed in this game.")); break;
case RespGameFull: QMessageBox::critical(this, tr("Error"), tr("The game is already full.")); 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 RespOnlyBuddies: QMessageBox::critical(this, tr("Error"), tr("This game is only open to its creator's buddies.")); break;
case RespInIgnoreList: QMessageBox::critical(this, tr("Error"), tr("You are being ignored by the creator of this game.")); break;
case Response::RespNotInRoom: QMessageBox::critical(this, tr("Error"), tr("Please join the appropriate room first.")); break;
case Response::RespWrongPassword: QMessageBox::critical(this, tr("Error"), tr("Wrong password.")); break;
case Response::RespSpectatorsNotAllowed: QMessageBox::critical(this, tr("Error"), tr("Spectators are not allowed in this game.")); break;
case Response::RespGameFull: QMessageBox::critical(this, tr("Error"), tr("The game is already full.")); break;
case Response::RespNameNotFound: QMessageBox::critical(this, tr("Error"), tr("The game does not exist any more.")); break;
case Response::RespUserLevelTooLow: QMessageBox::critical(this, tr("Error"), tr("This game is only open to registered users.")); break;
case Response::RespOnlyBuddies: QMessageBox::critical(this, tr("Error"), tr("This game is only open to its creator's buddies.")); break;
case Response::RespInIgnoreList: QMessageBox::critical(this, tr("Error"), tr("You are being ignored by the creator of this game.")); break;
default: ;
}
}
@ -116,10 +117,10 @@ void GameSelector::actJoin()
QModelIndex ind = gameListView->currentIndex();
if (!ind.isValid())
return;
ServerInfo_Game *game = gameListModel->getGame(ind.data(Qt::UserRole).toInt());
const ServerInfo_Game &game = gameListModel->getGame(ind.data(Qt::UserRole).toInt());
bool overrideRestrictions = !tabSupervisor->getAdminLocked();
QString password;
if (game->getHasPassword() && !(spectator && !game->getSpectatorsNeedPassword()) && !overrideRestrictions) {
if (game.with_password() && !(spectator && !game.spectators_need_password()) && !overrideRestrictions) {
bool ok;
password = QInputDialog::getText(this, tr("Join game"), tr("Password:"), QLineEdit::Password, QString(), &ok);
if (!ok)
@ -127,19 +128,19 @@ void GameSelector::actJoin()
}
Command_JoinGame cmd;
cmd.set_game_id(game->getGameId());
cmd.set_game_id(game.game_id());
cmd.set_password(password.toStdString());
cmd.set_spectator(spectator);
cmd.set_override_restrictions(overrideRestrictions);
TabRoom *r = tabSupervisor->getRoomTabs().value(game->getRoomId());
TabRoom *r = tabSupervisor->getRoomTabs().value(game.room_id());
if (!r) {
QMessageBox::critical(this, tr("Error"), tr("Please join the respective room first."));
return;
}
PendingCommand *pend = r->prepareRoomCommand(cmd);
connect(pend, SIGNAL(finished(ResponseCode)), this, SLOT(checkResponse(ResponseCode)));
connect(pend, SIGNAL(finished(Response::ResponseCode)), this, SLOT(checkResponse(Response::ResponseCode)));
r->sendRoomCommand(pend);
if (createButton)
@ -159,8 +160,7 @@ void GameSelector::retranslateUi()
spectateButton->setText(tr("J&oin as spectator"));
}
void GameSelector::processGameInfo(ServerInfo_Game *info)
void GameSelector::processGameInfo(const ServerInfo_Game &info)
{
gameListModel->updateGameList(info);
}

View file

@ -2,9 +2,9 @@
#define GAMESELECTOR_H
#include <QGroupBox>
#include "protocol_datastructures.h"
#include "tab_room.h"
//#include "tab_room.h"
#include "gametypemap.h"
#include "pb/response.pb.h"
class QTreeView;
class GamesModel;
@ -14,6 +14,7 @@ class QCheckBox;
class AbstractClient;
class TabSupervisor;
class TabRoom;
class ServerInfo_Game;
class GameSelector : public QGroupBox {
Q_OBJECT
@ -22,7 +23,7 @@ private slots:
void showRunningGamesChanged(int state);
void actCreate();
void actJoin();
void checkResponse(ResponseCode response);
void checkResponse(Response::ResponseCode response);
signals:
void gameJoined(int gameId);
private:
@ -38,7 +39,7 @@ private:
public:
GameSelector(AbstractClient *_client, TabSupervisor *_tabSupervisor, TabRoom *_room, const QMap<int, QString> &_rooms, const QMap<int, GameTypeMap> &_gameTypes, QWidget *parent = 0);
void retranslateUi();
void processGameInfo(ServerInfo_Game *info);
void processGameInfo(const ServerInfo_Game &info);
};
#endif

View file

@ -1,5 +1,6 @@
#include "gamesmodel.h"
#include "protocol_datastructures.h"
#include "pb/serverinfo_game.pb.h"
#include <QStringList>
GamesModel::GamesModel(const QMap<int, QString> &_rooms, const QMap<int, GameTypeMap> &_gameTypes, QObject *parent)
: QAbstractTableModel(parent), rooms(_rooms), gameTypes(_gameTypes)
@ -10,8 +11,6 @@ GamesModel::~GamesModel()
{
if (!gameList.isEmpty()) {
beginRemoveRows(QModelIndex(), 0, gameList.size() - 1);
for (int i = 0; i < gameList.size(); ++i)
delete gameList[i];
gameList.clear();
endRemoveRows();
}
@ -28,30 +27,29 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const
if ((index.row() >= gameList.size()) || (index.column() >= columnCount()))
return QVariant();
ServerInfo_Game *g = gameList[index.row()];
const ServerInfo_Game &g = gameList[index.row()];
switch (index.column()) {
case 0: return g->getDescription();
case 1: return rooms.value(g->getRoomId());
case 2: return g->getCreatorInfo()->getName();
case 0: return QString::fromStdString(g.description());
case 1: return rooms.value(g.room_id());
case 2: return QString::fromStdString(g.creator_info().name());
case 3: {
QStringList result;
QList<GameTypeId *> gameTypeList = g->getGameTypes();
GameTypeMap gameTypeMap = gameTypes.value(g->getRoomId());
for (int i = 0; i < gameTypeList.size(); ++i)
result.append(gameTypeMap.value(gameTypeList[i]->getData()));
GameTypeMap gameTypeMap = gameTypes.value(g.room_id());
for (int i = g.game_types_size() - 1; i >= 0; --i)
result.append(gameTypeMap.value(g.game_types(i)));
return result.join(", ");
}
case 4: return g->getHasPassword() ? (g->getSpectatorsNeedPassword() ? tr("yes") : tr("yes, free for spectators")) : tr("no");
case 4: return g.with_password() ? (g.spectators_need_password() ? tr("yes") : tr("yes, free for spectators")) : tr("no");
case 5: {
QStringList result;
if (g->getOnlyBuddies())
if (g.only_buddies())
result.append(tr("buddies only"));
if (g->getOnlyRegistered())
if (g.only_registered())
result.append(tr("reg. users only"));
return result.join(", ");
}
case 6: return QString("%1/%2").arg(g->getPlayerCount()).arg(g->getMaxPlayers());
case 7: return g->getSpectatorsAllowed() ? QVariant(g->getSpectatorCount()) : QVariant(tr("not allowed"));
case 6: return QString("%1/%2").arg(g.player_count()).arg(g.max_players());
case 7: return g.spectators_allowed() ? QVariant(g.spectators_count()) : QVariant(tr("not allowed"));
default: return QVariant();
}
}
@ -73,33 +71,27 @@ QVariant GamesModel::headerData(int section, Qt::Orientation orientation, int ro
}
}
ServerInfo_Game *GamesModel::getGame(int row)
const ServerInfo_Game &GamesModel::getGame(int row)
{
Q_ASSERT(row < gameList.size());
return gameList[row];
}
void GamesModel::updateGameList(ServerInfo_Game *_game)
void GamesModel::updateGameList(const ServerInfo_Game &game)
{
QList<GameTypeId *> gameTypeList, oldGameTypeList = _game->getGameTypes();
for (int i = 0; i < oldGameTypeList.size(); ++i)
gameTypeList.append(new GameTypeId(oldGameTypeList[i]->getData()));
ServerInfo_Game *game = new ServerInfo_Game(_game->getRoomId(), _game->getGameId(), _game->getDescription(), _game->getHasPassword(), _game->getPlayerCount(), _game->getMaxPlayers(), _game->getStarted(), gameTypeList, new ServerInfo_User(_game->getCreatorInfo()), _game->getOnlyBuddies(), _game->getOnlyRegistered(), _game->getSpectatorsAllowed(), _game->getSpectatorsNeedPassword(), _game->getSpectatorCount());
for (int i = 0; i < gameList.size(); i++)
if (gameList[i]->getGameId() == game->getGameId()) {
if (game->getPlayerCount() == 0) {
if (gameList[i].game_id() == game.game_id()) {
if (!game.has_player_count()) {
beginRemoveRows(QModelIndex(), i, i);
delete gameList.takeAt(i);
gameList.removeAt(i);
endRemoveRows();
} else {
delete gameList[i];
gameList[i] = game;
emit dataChanged(index(i, 0), index(i, 7));
}
return;
}
if (game->getPlayerCount() == 0)
if (game.player_count() <= 0)
return;
beginInsertRows(QModelIndex(), gameList.size(), gameList.size());
gameList.append(game);
@ -130,10 +122,10 @@ bool GamesProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &/*sourc
if (!model)
return false;
ServerInfo_Game *game = model->getGame(sourceRow);
if ((game->getPlayerCount() == game->getMaxPlayers()) && !fullGamesVisible)
const ServerInfo_Game &game = model->getGame(sourceRow);
if ((game.player_count() == game.max_players()) && !fullGamesVisible)
return false;
if (game->getStarted() && !runningGamesVisible)
if (game.started() && !runningGamesVisible)
return false;
return true;

View file

@ -11,7 +11,7 @@ class ServerInfo_Game;
class GamesModel : public QAbstractTableModel {
Q_OBJECT
private:
QList<ServerInfo_Game *> gameList;
QList<ServerInfo_Game> gameList;
QMap<int, QString> rooms;
QMap<int, GameTypeMap> gameTypes;
public:
@ -22,8 +22,8 @@ public:
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
ServerInfo_Game *getGame(int row);
void updateGameList(ServerInfo_Game *game);
const ServerInfo_Game &getGame(int row);
void updateGameList(const ServerInfo_Game &game);
};
class GamesProxyModel : public QSortFilterProxyModel {

View file

@ -1,8 +1,10 @@
#include "messagelogwidget.h"
#include "player.h"
#include "cardzone.h"
#include "protocol_items.h"
#include "soundengine.h"
#include "pb/serverinfo_user.pb.h"
#include "pb/context_move_card.pb.h"
#include "pb/context_mulligan.pb.h"
#include <QScrollBar>
QString MessageLogWidget::sanitizeHtml(QString dirty) const
@ -15,7 +17,7 @@ QString MessageLogWidget::sanitizeHtml(QString dirty) const
bool MessageLogWidget::isFemale(Player *player) const
{
return player->getUserInfo()->getGender() == ServerInfo_User::Female;
return player->getUserInfo()->gender() == ServerInfo_User::Female;
}
void MessageLogWidget::logGameJoined(int gameId)
@ -728,14 +730,15 @@ void MessageLogWidget::logSetActivePhase(int phase)
appendHtml("<font color=\"green\"><b>" + tr("It is now the %1.").arg(phaseName) + "</b></font>");
}
void MessageLogWidget::containerProcessingStarted(GameEventContext *_context)
void MessageLogWidget::containerProcessingStarted(const GameEventContext &_context)
{
if (qobject_cast<Context_MoveCard *>(_context))
if (_context.HasExtension(Context_MoveCard::ext))
currentContext = MessageContext_MoveCard;
else if (qobject_cast<Context_Mulligan *>(_context)) {
else if (_context.HasExtension(Context_Mulligan::ext)) {
const Context_Mulligan &contextMulligan = _context.GetExtension(Context_Mulligan::ext);
currentContext = MessageContext_Mulligan;
mulliganPlayer = 0;
mulliganNumber = static_cast<Context_Mulligan *>(_context)->getNumber();
mulliganNumber = contextMulligan.number();
}
}

View file

@ -4,7 +4,6 @@
#include "chatview.h"
#include <QAbstractSocket>
#include "translation.h"
#include "protocol_datastructures.h"
class Player;
class CardZone;
@ -78,7 +77,7 @@ public slots:
void logRevealCards(Player *player, CardZone *zone, int cardId, QString cardName, Player *otherPlayer);
void logSetActivePlayer(Player *player);
void logSetActivePhase(int phase);
void containerProcessingStarted(GameEventContext *context);
void containerProcessingStarted(const GameEventContext &context);
void containerProcessingDone();
public:
void connectToPlayer(Player *player);

View file

@ -1,12 +1,10 @@
#include <QHeaderView>
#include "playerlistwidget.h"
#include "protocol_datastructures.h"
#include "pixmapgenerator.h"
#include "abstractclient.h"
#include "tab_game.h"
#include "tab_supervisor.h"
#include "tab_userlists.h"
#include "protocol_items.h"
#include "userlist.h"
#include "userinfobox.h"
#include <QMouseEvent>
@ -15,6 +13,7 @@
#include "pb/session_commands.pb.h"
#include "pb/command_kick_from_game.pb.h"
#include "pb/serverinfo_playerproperties.pb.h"
PlayerListItemDelegate::PlayerListItemDelegate(QObject *const parent)
: QStyledItemDelegate(parent)
@ -73,34 +72,35 @@ void PlayerListWidget::retranslateUi()
{
}
void PlayerListWidget::addPlayer(ServerInfo_PlayerProperties *player)
void PlayerListWidget::addPlayer(const ServerInfo_PlayerProperties &player)
{
QTreeWidgetItem *newPlayer = new PlayerListTWI;
players.insert(player->getPlayerId(), newPlayer);
players.insert(player.player_id(), newPlayer);
updatePlayerProperties(player);
addTopLevelItem(newPlayer);
sortItems(1, Qt::AscendingOrder);
}
void PlayerListWidget::updatePlayerProperties(ServerInfo_PlayerProperties *prop)
void PlayerListWidget::updatePlayerProperties(const ServerInfo_PlayerProperties &prop)
{
QTreeWidgetItem *player = players.value(prop->getPlayerId(), 0);
QTreeWidgetItem *player = players.value(prop.player_id(), 0);
if (!player)
return;
player->setIcon(1, prop->getSpectator() ? spectatorIcon : playerIcon);
player->setData(1, Qt::UserRole, !prop->getSpectator());
player->setData(2, Qt::UserRole, prop->getConceded());
player->setData(2, Qt::UserRole + 1, prop->getReadyStart());
player->setIcon(2, gameStarted ? (prop->getConceded() ? concededIcon : QIcon()) : (prop->getReadyStart() ? readyIcon : notReadyIcon));
player->setData(3, Qt::UserRole, prop->getUserInfo()->getUserLevel());
player->setIcon(3, QIcon(UserLevelPixmapGenerator::generatePixmap(12, prop->getUserInfo()->getUserLevel())));
player->setText(4, prop->getUserInfo()->getName());
if (!prop->getUserInfo()->getCountry().isEmpty())
player->setIcon(4, QIcon(CountryPixmapGenerator::generatePixmap(12, prop->getUserInfo()->getCountry())));
player->setData(4, Qt::UserRole, prop->getUserInfo()->getName());
player->setData(4, Qt::UserRole + 1, prop->getPlayerId());
player->setText(5, prop->getDeckHash());
player->setIcon(1, prop.spectator() ? spectatorIcon : playerIcon);
player->setData(1, Qt::UserRole, !prop.spectator());
player->setData(2, Qt::UserRole, prop.conceded());
player->setData(2, Qt::UserRole + 1, prop.ready_start());
player->setIcon(2, gameStarted ? (prop.conceded() ? concededIcon : QIcon()) : (prop.ready_start() ? readyIcon : notReadyIcon));
player->setData(3, Qt::UserRole, prop.user_info().user_level());
player->setIcon(3, QIcon(UserLevelPixmapGenerator::generatePixmap(12, prop.user_info().user_level())));
player->setText(4, QString::fromStdString(prop.user_info().name()));
const QString country = QString::fromStdString(prop.user_info().country());
if (!country.isEmpty())
player->setIcon(4, QIcon(CountryPixmapGenerator::generatePixmap(12, country)));
player->setData(4, Qt::UserRole, QString::fromStdString(prop.user_info().name()));
player->setData(4, Qt::UserRole + 1, prop.player_id());
player->setText(5, QString::fromStdString(prop.deck_hash()));
}
void PlayerListWidget::removePlayer(int playerId)
@ -185,7 +185,7 @@ void PlayerListWidget::showContextMenu(const QPoint &pos, const QModelIndex &ind
menu->addSeparator();
menu->addAction(aKick);
}
if (userName == game->getTabSupervisor()->getUserInfo()->getName()) {
if (userName == QString::fromStdString(game->getTabSupervisor()->getUserInfo()->name())) {
aChat->setEnabled(false);
aAddToBuddyList->setEnabled(false);
aRemoveFromBuddyList->setEnabled(false);

View file

@ -38,11 +38,11 @@ signals:
public:
PlayerListWidget(TabSupervisor *_tabSupervisor, AbstractClient *_client, TabGame *_game, QWidget *parent = 0);
void retranslateUi();
void addPlayer(ServerInfo_PlayerProperties *player);
void addPlayer(const ServerInfo_PlayerProperties &player);
void removePlayer(int playerId);
void setActivePlayer(int playerId);
void updatePing(int playerId, int pingTime);
void updatePlayerProperties(ServerInfo_PlayerProperties *prop);
void updatePlayerProperties(const ServerInfo_PlayerProperties &prop);
void setGameStarted(bool _gameStarted, bool resuming);
void showContextMenu(const QPoint &pos, const QModelIndex &index);
};

View file

@ -1,7 +1,9 @@
#include <QGraphicsSceneMouseEvent>
#include "selectzone.h"
#include "gamescene.h"
#include "carditem.h"
#include <QDebug>
SelectZone::SelectZone(Player *_player, const QString &_name, bool _hasCardAttr, bool _isShufflable, bool _contentsKnown, QGraphicsItem *parent, bool isView)
: CardZone(_player, _name, _hasCardAttr, _isShufflable, _contentsKnown, parent, isView)
{

View file

@ -13,11 +13,11 @@
#include "remotedecklist_treewidget.h"
#include "abstractclient.h"
#include "decklist.h"
#include "protocol_items.h"
#include "window_deckeditor.h"
#include "settingscache.h"
#include "pending_command.h"
#include "pb/response.pb.h"
#include "pb/command_deck_upload.pb.h"
#include "pb/command_deck_download.pb.h"
#include "pb/command_deck_new_dir.pb.h"
@ -173,15 +173,15 @@ void TabDeckStorage::actUpload()
client->sendCommand(pend);
}
void TabDeckStorage::uploadFinished(ProtocolResponse *r)
void TabDeckStorage::uploadFinished(const Response &r)
{
Response_DeckUpload *resp = qobject_cast<Response_DeckUpload *>(r);
/* Response_DeckUpload *resp = qobject_cast<Response_DeckUpload *>(r);
if (!resp)
return;
const Command_DeckUpload &cmd = static_cast<const Command_DeckUpload &>(static_cast<PendingCommand *>(sender())->getCommandContainer().session_command(0).GetExtension(Command_DeckUpload::ext));
serverDirView->addFileToTree(resp->getFile(), serverDirView->getNodeByPath(QString::fromStdString(cmd.path())));
}
*/}
void TabDeckStorage::actOpenRemoteDeck()
{
@ -197,16 +197,16 @@ void TabDeckStorage::actOpenRemoteDeck()
client->sendCommand(pend);
}
void TabDeckStorage::openRemoteDeckFinished(ProtocolResponse *r)
void TabDeckStorage::openRemoteDeckFinished(const Response &r)
{
Response_DeckDownload *resp = qobject_cast<Response_DeckDownload *>(r);
/* Response_DeckDownload *resp = qobject_cast<Response_DeckDownload *>(r);
if (!resp)
return;
WndDeckEditor *deckEditor = new WndDeckEditor;
deckEditor->setDeck(new DeckList(resp->getDeck()));
deckEditor->show();
}
*/}
void TabDeckStorage::actDownload()
{
@ -234,16 +234,16 @@ void TabDeckStorage::actDownload()
client->sendCommand(pend);
}
void TabDeckStorage::downloadFinished(ProtocolResponse *r)
void TabDeckStorage::downloadFinished(const Response &r)
{
Response_DeckDownload *resp = qobject_cast<Response_DeckDownload *>(r);
/* Response_DeckDownload *resp = qobject_cast<Response_DeckDownload *>(r);
if (!resp)
return;
PendingCommand *pend = static_cast<PendingCommand *>(sender());
QString filePath = pend->getExtraData().toString();
resp->getDeck()->saveToFile(filePath, DeckList::CockatriceFormat);
}
*/}
void TabDeckStorage::actNewFolder()
{
@ -265,13 +265,13 @@ void TabDeckStorage::actNewFolder()
cmd.set_dir_name(folderName.toStdString());
PendingCommand *pend = client->prepareSessionCommand(cmd);
connect(pend, SIGNAL(finished(ResponseCode)), this, SLOT(newFolderFinished(ResponseCode)));
connect(pend, SIGNAL(finished(Response::ResponseCode)), this, SLOT(newFolderFinished(Response::ResponseCode)));
client->sendCommand(pend);
}
void TabDeckStorage::newFolderFinished(ResponseCode resp)
void TabDeckStorage::newFolderFinished(Response::ResponseCode resp)
{
if (resp != RespOk)
if (resp != Response::RespOk)
return;
const Command_DeckNewDir &cmd = static_cast<const Command_DeckNewDir &>(static_cast<PendingCommand *>(sender())->getCommandContainer().session_command(0).GetExtension(Command_DeckNewDir::ext));
@ -292,20 +292,20 @@ void TabDeckStorage::actDelete()
Command_DeckDelDir cmd;
cmd.set_path(path.toStdString());
pend = client->prepareSessionCommand(cmd);
connect(pend, SIGNAL(finished(ResponseCode)), this, SLOT(deleteFolderFinished(ResponseCode)));
connect(pend, SIGNAL(finished(Response::ResponseCode)), this, SLOT(deleteFolderFinished(Response::ResponseCode)));
} else {
Command_DeckDel cmd;
cmd.set_deck_id(dynamic_cast<RemoteDeckList_TreeModel::FileNode *>(curRight)->getId());
pend = client->prepareSessionCommand(cmd);
connect(pend, SIGNAL(finished(ResponseCode)), this, SLOT(deleteDeckFinished(ResponseCode)));
connect(pend, SIGNAL(finished(Response::ResponseCode)), this, SLOT(deleteDeckFinished(Response::ResponseCode)));
}
client->sendCommand(pend);
}
void TabDeckStorage::deleteDeckFinished(ResponseCode resp)
void TabDeckStorage::deleteDeckFinished(Response::ResponseCode resp)
{
if (resp != RespOk)
if (resp != Response::RespOk)
return;
const Command_DeckDel &cmd = static_cast<const Command_DeckDel &>(static_cast<PendingCommand *>(sender())->getCommandContainer().session_command(0).GetExtension(Command_DeckDel::ext));
@ -314,9 +314,9 @@ void TabDeckStorage::deleteDeckFinished(ResponseCode resp)
serverDirView->removeNode(toDelete);
}
void TabDeckStorage::deleteFolderFinished(ResponseCode resp)
void TabDeckStorage::deleteFolderFinished(Response::ResponseCode resp)
{
if (resp != RespOk)
if (resp != Response::RespOk)
return;
const Command_DeckDelDir &cmd = static_cast<const Command_DeckDelDir &>(static_cast<PendingCommand *>(sender())->getCommandContainer().session_command(0).GetExtension(Command_DeckDelDir::ext));

View file

@ -2,7 +2,7 @@
#define TAB_DECK_STORAGE_H
#include "tab.h"
#include "protocol.h"
#include "pb/response.pb.h"
class AbstractClient;
class QTreeView;
@ -31,20 +31,20 @@ private slots:
void actOpenLocalDeck();
void actUpload();
void uploadFinished(ProtocolResponse *r);
void uploadFinished(const Response &r);
void actOpenRemoteDeck();
void openRemoteDeckFinished(ProtocolResponse *r);
void openRemoteDeckFinished(const Response &r);
void actDownload();
void downloadFinished(ProtocolResponse *r);
void downloadFinished(const Response &r);
void actNewFolder();
void newFolderFinished(ResponseCode resp);
void newFolderFinished(Response::ResponseCode resp);
void actDelete();
void deleteFolderFinished(ResponseCode resp);
void deleteDeckFinished(ResponseCode resp);
void deleteFolderFinished(Response::ResponseCode resp);
void deleteDeckFinished(Response::ResponseCode resp);
public:
TabDeckStorage(TabSupervisor *_tabSupervisor, AbstractClient *_client);
void retranslateUi();

View file

@ -37,6 +37,8 @@
#include "localclient.h"
#include "pb/room_commands.pb.h"
#include "pb/event_connection_closed.pb.h"
#include "pb/event_server_shutdown.pb.h"
const QString MainWindow::appName = "Cockatrice";
@ -49,9 +51,9 @@ void MainWindow::updateTabMenu(QMenu *menu)
menuBar()->insertMenu(helpMenu->menuAction(), menu);
}
void MainWindow::processConnectionClosedEvent(Event_ConnectionClosed *event)
void MainWindow::processConnectionClosedEvent(const Event_ConnectionClosed &event)
{
/* QString reason = event->getReason();
QString reason = QString::fromStdString(event.reason());
client->disconnectFromServer();
QString reasonStr;
if (reason == "too_many_connections")
@ -63,13 +65,11 @@ void MainWindow::processConnectionClosedEvent(Event_ConnectionClosed *event)
else
reasonStr = tr("Unknown reason.");
QMessageBox::critical(this, tr("Connection closed"), tr("The server has terminated your connection.\nReason: %1").arg(reasonStr));
*/
}
void MainWindow::processServerShutdownEvent(Event_ServerShutdown *event)
void MainWindow::processServerShutdownEvent(const Event_ServerShutdown &event)
{
/* QMessageBox::information(this, tr("Scheduled server shutdown"), tr("The server is going to be restarted in %n minute(s).\nAll running games will be lost.\nReason for shutdown: %1", "", event->getMinutes()).arg(event->getReason()));
* */
QMessageBox::information(this, tr("Scheduled server shutdown"), tr("The server is going to be restarted in %n minute(s).\nAll running games will be lost.\nReason for shutdown: %1", "", event.minutes()).arg(QString::fromStdString(event.reason())));
}
void MainWindow::statusChanged(ClientStatus _status)

View file

@ -35,8 +35,8 @@ class MainWindow : public QMainWindow {
private slots:
void updateTabMenu(QMenu *menu);
void statusChanged(ClientStatus _status);
void processConnectionClosedEvent(Event_ConnectionClosed *event);
void processServerShutdownEvent(Event_ServerShutdown *event);
void processConnectionClosedEvent(const Event_ConnectionClosed &event);
void processServerShutdownEvent(const Event_ServerShutdown &event);
void serverTimeout();
void serverError(Response::ResponseCode r);
void socketError(const QString &errorStr);

View file

@ -5,11 +5,11 @@
#include <QStringList>
#include <QMap>
#include <QMutex>
#include "pb/serverinfo_user.pb.h"
class Server_Game;
class Server_Room;
class Server_ProtocolHandler;
class ServerInfo_User;
enum AuthenticationResult { PasswordWrong = 0, PasswordRight = 1, UnknownUser = 2, WouldOverwriteOldSession = 3 };