comment all not working code

This commit is contained in:
Andrei Yankovich 2020-10-23 14:33:12 +03:00
parent 69a08cf489
commit aaa8a1bf80
6 changed files with 76 additions and 74 deletions

View File

@ -13,36 +13,36 @@
HanoiServer::HanoiServer() {
QString address = DEFAULT_ADDRESS;
unsigned short port = DEFAULT_HANOI_PORT;
// QString address = DEFAULT_ADDRESS;
// unsigned short port = DEFAULT_HANOI_PORT;
if (QuasarAppUtils::Params::isEndable("address")) {
auto addressList = QuasarAppUtils::Params::getStrArg("address").split(":");
if (address.size() != 2) {
// if (QuasarAppUtils::Params::isEndable("address")) {
// auto addressList = QuasarAppUtils::Params::getStrArg("address").split(":");
// if (address.size() != 2) {
QuasarAppUtils::Params::log("invalid address params",
QuasarAppUtils::Error);
QCoreApplication ::exit(2);
// QuasarAppUtils::Params::log("invalid address params",
// QuasarAppUtils::Error);
// QCoreApplication ::exit(2);
}
// }
address = addressList.first();
port = static_cast<decltype (port)>(addressList.last().toInt());
}
// address = addressList.first();
// port = static_cast<decltype (port)>(addressList.last().toInt());
// }
if (!run(address, port)) {
QuasarAppUtils::Params::log("fail to run server",
QuasarAppUtils::Error);
QCoreApplication ::exit(3);
// if (!run(address, port)) {
// QuasarAppUtils::Params::log("fail to run server",
// QuasarAppUtils::Error);
// QCoreApplication ::exit(3);
}
// }
}
QVariantMap HanoiServer::defaultDbParams() const {
return {
{"DBDriver", "QSQLITE"},
{"DBFilePath", DEFAULT_DB_PATH},
{"DBInitFile", DEFAULT_DB_INIT_FILE_PATH}
};
}
//QVariantMap HanoiServer::defaultDbParams() const {
// return {
// {"DBDriver", "QSQLITE"},
// {"DBFilePath", DEFAULT_DB_PATH},
// {"DBInitFile", DEFAULT_DB_INIT_FILE_PATH}
// };
//}

View File

@ -5,15 +5,12 @@
#define DEFAULT_HANOI_PORT 7770
#include <quasarapp.h>
#include <ratingusernode.h>
class HanoiServer: public NP::RatingUserNode
class HanoiServer
{
Q_OBJECT
// Q_OBJECT
public:
HanoiServer();
QVariantMap defaultDbParams() const override;
};
#endif // SNAKESERVER_H

View File

