changeset 20628:b8962a8c5daa

merge of '33aead6e626883ef6ad44b79099f01d2da042d9a' and 'f76b9e1feb23d6a4308ca0c80f5f85765d985aff'
author Mark Doliner <mark@kingant.net>
date Sun, 23 Sep 2007 22:08:46 +0000
parents 0584c704cc4a (current diff) 52dce2882c03 (diff)
children 77fda34d4289
files libpurple/protocols/msn/msn-utils.c libpurple/protocols/msn/msn-utils.h libpurple/protocols/myspace/markup.c libpurple/protocols/myspace/myspace.c
diffstat 6 files changed, 80 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jabber.c	Sun Sep 23 20:19:13 2007 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Sun Sep 23 22:08:46 2007 +0000
@@ -2240,6 +2240,44 @@
 	return PURPLE_CMD_RET_FAILED;
 }
 
+GList *jabber_attention_types(PurpleAccount *account)
+{
+	static GList *types = NULL;
+	PurpleAttentionType *attn;
+
+	if (!types) {
+		attn = g_new0(PurpleAttentionType, 1);
+		attn->name = _("Buzz");
+		attn->incoming_description = _("%s has buzzed you!");
+		attn->outgoing_description = _("Buzzing %s...");
+		types = g_list_append(types, attn);
+	}
+
+	return types;
+}
+
+gboolean jabber_send_attention(PurpleConnection *gc, const char *username, guint code)
+{
+	PurpleConversation *conv;
+	char *error;
+	char *args[1];
+	PurpleCmdRet ret;
+
+	conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, username, gc->account);
+
+	args[0] = (char *)username;
+
+	ret = jabber_cmd_buzz(conv, "buzz", args, &error, NULL);
+
+	if (ret == PURPLE_CMD_RET_FAILED) {
+		purple_debug_error("jabber", "jabber_send_attention: jabber_cmd_buzz failed with error: %s\n", error ? error : "(NULL)");
+		return FALSE;
+	} else {
+		return TRUE;
+	}
+}
+
+
 gboolean jabber_offline_message(const PurpleBuddy *buddy)
 {
 	return TRUE;
--- a/libpurple/protocols/jabber/jabber.h	Sun Sep 23 20:19:13 2007 +0000
+++ b/libpurple/protocols/jabber/jabber.h	Sun Sep 23 22:08:46 2007 +0000
@@ -66,6 +66,9 @@
 
 #define CAPS0115_NODE "http://pidgin.im/caps"
 
+/* Index into attention_types list */
+#define JABBER_BUZZ 0
+
 typedef enum {
 	JABBER_STREAM_OFFLINE,
 	JABBER_STREAM_CONNECTING,
@@ -231,6 +234,8 @@
 void jabber_register_gateway(JabberStream *js, const char *gateway);
 void jabber_register_account(PurpleAccount *account);
 void jabber_unregister_account(PurpleAccount *account, PurpleAccountUnregistrationCb cb, void *user_data);
+gboolean jabber_send_attention(PurpleConnection *gc, const char *username, guint code);
+GList *jabber_attention_types(PurpleAccount *account);
 void jabber_convo_closed(PurpleConnection *gc, const char *who);
 PurpleChat *jabber_find_blist_chat(PurpleAccount *account, const char *name);
 gboolean jabber_offline_message(const PurpleBuddy *buddy);
--- a/libpurple/protocols/jabber/libxmpp.c	Sun Sep 23 20:19:13 2007 +0000
+++ b/libpurple/protocols/jabber/libxmpp.c	Sun Sep 23 22:08:46 2007 +0000
@@ -113,10 +113,10 @@
 	jabber_prpl_send_raw,			/* send_raw */
 	jabber_roomlist_room_serialize, /* roomlist_room_serialize */
 	jabber_unregister_account,		/* unregister_user */
+	jabber_attention_types,                 /* attention_types */
+	jabber_send_attention,                  /* send_attention */
 
 	/* padding */
-	NULL,
-	NULL,
 	NULL
 };
 
--- a/libpurple/protocols/myspace/markup.c	Sun Sep 23 20:19:13 2007 +0000
+++ b/libpurple/protocols/myspace/markup.c	Sun Sep 23 22:08:46 2007 +0000
@@ -515,7 +515,8 @@
 #endif
 
 		err = g_strdup_printf("html_tag_to_msim_markup: unrecognized "
-			"HTML tag %s was sent by the IM client; ignoring", root->name);
+			"HTML tag %s was sent by the IM client; ignoring", 
+			root->name ? root->name : "(NULL)");
 		msim_unrecognized(NULL, NULL, err);
 		g_free(err);
 	}
--- a/libpurple/protocols/myspace/myspace.c	Sun Sep 23 20:19:13 2007 +0000
+++ b/libpurple/protocols/myspace/myspace.c	Sun Sep 23 22:08:46 2007 +0000
@@ -454,6 +454,7 @@
 	purple_cipher_context_append(key_context, hash_pw, HASH_SIZE);
 	purple_cipher_context_append(key_context, (guchar *)(nonce + NONCE_SIZE), NONCE_SIZE);
 	purple_cipher_context_digest(key_context, sizeof(key), key, NULL);
