1 /***************************************************************************
2 * Copyright (C) 2006 by David Cuadrado *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include "regmanager.h"
24 #include <QCryptographicHash>
26 #include <dcore/debug.h>
30 #include "connection.h"
33 #include "actionregisteruserparser.h"
35 #include "dashserver/users/usermanager.h"
36 #include "dashserver/users/user.h"
38 #include "dash/network/package/adduser.h"
40 namespace DashServer
{
43 struct Manager::Private
47 Manager::Manager() : DashServer::Observer(),d( new Private
)
58 void Manager::handlePackage(DashServer::Package
* const pkg
)
60 DashServer::TcpServer
*server
= pkg
->source()->server();
62 if( pkg
->root() == "listregisters" )
64 // QString fname = d->db->fileName();
69 // if( f.open(QIODevice::ReadOnly | QIODevice::Text) )
71 // pkg->source()->sendToClient(f.readAll());
75 else if ( pkg
->root() == "registeruser" )
77 Parsers::ActionRegisterUserParser parser
;
79 if( parser
.parse(pkg
->xml()))
81 // QHash<QString, QString> data = parser.data();
82 // QString email = data["email"];
84 // data = d->db->findRegisterByEmail(email);
85 // d->db->removeRegister(email);
87 // dDebug() << data["login"];
89 // Users::Manager *manager = server->userManager();
92 // user.setLogin(data["login"]);
93 // user.setName(data["name"]);
94 // user.setPassword(QCryptographicHash::hash("", QCryptographicHash::Md5));
96 // // manager->addUser(user); FIXME
98 // server->sendToAdmins(pkg->xml());
99 // Packages::AddUser adduser(data["login"], data["name"]);
100 // server->sendToAdmins(adduser.toString());