diff --git a/src/client/client.cpp b/src/client/client.cpp index 547c10a1..7e4b4096 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -119,13 +119,13 @@ void Client::setLoginInfo(const QString &username, const QString &password) { void Client::replyToServer(const QString &command, const QString &jsonData) { int type = Router::TYPE_REPLY | Router::SRC_CLIENT | Router::DEST_SERVER; - router->reply(type, command, jsonData); + router->reply(type, command.toUtf8(), jsonData.toUtf8()); } void Client::notifyServer(const QString &command, const QString &jsonData) { int type = Router::TYPE_NOTIFICATION | Router::SRC_CLIENT | Router::DEST_SERVER; - router->notify(type, command, jsonData); + router->notify(type, command.toUtf8(), jsonData.toUtf8()); } void Client::callLua(const QString& command, const QString& json_data, bool isRequest) { diff --git a/src/core/c-wrapper.h b/src/core/c-wrapper.h index aa3cdc5f..64b74f8d 100644 --- a/src/core/c-wrapper.h +++ b/src/core/c-wrapper.h @@ -35,7 +35,8 @@ class Lua { class Sqlite3 { public: - Sqlite3(const QString &filename = "./server/users.db", const QString &initSql = "./server/init.sql"); + Sqlite3(const QString &filename = QStringLiteral("./server/users.db"), + const QString &initSql = QStringLiteral("./server/init.sql")); ~Sqlite3(); static bool checkString(const QString &str); diff --git a/src/core/packman.cpp b/src/core/packman.cpp index 7359f2c4..f7bd6e4c 100644 --- a/src/core/packman.cpp +++ b/src/core/packman.cpp @@ -277,7 +277,7 @@ int PackMan::clone(const QString &u) { QString fileName = QUrl(url).fileName(); if (fileName.endsWith(".git")) fileName.chop(4); - fileName = "packages/" + fileName; + fileName = QStringLiteral("packages/") + fileName; git_clone_options opt = GIT_CLONE_OPTIONS_INIT; opt.fetch_opts.callbacks.transfer_progress = transfer_progress_cb; diff --git a/src/freekill.cpp b/src/freekill.cpp index 597cb17f..2fc44e1c 100644 --- a/src/freekill.cpp +++ b/src/freekill.cpp @@ -352,15 +352,15 @@ int freekill_main(int argc, char *argv[]) { QString system; #if defined(Q_OS_ANDROID) - system = "Android"; + system = QStringLiteral("Android"); #elif defined(Q_OS_WIN32) qputenv("QT_MEDIA_BACKEND", "windows"); - system = "Win"; + system = QStringLiteral("Win"); ::system("chcp 65001"); #elif defined(Q_OS_LINUX) - system = "Linux"; + system = QStringLiteral("Linux"); #else - system = "Other"; + system = QStringLiteral("Other"); #endif root->setContextProperty("OS", system); diff --git a/src/network/client_socket.cpp b/src/network/client_socket.cpp index 5c18cacf..89fef47d 100644 --- a/src/network/client_socket.cpp +++ b/src/network/client_socket.cpp @@ -57,7 +57,7 @@ void ClientSocket::send(const QByteArray &msg) { QByteArray _msg; if (msg.length() >= 1024) { auto comp = qCompress(msg); - _msg = "Compressed" + comp.toBase64(); + _msg = QByteArrayLiteral("Compressed") + comp.toBase64(); _msg = aesEnc(_msg) + "\n"; } else { _msg = aesEnc(msg) + "\n"; diff --git a/src/network/client_socket.h b/src/network/client_socket.h index f084226f..155423bc 100644 --- a/src/network/client_socket.h +++ b/src/network/client_socket.h @@ -43,7 +43,7 @@ class ClientSocket : public QObject { ClientSocket(QTcpSocket *socket); /// 客户端使用,用于连接到远程服务器 - void connectToHost(const QString &address = "127.0.0.1", ushort port = 9527u); + void connectToHost(const QString &address = QStringLiteral("127.0.0.1"), ushort port = 9527u); /// 双端都可使用。禁用加密传输并断开TCP连接。 void disconnectFromHost(); /// 设置AES密钥,同时启用加密传输。 diff --git a/src/network/router.cpp b/src/network/router.cpp index 970d904f..9b57b8ee 100644 --- a/src/network/router.cpp +++ b/src/network/router.cpp @@ -48,7 +48,7 @@ void Router::setReplyReadySemaphore(QSemaphore *semaphore) { extraReplyReadySemaphore = semaphore; } -void Router::request(int type, const QString &command, const QString &jsonData, +void Router::request(int type, const QByteArray &command, const QByteArray &jsonData, int timeout, qint64 timestamp) { // In case a request is called without a following waitForReply call if (replyReadySemaphore.available() > 0) @@ -61,36 +61,36 @@ void Router::request(int type, const QString &command, const QString &jsonData, expectedReplyId = requestId; replyTimeout = timeout; requestStartTime = QDateTime::currentDateTime(); - m_reply = "__notready"; + m_reply = QStringLiteral("__notready"); replyMutex.unlock(); QJsonArray body; body << requestId; body << type; - body << command; - body << jsonData; + body << command.constData(); + body << jsonData.constData(); body << timeout; body << (timestamp <= 0 ? requestStartTime.toMSecsSinceEpoch() : timestamp); emit messageReady(JsonArray2Bytes(body)); } -void Router::reply(int type, const QString &command, const QString &jsonData) { +void Router::reply(int type, const QByteArray &command, const QByteArray &jsonData) { QJsonArray body; body << this->requestId; body << type; - body << command; - body << jsonData; + body << command.constData(); + body << jsonData.constData(); emit messageReady(JsonArray2Bytes(body)); } -void Router::notify(int type, const QString &command, const QString &jsonData) { +void Router::notify(int type, const QByteArray &command, const QByteArray &jsonData) { QJsonArray body; body << -2; // requestId = -2 mean this is for notification body << type; - body << command; - body << jsonData; + body << command.constData(); + body << jsonData.constData(); emit messageReady(JsonArray2Bytes(body)); } diff --git a/src/network/router.h b/src/network/router.h index 3992aab6..e2faa91c 100644 --- a/src/network/router.h +++ b/src/network/router.h @@ -45,10 +45,10 @@ class Router : public QObject { void setReplyReadySemaphore(QSemaphore *semaphore); - void request(int type, const QString &command, - const QString &jsonData, int timeout, qint64 timestamp = -1); - void reply(int type, const QString &command, const QString &jsonData); - void notify(int type, const QString &command, const QString &jsonData); + void request(int type, const QByteArray &command, + const QByteArray &jsonData, int timeout, qint64 timestamp = -1); + void reply(int type, const QByteArray &command, const QByteArray &jsonData); + void notify(int type, const QByteArray &command, const QByteArray &jsonData); int getTimeout() const; @@ -62,7 +62,6 @@ class Router : public QObject { signals: void messageReady(const QByteArray &message); - void unknownPacket(const QByteArray &packet); void replyReady(); void notification_got(const QString &command, const QString &jsonData); diff --git a/src/server/auth.cpp b/src/server/auth.cpp index 9df6e7e4..49aae906 100644 --- a/src/server/auth.cpp +++ b/src/server/auth.cpp @@ -61,7 +61,7 @@ bool AuthManager::checkClientVersion(ClientSocket *client, const QString &cver) .arg(FK_VERSION, "1"); } - server->sendEarlyPacket(client, "ErrorDlg", errmsg); + server->sendEarlyPacket(client, "ErrorDlg", errmsg.toUtf8()); client->disconnectFromHost(); return false; } @@ -107,7 +107,7 @@ QMap AuthManager::checkPassword(ClientSocket *client, const QS auto server = qobject_cast(parent()); bool passed = false; - QString error_msg; + const char *error_msg = nullptr; QMap obj; int id; QByteArray salt; diff --git a/src/server/lobby.cpp b/src/server/lobby.cpp index 919019db..0560ebce 100644 --- a/src/server/lobby.cpp +++ b/src/server/lobby.cpp @@ -40,7 +40,7 @@ void Lobby::updateAvatar(ServerPlayer *sender, const QString &jsonData) { .arg(sender->getId()); ServerInstance->getDatabase()->exec(sql); sender->setAvatar(avatar); - sender->doNotify("UpdateAvatar", avatar); + sender->doNotify("UpdateAvatar", avatar.toUtf8()); } } @@ -90,7 +90,7 @@ void Lobby::getRoomConfig(ServerPlayer *sender, const QString &jsonData) { if (room) { auto settings = room->getSettings(); // 手搓JSON数组 跳过编码解码 - sender->doNotify("GetRoomConfig", QString("[%1,%2]").arg(roomId).arg(settings)); + sender->doNotify("GetRoomConfig", QString("[%1,%2]").arg(roomId).arg(settings).toUtf8()); } else { sender->doNotify("ErrorMsg", "no such room"); } diff --git a/src/server/room.cpp b/src/server/room.cpp index b89b6eab..b69f98d2 100644 --- a/src/server/room.cpp +++ b/src/server/room.cpp @@ -43,6 +43,12 @@ Room::~Room() { if (gameStarted) { gameOver(); } + for (auto p : players) { + if (p->getId() > 0) removePlayer(p); + } + for (auto p : observers) { + removeObserver(p); + } } int Room::getId() const { return id; } @@ -99,7 +105,7 @@ void Room::addPlayer(ServerPlayer *player) { if (runned_players.contains(player->getId())) { player->doNotify("ErrorMsg", "Running away is shameful."); } - // 此时player仍在lobby中,别管就行了 + // 此时phttps://github.com/fmanlou/qt6printerslayer仍在lobby中,别管就行了 // emit playerRemoved(player); return; } @@ -298,7 +304,7 @@ void Room::delay(int ms) { bool Room::isOutdated() { bool ret = md5 != server->getMd5(); - if (ret) md5 = ""; + if (ret) md5 = QStringLiteral(""); return ret; } @@ -542,14 +548,14 @@ void Room::manuallyStart() { for (auto i = ipList.cbegin(); i != ipList.cend(); i++) { if (i.value().length() <= 1) continue; auto warn = QString("*WARN* Same IP address: [%1]").arg(i.value().join(", ")); - doBroadcastNotify(getPlayers(), "ServerMessage", warn); + doBroadcastNotify(getPlayers(), "ServerMessage", warn.toUtf8()); qInfo("%s", warn.toUtf8().constData()); } for (auto i = uuidList.cbegin(); i != uuidList.cend(); i++) { if (i.value().length() <= 1) continue; auto warn = QString("*WARN* Same device id: [%1]").arg(i.value().join(", ")); - doBroadcastNotify(getPlayers(), "ServerMessage", warn); + doBroadcastNotify(getPlayers(), "ServerMessage", warn.toUtf8()); qInfo("%s", warn.toUtf8().constData()); } diff --git a/src/server/roombase.cpp b/src/server/roombase.cpp index fc257119..3d0b1135 100644 --- a/src/server/roombase.cpp +++ b/src/server/roombase.cpp @@ -26,7 +26,7 @@ ServerPlayer *RoomBase::findPlayer(int id) const { } void RoomBase::doBroadcastNotify(const QList targets, - const QString &command, const QString &jsonData) { + const QByteArray &command, const QByteArray &jsonData) { for (auto p : targets) { p->doNotify(command, jsonData); } diff --git a/src/server/roombase.h b/src/server/roombase.h index ef749949..b2c96501 100644 --- a/src/server/roombase.h +++ b/src/server/roombase.h @@ -13,7 +13,7 @@ class RoomBase : public QObject { ServerPlayer *findPlayer(int id) const; void doBroadcastNotify(const QList targets, - const QString &command, const QString &jsonData); + const QByteArray &command, const QByteArray &jsonData); void chat(ServerPlayer *sender, const QString &jsonData); diff --git a/src/server/roomthread.cpp b/src/server/roomthread.cpp index 8711ba03..e4e8feef 100644 --- a/src/server/roomthread.cpp +++ b/src/server/roomthread.cpp @@ -67,7 +67,7 @@ bool RoomThread::isOutdated() { if (ret) { // 让以后每次都outdate // 不然反复disable/enable的情况下会出乱子 - md5 = ""; + md5 = QStringLiteral(""); } return ret; } diff --git a/src/server/server.cpp b/src/server/server.cpp index bc8c5d5a..f9c779c2 100644 --- a/src/server/server.cpp +++ b/src/server/server.cpp @@ -168,32 +168,32 @@ void Server::updateRoomList(ServerPlayer *teller) { arr.prepend(v); } auto jsonData = JsonArray2Bytes(arr); - teller->doNotify("UpdateRoomList", QString(jsonData)); + teller->doNotify("UpdateRoomList", jsonData); } void Server::updateOnlineInfo() { lobby()->doBroadcastNotify(lobby()->getPlayers(), "UpdatePlayerNum", - QString(JsonArray2Bytes(QJsonArray({ + JsonArray2Bytes(QJsonArray({ lobby()->getPlayers().length(), this->players.count(), - })))); + }))); } Sqlite3 *Server::getDatabase() { return db; } -void Server::broadcast(const QString &command, const QString &jsonData) { +void Server::broadcast(const QByteArray &command, const QByteArray &jsonData) { for (ServerPlayer *p : players.values()) { p->doNotify(command, jsonData); } } -void Server::sendEarlyPacket(ClientSocket *client, const QString &type, const QString &msg) { +void Server::sendEarlyPacket(ClientSocket *client, const QByteArray &type, const QByteArray &msg) { QJsonArray body; body << -2; body << (Router::TYPE_NOTIFICATION | Router::SRC_SERVER | Router::DEST_CLIENT); - body << type; - body << msg; + body << type.constData(); + body << msg.constData(); client->send(JsonArray2Bytes(body)); } @@ -222,7 +222,7 @@ void Server::processNewConnection(ClientSocket *client) { // check ban ip auto result = db->select(QString("SELECT * FROM banip WHERE ip='%1';").arg(addr)); - auto errmsg = QString(); + const char *errmsg = nullptr; if (!result.isEmpty()) { errmsg = "you have been banned!"; @@ -232,7 +232,7 @@ void Server::processNewConnection(ClientSocket *client) { errmsg = "server is full!"; } - if (!errmsg.isEmpty()) { + if (errmsg) { sendEarlyPacket(client, "ErrorDlg", errmsg); qInfo() << "Refused banned IP:" << addr; client->disconnectFromHost(); @@ -243,7 +243,7 @@ void Server::processNewConnection(ClientSocket *client) { [client]() { qInfo() << client->peerAddress() << "disconnected"; }); // network delay test - sendEarlyPacket(client, "NetworkDelayTest", auth->getPublicKey()); + sendEarlyPacket(client, "NetworkDelayTest", auth->getPublicKey().toUtf8()); // Note: the client should send a setup string next connect(client, &ClientSocket::message_got, this, &Server::processRequest); client->timerSignup.start(30000); @@ -295,7 +295,7 @@ void Server::processRequest(const QByteArray &msg) { auto md5_str = arr[2].toString(); if (md5 != md5_str) { sendEarlyPacket(client, "ErrorMsg", "MD5 check failed!"); - sendEarlyPacket(client, "UpdatePackage", Pacman->getPackSummary()); + sendEarlyPacket(client, "UpdatePackage", Pacman->getPackSummary().toUtf8()); client->disconnectFromHost(); return; } @@ -333,7 +333,7 @@ void Server::processRequest(const QByteArray &msg) { player->setId(id); player->setUuid(uuid_str); if (players.count() <= 10) { - broadcast("ServerMessage", tr("%1 logged in").arg(player->getScreenName())); + broadcast("ServerMessage", tr("%1 logged in").arg(player->getScreenName()).toUtf8()); } players.insert(player->getId(), player); @@ -354,7 +354,7 @@ void Server::processRequest(const QByteArray &msg) { void Server::readConfig() { QFile file("freekill.server.config.json"); - QByteArray json = "{}"; + QByteArray json = QByteArrayLiteral("{}"); if (file.open(QIODevice::ReadOnly)) { json = file.readAll(); } diff --git a/src/server/server.h b/src/server/server.h index cd38a85a..bc18f2b9 100644 --- a/src/server/server.h +++ b/src/server/server.h @@ -61,7 +61,7 @@ class Server : public QObject { @param settings 表示JSON对象的字符串,用作房间配置 */ void createRoom(ServerPlayer *owner, const QString &name, int capacity, - int timeout = 15, const QByteArray &settings = "{}"); + int timeout = 15, const QByteArray &settings = QByteArrayLiteral("{}")); void removeRoom(int id); /// 单纯从表中删除指针 内存由对应thread管理 @@ -78,8 +78,8 @@ class Server : public QObject { Sqlite3 *getDatabase(); - void broadcast(const QString &command, const QString &jsonData); - void sendEarlyPacket(ClientSocket *client, const QString &type, const QString &msg); + void broadcast(const QByteArray &command, const QByteArray &jsonData); + void sendEarlyPacket(ClientSocket *client, const QByteArray &type, const QByteArray &msg); void setupPlayer(ServerPlayer *player, bool all_info = true); bool isListening; diff --git a/src/server/serverplayer.cpp b/src/server/serverplayer.cpp index ef1eaa33..58d4e73e 100644 --- a/src/server/serverplayer.cpp +++ b/src/server/serverplayer.cpp @@ -89,7 +89,7 @@ void ServerPlayer::setRoom(RoomBase *room) { this->room = room; } void ServerPlayer::speak(const QString &message) { ; } -void ServerPlayer::doRequest(const QString &command, const QString &jsonData, +void ServerPlayer::doRequest(const QByteArray &command, const QByteArray &jsonData, int timeout, qint64 timestamp) { if (getState() != Player::Online) return; @@ -105,14 +105,14 @@ QString ServerPlayer::waitForReply(int timeout) { #ifndef QT_DEBUG QThread::sleep(1); #endif - ret = "__cancel"; + ret = QStringLiteral("__cancel"); } else { ret = router->waitForReply(timeout); } return ret; } -void ServerPlayer::doNotify(const QString &command, const QString &jsonData) { +void ServerPlayer::doNotify(const QByteArray &command, const QByteArray &jsonData) { if (getState() != Player::Online) return; int type = @@ -139,7 +139,7 @@ void ServerPlayer::kick() { void ServerPlayer::reconnect(ClientSocket *client) { if (server->getPlayers().count() <= 10) { - server->broadcast("ServerMessage", tr("%1 backed").arg(getScreenName())); + server->broadcast("ServerMessage", tr("%1 backed").arg(getScreenName()).toUtf8()); } setState(Player::Online); @@ -213,7 +213,7 @@ void ServerPlayer::onStateChanged() { auto state = getState(); room->doBroadcastNotify(room->getPlayers(), "NetStateChanged", - QString("[%1,\"%2\"]").arg(getId()).arg(getStateString())); + QString("[%1,\"%2\"]").arg(getId()).arg(getStateString()).toUtf8()); if (state == Player::Online) { resumeGameTimer(); @@ -225,14 +225,14 @@ void ServerPlayer::onStateChanged() { void ServerPlayer::onReadyChanged() { if (room && !room->isLobby()) { room->doBroadcastNotify(room->getPlayers(), "ReadyChanged", - QString("[%1,%2]").arg(getId()).arg(isReady())); + QString("[%1,%2]").arg(getId()).arg(isReady()).toUtf8()); } } void ServerPlayer::onDisconnected() { qInfo() << "Player" << getId() << "disconnected"; if (server->getPlayers().count() <= 10) { - server->broadcast("ServerMessage", tr("%1 logged out").arg(getScreenName())); + server->broadcast("ServerMessage", tr("%1 logged out").arg(getScreenName()).toUtf8());; } auto _room = getRoom(); diff --git a/src/server/serverplayer.h b/src/server/serverplayer.h index 55b5da1e..6cb9d72e 100644 --- a/src/server/serverplayer.h +++ b/src/server/serverplayer.h @@ -31,11 +31,11 @@ class ServerPlayer : public Player { void speak(const QString &message); - void doRequest(const QString &command, - const QString &jsonData, int timeout = -1, qint64 timestamp = -1); + void doRequest(const QByteArray &command, + const QByteArray &jsonData, int timeout = -1, qint64 timestamp = -1); void abortRequest(); QString waitForReply(int timeout); - void doNotify(const QString &command, const QString &jsonData); + void doNotify(const QByteArray &command, const QByteArray &jsonData); void prepareForRequest(const QString &command, const QString &data); diff --git a/src/server/shell.cpp b/src/server/shell.cpp index b7509592..13e0049a 100644 --- a/src/server/shell.cpp +++ b/src/server/shell.cpp @@ -197,7 +197,7 @@ void Shell::msgCommand(QStringList &list) { } auto msg = list.join(' '); - ServerInstance->broadcast("ServerMessage", msg); + ServerInstance->broadcast("ServerMessage", msg.toUtf8()); } static void banAccount(Sqlite3 *db, const QString &name, bool banned) { diff --git a/src/swig/freekill.i b/src/swig/freekill.i index 83ee1fb3..be8e0ae5 100644 --- a/src/swig/freekill.i +++ b/src/swig/freekill.i @@ -8,7 +8,6 @@ #include "client/client.h" #include "server/server.h" #include "server/serverplayer.h" -#include "client/clientplayer.h" #include "server/room.h" #include "server/roomthread.h" #include "ui/qmlbackend.h" diff --git a/src/swig/naturalvar.i b/src/swig/naturalvar.i index 9c7fb9f3..48c5b53a 100644 --- a/src/swig/naturalvar.i +++ b/src/swig/naturalvar.i @@ -88,8 +88,8 @@ QVariant Lua::readValue(lua_State *L, int index, QHash stack case LUA_TTABLE: { auto p = lua_topointer(L, index); if (stack[p]) { - luaL_error(L, "circular reference detected"); - return QVariant(); // won't return + qCritical("circular reference detected"); + return QVariant(); } stack[p] = true; @@ -104,7 +104,7 @@ QVariant Lua::readValue(lua_State *L, int index, QHash stack lua_pushnil(L); while (lua_next(L, index) != 0) { if (lua_type(L, -2) != LUA_TSTRING) { - luaL_error(L, "key of object must be string"); + qCritical("key of object must be string"); return QVariant(); } @@ -135,9 +135,9 @@ QVariant Lua::readValue(lua_State *L, int index, QHash stack // ignore function, userdata and thread default: - luaL_error(L, "unexpected value type %s", lua_typename(L, tp)); + qCritical("unexpected value type %s", lua_typename(L, tp)); } - return QVariant(); // won't return + return QVariant(); } %} @@ -156,7 +156,6 @@ SWIG_arg ++; %typemap(out) QString %{ - // FIXME: 这里针对高频出现的字符串减少toUtf8调用避免创建新的bytearray... if ($1.isEmpty()) { lua_pushstring(L, ""); } else if ($1 == "__notready") { @@ -188,7 +187,7 @@ SWIG_arg ++; %} // 解决函数重载中类型检测问题 -%typecheck(SWIG_TYPECHECK_STRING) QString, QString const& { +%typecheck(SWIG_TYPECHECK_STRING) QString, QString const&, QByteArray, QByteArray const& { $1 = lua_isstring(L,$input); } @@ -238,9 +237,10 @@ SWIG_arg++; %typemap(arginit) QByteArray const & "QByteArray $1_str;" -%typemap(in, checkfn = "lua_isstring") QByteArray const & +%typemap(in, checkfn = "lua_isstring") QByteArray const & (const char * temp) %{ - $1_str = QByteArray(lua_tostring(L, $input)); + temp = lua_tostring(L, $input); + $1_str = QByteArray::fromRawData(temp, strlen(temp)); $1 = &$1_str; %} diff --git a/src/swig/qml-nogui.i b/src/swig/qml-nogui.i deleted file mode 100644 index 90dc7373..00000000 --- a/src/swig/qml-nogui.i +++ /dev/null @@ -1,12 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -%nodefaultctor QmlBackend; -%nodefaultdtor QmlBackend; -class QmlBackend : public QObject { -public: - static void cd(const QString &path); - static QStringList ls(const QString &dir); - static QString pwd(); - static bool exists(const QString &file); - static bool isDir(const QString &file); -}; diff --git a/src/swig/qt.i b/src/swig/qt.i index f573fc2b..e464a2d0 100644 --- a/src/swig/qt.i +++ b/src/swig/qt.i @@ -3,15 +3,12 @@ // Make the base classes look like "complete" %nodefaultctor QObject; -%nodefaultdtor QObject; class QObject {}; %nodefaultctor QThread; -%nodefaultdtor QThread; class QThread {}; %nodefaultctor QList; -%nodefaultdtor QList; template class QList { public: diff --git a/src/swig/server.i b/src/swig/server.i index dc252c05..beef256e 100644 --- a/src/swig/server.i +++ b/src/swig/server.i @@ -53,10 +53,10 @@ public: %nodefaultdtor ServerPlayer; class ServerPlayer : public Player { public: - void doRequest(const QString &command, - const QString &json_data, int timeout, long long timestamp = -1); + void doRequest(const QByteArray &command, + const QByteArray &json_data, int timeout, long long timestamp = -1); QString waitForReply(int timeout); - void doNotify(const QString &command, const QString &json_data); + void doNotify(const QByteArray &command, const QByteArray &json_data); bool thinking(); void setThinking(bool t); diff --git a/src/ui/qmlbackend.h b/src/ui/qmlbackend.h index ef20c3d8..eaf204a5 100644 --- a/src/ui/qmlbackend.h +++ b/src/ui/qmlbackend.h @@ -15,7 +15,7 @@ class QmlBackend : public QObject { // File used by both Lua and Qml static Q_INVOKABLE void cd(const QString &path); - static Q_INVOKABLE QStringList ls(const QString &dir = ""); + static Q_INVOKABLE QStringList ls(const QString &dir = QStringLiteral("")); static Q_INVOKABLE QString pwd(); static Q_INVOKABLE bool exists(const QString &file); static Q_INVOKABLE bool isDir(const QString &file);