- Support to get/send binary data in Network::Socket
[dashstudio.git] / src / dash / network / socket.h
blob6725133a2448817d6240b6fd859e68ce78e19d7b
1 /***************************************************************************
2 * Copyright (C) 2006 by David Cuadrado *
3 * krawek@gmail.com *
4 * *
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. *
9 * *
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. *
14 * *
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 DASH_NETWORKSOCKET_H
22 #define DASH_NETWORKSOCKET_H
24 #include <QSslSocket>
25 #include <QByteArray>
26 #include <QString>
27 #include <QDomDocument>
29 #include <dash/exports.h>
31 namespace Dash {
32 namespace Network {
34 class SocketObserver;
36 /**
37 * @author David Cuadrado <krawek@gmail.com>
39 class DASH_EXPORT Socket : public QTcpSocket //QSslSocket
41 Q_OBJECT;
43 public:
44 enum Format {
45 Text = 0x1,
46 Binary
49 Socket(QObject *parent = 0);
50 ~Socket();
52 void setFormat(Format format);
53 Format format() const;
55 void addObserver(SocketObserver *observer);
56 void removeObserver(SocketObserver *observer);
58 void send(const QByteArray &data);
59 void send(const QDomDocument &doc);
61 protected slots:
62 virtual void readFromServer();
64 public slots:
65 void sendQueue();
66 void clearQueue();
68 private:
69 struct Private;
70 Private *const d;
77 #endif