diff --git a/cockatrice/src/localserverinterface.h b/cockatrice/src/localserverinterface.h index 3620d1bb..557ada95 100644 --- a/cockatrice/src/localserverinterface.h +++ b/cockatrice/src/localserverinterface.h @@ -20,6 +20,7 @@ private: Response::ResponseCode cmdReplayList(const Command_ReplayList & /*cmd*/, ResponseContainer & /*rc*/) { return Response::RespFunctionNotAllowed; } Response::ResponseCode cmdReplayDownload(const Command_ReplayDownload & /*cmd*/, ResponseContainer & /*rc*/) { return Response::RespFunctionNotAllowed; } Response::ResponseCode cmdReplayModifyMatch(const Command_ReplayModifyMatch &cmd, ResponseContainer &rc) { return Response::RespFunctionNotAllowed; } + Response::ResponseCode cmdReplayDeleteMatch(const Command_ReplayDeleteMatch &cmd, ResponseContainer &rc) { return Response::RespFunctionNotAllowed; } Response::ResponseCode cmdBanFromServer(const Command_BanFromServer & /*cmd*/, ResponseContainer & /*rc*/) { return Response::RespFunctionNotAllowed; } Response::ResponseCode cmdShutdownServer(const Command_ShutdownServer & /*cmd*/, ResponseContainer & /*rc*/) { return Response::RespFunctionNotAllowed; } Response::ResponseCode cmdUpdateServerMessage(const Command_UpdateServerMessage & /*cmd*/, ResponseContainer & /*rc*/) { return Response::RespFunctionNotAllowed; } diff --git a/cockatrice/src/remotereplaylist_treewidget.cpp b/cockatrice/src/remotereplaylist_treewidget.cpp index f502f0fb..ed2d823d 100644 --- a/cockatrice/src/remotereplaylist_treewidget.cpp +++ b/cockatrice/src/remotereplaylist_treewidget.cpp @@ -243,6 +243,17 @@ void RemoteReplayList_TreeModel::updateMatchInfo(int gameId, const ServerInfo_Re } } +void RemoteReplayList_TreeModel::removeMatchInfo(int gameId) +{ + for (int i = 0; i < replayMatches.size(); ++i) + if (replayMatches[i]->getMatchInfo().game_id() == gameId) { + beginRemoveRows(QModelIndex(), i, i); + replayMatches.removeAt(i); + endRemoveRows(); + break; + } +} + void RemoteReplayList_TreeModel::replayListFinished(const Response &r) { const Response_ReplayList &resp = r.GetExtension(Response_ReplayList::ext); diff --git a/cockatrice/src/remotereplaylist_treewidget.h b/cockatrice/src/remotereplaylist_treewidget.h index e9e695ce..7397d21d 100644 --- a/cockatrice/src/remotereplaylist_treewidget.h +++ b/cockatrice/src/remotereplaylist_treewidget.h @@ -72,6 +72,7 @@ public: ServerInfo_ReplayMatch const* getReplayMatch(const QModelIndex &index) const; void addMatchInfo(const ServerInfo_ReplayMatch &matchInfo); void updateMatchInfo(int gameId, const ServerInfo_ReplayMatch &matchInfo); + void removeMatchInfo(int gameId); }; class RemoteReplayList_TreeWidget : public QTreeView { @@ -86,6 +87,7 @@ public: void refreshTree(); void addMatchInfo(const ServerInfo_ReplayMatch &matchInfo) { treeModel->addMatchInfo(matchInfo); } void updateMatchInfo(int gameId, const ServerInfo_ReplayMatch &matchInfo) { treeModel->updateMatchInfo(gameId, matchInfo); } + void removeMatchInfo(int gameId) { treeModel->removeMatchInfo(gameId); } }; #endif diff --git a/cockatrice/src/tab_deck_storage.cpp b/cockatrice/src/tab_deck_storage.cpp index de8fa27f..724d1940 100644 --- a/cockatrice/src/tab_deck_storage.cpp +++ b/cockatrice/src/tab_deck_storage.cpp @@ -8,11 +8,11 @@ #include #include #include +#include #include "tab_deck_storage.h" #include "remotedecklist_treewidget.h" #include "abstractclient.h" #include "decklist.h" -//#include "window_deckeditor.h" #include "settingscache.h" #include "pending_command.h" @@ -80,6 +80,9 @@ TabDeckStorage::TabDeckStorage(TabSupervisor *_tabSupervisor, AbstractClient *_c aUpload = new QAction(this); aUpload->setIcon(QIcon(":/resources/arrow_right_green.svg")); connect(aUpload, SIGNAL(triggered()), this, SLOT(actUpload())); + aDeleteLocalDeck = new QAction(this); + aDeleteLocalDeck->setIcon(QIcon(":/resources/remove_row.svg")); + connect(aDeleteLocalDeck, SIGNAL(triggered()), this, SLOT(actDeleteLocalDeck())); aOpenRemoteDeck = new QAction(this); aOpenRemoteDeck->setIcon(QIcon(":/resources/pencil.svg")); connect(aOpenRemoteDeck, SIGNAL(triggered()), this, SLOT(actOpenRemoteDeck())); @@ -89,16 +92,17 @@ TabDeckStorage::TabDeckStorage(TabSupervisor *_tabSupervisor, AbstractClient *_c aNewFolder = new QAction(this); aNewFolder->setIcon(qApp->style()->standardIcon(QStyle::SP_FileDialogNewFolder)); connect(aNewFolder, SIGNAL(triggered()), this, SLOT(actNewFolder())); - aDelete = new QAction(this); - aDelete->setIcon(QIcon(":/resources/remove_row.svg")); - connect(aDelete, SIGNAL(triggered()), this, SLOT(actDelete())); + aDeleteRemoteDeck = new QAction(this); + aDeleteRemoteDeck->setIcon(QIcon(":/resources/remove_row.svg")); + connect(aDeleteRemoteDeck, SIGNAL(triggered()), this, SLOT(actDeleteRemoteDeck())); leftToolBar->addAction(aOpenLocalDeck); leftToolBar->addAction(aUpload); + leftToolBar->addAction(aDeleteLocalDeck); rightToolBar->addAction(aOpenRemoteDeck); rightToolBar->addAction(aDownload); rightToolBar->addAction(aNewFolder); - rightToolBar->addAction(aDelete); + rightToolBar->addAction(aDeleteRemoteDeck); retranslateUi(); setLayout(hbox); @@ -114,7 +118,8 @@ void TabDeckStorage::retranslateUi() aOpenRemoteDeck->setText(tr("Open in deck editor")); aDownload->setText(tr("Download deck")); aNewFolder->setText(tr("New folder")); - aDelete->setText(tr("Delete")); + aDeleteLocalDeck->setText(tr("Delete")); + aDeleteRemoteDeck->setText(tr("Delete")); } void TabDeckStorage::actOpenLocalDeck() @@ -178,6 +183,15 @@ void TabDeckStorage::uploadFinished(const Response &r, const CommandContainer &c serverDirView->addFileToTree(resp.new_file(), serverDirView->getNodeByPath(QString::fromStdString(cmd.path()))); } +void TabDeckStorage::actDeleteLocalDeck() +{ + QModelIndex curLeft = localDirView->selectionModel()->currentIndex(); + if (QMessageBox::warning(this, tr("Delete local file"), tr("Are you sure you want to delete \"%1\"?").arg(localDirModel->fileName(curLeft)), QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) + return; + + localDirModel->remove(curLeft); +} + void TabDeckStorage::actOpenRemoteDeck() { RemoteDeckList_TreeModel::FileNode *curRight = dynamic_cast(serverDirView->getCurrentItem()); @@ -269,7 +283,7 @@ void TabDeckStorage::newFolderFinished(const Response &response, const CommandCo serverDirView->addFolderToTree(QString::fromStdString(cmd.dir_name()), serverDirView->getNodeByPath(QString::fromStdString(cmd.path()))); } -void TabDeckStorage::actDelete() +void TabDeckStorage::actDeleteRemoteDeck() { PendingCommand *pend; RemoteDeckList_TreeModel::Node *curRight = serverDirView->getCurrentItem(); @@ -285,8 +299,12 @@ void TabDeckStorage::actDelete() pend = client->prepareSessionCommand(cmd); connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(deleteFolderFinished(Response, CommandContainer))); } else { + RemoteDeckList_TreeModel::FileNode *deckNode = dynamic_cast(curRight); + if (QMessageBox::warning(this, tr("Delete remote deck"), tr("Are you sure you want to delete \"%1\"?").arg(deckNode->getName()), QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) + return; + Command_DeckDel cmd; - cmd.set_deck_id(dynamic_cast(curRight)->getId()); + cmd.set_deck_id(deckNode->getId()); pend = client->prepareSessionCommand(cmd); connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(deleteDeckFinished(Response, CommandContainer))); } diff --git a/cockatrice/src/tab_deck_storage.h b/cockatrice/src/tab_deck_storage.h index 19c66d77..6996c435 100644 --- a/cockatrice/src/tab_deck_storage.h +++ b/cockatrice/src/tab_deck_storage.h @@ -24,13 +24,15 @@ private: RemoteDeckList_TreeWidget *serverDirView; QGroupBox *leftGroupBox, *rightGroupBox; - QAction *aOpenLocalDeck, *aUpload, *aOpenRemoteDeck, *aDownload, *aNewFolder, *aDelete; + QAction *aOpenLocalDeck, *aUpload, *aDeleteLocalDeck, *aOpenRemoteDeck, *aDownload, *aNewFolder, *aDeleteRemoteDeck; private slots: void actOpenLocalDeck(); void actUpload(); void uploadFinished(const Response &r, const CommandContainer &commandContainer); - + + void actDeleteLocalDeck(); + void actOpenRemoteDeck(); void openRemoteDeckFinished(const Response &r); @@ -40,7 +42,7 @@ private slots: void actNewFolder(); void newFolderFinished(const Response &response, const CommandContainer &commandContainer); - void actDelete(); + void actDeleteRemoteDeck(); void deleteFolderFinished(const Response &response, const CommandContainer &commandContainer); void deleteDeckFinished(const Response &response, const CommandContainer &commandContainer); public: diff --git a/cockatrice/src/tab_replays.cpp b/cockatrice/src/tab_replays.cpp index 58b0af3d..5119d50b 100644 --- a/cockatrice/src/tab_replays.cpp +++ b/cockatrice/src/tab_replays.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include "tab_replays.h" #include "remotereplaylist_treewidget.h" #include "abstractclient.h" @@ -20,6 +21,7 @@ #include "pb/response_replay_download.pb.h" #include "pb/command_replay_download.pb.h" #include "pb/command_replay_modify_match.pb.h" +#include "pb/command_replay_delete_match.pb.h" #include "pb/event_replay_added.pb.h" TabReplays::TabReplays(TabSupervisor *_tabSupervisor, AbstractClient *_client) @@ -74,6 +76,9 @@ TabReplays::TabReplays(TabSupervisor *_tabSupervisor, AbstractClient *_client) aOpenLocalReplay = new QAction(this); aOpenLocalReplay->setIcon(QIcon(":/resources/pencil.svg")); connect(aOpenLocalReplay, SIGNAL(triggered()), this, SLOT(actOpenLocalReplay())); + aDeleteLocalReplay = new QAction(this); + aDeleteLocalReplay->setIcon(QIcon(":/resources/remove_row.svg")); + connect(aDeleteLocalReplay, SIGNAL(triggered()), this, SLOT(actDeleteLocalReplay())); aOpenRemoteReplay = new QAction(this); aOpenRemoteReplay->setIcon(QIcon(":/resources/pencil.svg")); connect(aOpenRemoteReplay, SIGNAL(triggered()), this, SLOT(actOpenRemoteReplay())); @@ -83,11 +88,16 @@ TabReplays::TabReplays(TabSupervisor *_tabSupervisor, AbstractClient *_client) aKeep = new QAction(this); aKeep->setIcon(QIcon(":/resources/lock.svg")); connect(aKeep, SIGNAL(triggered()), this, SLOT(actKeepRemoteReplay())); + aDeleteRemoteReplay = new QAction(this); + aDeleteRemoteReplay->setIcon(QIcon(":/resources/remove_row.svg")); + connect(aDeleteRemoteReplay, SIGNAL(triggered()), this, SLOT(actDeleteRemoteReplay())); leftToolBar->addAction(aOpenLocalReplay); + leftToolBar->addAction(aDeleteLocalReplay); rightToolBar->addAction(aOpenRemoteReplay); rightToolBar->addAction(aDownload); rightToolBar->addAction(aKeep); + rightToolBar->addAction(aDeleteRemoteReplay); retranslateUi(); setLayout(hbox); @@ -101,9 +111,11 @@ void TabReplays::retranslateUi() rightGroupBox->setTitle(tr("Server replay storage")); aOpenLocalReplay->setText(tr("Watch replay")); + aDeleteLocalReplay->setText(tr("Delete")); aOpenRemoteReplay->setText(tr("Watch replay")); aDownload->setText(tr("Download replay")); aKeep->setText(tr("Toggle expiration lock")); + aDeleteLocalReplay->setText(tr("Delete")); } void TabReplays::actOpenLocalReplay() @@ -125,6 +137,15 @@ void TabReplays::actOpenLocalReplay() emit openReplay(replay); } +void TabReplays::actDeleteLocalReplay() +{ + QModelIndex curLeft = localDirView->selectionModel()->currentIndex(); + if (QMessageBox::warning(this, tr("Delete local file"), tr("Are you sure you want to delete \"%1\"?").arg(localDirModel->fileName(curLeft)), QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) + return; + + localDirModel->remove(curLeft); +} + void TabReplays::actOpenRemoteReplay() { ServerInfo_Replay const *curRight = serverDirView->getCurrentReplay(); @@ -214,6 +235,31 @@ void TabReplays::keepRemoteReplayFinished(const Response &r, const CommandContai serverDirView->updateMatchInfo(cmd.game_id(), temp); } +void TabReplays::actDeleteRemoteReplay() +{ + ServerInfo_ReplayMatch const *curRight = serverDirView->getCurrentReplayMatch(); + if (!curRight) + return; + if (QMessageBox::warning(this, tr("Delete remote replay"), tr("Are you sure you want to delete the replay of game %1?").arg(curRight->game_id()), QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) + return; + + Command_ReplayDeleteMatch cmd; + cmd.set_game_id(curRight->game_id()); + + PendingCommand *pend = client->prepareSessionCommand(cmd); + connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(deleteRemoteReplayFinished(Response, CommandContainer))); + client->sendCommand(pend); +} + +void TabReplays::deleteRemoteReplayFinished(const Response &r, const CommandContainer &commandContainer) +{ + if (r.response_code() != Response::RespOk) + return; + + const Command_ReplayDeleteMatch &cmd = commandContainer.session_command(0).GetExtension(Command_ReplayDeleteMatch::ext); + serverDirView->removeMatchInfo(cmd.game_id()); +} + void TabReplays::replayAddedEventReceived(const Event_ReplayAdded &event) { serverDirView->addMatchInfo(event.match_info()); diff --git a/cockatrice/src/tab_replays.h b/cockatrice/src/tab_replays.h index 6ea0c667..dd3e3b0e 100644 --- a/cockatrice/src/tab_replays.h +++ b/cockatrice/src/tab_replays.h @@ -24,10 +24,12 @@ private: RemoteReplayList_TreeWidget *serverDirView; QGroupBox *leftGroupBox, *rightGroupBox; - QAction *aOpenLocalReplay, *aOpenRemoteReplay, *aDownload, *aKeep; + QAction *aOpenLocalReplay, *aDeleteLocalReplay, *aOpenRemoteReplay, *aDownload, *aKeep, *aDeleteRemoteReplay; private slots: void actOpenLocalReplay(); + void actDeleteLocalReplay(); + void actOpenRemoteReplay(); void openRemoteReplayFinished(const Response &r); @@ -37,6 +39,9 @@ private slots: void actKeepRemoteReplay(); void keepRemoteReplayFinished(const Response &r, const CommandContainer &commandContainer); + void actDeleteRemoteReplay(); + void deleteRemoteReplayFinished(const Response &r, const CommandContainer &commandContainer); + void replayAddedEventReceived(const Event_ReplayAdded &event); signals: void openReplay(GameReplay *replay); diff --git a/cockatrice/translations/cockatrice_de.ts b/cockatrice/translations/cockatrice_de.ts index 89a85bab..ec6096fe 100644 --- a/cockatrice/translations/cockatrice_de.ts +++ b/cockatrice/translations/cockatrice_de.ts @@ -5160,7 +5160,7 @@ Lokale Version ist %1, Serverversion ist %2. - + Number: Anzahl: @@ -5175,27 +5175,27 @@ Lokale Version ist %1, Serverversion ist %2. Oberste Karten ins Exil schicken - + Set power/toughness Kampfwerte setzen - + Please enter the new PT: Bitte die neuen Kampfwerte eingeben: - + Set annotation Hinweis setzen - + Please enter the new annotation: Bitte den Hinweis eingeben: - + Set counters Setze Zählmarken @@ -5743,66 +5743,83 @@ Bitte überprüfen Sie, dass Sie Schreibrechte in dem Verzeichnis haben, und ver TabDeckStorage - + Local file system Lokales Dateisystem - + Server deck storage Deckspeicherplatz auf dem Server - - + + Open in deck editor Im Deckeditor öffnen - + Upload deck Deck hochladen - + Download deck Deck herunterladen - - + + New folder Neuer Ordner - + + Delete Löschen - + Enter deck name Decknamen eingeben - + This decklist does not have a name. Please enter a name: Diese Deckliste hat keinen Namen. Bitte geben Sie einen Namen ein: - + Unnamed deck Unbenanntes Deck - + + Delete local file + Lokale Datei löschen + + + + + Are you sure you want to delete "%1"? + Sind Sie sicher, dass Sie "%1" löschen möchten? + + + Name of new folder: Name für den neuen Ordner: - + + Delete remote deck + Deck auf dem Server löschen + + + Deck storage Deckspeicherplatz @@ -6023,33 +6040,59 @@ Bitte geben Sie einen Namen ein: TabReplays - + Local file system Lokales Dateisystem - + Server replay storage Replay-Speicherplatz auf dem Server - - + + Watch replay Replay abspielen - + + + Delete + Löschen + + + Download replay Replay herunterladen - + Toggle expiration lock automatische Löschung umschalten - + + Delete local file + Lokale Datei löschen + + + + Are you sure you want to delete "%1"? + Sind Sie sicher, dass Sie "%1" löschen möchten? + + + + Delete remote replay + Replay auf dem Server löschen + + + + Are you sure you want to delete the replay of game %1? + Sind Sie sicher, dass Sie das Replay des Spiels %1 löschen möchten? + + + Game replays Replays diff --git a/common/pb/CMakeLists.txt b/common/pb/CMakeLists.txt index 033008bd..e109a58b 100644 --- a/common/pb/CMakeLists.txt +++ b/common/pb/CMakeLists.txt @@ -31,6 +31,7 @@ SET(PROTO_FILES command_mulligan.proto command_next_turn.proto command_ready_start.proto + command_replay_delete_match.proto command_replay_list.proto command_replay_download.proto command_replay_modify_match.proto diff --git a/common/pb/session_commands.proto b/common/pb/session_commands.proto index 9c2af4e6..bbb5e81d 100644 --- a/common/pb/session_commands.proto +++ b/common/pb/session_commands.proto @@ -19,6 +19,7 @@ message SessionCommand { REPLAY_LIST = 1100; REPLAY_DOWNLOAD = 1101; REPLAY_MODIFY_MATCH = 1102; + REPLAY_DELETE_MATCH = 1103; } extensions 100 to max; } diff --git a/common/server_protocolhandler.cpp b/common/server_protocolhandler.cpp index 06df1df6..0be4ac76 100644 --- a/common/server_protocolhandler.cpp +++ b/common/server_protocolhandler.cpp @@ -21,6 +21,7 @@ #include "pb/command_replay_list.pb.h" #include "pb/command_replay_download.pb.h" #include "pb/command_replay_modify_match.pb.h" +#include "pb/command_replay_delete_match.pb.h" #include "pb/response.pb.h" #include "pb/response_login.pb.h" #include "pb/response_list_users.pb.h" @@ -149,6 +150,7 @@ Response::ResponseCode Server_ProtocolHandler::processSessionCommandContainer(co case SessionCommand::REPLAY_LIST: resp = cmdReplayList(sc.GetExtension(Command_ReplayList::ext), rc); break; case SessionCommand::REPLAY_DOWNLOAD: resp = cmdReplayDownload(sc.GetExtension(Command_ReplayDownload::ext), rc); break; case SessionCommand::REPLAY_MODIFY_MATCH: resp = cmdReplayModifyMatch(sc.GetExtension(Command_ReplayModifyMatch::ext), rc); break; + case SessionCommand::REPLAY_DELETE_MATCH: resp = cmdReplayDeleteMatch(sc.GetExtension(Command_ReplayDeleteMatch::ext), rc); break; case SessionCommand::GET_GAMES_OF_USER: resp = cmdGetGamesOfUser(sc.GetExtension(Command_GetGamesOfUser::ext), rc); break; case SessionCommand::GET_USER_INFO: resp = cmdGetUserInfo(sc.GetExtension(Command_GetUserInfo::ext), rc); break; case SessionCommand::LIST_ROOMS: resp = cmdListRooms(sc.GetExtension(Command_ListRooms::ext), rc); break; diff --git a/common/server_protocolhandler.h b/common/server_protocolhandler.h index d17e06a4..4f7fd8e4 100644 --- a/common/server_protocolhandler.h +++ b/common/server_protocolhandler.h @@ -43,6 +43,7 @@ class Command_DeckUpload; class Command_ReplayList; class Command_ReplayDownload; class Command_ReplayModifyMatch; +class Command_ReplayDeleteMatch; class Command_ListRooms; class Command_JoinRoom; class Command_LeaveRoom; @@ -84,6 +85,7 @@ private: virtual Response::ResponseCode cmdReplayList(const Command_ReplayList &cmd, ResponseContainer &rc) = 0; virtual Response::ResponseCode cmdReplayDownload(const Command_ReplayDownload &cmd, ResponseContainer &rc) = 0; virtual Response::ResponseCode cmdReplayModifyMatch(const Command_ReplayModifyMatch &cmd, ResponseContainer &rc) = 0; + virtual Response::ResponseCode cmdReplayDeleteMatch(const Command_ReplayDeleteMatch &cmd, ResponseContainer &rc) = 0; Response::ResponseCode cmdGetGamesOfUser(const Command_GetGamesOfUser &cmd, ResponseContainer &rc); Response::ResponseCode cmdGetUserInfo(const Command_GetUserInfo &cmd, ResponseContainer &rc); Response::ResponseCode cmdListRooms(const Command_ListRooms &cmd, ResponseContainer &rc); diff --git a/servatrice/src/serversocketinterface.cpp b/servatrice/src/serversocketinterface.cpp index cd92a2e5..847daa3b 100644 --- a/servatrice/src/serversocketinterface.cpp +++ b/servatrice/src/serversocketinterface.cpp @@ -37,6 +37,7 @@ #include "pb/command_replay_list.pb.h" #include "pb/command_replay_download.pb.h" #include "pb/command_replay_modify_match.pb.h" +#include "pb/command_replay_delete_match.pb.h" #include "pb/event_connection_closed.pb.h" #include "pb/event_server_message.pb.h" #include "pb/event_server_identification.pb.h" @@ -480,7 +481,7 @@ Response::ResponseCode ServerSocketInterface::cmdReplayList(const Command_Replay servatrice->dbMutex.lock(); QSqlQuery query1; - query1.prepare("select a.id_game, a.replay_name, b.room_name, b.time_started, b.time_finished, b.descr, a.do_not_hide from cockatrice_replays_access a left join cockatrice_games b on b.id = a.id_game where a.id_player = :id_player and (a.do_not_hide = 1 or date_add(b.time_started, interval 14 day) > now())"); + query1.prepare("select a.id_game, a.replay_name, b.room_name, b.time_started, b.time_finished, b.descr, a.do_not_hide from cockatrice_replays_access a left join cockatrice_games b on b.id = a.id_game where a.id_player = :id_player and (a.do_not_hide = 1 or date_add(b.time_started, interval 7 day) > now())"); query1.bindValue(":id_player", userInfo->id()); servatrice->execSqlQuery(query1); while (query1.next()) { @@ -570,6 +571,22 @@ Response::ResponseCode ServerSocketInterface::cmdReplayModifyMatch(const Command return servatrice->execSqlQuery(query1) ? Response::RespOk : Response::RespNameNotFound; } +Response::ResponseCode ServerSocketInterface::cmdReplayDeleteMatch(const Command_ReplayDeleteMatch &cmd, ResponseContainer & /*rc*/) +{ + if (authState != PasswordRight) + return Response::RespFunctionNotAllowed; + + QMutexLocker dbLocker(&servatrice->dbMutex); + + QSqlQuery query1; + query1.prepare("delete from " + servatrice->getDbPrefix() + "_replays_access where id_player = :id_player and id_game = :id_game"); + query1.bindValue(":id_player", userInfo->id()); + query1.bindValue(":id_game", cmd.game_id()); + + servatrice->execSqlQuery(query1); + return query1.numRowsAffected() > 0 ? Response::RespOk: Response::RespNameNotFound; +} + // MODERATOR FUNCTIONS. // May be called by admins and moderators. Permission is checked by the calling function. diff --git a/servatrice/src/serversocketinterface.h b/servatrice/src/serversocketinterface.h index 7e04b9a5..0502c583 100644 --- a/servatrice/src/serversocketinterface.h +++ b/servatrice/src/serversocketinterface.h @@ -64,6 +64,7 @@ private: Response::ResponseCode cmdReplayList(const Command_ReplayList &cmd, ResponseContainer &rc); Response::ResponseCode cmdReplayDownload(const Command_ReplayDownload &cmd, ResponseContainer &rc); Response::ResponseCode cmdReplayModifyMatch(const Command_ReplayModifyMatch &cmd, ResponseContainer &rc); + Response::ResponseCode cmdReplayDeleteMatch(const Command_ReplayDeleteMatch &cmd, ResponseContainer &rc); Response::ResponseCode cmdBanFromServer(const Command_BanFromServer &cmd, ResponseContainer &rc); Response::ResponseCode cmdShutdownServer(const Command_ShutdownServer &cmd, ResponseContainer &rc); Response::ResponseCode cmdUpdateServerMessage(const Command_UpdateServerMessage &cmd, ResponseContainer &rc);