Mercurial > pidgin.yaz
annotate src/protocols/oscar/ft.c @ 4173:b66f960bfe60
[gaim-migrate @ 4403]
So type is actually 1 byte, and not 2.
Something about an ass out of u and me.
This should make multi-recipient ICQ messages work.
It also fixes a little mistake that caused ICQ URLs,
auth requests, pager messages, emails, and ICQ cotact
sending thingies to not show up. I don't think that
bug existed for more than a more days.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 02 Jan 2003 22:22:38 +0000 |
parents | 9891c1458eb7 |
children | 858979ab3867 |
rev | line source |
---|---|
2086 | 1 /* |
2 * File transfer (OFT) and DirectIM (ODC). | |
3 * (OSCAR File Transfer, Oscar Direct Connect(ion?) | |
4 */ | |
5 | |
6 #define FAIM_INTERNAL | |
2931 | 7 |
2711
b7455c506979
[gaim-migrate @ 2724]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2675
diff
changeset
|
8 #ifdef HAVE_CONFIG_H |
b7455c506979
[gaim-migrate @ 2724]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2675
diff
changeset
|
9 #include <config.h> |
b7455c506979
[gaim-migrate @ 2724]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2675
diff
changeset
|
10 #endif |
2086 | 11 #include <aim.h> |
12 | |
13 #ifndef _WIN32 | |
14 #include <netdb.h> | |
15 #include <sys/socket.h> | |
16 #include <netinet/in.h> | |
17 #include <sys/utsname.h> /* for aim_directim_initiate */ | |
3630 | 18 #include <arpa/inet.h> /* for inet_ntoa */ |
3960 | 19 #define G_DIR_SEPARATOR '/' |
3646
bfd8df165f32
[gaim-migrate @ 3770]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
20 #endif |
bfd8df165f32
[gaim-migrate @ 3770]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
21 |
bfd8df165f32
[gaim-migrate @ 3770]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
22 #ifdef _WIN32 |
3630 | 23 #include "win32dep.h" |
24 #endif | |
2086 | 25 |
3771 | 26 #define AIM_OFT_PROTO_OFFER 0x0101 |
27 #define AIM_OFT_PROTO_ACCEPT 0x0202 | |
28 #define AIM_OFT_PROTO_RESUME 0x0205 | |
29 #define AIM_OFT_PROTO_RESUMEACCEPT 0x0207 | |
30 #define AIM_OFT_PROTO_ACK 0x0204 | |
2086 | 31 |
3771 | 32 struct aim_filetransfer_priv { |
33 char sn[MAXSNLEN+1]; | |
34 char cookie[8]; | |
35 char ip[30]; | |
36 int state; | |
37 struct aim_fileheader_t fh; | |
38 }; | |
2086 | 39 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
40 struct aim_directim_intdata { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
41 fu8_t cookie[8]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
42 char sn[MAXSNLEN+1]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
43 char ip[22]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
44 }; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
45 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
46 static int listenestablish(fu16_t portnum); |
3952 | 47 static struct aim_fileheader_t *aim_oft_getfh(aim_bstream_t *bs); |
48 static void oft_dirconvert(char *name); | |
49 static int aim_oft_buildheader(aim_bstream_t *bs, struct aim_fileheader_t *fh); | |
2086 | 50 |
51 /** | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
52 * aim_handlerendconnect - call this to accept OFT connections and set up the required structures |
2086 | 53 * @sess: the session |
54 * @cur: the conn the incoming connection is on | |
55 * | |
56 * call this when you get an outstanding read on a conn with subtype | |
57 * AIM_CONN_SUBTYPE_RENDEZVOUS_OUT, it will clone the current | |
58 * &aim_conn_t and tweak things as appropriate. the new conn and the | |
59 * listener conn are both returned to the client in the | |
60 * %AIM_CB_FAM_OFT, %AIM_CB_OFT_<CLASS>INITIATE callback. | |
61 */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
62 faim_export int aim_handlerendconnect(aim_session_t *sess, aim_conn_t *cur) |
2086 | 63 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
64 int acceptfd = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
65 struct sockaddr cliaddr; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
66 int clilen = sizeof(cliaddr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
67 int ret = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
68 aim_conn_t *newconn; |
2086 | 69 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
70 if ((acceptfd = accept(cur->fd, &cliaddr, &clilen)) == -1) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
71 return 0; /* not an error */ |
2086 | 72 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
73 if (cliaddr.sa_family != AF_INET) { /* just in case IPv6 really is happening */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
74 close(acceptfd); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
75 aim_conn_close(cur); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
76 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
77 } |
2086 | 78 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
79 if (!(newconn = aim_cloneconn(sess, cur))) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
80 close(acceptfd); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
81 aim_conn_close(cur); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
82 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
83 } |
2086 | 84 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
85 newconn->type = AIM_CONN_TYPE_RENDEZVOUS; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
86 newconn->fd = acceptfd; |
2086 | 87 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
88 if (newconn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
89 struct aim_directim_intdata *priv; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
90 aim_rxcallback_t userfunc; |
2086 | 91 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
92 priv = (struct aim_directim_intdata *)(newconn->internal = cur->internal); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
93 cur->internal = NULL; |
2086 | 94 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
95 snprintf(priv->ip, sizeof(priv->ip), "%s:%u", |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
96 inet_ntoa(((struct sockaddr_in *)&cliaddr)->sin_addr), |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
97 ntohs(((struct sockaddr_in *)&cliaddr)->sin_port)); |
2086 | 98 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
99 if ((userfunc = aim_callhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINITIATE))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
100 ret = userfunc(sess, NULL, newconn, cur); |
2086 | 101 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
102 } else if (newconn->subtype == AIM_CONN_SUBTYPE_OFT_GETFILE) { |
3771 | 103 #if 0 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
104 struct aim_filetransfer_priv *priv; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
105 aim_rxcallback_t userfunc; |
2086 | 106 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
107 newconn->priv = cur->priv; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
108 cur->priv = NULL; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
109 priv = (struct aim_filetransfer_priv *)newconn->priv; |
2086 | 110 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
111 snprintf(priv->ip, sizeof(priv->ip), "%s:%u", inet_ntoa(((struct sockaddr_in *)&cliaddr)->sin_addr), ntohs(((struct sockaddr_in *)&cliaddr)->sin_port)); |
2086 | 112 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
113 if ((userfunc = aim_callhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEINITIATE))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
114 ret = userfunc(sess, NULL, newconn, cur); |
3771 | 115 #endif |
3630 | 116 } else if (newconn->subtype == AIM_CONN_SUBTYPE_OFT_SENDFILE) { |
117 struct aim_filetransfer_priv *ft; | |
118 aim_rxcallback_t userfunc; | |
119 | |
3771 | 120 /* The new conn automatically inherits the internal value |
3630 | 121 * of cur. */ |
3771 | 122 cur->internal = NULL; |
123 ft = (struct aim_filetransfer_priv *)newconn->internal; | |
3630 | 124 |
125 snprintf(ft->ip, sizeof(ft->ip), "%s:%u", inet_ntoa(((struct sockaddr_in *)&cliaddr)->sin_addr), ntohs(((struct sockaddr_in *)&cliaddr)->sin_port)); | |
126 | |
3771 | 127 if ((userfunc = aim_callhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_SENDFILEINITIATE))) |
3630 | 128 ret = userfunc(sess, NULL, newconn, cur); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
129 } else { |
2844
e63cd7fdd9eb
[gaim-migrate @ 2857]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2764
diff
changeset
|
130 faimdprintf(sess, 1,"Got a Connection on a listener that's not Rendezvous Closing conn.\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
131 aim_conn_close(newconn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
132 ret = -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
133 } |
2086 | 134 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
135 return ret; |
2086 | 136 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
137 |
2086 | 138 /** |
2993 | 139 * aim_send_typing - send client-to-client typing notification over established connection |
2086 | 140 * @sess: session to conn |
141 * @conn: directim connection | |
2993 | 142 * @typing: If true, notify user has started typing; if false, notify user has stopped. |
2086 | 143 * |
2993 | 144 * The connection must have been previously established. |
2086 | 145 */ |
2993 | 146 faim_export int aim_send_typing(aim_session_t *sess, aim_conn_t *conn, int typing) |
2086 | 147 { |
3952 | 148 struct aim_directim_intdata *intdata = (struct aim_directim_intdata *)conn->internal; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
149 aim_frame_t *fr; |
3952 | 150 aim_bstream_t *hdrbs; |
151 fu8_t *hdr; | |
152 int hdrlen = 0x44; | |
2086 | 153 |
3952 | 154 if (!sess || !conn || (conn->type != AIM_CONN_TYPE_RENDEZVOUS)) |
155 return -EINVAL; | |
2086 | 156 |
2993 | 157 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_OFT, 0x01, 0))) |
3952 | 158 return -ENOMEM; |
159 memcpy(fr->hdr.rend.magic, "ODC2", 4); | |
160 fr->hdr.rend.hdrlen = hdrlen; | |
2086 | 161 |
3952 | 162 if (!(hdr = calloc(1, hdrlen))) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
163 aim_frame_destroy(fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
164 return -ENOMEM; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
165 } |
3952 | 166 |
167 hdrbs = &(fr->data); | |
168 aim_bstream_init(hdrbs, hdr, hdrlen); | |
2086 | 169 |
3952 | 170 aimbs_put16(hdrbs, 0x0006); |
171 aimbs_put16(hdrbs, 0x0000); | |
172 aimbs_putraw(hdrbs, intdata->cookie, 8); | |
173 aimbs_put16(hdrbs, 0x0000); | |
174 aimbs_put16(hdrbs, 0x0000); | |
175 aimbs_put16(hdrbs, 0x0000); | |
176 aimbs_put16(hdrbs, 0x0000); | |
177 aimbs_put32(hdrbs, 0x00000000); | |
178 aimbs_put16(hdrbs, 0x0000); | |
179 aimbs_put16(hdrbs, 0x0000); | |
180 aimbs_put16(hdrbs, 0x0000); | |
2086 | 181 |
2993 | 182 /* flags -- 0x000e for "started typing", 0x0002 for "stopped typing */ |
3952 | 183 aimbs_put16(hdrbs, ( typing ? 0x000e : 0x0002)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
184 |
3952 | 185 aimbs_put16(hdrbs, 0x0000); |
186 aimbs_put16(hdrbs, 0x0000); | |
187 aimbs_putraw(hdrbs, sess->sn, strlen(sess->sn)); | |
2993 | 188 |
3952 | 189 aim_bstream_setpos(hdrbs, 52); /* bleeehh */ |
2086 | 190 |
3952 | 191 aimbs_put8(hdrbs, 0x00); |
192 aimbs_put16(hdrbs, 0x0000); | |
193 aimbs_put16(hdrbs, 0x0000); | |
194 aimbs_put16(hdrbs, 0x0000); | |
195 aimbs_put16(hdrbs, 0x0000); | |
196 aimbs_put16(hdrbs, 0x0000); | |
197 aimbs_put16(hdrbs, 0x0000); | |
198 aimbs_put16(hdrbs, 0x0000); | |
199 aimbs_put8(hdrbs, 0x00); | |
2086 | 200 |
3952 | 201 /* end of hdr */ |
2086 | 202 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
203 aim_tx_enqueue(sess, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
204 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
205 return 0; |
2086 | 206 } |
207 | |
2993 | 208 /** |
209 * aim_send_im_direct - send IM client-to-client over established connection | |
210 * @sess: session to conn | |
211 * @conn: directim connection | |
3952 | 212 * @msg: null-terminated string to send. |
213 * @len: The length of the message to send, including binary data. | |
214 * @encoding: 0 for ascii, 2 for Unicode, 3 for ISO 8859-1 | |
2993 | 215 * |
216 * Call this just like you would aim_send_im, to send a directim. You | |
217 * _must_ have previously established the directim connection. | |
218 */ | |
3952 | 219 faim_export int aim_send_im_direct(aim_session_t *sess, aim_conn_t *conn, const char *msg, int len, int encoding) |
2993 | 220 { |
221 struct aim_directim_intdata *intdata = (struct aim_directim_intdata *)conn->internal; | |
222 aim_frame_t *fr; | |
3952 | 223 aim_bstream_t *hdrbs; |
224 int hdrlen = 0x44; | |
225 fu8_t *hdr; | |
2993 | 226 |
227 if (!sess || !conn || !msg || (conn->type != AIM_CONN_TYPE_RENDEZVOUS)) | |
228 return -EINVAL; | |
229 | |
3033 | 230 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_OFT, 0x01, len))) |
2993 | 231 return -ENOMEM; |
232 | |
3952 | 233 memcpy(fr->hdr.rend.magic, "ODC2", 4); |
234 fr->hdr.rend.hdrlen = hdrlen; | |
2993 | 235 |
3952 | 236 if (!(hdr = calloc(1, hdrlen + len))) { |
2993 | 237 aim_frame_destroy(fr); |
238 return -ENOMEM; | |
239 } | |
3952 | 240 |
241 hdrbs = &(fr->data); | |
242 aim_bstream_init(hdrbs, hdr, hdrlen + len); | |
243 | |
244 aimbs_put16(hdrbs, 0x0006); | |
245 aimbs_put16(hdrbs, 0x0000); | |
246 aimbs_putraw(hdrbs, intdata->cookie, 8); | |
247 aimbs_put16(hdrbs, 0x0000); | |
248 aimbs_put16(hdrbs, 0x0000); | |
249 aimbs_put16(hdrbs, 0x0000); | |
250 aimbs_put16(hdrbs, 0x0000); | |
251 aimbs_put32(hdrbs, len); | |
252 aimbs_put16(hdrbs, encoding); | |
253 aimbs_put16(hdrbs, 0x0000); | |
254 aimbs_put16(hdrbs, 0x0000); | |
2993 | 255 |
256 /* flags -- 0x000e for "started typing", 0x0002 for "stopped typing, 0x0000 for message */ | |
3952 | 257 aimbs_put16(hdrbs, 0x0000); |
258 | |
259 aimbs_put16(hdrbs, 0x0000); | |
260 aimbs_put16(hdrbs, 0x0000); | |
261 aimbs_putraw(hdrbs, sess->sn, strlen(sess->sn)); | |
262 | |
263 aim_bstream_setpos(hdrbs, 52); /* bleeehh */ | |
264 | |
265 aimbs_put8(hdrbs, 0x00); | |
266 aimbs_put16(hdrbs, 0x0000); | |
267 aimbs_put16(hdrbs, 0x0000); | |
268 aimbs_put16(hdrbs, 0x0000); | |
269 aimbs_put16(hdrbs, 0x0000); | |
270 aimbs_put16(hdrbs, 0x0000); | |
271 aimbs_put16(hdrbs, 0x0000); | |
272 aimbs_put16(hdrbs, 0x0000); | |
273 aimbs_put8(hdrbs, 0x00); | |
2993 | 274 |
275 /* end of hdr2 */ | |
276 | |
277 #if 0 /* XXX this is how you send buddy icon info... */ | |
278 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0008); | |
279 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x000c); | |
280 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000); | |
281 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x1466); | |
282 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0001); | |
283 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x2e0f); | |
284 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x393e); | |
285 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0xcac8); | |
286 #endif | |
3952 | 287 aimbs_putraw(hdrbs, msg, len); |
2993 | 288 |
289 aim_tx_enqueue(sess, fr); | |
290 | |
291 return 0; | |
292 } | |
293 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
294 static int getlocalip(fu8_t *ip) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
295 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
296 struct hostent *hptr; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
297 char localhost[129]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
298 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
299 /* XXX if available, use getaddrinfo() */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
300 /* XXX allow client to specify which IP to use for multihomed boxes */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
301 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
302 if (gethostname(localhost, 128) < 0) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
303 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
304 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
305 if (!(hptr = gethostbyname(localhost))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
306 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
307 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
308 memcpy(ip, hptr->h_addr_list[0], 4); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
309 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
310 return 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
311 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
312 |
2086 | 313 /** |
314 * aim_directim_intitiate - For those times when we want to open up the directim channel ourselves. | |
315 * @sess: your session, | |
316 * @conn: the BOS conn, | |
317 * @priv: a dummy priv value (we'll let it get filled in later) (if you pass a %NULL, we alloc one) | |
318 * @destsn: the SN to connect to. | |
319 * | |
320 */ | |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
321 faim_export aim_conn_t *aim_directim_initiate(aim_session_t *sess, const char *destsn) |
2086 | 322 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
323 aim_conn_t *newconn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
324 aim_msgcookie_t *cookie; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
325 struct aim_directim_intdata *priv; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
326 int listenfd; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
327 fu16_t port = 4443; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
328 fu8_t localip[4]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
329 fu8_t ck[8]; |
2086 | 330 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
331 if (getlocalip(localip) == -1) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
332 return NULL; |
2086 | 333 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
334 if ((listenfd = listenestablish(port)) == -1) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
335 return NULL; |
2086 | 336 |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
337 aim_request_directim(sess, destsn, localip, port, ck); |
2086 | 338 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
339 cookie = (aim_msgcookie_t *)calloc(1, sizeof(aim_msgcookie_t)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
340 memcpy(cookie->cookie, ck, 8); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
341 cookie->type = AIM_COOKIETYPE_OFTIM; |
2086 | 342 |
2247
f721ae9582d5
[gaim-migrate @ 2257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
343 /* this one is for the cookie */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
344 priv = (struct aim_directim_intdata *)calloc(1, sizeof(struct aim_directim_intdata)); |
2086 | 345 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
346 memcpy(priv->cookie, ck, 8); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
347 strncpy(priv->sn, destsn, sizeof(priv->sn)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
348 cookie->data = priv; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
349 aim_cachecookie(sess, cookie); |
2086 | 350 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
351 /* XXX switch to aim_cloneconn()? */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
352 if (!(newconn = aim_newconn(sess, AIM_CONN_TYPE_RENDEZVOUS_OUT, NULL))) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
353 close(listenfd); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
354 return NULL; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
355 } |
2086 | 356 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
357 /* this one is for the conn */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
358 priv = (struct aim_directim_intdata *)calloc(1, sizeof(struct aim_directim_intdata)); |
2086 | 359 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
360 memcpy(priv->cookie, ck, 8); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
361 strncpy(priv->sn, destsn, sizeof(priv->sn)); |
2086 | 362 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
363 newconn->fd = listenfd; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
364 newconn->subtype = AIM_CONN_SUBTYPE_OFT_DIRECTIM; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
365 newconn->internal = priv; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
366 newconn->lastactivity = time(NULL); |
2086 | 367 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
368 faimdprintf(sess, 2,"faim: listening (fd = %d, unconnected)\n", newconn->fd); |
2086 | 369 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
370 return newconn; |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
371 } |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
372 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
373 /** |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
374 * aim_sendfile_intitiate - For those times when we want to send the file ourselves. |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
375 * @sess: your session, |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
376 * @conn: the BOS conn, |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
377 * @destsn: the SN to connect to. |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
378 * @filename: the name of the files you want to send |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
379 * |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
380 */ |
3630 | 381 faim_export aim_conn_t *aim_sendfile_initiate(aim_session_t *sess, const char *destsn, const char *filename, fu16_t numfiles, fu32_t totsize, char *cookret) |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
382 { |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
383 aim_conn_t *newconn; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
384 aim_msgcookie_t *cookie; |
3630 | 385 struct aim_filetransfer_priv *ft; |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
386 int listenfd; |
3630 | 387 |
3771 | 388 /* XXX allow different ports */ |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
389 fu16_t port = 4443; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
390 fu8_t localip[4]; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
391 fu8_t ck[8]; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
392 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
393 if (getlocalip(localip) == -1) |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
394 return NULL; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
395 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
396 if ((listenfd = listenestablish(port)) == -1) |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
397 return NULL; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
398 |
3952 | 399 aim_request_sendfile(sess, destsn, filename, numfiles, totsize, localip, port, ck); |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
400 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
401 cookie = (aim_msgcookie_t *)calloc(1, sizeof(aim_msgcookie_t)); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
402 memcpy(cookie->cookie, ck, 8); |
3630 | 403 cookie->type = AIM_COOKIETYPE_OFTSEND; |
404 memcpy(cookret, ck, 8); | |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
405 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
406 /* this one is for the cookie */ |
3630 | 407 ft = (struct aim_filetransfer_priv *)calloc(1, sizeof(struct aim_filetransfer_priv)); |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
408 |
3630 | 409 memcpy(ft->cookie, ck, 8); |
410 strncpy(ft->sn, destsn, sizeof(ft->sn)); | |
411 cookie->data = ft; | |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
412 aim_cachecookie(sess, cookie); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
413 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
414 if (!(newconn = aim_newconn(sess, AIM_CONN_TYPE_RENDEZVOUS_OUT, NULL))) { |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
415 close(listenfd); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
416 return NULL; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
417 } |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
418 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
419 /* this one is for the conn */ |
3630 | 420 ft = (struct aim_filetransfer_priv *)calloc(1, sizeof(struct aim_filetransfer_priv)); |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
421 |
3630 | 422 memcpy(ft->cookie, ck, 8); |
423 strncpy(ft->sn, destsn, sizeof(ft->sn)); | |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
424 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
425 newconn->fd = listenfd; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
426 newconn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; |
3771 | 427 newconn->internal = ft; |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
428 newconn->lastactivity = time(NULL); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
429 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
430 faimdprintf(sess, 2,"faim: listening (fd = %d, unconnected)\n", newconn->fd); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
431 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
432 return newconn; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
433 } |
2086 | 434 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
435 #if 0 |
2086 | 436 /** |
437 * unsigned int aim_oft_listener_clean - close up old listeners | |
438 * @sess: session to clean up in | |
3952 | 439 * @age: maximum age in seconds |
2086 | 440 * |
441 * returns number closed, -1 on error. | |
442 */ | |
3952 | 443 faim_export unsigned int aim_oft_listener_clean(aim_session_t *sess, time_t age) |
444 { | |
445 aim_conn_t *cur; | |
446 time_t now; | |
447 unsigned int hit = 0; | |
448 | |
449 if (!sess) | |
450 return -1; | |
451 now = time(NULL); | |
452 | |
453 for(cur = sess->connlist;cur; cur = cur->next) | |
454 if (cur->type == AIM_CONN_TYPE_RENDEZVOUS_OUT) { | |
455 if (cur->lastactivity < (now - age) ) { | |
456 aim_conn_close(cur); | |
457 hit++; | |
458 } | |
459 } | |
460 return hit; | |
461 } | |
462 #endif | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
463 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
464 faim_export const char *aim_directim_getsn(aim_conn_t *conn) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
465 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
466 struct aim_directim_intdata *intdata; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
467 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
468 if (!conn) |
3952 | 469 return NULL; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
470 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
471 if ((conn->type != AIM_CONN_TYPE_RENDEZVOUS) || |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
472 (conn->subtype != AIM_CONN_SUBTYPE_OFT_DIRECTIM)) |
3952 | 473 return NULL; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
474 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
475 if (!conn->internal) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
476 return NULL; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
477 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
478 intdata = (struct aim_directim_intdata *)conn->internal; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
479 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
480 return intdata->sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
481 } |
2086 | 482 |
483 /** | |
484 * aim_directim_connect - connect to buddy for directim | |
485 * @sess: the session to append the conn to, | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
486 * @sn: the SN we're connecting to |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
487 * @addr: address to connect to |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
488 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
489 * This is a wrapper for aim_newconn. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
490 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
491 * If addr is NULL, the socket is not created, but the connection is |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
492 * allocated and setup to connect. |
2086 | 493 * |
494 */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
495 faim_export aim_conn_t *aim_directim_connect(aim_session_t *sess, const char *sn, const char *addr, const fu8_t *cookie) |
2086 | 496 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
497 aim_conn_t *newconn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
498 struct aim_directim_intdata *intdata; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
499 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
500 if (!sess || !sn) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
501 return NULL; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
502 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
503 if (!(intdata = malloc(sizeof(struct aim_directim_intdata)))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
504 return NULL; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
505 memset(intdata, 0, sizeof(struct aim_directim_intdata)); |
2086 | 506 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
507 memcpy(intdata->cookie, cookie, 8); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
508 strncpy(intdata->sn, sn, sizeof(intdata->sn)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
509 if (addr) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
510 strncpy(intdata->ip, addr, sizeof(intdata->ip)); |
2086 | 511 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
512 /* XXX verify that non-blocking connects actually work */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
513 if (!(newconn = aim_newconn(sess, AIM_CONN_TYPE_RENDEZVOUS, addr))) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
514 free(intdata); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
515 return NULL; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
516 } |
2086 | 517 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
518 if (!newconn) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
519 free(intdata); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
520 return newconn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
521 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
522 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
523 newconn->subtype = AIM_CONN_SUBTYPE_OFT_DIRECTIM; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
524 newconn->internal = intdata; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
525 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
526 return newconn; |
2086 | 527 } |
528 | |
529 /** | |
530 * aim_directim_getconn - find a directim conn for buddy name | |
531 * @sess: your session, | |
3952 | 532 * @name: the name to get, |
2086 | 533 * |
534 * returns conn for directim with name, %NULL if none found. | |
535 * | |
536 */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
537 faim_export aim_conn_t *aim_directim_getconn(aim_session_t *sess, const char *name) |
2086 | 538 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
539 aim_conn_t *cur; |
2086 | 540 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
541 if (!sess || !name || !strlen(name)) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
542 return NULL; |
2086 | 543 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
544 for (cur = sess->connlist; cur; cur = cur->next) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
545 struct aim_directim_intdata *intdata; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
546 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
547 if ((cur->type != AIM_CONN_TYPE_RENDEZVOUS) || (cur->subtype != AIM_CONN_SUBTYPE_OFT_DIRECTIM)) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
548 continue; |
2086 | 549 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
550 intdata = cur->internal; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
551 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
552 if (aim_sncmp(intdata->sn, name) == 0) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
553 break; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
554 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
555 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
556 return cur; |
2086 | 557 } |
558 | |
559 /** | |
560 * aim_accepttransfer - accept a file transfer request | |
561 * @sess: the session, | |
562 * @conn: the BOS conn for the CAP reply | |
563 * @sn: the screenname to send it to, | |
564 * @cookie: the cookie used | |
565 * @ip: the ip to connect to | |
3630 | 566 * @port: the port to use |
3952 | 567 * @rendid: capability type (%AIM_CAPS_GETFILE or %AIM_CAPS_SENDFILE) |
3630 | 568 * |
2086 | 569 * @listingfiles: number of files to share |
570 * @listingtotsize: total size of shared files | |
571 * @listingsize: length of the listing file(buffer) | |
572 * @listingchecksum: checksum of the listing | |
573 * | |
574 * Returns new connection or %NULL on error. | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
575 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
576 * XXX this should take a struct. |
2086 | 577 */ |
3952 | 578 faim_export aim_conn_t *aim_accepttransfer(aim_session_t *sess, aim_conn_t *conn, const char *sn, |
579 const fu8_t *cookie, const fu8_t *ip, | |
580 fu16_t port, fu16_t rendid, ...) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
581 { |
3952 | 582 aim_frame_t *newpacket; |
583 aim_conn_t *newconn; | |
584 struct aim_filetransfer_priv *priv; | |
585 int i; | |
586 char addr[21]; | |
2086 | 587 |
3952 | 588 if (!sess || !conn || !sn || !cookie || !ip) { |
589 return NULL; | |
590 } | |
591 | |
592 /* OSCAR CAP accept packet */ | |
2086 | 593 |
3952 | 594 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x0002, 10+8+2+1+strlen(sn)+4+2+8+16))) { |
595 return NULL; | |
596 } | |
3630 | 597 |
3952 | 598 aim_putsnac(&newpacket->data, 0x0004, 0x0006, 0x0000, sess->snacid_next); |
599 | |
600 for (i = 0; i < 8; i++) | |
601 aimbs_put8(&newpacket->data, cookie[i]); | |
3630 | 602 |
3952 | 603 aimbs_put16(&newpacket->data, 0x0002); |
604 aimbs_put8(&newpacket->data, strlen(sn)); | |
605 aimbs_putraw(&newpacket->data, sn, strlen(sn)); | |
606 aimbs_put16(&newpacket->data, 0x0005); | |
607 aimbs_put16(&newpacket->data, 0x001a); | |
608 aimbs_put16(&newpacket->data, AIM_RENDEZVOUS_ACCEPT); | |
3630 | 609 |
3952 | 610 for (i = 0; i < 8; i++) /* yes, again... */ |
611 aimbs_put8(&newpacket->data, cookie[i]); | |
3630 | 612 |
3952 | 613 aim_putcap(&newpacket->data, rendid); |
614 aim_tx_enqueue(sess, newpacket); | |
3630 | 615 |
3952 | 616 snprintf(addr, sizeof(addr), "%s:%d", ip, port); |
617 newconn = aim_newconn(sess, AIM_CONN_TYPE_RENDEZVOUS, addr); | |
3630 | 618 |
3952 | 619 if (newconn->status & AIM_CONN_STATUS_CONNERR) { |
620 return NULL; | |
621 } | |
3630 | 622 |
3952 | 623 if (!newconn || (newconn->fd == -1)) { |
624 perror("aim_newconn"); | |
625 faimdprintf(sess, 2, "could not connect to %s (fd: %i)\n", ip, newconn?newconn->fd:0); | |
626 return newconn; | |
627 } | |
2086 | 628 |
3952 | 629 priv = (struct aim_filetransfer_priv *)calloc(1, sizeof(struct aim_filetransfer_priv)); |
3630 | 630 |
3952 | 631 memcpy(priv->cookie, cookie, 8); |
632 priv->state = 0; | |
633 strncpy(priv->sn, sn, MAXSNLEN); | |
634 strncpy(priv->ip, ip, sizeof(priv->ip)); | |
635 newconn->internal = (void *)priv; | |
3630 | 636 |
3952 | 637 faimdprintf(sess, 2, "faim: connected to peer (fd = %d)\n", newconn->fd); |
638 | |
639 if (rendid == AIM_CAPS_GETFILE) { | |
640 return NULL; /* This should never happen for now. -- wtm */ | |
3630 | 641 |
642 #if 0 | |
3952 | 643 struct aim_fileheader_t *fh; |
644 aim_frame_t *newoft; | |
645 aim_msgcookie_t *cachedcook; | |
646 /* XXX take the following parameters fu16_t listingfiles, | |
647 fu16_t listingtotsize, | |
648 fu16_t listingsize, | |
649 fu32_t listingchecksum, */ | |
3630 | 650 |
3952 | 651 newconn->subtype = AIM_CONN_SUBTYPE_OFT_GETFILE; |
652 | |
653 faimdprintf(sess, 2, "faim: getfile request accept\n"); | |
2086 | 654 |
3952 | 655 if (!(newoft = aim_tx_new(sess, newconn, AIM_FRAMETYPE_OFT, 0x1108, 0))) { |
656 faimdprintf(sess, 2, "faim: aim_accepttransfer: tx_new OFT failed\n"); | |
657 /* XXX: conn leak here */ | |
658 return NULL; | |
659 } | |
2086 | 660 |
3952 | 661 memcpy(newoft->hdr.oft.magic, "OFT2", 4); |
662 newoft->hdr.oft.hdr2len = 0x100 - 8; | |
2086 | 663 |
3952 | 664 if (!(fh = (struct aim_fileheader_t*)calloc(1, sizeof(struct aim_fileheader_t)))) { |
665 /* XXX: conn leak here */ | |
666 perror("calloc"); | |
667 return NULL; | |
668 } | |
2086 | 669 |
3952 | 670 fh->encrypt = 0x0000; |
671 fh->compress = 0x0000; | |
672 fh->totfiles = listingfiles; | |
673 fh->filesleft = listingfiles; /* is this right -- total parts and parts left?*/ | |
674 fh->totparts = 0x0001; | |
675 fh->partsleft = 0x0001; | |
676 fh->totsize = listingtotsize; | |
677 fh->size = listingsize; /* ls -l listing.txt */ | |
678 fh->modtime = (int)time(NULL); /* we'll go with current time for now */ | |
679 fh->checksum = listingchecksum; | |
680 fh->rfcsum = 0x00000000; | |
681 fh->rfsize = 0x00000000; | |
682 fh->cretime = 0x00000000; | |
683 fh->rfcsum = 0x00000000; | |
684 fh->nrecvd = 0x00000000; | |
685 fh->recvcsum = 0x00000000; | |
686 memset(fh->idstring, 0, sizeof(fh->idstring)); | |
687 strncpy(fh->idstring, "OFT_Windows ICBMFT V1.1 32", sizeof(fh->idstring)); | |
688 fh->flags = 0x02; | |
689 fh->lnameoffset = 0x1a; | |
690 fh->lsizeoffset = 0x10; | |
691 memset(fh->dummy, 0, sizeof(fh->dummy)); | |
692 memset(fh->macfileinfo, 0, sizeof(fh->macfileinfo)); | |
2086 | 693 |
3952 | 694 /* we need to figure out these encodings for filenames */ |
695 fh->nencode = 0x0000; | |
696 fh->nlanguage = 0x0000; | |
697 memset(fh->name, 0, sizeof(fh->name)); | |
698 strncpy(fh->name, "listing.txt", sizeof(fh->name)); | |
2086 | 699 |
3952 | 700 if (!(newoft->hdr.oft.hdr2 = (char *)calloc(1,newoft->hdr.oft.hdr2len))) { |
701 aim_frame_destroy(newoft); | |
702 /* XXX: conn leak */ | |
703 perror("calloc (1)"); | |
704 return NULL; | |
705 } | |
2086 | 706 |
3952 | 707 memcpy(fh->bcookie, cookie, 8); |
2086 | 708 |
3952 | 709 if (!(aim_oft_buildheader((unsigned char *)newoft->hdr.oft.hdr2, fh))) |
710 faimdprintf(sess, 1, "eek, bh fail!\n"); | |
711 | |
712 aim_tx_enqueue(sess, newoft); | |
2086 | 713 |
3952 | 714 if (!(cachedcook = (aim_msgcookie_t *)calloc(1, sizeof(aim_msgcookie_t)))) { |
715 faimdprintf(sess, 1, "faim: accepttransfer: couldn't calloc cachedcook. yeep!\n"); | |
716 /* XXX: more cleanup, conn leak */ | |
717 perror("calloc (2)"); | |
718 return NULL; | |
719 } | |
720 | |
721 memcpy(&(priv->fh), fh, sizeof(struct aim_fileheader_t)); | |
722 memcpy(cachedcook->cookie, cookie, 8); | |
2086 | 723 |
3952 | 724 cachedcook->type = AIM_COOKIETYPE_OFTGET; |
725 /* XXX doesn't priv need to be copied so we don't | |
726 * double free? -- wtm | |
727 */ | |
728 cachedcook->data = (void *)priv; | |
2086 | 729 |
3952 | 730 if (aim_cachecookie(sess, cachedcook) == -1) |
731 faimdprintf(sess, 1, "faim: ERROR caching message cookie\n"); | |
2086 | 732 |
3952 | 733 free(fh); |
3630 | 734 #endif |
735 | |
3952 | 736 } else if (rendid == AIM_CAPS_SENDFILE) { |
737 newconn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
738 priv->fh.recvcsum = 0xffff0000; | |
739 } else { | |
740 return NULL; | |
741 } | |
3630 | 742 |
3952 | 743 return newconn; |
3630 | 744 } |
745 | |
746 /* conn is a BOS connection over which to send the cancel msg */ | |
747 faim_export int aim_canceltransfer(aim_session_t *sess, aim_conn_t *conn, | |
748 const char *cookie, const char *sn, int rendid) | |
749 { | |
3952 | 750 aim_frame_t *newpacket; |
751 int i; | |
3630 | 752 |
3952 | 753 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x0002, 10+8+2+1+strlen(sn)+4+2+8+16))) { |
754 return 1; | |
755 } | |
2086 | 756 |
3952 | 757 aim_putsnac(&newpacket->data, 0x0004, 0x0006, 0x0000, sess->snacid_next); |
758 | |
759 for (i = 0; i < 8; i++) | |
760 aimbs_put8(&newpacket->data, cookie[i]); | |
2086 | 761 |
3952 | 762 aimbs_put16(&newpacket->data, 0x0002); |
763 aimbs_put8(&newpacket->data, strlen(sn)); | |
764 aimbs_putraw(&newpacket->data, sn, strlen(sn)); | |
765 aimbs_put16(&newpacket->data, 0x0005); | |
766 aimbs_put16(&newpacket->data, 0x001a); | |
767 aimbs_put16(&newpacket->data, AIM_RENDEZVOUS_CANCEL); | |
2086 | 768 |
3952 | 769 for (i = 0; i < 8; i++) |
770 aimbs_put8(&newpacket->data, cookie[i]); | |
2086 | 771 |
3952 | 772 aim_putcap(&newpacket->data, rendid); |
773 aim_tx_enqueue(sess, newpacket); | |
774 | |
775 return 0; | |
2086 | 776 } |
777 | |
778 /** | |
779 * aim_getlisting(FILE *file) -- get an aim_fileheader_t for a given FILE* | |
3952 | 780 * @file is an opened listing file |
2086 | 781 * |
782 * returns a pointer to the filled-in fileheader_t | |
783 * | |
784 * Currently omits checksum. we'll fix this when AOL breaks us, i | |
785 * guess. | |
786 * | |
787 */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
788 faim_export struct aim_fileheader_t *aim_getlisting(aim_session_t *sess, FILE *file) |
2086 | 789 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
790 return NULL; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
791 #if 0 |
3952 | 792 struct aim_fileheader_t *fh; |
793 u_long totsize = 0, size = 0, checksum = 0xffff0000; | |
794 short totfiles = 0; | |
795 char *linebuf, sizebuf[9]; | |
796 int linelength = 1024; | |
2086 | 797 |
3952 | 798 /* XXX: if we have a line longer than 1024chars, God help us. */ |
799 if ((linebuf = (char *)calloc(1, linelength)) == NULL ) { | |
800 faimdprintf(sess, 2, "linebuf calloc failed\n"); | |
801 return NULL; | |
802 } | |
2086 | 803 |
3952 | 804 if (fseek(file, 0, SEEK_END) == -1) { /* use this for sanity check */ |
805 perror("getlisting END1 fseek:"); | |
806 faimdprintf(sess, 2, "getlising fseek END1 error\n"); | |
807 } | |
2086 | 808 |
3952 | 809 if ((size = ftell(file)) == -1) { |
810 perror("getlisting END1 getpos:"); | |
811 faimdprintf(sess, 2, "getlising getpos END1 error\n"); | |
812 } | |
2086 | 813 |
3952 | 814 if (fseek(file, 0, SEEK_SET) != 0) { |
815 perror("getlesting fseek(SET):"); | |
816 faimdprintf(sess, 2, "faim: getlisting: couldn't seek to beginning of listing file\n"); | |
817 } | |
818 | |
819 memset(linebuf, 0, linelength); | |
2086 | 820 |
3952 | 821 size = 0; |
2086 | 822 |
3952 | 823 while(fgets(linebuf, linelength, file)) { |
824 totfiles++; | |
825 memset(sizebuf, 0, 9); | |
826 | |
827 size += strlen(linebuf); | |
2086 | 828 |
3952 | 829 if (strlen(linebuf) < 23) { |
830 faimdprintf(sess, 2, "line \"%s\" too short. skipping\n", linebuf); | |
831 continue; | |
832 } | |
2086 | 833 |
3952 | 834 if (linebuf[strlen(linebuf)-1] != '\n') { |
835 faimdprintf(sess, 2, "faim: OFT: getlisting -- hit EOF or line too long!\n"); | |
836 } | |
2086 | 837 |
3952 | 838 memcpy(sizebuf, linebuf+17, 8); |
839 | |
840 totsize += strtol(sizebuf, NULL, 10); | |
841 memset(linebuf, 0, linelength); | |
842 } | |
2086 | 843 |
3952 | 844 if (fseek(file, 0, SEEK_SET) == -1) { |
845 perror("getlisting END2 fseek:"); | |
846 faimdprintf(sess, 2, "getlising fseek END2 error\n"); | |
847 } | |
2086 | 848 |
3952 | 849 free(linebuf); |
2086 | 850 |
3952 | 851 /* we're going to ignore checksumming the data for now -- that |
852 * requires walking the whole listing.txt. it should probably be | |
853 * done at register time and cached, but, eh. */ | |
2086 | 854 |
3952 | 855 if (!(fh = (struct aim_fileheader_t*)calloc(1, sizeof(struct aim_fileheader_t)))) |
856 return NULL; | |
2086 | 857 |
3952 | 858 fh->encrypt = 0x0000; |
859 fh->compress = 0x0000; | |
860 fh->totfiles = totfiles; | |
861 fh->filesleft = totfiles; /* is this right? */ | |
862 fh->totparts = 0x0001; | |
863 fh->partsleft = 0x0001; | |
864 fh->totsize = totsize; | |
865 fh->size = size; /* ls -l listing.txt */ | |
866 fh->modtime = (int)time(NULL); /* we'll go with current time for now */ | |
867 fh->checksum = checksum; /* XXX: checksum ! */ | |
868 fh->rfcsum = 0x00000000; | |
869 fh->rfsize = 0x00000000; | |
870 fh->cretime = 0x00000000; | |
871 fh->rfcsum = 0x00000000; | |
872 fh->nrecvd = 0x00000000; | |
873 fh->recvcsum = 0x00000000; | |
2086 | 874 |
3952 | 875 /* memset(fh->idstring, 0, sizeof(fh->idstring)); */ |
876 memcpy(fh->idstring, "OFT_Windows ICBMFT V1.1 32", sizeof(fh->idstring)); | |
877 memset(fh->idstring+strlen(fh->idstring), 0, sizeof(fh->idstring)-strlen(fh->idstring)); | |
2086 | 878 |
3952 | 879 fh->flags = 0x02; |
880 fh->lnameoffset = 0x1a; | |
881 fh->lsizeoffset = 0x10; | |
2086 | 882 |
3952 | 883 /* memset(fh->dummy, 0, sizeof(fh->dummy)); */ |
884 memset(fh->macfileinfo, 0, sizeof(fh->macfileinfo)); | |
2086 | 885 |
3952 | 886 fh->nencode = 0x0000; /* we need to figure out these encodings for filenames */ |
887 fh->nlanguage = 0x0000; | |
2086 | 888 |
3952 | 889 /* memset(fh->name, 0, sizeof(fh->name)); */ |
890 strncpy(fh->name, "listing.txt", sizeof(fh->name)); | |
891 memset(fh->name+strlen(fh->name), 0, 64-strlen(fh->name)); | |
2086 | 892 |
3952 | 893 faimdprintf(sess, 2, "faim: OFT: listing fh name %s / %s\n", fh->name, (fh->name+(strlen(fh->name)))); |
894 return fh; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
895 #endif |
2086 | 896 } |
897 | |
898 /** | |
899 * aim_listenestablish - create a listening socket on a port. | |
3952 | 900 * @portnum: the port number to bind to. |
2086 | 901 * |
902 * you need to call accept() when it's connected. returns your fd | |
903 * | |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
904 * XXX: give the client author the responsibility of setting up a |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
905 * listener, then we no longer have a libfaim problem with broken |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2711
diff
changeset
|
906 * solaris *innocent smile* -jbm |
2086 | 907 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
908 static int listenestablish(fu16_t portnum) |
2086 | 909 { |
2711
b7455c506979
[gaim-migrate @ 2724]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2675
diff
changeset
|
910 #if HAVE_GETADDRINFO |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
911 int listenfd; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
912 const int on = 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
913 struct addrinfo hints, *res, *ressave; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
914 char serv[5]; |
2086 | 915 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
916 snprintf(serv, sizeof(serv), "%d", portnum); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
917 memset(&hints, 0, sizeof(struct addrinfo)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
918 hints.ai_flags = AI_PASSIVE; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
919 hints.ai_family = AF_UNSPEC; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
920 hints.ai_socktype = SOCK_STREAM; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
921 if (getaddrinfo(NULL /*any IP*/, serv, &hints, &res) != 0) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
922 perror("getaddrinfo"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
923 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
924 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
925 ressave = res; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
926 do { |
3952 | 927 listenfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
928 if (listenfd < 0) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
929 continue; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
930 setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
931 if (bind(listenfd, res->ai_addr, res->ai_addrlen) == 0) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
932 break; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
933 /* success */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
934 close(listenfd); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
935 } while ( (res = res->ai_next) ); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
936 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
937 if (!res) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
938 return -1; |
2086 | 939 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
940 if (listen(listenfd, 1024)!=0) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
941 perror("listen"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
942 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
943 } |
2086 | 944 |
3630 | 945 fcntl(listenfd, F_SETFL, O_NONBLOCK); |
946 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
947 freeaddrinfo(ressave); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
948 return listenfd; |
2086 | 949 #else |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
950 int listenfd; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
951 const int on = 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
952 struct sockaddr_in sockin; |
2086 | 953 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
954 if ((listenfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
955 perror("socket(listenfd)"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
956 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
957 } |
2086 | 958 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2247
diff
changeset
|
959 if (setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) != 0) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
960 perror("setsockopt(listenfd)"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
961 close(listenfd); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
962 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
963 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
964 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
965 memset(&sockin, 0, sizeof(struct sockaddr_in)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
966 sockin.sin_family = AF_INET; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
967 sockin.sin_port = htons(portnum); |
2086 | 968 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
969 if (bind(listenfd, (struct sockaddr *)&sockin, sizeof(struct sockaddr_in)) != 0) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
970 perror("bind(listenfd)"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
971 close(listenfd); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
972 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
973 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
974 if (listen(listenfd, 4) != 0) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
975 perror("listen(listenfd)"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
976 close(listenfd); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
977 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
978 } |
3630 | 979 fcntl(listenfd, F_SETFL, O_NONBLOCK); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
980 return listenfd; |
2086 | 981 #endif |
982 } | |
983 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
984 static int getcommand_getfile(aim_session_t *sess, aim_conn_t *conn) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
985 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
986 #if 0 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
987 struct aim_filetransfer_priv *ft; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
988 aim_rxcallback_t userfunc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
989 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
990 ft = conn->priv; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
991 if (ft->state == 2) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
992 /* waiting on listing data */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
993 int ret = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
994 char *listing; |
3630 | 995 aim_frame_t *newoft; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
996 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
997 if (!(listing = malloc(ft->fh.size))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
998 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
999 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1000 ft->state = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1001 if (aim_recv(conn->fd, listing, ft->fh.size) != ft->fh.size) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1002 faimdprintf(sess, 2, "OFT get: file %s was short. (0x%lx)\n", ft->fh.name, ft->fh.size); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1003 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1004 if (!(newoft = aim_tx_new(sess, conn, AIM_FRAMETYPE_OFT, 0x120b, 0))) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1005 faimdprintf(sess, 2, "faim: aim_get_command_rendezvous: getfile listing: tx_new OFT failed\n"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1006 free(listing); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1007 aim_conn_close(conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1008 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1009 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1010 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1011 memcpy(newoft->hdr.oft.magic, "OFT2", 4); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1012 newoft->hdr.oft.hdr2len = 0x100 - 8; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1013 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1014 /* Protocol BS - set nrecvd to size of listing, recvcsum to listing checksum, flags to 0 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1015 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1016 ft->fh.nrecvd = ft->fh.size; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1017 ft->fh.recvcsum = ft->fh.checksum; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1018 ft->fh.flags = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1019 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1020 if (!(newoft->hdr.oft.hdr2 = (char *)calloc(1,newoft->hdr.oft.hdr2len))) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1021 aim_frame_destroy(newoft); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1022 free(listing); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1023 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1024 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1025 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1026 if (!(aim_oft_buildheader((unsigned char *)newoft->hdr.oft.hdr2, &(ft->fh)))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1027 faimdprintf(sess, 2, "eek! bh fail listing\n"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1028 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1029 /* send the 120b */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1030 aim_tx_enqueue(sess, newoft); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1031 if ( (userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILELISTING)) ) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1032 ret = userfunc(sess, NULL, conn, ft, listing); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1033 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1034 free(listing); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1035 return ret; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1036 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1037 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1038 if (ft->state == 3) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1039 /* waiting on file data */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1040 if ( (userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILERECEIVE)) ) |
3630 | 1041 return userfunc(sess, NULL, conn, ft->fh.name, |
1042 ft->fh.size); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1043 return 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1044 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1045 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1046 if (ft->state == 4) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1047 if( (userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILESTATE4)) ) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1048 return userfunc(sess, NULL, conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1049 aim_conn_close(conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1050 return 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1051 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1052 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1053 return 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1054 #else |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1055 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1056 #endif |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1057 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1058 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1059 static void connclose_sendfile(aim_session_t *sess, aim_conn_t *conn) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1060 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1061 aim_msgcookie_t *cook; |
3771 | 1062 struct aim_filetransfer_priv *priv = (struct aim_filetransfer_priv *)conn->internal; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1063 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1064 cook = aim_uncachecookie(sess, priv->cookie, AIM_COOKIETYPE_OFTSEND); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1065 aim_cookie_free(sess, cook); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1066 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1067 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1068 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1069 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1070 static void connkill_sendfile(aim_session_t *sess, aim_conn_t *conn) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1071 { |
3771 | 1072 free(conn->internal); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1073 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1074 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1075 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1076 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1077 static void connclose_getfile(aim_session_t *sess, aim_conn_t *conn) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1078 { |
3771 | 1079 #if 0 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1080 aim_msgcookie_t *cook; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1081 struct aim_filetransfer_priv *priv = (struct aim_filetransfer_priv *)conn->priv; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1082 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1083 cook = aim_uncachecookie(sess, priv->cookie, AIM_COOKIETYPE_OFTGET); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1084 aim_cookie_free(sess, cook); |
3771 | 1085 #endif |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1086 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1087 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1088 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1089 static void connkill_getfile(aim_session_t *sess, aim_conn_t *conn) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1090 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1091 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1092 free(conn->internal); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1093 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1094 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1095 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1096 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1097 static void connclose_directim(aim_session_t *sess, aim_conn_t *conn) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1098 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1099 struct aim_directim_intdata *intdata = (struct aim_directim_intdata *)conn->internal; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1100 aim_msgcookie_t *cook; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1101 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1102 cook = aim_uncachecookie(sess, intdata->cookie, AIM_COOKIETYPE_OFTIM); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1103 aim_cookie_free(sess, cook); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1104 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1105 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1106 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1107 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1108 static void connkill_directim(aim_session_t *sess, aim_conn_t *conn) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1109 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1110 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1111 free(conn->internal); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1112 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1113 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1114 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1115 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1116 faim_internal void aim_conn_close_rend(aim_session_t *sess, aim_conn_t *conn) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1117 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1118 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1119 if (conn->type != AIM_CONN_TYPE_RENDEZVOUS) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1120 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1121 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1122 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_SENDFILE) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1123 connclose_sendfile(sess, conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1124 else if (conn->subtype == AIM_CONN_SUBTYPE_OFT_GETFILE) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1125 connclose_getfile(sess, conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1126 else if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1127 connclose_directim(sess, conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1128 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1129 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1130 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1131 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1132 faim_internal void aim_conn_kill_rend(aim_session_t *sess, aim_conn_t *conn) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1133 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1134 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1135 if (conn->type != AIM_CONN_TYPE_RENDEZVOUS) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1136 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1137 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1138 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_SENDFILE) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1139 connkill_sendfile(sess, conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1140 else if (conn->subtype == AIM_CONN_SUBTYPE_OFT_GETFILE) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1141 connkill_getfile(sess, conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1142 else if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1143 connkill_directim(sess, conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1144 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1145 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1146 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1147 |
3952 | 1148 static int handlehdr_directim(aim_session_t *sess, aim_conn_t *conn, aim_bstream_t *bs) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1149 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1150 aim_frame_t fr; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1151 aim_rxcallback_t userfunc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1152 fu32_t payloadlength; |
3952 | 1153 fu16_t flags, encoding; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1154 char *snptr = NULL; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1155 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1156 fr.conn = conn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1157 |
3952 | 1158 /* XXX ugly */ |
1159 aim_bstream_setpos(bs, 20); | |
1160 payloadlength = aimbs_get32(bs); | |
1161 | |
1162 aim_bstream_setpos(bs, 24); | |
1163 encoding = aimbs_get16(bs); | |
1164 | |
1165 aim_bstream_setpos(bs, 30); | |
1166 flags = aimbs_get16(bs); | |
1167 | |
1168 aim_bstream_setpos(bs, 36); | |
1169 /* XXX -create an aimbs_getnullstr function? */ | |
1170 snptr = aimbs_getstr(bs, MAXSNLEN); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1171 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1172 faimdprintf(sess, 2, "faim: OFT frame: handlehdr_directim: %04x / %04x / %s\n", payloadlength, flags, snptr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1173 |
3952 | 1174 if (flags & 0x0002) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1175 int ret = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1176 |
4002 | 1177 if (flags & 0x000c) { |
3952 | 1178 if ((userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING))) |
1179 ret = userfunc(sess, &fr, snptr, 1); | |
1180 return ret; | |
1181 } | |
2993 | 1182 |
1183 if ((userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING))) | |
1184 ret = userfunc(sess, &fr, snptr, 0); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1185 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1186 return ret; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1187 |
3952 | 1188 } else if (((flags & 0x000f) == 0x0000) && payloadlength) { |
2993 | 1189 char *msg, *msg2; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1190 int ret = 0; |
2993 | 1191 int recvd = 0; |
1192 int i; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1193 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1194 if (!(msg = calloc(1, payloadlength+1))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1195 return -1; |
2993 | 1196 msg2 = msg; |
1197 | |
1198 while (payloadlength - recvd) { | |
1199 if (payloadlength - recvd >= 1024) | |
1200 i = aim_recv(conn->fd, msg2, 1024); | |
1201 else | |
1202 i = aim_recv(conn->fd, msg2, payloadlength - recvd); | |
3012 | 1203 if (i <= 0) { |
2993 | 1204 free(msg); |
1205 return -1; | |
1206 } | |
1207 recvd = recvd + i; | |
1208 msg2 = msg2 + i; | |
3033 | 1209 if ((userfunc=aim_callhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER))) |
2993 | 1210 userfunc(sess, &fr, snptr, (double)recvd / payloadlength); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1211 } |
2993 | 1212 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1213 if ( (userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING)) ) |
3952 | 1214 ret = userfunc(sess, &fr, snptr, msg, payloadlength, encoding); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1215 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1216 free(msg); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1217 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1218 return ret; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1219 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1220 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1221 return 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1222 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1223 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1224 static int handlehdr_getfile_listing(aim_session_t *sess, aim_conn_t *conn, fu8_t *hdr) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1225 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1226 #if 0 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1227 struct aim_filetransfer_priv *ft; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1228 struct aim_fileheader_t *fh; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1229 struct aim_msgcookie_t *cook; |
3630 | 1230 aim_frame_t *newoft; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1231 aim_rxcallback_t userfunc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1232 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1233 faimdprintf(sess, 2,"faim: rend: fileget 0x1108\n"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1234 fh = aim_oft_getfh(hdr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1235 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1236 faim_mutex_unlock(&conn->active); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1237 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1238 if (!(cook = aim_checkcookie(sess, fh->bcookie, AIM_COOKIETYPE_OFTGET))) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1239 free(fh); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1240 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1241 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1242 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1243 ft = cook->data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1244 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1245 /* we're waaaaiiiting.. for listing.txt */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1246 ft->state = 2; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1247 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1248 memcpy(&(ft->fh), fh, sizeof(struct aim_fileheader_t)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1249 free(fh); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1250 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1251 if(aim_cachecookie(sess, cook) == -1) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1252 faimdprintf(sess, 1, "error caching cookie\n"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1253 return -1; |
3952 | 1254 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1255 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1256 if (!(newoft = aim_tx_new(sess, conn, AIM_FRAMETYPE_OFT, 0x1209, 0))) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1257 aim_conn_close(conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1258 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1259 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1260 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1261 memcpy(newoft->hdr.oft.magic, "OFT2", 4); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1262 newoft->hdr.oft.hdr2len = 0x100 - 8; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1263 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1264 if (!(newoft->hdr.oft.hdr2 = (char *)calloc(1,newoft->hdr.oft.hdr2len))) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1265 newoft->lock = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1266 aim_frame_destroy(newoft); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1267 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1268 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1269 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1270 if (!(aim_oft_buildheader((unsigned char *)newoft->hdr.oft.hdr2, &(ft->fh)))) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1271 newoft->lock = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1272 aim_frame_destroy(newoft); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1273 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1274 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1275 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1276 newoft->lock = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1277 aim_tx_enqueue(sess, newoft); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1278 #endif |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1279 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1280 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1281 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1282 static int handlehdr_getfile_listing2(aim_session_t *sess, aim_conn_t *conn, fu8_t *hdr) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1283 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1284 #if 0 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1285 struct aim_filetransfer_priv *ft; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1286 struct aim_fileheader_t *fh; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1287 struct aim_msgcookie_t *cook; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1288 int ret = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1289 aim_rxcallback_t userfunc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1290 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1291 fh = aim_oft_getfh(hdr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1292 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1293 if (!(cook = aim_checkcookie(sess, fh->bcookie, AIM_COOKIETYPE_OFTGET))) |
3952 | 1294 faimdprintf(sess, 2, "shit, no cookie in 0x1209. (%i/%s)going to crash..\n", AIM_COOKIETYPE_OFTGET, fh->bcookie); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1295 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1296 ft = cook->data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1297 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1298 if (ft->fh.size != fh->size) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1299 faimdprintf(sess, 2, "hrm. ft->fh.size (%ld) != fh->size (%ld). um. using ft->fh.size\n", ft->fh.size, fh->size); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1300 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1301 if ( (userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILELISTINGREQ))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1302 ret = userfunc(sess, NULL, conn, fh); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1303 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1304 faimdprintf(sess, 2, "faim: get_command_rendezvous: hit end of 1209\n"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1305 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1306 free(fh); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1307 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1308 return ret; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1309 #else |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1310 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1311 #endif |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1312 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1313 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1314 static int handlehdr_getfile_listing3(aim_session_t *sess, aim_conn_t *conn, fu8_t *hdr) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1315 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1316 #if 0 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1317 struct aim_filetransfer_priv *ft; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1318 struct aim_msgcookie_t *cook; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1319 struct aim_fileheader_t *fh; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1320 aim_rxcallback_t userfunc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1321 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1322 fh = aim_oft_getfh(hdr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1323 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1324 if (!(cook = aim_checkcookie(sess, fh->bcookie, AIM_COOKIETYPE_OFTGET))) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1325 free(fh); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1326 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1327 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1328 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1329 free(fh); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1330 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1331 ft = cook->data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1332 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1333 if (aim_cachecookie(sess, cook) == -1) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1334 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1335 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1336 if ((userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILELISTINGRXCONFIRM))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1337 return userfunc(sess, NULL, conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1338 #endif |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1339 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1340 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1341 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1342 static int handlehdr_getfile_request(aim_session_t *sess, aim_conn_t *conn, fu8_t *hdr) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1343 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1344 #if 0 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1345 struct aim_filetransfer_priv *ft; |
3630 | 1346 aim_msgcookie_t *cook; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1347 struct aim_fileheader_t *fh; |
3630 | 1348 aim_frame_t *newoft; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1349 int i = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1350 aim_rxcallback_t userfunc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1351 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1352 fh = aim_oft_getfh(hdr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1353 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1354 if (!(cook = aim_checkcookie(sess, fh->bcookie, AIM_COOKIETYPE_OFTGET))) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1355 free(fh); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1356 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1357 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1358 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1359 ft = cook->data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1360 memcpy(&(ft->fh), fh, sizeof(struct aim_fileheader_t)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1361 free(fh); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1362 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1363 aim_cachecookie(sess, cook); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1364 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1365 faimdprintf(sess, 2, "faim: fileget: %s seems to want %s\n", ft->sn, ft->fh.name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1366 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1367 if ( (userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEFILEREQ)) ) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1368 i = userfunc(sess, NULL, conn, &(ft->fh), cook->cookie); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1369 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1370 if (i < 0) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1371 return i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1372 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1373 if (!(newoft = aim_tx_new(sess, conn, AIM_FRAMETYPE_OFT, 0x0101, 0))) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1374 faimdprintf(sess, 2, "faim: send_final_transfer: tx_new OFT failed\n"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1375 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1376 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1377 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1378 memcpy(newoft->hdr.oft.magic, "OFT2", 4); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1379 newoft->hdr.oft.hdr2len = 0x100 - 8; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1380 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1381 if (!(newoft->hdr.oft.hdr2 = calloc(1,newoft->hdr.oft.hdr2len))) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1382 aim_frame_destroy(newoft); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1383 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1384 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1385 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1386 /* protocol BS: nrecvd, recvcsum to 0, flags to 0x20. */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1387 ft->fh.nrecvd = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1388 ft->fh.recvcsum = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1389 ft->fh.flags = 0x20; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1390 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1391 aim_oft_buildheader((unsigned char *)newoft->hdr.oft.hdr2, &(ft->fh)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1392 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1393 aim_tx_enqueue(sess, newoft); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1394 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1395 faimdprintf(sess, 2, "faim: OFT: OFT file header enqueued.\n"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1396 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1397 return i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1398 #else |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1399 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1400 #endif |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1401 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1402 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1403 static int handlehdr_getfile_sending(aim_session_t *sess, aim_conn_t *conn, fu8_t *hdr) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1404 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1405 #if 0 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1406 struct aim_fileheader_t *fh; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1407 struct aim_filetransfer_priv *ft; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1408 struct aim_msgcookie_t *cook; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1409 struct command_tx_struct *newoft; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1410 aim_rxcallback_t userfunc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1411 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1412 fh = aim_oft_getfh(hdr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1413 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1414 if (!(cook = aim_checkcookie(sess, fh->bcookie, AIM_COOKIETYPE_OFTGET))) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1415 free(fh); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1416 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1417 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1418 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1419 free(fh); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1420 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1421 ft = cook->data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1422 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1423 ft->state = 3; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1424 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1425 if (aim_cachecookie(sess, cook) == -1) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1426 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1427 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1428 faimdprintf(sess, 2, "faim: fileget: %s seems to want to send %s\n", ft->sn, ft->fh.name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1429 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1430 if (!(newoft = aim_tx_new(sess, conn, AIM_FRAMETYPE_OFT, 0x0202, 0))) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1431 faimdprintf(sess, 2, "faim: send_final_transfer: tx_new OFT failed\n"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1432 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1433 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1434 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1435 newoft->lock = 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1436 memcpy(newoft->hdr.oft.magic, "OFT2", 4); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1437 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1438 newoft->hdr.oft.hdr2len = 0x100 - 8; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1439 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1440 if (!(newoft->hdr.oft.hdr2 = calloc(1,newoft->hdr.oft.hdr2len))) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1441 aim_frame_destroy(newoft); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1442 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1443 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1444 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1445 aim_oft_buildheader((unsigned char *)newoft->hdr.oft.hdr2, &(ft->fh)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1446 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1447 newoft->lock = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1448 aim_tx_enqueue(sess, newoft); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1449 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1450 faimdprintf(sess, 2, "faim: OFT: OFT 0x0202 enqueued.\n"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1451 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1452 if ( (userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEFILEREQ)) == NULL) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1453 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1454 #else |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1455 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1456 #endif |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1457 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1458 |
3771 | 1459 /* We are receiving a file, and the buddy sent us this header describing |
1460 * it. We send back a similar header to confirm, then we're ready to | |
1461 * start reading the raw data. | |
1462 */ | |
3952 | 1463 static int handlehdr_sendfile_sending(aim_session_t *sess, aim_conn_t *conn, aim_bstream_t *bs) |
3630 | 1464 { |
1465 struct aim_filetransfer_priv *ft; | |
1466 struct aim_fileheader_t *fh; | |
1467 aim_frame_t *newoft; | |
1468 aim_rxcallback_t userfunc; | |
1469 | |
3952 | 1470 fh = aim_oft_getfh(bs); |
3630 | 1471 |
1472 /* We receive a null cookie for the first file; we must fill | |
1473 * it in to authenticate ourselves. -- wtm | |
1474 */ | |
3771 | 1475 ft = conn->internal; |
3630 | 1476 memcpy(&(fh->bcookie), ft->cookie, 8); |
1477 | |
1478 memcpy(&(ft->fh), fh, sizeof(struct aim_fileheader_t)); | |
1479 free(fh); | |
1480 | |
3771 | 1481 if (!(newoft = aim_tx_new(sess, conn, AIM_FRAMETYPE_OFT, AIM_OFT_PROTO_ACCEPT, 0))) { |
3630 | 1482 faimdprintf(sess, 2, "faim: send_final_transfer: tx_new OFT failed\n"); |
1483 return -1; | |
1484 } | |
1485 | |
3952 | 1486 if (aim_oft_buildheader(&(newoft->data), &(ft->fh)) == -1) { |
3630 | 1487 return -1; |
1488 } | |
3952 | 1489 memcpy(newoft->hdr.rend.magic, "OFT2", 4); |
1490 newoft->hdr.rend.hdrlen = aim_bstream_curpos(&newoft->data); | |
3630 | 1491 |
1492 aim_tx_enqueue(sess, newoft); | |
1493 | |
3771 | 1494 if ( (userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_SENDFILEFILEREQ)) == NULL) |
3630 | 1495 return 1; |
1496 | |
1497 { | |
1498 char *cur; | |
1499 /* Convert the directory separator: it is sent | |
1500 * as ^A (0x01). | |
1501 */ | |
1502 while ((cur = strchr(ft->fh.name, 0x01))) { | |
1503 *cur = G_DIR_SEPARATOR; | |
1504 } | |
1505 } | |
3771 | 1506 return userfunc(sess, NULL, conn, &(ft->fh)); |
3630 | 1507 } |
1508 | |
1509 | |
1510 /* | |
1511 * These were originally described by Josh Myer: | |
1512 * http://www.geocrawler.com/archives/3/896/2000/9/0/4291064/ | |
3960 | 1513 * XXX this doesn't actually work yet |
3630 | 1514 * -- wtm |
1515 */ | |
3952 | 1516 static int handlehdr_sendfile_resume(aim_session_t *sess, aim_conn_t *conn, aim_bstream_t *bs) { |
1517 aim_frame_t *newoft; | |
1518 aim_msgcookie_t *cook; | |
1519 struct aim_fileheader_t *fh; | |
1520 struct aim_filetransfer_priv *ft; | |
1521 | |
1522 fh = aim_oft_getfh(bs); | |
1523 if (!(cook = aim_checkcookie(sess, fh->bcookie, AIM_COOKIETYPE_OFTSEND))) { | |
1524 free(fh); | |
1525 return -1; | |
1526 } | |
1527 ft = (struct aim_filetransfer_priv *)cook->data; | |
3630 | 1528 |
3952 | 1529 ft->fh.nrecvd = fh->nrecvd; |
1530 ft->fh.recvcsum = fh->recvcsum; | |
1531 strncpy(ft->fh.name, fh->name, sizeof(ft->fh.name)); | |
1532 if (!(newoft = aim_tx_new(sess, conn, AIM_FRAMETYPE_OFT, 0x0106, 0))) { | |
1533 faimdprintf(sess, 2, "faim: aim_accepttransfer: tx_new OFT failed\n"); | |
1534 free(fh); | |
1535 return -1; | |
1536 } | |
3630 | 1537 |
3952 | 1538 if (aim_oft_buildheader(&(newoft->data), &(ft->fh)) == -1) { |
1539 aim_frame_destroy(newoft); | |
1540 free(fh); | |
1541 return -1; | |
1542 } | |
1543 memcpy(newoft->hdr.rend.magic, "OFT2", 4); | |
1544 newoft->hdr.rend.hdrlen = aim_bstream_curpos(&newoft->data); | |
3630 | 1545 |
3952 | 1546 aim_tx_enqueue(sess, newoft); |
1547 free(fh); | |
3630 | 1548 |
3952 | 1549 return 0; |
3630 | 1550 } |
1551 | |
3771 | 1552 /* We are sending a file, and the buddy sent us this header indicating |
1553 * that he or she is ready for the raw data. | |
1554 */ | |
3952 | 1555 static int handlehdr_sendfile_recv(aim_session_t *sess, aim_conn_t *conn, aim_bstream_t *bs) { |
3630 | 1556 struct aim_fileheader_t *fh; |
1557 aim_msgcookie_t *cook; | |
1558 int ret = 1; | |
1559 struct aim_filetransfer_priv *ft; | |
1560 aim_rxcallback_t userfunc; | |
1561 | |
3952 | 1562 fh = aim_oft_getfh(bs); |
3630 | 1563 if (!(cook = aim_checkcookie(sess, fh->bcookie, AIM_COOKIETYPE_OFTSEND))) { |
1564 free(fh); | |
1565 return -1; | |
1566 } | |
1567 ft = (struct aim_filetransfer_priv *)cook->data; | |
1568 | |
3771 | 1569 if ( (userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_SENDFILEFILESEND)) ) |
1570 ret = userfunc(sess, NULL, conn, &(ft->fh)); | |
3630 | 1571 |
1572 free(fh); | |
1573 | |
1574 return ret; | |
1575 } | |
1576 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1577 static int handlehdr_getfile_recv(aim_session_t *sess, aim_conn_t *conn, fu8_t *hdr) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1578 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1579 #if 0 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1580 struct aim_fileheader_t *fh; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1581 struct aim_msgcookie_t *cook; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1582 int ret = 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1583 aim_rxcallback_t userfunc; |
3630 | 1584 struct aim_filetransfer_priv *ft; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1585 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1586 fh = aim_oft_getfh(hdr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1587 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1588 if (!(cook = aim_checkcookie(sess, fh->bcookie, AIM_COOKIETYPE_OFTGET))) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1589 free(fh); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1590 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1591 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1592 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1593 ft = cook->data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1594 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1595 faimdprintf(sess, 2, "faim: get_rend: looks like we're ready to send data.(oft 0x0202)\n"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1596 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1597 if ( (userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEFILESEND)) ) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1598 ret = userfunc(sess, NULL, conn, fh); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1599 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1600 free(fh); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1601 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1602 return ret; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1603 #else |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1604 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1605 #endif |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1606 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1607 |
3771 | 1608 /* We just sent the raw data of a file, and the buddy sent us back this |
1609 * header indicating that the transfer is complete. | |
1610 */ | |
3952 | 1611 static int handlehdr_sendfile_finish(aim_session_t *sess, aim_conn_t *conn, aim_bstream_t *bs) |
3630 | 1612 { |
1613 struct aim_fileheader_t *fh; | |
1614 aim_msgcookie_t *cook; | |
1615 aim_rxcallback_t userfunc; | |
1616 | |
3952 | 1617 fh = aim_oft_getfh(bs); |
1618 | |
3630 | 1619 if (!(cook = aim_checkcookie(sess, fh->bcookie, AIM_COOKIETYPE_OFTSEND))) { |
1620 free(fh); | |
1621 return -1; | |
1622 } | |
1623 | |
3771 | 1624 if ( (userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_SENDFILECOMPLETE)) ) |
3630 | 1625 userfunc(sess, NULL, conn, fh->bcookie); |
1626 | |
1627 free(fh); | |
1628 return 0; | |
1629 } | |
1630 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1631 static int handlehdr_getfile_finish(aim_session_t *sess, aim_conn_t *conn, fu8_t *hdr) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1632 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1633 #if 0 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1634 struct aim_fileheader_t *fh; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1635 aim_rxcallback_t userfunc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1636 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1637 fh = aim_oft_getfh(hdr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1638 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1639 faimdprintf(sess, 2, "faim: get_rend: looks like we're done with a transfer (oft 0x0204)\n"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1640 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1641 if ( (userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILECOMPLETE)) ) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1642 userfunc(sess, NULL, conn, fh); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1643 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1644 free(fh); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1645 #endif |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1646 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1647 return -1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1648 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1649 |
3952 | 1650 faim_internal int aim_rxdispatch_rendezvous(aim_session_t *sess, aim_frame_t *fr) |
2086 | 1651 { |
3952 | 1652 aim_conn_t *conn = fr->conn; |
1653 aim_bstream_t *bs = &fr->data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1654 int ret = -1; |
2086 | 1655 |
3771 | 1656 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_GETFILE) { |
1657 /* This should never happen. -- wtm */ | |
1658 return getcommand_getfile(sess, conn); | |
2086 | 1659 |
3952 | 1660 } else if (conn->subtype == AIM_CONN_SUBTYPE_OFT_SENDFILE) { |
1661 switch(fr->hdr.rend.type) { | |
3771 | 1662 case AIM_OFT_PROTO_OFFER: |
3952 | 1663 ret = handlehdr_sendfile_sending(sess, conn, bs); |
3630 | 1664 break; |
3771 | 1665 case AIM_OFT_PROTO_RESUME: |
3952 | 1666 ret = handlehdr_sendfile_resume(sess, conn, bs); |
3630 | 1667 break; |
3771 | 1668 case AIM_OFT_PROTO_RESUMEACCEPT: /* like _ACCEPT */; |
1669 case AIM_OFT_PROTO_ACCEPT: | |
3952 | 1670 ret = handlehdr_sendfile_recv(sess, conn, bs); |
3630 | 1671 break; |
3771 | 1672 case AIM_OFT_PROTO_ACK: |
3952 | 1673 ret = handlehdr_sendfile_finish(sess, conn, bs); |
3630 | 1674 break; |
1675 default: | |
3952 | 1676 faimdprintf(sess, 2, "faim: OFT frame: uknown type %04x\n", fr->hdr.rend.type); |
3630 | 1677 ret = -1; |
1678 break; | |
1679 } | |
1680 | |
3952 | 1681 } else if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) { |
1682 if (fr->hdr.rend.type == 0x0001) | |
1683 ret = handlehdr_directim(sess, conn, bs); | |
1684 else | |
1685 faimdprintf(sess, 0, "faim: DIM frame: unknown type %04x\n", fr->hdr.rend.type); | |
3771 | 1686 |
3952 | 1687 } else if (conn->subtype == AIM_CONN_SUBTYPE_OFT_GETFILE) { |
1688 /* This _really_ shouldn't happen. :) -- wtm */ | |
1689 char *hdr = NULL; | |
1690 int hdrtype = fr->hdr.rend.type; | |
1691 if (hdrtype == 0x1108) /* getfile listing.txt incoming tx->rx */ | |
1692 ret = handlehdr_getfile_listing(sess, conn, hdr); | |
1693 else if (hdrtype == 0x1209) /* get file listing ack rx->tx */ | |
1694 ret = handlehdr_getfile_listing2(sess, conn, hdr); | |
1695 else if (hdrtype == 0x120b) /* get file listing rx confirm */ | |
1696 ret = handlehdr_getfile_listing3(sess, conn, hdr); | |
1697 else if (hdrtype == 0x120c) /* getfile request */ | |
1698 ret = handlehdr_getfile_request(sess, conn, hdr); | |
1699 else if (hdrtype == 0x0101) /* getfile sending data */ | |
1700 ret = handlehdr_getfile_sending(sess, conn, hdr); | |
1701 else if (hdrtype == 0x0202) /* getfile recv data */ | |
1702 ret = handlehdr_getfile_recv(sess, conn, hdr); | |
1703 else if (hdrtype == 0x0204) /* getfile finished */ | |
1704 ret = handlehdr_getfile_finish(sess, conn, hdr); | |
1705 else { | |
1706 faimdprintf(sess, 2,"faim: OFT frame: uknown type %04x\n", hdrtype); | |
1707 ret = -1; | |
1708 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1709 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1710 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1711 if (ret == -1) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1712 aim_conn_close(conn); |
2086 | 1713 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1714 return ret; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1715 } |
2086 | 1716 |
1717 /** | |
1718 * aim_oft_getfh - extracts an &aim_fileheader_t from buffer hdr. | |
3952 | 1719 * @bs: bstream to extract header from |
2086 | 1720 * |
3952 | 1721 * returns pointer to new struct on success; %NULL on error. |
2086 | 1722 * |
1723 */ | |
3952 | 1724 static struct aim_fileheader_t *aim_oft_getfh(aim_bstream_t *bs) |
2086 | 1725 { |
3952 | 1726 struct aim_fileheader_t *fh; |
1727 | |
1728 if (!(fh = calloc(1, sizeof(struct aim_fileheader_t)))) | |
1729 return NULL; | |
1730 | |
1731 /* The bstream should be positioned after the hdrtype. */ | |
1732 aimbs_getrawbuf(bs, fh->bcookie, 8); | |
1733 fh->encrypt = aimbs_get16(bs); | |
1734 fh->compress = aimbs_get16(bs); | |
1735 fh->totfiles = aimbs_get16(bs); | |
1736 fh->filesleft = aimbs_get16(bs); | |
1737 fh->totparts = aimbs_get16(bs); | |
1738 fh->partsleft = aimbs_get16(bs); | |
1739 fh->totsize = aimbs_get32(bs); | |
1740 fh->size = aimbs_get32(bs); | |
1741 fh->modtime = aimbs_get32(bs); | |
1742 fh->checksum = aimbs_get32(bs); | |
1743 fh->rfrcsum = aimbs_get32(bs); | |
1744 fh->rfsize = aimbs_get32(bs); | |
3953 | 1745 fh->cretime = aimbs_get32(bs); |
1746 fh->rfcsum = aimbs_get32(bs); | |
1747 fh->nrecvd = aimbs_get32(bs); | |
1748 fh->recvcsum = aimbs_get32(bs); | |
3952 | 1749 aimbs_getrawbuf(bs, fh->idstring, 32); |
1750 fh->flags = aimbs_get8(bs); | |
1751 fh->lnameoffset = aimbs_get8(bs); | |
1752 fh->lsizeoffset = aimbs_get8(bs); | |
1753 aimbs_getrawbuf(bs, fh->dummy, 69); | |
1754 aimbs_getrawbuf(bs, fh->macfileinfo, 16); | |
1755 fh->nencode = aimbs_get16(bs); | |
1756 fh->nlanguage = aimbs_get16(bs); | |
1757 aimbs_getrawbuf(bs, fh->name, 64); /* XXX */ | |
1758 | |
1759 return fh; | |
2086 | 1760 } |
1761 | |
1762 /** | |
1763 * aim_oft_checksum - calculate oft checksum of buffer | |
1764 * @buffer: buffer of data to checksum | |
1765 * @bufsize: size of buffer | |
3630 | 1766 * @prevcheck: previous checksum |
2086 | 1767 * |
3630 | 1768 * Prevcheck should be 0xFFFF0000 for each new file; you can have this |
1769 * checksum chunks of files in series if you just call it repeatedly in a | |
1770 * for(; ; ) loop and don't reset the checksum between each call. And you | |
1771 * thought we didn't care about you and your pathetic client's meomry | |
1772 * footprint ;^) | |
2086 | 1773 * |
3630 | 1774 * Thanks to Graham Booker for providing this improved checksum |
1775 * routine, which is simpler and should be more accurate than Josh | |
3952 | 1776 * Myer's original code. -- wtm |
2086 | 1777 * |
3630 | 1778 * This algorithim works every time I have tried it. The other fails |
1779 * sometimes. So, AOL who thought this up? It has got to be the weirdest | |
1780 * checksum I have ever seen. | |
2086 | 1781 */ |
3630 | 1782 faim_export fu32_t aim_oft_checksum(const unsigned char *buffer, int bufferlen, int prevcheck) { |
3952 | 1783 fu32_t check = (prevcheck >> 16) & 0xffff, oldcheck; |
1784 int i; | |
1785 unsigned short val; | |
1786 | |
1787 for (i=0; i<bufferlen; i++) { | |
1788 oldcheck = check; | |
1789 if (i&1) { | |
1790 val = buffer[i]; | |
1791 } else { | |
1792 val = buffer[i] << 8; | |
1793 } | |
1794 check -= val; | |
1795 /* The follownig appears to be necessary.... It happens every once in a while and the checksum doesn't fail. */ | |
1796 if (check > oldcheck) { | |
1797 check--; | |
1798 } | |
1799 } | |
1800 check = ((check & 0x0000ffff) + (check >> 16)); | |
1801 check = ((check & 0x0000ffff) + (check >> 16)); | |
1802 return check << 16; | |
3630 | 1803 } |
2086 | 1804 |
3630 | 1805 faim_export fu32_t aim_update_checksum(aim_session_t *sess, aim_conn_t *conn, |
1806 const unsigned char *buffer, int len) { | |
3771 | 1807 struct aim_filetransfer_priv *ft = conn->internal; |
2086 | 1808 |
3630 | 1809 ft->fh.nrecvd += len; |
1810 ft->fh.recvcsum = aim_oft_checksum(buffer, len, ft->fh.recvcsum); | |
2086 | 1811 |
3630 | 1812 return 0; |
1813 } | |
2086 | 1814 |
1815 /** | |
1816 * aim_oft_buildheader - fills a buffer with network-order fh data | |
3952 | 1817 * @bs: bstream to fill -- automatically initialized |
1818 * @fh: fh to get data from | |
2086 | 1819 * |
3952 | 1820 * returns -1 on error. |
2086 | 1821 * |
1822 */ | |
3952 | 1823 static int aim_oft_buildheader(aim_bstream_t *bs, struct aim_fileheader_t *fh) |
2086 | 1824 { |
3952 | 1825 fu8_t *hdr; |
1826 | |
1827 if (!bs || !fh) | |
1828 return -1; | |
1829 | |
1830 | |
1831 | |
1832 | |
1833 if (!(hdr = (unsigned char *)calloc(1, 0x100 - 8))) { | |
1834 return -1; | |
1835 } | |
1836 aim_bstream_init(bs, hdr, 0x100 - 8); | |
2086 | 1837 |
3952 | 1838 aimbs_putraw(bs, fh->bcookie, 8); |
1839 aimbs_put16(bs, fh->encrypt); | |
1840 aimbs_put16(bs, fh->compress); | |
1841 aimbs_put16(bs, fh->totfiles); | |
1842 aimbs_put16(bs, fh->filesleft); | |
1843 aimbs_put16(bs, fh->totparts); | |
1844 aimbs_put16(bs, fh->partsleft); | |
1845 aimbs_put32(bs, fh->totsize); | |
1846 aimbs_put32(bs, fh->size); | |
1847 aimbs_put32(bs, fh->modtime); | |
1848 aimbs_put32(bs, fh->checksum); | |
1849 aimbs_put32(bs, fh->rfrcsum); | |
1850 aimbs_put32(bs, fh->rfsize); | |
1851 aimbs_put32(bs, fh->cretime); | |
1852 aimbs_put32(bs, fh->rfcsum); | |
1853 aimbs_put32(bs, fh->nrecvd); | |
1854 aimbs_put32(bs, fh->recvcsum); | |
1855 aimbs_putraw(bs, fh->idstring, 32); | |
1856 aimbs_put8(bs, fh->flags); | |
1857 aimbs_put8(bs, fh->lnameoffset); | |
1858 aimbs_put8(bs, fh->lsizeoffset); | |
1859 aimbs_putraw(bs, fh->dummy, 69); | |
1860 aimbs_putraw(bs, fh->macfileinfo, 16); | |
1861 aimbs_put16(bs, fh->nencode); | |
1862 aimbs_put16(bs, fh->nlanguage); | |
1863 aimbs_putraw(bs, fh->name, 64); | |
1864 | |
1865 /* XXX: Filenames longer than 64B */ | |
1866 return 0; | |
2086 | 1867 } |
1868 | |
1869 /** | |
1870 * aim_getfile_intitiate - Request an OFT getfile session | |
1871 * @sess: your session, | |
1872 * @conn: the BOS conn, | |
1873 * @destsn is the SN to connect to. | |
1874 * | |
1875 * returns a new &aim_conn_t on success, %NULL on error | |
1876 */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1877 faim_export aim_conn_t *aim_getfile_initiate(aim_session_t *sess, aim_conn_t *conn, const char *destsn) |
2086 | 1878 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1879 return NULL; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1880 #if 0 |
3952 | 1881 struct command_tx_struct *newpacket; |
1882 struct aim_conn_t *newconn; | |
1883 struct aim_filetransfer_priv *priv; | |
1884 struct aim_msgcookie_t *cookie; | |
1885 int curbyte, i, listenfd; | |
1886 short port = 4443; | |
1887 struct hostent *hptr; | |
1888 struct utsname myname; | |
1889 char cap[16]; | |
1890 char d[4]; | |
2086 | 1891 |
3952 | 1892 /* Open our socket */ |
1893 | |
1894 if ( (listenfd = aim_listenestablish(port)) == -1) | |
1895 return NULL; | |
2086 | 1896 |
3952 | 1897 /* get our local IP */ |
2086 | 1898 |
3952 | 1899 if (uname(&myname) < 0) |
1900 return NULL; | |
1901 if ( (hptr = gethostbyname(myname.nodename)) == NULL) | |
1902 return NULL; | |
1903 memcpy(&d, hptr->h_addr_list[0], 4); | |
2086 | 1904 |
3952 | 1905 aim_putcap(cap, 16, AIM_CAPS_GETFILE); |
2086 | 1906 |
3952 | 1907 /* create the OSCAR packet */ |
2086 | 1908 |
3952 | 1909 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10+8+2+1+strlen(destsn)+4+4+0x42))) |
1910 return NULL; | |
1911 newpacket->lock = 1; | |
2086 | 1912 |
3952 | 1913 /* lock struct */ |
1914 curbyte = 0; | |
1915 curbyte += aim_putsnac(newpacket->data+curbyte, 0x0004, 0x0006, 0x0000, sess->snac_nextid); | |
2086 | 1916 |
3952 | 1917 /* XXX: check the cookie before commiting to using it */ |
2086 | 1918 |
3952 | 1919 /* Generate a random message cookie |
1920 * This cookie needs to be alphanumeric and NULL-terminated to be TOC-compatible. */ | |
1921 for (i=0; i<7; i++) | |
1922 curbyte += aimutil_put8(newpacket->data+curbyte, 0x30 + ((u_char) random() % 10)); | |
2086 | 1923 |
3952 | 1924 curbyte += aimutil_put8(newpacket->data+curbyte, 0x00); |
2086 | 1925 |
3952 | 1926 /* grab all the data for cookie caching. */ |
2086 | 1927 |
3952 | 1928 if (!(cookie = (struct aim_msgcookie_t *)calloc(1, sizeof(struct aim_msgcookie_t)))) |
1929 return NULL; | |
1930 memcpy(cookie->cookie, newpacket->data+curbyte-8, 8); | |
1931 cookie->type = AIM_COOKIETYPE_OFTGET; | |
2086 | 1932 |
3952 | 1933 if (!(priv = (struct aim_filetransfer_priv *)calloc(1, sizeof(struct aim_filetransfer_priv)))) |
1934 return NULL; | |
1935 memcpy(priv->cookie, cookie, 8); | |
1936 memcpy(priv->sn, destsn, sizeof(priv->sn)); | |
1937 memcpy(priv->fh.name, "listing.txt", strlen("listing.txt")); | |
1938 priv->state = 1; | |
2086 | 1939 |
3952 | 1940 cookie->data = priv; |
2086 | 1941 |
3952 | 1942 aim_cachecookie(sess, cookie); |
2086 | 1943 |
3952 | 1944 /* Channel ID */ |
1945 curbyte += aimutil_put16(newpacket->data+curbyte,0x0002); | |
2086 | 1946 |
3952 | 1947 /* Destination SN (prepended with byte length) */ |
1948 curbyte += aimutil_put8(newpacket->data+curbyte,strlen(destsn)); | |
1949 curbyte += aimutil_putstr(newpacket->data+curbyte, destsn, strlen(destsn)); | |
1950 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0003); | |
1951 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000); | |
2086 | 1952 |
3952 | 1953 /* enTLV start */ |
1954 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0005); | |
1955 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0042); | |
2086 | 1956 |
3952 | 1957 /* Flag data / ICBM Parameters? */ |
1958 curbyte += aimutil_put8(newpacket->data+curbyte, 0x00); | |
1959 curbyte += aimutil_put8(newpacket->data+curbyte, 0x00); | |
2086 | 1960 |
3952 | 1961 /* Cookie */ |
1962 curbyte += aimutil_putstr(newpacket->data+curbyte, (char *)cookie, 8); | |
2086 | 1963 |
3952 | 1964 /* Capability String */ |
1965 curbyte += aimutil_putstr(newpacket->data+curbyte, (char *)cap, 0x10); | |
2086 | 1966 |
3952 | 1967 /* 000a/0002 : 0001 */ |
1968 curbyte += aimutil_put16(newpacket->data+curbyte, 0x000a); | |
1969 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002); | |
1970 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001); | |
2086 | 1971 |
3952 | 1972 /* 0003/0004: IP address */ |
1973 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0003); | |
1974 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0004); | |
1975 for (i = 0; i < 4; i++) | |
1976 curbyte += aimutil_put8(newpacket->data+curbyte, d[i]); | |
2086 | 1977 |
3952 | 1978 /* already in network byte order */ |
2086 | 1979 |
3952 | 1980 /* 0005/0002: Port */ |
1981 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0005); | |
1982 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002); | |
1983 curbyte += aimutil_put16(newpacket->data+curbyte, port); | |
2086 | 1984 |
3952 | 1985 /* 000f/0000: ?? */ |
1986 curbyte += aimutil_put16(newpacket->data+curbyte, 0x000f); | |
1987 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000); | |
2086 | 1988 |
3952 | 1989 /* 2711/000c: ?? */ |
1990 curbyte += aimutil_put16(newpacket->data+curbyte, 0x2711); | |
1991 curbyte += aimutil_put16(newpacket->data+curbyte, 0x000c); | |
1992 curbyte += aimutil_put32(newpacket->data+curbyte, 0x00120001); | |
2086 | 1993 |
3952 | 1994 for (i = 0; i < 0x000c - 4; i++) |
1995 curbyte += aimutil_put8(newpacket->data+curbyte, 0x00); | |
2086 | 1996 |
3952 | 1997 newpacket->commandlen = curbyte; |
1998 newpacket->lock = 0; | |
1999 aim_tx_enqueue(sess, newpacket); | |
2086 | 2000 |
3952 | 2001 /* allocate and set up our connection */ |
2086 | 2002 |
3952 | 2003 i = fcntl(listenfd, F_GETFL, 0); |
2004 fcntl(listenfd, F_SETFL, i | O_NONBLOCK); | |
2005 newconn = aim_newconn(sess, AIM_CONN_TYPE_RENDEZVOUS_OUT, NULL); | |
2086 | 2006 |
3952 | 2007 if (!newconn){ |
2008 perror("aim_newconn"); | |
2009 return NULL; | |
2010 } | |
2086 | 2011 |
3952 | 2012 newconn->fd = listenfd; |
2013 newconn->subtype = AIM_CONN_SUBTYPE_OFT_GETFILE; | |
2014 newconn->internal = priv; | |
2015 faimdprintf(sess, 2,"faim: listening (fd = %d, unconnected)\n", newconn->fd); | |
2086 | 2016 |
3952 | 2017 return newconn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2018 #endif |
2086 | 2019 } |
2020 | |
2021 /** | |
2022 * aim_oft_getfile_request - request a particular file over an established getfile connection | |
2023 * @sess: your session | |
2024 * @conn: the established OFT getfile connection | |
2025 * @name: filename to request | |
2026 * @size: size of the file | |
2027 * | |
2028 * | |
2029 * returns -1 on error, 0 on successful enqueuing | |
2030 */ | |
3630 | 2031 #if 0 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2032 faim_export int aim_oft_getfile_request(aim_session_t *sess, aim_conn_t *conn, const char *name, int size) |
2086 | 2033 { |
3952 | 2034 aim_frame_t *newoft; |
2035 struct aim_filetransfer_priv *ft; | |
2036 if (!sess || !conn || !conn->priv || !name) | |
2037 return -1; | |
2086 | 2038 |
3952 | 2039 if (!(newoft = aim_tx_new(sess, conn, AIM_FRAMETYPE_OFT, 0x120c, 0))) { |
2040 faimdprintf(sess, 2, "faim: aim_accepttransfer: tx_new OFT failed\n"); | |
2041 return -1; | |
2042 } | |
2043 memcpy(newoft->hdr.oft.magic, "OFT2", 4); | |
2044 newoft->hdr.oft.hdr2len = 0x100 - 8; | |
2086 | 2045 |
3952 | 2046 ft = (struct aim_filetransfer_priv *)conn->priv; |
2047 ft->fh.filesleft = 1; | |
2048 ft->fh.totfiles = 1; | |
2049 ft->fh.totparts = 1; | |
2050 ft->fh.partsleft = 1; | |
2051 ft->fh.totsize = size; | |
2052 ft->fh.size = size; | |
2053 ft->fh.checksum = 0; | |
2054 memcpy(ft->fh.name, name, strlen(name)); | |
2055 memset(ft->fh.name+strlen(name), 0, 1); | |
2086 | 2056 |
3952 | 2057 if (!(newoft->hdr.oft.hdr2 = (unsigned char *)calloc(1,newoft->hdr.oft.hdr2len))) { |
2058 aim_frame_destroy(newoft); | |
2059 return -1; | |
2060 } | |
2086 | 2061 |
3952 | 2062 if (!(aim_oft_buildheader(newoft->hdr.oft.hdr2, &(ft->fh)))) { |
2063 aim_frame_destroy(newoft); | |
2064 return -1; | |
2065 } | |
2086 | 2066 |
3952 | 2067 aim_tx_enqueue(sess, newoft); |
2068 return 0; | |
3630 | 2069 } |
2070 #endif | |
2071 | |
2072 /* Identify a file that we are about to send by transmitting the | |
2073 * appropriate header. | |
2074 */ | |
3771 | 2075 faim_export int aim_oft_sendfile_request(aim_session_t *sess, aim_conn_t *conn, const char *filename, int filesdone, int numfiles, int size, int totsize) |
3630 | 2076 { |
3952 | 2077 aim_frame_t *newoft; |
2078 aim_msgcookie_t *cook; | |
2079 struct aim_filetransfer_priv *ft = (struct aim_filetransfer_priv *)conn->internal; | |
2080 struct aim_fileheader_t *fh; | |
3630 | 2081 |
3952 | 2082 if (!sess || !conn || !filename) |
2083 return -1; | |
3630 | 2084 |
3952 | 2085 if (!(fh = (struct aim_fileheader_t*)calloc(1, sizeof(struct aim_fileheader_t)))) |
2086 return -1; | |
3630 | 2087 |
3752 | 2088 #ifdef DUMB_OFT_CHECKSUM |
3952 | 2089 /* Yes, we are supposed to checksum the whole file before sending, and |
2090 * yes, it's dumb. This is the only way to get some clients (such as | |
2091 * Mac AIM v4.5.163) to successfully complete the transfer. With | |
2092 * the WinAIM clients, we seem to be able to get away with just | |
2093 * setting the checksum to zero. | |
2094 * -- wtm | |
2095 */ | |
2096 { | |
2097 int fd = open(filename, O_RDONLY); | |
2098 if (fd >= 0) { | |
2099 int bytes; | |
2100 char buf[1024]; | |
2101 fh->checksum = 0xffff0000; | |
2102 while ((bytes = aim_recv(fd, buf, 1024)) > 0) { | |
2103 fh->checksum = aim_oft_checksum(buf, bytes, fh->checksum); | |
2104 } | |
2105 } | |
2106 close(fd); | |
2107 } | |
3752 | 2108 #else |
3952 | 2109 fh->checksum = 0x00000000; |
3752 | 2110 #endif |
3952 | 2111 fh->encrypt = 0x0000; |
2112 fh->compress = 0x0000; | |
2113 fh->totfiles = numfiles; | |
2114 fh->filesleft = numfiles - filesdone; | |
3960 | 2115 fh->totparts = 0x0001; /* set to 0x0002 sending Mac resource forks */ |
3952 | 2116 fh->partsleft = 0x0001; |
3960 | 2117 fh->totsize = totsize; |
3952 | 2118 fh->size = size; |
2119 fh->modtime = (int)time(NULL); /* we'll go with current time for now */ | |
2120 /* fh->checksum set above */ | |
2121 fh->rfcsum = 0x00000000; | |
2122 fh->rfsize = 0x00000000; | |
2123 fh->cretime = 0x00000000; | |
2124 fh->rfcsum = 0x00000000; | |
2125 fh->nrecvd = 0x00000000; /* always zero initially */ | |
2126 fh->recvcsum= 0x00000000; /* ditto */ | |
3630 | 2127 |
3952 | 2128 strncpy(fh->idstring, "OFT_Windows ICBMFT V1.1 32", sizeof(fh->idstring)); |
2129 fh->flags = 0x02; | |
2130 fh->lnameoffset = 0x1a; | |
2131 fh->lsizeoffset = 0x10; | |
2132 memset(fh->dummy, 0, sizeof(fh->dummy)); | |
2133 memset(fh->macfileinfo, 0, sizeof(fh->macfileinfo)); | |
3630 | 2134 |
3952 | 2135 /* apparently 0 is ASCII, 2 is UCS-2 */ |
2136 /* it is likely that 3 is ISO 8859-1 */ | |
2137 fh->nencode = 0x0000; | |
2138 fh->nlanguage = 0x0000; | |
3752 | 2139 |
3952 | 2140 /* Convert the directory separator to ^A for portability. */ |
2141 strncpy(fh->name, filename, sizeof(fh->name)); | |
2142 oft_dirconvert(fh->name); | |
3752 | 2143 |
3952 | 2144 /* XXX we should normally send a null cookie here, and make |
2145 * the receiver fill it in for authentication -- wtm | |
2146 */ | |
2147 memcpy(fh->bcookie, ft->cookie, 8); | |
3630 | 2148 |
3952 | 2149 if (!(cook = aim_checkcookie(sess, ft->cookie, AIM_COOKIETYPE_OFTSEND))) { |
2150 return -1; | |
2151 } | |
2152 | |
2153 /* Update both headers to be safe. */ | |
2154 memcpy(&(ft->fh), fh, sizeof(struct aim_fileheader_t)); | |
2155 memcpy(&(((struct aim_filetransfer_priv *)cook->data)->fh), fh, sizeof(struct aim_fileheader_t)); | |
3630 | 2156 |
3952 | 2157 if (!(newoft = aim_tx_new(sess, conn, AIM_FRAMETYPE_OFT, AIM_OFT_PROTO_OFFER, 0))) { |
2158 faimdprintf(sess, 2, "faim: aim_accepttransfer: tx_new OFT failed\n"); | |
2159 free(fh); | |
2160 return -1; | |
2161 } | |
3630 | 2162 |
3952 | 2163 if (aim_oft_buildheader(&newoft->data, fh) == -1) { |
2164 aim_frame_destroy(newoft); | |
2165 free(fh); | |
2166 return -1; | |
2167 } | |
2086 | 2168 |
3952 | 2169 memcpy(newoft->hdr.rend.magic, "OFT2", 4); |
2170 newoft->hdr.rend.hdrlen = aim_bstream_curpos(&newoft->data); | |
2171 | |
2172 aim_tx_enqueue(sess, newoft); | |
2173 free(fh); | |
2174 return 0; | |
2086 | 2175 } |
2176 | |
2177 /** | |
2178 * aim_oft_getfile_ack - acknowledge a getfile download as complete | |
2179 * @sess: your session | |
2180 * @conn: the getfile conn to send the ack over | |
2181 * | |
2182 * Call this function after you have read all the data in a particular | |
2183 * filetransfer. Returns -1 on error, 0 on apparent success | |
2184 * | |
2185 */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2186 faim_export int aim_oft_getfile_ack(aim_session_t *sess, aim_conn_t *conn) |
2086 | 2187 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2188 return -EINVAL; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2189 #if 0 |
3952 | 2190 struct command_tx_struct *newoft; |
2191 struct aim_filetransfer_priv *ft; | |
2086 | 2192 |
3952 | 2193 if (!sess || !conn || !conn->priv) |
2194 return -1; | |
2086 | 2195 |
3952 | 2196 if (!(newoft = aim_tx_new(sess, conn, AIM_FRAMETYPE_OFT, 0x0202, 0))) { |
2197 faimdprintf(sess, 2, "faim: aim_accepttransfer: tx_new OFT failed\n"); | |
2198 return -1; | |
2199 } | |
2086 | 2200 |
3952 | 2201 newoft->lock = 1; |
2086 | 2202 |
3952 | 2203 memcpy(newoft->hdr.oft.magic, "OFT2", 4); |
2204 newoft->hdr.oft.hdr2len = 0x100-8; | |
2086 | 2205 |
3952 | 2206 if (!(newoft->hdr.oft.hdr2 = (char *)calloc(1,newoft->hdr.oft.hdr2len))) { |
2207 newoft->lock = 0; | |
2208 aim_frame_destroy(newoft); | |
2209 return -1; | |
2210 } | |
2086 | 2211 |
3952 | 2212 ft = (struct aim_filetransfer_priv *)conn->priv; |
2086 | 2213 |
3952 | 2214 if (!(aim_oft_buildheader((unsigned char *)newoft->hdr.oft.hdr2, &(ft->fh)))) { |
2215 newoft->lock = 0; | |
2216 aim_frame_destroy(newoft); | |
2217 return -1; | |
2218 } | |
2086 | 2219 |
3952 | 2220 newoft->lock = 0; |
2221 aim_tx_enqueue(sess, newoft); | |
2222 return 0; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2223 #endif |
2086 | 2224 } |
2225 | |
2226 /** | |
3630 | 2227 * aim_oft_end - end a getfile/sendfile. |
2086 | 2228 * @sess: your session |
2229 * @conn: the getfile connection | |
2230 * | |
2231 * call this before you close the getfile connection if you're on the | |
2232 * receiving/requesting end. | |
2233 */ | |
3630 | 2234 faim_export int aim_oft_end(aim_session_t *sess, aim_conn_t *conn) |
2086 | 2235 { |
3952 | 2236 aim_frame_t *newoft; |
2237 struct aim_filetransfer_priv *ft; | |
2238 | |
2239 if (!sess || !conn || !conn->internal) | |
2240 return -1; | |
2241 | |
2242 if (!(newoft = aim_tx_new(sess, conn, AIM_FRAMETYPE_OFT, AIM_OFT_PROTO_ACK, 0))) { | |
2243 faimdprintf(sess, 2, "faim: aim_accepttransfer: tx_new OFT failed\n"); | |
2244 return -1; | |
2245 } | |
2086 | 2246 |
3952 | 2247 ft = (struct aim_filetransfer_priv *)conn->internal; |
2248 ft->state = 4; /* no longer wanting data */ | |
2249 ft->fh.flags = 0x21; | |
2250 | |
2251 if (aim_oft_buildheader(&(newoft->data), &(ft->fh)) == -1) { | |
2252 aim_frame_destroy(newoft); | |
2253 return -1; | |
2254 } | |
2255 memcpy(newoft->hdr.rend.magic, "OFT2", 4); | |
2256 newoft->hdr.rend.hdrlen = aim_bstream_curpos(&newoft->data); | |
2257 | |
2258 aim_tx_enqueue(sess, newoft); | |
2259 | |
2260 return 0; | |
2086 | 2261 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2262 |
3952 | 2263 /* |
2264 * Convert the directory separator to ^A, which seems to be AOL's attempt at portability. | |
2265 */ | |
2266 static void oft_dirconvert(char *name) { | |
2267 char *c = name; | |
2268 while ((c = strchr(c, G_DIR_SEPARATOR))) | |
2269 *c = 0x01; | |
3771 | 2270 } |