+	purple_cipher_context_destroy(key_context);
 
 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE
 	purple_debug_info("msim", "key = ");
@@ -1030,7 +1031,7 @@
 	PurpleStatusType *type;
 	MsimSession *session;
 	guint status_code;
-	const gchar *statstring;
+	gchar *statstring;
 
 	session = (MsimSession *)account->gc->proto_data;
 
@@ -1064,7 +1065,7 @@
 			break;
 	}
 
-	statstring = purple_status_get_attr_string(status, "message");
+	statstring = (gchar *)purple_status_get_attr_string(status, "message");
 
 	if (!statstring) {
 		statstring = "";
@@ -1073,7 +1074,7 @@
 	/* Status strings are plain text. */
 	statstring = purple_markup_strip_html(statstring);
 
-	msim_set_status_code(session, status_code, g_strdup(statstring));
+	msim_set_status_code(session, status_code, statstring);
 }
 
 /** Go idle. */
@@ -1204,7 +1205,7 @@
 		if (uid == wanted_uid)
 		{
 			ret = g_strdup(name);
-            break;
+			break;
 		}
 	}
 
@@ -1863,6 +1864,7 @@
 		purple_blist_add_buddy(buddy, NULL, NULL, NULL);
 
 		user = msim_get_user_from_buddy(buddy);
+		/* TODO: free user. memory leak? */
 
 		/* All buddies on list should have 'uid' integer associated with them. */
 		purple_blist_node_set_int(&buddy->node, "UserID", msim_msg_get_integer(msg, "f"));
--- a/libpurple/protocols/myspace/user.c	Sun Sep 23 20:19:13 2007 +0000
+++ b/libpurple/protocols/myspace/user.c	Sun Sep 23 22:08:46 2007 +0000
@@ -154,7 +154,13 @@
 	}
 }
 
-/** Store a field of information about a buddy. */
+/** Store a field of information about a buddy. 
+ *
+ * @param key_str Key to store.
+ * @param value_str Value string, either user takes ownership of this string
+ *                  or it is freed if MsimUser doesn't store the string.
+ * @param user User to store data in. Existing data will be replaced.
+ * */
 void 
 msim_store_user_info_each(const gchar *key_str, gchar *value_str, MsimUser *user)
 {
@@ -168,25 +174,33 @@
 		/* Need to store in MsimUser, too? What if not on blist? */
 	} else if (g_str_equal(key_str, "Age")) {
 		user->age = atol(value_str);
+		g_free(value_str);
 	} else if (g_str_equal(key_str, "Gender")) {
-		user->gender = g_strdup(value_str);
+		g_free(user->gender);
+		user->gender = value_str;
 	} else if (g_str_equal(key_str, "Location")) {
-		user->location = g_strdup(value_str);
+		g_free(user->location);
+		user->location = value_str;
 	} else if (g_str_equal(key_str, "TotalFriends")) {
 		user->total_friends = atol(value_str);
 	} else if (g_str_equal(key_str, "DisplayName")) {
-		user->display_name = g_strdup(value_str);
+		g_free(user->display_name);
+		user->display_name = value_str;
 	} else if (g_str_equal(key_str, "BandName")) {
-		user->band_name = g_strdup(value_str);
+		g_free(user->band_name);
+		user->band_name = value_str;
 	} else if (g_str_equal(key_str, "SongName")) {
-		user->song_name = g_strdup(value_str);
+		g_free(user->song_name);
+		user->song_name = value_str;
 	} else if (g_str_equal(key_str, "UserName") || g_str_equal(key_str, "IMName") || g_str_equal(key_str, "NickName")) {
 		/* Ignore because PurpleBuddy knows this already */
-		;
+		g_free(value_str);
 	} else if (g_str_equal(key_str, "ImageURL") || g_str_equal(key_str, "AvatarURL")) {
 		const gchar *previous_url;
 
-		user->image_url = g_strdup(value_str);
+		g_free(user->image_url);
+
+		user->image_url = value_str;
 
 		/* Instead of showing 'no photo' picture, show nothing. */
 		if (g_str_equal(user->image_url, "http://x.myspace.com/images/no_pic.gif"))
@@ -207,14 +221,17 @@
 	} else if (g_str_equal(key_str, "LastImageUpdated")) {
 		/* TODO: use somewhere */
 		user->last_image_updated = atol(value_str);
+		g_free(value_str);
 	} else if (g_str_equal(key_str, "Headline")) {
-		user->headline = g_strdup(value_str);
+		g_free(user->headline);
+		user->headline = value_str;
 	} else {
 		/* TODO: other fields in MsimUser */
 		gchar *msg;
 
 		msg = g_strdup_printf("msim_store_user_info_each: unknown field %s=%s",
 				key_str, value_str);
+		g_free(value_str);
 
 		msim_unrecognized(NULL, NULL, msg);
 
@@ -284,7 +301,6 @@
 
 		value_str = msim_msg_get_string_from_element(elem);
 		msim_store_user_info_each(key_str, value_str, user);
-		g_free(value_str);
 	}
 
 	if (msim_msg_get_integer(msg, "dsn") == MG_OWN_IM_INFO_DSN &&
@@ -301,6 +317,7 @@
 	}
 
 	msim_msg_free(body);
+	g_free(username);
 
 	return TRUE;
 }