Mercurial > pidgin.yaz
comparison libpurple/protocols/oscar/peer.h @ 15374:5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sat, 20 Jan 2007 02:32:10 +0000 |
parents | |
children | 32c366eeeb99 |
comparison
equal
deleted
inserted
replaced
15373:f79e0f4df793 | 15374:5fe8042783c1 |
---|---|
1 /* | |
2 * Gaim's oscar protocol plugin | |
3 * This file is the legal property of its developers. | |
4 * Please see the AUTHORS file distributed alongside this file. | |
5 * | |
6 * This library is free software; you can redistribute it and/or | |
7 * modify it under the terms of the GNU Lesser General Public | |
8 * License as published by the Free Software Foundation; either | |
9 * version 2 of the License, or (at your option) any later version. | |
10 * | |
11 * This library is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * Lesser General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU Lesser General Public | |
17 * License along with this library; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 */ | |
20 | |
21 /* | |
22 * OFT and ODC Services | |
23 */ | |
24 | |
25 #ifndef _PEER_H_ | |
26 #define _PEER_H_ | |
27 | |
28 #include "ft.h" | |
29 #include "network.h" | |
30 #include "proxy.h" | |
31 | |
32 typedef struct _ChecksumData ChecksumData; | |
33 typedef struct _OdcFrame OdcFrame; | |
34 typedef struct _OftFrame OftFrame; | |
35 typedef struct _ProxyFrame ProxyFrame; | |
36 typedef struct _PeerConnection PeerConnection; | |
37 | |
38 #define PEER_CONNECTION_FLAG_INITIATED_BY_ME 0x0001 | |
39 #define PEER_CONNECTION_FLAG_APPROVED 0x0002 | |
40 #define PEER_CONNECTION_FLAG_TRIED_DIRECT 0x0004 | |
41 #define PEER_CONNECTION_FLAG_TRIED_INCOMING 0x0008 | |
42 #define PEER_CONNECTION_FLAG_TRIED_PROXY 0x0010 | |
43 #define PEER_CONNECTION_FLAG_IS_INCOMING 0x0020 | |
44 | |
45 #define PEER_TYPE_PROMPT 0x0101 /* "I am going to send you this file, is that ok?" */ | |
46 #define PEER_TYPE_RESUMEACCEPT 0x0106 /* We are accepting the resume */ | |
47 #define PEER_TYPE_ACK 0x0202 /* "Yes, it is ok for you to send me that file" */ | |
48 #define PEER_TYPE_DONE 0x0204 /* "I received that file with no problems, thanks a bunch" */ | |
49 #define PEER_TYPE_RESUME 0x0205 /* Resume transferring, sent by whoever receives */ | |
50 #define PEER_TYPE_RESUMEACK 0x0207 /* Our resume accept was ACKed */ | |
51 | |
52 #define PEER_TYPE_GETFILE_REQUESTLISTING 0x1108 /* "I have a listing.txt file, do you want it?" */ | |
53 #define PEER_TYPE_GETFILE_RECEIVELISTING 0x1209 /* "Yes, please send me your listing.txt file" */ | |
54 #define PEER_TYPE_GETFILE_RECEIVEDLISTING 0x120a /* received corrupt listing.txt file? I'm just guessing about this one... */ | |
55 #define PEER_TYPE_GETFILE_ACKLISTING 0x120b /* "I received the listing.txt file successfully" */ | |
56 #define PEER_TYPE_GETFILE_REQUESTFILE 0x120c /* "Please send me this file" */ | |
57 | |
58 /* | |
59 * For peer proxying | |
60 */ | |
61 #define PEER_PROXY_SERVER "ars.oscar.aol.com" | |
62 #define PEER_PROXY_PORT 5190 /* The port we should always connect to */ | |
63 #define PEER_PROXY_PACKET_VERSION 0x044a | |
64 | |
65 /* Thanks to Keith Lea and the Joust project for documenting these */ | |
66 #define PEER_PROXY_TYPE_ERROR 0x0001 | |
67 #define PEER_PROXY_TYPE_CREATE 0x0002 | |
68 #define PEER_PROXY_TYPE_CREATED 0x0003 | |
69 #define PEER_PROXY_TYPE_JOIN 0x0004 | |
70 #define PEER_PROXY_TYPE_READY 0x0005 | |
71 | |
72 struct _OdcFrame | |
73 { | |
74 /* guchar magic[4]; */ /* 0 */ | |
75 /* guint16 length; */ /* 4 */ | |
76 guint16 type; /* 6 */ | |
77 guint16 subtype; /* 8 */ | |
78 /* Unknown */ /* 10 */ | |
79 guchar cookie[8]; /* 12 */ | |
80 /* Unknown */ | |
81 /* guint32 payloadlength; */ /* 28 */ | |
82 guint16 encoding; /* 32 */ | |
83 /* Unknown */ | |
84 guint16 flags; /* 38 */ | |
85 /* Unknown */ | |
86 guchar sn[32]; /* 44 */ | |
87 /* Unknown */ | |
88 ByteStream payload; /* 76 */ | |
89 }; | |
90 | |
91 struct _OftFrame | |
92 { | |
93 /* guchar magic[4]; */ /* 0 */ | |
94 /* guint16 length; */ /* 4 */ | |
95 guint16 type; /* 6 */ | |
96 guchar cookie[8]; /* 8 */ | |
97 guint16 encrypt; /* 16 */ | |
98 guint16 compress; /* 18 */ | |
99 guint16 totfiles; /* 20 */ | |
100 guint16 filesleft; /* 22 */ | |
101 guint16 totparts; /* 24 */ | |
102 guint16 partsleft; /* 26 */ | |
103 guint32 totsize; /* 28 */ | |
104 guint32 size; /* 32 */ | |
105 guint32 modtime; /* 36 */ | |
106 guint32 checksum; /* 40 */ | |
107 guint32 rfrcsum; /* 44 */ | |
108 guint32 rfsize; /* 48 */ | |
109 guint32 cretime; /* 52 */ | |
110 guint32 rfcsum; /* 56 */ | |
111 guint32 nrecvd; /* 60 */ | |
112 guint32 recvcsum; /* 64 */ | |
113 guchar idstring[32]; /* 68 */ | |
114 guint8 flags; /* 100 */ | |
115 guint8 lnameoffset; /* 101 */ | |
116 guint8 lsizeoffset; /* 102 */ | |
117 guchar dummy[69]; /* 103 */ | |
118 guchar macfileinfo[16]; /* 172 */ | |
119 guint16 nencode; /* 188 */ | |
120 guint16 nlanguage; /* 190 */ | |
121 guchar *name; /* 192 */ | |
122 size_t name_length; | |
123 /* Payload? */ /* 256 */ | |
124 }; | |
125 | |
126 struct _ProxyFrame | |
127 { | |
128 /* guint16 length; */ /* 0 */ | |
129 guint16 version; /* 2 */ | |
130 guint16 type; /* 4 */ | |
131 guint32 unknown; /* 6 */ | |
132 guint16 flags; /* 10 */ | |
133 ByteStream payload; /* 12 */ | |
134 }; | |
135 | |
136 struct _PeerConnection | |
137 { | |
138 OscarData *od; | |
139 OscarCapability type; | |
140 char *sn; | |
141 guchar magic[4]; | |
142 guchar cookie[8]; | |
143 guint16 lastrequestnumber; | |
144 | |
145 gboolean ready; | |
146 int flags; /**< Bitmask of PEER_CONNECTION_FLAG_ */ | |
147 time_t lastactivity; /**< Time of last transmit. */ | |
148 guint destroy_timeout; | |
149 OscarDisconnectReason disconnect_reason; | |
150 char *error_message; | |
151 | |
152 /** | |
153 * A pointer to either an OdcFrame or an OftFrame. | |
154 */ | |
155 gpointer frame; | |
156 | |
157 /** | |
158 * This is only used when the peer connection is being established. | |
159 */ | |
160 GaimProxyConnectData *client_connect_data; | |
161 GaimProxyConnectData *verified_connect_data; | |
162 | |
163 /** | |
164 * This is only used when the peer connection is being established. | |
165 */ | |
166 GaimNetworkListenData *listen_data; | |
167 | |
168 | |
169 /** | |
170 * This is only used when the peer connection is being established. | |
171 */ | |
172 guint connect_timeout_timer; | |
173 | |
174 /** | |
175 * This is only used while the remote user is attempting to | |
176 * connect to us. | |
177 */ | |
178 int listenerfd; | |
179 | |
180 int fd; | |
181 guint8 header[6]; | |
182 ssize_t header_received; | |
183 guint8 proxy_header[12]; | |
184 ssize_t proxy_header_received; | |
185 ByteStream buffer_incoming; | |
186 GaimCircBuffer *buffer_outgoing; | |
187 guint watcher_incoming; | |
188 guint watcher_outgoing; | |
189 | |
190 /** | |
191 * IP address of the proxy server, if applicable. | |
192 */ | |
193 gchar *proxyip; | |
194 | |
195 /** | |
196 * IP address of the remote user from THEIR point of view. | |
197 */ | |
198 gchar *clientip; | |
199 | |
200 /** | |
201 * IP address of the remote user from the oscar server's | |
202 * point of view. | |
203 */ | |
204 gchar *verifiedip; | |
205 | |
206 guint16 port; | |
207 gboolean use_proxy; | |
208 | |
209 /** | |
210 * Checksumming | |
211 */ | |
212 ChecksumData *checksum_data; | |
213 | |
214 /* TODOFT */ | |
215 GaimXfer *xfer; | |
216 OftFrame xferdata; | |
217 guint sending_data_timer; | |
218 }; | |
219 | |
220 /* | |
221 * For all peer connections | |
222 */ | |
223 | |
224 /** | |
225 * Create a new PeerConnection structure and initialize it with some | |
226 * sane defaults. | |
227 * | |
228 * @param type The type of the peer connection. One of | |
229 * OSCAR_CAPABILITY_DIRECTIM or OSCAR_CAPABILITY_SENDFILE. | |
230 */ | |
231 PeerConnection *peer_connection_new(OscarData *od, OscarCapability type, const char *sn); | |
232 | |
233 void peer_connection_destroy(PeerConnection *conn, OscarDisconnectReason reason, const gchar *error_message); | |
234 void peer_connection_schedule_destroy(PeerConnection *conn, OscarDisconnectReason reason, const gchar *error_message); | |
235 PeerConnection *peer_connection_find_by_type(OscarData *od, const char *sn, OscarCapability type); | |
236 PeerConnection *peer_connection_find_by_cookie(OscarData *od, const char *sn, const guchar *cookie); | |
237 | |
238 void peer_connection_listen_cb(gpointer data, gint source, GaimInputCondition cond); | |
239 void peer_connection_recv_cb(gpointer data, gint source, GaimInputCondition cond); | |
240 void peer_connection_send(PeerConnection *conn, ByteStream *bs); | |
241 | |
242 void peer_connection_trynext(PeerConnection *conn); | |
243 void peer_connection_finalize_connection(PeerConnection *conn); | |
244 void peer_connection_propose(OscarData *od, OscarCapability type, const char *sn); | |
245 void peer_connection_got_proposition(OscarData *od, const gchar *sn, const gchar *message, IcbmArgsCh2 *args); | |
246 | |
247 /* | |
248 * For ODC | |
249 */ | |
250 void peer_odc_close(PeerConnection *conn); | |
251 void peer_odc_recv_frame(PeerConnection *conn, ByteStream *bs); | |
252 void peer_odc_send_cookie(PeerConnection *conn); | |
253 void peer_odc_send_typing(PeerConnection *conn, GaimTypingState typing); | |
254 void peer_odc_send_im(PeerConnection *conn, const char *msg, int len, int encoding, gboolean autoreply); | |
255 | |
256 /* | |
257 * For OFT | |
258 */ | |
259 void peer_oft_close(PeerConnection *conn); | |
260 void peer_oft_recv_frame(PeerConnection *conn, ByteStream *bs); | |
261 void peer_oft_send_prompt(PeerConnection *conn); | |
262 void peer_oft_checksum_destroy(ChecksumData *checksum_data); | |
263 | |
264 /* Xfer callbacks for receiving a file */ | |
265 void peer_oft_recvcb_init(GaimXfer *xfer); | |
266 void peer_oft_recvcb_end(GaimXfer *xfer); | |
267 void peer_oft_recvcb_ack_recv(GaimXfer *xfer, const guchar *buffer, size_t size); | |
268 | |
269 /* Xfer callbacks for sending a file */ | |
270 void peer_oft_sendcb_init(GaimXfer *xfer); | |
271 void peer_oft_sendcb_ack(GaimXfer *xfer, const guchar *buffer, size_t size); | |
272 | |
273 /* Xfer callbacks for both sending and receiving */ | |
274 void peer_oft_cb_generic_cancel(GaimXfer *xfer); | |
275 | |
276 /* | |
277 * For peer proxying | |
278 */ | |
279 void peer_proxy_connection_established_cb(gpointer data, gint source, const gchar *error_message); | |
280 | |
281 #if 0 | |
282 int peer_oft_sendheader(OscarData *od, guint16 type, PeerConnection *peer_connection); | |
283 guint32 peer_oft_checksum_chunk(const guint8 *buffer, int bufferlen, guint32 prevcheck); | |
284 guint32 peer_oft_checksum_file(char *filename); | |
285 int peer_oft_sendheader(OscarData *od, guint16 type, PeerConnection *peer_connection); | |
286 PeerConnection *peer_oft_createinfo(OscarData *od, const guchar *cookie, const char *sn, | |
287 const char *ip, guint16 port, guint32 size, guint32 modtime, char *filename, int send_or_recv, | |
288 int method, int stage); | |
289 int peer_oft_destroyinfo(PeerConnection *peer_connection); | |
290 #endif | |
291 | |
292 #endif /* _PEER_H_ */ |