| |
1 /** |
| |
2 * @file httpconn.h HTTP connection |
| |
3 * |
| |
4 * gaim |
| |
5 * |
| |
6 * Gaim is the legal property of its developers, whose names are too numerous |
| |
7 * to list here. Please refer to the COPYRIGHT file distributed with this |
| |
8 * source distribution. |
| |
9 * |
| |
10 * This program is free software; you can redistribute it and/or modify |
| |
11 * it under the terms of the GNU General Public License as published by |
| |
12 * the Free Software Foundation; either version 2 of the License, or |
| |
13 * (at your option) any later version. |
| |
14 * |
| |
15 * This program is distributed in the hope that it will be useful, |
| |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| |
18 * GNU General Public License for more details. |
| |
19 * |
| |
20 * You should have received a copy of the GNU General Public License |
| |
21 * along with this program; if not, write to the Free Software |
| |
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| |
23 */ |
| |
24 #ifndef _MSN_HTTPCONN_H_ |
| |
25 #define _MSN_HTTPCONN_H_ |
| |
26 |
| |
27 typedef struct _MsnHttpConn MsnHttpConn; |
| |
28 |
| |
29 #include "servconn.h" |
| |
30 |
| |
31 struct _MsnHttpConn |
| |
32 { |
| |
33 MsnSession *session; |
| |
34 MsnServConn *servconn; |
| |
35 |
| |
36 char *full_session_id; |
| |
37 char *session_id; |
| |
38 |
| |
39 int timer; |
| |
40 |
| |
41 gboolean waiting_response; |
| |
42 gboolean dirty; /**< The flag that states if we should poll. */ |
| |
43 gboolean connected; |
| |
44 |
| |
45 char *host; |
| |
46 GList *queue; |
| |
47 |
| |
48 int fd; |
| |
49 int inpa; |
| |
50 |
| |
51 char *rx_buf; |
| |
52 int rx_len; |
| |
53 |
| |
54 #if 0 |
| |
55 GQueue *servconn_queue; |
| |
56 #endif |
| |
57 |
| |
58 gboolean virgin; |
| |
59 }; |
| |
60 |
| |
61 MsnHttpConn *msn_httpconn_new(MsnServConn *servconn); |
| |
62 void msn_httpconn_destroy(MsnHttpConn *httpconn); |
| |
63 size_t msn_httpconn_write(MsnHttpConn *httpconn, const char *buf, size_t size); |
| |
64 |
| |
65 gboolean msn_httpconn_connect(MsnHttpConn *httpconn, |
| |
66 const char *host, int port); |
| |
67 void msn_httpconn_disconnect(MsnHttpConn *httpconn); |
| |
68 |
| |
69 #if 0 |
| |
70 void msn_httpconn_queue_servconn(MsnHttpConn *httpconn, MsnServConn *servconn); |
| |
71 #endif |
| |
72 |
| |
73 #if 0 |
| |
74 /** |
| |
75 * Initializes the HTTP data for a session. |
| |
76 * |
| |
77 * @param session The session. |
| |
78 */ |
| |
79 void msn_http_session_init(MsnSession *session); |
| |
80 |
| |
81 /** |
| |
82 * Uninitializes the HTTP data for a session. |
| |
83 * |
| |
84 * @param session The session. |
| |
85 */ |
| |
86 void msn_http_session_uninit(MsnSession *session); |
| |
87 |
| |
88 /** |
| |
89 * Writes data to the server using the HTTP connection method. |
| |
90 * |
| |
91 * @param servconn The server connection. |
| |
92 * @param buf The data to write. |
| |
93 * @param size The size of the data to write. |
| |
94 * @param server_type The optional server type. |
| |
95 * |
| |
96 * @return The number of bytes written. |
| |
97 */ |
| |
98 size_t msn_http_servconn_write(MsnServConn *servconn, const char *buf, |
| |
99 size_t size, const char *server_type); |
| |
100 |
| |
101 /** |
| |
102 * Polls the server for data. |
| |
103 * |
| |
104 * @param servconn The server connection. |
| |
105 */ |
| |
106 void msn_http_servconn_poll(MsnServConn *servconn); |
| |
107 |
| |
108 /** |
| |
109 * Processes an incoming message and returns a string the rest of MSN |
| |
110 * can deal with. |
| |
111 * |
| |
112 * @param servconn The server connection. |
| |
113 * @param buf The incoming buffer. |
| |
114 * @param size The incoming size. |
| |
115 * @param ret_buf The returned buffer. |
| |
116 * @param ret_len The returned length. |
| |
117 * @param error TRUE if there was an HTTP error. |
| |
118 * |
| |
119 * @return TRUE if the returned buffer is ready to be processed. |
| |
120 * FALSE otherwise. |
| |
121 */ |
| |
122 gboolean msn_http_servconn_parse_data(MsnServConn *servconn, |
| |
123 const char *buf, size_t size, |
| |
124 char **ret_buf, size_t *ret_size, |
| |
125 gboolean *error); |
| |
126 #endif |
| |
127 |
| |
128 #endif /* _MSN_HTTPCONN_H_ */ |