1
/***************************************************************************
2
* Project TUPI: Magia 2D *
3
* Project Contact: info@maefloresta.com *
4
* Project Website: http://www.maefloresta.com *
5
* Project Leader: Gustav Gonzalez <info@maefloresta.com> *
9
* Gustavo Gonzalez / xtingray *
20
* Copyright (C) 2010 Gustav Gonzalez - http://www.maefloresta.com *
22
* This program is free software; you can redistribute it and/or modify *
23
* it under the terms of the GNU General Public License as published by *
24
* the Free Software Foundation; either version 3 of the License, or *
25
* (at your option) any later version. *
27
* This program is distributed in the hope that it will be useful, *
28
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
29
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30
* GNU General Public License for more details. *
32
* You should have received a copy of the GNU General Public License *
33
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
34
***************************************************************************/
36
#include "ktconnectpackage.h"
37
#include "talgorithm.h"
41
#include <QStringList>
44
<user_connect version="0">
45
<client type="0"/> // 0 for Tupi artist clients - 1 for Tupi admin clients
46
<login>user_login</login>
47
<password>md5_hashed_password</password>
51
KTConnectPackage::KTConnectPackage(const QString &server, const QString &login, const QString &passwd) : QDomDocument()
53
QDomElement root = createElement("user_connect");
54
root.setAttribute("version", "0");
57
QDomElement client = createElement("client");
58
client.setAttribute("type", 0);
59
root.appendChild(client);
61
root.appendChild(createElement("login")).appendChild(createTextNode(login));
63
if (server.compare("tupitube.com") != 0) {
64
root.appendChild(createElement("password")).appendChild(createTextNode(KMD5Hash::hash(passwd)));
66
QString salt = TAlgorithm::randomString(15);
68
QDomElement token = createElement("salt");
69
token.setAttribute("method", "sha512");
70
token.appendChild(createTextNode(salt));
71
root.appendChild(token);
73
QStringList passwdList = KMD5Hash::passwords(passwd);
74
for (int i = 0; i < passwdList.size(); ++i) {
75
root.appendChild(createElement("password")).appendChild(createTextNode(passwdList.at(i)));
80
KTConnectPackage::~KTConnectPackage()