diff 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
line wrap: on
line diff
--- a/src/protocols/oscar/ssi.c	Mon Oct 06 02:28:43 2003 +0000
+++ b/src/protocols/oscar/ssi.c	Mon Oct 06 03:21:33 2003 +0000
@@ -385,7 +385,7 @@
  * @param list A pointer to the current list of items.
  * @param gn The group of the buddy.
  * @param sn The name of the buddy.
- * @return A pointer to a NULL terminated string that is the buddies 
+ * @return A pointer to a NULL terminated string that is the buddy's 
  *         alias, or NULL if the buddy has no alias.  You should free
  *         this returned value!
  */
@@ -405,6 +405,31 @@
 }
 
 /**
+ * Locally find the comment of the given buddy.
+ *
+ * @param list A pointer to the current list of items.
+ * @param gn The group of the buddy.
+ * @param sn The name of the buddy.
+ * @return A pointer to a NULL terminated string that is the buddy's 
+ *         comment, or NULL if the buddy has no comment.  You should free
+ *         this returned value!
+ */
+faim_export char *aim_ssi_getcomment(struct aim_ssi_item *list, const char *gn, const char *sn)
+{
+	struct aim_ssi_item *cur = aim_ssi_itemlist_finditem(list, gn, sn, AIM_SSI_TYPE_BUDDY);
+	if (cur) {
+		aim_tlv_t *tlv = aim_tlv_gettlv(cur->data, 0x013c, 1);
+		if (tlv && tlv->length) {
+			char *alias = (char *)malloc((tlv->length+1)*sizeof(char));
+			strncpy(alias, tlv->value, tlv->length);
+			alias[tlv->length] = 0;
+			return alias;
+		}
+	}
+	return NULL;
+}
+
+/**
  * Locally find if you are waiting for authorization for a buddy.
  *
  * @param list A pointer to the current list of items.
@@ -882,7 +907,7 @@
  * @param gn The group that the buddy is currently in.
  * @param sn The screen name of the buddy.
  * @param alias The new alias for the buddy, or NULL if you want to remove 
- *        a buddies alias.
+ *        a buddy's comment.
  * @return Return 0 if no errors, otherwise return the error number.
  */
 faim_export int aim_ssi_aliasbuddy(aim_session_t *sess, const char *gn, const char *sn, const char *alias)
@@ -908,6 +933,38 @@
 }
 
 /**
+ * Change the comment stored on the server for a given buddy.
+ *
+ * @param sess The oscar session.
+ * @param gn The group that the buddy is currently in.
+ * @param sn The screen name of the buddy.
+ * @param alias The new comment for the buddy, or NULL if you want to remove 
+ *        a buddy's comment.
+ * @return Return 0 if no errors, otherwise return the error number.
+ */
+faim_export int aim_ssi_editcomment(aim_session_t *sess, const char *gn, const char *sn, const char *comment)
+{
+	struct aim_ssi_item *tmp;
+
+	if (!sess || !gn || !sn)
+		return -EINVAL;
+
+	if (!(tmp = aim_ssi_itemlist_finditem(sess->ssi.local, gn, sn, AIM_SSI_TYPE_BUDDY)))
+		return -EINVAL;
+
+	/* Either add or remove the 0x0131 TLV from the TLV chain */
+	if ((comment != NULL) && (strlen(comment) > 0))
+		aim_tlvlist_replace_raw(&tmp->data, 0x013c, strlen(comment), comment);
+	else
+		aim_tlvlist_remove(&tmp->data, 0x013c);
+
+	/* Sync our local list with the server list */
+	aim_ssi_sync(sess);
+
+	return 0;
+}
+
+/**
  * Rename a group.
  *
  * @param sess The oscar session.