source: protocols/oscar/buddylist.c @ b3ebb3a

Last change on this file since b3ebb3a was 5ebff60, checked in by dequis <dx@…>, at 2015-02-20T22:50:54Z

Reindent everything to K&R style with tabs

Used uncrustify, with the configuration file in ./doc/uncrustify.cfg

Commit author set to "Indent <please@…>" so that it's easier to
skip while doing git blame.

  • Property mode set to 100644
File size: 2.2 KB
RevLine 
[b7d3cc34]1#include <aim.h>
2#include "buddylist.h"
3
4/*
5 * Oncoming Buddy notifications contain a subset of the
6 * user information structure.  Its close enough to run
7 * through aim_extractuserinfo() however.
8 *
9 * Although the offgoing notification contains no information,
10 * it is still in a format parsable by extractuserinfo.
11 *
12 */
13static int buddychange(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
14{
15        aim_userinfo_t userinfo;
16        aim_rxcallback_t userfunc;
17
18        aim_extractuserinfo(sess, bs, &userinfo);
19
[5ebff60]20        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
[b7d3cc34]21                return userfunc(sess, rx, &userinfo);
[5ebff60]22        }
[b7d3cc34]23
24        return 0;
25}
26
27static int rights(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
28{
29        aim_rxcallback_t userfunc;
30        aim_tlvlist_t *tlvlist;
31        guint16 maxbuddies = 0, maxwatchers = 0;
32        int ret = 0;
33
[5ebff60]34        /*
35         * TLVs follow
[b7d3cc34]36         */
37        tlvlist = aim_readtlvchain(bs);
38
39        /*
40         * TLV type 0x0001: Maximum number of buddies.
41         */
[5ebff60]42        if (aim_gettlv(tlvlist, 0x0001, 1)) {
[b7d3cc34]43                maxbuddies = aim_gettlv16(tlvlist, 0x0001, 1);
[5ebff60]44        }
[b7d3cc34]45
46        /*
47         * TLV type 0x0002: Maximum number of watchers.
48         *
49         * Watchers are other users who have you on their buddy
50         * list.  (This is called the "reverse list" by a certain
51         * other IM protocol.)
[5ebff60]52         *
[b7d3cc34]53         */
[5ebff60]54        if (aim_gettlv(tlvlist, 0x0002, 1)) {
[b7d3cc34]55                maxwatchers = aim_gettlv16(tlvlist, 0x0002, 1);
[5ebff60]56        }
[b7d3cc34]57
58        /*
59         * TLV type 0x0003: Unknown.
60         *
61         * ICQ only?
62         */
63
[5ebff60]64        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
[b7d3cc34]65                ret = userfunc(sess, rx, maxbuddies, maxwatchers);
[5ebff60]66        }
[b7d3cc34]67
68        aim_freetlvchain(&tlvlist);
69
[5ebff60]70        return ret;
[b7d3cc34]71}
72
73static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
74{
75
[5ebff60]76        if (snac->subtype == 0x0003) {
[b7d3cc34]77                return rights(sess, mod, rx, snac, bs);
[5ebff60]78        } else if ((snac->subtype == 0x000b) || (snac->subtype == 0x000c)) {
[b7d3cc34]79                return buddychange(sess, mod, rx, snac, bs);
[5ebff60]80        }
[b7d3cc34]81
82        return 0;
83}
84
85int buddylist_modfirst(aim_session_t *sess, aim_module_t *mod)
86{
87
88        mod->family = 0x0003;
89        mod->version = 0x0001;
90        mod->toolid = 0x0110;
91        mod->toolversion = 0x0629;
92        mod->flags = 0;
93        strncpy(mod->name, "buddylist", sizeof(mod->name));
94        mod->snachandler = snachandler;
95
96        return 0;
97}
Note: See TracBrowser for help on using the repository browser.