[b7d3cc34] | 1 | #include <aim.h> |
---|
| 2 | #include "bos.h" |
---|
| 3 | |
---|
| 4 | /* Request BOS rights (group 9, type 2) */ |
---|
| 5 | int aim_bos_reqrights(aim_session_t *sess, aim_conn_t *conn) |
---|
| 6 | { |
---|
| 7 | return aim_genericreq_n(sess, conn, 0x0009, 0x0002); |
---|
| 8 | } |
---|
| 9 | |
---|
| 10 | /* BOS Rights (group 9, type 3) */ |
---|
| 11 | static int rights(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
---|
| 12 | { |
---|
| 13 | aim_rxcallback_t userfunc; |
---|
| 14 | aim_tlvlist_t *tlvlist; |
---|
| 15 | guint16 maxpermits = 0, maxdenies = 0; |
---|
| 16 | int ret = 0; |
---|
| 17 | |
---|
| 18 | /* |
---|
| 19 | * TLVs follow |
---|
| 20 | */ |
---|
| 21 | tlvlist = aim_readtlvchain(bs); |
---|
| 22 | |
---|
| 23 | /* |
---|
| 24 | * TLV type 0x0001: Maximum number of buddies on permit list. |
---|
| 25 | */ |
---|
| 26 | if (aim_gettlv(tlvlist, 0x0001, 1)) |
---|
| 27 | maxpermits = aim_gettlv16(tlvlist, 0x0001, 1); |
---|
| 28 | |
---|
| 29 | /* |
---|
| 30 | * TLV type 0x0002: Maximum number of buddies on deny list. |
---|
| 31 | */ |
---|
| 32 | if (aim_gettlv(tlvlist, 0x0002, 1)) |
---|
| 33 | maxdenies = aim_gettlv16(tlvlist, 0x0002, 1); |
---|
| 34 | |
---|
| 35 | if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
---|
| 36 | ret = userfunc(sess, rx, maxpermits, maxdenies); |
---|
| 37 | |
---|
| 38 | aim_freetlvchain(&tlvlist); |
---|
| 39 | |
---|
| 40 | return ret; |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | /* |
---|
| 44 | * Set group permisson mask (group 9, type 4) |
---|
| 45 | * |
---|
| 46 | * Normally 0x1f (all classes). |
---|
| 47 | * |
---|
| 48 | * The group permission mask allows you to keep users of a certain |
---|
| 49 | * class or classes from talking to you. The mask should be |
---|
| 50 | * a bitwise OR of all the user classes you want to see you. |
---|
| 51 | * |
---|
| 52 | */ |
---|
| 53 | int aim_bos_setgroupperm(aim_session_t *sess, aim_conn_t *conn, guint32 mask) |
---|
| 54 | { |
---|
| 55 | return aim_genericreq_l(sess, conn, 0x0009, 0x0004, &mask); |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
---|
| 59 | { |
---|
| 60 | |
---|
| 61 | if (snac->subtype == 0x0003) |
---|
| 62 | return rights(sess, mod, rx, snac, bs); |
---|
| 63 | |
---|
| 64 | return 0; |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | int bos_modfirst(aim_session_t *sess, aim_module_t *mod) |
---|
| 68 | { |
---|
| 69 | |
---|
| 70 | mod->family = 0x0009; |
---|
| 71 | mod->version = 0x0001; |
---|
| 72 | mod->toolid = 0x0110; |
---|
| 73 | mod->toolversion = 0x0629; |
---|
| 74 | mod->flags = 0; |
---|
| 75 | strncpy(mod->name, "bos", sizeof(mod->name)); |
---|
| 76 | mod->snachandler = snachandler; |
---|
| 77 | |
---|
| 78 | return 0; |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | |
---|