Mon, 16 Apr 2007 00:43:53 +0000
Commit a proper copy of this binary file. The old one was corrupted,
probably due to missing SVN attributes.
This was retrieved from the following URL, though we may have it in CVS:
http://dev.openwengo.com/trac/openwengo/trac.cgi/browser/vendors/gaim/trunk/doc/oscar/On_Sending_Files_via_OSCAR.odt?rev=4273
| 8675 | 1 | /* |
| 2 | * nmconn.h | |
| 3 | * | |
|
8933
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
4 | * Copyright (c) 2004 Novell, Inc. All Rights Reserved. |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
5 | * |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
6 | * This program is free software; you can redistribute it and/or modify |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
7 | * it under the terms of the GNU General Public License as published by |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
8 | * the Free Software Foundation; version 2 of the License. |
| 8675 | 9 | * |
|
8933
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
13 | * GNU General Public License for more details. |
|
8684
7ec649752daa
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
14 | * |
|
8933
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
16 | * along with this program; if not, write to the Free Software |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 8675 | 18 | * |
| 19 | */ | |
| 20 | ||
| 21 | #ifndef __NM_CONN_H__ | |
| 22 | #define __NM_CONN_H__ | |
| 23 | ||
| 24 | typedef struct _NMConn NMConn; | |
| 25 | typedef struct _NMSSLConn NMSSLConn; | |
| 26 | ||
| 27 | #include "nmfield.h" | |
| 28 | #include "nmuser.h" | |
| 29 | ||
| 30 | typedef int (*nm_ssl_read_cb) (gpointer ssl_data, void *buff, int len); | |
| 31 | typedef int (*nm_ssl_write_cb) (gpointer ssl_data, const void *buff, int len); | |
| 32 | ||
| 33 | struct _NMConn | |
| 34 | { | |
| 35 | ||
| 36 | /* The address of the server that we are connecting to. */ | |
| 37 | char *addr; | |
| 38 | ||
| 39 | /* The port that we are connecting to. */ | |
| 40 | int port; | |
| 41 | ||
| 42 | /* The file descriptor of the socket for the connection. */ | |
| 43 | int fd; | |
| 44 | ||
| 45 | /* The transaction counter. */ | |
| 46 | int trans_id; | |
| 47 | ||
| 48 | /* A list of requests currently awaiting a response. */ | |
| 49 | GSList *requests; | |
| 50 | ||
| 51 | /* Are we connected? TRUE if so, FALSE if not. */ | |
| 52 | gboolean connected; | |
| 53 | ||
| 54 | /* Are we running in secure mode? */ | |
| 55 | gboolean use_ssl; | |
| 56 | ||
| 57 | /* Have we been redirected? */ | |
| 58 | gboolean redirect; | |
| 59 | ||
| 60 | /* SSL connection */ | |
| 61 | NMSSLConn *ssl_conn; | |
| 62 | ||
| 63 | }; | |
| 64 | ||
| 65 | struct _NMSSLConn | |
| 66 | { | |
| 67 | ||
| 68 | /* Data to pass to the callbacks */ | |
| 69 | gpointer data; | |
| 70 | ||
| 71 | /* Callbacks for reading/writing */ | |
| 72 | nm_ssl_read_cb read; | |
| 73 | nm_ssl_write_cb write; | |
| 74 | ||
| 75 | }; | |
| 76 | ||
| 77 | /** | |
|
9360
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
78 | * Allocate a new NMConn struct |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
79 | * |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
80 | * @param The address of the server that we are connecting to. |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
81 | * @param The port that we are connecting to. |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
82 | * |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
83 | * @return A pointer to a newly allocated NMConn struct, should |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
84 | * be freed by calling nm_release_conn() |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
85 | */ |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
86 | NMConn *nm_create_conn(const char *addr, int port); |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
87 | |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
88 | /** |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
89 | * Release an NMConn |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
90 | * |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
91 | * @param Pointer to the NMConn to release. |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
92 | * |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
93 | */ |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
94 | void nm_release_conn(NMConn *conn); |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
95 | |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
96 | /** |
| 8675 | 97 | * Write len bytes from the given buffer. |
| 98 | * | |
| 99 | * @param conn The connection to write to. | |
| 100 | * @param buff The buffer to write from. | |
| 101 | * @param len The number of bytes to write. | |
| 102 | * | |
| 103 | * @return The number of bytes written. | |
| 104 | */ | |
| 105 | int nm_tcp_write(NMConn * conn, const void *buff, int len); | |
| 106 | ||
| 107 | /** | |
| 108 | * Read at most len bytes into the given buffer. | |
| 109 | * | |
| 110 | * @param conn The connection to read from. | |
| 111 | * @param buff The buffer to write to. | |
| 112 | * @param len The maximum number of bytes to read. | |
| 113 | * | |
| 114 | * @return The number of bytes read. | |
| 115 | */ | |
| 116 | int nm_tcp_read(NMConn * conn, void *buff, int len); | |
| 117 | ||
| 118 | /** | |
| 119 | * Read exactly len bytes into the given buffer. | |
| 120 | * | |
| 121 | * @param conn The connection to read from. | |
| 122 | * @param buff The buffer to write to. | |
| 123 | * @param len The number of bytes to read. | |
| 124 | * | |
| 125 | * @return NM_OK on success, NMERR_TCP_READ if read fails. | |
| 126 | */ | |
| 127 | NMERR_T nm_read_all(NMConn * conn, char *buf, int len); | |
| 128 | ||
| 129 | /** | |
|
8874
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
130 | * Read a 32 bit value and convert it to the host byte order. |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
131 | * |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
132 | * @param conn The connection to read from. |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
133 | * @param val A pointer to unsigned 32 bit integer |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
134 | * |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
135 | * @return NM_OK on success, NMERR_TCP_READ if read fails. |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
136 | */ |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
137 | NMERR_T |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
138 | nm_read_uint32(NMConn *conn, guint32 *val); |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
139 | |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
140 | /** |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
141 | * Read a 16 bit value and convert it to the host byte order. |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
142 | * |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
143 | * @param conn The connection to read from. |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
144 | * @param val A pointer to unsigned 16 bit integer |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
145 | * |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
146 | * @return NM_OK on success, NMERR_TCP_READ if read fails. |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
147 | */ |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
148 | NMERR_T |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
149 | nm_read_uint16(NMConn *conn, guint16 *val); |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
150 | |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
151 | /** |
| 8675 | 152 | * Dispatch a request to the server. |
| 153 | * | |
| 154 | * @param conn The connection. | |
| 155 | * @param cmd The request to dispatch. | |
| 156 | * @param fields The field list for the request. | |
|
9360
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
157 | * @param cb The response callback for the new request object. |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
158 | * @param data The user defined data for the request (to be passed to the resp cb). |
| 8675 | 159 | * @param req The request. Should be freed with nm_release_request. |
| 160 | * | |
| 161 | * @return NM_OK on success. | |
| 162 | */ | |
|
9360
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
163 | NMERR_T |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
164 | nm_send_request(NMConn *conn, char *cmd, NMField *fields, |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
165 | nm_response_cb cb, gpointer data, NMRequest **request); |
| 8675 | 166 | |
| 167 | /** | |
| 168 | * Write out the given field list. | |
| 169 | * | |
| 170 | * @param conn The connection to write to. | |
| 171 | * @param fields The field list to write. | |
| 172 | * | |
| 173 | * @return NM_OK on success. | |
| 174 | */ | |
| 175 | NMERR_T nm_write_fields(NMConn * conn, NMField * fields); | |
| 176 | ||
| 177 | /** | |
| 178 | * Read the headers for a response. | |
| 179 | * | |
| 180 | * @param conn The connection to read from. | |
| 181 | * | |
| 182 | * @return NM_OK on success. | |
| 183 | */ | |
| 184 | NMERR_T nm_read_header(NMConn * conn); | |
| 185 | ||
| 186 | /** | |
| 187 | * Read a field list from the connection. | |
| 188 | * | |
| 189 | * @param conn The connection to read from. | |
| 190 | * @param count The maximum number of fields to read (or -1 for no max). | |
| 191 | * @param fields The field list. This is an out param. It | |
| 192 | * should be freed by calling nm_free_fields | |
| 193 | * when finished. | |
| 194 | * | |
| 195 | * @return NM_OK on success. | |
| 196 | */ | |
| 197 | NMERR_T nm_read_fields(NMConn * conn, int count, NMField ** fields); | |
| 198 | ||
| 199 | /** | |
| 200 | * Add a request to the connections request list. | |
| 201 | * | |
| 202 | * @param conn The connection. | |
| 203 | * @param request The request to add to the list. | |
| 204 | */ | |
| 205 | void nm_conn_add_request_item(NMConn * conn, NMRequest * request); | |
| 206 | ||
| 207 | /** | |
| 208 | * Remove a request from the connections list. | |
| 209 | * | |
| 210 | * @param conn The connection. | |
| 211 | * @param request The request to remove from the list. | |
| 212 | */ | |
| 213 | void nm_conn_remove_request_item(NMConn * conn, NMRequest * request); | |
| 214 | ||
| 215 | /** | |
| 216 | * Find the request with the given transaction id in the connections | |
| 217 | * request list. | |
| 218 | * | |
| 219 | * @param conn The connection. | |
| 220 | * @param trans_id The transaction id of the request to return. | |
| 221 | * | |
| 222 | * @return The request, or NULL if a matching request is not | |
| 223 | * found. | |
| 224 | */ | |
| 225 | NMRequest *nm_conn_find_request(NMConn * conn, int trans_id); | |
| 226 | ||
| 227 | /** | |
| 228 | * Get the server address for the connection. | |
| 229 | * | |
| 230 | * @param conn The connection. | |
| 231 | * | |
| 232 | * @return The server address for the connection. | |
| 233 | * | |
| 234 | */ | |
| 235 | const char *nm_conn_get_addr(NMConn * conn); | |
| 236 | ||
| 237 | /** | |
| 238 | * Get the port for the connection. | |
| 239 | * | |
| 240 | * @param conn The connection. | |
| 241 | * | |
| 242 | * @return The port that we are connected to. | |
| 243 | */ | |
| 244 | int nm_conn_get_port(NMConn * conn); | |
| 245 | ||
| 246 | #endif |