1 /***************************************************************************
2 * Copyright (C) 2007 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 NETWORKHANDLER_H
22 #define NETWORKHANDLER_H
27 #include <dash/network/socketobserver.h>
28 #include <dash/network/package/dispatcher.h>
54 * @author David Cuadrado <krawek@gmail.com>
56 class NetworkHandler
: public QObject
, Dash::Network::SocketObserver
61 NetworkHandler(ProjectManager
*manager
, QObject
*parent
= 0);
64 void connectToHost(const QString
&host
, quint16 port
, const QString
&login
, const QString
&password
);
65 bool send(const QString
&xml
);
67 void addObserver(Dash::Network::Package::Observer
*observer
);
68 void removeObserver(Dash::Network::Package::Observer
*observer
);
70 void execute(YAMF::Command::Base
*cmd
);
72 void newProject(const ProjectParams
*params
);
75 void openProject(const QString
&projectName
);
80 void showChatWindow();
83 virtual void readed(const QString
&txt
);
84 virtual void dataReaded(const QByteArray
&data
);
87 void onReceiverFinished(const QString
&fileName
);
90 ProjectManager
*m_manager
;
91 Dash::Network::Socket
*m_socket
;
92 Dash::Network::FileReceiver
*m_receiver
;
96 Dash::Network::Package::Dispatcher
*m_dispatcher
;
98 YAMF::Command::Processor
*m_processor
;
100 QQueue
<YAMF::Command::Base
*> m_commands
;
101 bool m_waitingResponse
;
103 QString m_currentPackage
;