Mercurial > pidgin
annotate src/protocols/oscar/misc.c @ 13842:a9ff4499d9ce
[gaim-migrate @ 16295]
Hopefully improve the typing notification code so it's a lot easier
to understand. This also creates a distinction between the signals
emitted when receiving GAIM_TYPED and GAIM_NOT_TYPING messages
(by adding a gaim-typed signal). And the gaim-not-typing signal
should work in all cases.
Most of this is stuff I changed last week during work, thanks to
Meebo
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 20 Jun 2006 08:17:49 +0000 |
parents | 5796551db930 |
children |
rev | line source |
---|---|
13234 | 1 /* |
2 * Gaim's oscar protocol plugin | |
3 * This file is the legal property of its developers. | |
4 * Please see the AUTHORS file distributed alongside this file. | |
5 * | |
6 * This library is free software; you can redistribute it and/or | |
7 * modify it under the terms of the GNU Lesser General Public | |
8 * License as published by the Free Software Foundation; either | |
9 * version 2 of the License, or (at your option) any later version. | |
10 * | |
11 * This library is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * Lesser General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU Lesser General Public | |
17 * License along with this library; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 */ | |
20 | |
2086 | 21 /* |
13234 | 22 * Random stuff. Basically just a few functions for sending |
3952 | 23 * simple SNACs, and then the generic error handler. |
2086 | 24 */ |
25 | |
13234 | 26 #include "oscar.h" |
2086 | 27 |
28 /* | |
29 * Generic routine for sending commands. | |
30 * | |
31 * I know I can do this in a smarter way...but I'm not thinking straight | |
32 * right now... | |
33 * | |
34 * I had one big function that handled all three cases, but then it broke | |
35 * and I split it up into three. But then I fixed it. I just never went | |
36 * back to the single. I don't see any advantage to doing it either way. | |
37 * | |
38 */ | |
13592 | 39 int |
40 aim_genericreq_n(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype) | |
2086 | 41 { |
13592 | 42 FlapFrame *frame; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
43 aim_snacid_t snacid = 0x00000000; |
2086 | 44 |
13592 | 45 frame = flap_frame_new(od, 0x02, 10); |
2086 | 46 |
13592 | 47 aim_putsnac(&frame->data, family, subtype, 0x0000, snacid); |
2086 | 48 |
13592 | 49 flap_connection_send(conn, frame); |
2086 | 50 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
51 return 0; |
2086 | 52 } |
53 | |
13609 | 54 void |
13592 | 55 aim_genericreq_n_snacid(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype) |
2086 | 56 { |
13592 | 57 FlapFrame *frame; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
58 aim_snacid_t snacid; |
2086 | 59 |
13592 | 60 frame = flap_frame_new(od, 0x02, 10); |
2086 | 61 |
13592 | 62 snacid = aim_cachesnac(od, family, subtype, 0x0000, NULL, 0); |
63 aim_putsnac(&frame->data, family, subtype, 0x0000, snacid); | |
2086 | 64 |
13592 | 65 flap_connection_send(conn, frame); |
2086 | 66 } |
67 | |
13592 | 68 int |
69 aim_genericreq_l(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype, guint32 *longdata) | |
2086 | 70 { |
13592 | 71 FlapFrame *frame; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
72 aim_snacid_t snacid; |
2086 | 73 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
74 if (!longdata) |
13592 | 75 return aim_genericreq_n(od, conn, family, subtype); |
2086 | 76 |
13592 | 77 frame = flap_frame_new(od, 0x02, 10+4); |
2086 | 78 |
13592 | 79 snacid = aim_cachesnac(od, family, subtype, 0x0000, NULL, 0); |
2086 | 80 |
13592 | 81 aim_putsnac(&frame->data, family, subtype, 0x0000, snacid); |
82 byte_stream_put32(&frame->data, *longdata); | |
2086 | 83 |
13592 | 84 flap_connection_send(conn, frame); |
2086 | 85 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
86 return 0; |
2086 | 87 } |
88 | |
13592 | 89 int |
90 aim_genericreq_s(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype, guint16 *shortdata) | |
2086 | 91 { |
13592 | 92 FlapFrame *frame; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
93 aim_snacid_t snacid; |
2086 | 94 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
95 if (!shortdata) |
13592 | 96 return aim_genericreq_n(od, conn, family, subtype); |
2086 | 97 |
13592 | 98 frame = flap_frame_new(od, 0x02, 10+2); |
2086 | 99 |
13592 | 100 snacid = aim_cachesnac(od, family, subtype, 0x0000, NULL, 0); |
2086 | 101 |
13592 | 102 aim_putsnac(&frame->data, family, subtype, 0x0000, snacid); |
103 byte_stream_put16(&frame->data, *shortdata); | |
2086 | 104 |
13592 | 105 flap_connection_send(conn, frame); |
2086 | 106 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
107 return 0; |
2086 | 108 } |
109 | |
110 /* | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2675
diff
changeset
|
111 * Should be generic enough to handle the errors for all groups. |
2086 | 112 * |
113 */ | |
13592 | 114 static int |
115 generror(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) | |
2086 | 116 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
117 int ret = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
118 int error = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
119 aim_rxcallback_t userfunc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
120 aim_snac_t *snac2; |
2086 | 121 |
13592 | 122 snac2 = aim_remsnac(od, snac->id); |
2086 | 123 |
13592 | 124 if (byte_stream_empty(bs)) |
125 error = byte_stream_get16(bs); | |
2086 | 126 |
13592 | 127 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) |
128 ret = userfunc(od, conn, frame, error, snac2 ? snac2->data : NULL); | |
2086 | 129 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
130 if (snac2) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
131 free(snac2->data); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
132 free(snac2); |
2086 | 133 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
134 return ret; |
2086 | 135 } |
136 | |
13592 | 137 static int |
138 snachandler(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) | |
2086 | 139 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
140 if (snac->subtype == 0x0001) |
13592 | 141 return generror(od, conn, mod, frame, snac, bs); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
142 else if ((snac->family == 0xffff) && (snac->subtype == 0xffff)) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
143 aim_rxcallback_t userfunc; |
2086 | 144 |
13592 | 145 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) |
146 return userfunc(od, conn, frame); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
147 } |
2086 | 148 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
149 return 0; |
2086 | 150 } |
151 | |
13592 | 152 int |
153 misc_modfirst(OscarData *od, aim_module_t *mod) | |
2086 | 154 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
155 mod->family = 0xffff; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
156 mod->version = 0x0000; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
157 mod->flags = AIM_MODFLAG_MULTIFAMILY; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
158 strncpy(mod->name, "misc", sizeof(mod->name)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
159 mod->snachandler = snachandler; |
2086 | 160 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
161 return 0; |
2086 | 162 } |