deprecate the gender property from the protocol entirely (#4496)
* deprecate the gender property from the protocol entirely * use obsolete instead of deprecated * add the database migration * update internal database version as well
This commit is contained in:
parent
86881bbbc3
commit
07e6aadbbe
24 changed files with 25 additions and 170 deletions
|
@ -307,10 +307,6 @@
|
||||||
<file>resources/countries/zm.svg</file>
|
<file>resources/countries/zm.svg</file>
|
||||||
<file>resources/countries/zw.svg</file>
|
<file>resources/countries/zw.svg</file>
|
||||||
|
|
||||||
<file>resources/genders/male.svg</file>
|
|
||||||
<file>resources/genders/female.svg</file>
|
|
||||||
<file>resources/genders/unknown.svg</file>
|
|
||||||
|
|
||||||
<file>resources/phases/untap.svg</file>
|
<file>resources/phases/untap.svg</file>
|
||||||
<file>resources/phases/upkeep.svg</file>
|
<file>resources/phases/upkeep.svg</file>
|
||||||
<file>resources/phases/draw.svg</file>
|
<file>resources/phases/draw.svg</file>
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
||||||
<svg
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
version="1.0"
|
|
||||||
width="75"
|
|
||||||
height="75"
|
|
||||||
id="svg34864">
|
|
||||||
<defs
|
|
||||||
id="defs34866" />
|
|
||||||
<g
|
|
||||||
transform="translate(-348.7552,-478.0905)"
|
|
||||||
id="layer1">
|
|
||||||
<g
|
|
||||||
transform="matrix(1.071197,0,0,1.075147,-13.30677,-36.99488)"
|
|
||||||
id="g3773">
|
|
||||||
<path
|
|
||||||
d="M 176 33 A 11 11 0 1 1 154,33 A 11 11 0 1 1 176 33 z"
|
|
||||||
transform="matrix(1.540096,0,0,1.5384,118.8893,454.0543)"
|
|
||||||
style="color:black;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
|
|
||||||
id="path3939" />
|
|
||||||
<path
|
|
||||||
d="M 373.00525,521.74399 L 373.00525,543.28159"
|
|
||||||
style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:4.61774349;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
id="path3941" />
|
|
||||||
<path
|
|
||||||
d="M 363.76467,534.05119 L 382.24582,534.05119"
|
|
||||||
style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:4.61774349;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
id="path4816" />
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 1.5 KiB |
|
@ -1,12 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
||||||
<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.0" width="75" height="75" id="svg34864">
|
|
||||||
<defs id="defs34866"/>
|
|
||||||
<g transform="translate(-348.755, -478.091)" id="layer1">
|
|
||||||
<g transform="matrix(1.94812, 0, 0, 1.93731, -342.43, -460.01)" id="g1872">
|
|
||||||
<path d="M 387.95009,489.60348 L 378.66214,498.89143" style="opacity: 1; color: black; fill: none; fill-opacity: 0.75; fill-rule: evenodd; stroke: black; stroke-width: 3; stroke-linecap: butt; stroke-linejoin: miter; marker: none; stroke-miterlimit: 4; stroke-dasharray: none; stroke-dashoffset: 0pt; stroke-opacity: 1; visibility: visible; display: inline; overflow: visible;" id="path26867"/>
|
|
||||||
<path d="M 49.396475 36.70454 A 15.623922 16.319134 0 1 1 18.14863,36.70454 A 15.623922 16.319134 0 1 1 49.396475 36.70454 z" transform="matrix(0.48802, 0.48802, -0.467594, 0.467594, 371.609, 473.136)" style="opacity: 1; color: black; fill: none; fill-opacity: 1; fill-rule: evenodd; stroke: black; stroke-width: 4.44072; stroke-linecap: butt; stroke-linejoin: miter; marker: none; stroke-miterlimit: 4; stroke-dasharray: none; stroke-dashoffset: 0pt; stroke-opacity: 1; visibility: visible; display: inline; overflow: visible;" id="path26871"/>
|
|
||||||
<path d="M 379.92823,489.70212 C 387.842,489.70212 387.842,489.70212 387.842,489.70212 L 387.842,497.61589" style="fill: none; fill-rule: evenodd; stroke: black; stroke-width: 3; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 4; stroke-dasharray: none; stroke-opacity: 1;" id="path27759"/>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 1.7 KiB |
|
@ -1,10 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!-- Intersexual/Transgendered symbol by Gregory Maxwell. Copyright 2005. GFDL-1.2 only -->
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
version="1.1"
|
|
||||||
width="210"
|
|
||||||
height="280">
|
|
||||||
<path d="M 188,38 v 20 l 14,-8 v -42 h -42 l -8,14 h 20 l -37,37 a 79,79 0 1,0 -59,141 v 22 h -27 v 23 h 27 v 27 h 23 v -27 h 27 v -23 h -27 v -22 a 79,79 0 0,0 52,-125 zm -100,27 a 57,57 0 1,1 0,114 a 57,57 0 1,1 0,-114 z"/>
|
|
||||||
<!-- 88,65 // -63,-10 -->
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 500 B |
|
@ -88,7 +88,6 @@ protected slots:
|
||||||
protected:
|
protected:
|
||||||
QMap<int, PendingCommand *> pendingCommands;
|
QMap<int, PendingCommand *> pendingCommands;
|
||||||
QString userName, password, email, country, realName, token;
|
QString userName, password, email, country, realName, token;
|
||||||
int gender;
|
|
||||||
void setStatus(ClientStatus _status);
|
void setStatus(ClientStatus _status);
|
||||||
int getNewCmdId()
|
int getNewCmdId()
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,10 +21,6 @@ public:
|
||||||
{
|
{
|
||||||
return emailEdit->text();
|
return emailEdit->text();
|
||||||
}
|
}
|
||||||
int getGender() const
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
} // This will return GenderUnknown for protocol purposes.
|
|
||||||
QString getCountry() const
|
QString getCountry() const
|
||||||
{
|
{
|
||||||
return countryEdit->currentIndex() == 0 ? "" : countryEdit->currentText();
|
return countryEdit->currentIndex() == 0 ? "" : countryEdit->currentText();
|
||||||
|
|
|
@ -34,10 +34,6 @@ public:
|
||||||
{
|
{
|
||||||
return emailEdit->text();
|
return emailEdit->text();
|
||||||
}
|
}
|
||||||
int getGender() const
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
} // This will return GenderUnknown for the protocol.
|
|
||||||
QString getCountry() const
|
QString getCountry() const
|
||||||
{
|
{
|
||||||
return countryEdit->currentIndex() == 0 ? "" : countryEdit->currentText();
|
return countryEdit->currentIndex() == 0 ? "" : countryEdit->currentText();
|
||||||
|
|
|
@ -78,25 +78,6 @@ QPixmap PingPixmapGenerator::generatePixmap(int size, int value, int max)
|
||||||
|
|
||||||
QMap<int, QPixmap> PingPixmapGenerator::pmCache;
|
QMap<int, QPixmap> PingPixmapGenerator::pmCache;
|
||||||
|
|
||||||
QPixmap GenderPixmapGenerator::generatePixmap(int height)
|
|
||||||
{
|
|
||||||
ServerInfo_User::Gender gender = ServerInfo_User::GenderUnknown;
|
|
||||||
|
|
||||||
int key = gender * 100000 + height;
|
|
||||||
if (pmCache.contains(key))
|
|
||||||
return pmCache.value(key);
|
|
||||||
|
|
||||||
QString genderStr;
|
|
||||||
genderStr = "unknown";
|
|
||||||
|
|
||||||
QPixmap pixmap =
|
|
||||||
QPixmap("theme:genders/" + genderStr).scaled(height, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
|
||||||
pmCache.insert(key, pixmap);
|
|
||||||
return pixmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMap<int, QPixmap> GenderPixmapGenerator::pmCache;
|
|
||||||
|
|
||||||
QPixmap CountryPixmapGenerator::generatePixmap(int height, const QString &countryCode)
|
QPixmap CountryPixmapGenerator::generatePixmap(int height, const QString &countryCode)
|
||||||
{
|
{
|
||||||
if (countryCode.size() != 2)
|
if (countryCode.size() != 2)
|
||||||
|
|
|
@ -45,19 +45,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class GenderPixmapGenerator
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
static QMap<int, QPixmap> pmCache;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static QPixmap generatePixmap(int height);
|
|
||||||
static void clear()
|
|
||||||
{
|
|
||||||
pmCache.clear();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class CountryPixmapGenerator
|
class CountryPixmapGenerator
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -152,7 +152,6 @@ void RemoteClient::processServerIdentificationEvent(const Event_ServerIdentifica
|
||||||
cmdRegister.set_user_name(userName.toStdString());
|
cmdRegister.set_user_name(userName.toStdString());
|
||||||
cmdRegister.set_password(password.toStdString());
|
cmdRegister.set_password(password.toStdString());
|
||||||
cmdRegister.set_email(email.toStdString());
|
cmdRegister.set_email(email.toStdString());
|
||||||
cmdRegister.set_gender((ServerInfo_User_Gender)gender);
|
|
||||||
cmdRegister.set_country(country.toStdString());
|
cmdRegister.set_country(country.toStdString());
|
||||||
cmdRegister.set_real_name(realName.toStdString());
|
cmdRegister.set_real_name(realName.toStdString());
|
||||||
cmdRegister.set_clientid(getSrvClientID(lastHostname).toStdString());
|
cmdRegister.set_clientid(getSrvClientID(lastHostname).toStdString());
|
||||||
|
@ -449,7 +448,6 @@ void RemoteClient::doRegisterToServer(const QString &hostname,
|
||||||
const QString &_userName,
|
const QString &_userName,
|
||||||
const QString &_password,
|
const QString &_password,
|
||||||
const QString &_email,
|
const QString &_email,
|
||||||
const int _gender,
|
|
||||||
const QString &_country,
|
const QString &_country,
|
||||||
const QString &_realname)
|
const QString &_realname)
|
||||||
{
|
{
|
||||||
|
@ -458,7 +456,6 @@ void RemoteClient::doRegisterToServer(const QString &hostname,
|
||||||
userName = _userName;
|
userName = _userName;
|
||||||
password = _password;
|
password = _password;
|
||||||
email = _email;
|
email = _email;
|
||||||
gender = _gender;
|
|
||||||
country = _country;
|
country = _country;
|
||||||
realName = _realname;
|
realName = _realname;
|
||||||
lastHostname = hostname;
|
lastHostname = hostname;
|
||||||
|
@ -539,11 +536,10 @@ void RemoteClient::registerToServer(const QString &hostname,
|
||||||
const QString &_userName,
|
const QString &_userName,
|
||||||
const QString &_password,
|
const QString &_password,
|
||||||
const QString &_email,
|
const QString &_email,
|
||||||
const int _gender,
|
|
||||||
const QString &_country,
|
const QString &_country,
|
||||||
const QString &_realname)
|
const QString &_realname)
|
||||||
{
|
{
|
||||||
emit sigRegisterToServer(hostname, port, _userName, _password, _email, _gender, _country, _realname);
|
emit sigRegisterToServer(hostname, port, _userName, _password, _email, _country, _realname);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteClient::activateToServer(const QString &_token)
|
void RemoteClient::activateToServer(const QString &_token)
|
||||||
|
|
|
@ -27,7 +27,6 @@ signals:
|
||||||
const QString &_userName,
|
const QString &_userName,
|
||||||
const QString &_password,
|
const QString &_password,
|
||||||
const QString &_email,
|
const QString &_email,
|
||||||
int _gender,
|
|
||||||
const QString &_country,
|
const QString &_country,
|
||||||
const QString &_realname);
|
const QString &_realname);
|
||||||
void sigActivateToServer(const QString &_token);
|
void sigActivateToServer(const QString &_token);
|
||||||
|
@ -67,7 +66,6 @@ private slots:
|
||||||
const QString &_userName,
|
const QString &_userName,
|
||||||
const QString &_password,
|
const QString &_password,
|
||||||
const QString &_email,
|
const QString &_email,
|
||||||
int _gender,
|
|
||||||
const QString &_country,
|
const QString &_country,
|
||||||
const QString &_realname);
|
const QString &_realname);
|
||||||
void doRequestPasswordSalt();
|
void doRequestPasswordSalt();
|
||||||
|
@ -130,7 +128,6 @@ public:
|
||||||
const QString &_userName,
|
const QString &_userName,
|
||||||
const QString &_password,
|
const QString &_password,
|
||||||
const QString &_email,
|
const QString &_email,
|
||||||
int _gender,
|
|
||||||
const QString &_country,
|
const QString &_country,
|
||||||
const QString &_realname);
|
const QString &_realname);
|
||||||
void activateToServer(const QString &_token);
|
void activateToServer(const QString &_token);
|
||||||
|
|
|
@ -200,7 +200,6 @@ void UserInfoBox::actEditInternal(const Response &r)
|
||||||
Command_AccountEdit cmd;
|
Command_AccountEdit cmd;
|
||||||
cmd.set_real_name(dlg.getRealName().toStdString());
|
cmd.set_real_name(dlg.getRealName().toStdString());
|
||||||
cmd.set_email(dlg.getEmail().toStdString());
|
cmd.set_email(dlg.getEmail().toStdString());
|
||||||
cmd.set_gender((ServerInfo_User_Gender)dlg.getGender());
|
|
||||||
cmd.set_country(dlg.getCountry().toStdString());
|
cmd.set_country(dlg.getCountry().toStdString());
|
||||||
|
|
||||||
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||||
|
|
|
@ -201,8 +201,7 @@ void MainWindow::actRegister()
|
||||||
DlgRegister dlg(this);
|
DlgRegister dlg(this);
|
||||||
if (dlg.exec()) {
|
if (dlg.exec()) {
|
||||||
client->registerToServer(dlg.getHost(), static_cast<unsigned int>(dlg.getPort()), dlg.getPlayerName(),
|
client->registerToServer(dlg.getHost(), static_cast<unsigned int>(dlg.getPort()), dlg.getPlayerName(),
|
||||||
dlg.getPassword(), dlg.getEmail(), dlg.getGender(), dlg.getCountry(),
|
dlg.getPassword(), dlg.getEmail(), dlg.getCountry(), dlg.getRealName());
|
||||||
dlg.getRealName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ message GameCommand {
|
||||||
NEXT_TURN = 1022;
|
NEXT_TURN = 1022;
|
||||||
SET_ACTIVE_PHASE = 1023;
|
SET_ACTIVE_PHASE = 1023;
|
||||||
DUMP_ZONE = 1024;
|
DUMP_ZONE = 1024;
|
||||||
STOP_DUMP_ZONE = 1025; // deprecated
|
// STOP_DUMP_ZONE = 1025; // obsolete
|
||||||
REVEAL_CARDS = 1026;
|
REVEAL_CARDS = 1026;
|
||||||
MOVE_CARD = 1027;
|
MOVE_CARD = 1027;
|
||||||
SET_SIDEBOARD_PLAN = 1028;
|
SET_SIDEBOARD_PLAN = 1028;
|
||||||
|
|
|
@ -28,7 +28,7 @@ message GameEvent {
|
||||||
SET_ACTIVE_PLAYER = 2016;
|
SET_ACTIVE_PLAYER = 2016;
|
||||||
SET_ACTIVE_PHASE = 2017;
|
SET_ACTIVE_PHASE = 2017;
|
||||||
DUMP_ZONE = 2018;
|
DUMP_ZONE = 2018;
|
||||||
STOP_DUMP_ZONE = 2019; // deprecated
|
// STOP_DUMP_ZONE = 2019; // obsolete
|
||||||
CHANGE_ZONE_PROPERTIES = 2020;
|
CHANGE_ZONE_PROPERTIES = 2020;
|
||||||
REVERSE_TURN = 2021;
|
REVERSE_TURN = 2021;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,16 +8,11 @@ message ServerInfo_User {
|
||||||
IsAdmin = 8;
|
IsAdmin = 8;
|
||||||
IsJudge = 16;
|
IsJudge = 16;
|
||||||
};
|
};
|
||||||
enum Gender {
|
|
||||||
GenderUnknown = -1;
|
|
||||||
Male = 0;
|
|
||||||
Female = 1;
|
|
||||||
};
|
|
||||||
optional string name = 1;
|
optional string name = 1;
|
||||||
optional uint32 user_level = 2;
|
optional uint32 user_level = 2;
|
||||||
optional string address = 3;
|
optional string address = 3;
|
||||||
optional string real_name = 4;
|
optional string real_name = 4;
|
||||||
optional Gender gender = 5 [default = GenderUnknown];
|
// gender = 5; // obsolete
|
||||||
optional string country = 6;
|
optional string country = 6;
|
||||||
optional bytes avatar_bmp = 7;
|
optional bytes avatar_bmp = 7;
|
||||||
optional sint32 id = 8 [default = -1];
|
optional sint32 id = 8 [default = -1];
|
||||||
|
|
|
@ -122,8 +122,7 @@ message Command_Register {
|
||||||
required string password = 2;
|
required string password = 2;
|
||||||
// Email address of the client for user validation
|
// Email address of the client for user validation
|
||||||
optional string email = 3;
|
optional string email = 3;
|
||||||
// Gender of the user
|
// gender = 4; // obsolete
|
||||||
optional ServerInfo_User.Gender gender = 4;
|
|
||||||
// Country code of the user. 2 letter ISO format
|
// Country code of the user. 2 letter ISO format
|
||||||
optional string country = 5;
|
optional string country = 5;
|
||||||
optional string real_name = 6;
|
optional string real_name = 6;
|
||||||
|
@ -148,7 +147,7 @@ message Command_AccountEdit {
|
||||||
}
|
}
|
||||||
optional string real_name = 1;
|
optional string real_name = 1;
|
||||||
optional string email = 2;
|
optional string email = 2;
|
||||||
optional ServerInfo_User.Gender gender = 3;
|
// gender = 3; // obsolete
|
||||||
optional string country = 4;
|
optional string country = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,6 @@ public:
|
||||||
}
|
}
|
||||||
virtual bool registerUser(const QString & /* userName */,
|
virtual bool registerUser(const QString & /* userName */,
|
||||||
const QString & /* realName */,
|
const QString & /* realName */,
|
||||||
ServerInfo_User_Gender const & /* gender */,
|
|
||||||
const QString & /* password */,
|
const QString & /* password */,
|
||||||
const QString & /* emailAddress */,
|
const QString & /* emailAddress */,
|
||||||
const QString & /* country */,
|
const QString & /* country */,
|
||||||
|
@ -159,10 +158,6 @@ public:
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
virtual QChar getGenderChar(ServerInfo_User_Gender const & /* gender */)
|
|
||||||
{
|
|
||||||
return QChar('u');
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
5
servatrice/migrations/servatrice_0027_to_0028.sql
Normal file
5
servatrice/migrations/servatrice_0027_to_0028.sql
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
-- Servatrice db migration from version 27 to version 28
|
||||||
|
|
||||||
|
ALTER TABLE cockatrice_users DROP COLUMN gender;
|
||||||
|
|
||||||
|
UPDATE cockatrice_schema_version SET version=28 WHERE version=27;
|
|
@ -20,7 +20,7 @@ CREATE TABLE IF NOT EXISTS `cockatrice_schema_version` (
|
||||||
PRIMARY KEY (`version`)
|
PRIMARY KEY (`version`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;
|
||||||
|
|
||||||
INSERT INTO cockatrice_schema_version VALUES(27);
|
INSERT INTO cockatrice_schema_version VALUES(28);
|
||||||
|
|
||||||
-- users and user data tables
|
-- users and user data tables
|
||||||
CREATE TABLE IF NOT EXISTS `cockatrice_users` (
|
CREATE TABLE IF NOT EXISTS `cockatrice_users` (
|
||||||
|
@ -28,7 +28,6 @@ CREATE TABLE IF NOT EXISTS `cockatrice_users` (
|
||||||
`admin` tinyint(1) NOT NULL,
|
`admin` tinyint(1) NOT NULL,
|
||||||
`name` varchar(35) NOT NULL,
|
`name` varchar(35) NOT NULL,
|
||||||
`realname` varchar(255) NOT NULL,
|
`realname` varchar(255) NOT NULL,
|
||||||
`gender` char(1) NOT NULL,
|
|
||||||
`password_sha512` char(120) NOT NULL,
|
`password_sha512` char(120) NOT NULL,
|
||||||
`email` varchar(255) NOT NULL,
|
`email` varchar(255) NOT NULL,
|
||||||
`country` char(2) NOT NULL,
|
`country` char(2) NOT NULL,
|
||||||
|
|
|
@ -197,7 +197,6 @@ bool Servatrice_DatabaseInterface::usernameIsValid(const QString &user, QString
|
||||||
|
|
||||||
bool Servatrice_DatabaseInterface::registerUser(const QString &userName,
|
bool Servatrice_DatabaseInterface::registerUser(const QString &userName,
|
||||||
const QString &realName,
|
const QString &realName,
|
||||||
ServerInfo_User_Gender const &gender,
|
|
||||||
const QString &password,
|
const QString &password,
|
||||||
const QString &emailAddress,
|
const QString &emailAddress,
|
||||||
const QString &country,
|
const QString &country,
|
||||||
|
@ -211,14 +210,13 @@ bool Servatrice_DatabaseInterface::registerUser(const QString &userName,
|
||||||
|
|
||||||
QSqlQuery *query =
|
QSqlQuery *query =
|
||||||
prepareQuery("insert into {prefix}_users "
|
prepareQuery("insert into {prefix}_users "
|
||||||
"(name, realname, gender, password_sha512, email, country, registrationDate, active, token, "
|
"(name, realname, password_sha512, email, country, registrationDate, active, token, "
|
||||||
"admin, avatar_bmp, clientid, privlevel, privlevelStartDate, privlevelEndDate) "
|
"admin, avatar_bmp, clientid, privlevel, privlevelStartDate, privlevelEndDate) "
|
||||||
"values "
|
"values "
|
||||||
"(:userName, :realName, :gender, :password_sha512, :email, :country, UTC_TIMESTAMP(), :active, "
|
"(:userName, :realName, :password_sha512, :email, :country, UTC_TIMESTAMP(), :active, "
|
||||||
":token, 0, '', '', 'NONE', UTC_TIMESTAMP(), UTC_TIMESTAMP())");
|
":token, 0, '', '', 'NONE', UTC_TIMESTAMP(), UTC_TIMESTAMP())");
|
||||||
query->bindValue(":userName", userName);
|
query->bindValue(":userName", userName);
|
||||||
query->bindValue(":realName", realName);
|
query->bindValue(":realName", realName);
|
||||||
query->bindValue(":gender", getGenderChar(gender));
|
|
||||||
query->bindValue(":password_sha512", passwordSha512);
|
query->bindValue(":password_sha512", passwordSha512);
|
||||||
query->bindValue(":email", emailAddress);
|
query->bindValue(":email", emailAddress);
|
||||||
query->bindValue(":country", country);
|
query->bindValue(":country", country);
|
||||||
|
@ -268,20 +266,6 @@ bool Servatrice_DatabaseInterface::activateUser(const QString &userName, const Q
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QChar Servatrice_DatabaseInterface::getGenderChar(ServerInfo_User_Gender const &gender)
|
|
||||||
{
|
|
||||||
switch (gender) {
|
|
||||||
case ServerInfo_User_Gender_GenderUnknown:
|
|
||||||
return QChar('u');
|
|
||||||
case ServerInfo_User_Gender_Male:
|
|
||||||
return QChar('m');
|
|
||||||
case ServerInfo_User_Gender_Female:
|
|
||||||
return QChar('f');
|
|
||||||
default:
|
|
||||||
return QChar('u');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AuthenticationResult Servatrice_DatabaseInterface::checkUserPassword(Server_ProtocolHandler *handler,
|
AuthenticationResult Servatrice_DatabaseInterface::checkUserPassword(Server_ProtocolHandler *handler,
|
||||||
const QString &user,
|
const QString &user,
|
||||||
const QString &password,
|
const QString &password,
|
||||||
|
@ -602,31 +586,25 @@ ServerInfo_User Servatrice_DatabaseInterface::evalUserQueryResult(const QSqlQuer
|
||||||
result.set_privlevel(privlevel.toStdString());
|
result.set_privlevel(privlevel.toStdString());
|
||||||
|
|
||||||
if (complete) {
|
if (complete) {
|
||||||
const QString genderStr = query->value(5).toString();
|
const QString realName = query->value(5).toString();
|
||||||
if (genderStr == "m")
|
|
||||||
result.set_gender(ServerInfo_User::Male);
|
|
||||||
else if (genderStr == "f")
|
|
||||||
result.set_gender(ServerInfo_User::Female);
|
|
||||||
|
|
||||||
const QString realName = query->value(6).toString();
|
|
||||||
if (!realName.isEmpty())
|
if (!realName.isEmpty())
|
||||||
result.set_real_name(realName.toStdString());
|
result.set_real_name(realName.toStdString());
|
||||||
|
|
||||||
const QByteArray avatarBmp = query->value(7).toByteArray();
|
const QByteArray avatarBmp = query->value(6).toByteArray();
|
||||||
if (avatarBmp.size())
|
if (avatarBmp.size())
|
||||||
result.set_avatar_bmp(avatarBmp.data(), avatarBmp.size());
|
result.set_avatar_bmp(avatarBmp.data(), avatarBmp.size());
|
||||||
|
|
||||||
const QDateTime regDate = query->value(8).toDateTime();
|
const QDateTime regDate = query->value(7).toDateTime();
|
||||||
if (!regDate.toString(Qt::ISODate).isEmpty()) {
|
if (!regDate.toString(Qt::ISODate).isEmpty()) {
|
||||||
qint64 accountAgeInSeconds = regDate.secsTo(QDateTime::currentDateTime());
|
qint64 accountAgeInSeconds = regDate.secsTo(QDateTime::currentDateTime());
|
||||||
result.set_accountage_secs(accountAgeInSeconds);
|
result.set_accountage_secs(accountAgeInSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString email = query->value(9).toString();
|
const QString email = query->value(8).toString();
|
||||||
if (!email.isEmpty())
|
if (!email.isEmpty())
|
||||||
result.set_email(email.toStdString());
|
result.set_email(email.toStdString());
|
||||||
|
|
||||||
const QString clientid = query->value(10).toString();
|
const QString clientid = query->value(9).toString();
|
||||||
if (!clientid.isEmpty())
|
if (!clientid.isEmpty())
|
||||||
result.set_clientid(clientid.toStdString());
|
result.set_clientid(clientid.toStdString());
|
||||||
}
|
}
|
||||||
|
@ -644,7 +622,7 @@ ServerInfo_User Servatrice_DatabaseInterface::getUserData(const QString &name, b
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
QSqlQuery *query =
|
QSqlQuery *query =
|
||||||
prepareQuery("select id, name, admin, country, privlevel, gender, realname, avatar_bmp, registrationDate, "
|
prepareQuery("select id, name, admin, country, privlevel, realname, avatar_bmp, registrationDate, "
|
||||||
"email, clientid from {prefix}_users where name = :name and active = 1");
|
"email, clientid from {prefix}_users where name = :name and active = 1");
|
||||||
query->bindValue(":name", name);
|
query->bindValue(":name", name);
|
||||||
if (!execSqlQuery(query))
|
if (!execSqlQuery(query))
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSqlDatabase>
|
#include <QSqlDatabase>
|
||||||
|
|
||||||
#define DATABASE_SCHEMA_VERSION 27
|
#define DATABASE_SCHEMA_VERSION 28
|
||||||
|
|
||||||
class Servatrice;
|
class Servatrice;
|
||||||
|
|
||||||
|
@ -97,7 +97,6 @@ public:
|
||||||
int checkNumberOfUserAccounts(const QString &email);
|
int checkNumberOfUserAccounts(const QString &email);
|
||||||
bool registerUser(const QString &userName,
|
bool registerUser(const QString &userName,
|
||||||
const QString &realName,
|
const QString &realName,
|
||||||
ServerInfo_User_Gender const &gender,
|
|
||||||
const QString &password,
|
const QString &password,
|
||||||
const QString &emailAddress,
|
const QString &emailAddress,
|
||||||
const QString &country,
|
const QString &country,
|
||||||
|
@ -114,7 +113,6 @@ public:
|
||||||
const QString &targetName);
|
const QString &targetName);
|
||||||
bool
|
bool
|
||||||
changeUserPassword(const QString &user, const QString &oldPassword, const QString &newPassword, const bool &force);
|
changeUserPassword(const QString &user, const QString &oldPassword, const QString &newPassword, const bool &force);
|
||||||
QChar getGenderChar(ServerInfo_User_Gender const &gender);
|
|
||||||
QList<ServerInfo_Ban> getUserBanHistory(const QString userName);
|
QList<ServerInfo_Ban> getUserBanHistory(const QString userName);
|
||||||
bool
|
bool
|
||||||
addWarning(const QString userName, const QString adminName, const QString warningReason, const QString clientID);
|
addWarning(const QString userName, const QString adminName, const QString warningReason, const QString clientID);
|
||||||
|
|
|
@ -1164,7 +1164,6 @@ Response::ResponseCode AbstractServerSocketInterface::cmdRegisterAccount(const C
|
||||||
}
|
}
|
||||||
|
|
||||||
QString realName = QString::fromStdString(cmd.real_name());
|
QString realName = QString::fromStdString(cmd.real_name());
|
||||||
ServerInfo_User_Gender gender = cmd.gender();
|
|
||||||
QString country = QString::fromStdString(cmd.country());
|
QString country = QString::fromStdString(cmd.country());
|
||||||
QString password = QString::fromStdString(cmd.password());
|
QString password = QString::fromStdString(cmd.password());
|
||||||
|
|
||||||
|
@ -1178,8 +1177,8 @@ Response::ResponseCode AbstractServerSocketInterface::cmdRegisterAccount(const C
|
||||||
}
|
}
|
||||||
|
|
||||||
bool requireEmailActivation = settingsCache->value("registration/requireemailactivation", true).toBool();
|
bool requireEmailActivation = settingsCache->value("registration/requireemailactivation", true).toBool();
|
||||||
bool regSucceeded = sqlInterface->registerUser(userName, realName, gender, password, emailAddress, country,
|
bool regSucceeded =
|
||||||
!requireEmailActivation);
|
sqlInterface->registerUser(userName, realName, password, emailAddress, country, !requireEmailActivation);
|
||||||
|
|
||||||
if (regSucceeded) {
|
if (regSucceeded) {
|
||||||
qDebug() << "Accepted register command for user: " << userName;
|
qDebug() << "Accepted register command for user: " << userName;
|
||||||
|
@ -1260,16 +1259,14 @@ Response::ResponseCode AbstractServerSocketInterface::cmdAccountEdit(const Comma
|
||||||
|
|
||||||
QString realName = QString::fromStdString(cmd.real_name());
|
QString realName = QString::fromStdString(cmd.real_name());
|
||||||
QString emailAddress = QString::fromStdString(cmd.email());
|
QString emailAddress = QString::fromStdString(cmd.email());
|
||||||
ServerInfo_User_Gender gender = cmd.gender();
|
|
||||||
QString country = QString::fromStdString(cmd.country());
|
QString country = QString::fromStdString(cmd.country());
|
||||||
|
|
||||||
QString userName = QString::fromStdString(userInfo->name());
|
QString userName = QString::fromStdString(userInfo->name());
|
||||||
|
|
||||||
QSqlQuery *query = sqlInterface->prepareQuery("update {prefix}_users set realname=:realName, email=:email, "
|
QSqlQuery *query = sqlInterface->prepareQuery("update {prefix}_users set realname=:realName, email=:email, "
|
||||||
"gender=:gender, country=:country where name=:userName");
|
"country=:country where name=:userName");
|
||||||
query->bindValue(":realName", realName);
|
query->bindValue(":realName", realName);
|
||||||
query->bindValue(":email", emailAddress);
|
query->bindValue(":email", emailAddress);
|
||||||
query->bindValue(":gender", sqlInterface->getGenderChar(gender));
|
|
||||||
query->bindValue(":country", country);
|
query->bindValue(":country", country);
|
||||||
query->bindValue(":userName", userName);
|
query->bindValue(":userName", userName);
|
||||||
if (!sqlInterface->execSqlQuery(query))
|
if (!sqlInterface->execSqlQuery(query))
|
||||||
|
@ -1277,7 +1274,6 @@ Response::ResponseCode AbstractServerSocketInterface::cmdAccountEdit(const Comma
|
||||||
|
|
||||||
userInfo->set_real_name(cmd.real_name());
|
userInfo->set_real_name(cmd.real_name());
|
||||||
userInfo->set_email(cmd.email());
|
userInfo->set_email(cmd.email());
|
||||||
userInfo->set_gender(cmd.gender());
|
|
||||||
userInfo->set_country(cmd.country());
|
userInfo->set_country(cmd.country());
|
||||||
|
|
||||||
return Response::RespOk;
|
return Response::RespOk;
|
||||||
|
|
|
@ -3,7 +3,6 @@ export interface User {
|
||||||
name: string;
|
name: string;
|
||||||
privlevel: UserAccessLevel;
|
privlevel: UserAccessLevel;
|
||||||
userLevel: UserPrivLevel;
|
userLevel: UserPrivLevel;
|
||||||
gender?: number;
|
|
||||||
realName?: string;
|
realName?: string;
|
||||||
country?: string;
|
country?: string;
|
||||||
avatarBmp?: Uint8Array;
|
avatarBmp?: Uint8Array;
|
||||||
|
|
Loading…
Reference in a new issue