annotate src/protocols/oscar/ft.c @ 3718:fd3880c03f0d

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