[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 | */ |
---|
| 13 | static 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 | return 0; |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | static int rights(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
---|
| 27 | { |
---|
| 28 | aim_rxcallback_t userfunc; |
---|
| 29 | aim_tlvlist_t *tlvlist; |
---|
| 30 | guint16 maxbuddies = 0, maxwatchers = 0; |
---|
| 31 | int ret = 0; |
---|
| 32 | |
---|
| 33 | /* |
---|
| 34 | * TLVs follow |
---|
| 35 | */ |
---|
| 36 | tlvlist = aim_readtlvchain(bs); |
---|
| 37 | |
---|
| 38 | /* |
---|
| 39 | * TLV type 0x0001: Maximum number of buddies. |
---|
| 40 | */ |
---|
| 41 | if (aim_gettlv(tlvlist, 0x0001, 1)) |
---|
| 42 | maxbuddies = aim_gettlv16(tlvlist, 0x0001, 1); |
---|
| 43 | |
---|
| 44 | /* |
---|
| 45 | * TLV type 0x0002: Maximum number of watchers. |
---|
| 46 | * |
---|
| 47 | * Watchers are other users who have you on their buddy |
---|
| 48 | * list. (This is called the "reverse list" by a certain |
---|
| 49 | * other IM protocol.) |
---|
| 50 | * |
---|
| 51 | */ |
---|
| 52 | if (aim_gettlv(tlvlist, 0x0002, 1)) |
---|
| 53 | maxwatchers = aim_gettlv16(tlvlist, 0x0002, 1); |
---|
| 54 | |
---|
| 55 | /* |
---|
| 56 | * TLV type 0x0003: Unknown. |
---|
| 57 | * |
---|
| 58 | * ICQ only? |
---|
| 59 | */ |
---|
| 60 | |
---|
| 61 | if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
---|
| 62 | ret = userfunc(sess, rx, maxbuddies, maxwatchers); |
---|
| 63 | |
---|
| 64 | aim_freetlvchain(&tlvlist); |
---|
| 65 | |
---|
| 66 | return ret; |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
---|
| 70 | { |
---|
| 71 | |
---|
| 72 | if (snac->subtype == 0x0003) |
---|
| 73 | return rights(sess, mod, rx, snac, bs); |
---|
| 74 | else if ((snac->subtype == 0x000b) || (snac->subtype == 0x000c)) |
---|
| 75 | return buddychange(sess, mod, rx, snac, bs); |
---|
| 76 | |
---|
| 77 | return 0; |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | int buddylist_modfirst(aim_session_t *sess, aim_module_t *mod) |
---|
| 81 | { |
---|
| 82 | |
---|
| 83 | mod->family = 0x0003; |
---|
| 84 | mod->version = 0x0001; |
---|
| 85 | mod->toolid = 0x0110; |
---|
| 86 | mod->toolversion = 0x0629; |
---|
| 87 | mod->flags = 0; |
---|
| 88 | strncpy(mod->name, "buddylist", sizeof(mod->name)); |
---|
| 89 | mod->snachandler = snachandler; |
---|
| 90 | |
---|
| 91 | return 0; |
---|
| 92 | } |
---|