Code

Unix-ify the sources
[inkscape.git] / src / dom / io / socket.h
1 #ifndef __DOM_SOCKET_H__
2 #define __DOM_SOCKET_H__
3 /**
4  * Phoebe DOM Implementation.
5  *
6  * This is a C++ approximation of the W3C DOM model, which follows
7  * fairly closely the specifications in the various .idl files, copies of
8  * which are provided for reference.  Most important is this one:
9  *
10  * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html
11  *
12  * Authors:
13  *   Bob Jamison
14  *
15  * Copyright (C) 2005 Bob Jamison
16  *
17  *  This library is free software; you can redistribute it and/or
18  *  modify it under the terms of the GNU Lesser General Public
19  *  License as published by the Free Software Foundation; either
20  *  version 2.1 of the License, or (at your option) any later version.
21  *
22  *  This library is distributed in the hope that it will be useful,
23  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
24  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25  *  Lesser General Public License for more details.
26  *
27  *  You should have received a copy of the GNU Lesser General Public
28  *  License along with this library; if not, write to the Free Software
29  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
30  */
32 #include "dom/dom.h"
34 #ifdef HAVE_SSL
35 #include <openssl/ssl.h>
36 #endif
38 namespace org
39 {
40 namespace w3c
41 {
42 namespace dom
43 {
44 namespace io
45 {
47 class TcpSocket
48 {
49 public:
51     TcpSocket();
53     TcpSocket(const DOMString &hostname, int port);
55     TcpSocket(const TcpSocket &other);
57     virtual ~TcpSocket();
59     bool isConnected();
61     void enableSSL(bool val);
63     bool connect(const DOMString &hostname, int portno);
65     bool startTls();
67     bool connect();
69     bool disconnect();
71     bool setReceiveTimeout(unsigned long millis);
73     long available();
75     bool write(int ch);
77     bool write(const DOMString &str);
79     int read();
81     bool readLine(DOMString &result);
83 private:
85     void init();
87     DOMString hostname;
88     int  portno;
89     int  sock;
90     bool connected;
92     bool sslEnabled;
94     unsigned long receiveTimeout;
96 #ifdef HAVE_SSL
97     SSL_CTX *sslContext;
98     SSL *sslStream;
99 #endif
101 };
106 }  //namespace io
107 }  //namespace dom
108 }  //namespace w3c
109 }  //namespace org
111 #endif /* __DOM_SOCKET_H__ */
112 //#########################################################################
113 //# E N D    O F    F I L E
114 //#########################################################################