source: protocols/oscar/buddylist.c @ ad54149

Last change on this file since ad54149 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
Line 
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
20        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
21                return userfunc(sess, rx, &userinfo);
22        }
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
34        /*
35         * TLVs follow
36         */
37        tlvlist = aim_readtlvchain(bs);
38
39        /*
40         * TLV type 0x0001: Maximum number of buddies.
41         */
42        if (aim_gettlv(tlvlist, 0x0001, 1)) {
43                maxbuddies = aim_gettlv16(tlvlist, 0x0001, 1);
44        }
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.)
52         *
53         */
54        if (aim_gettlv(tlvlist, 0x0002, 1)) {
55                maxwatchers = aim_gettlv16(tlvlist, 0x0002, 1);
56        }
57
58        /*
59         * TLV type 0x0003: Unknown.
60         *
61         * ICQ only?
62         */
63
64        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
65                ret = userfunc(sess, rx, maxbuddies, maxwatchers);
66        }
67
68        aim_freetlvchain(&tlvlist);
69
70        return ret;
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
76        if (snac->subtype == 0x0003) {
77                return rights(sess, mod, rx, snac, bs);
78        } else if ((snac->subtype == 0x000b) || (snac->subtype == 0x000c)) {
79                return buddychange(sess, mod, rx, snac, bs);
80        }
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.