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 #ifndef DOMSERVERCONNECTION_H
22 #define DOMSERVERCONNECTION_H
26 #include <QDomDocument>
28 #include <dash/network/socketobserver.h>
29 #include <dash/network/package/error.h>
38 namespace DashServer
{
46 * Esta clase representa cada conexion de un cliente al servidor, es un hilo.
47 * @author David Cuadrado \<krawek@gmail.com\>
49 class Connection
: public QThread
, virtual protected Dash::Network::SocketObserver
54 Connection(int socketDescriptor
, DashServer::TcpServer
*server
);
57 void sendToClient(const QString
&xml
, bool sign
) const;
58 void sendToAll(const QString
&xml
, bool sign
);
60 void sendToClient(QDomDocument
&doc
, bool sign
);
61 void sendToAll(QDomDocument
&doc
, bool sign
);
64 void setData(int key
, const QVariant
&value
);
65 QVariant
data(int key
) const;
67 Dash::Network::Socket
*client() const;
68 TcpServer
*server() const;
70 void setUser(Users::User
*user
);
71 Users::User
*user() const;
76 QString
signXml(const QString
&xml
) const;
78 void setValid(bool v
);
83 void readed(const QString
&readed
);
84 void dataReaded(const QByteArray
&data
);
88 void sendError(const QString
& message
, Dash::Network::Package::Error::Level level
);
91 void removeConnection();
94 void error(QTcpSocket::SocketError socketError
);
95 void requestSendToAll(const QString
&msg
);
96 void connectionClosed( DashServer::Connection
*cnn
);
97 void packageReaded(DashServer::Connection
*cnn
, const QString
& root
,const QString
& packages
);