annotate src/protocols/oscar/family_oservice.c @ 13648:3eba1e7458c7

[gaim-migrate @ 16049] __unix__ is not defined in Mac OS X [1], but this code for asynchronous DNS lookups works fine on that platform (at least as of OS X 10.3.9). We now check for __unix__ or __APPLE__ being defined. [1] http://developer.apple.com/technotes/tn2002/tn2071.html - under the section "Predefined Macros" committer: Tailor Script <tailor@pidgin.im>
author Evan Schoenberg <evan.s@dreskin.net>
date Mon, 17 Apr 2006 19:28:15 +0000
parents 7f91efd5af77
children 4132d997ccec
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
2 * Gaim's oscar protocol plugin
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
3 * This file is the legal property of its developers.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
4 * Please see the AUTHORS file distributed alongside this file.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
5 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
6 * This library is free software; you can redistribute it and/or
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
7 * modify it under the terms of the GNU Lesser General Public
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
8 * License as published by the Free Software Foundation; either
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
9 * version 2 of the License, or (at your option) any later version.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
10 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
11 * This library is distributed in the hope that it will be useful,
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
14 * Lesser General Public License for more details.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
15 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
16 * You should have received a copy of the GNU Lesser General Public
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
17 * License along with this library; if not, write to the Free Software
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
19 */
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
20
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
21 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
22 * Family 0x0001 - This is a very special group. All connections support
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
23 * this group, as it does some particularly good things (like rate limiting).
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
24 */
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
25
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
26 #include "oscar.h"
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
27
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
28 #include "cipher.h"
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
29
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
30 /* Subtype 0x0002 - Client Online */
13609
5796551db930 [gaim-migrate @ 15995]
Mark Doliner <mark@kingant.net>
parents: 13592
diff changeset
31 void
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
32 aim_clientready(OscarData *od, FlapConnection *conn)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
33 {
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
34 FlapFrame *frame;
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
35 aim_snacid_t snacid;
13611
7f91efd5af77 [gaim-migrate @ 15997]
Mark Doliner <mark@kingant.net>
parents: 13609
diff changeset
36 GList *cur;
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
37
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
38 frame = flap_frame_new(od, 0x02, 1152);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
39
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
40 snacid = aim_cachesnac(od, 0x0001, 0x0002, 0x0000, NULL, 0);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
41 aim_putsnac(&frame->data, 0x0001, 0x0002, 0x0000, snacid);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
42
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
43 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
44 * Send only the tool versions that the server cares about (that it
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
45 * marked as supporting in the server ready SNAC).
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
46 */
13611
7f91efd5af77 [gaim-migrate @ 15997]
Mark Doliner <mark@kingant.net>
parents: 13609
diff changeset
47 for (cur = conn->groups; cur != NULL; cur = cur->next)
13609
5796551db930 [gaim-migrate @ 15995]
Mark Doliner <mark@kingant.net>
parents: 13592
diff changeset
48 {
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
49 aim_module_t *mod;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
50
13611
7f91efd5af77 [gaim-migrate @ 15997]
Mark Doliner <mark@kingant.net>
parents: 13609
diff changeset
51 if ((mod = aim__findmodulebygroup(od, GPOINTER_TO_UINT(cur->data))))
7f91efd5af77 [gaim-migrate @ 15997]
Mark Doliner <mark@kingant.net>
parents: 13609
diff changeset
52 {
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
53 byte_stream_put16(&frame->data, mod->family);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
54 byte_stream_put16(&frame->data, mod->version);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
55 byte_stream_put16(&frame->data, mod->toolid);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
56 byte_stream_put16(&frame->data, mod->toolversion);
13611
7f91efd5af77 [gaim-migrate @ 15997]
Mark Doliner <mark@kingant.net>
parents: 13609
diff changeset
57 }
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
58 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
59
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
60 flap_connection_send(conn, frame);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
61 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
62
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
63 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
64 * Subtype 0x0003 - Host Online
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
65 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
66 * See comments in conn.c about how the group associations are supposed
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
67 * to work, and how they really work.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
68 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
69 * This info probably doesn't even need to make it to the client.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
70 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
71 * We don't actually call the client here. This starts off the connection
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
72 * initialization routine required by all AIM connections. The next time
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
73 * the client is called is the CONNINITDONE callback, which should be
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
74 * shortly after the rate information is acknowledged.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
75 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
76 */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
77 static int
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
78 hostonline(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
79 {
13611
7f91efd5af77 [gaim-migrate @ 15997]
Mark Doliner <mark@kingant.net>
parents: 13609
diff changeset
80 int group;
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
81
13611
7f91efd5af77 [gaim-migrate @ 15997]
Mark Doliner <mark@kingant.net>
parents: 13609
diff changeset
82 while (byte_stream_empty(bs))
7f91efd5af77 [gaim-migrate @ 15997]
Mark Doliner <mark@kingant.net>
parents: 13609
diff changeset
83 {
7f91efd5af77 [gaim-migrate @ 15997]
Mark Doliner <mark@kingant.net>
parents: 13609
diff changeset
84 group = byte_stream_get16(bs);
7f91efd5af77 [gaim-migrate @ 15997]
Mark Doliner <mark@kingant.net>
parents: 13609
diff changeset
85 conn->groups = g_list_prepend(conn->groups, GUINT_TO_POINTER(group));
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
86 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
87
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
88 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
89 * Next step is in the Host Versions handler.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
90 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
91 * Note that we must send this before we request rates, since
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
92 * the format of the rate information depends on the versions we
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
93 * give it.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
94 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
95 */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
96 aim_setversions(od, conn);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
97
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
98 return 1;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
99 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
100
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
101 /* Subtype 0x0004 - Service request */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
102 int aim_reqservice(OscarData *od, guint16 serviceid)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
103 {
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
104 FlapConnection *conn;
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
105
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
106 conn = flap_connection_findbygroup(od, SNAC_FAMILY_BOS);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
107
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
108 return aim_genericreq_s(od, conn, 0x0001, 0x0004, &serviceid);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
109 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
110
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
111 /*
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
112 * Join a room of name roomname. This is the first step to joining an
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
113 * already created room. It's basically a Service Request for
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
114 * family 0x000e, with a little added on to specify the exchange and room
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
115 * name.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
116 */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
117 int
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
118 aim_chat_join(OscarData *od, guint16 exchange, const char *roomname, guint16 instance)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
119 {
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
120 FlapConnection *conn;
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
121 FlapFrame *frame;
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
122 aim_snacid_t snacid;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
123 aim_tlvlist_t *tl = NULL;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
124 struct chatsnacinfo csi;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
125
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
126 conn = flap_connection_findbygroup(od, SNAC_FAMILY_BOS);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
127 if (!od || !conn || !roomname || !strlen(roomname))
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
128 return -EINVAL;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
129
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
130 frame = flap_frame_new(od, 0x02, 512);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
131
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
132 memset(&csi, 0, sizeof(csi));
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
133 csi.exchange = exchange;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
134 strncpy(csi.name, roomname, sizeof(csi.name));
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
135 csi.instance = instance;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
136
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
137 snacid = aim_cachesnac(od, 0x0001, 0x0004, 0x0000, &csi, sizeof(csi));
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
138 aim_putsnac(&frame->data, 0x0001, 0x0004, 0x0000, snacid);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
139
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
140 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
141 * Requesting service chat (0x000e)
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
142 */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
143 byte_stream_put16(&frame->data, 0x000e);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
144
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
145 aim_tlvlist_add_chatroom(&tl, 0x0001, exchange, roomname, instance);
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
146 aim_tlvlist_write(&frame->data, &tl);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
147 aim_tlvlist_free(&tl);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
148
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
149 flap_connection_send(conn, frame);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
150
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
151 return 0;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
152 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
153
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
154 /* Subtype 0x0005 - Redirect */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
155 static int
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
156 redirect(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
157 {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
158 struct aim_redirect_data redir;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
159 aim_rxcallback_t userfunc;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
160 aim_tlvlist_t *tlvlist;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
161 aim_snac_t *origsnac = NULL;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
162 int ret = 0;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
163
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
164 memset(&redir, 0, sizeof(redir));
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
165
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
166 tlvlist = aim_tlvlist_read(bs);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
167
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
168 if (!aim_tlv_gettlv(tlvlist, 0x000d, 1) ||
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
169 !aim_tlv_gettlv(tlvlist, 0x0005, 1) ||
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
170 !aim_tlv_gettlv(tlvlist, 0x0006, 1)) {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
171 aim_tlvlist_free(&tlvlist);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
172 return 0;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
173 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
174
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
175 redir.group = aim_tlv_get16(tlvlist, 0x000d, 1);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
176 redir.ip = aim_tlv_getstr(tlvlist, 0x0005, 1);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
177 redir.cookielen = aim_tlv_gettlv(tlvlist, 0x0006, 1)->length;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
178 redir.cookie = (guchar *)aim_tlv_getstr(tlvlist, 0x0006, 1);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
179
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
180 /* Fetch original SNAC so we can get csi if needed */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
181 origsnac = aim_remsnac(od, snac->id);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
182
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
183 if ((redir.group == SNAC_FAMILY_CHAT) && origsnac) {
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
184 struct chatsnacinfo *csi = (struct chatsnacinfo *)origsnac->data;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
185
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
186 redir.chat.exchange = csi->exchange;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
187 redir.chat.room = csi->name;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
188 redir.chat.instance = csi->instance;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
189 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
190
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
191 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
192 ret = userfunc(od, conn, frame, &redir);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
193
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
194 free((void *)redir.ip);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
195 free((void *)redir.cookie);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
196
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
197 if (origsnac)
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
198 free(origsnac->data);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
199 free(origsnac);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
200
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
201 aim_tlvlist_free(&tlvlist);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
202
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
203 return ret;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
204 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
205
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
206 /* Subtype 0x0006 - Request Rate Information. */
13609
5796551db930 [gaim-migrate @ 15995]
Mark Doliner <mark@kingant.net>
parents: 13592
diff changeset
207 void
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
208 aim_reqrates(OscarData *od, FlapConnection *conn)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
209 {
13609
5796551db930 [gaim-migrate @ 15995]
Mark Doliner <mark@kingant.net>
parents: 13592
diff changeset
210 aim_genericreq_n_snacid(od, conn, 0x0001, 0x0006);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
211 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
212
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
213 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
214 * OSCAR defines several 'rate classes'. Each class has separate
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
215 * rate limiting properties (limit level, alert level, disconnect
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
216 * level, etc), and a set of SNAC family/type pairs associated with
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
217 * it. The rate classes, their limiting properties, and the definitions
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
218 * of which SNACs are belong to which class, are defined in the
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
219 * Rate Response packet at login to each host.
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
220 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
221 * Logically, all rate offenses within one class count against further
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
222 * offenses for other SNACs in the same class (ie, sending messages
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
223 * too fast will limit the number of user info requests you can send,
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
224 * since those two SNACs are in the same rate class).
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
225 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
226 * Since the rate classes are defined dynamically at login, the values
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
227 * below may change. But they seem to be fairly constant.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
228 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
229 * Currently, BOS defines five rate classes, with the commonly used
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
230 * members as follows...
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
231 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
232 * Rate class 0x0001:
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
233 * - Everything thats not in any of the other classes
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
234 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
235 * Rate class 0x0002:
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
236 * - Buddy list add/remove
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
237 * - Permit list add/remove
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
238 * - Deny list add/remove
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
239 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
240 * Rate class 0x0003:
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
241 * - User information requests
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
242 * - Outgoing ICBMs
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
243 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
244 * Rate class 0x0004:
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
245 * - A few unknowns: 2/9, 2/b, and f/2
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
246 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
247 * Rate class 0x0005:
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
248 * - Chat room create
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
249 * - Outgoing chat ICBMs
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
250 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
251 * The only other thing of note is that class 5 (chat) has slightly looser
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
252 * limiting properties than class 3 (normal messages). But thats just a
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
253 * small bit of trivia for you.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
254 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
255 * The last thing that needs to be learned about the rate limiting
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
256 * system is how the actual numbers relate to the passing of time. This
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
257 * seems to be a big mystery.
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
258 *
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
259 */
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
260
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
261 static void
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
262 rc_addclass(struct rateclass **head, struct rateclass *inrc)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
263 {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
264 struct rateclass *rc, *rc2;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
265
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
266 rc = g_memdup(inrc, sizeof(struct rateclass));
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
267 rc->next = NULL;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
268
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
269 for (rc2 = *head; rc2 && rc2->next; rc2 = rc2->next)
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
270 ;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
271
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
272 if (!rc2)
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
273 *head = rc;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
274 else
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
275 rc2->next = rc;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
276
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
277 return;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
278 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
279
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
280 static struct rateclass *
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
281 rc_findclass(struct rateclass **head, guint16 id)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
282 {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
283 struct rateclass *rc;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
284
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
285 for (rc = *head; rc; rc = rc->next) {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
286 if (rc->classid == id)
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
287 return rc;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
288 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
289
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
290 return NULL;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
291 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
292
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
293 static void
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
294 rc_addpair(struct rateclass *rc, guint16 group, guint16 type)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
295 {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
296 struct snacpair *sp, *sp2;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
297
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
298 sp = g_new0(struct snacpair, 1);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
299 sp->group = group;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
300 sp->subtype = type;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
301 sp->next = NULL;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
302
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
303 for (sp2 = rc->members; sp2 && sp2->next; sp2 = sp2->next)
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
304 ;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
305
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
306 if (!sp2)
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
307 rc->members = sp;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
308 else
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
309 sp2->next = sp;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
310
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
311 return;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
312 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
313
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
314 /* Subtype 0x0007 - Rate Parameters */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
315 static int
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
316 rateresp(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
317 {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
318 guint16 numclasses, i;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
319 aim_rxcallback_t userfunc;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
320
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
321 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
322 * First are the parameters for each rate class.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
323 */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
324 numclasses = byte_stream_get16(bs);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
325 for (i = 0; i < numclasses; i++) {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
326 struct rateclass rc;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
327
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
328 memset(&rc, 0, sizeof(struct rateclass));
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
329
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
330 rc.classid = byte_stream_get16(bs);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
331 rc.windowsize = byte_stream_get32(bs);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
332 rc.clear = byte_stream_get32(bs);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
333 rc.alert = byte_stream_get32(bs);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
334 rc.limit = byte_stream_get32(bs);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
335 rc.disconnect = byte_stream_get32(bs);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
336 rc.current = byte_stream_get32(bs);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
337 rc.max = byte_stream_get32(bs);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
338
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
339 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
340 * The server will send an extra five bytes of parameters
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
341 * depending on the version we advertised in 1/17. If we
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
342 * didn't send 1/17 (evil!), then this will crash and you
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
343 * die, as it will default to the old version but we have
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
344 * the new version hardcoded here.
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
345 */
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
346 if (mod->version >= 3)
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
347 byte_stream_getrawbuf(bs, rc.unknown, sizeof(rc.unknown));
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
348
13609
5796551db930 [gaim-migrate @ 15995]
Mark Doliner <mark@kingant.net>
parents: 13592
diff changeset
349 rc_addclass(&conn->rates, &rc);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
350 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
351
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
352 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
353 * Then the members of each class.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
354 */
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
355 for (i = 0; i < numclasses; i++) {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
356 guint16 classid, count;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
357 struct rateclass *rc;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
358 int j;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
359
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
360 classid = byte_stream_get16(bs);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
361 count = byte_stream_get16(bs);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
362
13609
5796551db930 [gaim-migrate @ 15995]
Mark Doliner <mark@kingant.net>
parents: 13592
diff changeset
363 rc = rc_findclass(&conn->rates, classid);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
364
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
365 for (j = 0; j < count; j++) {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
366 guint16 group, subtype;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
367
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
368 group = byte_stream_get16(bs);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
369 subtype = byte_stream_get16(bs);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
370
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
371 if (rc)
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
372 rc_addpair(rc, group, subtype);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
373 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
374 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
375
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
376 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
377 * We don't pass the rate information up to the client, as it really
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
378 * doesn't care. The information is stored in the connection, however
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
379 * so that we can do more fun stuff later (not really).
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
380 */
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
381
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
382 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
383 * Last step in the conn init procedure is to acknowledge that we
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
384 * agree to these draconian limitations.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
385 */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
386 aim_rates_addparam(od, conn);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
387
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
388 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
389 * Finally, tell the client it's ready to go...
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
390 */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
391 if ((userfunc = aim_callhandler(od, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE)))
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
392 userfunc(od, conn, frame);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
393
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
394 return 1;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
395 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
396
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
397 /* Subtype 0x0008 - Add Rate Parameter */
13609
5796551db930 [gaim-migrate @ 15995]
Mark Doliner <mark@kingant.net>
parents: 13592
diff changeset
398 void
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
399 aim_rates_addparam(OscarData *od, FlapConnection *conn)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
400 {
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
401 FlapFrame *frame;
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
402 aim_snacid_t snacid;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
403 struct rateclass *rc;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
404
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
405 frame = flap_frame_new(od, 0x02, 512);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
406
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
407 snacid = aim_cachesnac(od, 0x0001, 0x0008, 0x0000, NULL, 0);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
408 aim_putsnac(&frame->data, 0x0001, 0x0008, 0x0000, snacid);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
409
13609
5796551db930 [gaim-migrate @ 15995]
Mark Doliner <mark@kingant.net>
parents: 13592
diff changeset
410 for (rc = conn->rates; rc; rc = rc->next)
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
411 byte_stream_put16(&frame->data, rc->classid);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
412
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
413 flap_connection_send(conn, frame);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
414 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
415
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
416 /* Subtype 0x0009 - Delete Rate Parameter */
13609
5796551db930 [gaim-migrate @ 15995]
Mark Doliner <mark@kingant.net>
parents: 13592
diff changeset
417 void
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
418 aim_rates_delparam(OscarData *od, FlapConnection *conn)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
419 {
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
420 FlapFrame *frame;
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
421 aim_snacid_t snacid;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
422 struct rateclass *rc;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
423
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
424 frame = flap_frame_new(od, 0x02, 512);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
425
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
426 snacid = aim_cachesnac(od, 0x0001, 0x0009, 0x0000, NULL, 0);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
427 aim_putsnac(&frame->data, 0x0001, 0x0009, 0x0000, snacid);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
428
13609
5796551db930 [gaim-migrate @ 15995]
Mark Doliner <mark@kingant.net>
parents: 13592
diff changeset
429 for (rc = conn->rates; rc; rc = rc->next)
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
430 byte_stream_put16(&frame->data, rc->classid);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
431
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
432 flap_connection_send(conn, frame);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
433 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
434
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
435 /* Subtype 0x000a - Rate Change */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
436 static int
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
437 ratechange(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
438 {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
439 int ret = 0;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
440 aim_rxcallback_t userfunc;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
441 guint16 code, rateclass;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
442 guint32 currentavg, maxavg, windowsize, clear, alert, limit, disconnect;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
443
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
444 code = byte_stream_get16(bs);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
445 rateclass = byte_stream_get16(bs);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
446
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
447 windowsize = byte_stream_get32(bs);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
448 clear = byte_stream_get32(bs);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
449 alert = byte_stream_get32(bs);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
450 limit = byte_stream_get32(bs);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
451 disconnect = byte_stream_get32(bs);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
452 currentavg = byte_stream_get32(bs);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
453 maxavg = byte_stream_get32(bs);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
454
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
455 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
456 ret = userfunc(od, conn, frame, code, rateclass, windowsize, clear, alert, limit, disconnect, currentavg, maxavg);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
457
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
458 return ret;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
459 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
460
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
461 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
462 * How Migrations work.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
463 *
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
464 * The server sends a Server Pause message, which the client should respond to
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
465 * with a Server Pause Ack, which contains the families it needs on this
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
466 * connection. The server will send a Migration Notice with an IP address, and
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
467 * then disconnect. Next the client should open the connection and send the
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
468 * cookie. Repeat the normal login process and pretend this never happened.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
469 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
470 * The Server Pause contains no data.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
471 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
472 */
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
473
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
474 /* Subtype 0x000b - Service Pause */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
475 static int
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
476 serverpause(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
477 {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
478 int ret = 0;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
479 aim_rxcallback_t userfunc;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
480
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
481 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
482 ret = userfunc(od, conn, frame);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
483
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
484 return ret;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
485 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
486
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
487 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
488 * Subtype 0x000c - Service Pause Acknowledgement
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
489 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
490 * It is rather important that aim_sendpauseack() gets called for the exact
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
491 * same connection that the Server Pause callback was called for, since
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
492 * libfaim extracts the data for the SNAC from the connection structure.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
493 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
494 * Of course, if you don't do that, more bad things happen than just what
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
495 * libfaim can cause.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
496 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
497 */
13609
5796551db930 [gaim-migrate @ 15995]
Mark Doliner <mark@kingant.net>
parents: 13592
diff changeset
498 void
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
499 aim_sendpauseack(OscarData *od, FlapConnection *conn)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
500 {
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
501 FlapFrame *frame;
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
502 aim_snacid_t snacid;
13611
7f91efd5af77 [gaim-migrate @ 15997]
Mark Doliner <mark@kingant.net>
parents: 13609
diff changeset
503 GList *cur;
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
504
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
505 frame = flap_frame_new(od, 0x02, 1024);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
506
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
507 snacid = aim_cachesnac(od, 0x0001, 0x000c, 0x0000, NULL, 0);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
508 aim_putsnac(&frame->data, 0x0001, 0x000c, 0x0000, snacid);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
509
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
510 /*
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
511 * This list should have all the groups that the original
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
512 * Host Online / Server Ready said this host supports. And
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
513 * we want them all back after the migration.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
514 */
13611
7f91efd5af77 [gaim-migrate @ 15997]
Mark Doliner <mark@kingant.net>
parents: 13609
diff changeset
515 for (cur = conn->groups; cur != NULL; cur = cur->next)
7f91efd5af77 [gaim-migrate @ 15997]
Mark Doliner <mark@kingant.net>
parents: 13609
diff changeset
516 byte_stream_put16(&frame->data, GPOINTER_TO_UINT(cur->data));
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
517
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
518 flap_connection_send(conn, frame);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
519 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
520
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
521 /* Subtype 0x000d - Service Resume */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
522 static int
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
523 serverresume(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
524 {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
525 int ret = 0;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
526 aim_rxcallback_t userfunc;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
527
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
528 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
529 ret = userfunc(od, conn, frame);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
530
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
531 return ret;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
532 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
533
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
534 /* Subtype 0x000e - Request self-info */
13609
5796551db930 [gaim-migrate @ 15995]
Mark Doliner <mark@kingant.net>
parents: 13592
diff changeset
535 void
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
536 aim_reqpersonalinfo(OscarData *od, FlapConnection *conn)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
537 {
13609
5796551db930 [gaim-migrate @ 15995]
Mark Doliner <mark@kingant.net>
parents: 13592
diff changeset
538 aim_genericreq_n_snacid(od, conn, 0x0001, 0x000e);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
539 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
540
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
541 /* Subtype 0x000f - Self User Info */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
542 static int
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
543 selfinfo(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
544 {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
545 int ret = 0;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
546 aim_rxcallback_t userfunc;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
547 aim_userinfo_t userinfo;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
548
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
549 aim_info_extract(od, bs, &userinfo);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
550
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
551 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
552 ret = userfunc(od, conn, frame, &userinfo);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
553
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
554 aim_info_free(&userinfo);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
555
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
556 return ret;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
557 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
558
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
559 /* Subtype 0x0010 - Evil Notification */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
560 static int
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
561 evilnotify(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
562 {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
563 int ret = 0;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
564 aim_rxcallback_t userfunc;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
565 guint16 newevil;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
566 aim_userinfo_t userinfo;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
567
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
568 memset(&userinfo, 0, sizeof(aim_userinfo_t));
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
569
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
570 newevil = byte_stream_get16(bs);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
571
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
572 if (byte_stream_empty(bs))
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
573 aim_info_extract(od, bs, &userinfo);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
574
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
575 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
576 ret = userfunc(od, conn, frame, newevil, &userinfo);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
577
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
578 aim_info_free(&userinfo);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
579
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
580 return ret;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
581 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
582
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
583 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
584 * Subtype 0x0011 - Idle Notification
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
585 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
586 * Should set your current idle time in seconds. Note that this should
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
587 * never be called consecutively with a non-zero idle time. That makes
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
588 * OSCAR do funny things. Instead, just set it once you go idle, and then
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
589 * call it again with zero when you're back.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
590 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
591 */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
592 int
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
593 aim_srv_setidle(OscarData *od, guint32 idletime)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
594 {
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
595 FlapConnection *conn;
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
596
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
597 if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_BOS)))
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
598 return -EINVAL;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
599
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
600 return aim_genericreq_l(od, conn, 0x0001, 0x0011, &idletime);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
601 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
602
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
603 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
604 * Subtype 0x0012 - Service Migrate
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
605 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
606 * This is the final SNAC sent on the original connection during a migration.
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
607 * It contains the IP and cookie used to connect to the new server, and
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
608 * optionally a list of the SNAC groups being migrated.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
609 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
610 */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
611 static int
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
612 migrate(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
613 {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
614 aim_rxcallback_t userfunc;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
615 int ret = 0;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
616 guint16 groupcount, i;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
617 aim_tlvlist_t *tl;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
618 char *ip = NULL;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
619 aim_tlv_t *cktlv;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
620
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
621 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
622 * Apparently there's some fun stuff that can happen right here. The
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
623 * migration can actually be quite selective about what groups it
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
624 * moves to the new server. When not all the groups for a connection
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
625 * are migrated, or they are all migrated but some groups are moved
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
626 * to a different server than others, it is called a bifurcated
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
627 * migration.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
628 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
629 * Let's play dumb and not support that.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
630 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
631 */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
632 groupcount = byte_stream_get16(bs);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
633 for (i = 0; i < groupcount; i++) {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
634 guint16 group;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
635
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
636 group = byte_stream_get16(bs);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
637
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
638 gaim_debug_misc("oscar", "bifurcated migration unsupported -- group 0x%04x\n", group);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
639 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
640
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
641 tl = aim_tlvlist_read(bs);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
642
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
643 if (aim_tlv_gettlv(tl, 0x0005, 1))
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
644 ip = aim_tlv_getstr(tl, 0x0005, 1);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
645
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
646 cktlv = aim_tlv_gettlv(tl, 0x0006, 1);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
647
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
648 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
649 ret = userfunc(od, conn, frame, ip, cktlv ? cktlv->value : NULL);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
650
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
651 aim_tlvlist_free(&tl);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
652 free(ip);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
653
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
654 return ret;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
655 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
656
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
657 /* Subtype 0x0013 - Message of the Day */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
658 static int
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
659 motd(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
660 {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
661 aim_rxcallback_t userfunc;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
662 char *msg = NULL;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
663 int ret = 0;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
664 aim_tlvlist_t *tlvlist;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
665 guint16 id;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
666
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
667 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
668 * Code.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
669 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
670 * Valid values:
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
671 * 1 Mandatory upgrade
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
672 * 2 Advisory upgrade
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
673 * 3 System bulletin
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
674 * 4 Nothing's wrong ("top o the world" -- normal)
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
675 * 5 Lets-break-something.
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
676 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
677 */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
678 id = byte_stream_get16(bs);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
679
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
680 /*
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
681 * TLVs follow
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
682 */
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
683 tlvlist = aim_tlvlist_read(bs);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
684
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
685 msg = aim_tlv_getstr(tlvlist, 0x000b, 1);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
686
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
687 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
688 ret = userfunc(od, conn, frame, id, msg);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
689
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
690 free(msg);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
691
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
692 aim_tlvlist_free(&tlvlist);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
693
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
694 return ret;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
695 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
696
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
697 /*
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
698 * Subtype 0x0014 - Set privacy flags
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
699 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
700 * Normally 0x03.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
701 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
702 * Bit 1: Allows other AIM users to see how long you've been idle.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
703 * Bit 2: Allows other AIM users to see how long you've been a member.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
704 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
705 */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
706 int
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
707 aim_bos_setprivacyflags(OscarData *od, FlapConnection *conn, guint32 flags)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
708 {
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
709 return aim_genericreq_l(od, conn, 0x0001, 0x0014, &flags);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
710 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
711
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
712 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
713 * Subtype 0x0016 - No-op
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
714 *
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
715 * WinAIM sends these every 4min or so to keep the connection alive. Its not
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
716 * really necessary.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
717 *
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
718 * Wha? No? Since when? I think WinAIM sends an empty channel 5
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
719 * FLAP as a no-op...
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
720 */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
721 int
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
722 aim_nop(OscarData *od, FlapConnection *conn)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
723 {
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
724 return aim_genericreq_n(od, conn, 0x0001, 0x0016);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
725 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
726
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
727 /*
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
728 * Subtype 0x0017 - Set client versions
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
729 *
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
730 * If you've seen the clientonline/clientready SNAC you're probably
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
731 * wondering what the point of this one is. And that point seems to be
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
732 * that the versions in the client online SNAC are sent too late for the
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
733 * server to be able to use them to change the protocol for the earlier
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
734 * login packets (client versions are sent right after Host Online is
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
735 * received, but client online versions aren't sent until quite a bit later).
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
736 * We can see them already making use of this by changing the format of
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
737 * the rate information based on what version of group 1 we advertise here.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
738 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
739 */
13609
5796551db930 [gaim-migrate @ 15995]
Mark Doliner <mark@kingant.net>
parents: 13592
diff changeset
740 void
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
741 aim_setversions(OscarData *od, FlapConnection *conn)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
742 {
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
743 FlapFrame *frame;
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
744 aim_snacid_t snacid;
13611
7f91efd5af77 [gaim-migrate @ 15997]
Mark Doliner <mark@kingant.net>
parents: 13609
diff changeset
745 GList *cur;
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
746
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
747 frame = flap_frame_new(od, 0x02, 1152);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
748
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
749 snacid = aim_cachesnac(od, 0x0001, 0x0017, 0x0000, NULL, 0);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
750 aim_putsnac(&frame->data, 0x0001, 0x0017, 0x0000, snacid);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
751
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
752 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
753 * Send only the versions that the server cares about (that it
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
754 * marked as supporting in the server ready SNAC).
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
755 */
13611
7f91efd5af77 [gaim-migrate @ 15997]
Mark Doliner <mark@kingant.net>
parents: 13609
diff changeset
756 for (cur = conn->groups; cur != NULL; cur = cur->next)
7f91efd5af77 [gaim-migrate @ 15997]
Mark Doliner <mark@kingant.net>
parents: 13609
diff changeset
757 {
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
758 aim_module_t *mod;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
759
13611
7f91efd5af77 [gaim-migrate @ 15997]
Mark Doliner <mark@kingant.net>
parents: 13609
diff changeset
760 if ((mod = aim__findmodulebygroup(od, GPOINTER_TO_UINT(cur->data))))
7f91efd5af77 [gaim-migrate @ 15997]
Mark Doliner <mark@kingant.net>
parents: 13609
diff changeset
761 {
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
762 byte_stream_put16(&frame->data, mod->family);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
763 byte_stream_put16(&frame->data, mod->version);
13611
7f91efd5af77 [gaim-migrate @ 15997]
Mark Doliner <mark@kingant.net>
parents: 13609
diff changeset
764 }
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
765 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
766
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
767 flap_connection_send(conn, frame);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
768 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
769
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
770 /* Subtype 0x0018 - Host versions */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
771 static int
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
772 hostversions(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
773 {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
774 int vercount;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
775 guint8 *versions;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
776
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
777 /* This is frivolous. (Thank you SmarterChild.) */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
778 vercount = byte_stream_empty(bs)/4;
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
779 versions = byte_stream_getraw(bs, byte_stream_empty(bs));
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
780 free(versions);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
781
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
782 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
783 * Now request rates.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
784 */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
785 aim_reqrates(od, conn);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
786
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
787 return 1;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
788 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
789
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
790 /*
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
791 * Subtype 0x001e - Set various account settings (mostly ICQ related).
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
792 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
793 * These settings are transient, not server-stored (i.e. they only
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
794 * apply to this session, and must be re-set the next time you sign
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
795 * on).
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
796 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
797 * You can set your ICQ status (available, away, do not disturb,
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
798 * etc.), or whether your IP address should be hidden or not, or
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
799 * if your status is visible on ICQ web sites, and you can set
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
800 * your IP address info and what not.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
801 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
802 * These are the same TLVs seen in user info. You can
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
803 * also set 0x0008 and 0x000c.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
804 */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
805 int
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
806 aim_setextstatus(OscarData *od, guint32 status)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
807 {
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
808 FlapConnection *conn;
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
809 FlapFrame *frame;
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
810 aim_snacid_t snacid;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
811 aim_tlvlist_t *tl = NULL;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
812 guint32 data;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
813
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
814 if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_ICBM)))
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
815 return -EINVAL;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
816
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
817 data = AIM_ICQ_STATE_HIDEIP | AIM_ICQ_STATE_DIRECTREQUIREAUTH | status;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
818
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
819 frame = flap_frame_new(od, 0x02, 10 + 8);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
820
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
821 snacid = aim_cachesnac(od, 0x0001, 0x001e, 0x0000, NULL, 0);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
822 aim_putsnac(&frame->data, 0x0001, 0x001e, 0x0000, snacid);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
823
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
824 aim_tlvlist_add_32(&tl, 0x0006, data);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
825 #if 0
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
826 aim_tlvlist_add_raw(&tl, 0x000c, 0x0025, chunk_of_x25_bytes_with_ip_address_etc);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
827 aim_tlvlist_add_raw(&tl, 0x0011, 0x0005, unknown 0x01 61 10 f6 41);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
828 aim_tlvlist_add_16(&tl, 0x0012, unknown 0x00 00);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
829 #endif
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
830 aim_tlvlist_write(&frame->data, &tl);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
831 aim_tlvlist_free(&tl);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
832
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
833 flap_connection_send(conn, frame);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
834
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
835 return 0;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
836 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
837
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
838 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
839 * Subtype 0x001e - Extended Status.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
840 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
841 * Sets your "available" message. This is currently only supported by iChat
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
842 * and Gaim.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
843 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
844 * These are the same TLVs seen in user info. You can
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
845 * also set 0x0008 and 0x000c.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
846 */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
847 int
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
848 aim_srv_setstatusmsg(OscarData *od, const char *msg)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
849 {
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
850 FlapConnection *conn;
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
851 FlapFrame *frame;
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
852 aim_snacid_t snacid;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
853
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
854 if (!od || !(conn = flap_connection_findbygroup(od, 0x0004)))
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
855 return -EINVAL;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
856
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
857 if ((msg != NULL) && *msg != '\0') {
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
858 frame = flap_frame_new(od, 0x02, 10 + 4 + strlen(msg) + 8);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
859
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
860 snacid = aim_cachesnac(od, 0x0001, 0x001e, 0x0000, NULL, 0);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
861 aim_putsnac(&frame->data, 0x0001, 0x001e, 0x0000, snacid);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
862
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
863 byte_stream_put16(&frame->data, 0x001d); /* userinfo TLV type */
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
864 byte_stream_put16(&frame->data, strlen(msg)+8); /* total length of userinfo TLV data */
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
865 byte_stream_put16(&frame->data, 0x0002);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
866 byte_stream_put8(&frame->data, 0x04);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
867 byte_stream_put8(&frame->data, strlen(msg)+4);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
868 byte_stream_put16(&frame->data, strlen(msg));
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
869 byte_stream_putstr(&frame->data, msg);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
870 byte_stream_put16(&frame->data, 0x0000);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
871 } else {
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
872 frame = flap_frame_new(od, 0x02, 10 + 4 + 8);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
873
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
874 snacid = aim_cachesnac(od, 0x0001, 0x001e, 0x0000, NULL, 0);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
875 aim_putsnac(&frame->data, 0x0001, 0x001e, 0x0000, snacid);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
876
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
877 byte_stream_put16(&frame->data, 0x001d);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
878 byte_stream_put16(&frame->data, 0x0008);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
879 byte_stream_put16(&frame->data, 0x0002);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
880 byte_stream_put16(&frame->data, 0x0404);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
881 byte_stream_put16(&frame->data, 0x0000);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
882 byte_stream_put16(&frame->data, 0x0000);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
883 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
884
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
885 flap_connection_send(conn, frame);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
886
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
887 return 0;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
888 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
889
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
890 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
891 * Starting this past week (26 Mar 2001, say), AOL has started sending
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
892 * this nice little extra SNAC. AFAIK, it has never been used until now.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
893 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
894 * The request contains eight bytes. The first four are an offset, the
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
895 * second four are a length.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
896 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
897 * The offset is an offset into aim.exe when it is mapped during execution
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
898 * on Win32. So far, AOL has only been requesting bytes in static regions
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
899 * of memory. (I won't put it past them to start requesting data in
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
900 * less static regions -- regions that are initialized at run time, but still
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
901 * before the client receives this request.)
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
902 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
903 * When the client receives the request, it adds it to the current ds
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
904 * (0x00400000) and dereferences it, copying the data into a buffer which
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
905 * it then runs directly through the MD5 hasher. The 16 byte output of
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
906 * the hash is then sent back to the server.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
907 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
908 * If the client does not send any data back, or the data does not match
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
909 * the data that the specific client should have, the client will get the
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
910 * following message from "AOL Instant Messenger":
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
911 * "You have been disconnected from the AOL Instant Message Service (SM)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
912 * for accessing the AOL network using unauthorized software. You can
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
913 * download a FREE, fully featured, and authorized client, here
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
914 * http://www.aol.com/aim/download2.html"
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
915 * The connection is then closed, receiving disconnect code 1, URL
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
916 * http://www.aim.aol.com/errors/USER_LOGGED_OFF_NEW_LOGIN.html.
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
917 *
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
918 * Note, however, that numerous inconsistencies can cause the above error,
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
919 * not just sending back a bad hash. Do not immediatly suspect this code
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
920 * if you get disconnected. AOL and the open/free software community have
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
921 * played this game for a couple years now, generating the above message
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
922 * on numerous ocassions.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
923 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
924 * Anyway, neener. We win again.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
925 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
926 */
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
927 /* Subtype 0x001f - Client verification */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
928 static int
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
929 memrequest(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
930 {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
931 int ret = 0;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
932 aim_rxcallback_t userfunc;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
933 guint32 offset, len;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
934 aim_tlvlist_t *list;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
935 char *modname;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
936
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
937 offset = byte_stream_get32(bs);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
938 len = byte_stream_get32(bs);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
939 list = aim_tlvlist_read(bs);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
940
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
941 modname = aim_tlv_getstr(list, 0x0001, 1);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
942
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
943 gaim_debug_info("oscar", "Got memory request for data at 0x%08lx (%d bytes) of requested %s\n", offset, len, modname ? modname : "aim.exe");
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
944
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
945 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
946 ret = userfunc(od, conn, frame, offset, len, modname);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
947
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
948 free(modname);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
949 aim_tlvlist_free(&list);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
950
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
951 return ret;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
952 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
953
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
954 /* Subtype 0x0020 - Client verification reply */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
955 int
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
956 aim_sendmemblock(OscarData *od, FlapConnection *conn, guint32 offset, guint32 len, const guint8 *buf, guint8 flag)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
957 {
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
958 FlapFrame *frame;
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
959 aim_snacid_t snacid;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
960
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
961 if (!od || !conn)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
962 return -EINVAL;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
963
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
964 frame = flap_frame_new(od, 0x02, 10+2+16);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
965
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
966 snacid = aim_cachesnac(od, 0x0001, 0x0020, 0x0000, NULL, 0);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
967
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
968 aim_putsnac(&frame->data, 0x0001, 0x0020, 0x0000, snacid);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
969 byte_stream_put16(&frame->data, 0x0010); /* md5 is always 16 bytes */
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
970
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
971 if ((flag == AIM_SENDMEMBLOCK_FLAG_ISHASH) && buf && (len == 0x10)) { /* we're getting a hash */
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
972
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
973 byte_stream_putraw(&frame->data, buf, 0x10);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
974
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
975 } else if (buf && (len > 0)) { /* use input buffer */
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
976 GaimCipher *cipher;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
977 GaimCipherContext *context;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
978 guchar digest[16];
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
979
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
980 cipher = gaim_ciphers_find_cipher("md5");
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
981
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
982 context = gaim_cipher_context_new(cipher, NULL);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
983 gaim_cipher_context_append(context, buf, len);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
984 gaim_cipher_context_digest(context, 16, digest, NULL);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
985 gaim_cipher_context_destroy(context);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
986
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
987 byte_stream_putraw(&frame->data, digest, 0x10);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
988
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
989 } else if (len == 0) { /* no length, just hash NULL (buf is optional) */
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
990 GaimCipher *cipher;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
991 GaimCipherContext *context;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
992 guchar digest[16];
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
993 guint8 nil = '\0';
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
994
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
995 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
996 * I'm not sure if we really need the empty append with the
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
997 * new MD5 functions, so I'll leave it in, just in case.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
998 */
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
999 cipher = gaim_ciphers_find_cipher("md5");
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1000
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1001 context = gaim_cipher_context_new(cipher, NULL);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1002 gaim_cipher_context_append(context, &nil, 0);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1003 gaim_cipher_context_digest(context, 16, digest, NULL);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1004 gaim_cipher_context_destroy(context);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1005
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1006 byte_stream_putraw(&frame->data, digest, 0x10);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1007
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1008 } else {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1009
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1010 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1011 * This data is correct for AIM 3.5.1670.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1012 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1013 * Using these blocks is as close to "legal" as you can get
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1014 * without using an AIM binary.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1015 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1016 */
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1017 if ((offset == 0x03ffffff) && (len == 0x03ffffff)) {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1018
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1019 #if 1 /* with "AnrbnrAqhfzcd" */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1020 byte_stream_put32(&frame->data, 0x44a95d26);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1021 byte_stream_put32(&frame->data, 0xd2490423);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1022 byte_stream_put32(&frame->data, 0x93b8821f);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1023 byte_stream_put32(&frame->data, 0x51c54b01);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1024 #else /* no filename */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1025 byte_stream_put32(&frame->data, 0x1df8cbae);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1026 byte_stream_put32(&frame->data, 0x5523b839);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1027 byte_stream_put32(&frame->data, 0xa0e10db3);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1028 byte_stream_put32(&frame->data, 0xa46d3b39);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1029 #endif
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1030
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1031 } else if ((offset == 0x00001000) && (len == 0x00000000)) {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1032
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1033 byte_stream_put32(&frame->data, 0xd41d8cd9);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1034 byte_stream_put32(&frame->data, 0x8f00b204);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1035 byte_stream_put32(&frame->data, 0xe9800998);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1036 byte_stream_put32(&frame->data, 0xecf8427e);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1037
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1038 } else
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1039 gaim_debug_warning("oscar", "sendmemblock: unknown hash request\n");
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1040
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1041 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1042
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1043 flap_connection_send(conn, frame);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1044
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1045 return 0;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1046 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1047
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1048 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1049 * Subtype 0x0021 - Receive our extended status
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1050 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1051 * This is used for iChat's "available" messages, and maybe ICQ extended
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1052 * status messages? It's also used to tell the client whether or not it
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1053 * needs to upload an SSI buddy icon... who engineers this stuff, anyway?
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1054 */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1055 static int
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1056 aim_parse_extstatus(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1057 {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1058 int ret = 0;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1059 aim_rxcallback_t userfunc;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1060 guint16 type;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1061 guint8 flags, length;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1062
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1063 type = byte_stream_get16(bs);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1064 flags = byte_stream_get8(bs);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1065 length = byte_stream_get8(bs);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1066
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1067 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) {
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1068 switch (type) {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1069 case 0x0000:
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1070 case 0x0001: { /* buddy icon checksum */
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1071 /* not sure what the difference between 1 and 0 is */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1072 guint8 *md5 = byte_stream_getraw(bs, length);
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1073 ret = userfunc(od, conn, frame, type, flags, length, md5);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1074 free(md5);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1075 } break;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1076 case 0x0002: { /* available message */
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1077 /* there is a second length that is just for the message */
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1078 char *msg = byte_stream_getstr(bs, byte_stream_get16(bs));
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1079 ret = userfunc(od, conn, frame, msg);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1080 free(msg);
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1081 } break;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1082 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1083 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1084
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1085 return ret;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1086 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1087
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1088 static int
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1089 snachandler(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1090 {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1091 if (snac->subtype == 0x0003)
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1092 return hostonline(od, conn, mod, frame, snac, bs);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1093 else if (snac->subtype == 0x0005)
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1094 return redirect(od, conn, mod, frame, snac, bs);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1095 else if (snac->subtype == 0x0007)
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1096 return rateresp(od, conn, mod, frame, snac, bs);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1097 else if (snac->subtype == 0x000a)
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1098 return ratechange(od, conn, mod, frame, snac, bs);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1099 else if (snac->subtype == 0x000b)
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1100 return serverpause(od, conn, mod, frame, snac, bs);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1101 else if (snac->subtype == 0x000d)
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1102 return serverresume(od, conn, mod, frame, snac, bs);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1103 else if (snac->subtype == 0x000f)
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1104 return selfinfo(od, conn, mod, frame, snac, bs);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1105 else if (snac->subtype == 0x0010)
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1106 return evilnotify(od, conn, mod, frame, snac, bs);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1107 else if (snac->subtype == 0x0012)
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1108 return migrate(od, conn, mod, frame, snac, bs);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1109 else if (snac->subtype == 0x0013)
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1110 return motd(od, conn, mod, frame, snac, bs);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1111 else if (snac->subtype == 0x0018)
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1112 return hostversions(od, conn, mod, frame, snac, bs);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1113 else if (snac->subtype == 0x001f)
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1114 return memrequest(od, conn, mod, frame, snac, bs);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1115 else if (snac->subtype == 0x0021)
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1116 return aim_parse_extstatus(od, conn, mod, frame, snac, bs);
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1117
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1118 return 0;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1119 }
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1120
13592
6519aeb66b31 [gaim-migrate @ 15978]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
1121 int service_modfirst(OscarData *od, aim_module_t *mod)
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1122 {
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1123 mod->family = 0x0001;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1124 mod->version = 0x0003;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1125 mod->toolid = 0x0110;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1126 mod->toolversion = 0x0629;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1127 mod->flags = 0;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1128 strncpy(mod->name, "oservice", sizeof(mod->name));
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1129 mod->snachandler = snachandler;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1130
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1131 return 0;
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1132 }