Mercurial > pidgin
comparison src/protocols/oscar/ssi.c @ 3109:51f49dcbd14b
[gaim-migrate @ 3123]
Mark Doliner fixed idle times. Thanks, Mark.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Fri, 29 Mar 2002 04:08:41 +0000 |
parents | 25c2f11e92fa |
children | aa18e79365b7 |
comparison
equal
deleted
inserted
replaced
3108:592e6adf68c8 | 3109:51f49dcbd14b |
---|---|
49 return cur->name; | 49 return cur->name; |
50 return 0; | 50 return 0; |
51 } | 51 } |
52 | 52 |
53 /* | 53 /* |
54 * Returns the permit/deny byte | |
55 * This should be removed and the byte should be passed directly to | |
56 * the handler for x0006, along with all the buddies and other info. | |
57 */ | |
58 faim_export int aim_ssi_getpermdeny(aim_tlvlist_t *tlvlist) | |
59 { | |
60 aim_tlv_t *tlv; | |
61 if ((tlv = aim_gettlv(tlvlist, 0x00ca, 1)) && tlv->value) | |
62 return tlv->value[0]; | |
63 return 0; | |
64 } | |
65 | |
66 /* | |
67 * Returns a pointer to an item with the given name and type, or NULL if one does not exist. | 54 * Returns a pointer to an item with the given name and type, or NULL if one does not exist. |
68 */ | 55 */ |
69 static struct aim_ssi_item *get_ssi_item(struct aim_ssi_item *items, char *name, fu16_t type) | 56 static struct aim_ssi_item *get_ssi_item(struct aim_ssi_item *items, char *name, fu16_t type) |
70 { | 57 { |
71 struct aim_ssi_item *cur; | 58 struct aim_ssi_item *cur; |
72 if (name) { | 59 if (name) { |
73 for (cur=items; cur; cur=cur->next) | 60 for (cur=items; cur; cur=cur->next) |
74 if ((cur->type == type) && (cur->name) && !(aim_sncmp(cur->name, name))) | 61 if ((cur->type == type) && (cur->name) && !(aim_sncmp(cur->name, name))) |
75 return cur; | 62 return cur; |
76 } else { /* return the master group */ | 63 } else { /* return the given type with gid 0 */ |
77 for (cur=items; cur; cur=cur->next) | 64 for (cur=items; cur; cur=cur->next) |
78 if ((cur->type == type) && (cur->gid == 0x0000)) | 65 if ((cur->type == type) && (cur->gid == 0x0000)) |
79 return cur; | 66 return cur; |
80 } | 67 } |
81 return NULL; | 68 return NULL; |
69 } | |
70 | |
71 /* | |
72 * Returns the permit/deny byte | |
73 */ | |
74 faim_export int aim_ssi_getpermdeny(aim_session_t *sess, aim_conn_t *conn) | |
75 { | |
76 struct aim_ssi_item *cur = get_ssi_item(sess->ssi.items, NULL, AIM_SSI_TYPE_PDINFO); | |
77 if (cur) { | |
78 aim_tlvlist_t *tlvlist = cur->data; | |
79 if (tlvlist) { | |
80 aim_tlv_t *tlv = aim_gettlv(tlvlist, 0x00ca, 1); | |
81 if (tlv && tlv->value) | |
82 return aimutil_get8(tlv->value); | |
83 } | |
84 } | |
85 | |
86 return 0; | |
87 } | |
88 | |
89 /* | |
90 * Returns the presence flag | |
91 * I'm pretty sure this is a bitmask, but really have no evidence for that. | |
92 * 0x00000400 - Show up as visible to others | |
93 */ | |
94 faim_export fu32_t aim_ssi_getpresence(aim_session_t *sess, aim_conn_t *conn) | |
95 { | |
96 struct aim_ssi_item *cur = get_ssi_item(sess->ssi.items, NULL, AIM_SSI_TYPE_PRESENCEPREFS); | |
97 if (cur) { | |
98 aim_tlvlist_t *tlvlist = cur->data; | |
99 if (tlvlist) { | |
100 aim_tlv_t *tlv = aim_gettlv(tlvlist, 0x00c9, 1); | |
101 if (tlv && tlv->length) | |
102 return aimutil_get32(tlv->value); | |
103 } | |
104 } | |
105 | |
106 return 0xFFFFFFFF; | |
82 } | 107 } |
83 | 108 |
84 /* | 109 /* |
85 * Add the given packet to the holding queue. | 110 * Add the given packet to the holding queue. |
86 */ | 111 */ |
807 | 832 |
808 if (!sess || !conn) | 833 if (!sess || !conn) |
809 return -EINVAL; | 834 return -EINVAL; |
810 | 835 |
811 /* Look up the permit/deny settings item */ | 836 /* Look up the permit/deny settings item */ |
812 for (cur=sess->ssi.items; (cur && (cur->type!=AIM_SSI_TYPE_PDINFO)); cur=cur->next); | 837 cur = get_ssi_item(sess->ssi.items, NULL, AIM_SSI_TYPE_PDINFO); |
813 | 838 |
814 if (cur) { | 839 if (cur) { |
815 /* The permit/deny item exists */ | 840 /* The permit/deny item exists */ |
816 if (cur->data && (tlv = aim_gettlv(cur->data, 0x00ca, 1))) { | 841 if (cur->data && (tlv = aim_gettlv(cur->data, 0x00ca, 1))) { |
817 /* Just change the value of the x00ca TLV */ | 842 /* Just change the value of the x00ca TLV */ |
859 | 884 |
860 return 0; | 885 return 0; |
861 } | 886 } |
862 | 887 |
863 /* | 888 /* |
889 * Stores your setting for whether you should show up as idle or not. | |
890 * presence is a bitmask (at least, I think so...) | |
891 * 0x00000400 if you want others to see your idle time | |
892 */ | |
893 faim_export int aim_ssi_setpresence(aim_session_t *sess, aim_conn_t *conn, fu32_t presence) { | |
894 struct aim_ssi_item *cur, *tmp; | |
895 fu16_t j; | |
896 aim_tlv_t *tlv; | |
897 | |
898 if (!sess || !conn) | |
899 return -EINVAL; | |
900 | |
901 /* Look up the item */ | |
902 cur = get_ssi_item(sess->ssi.items, NULL, AIM_SSI_TYPE_PRESENCEPREFS); | |
903 | |
904 if (cur) { | |
905 /* The item exists */ | |
906 if (cur->data && (tlv = aim_gettlv(cur->data, 0x00c9, 1))) { | |
907 /* Just change the value of the x00c9 TLV */ | |
908 if (tlv->length != 4) { | |
909 tlv->length = 4; | |
910 free(tlv->value); | |
911 tlv->value = (fu8_t *)malloc(4*sizeof(fu8_t)); | |
912 } | |
913 aimutil_put32(tlv->value, presence); | |
914 } else { | |
915 /* Need to add the x00c9 TLV to the TLV chain */ | |
916 aim_addtlvtochain32((aim_tlvlist_t**)&cur->data, 0x00c9, presence); | |
917 } | |
918 | |
919 /* Send the mod item SNAC */ | |
920 aim_ssi_addmoddel(sess, conn, &cur, 1, AIM_CB_SSI_MOD); | |
921 } else { | |
922 /* Need to add the item */ | |
923 if (!(cur = (struct aim_ssi_item *)malloc(sizeof(struct aim_ssi_item)))) | |
924 return -ENOMEM; | |
925 cur->name = NULL; | |
926 cur->gid = 0x0000; | |
927 cur->bid = 0x007a; /* XXX - Is this number significant? */ | |
928 do { | |
929 cur->bid += 0x0001; | |
930 for (tmp=sess->ssi.items, j=0; ((tmp) && (!j)); tmp=tmp->next) | |
931 if (tmp->bid == cur->bid) | |
932 j=1; | |
933 } while (j); | |
934 cur->type = AIM_SSI_TYPE_PRESENCEPREFS; | |
935 cur->data = NULL; | |
936 aim_addtlvtochain32((aim_tlvlist_t**)&cur->data, 0x00c9, presence); | |
937 | |
938 /* Add the item to our list */ | |
939 cur->next = sess->ssi.items; | |
940 sess->ssi.items = cur; | |
941 | |
942 /* Send the add item SNAC */ | |
943 aim_ssi_addmoddel(sess, conn, &cur, 1, AIM_CB_SSI_ADD); | |
944 } | |
945 | |
946 /* Begin sending SSI SNACs */ | |
947 aim_ssi_dispatch(sess, conn); | |
948 | |
949 return 0; | |
950 } | |
951 | |
952 /* | |
864 * Request SSI Rights. | 953 * Request SSI Rights. |
865 */ | 954 */ |
866 faim_export int aim_ssi_reqrights(aim_session_t *sess, aim_conn_t *conn) | 955 faim_export int aim_ssi_reqrights(aim_session_t *sess, aim_conn_t *conn) |
867 { | 956 { |
868 return aim_genericreq_n(sess, conn, AIM_CB_FAM_SSI, AIM_CB_SSI_REQRIGHTS); | 957 return aim_genericreq_n(sess, conn, AIM_CB_FAM_SSI, AIM_CB_SSI_REQRIGHTS); |