comparison libpurple/protocols/msnp9/servconn.h @ 21312:a07cfce78345

Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly old fools like me who prefer the stability of our MSNP9 code over the features of MSNP14 can enable this using the --disable-msnp14 ./configure option. If we want to release from i.p.p and MSN stability is the only blocker, we can trivially flick the default to use MSNP9 in configure.ac
author Stu Tomlinson <stu@nosnilmot.com>
date Sun, 11 Nov 2007 12:57:52 +0000
parents
children
comparison
equal deleted inserted replaced
21311:7d031cec5ba2 21312:a07cfce78345
1 /**
2 * @file servconn.h Server connection functions
3 *
4 * purple
5 *
6 * Purple 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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
23 */
24 #ifndef _MSN_SERVCONN_H_
25 #define _MSN_SERVCONN_H_
26
27 typedef struct _MsnServConn MsnServConn;
28
29 #include "session.h"
30 #include "cmdproc.h"
31
32 #include "proxy.h"
33 #include "httpconn.h"
34
35 /**
36 * Connection error types.
37 */
38 typedef enum
39 {
40 MSN_SERVCONN_ERROR_NONE,
41 MSN_SERVCONN_ERROR_CONNECT,
42 MSN_SERVCONN_ERROR_WRITE,
43 MSN_SERVCONN_ERROR_READ,
44
45 } MsnServConnError;
46
47 /**
48 * Connection types.
49 */
50 typedef enum
51 {
52 MSN_SERVCONN_NS,
53 MSN_SERVCONN_SB
54
55 } MsnServConnType;
56
57 /**
58 * A Connection.
59 */
60 struct _MsnServConn
61 {
62 MsnServConnType type; /**< The type of this connection. */
63 MsnSession *session; /**< The MSN session of this connection. */
64 MsnCmdProc *cmdproc; /**< The command processor of this connection. */
65
66 PurpleProxyConnectData *connect_data;
67
68 gboolean connected; /**< A flag that states if it's connected. */
69 gboolean processing; /**< A flag that states if something is working
70 with this connection. */
71 gboolean wasted; /**< A flag that states if it should be destroyed. */
72
73 char *host; /**< The host this connection is connected or should be
74 connected to. */
75 int num; /**< A number id of this connection. */
76
77 MsnHttpConn *httpconn; /**< The HTTP connection this connection should use. */
78
79 int fd; /**< The connection's file descriptor. */
80 int inpa; /**< The connection's input handler. */
81
82 char *rx_buf; /**< The receive buffer. */
83 int rx_len; /**< The receive buffer lenght. */
84
85 size_t payload_len; /**< The length of the payload.
86 It's only set when we've received a command that
87 has a payload. */
88
89 PurpleCircBuffer *tx_buf;
90 guint tx_handler;
91
92 void (*connect_cb)(MsnServConn *); /**< The callback to call when connecting. */
93 void (*disconnect_cb)(MsnServConn *); /**< The callback to call when disconnecting. */
94 void (*destroy_cb)(MsnServConn *); /**< The callback to call when destroying. */
95 };
96
97 /**
98 * Creates a new connection object.
99 *
100 * @param session The session.
101 * @param type The type of the connection.
102 */
103 MsnServConn *msn_servconn_new(MsnSession *session, MsnServConnType type);
104
105 /**
106 * Destroys a connection object.
107 *
108 * @param servconn The connection.
109 */
110 void msn_servconn_destroy(MsnServConn *servconn);
111
112 /**
113 * Connects to a host.
114 *
115 * @param servconn The connection.
116 * @param host The host.
117 * @param port The port.
118 */
119 gboolean msn_servconn_connect(MsnServConn *servconn, const char *host, int port);
120
121 /**
122 * Disconnects.
123 *
124 * @param servconn The connection.
125 */
126 void msn_servconn_disconnect(MsnServConn *servconn);
127
128 /**
129 * Sets the connect callback.
130 *
131 * @param servconn The servconn.
132 * @param connect_cb The connect callback.
133 */
134 void msn_servconn_set_connect_cb(MsnServConn *servconn,
135 void (*connect_cb)(MsnServConn *));
136 /**
137 * Sets the disconnect callback.
138 *
139 * @param servconn The servconn.
140 * @param disconnect_cb The disconnect callback.
141 */
142 void msn_servconn_set_disconnect_cb(MsnServConn *servconn,
143 void (*disconnect_cb)(MsnServConn *));
144 /**
145 * Sets the destroy callback.
146 *
147 * @param servconn The servconn that's being destroyed.
148 * @param destroy_cb The destroy callback.
149 */
150 void msn_servconn_set_destroy_cb(MsnServConn *servconn,
151 void (*destroy_cb)(MsnServConn *));
152
153 /**
154 * Writes a chunck of data to the servconn.
155 *
156 * @param servconn The servconn.
157 * @param buf The data to write.
158 * @param size The size of the data.
159 */
160 ssize_t msn_servconn_write(MsnServConn *servconn, const char *buf,
161 size_t size);
162
163 /**
164 * Function to call whenever an error related to a switchboard occurs.
165 *
166 * @param servconn The servconn.
167 * @param error The error that happened.
168 */
169 void msn_servconn_got_error(MsnServConn *servconn, MsnServConnError error);
170
171 #endif /* _MSN_SERVCONN_H_ */