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