comparison src/protocols/oscar/ssi.c @ 7172:895cd1d03efb

[gaim-migrate @ 7740] I added buddy comment support for AIM and ICQ I also fixed a tini memleak in gaim_request_something when using a multiline dialog. I also tried to organize ChangeLog some. I put stuff that I thought normal people would care about the most at the top, and tried to group stuff aimed at plugin authors together, and nearer to the bottom. Feel free to do a better job than me. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 06 Oct 2003 03:21:33 +0000
parents 6d3d8f11e765
children 5f4bccd8e3fd
comparison
equal deleted inserted replaced
7171:511b4edb467c 7172:895cd1d03efb
383 * Locally find the alias of the given buddy. 383 * Locally find the alias of the given buddy.
384 * 384 *
385 * @param list A pointer to the current list of items. 385 * @param list A pointer to the current list of items.
386 * @param gn The group of the buddy. 386 * @param gn The group of the buddy.
387 * @param sn The name of the buddy. 387 * @param sn The name of the buddy.
388 * @return A pointer to a NULL terminated string that is the buddies 388 * @return A pointer to a NULL terminated string that is the buddy's
389 * alias, or NULL if the buddy has no alias. You should free 389 * alias, or NULL if the buddy has no alias. You should free
390 * this returned value! 390 * this returned value!
391 */ 391 */
392 faim_export char *aim_ssi_getalias(struct aim_ssi_item *list, const char *gn, const char *sn) 392 faim_export char *aim_ssi_getalias(struct aim_ssi_item *list, const char *gn, const char *sn)
393 { 393 {
394 struct aim_ssi_item *cur = aim_ssi_itemlist_finditem(list, gn, sn, AIM_SSI_TYPE_BUDDY); 394 struct aim_ssi_item *cur = aim_ssi_itemlist_finditem(list, gn, sn, AIM_SSI_TYPE_BUDDY);
395 if (cur) { 395 if (cur) {
396 aim_tlv_t *tlv = aim_tlv_gettlv(cur->data, 0x0131, 1); 396 aim_tlv_t *tlv = aim_tlv_gettlv(cur->data, 0x0131, 1);
397 if (tlv && tlv->length) {
398 char *alias = (char *)malloc((tlv->length+1)*sizeof(char));
399 strncpy(alias, tlv->value, tlv->length);
400 alias[tlv->length] = 0;
401 return alias;
402 }
403 }
404 return NULL;
405 }
406
407 /**
408 * Locally find the comment of the given buddy.
409 *
410 * @param list A pointer to the current list of items.
411 * @param gn The group of the buddy.
412 * @param sn The name of the buddy.
413 * @return A pointer to a NULL terminated string that is the buddy's
414 * comment, or NULL if the buddy has no comment. You should free
415 * this returned value!
416 */
417 faim_export char *aim_ssi_getcomment(struct aim_ssi_item *list, const char *gn, const char *sn)
418 {
419 struct aim_ssi_item *cur = aim_ssi_itemlist_finditem(list, gn, sn, AIM_SSI_TYPE_BUDDY);
420 if (cur) {
421 aim_tlv_t *tlv = aim_tlv_gettlv(cur->data, 0x013c, 1);
397 if (tlv && tlv->length) { 422 if (tlv && tlv->length) {
398 char *alias = (char *)malloc((tlv->length+1)*sizeof(char)); 423 char *alias = (char *)malloc((tlv->length+1)*sizeof(char));
399 strncpy(alias, tlv->value, tlv->length); 424 strncpy(alias, tlv->value, tlv->length);
400 alias[tlv->length] = 0; 425 alias[tlv->length] = 0;
401 return alias; 426 return alias;
880 * 905 *
881 * @param sess The oscar session. 906 * @param sess The oscar session.
882 * @param gn The group that the buddy is currently in. 907 * @param gn The group that the buddy is currently in.
883 * @param sn The screen name of the buddy. 908 * @param sn The screen name of the buddy.
884 * @param alias The new alias for the buddy, or NULL if you want to remove 909 * @param alias The new alias for the buddy, or NULL if you want to remove
885 * a buddies alias. 910 * a buddy's comment.
886 * @return Return 0 if no errors, otherwise return the error number. 911 * @return Return 0 if no errors, otherwise return the error number.
887 */ 912 */
888 faim_export int aim_ssi_aliasbuddy(aim_session_t *sess, const char *gn, const char *sn, const char *alias) 913 faim_export int aim_ssi_aliasbuddy(aim_session_t *sess, const char *gn, const char *sn, const char *alias)
889 { 914 {
890 struct aim_ssi_item *tmp; 915 struct aim_ssi_item *tmp;
898 /* Either add or remove the 0x0131 TLV from the TLV chain */ 923 /* Either add or remove the 0x0131 TLV from the TLV chain */
899 if ((alias != NULL) && (strlen(alias) > 0)) 924 if ((alias != NULL) && (strlen(alias) > 0))
900 aim_tlvlist_replace_raw(&tmp->data, 0x0131, strlen(alias), alias); 925 aim_tlvlist_replace_raw(&tmp->data, 0x0131, strlen(alias), alias);
901 else 926 else
902 aim_tlvlist_remove(&tmp->data, 0x0131); 927 aim_tlvlist_remove(&tmp->data, 0x0131);
928
929 /* Sync our local list with the server list */
930 aim_ssi_sync(sess);
931
932 return 0;
933 }
934
935 /**
936 * Change the comment stored on the server for a given buddy.
937 *
938 * @param sess The oscar session.
939 * @param gn The group that the buddy is currently in.
940 * @param sn The screen name of the buddy.
941 * @param alias The new comment for the buddy, or NULL if you want to remove
942 * a buddy's comment.
943 * @return Return 0 if no errors, otherwise return the error number.
944 */
945 faim_export int aim_ssi_editcomment(aim_session_t *sess, const char *gn, const char *sn, const char *comment)
946 {
947 struct aim_ssi_item *tmp;
948
949 if (!sess || !gn || !sn)
950 return -EINVAL;
951
952 if (!(tmp = aim_ssi_itemlist_finditem(sess->ssi.local, gn, sn, AIM_SSI_TYPE_BUDDY)))
953 return -EINVAL;
954
955 /* Either add or remove the 0x0131 TLV from the TLV chain */
956 if ((comment != NULL) && (strlen(comment) > 0))
957 aim_tlvlist_replace_raw(&tmp->data, 0x013c, strlen(comment), comment);
958 else
959 aim_tlvlist_remove(&tmp->data, 0x013c);
903 960
904 /* Sync our local list with the server list */ 961 /* Sync our local list with the server list */
905 aim_ssi_sync(sess); 962 aim_ssi_sync(sess);
906 963
907 return 0; 964 return 0;