@ -35,8 +35,8 @@ BackEnd::BackEnd(QQmlApplicationEngine *engine):
init();
setProfile(_settings->getStrValue(CURRENT_PROFILE_KEY, DEFAULT_USER));
connect(&_client, &HanoiClient::statusChanged,
this, &BackEnd::handleLogined);
// connect(&_client, &HanoiClient::statusChanged,
// this, &BackEnd::handleLogined);
_loginModel = new LoginView::LVMainModel("userLogin");
_loginModel->setComponents(LoginView::Nickname);
@ -48,8 +48,8 @@ BackEnd::BackEnd(QQmlApplicationEngine *engine):
connect(_loginModel , &LoginView::LVMainModel::sigRegisterRequest,
this, &BackEnd::handleOnlineRequest);
connect(&_client , &HanoiClient::requestError,
this, &BackEnd::handleOnlineRequestError);
// connect(&_client , &HanoiClient::requestError,
// this, &BackEnd::handleOnlineRequestError);
}
@ -204,11 +204,11 @@ void BackEnd::handleOnlineRequestfromProfile(const QString &name) {
void BackEnd::handleOnlineRequest(const LoginView::UserData & user) {
if (!_client.login(user.nickname(), user.rawPassword().toLatin1())) {
QmlNotificationService::NotificationService::getService()->setNotify(
tr("Register online error"), tr("Failed to register this account, if this account was created by you, try to restore it."), "",
QmlNotificationService::NotificationData::Error);
}
// if (!_client.login(user.nickname(), user.rawPassword().toLatin1())) {
// QmlNotificationService::NotificationService::getService()->setNotify(
// tr("Register online error"), tr("Failed to register this account, if this account was created by you, try to restore it."), "",
// QmlNotificationService::NotificationData::Error);
// }
}
@ -218,10 +218,10 @@ void BackEnd::handleOnlineRequestError(const QString &) {
void BackEnd::handleLogined(int state) {
if (state == 2) {
auto logineduser = _client.user();
_profileList[logineduser->mail()]->update(logineduser.data());
}
// if (state == 2) {
// auto logineduser = _client.user();
// _profileList[logineduser->mail()]->update(logineduser.data());
// }
}
bool BackEnd::randomColor() const {
@ -293,7 +293,7 @@ QObject* BackEnd::gameState() {
}
QObject *BackEnd::onlineStatus() {
return &_client;
return nullptr;// &_client;
}
bool BackEnd::isOnline(const QString &name) {
@ -340,16 +340,16 @@ void BackEnd::setProfile(QString profile) {
auto profileData = dynamic_cast<ProfileData*>(profileObject());
if (profileData->isOnline()) {
_client.setUser(profileData->userData());
if (!_client.login()) {
QmlNotificationService::NotificationService::getService()->setNotify(
tr("Login failed"),
tr("Failed to login %0, if this account was created by you, try to restore it.").arg(_profile),
"",
QmlNotificationService::NotificationData::Warning);
}
}
// if (profileData->isOnline()) {
// _client.setUser(profileData->userData());
// if (!_client.login()) {
// QmlNotificationService::NotificationService::getService()->setNotify(
// tr("Login failed"),
// tr("Failed to login %0, if this account was created by you, try to restore it.").arg(_profile),
// "",
// QmlNotificationService::NotificationData::Warning);
// }
// }
emit profileChanged(_profile);
}
@ -368,11 +368,11 @@ void BackEnd::setReward(int revard) {
void BackEnd::removeOnlineProfile(QString) {
// not supported
if (!_client.removeProfile()) {
// if (!_client.removeProfile()) {
QmlNotificationService::NotificationService::getService()->setNotify(
tr("Remove online error"), tr("current profile not online!"), "",
QmlNotificationService::NotificationData::Warning);
}
// QmlNotificationService::NotificationService::getService()->setNotify(
// tr("Remove online error"), tr("current profile not online!"), "",
// QmlNotificationService::NotificationData::Warning);
// }
}

View File

@ -7,20 +7,18 @@
#include "hanoiclient.h"
#include <qmlnotifyservice.h>
#include <userrequest.h>
HanoiClient::HanoiClient():
NP::Client(REMOTE_HOST, REMOTE_PORT) {
connectClient();
HanoiClient::HanoiClient(){
// connectClient();
connect(this, &HanoiClient::requestError,
this, &HanoiClient::handleError);
// connect(this, &HanoiClient::requestError,
// this, &HanoiClient::handleError);
}
void HanoiClient::handleError(const QString &error) {
QmlNotificationService::NotificationService::getService()->setNotify(
tr("Jnline error"), error, "",
QmlNotificationService::NotificationData::Error);
}
//void HanoiClient::handleError(const QString &error) {
// QmlNotificationService::NotificationService::getService()->setNotify(
// tr("Jnline error"), error, "",
// QmlNotificationService::NotificationData::Error);
//}

View File

@ -15,14 +15,13 @@
#endif
#define REMOTE_PORT 7770
#include <client.h>
class HanoiClient: public NP::Client
class HanoiClient/*: public NP::Client*/
{
public:
HanoiClient();
private slots:
void handleError(const QString& error);
//private slots:
// void handleError(const QString& error);
};
#endif // HANOICLIENT_H

View File

@ -36,7 +36,11 @@ bool UserData::copyFrom(const QH::PKG::AbstractData *other) {
}
QH::PKG::DBObject *UserData::createDBObject() const {
QH::PKG::DBObject
return new UserData();
}
QH::PKG::PrepareResult UserData::prepareSaveQuery(QSqlQuery &q) const {
return QH::PKG::PrepareResult::Disabled;
}
QDataStream &UserData::fromStream(QDataStream &stream) {
@ -50,3 +54,7 @@ QDataStream &UserData::toStream(QDataStream &stream) const {
stream << _userData;
return stream;
}
QH::BaseId UserData::generateId() const {
return {};
}