2 * Purple's oscar protocol plugin
3 * This file is the legal property of its developers.
4 * Please see the AUTHORS file distributed alongside this file.
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 * Random stuff. Basically just a few functions for sending
23 * simple SNACs, and then the generic error handler.
29 * Generic routine for sending commands.
31 * I know I can do this in a smarter way...but I'm not thinking straight
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.
40 aim_genericreq_n(OscarData
*od
, FlapConnection
*conn
, guint16 family
, guint16 subtype
)
42 aim_snacid_t snacid
= 0x00000000;
44 flap_connection_send_snac(od
, conn
, family
, subtype
, snacid
, NULL
);
48 aim_genericreq_n_snacid(OscarData
*od
, FlapConnection
*conn
, guint16 family
, guint16 subtype
)
52 snacid
= aim_cachesnac(od
, family
, subtype
, 0x0000, NULL
, 0);
54 flap_connection_send_snac(od
, conn
, family
, subtype
, snacid
, NULL
);
58 aim_genericreq_l(OscarData
*od
, FlapConnection
*conn
, guint16 family
, guint16 subtype
, guint32
*longdata
)
65 aim_genericreq_n(od
, conn
, family
, subtype
);
69 byte_stream_new(&bs
, 4);
71 snacid
= aim_cachesnac(od
, family
, subtype
, 0x0000, NULL
, 0);
73 byte_stream_put32(&bs
, *longdata
);
75 flap_connection_send_snac(od
, conn
, family
, subtype
, snacid
, &bs
);
77 byte_stream_destroy(&bs
);
81 * Should be generic enough to handle the errors for all groups.
85 generror(OscarData
*od
, FlapConnection
*conn
, aim_module_t
*mod
, FlapFrame
*frame
, aim_modsnac_t
*snac
, ByteStream
*bs
)
89 aim_rxcallback_t userfunc
;
92 snac2
= aim_remsnac(od
, snac
->id
);
94 if (byte_stream_bytes_left(bs
))
95 error
= byte_stream_get16(bs
);
97 if ((userfunc
= aim_callhandler(od
, snac
->family
, snac
->subtype
)))
98 ret
= userfunc(od
, conn
, frame
, error
, snac2
? snac2
->data
: NULL
);
109 snachandler(OscarData
*od
, FlapConnection
*conn
, aim_module_t
*mod
, FlapFrame
*frame
, aim_modsnac_t
*snac
, ByteStream
*bs
)
111 if (snac
->subtype
== 0x0001)
112 return generror(od
, conn
, mod
, frame
, snac
, bs
);
113 else if ((snac
->family
== 0xffff) && (snac
->subtype
== 0xffff)) {
114 aim_rxcallback_t userfunc
;
116 if ((userfunc
= aim_callhandler(od
, snac
->family
, snac
->subtype
)))
117 return userfunc(od
, conn
, frame
);
124 misc_modfirst(OscarData
*od
, aim_module_t
*mod
)
126 mod
->family
= 0xffff;
127 mod
->version
= 0x0000;
128 mod
->flags
= AIM_MODFLAG_MULTIFAMILY
;
129 strncpy(mod
->name
, "misc", sizeof(mod
->name
));
130 mod
->snachandler
= snachandler
;