~ubuntu-branches/ubuntu/wily/tupi/wily-proposed

« back to all changes in this revision

Viewing changes to src/net/ktconnectpackage.cpp

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2013-05-13 09:53:35 UTC
  • mfrom: (8.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130513095335-3iqdvt9ne07ia25v
Tags: 0.2+git01-1
* Upload to unstable.
* Removed unnecessary versioned Build-Depends.
* Removed obsolete "DM-Upload-Allowed".
* Added Vcs links to collab-maint.
* Standards updated to version 3.9.4.
* Corrected "libavutil51"-->"libavutil-dev" in Build-Depends.
* Updated debian/watch (corrected URL, removed comments).
* Updated get-orig-source (can work from any directory).
* Updated my email address; bumped copyright years.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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>                *
6
 
 *                                                                         *
7
 
 *   Developers:                                                           *
8
 
 *   2010:                                                                 *
9
 
 *    Gustavo Gonzalez / xtingray                                          *
10
 
 *                                                                         *
11
 
 *   KTooN's versions:                                                     * 
12
 
 *                                                                         *
13
 
 *   2006:                                                                 *
14
 
 *    David Cuadrado                                                       *
15
 
 *    Jorge Cuadrado                                                       *
16
 
 *   2003:                                                                 *
17
 
 *    Fernado Roldan                                                       *
18
 
 *    Simena Dinas                                                         *
19
 
 *                                                                         *
20
 
 *   Copyright (C) 2010 Gustav Gonzalez - http://www.maefloresta.com       *
21
 
 *   License:                                                              *
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.                                   *
26
 
 *                                                                         *
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.                          *
31
 
 *                                                                         *
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
 
 ***************************************************************************/
35
 
 
36
 
#include "ktconnectpackage.h"
37
 
#include "talgorithm.h"
38
 
#include "kmd5hash.h"
39
 
#include "tdebug.h"
40
 
 
41
 
#include <QStringList>
42
 
 
43
 
/*
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>
48
 
</user_connect>
49
 
*/
50
 
 
51
 
KTConnectPackage::KTConnectPackage(const QString &server, const QString &login, const QString &passwd) : QDomDocument()
52
 
{
53
 
    QDomElement root = createElement("user_connect");
54
 
    root.setAttribute("version", "0");
55
 
    appendChild(root);
56
 
 
57
 
    QDomElement client = createElement("client");
58
 
    client.setAttribute("type", 0);
59
 
    root.appendChild(client);
60
 
 
61
 
    root.appendChild(createElement("login")).appendChild(createTextNode(login));
62
 
 
63
 
    if (server.compare("tupitube.com") != 0) {
64
 
        root.appendChild(createElement("password")).appendChild(createTextNode(KMD5Hash::hash(passwd)));
65
 
    } else {
66
 
        QString salt = TAlgorithm::randomString(15);
67
 
 
68
 
        QDomElement token = createElement("salt");
69
 
        token.setAttribute("method", "sha512");
70
 
        token.appendChild(createTextNode(salt));
71
 
        root.appendChild(token);
72
 
 
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)));
76
 
        }
77
 
    }
78
 
}
79
 
 
80
 
KTConnectPackage::~KTConnectPackage()
81
 
{
82
 
}