changeset 32573:65d599736f3d

propagate from branch 'im.pidgin.pidgin' (head ecded04145b1adc6b1f6b773b68bcef7eb1daf02) to branch 'im.pidgin.cpw.qulogic.gtk3' (head 9d8f789a57f4477db7d3cfbb9752b7842ff790dd)
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 10 Apr 2009 07:33:31 +0000
parents c40a3b9c90af (current diff) 1141d9c3c350 (diff)
children 4fa36f6928e3
files pidgin/gtkblist.c pidgin/gtkconv.c
diffstat 55 files changed, 574 insertions(+), 263 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Apr 10 05:00:13 2009 +0000
+++ b/ChangeLog	Fri Apr 10 07:33:31 2009 +0000
@@ -9,6 +9,9 @@
 	* Removed the unmaintained and unneeded toc protocol plugin.
 	* Fixed NTLM authentication on big-endian systems.
 
+	libpurple:
+	* Various memory cleanups when unloading libpurple. (Nick Hebner)
+
 	XMPP:
 	* Add voice & video support with Jingle (XEP-0166, 0167, 0176, & 0177),
 	  and voice support with GTalk and GMail. (Mike "Maiku" Ruprecht)
--- a/ChangeLog.API	Fri Apr 10 05:00:13 2009 +0000
+++ b/ChangeLog.API	Fri Apr 10 07:33:31 2009 +0000
@@ -9,6 +9,7 @@
 		* PURPLE_CONTACT
 		* PURPLE_BUDDY
 		* PURPLE_CHAT
+		* purple_buddy_destroy
 		* purple_buddy_get_protocol_data
 		* purple_buddy_set_protocol_data
 		* purple_buddy_get_local_buddy_alias
@@ -17,9 +18,12 @@
 		* purple_blist_set_ui_data
 		* purple_blist_node_get_ui_data
 		* purple_blist_node_set_ui_data
+		* purple_chat_destroy
 		* purple_connection_get_protocol_data
 		* purple_connection_set_protocol_data
+		* purple_contact_destroy
 		* purple_global_proxy_set_info
+		* purple_group_destroy
 		* purple_log_get_activity_score
 		* purple_network_force_online
 		* purple_network_set_stun_server
--- a/configure.ac	Fri Apr 10 05:00:13 2009 +0000
+++ b/configure.ac	Fri Apr 10 07:33:31 2009 +0000
@@ -706,9 +706,13 @@
 PKG_CHECK_MODULES(LIBXML, [libxml-2.0 >= 2.6.0], , [
 	AC_MSG_RESULT(no)
 	AC_MSG_ERROR([
-
 You must have libxml2 >= 2.6.0 development headers installed to build.
 ])])
+PKG_CHECK_EXISTS([libxml-2.0 >= 2.6.18], , [
+	AC_MSG_WARN([
+Versions of libxml2 < 2.6.18 may contain bugs that could cause XMPP messages to be discarded.
+])])
+
 AC_SUBST(LIBXML_CFLAGS)
 AC_SUBST(LIBXML_LIBS)
 
@@ -774,7 +778,7 @@
 	[AC_HELP_STRING([--disable-farsight], [compile without farsight support])],
 	enable_farsight="$enableval", enable_farsight="yes")
 if test "x$enable_farsight" != "xno"; then
-	PKG_CHECK_MODULES(FARSIGHT, [farsight2-0.10 >= 0.0.8], [
+	PKG_CHECK_MODULES(FARSIGHT, [farsight2-0.10 >= 0.0.9], [
 		AC_DEFINE(USE_FARSIGHT, 1, [Use Farsight for voice and video])
 		AC_SUBST(FARSIGHT_CFLAGS)
 		AC_SUBST(FARSIGHT_LIBS)
@@ -982,7 +986,7 @@
 		gadu_includes="yes"
 		gadu_libs="yes"
 	], [
-		AC_MSG_RESULT(no)
+		gadu_includes="no"
 	])
 else
 	if test "$ac_gadu_includes" != "no"; then
--- a/finch/gntmedia.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/finch/gntmedia.c	Fri Apr 10 07:33:31 2009 +0000
@@ -254,16 +254,15 @@
 	} else if (state == PURPLE_MEDIA_STATE_NEW &&
 			sid != NULL && name != NULL && 
 			purple_media_is_initiator(media, sid, name) == FALSE) {
-		PurpleConnection *pc;
+		PurpleAccount *account;
 		PurpleBuddy *buddy;
 		const gchar *alias;
 		PurpleMediaSessionType type =
 				purple_media_get_session_type(media, sid);
 		gchar *message = NULL;
 
-		pc = purple_media_get_connection(gntmedia->priv->media);
-		buddy = purple_find_buddy(
-				purple_connection_get_account(pc), name);
+		account = purple_media_get_account(gntmedia->priv->media);
+		buddy = purple_find_buddy(account, name);
 		alias = buddy ? purple_buddy_get_contact_alias(buddy) :	name;
 
 		if (type & PURPLE_MEDIA_AUDIO) {
@@ -386,13 +385,12 @@
 
 static gboolean
 finch_new_media(PurpleMediaManager *manager, PurpleMedia *media,
-		PurpleConnection *gc, gchar *name, gpointer null)
+		PurpleAccount *account, gchar *name, gpointer null)
 {
 	GntWidget *gntmedia;
 	PurpleConversation *conv;
 
-	conv = purple_conversation_new(PURPLE_CONV_TYPE_IM,
-			purple_connection_get_account(gc), name);
+	conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, name);
 
 	gntmedia = finch_media_new(media);
 	g_signal_connect(G_OBJECT(gntmedia), "message", G_CALLBACK(gntmedia_message_cb), conv);
--- a/finch/libgnt/gnttree.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/finch/libgnt/gnttree.c	Fri Apr 10 07:33:31 2009 +0000
@@ -432,7 +432,7 @@
 
 	if (tree->top == NULL)
 		tree->top = tree->root;
-	if (tree->current == NULL) {
+	if (tree->current == NULL && tree->root != NULL) {
 		tree->current = tree->root;
 		tree_selection_changed(tree, NULL, tree->current);
 	}
@@ -491,6 +491,13 @@
 		tree->top = get_next(tree->top);
 	row = tree->top;
 	scrcol = widget->priv.width - 1 - 2 * pos;  /* exclude the borders and the scrollbar */
+
+	if (tree->current && !row_matches_search(tree->current)) {
+		GntTreeRow *old = tree->current;
+		tree->current = tree->top;
+		tree_selection_changed(tree, old, tree->current);
+	}
+
 	for (i = start + pos; row && i < widget->priv.height - pos;
 				i++, row = get_next(row))
 	{
--- a/libpurple/account.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/account.c	Fri Apr 10 07:33:31 2009 +0000
@@ -2787,6 +2787,7 @@
 void
 purple_accounts_uninit(void)
 {
+	GList* account;
 	gpointer handle = purple_accounts_get_handle();
 	if (save_timer != 0)
 	{
@@ -2797,4 +2798,10 @@
 
 	purple_signals_disconnect_by_handle(handle);
 	purple_signals_unregister_by_instance(handle);
+
+	account = purple_accounts_get_all();
+	while (account) {
+		purple_account_destroy(account->data);
+		account = g_list_delete_link(account, account);
+	}
 }
--- a/libpurple/blist.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/blist.c	Fri Apr 10 07:33:31 2009 +0000
@@ -1202,6 +1202,16 @@
 	return chat;
 }
 
+void
+purple_chat_destroy(PurpleChat *chat)
+{
+	g_hash_table_destroy(chat->components);
+	g_hash_table_destroy(chat->node.settings);
+	g_free(chat->alias);
+	PURPLE_DBUS_UNREGISTER_POINTER(chat);
+	g_free(chat);
+}
+
 PurpleBuddy *purple_buddy_new(PurpleAccount *account, const char *name, const char *alias)
 {
 	PurpleBlistUiOps *ops = purple_blist_get_ui_ops();
@@ -1229,6 +1239,42 @@
 }
 
 void
+purple_buddy_destroy(PurpleBuddy *buddy)
+{
+	PurplePlugin *prpl;
+	PurplePluginProtocolInfo *prpl_info;
+
+	/*
+	 * Tell the owner PRPL that we're about to free the buddy so it
+	 * can free proto_data
+	 */
+	prpl = purple_find_prpl(purple_account_get_protocol_id(buddy->account));
+	if (prpl) {
+		prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+		if (prpl_info && prpl_info->buddy_free)
+			prpl_info->buddy_free(buddy);
+	}
+
+	/* Delete the node */
+	purple_buddy_icon_unref(buddy->icon);
+	g_hash_table_destroy(buddy->node.settings);
+	purple_presence_destroy(buddy->presence);
+	g_free(buddy->name);
+	g_free(buddy->alias);
+	g_free(buddy->server_alias);
+
+	PURPLE_DBUS_UNREGISTER_POINTER(buddy);
+	g_free(buddy);
+
+	/* FIXME: Once PurpleBuddy is a GObject, timeout callbacks can
+	 * g_object_ref() it when connecting the callback and
+	 * g_object_unref() it in the handler.  That way, it won't
+	 * get freed while the timeout is pending and this line can
+	 * be removed. */
+	while (g_source_remove_by_user_data((gpointer *)buddy));
+}
+
+void
 purple_buddy_set_icon(PurpleBuddy *buddy, PurpleBuddyIcon *icon)
 {
 	g_return_if_fail(buddy != NULL);
@@ -1519,6 +1565,14 @@
 	return contact;
 }
 
+void
+purple_contact_destroy(PurpleContact *contact)
+{
+	g_hash_table_destroy(contact->node.settings);
+	PURPLE_DBUS_UNREGISTER_POINTER(contact);
+	g_free(contact);
+}
+
 void purple_contact_set_alias(PurpleContact *contact, const char *alias)
 {
 	purple_blist_alias_contact(contact,alias);
@@ -1588,6 +1642,15 @@
 	return group;
 }
 
+void
+purple_group_destroy(PurpleGroup *group)
+{
+	g_hash_table_destroy(group->node.settings);
+	g_free(group->name);
+	PURPLE_DBUS_UNREGISTER_POINTER(group);
+	g_free(group);
+}
+
 void purple_blist_add_contact(PurpleContact *contact, PurpleGroup *group, PurpleBlistNode *node)
 {
 	PurpleBlistUiOps *ops = purple_blist_get_ui_ops();
@@ -1848,9 +1911,7 @@
 			ops->remove(purplebuddylist, node);
 
 		/* Delete the node */
-		g_hash_table_destroy(contact->node.settings);
-		PURPLE_DBUS_UNREGISTER_POINTER(contact);
-		g_free(contact);
+		purple_contact_destroy(contact);
 	}
 }
 
@@ -1861,8 +1922,6 @@
 	PurpleContact *contact;
 	PurpleGroup *group;
 	struct _purple_hbuddy hb;
-	PurplePlugin *prpl;
-	PurplePluginProtocolInfo *prpl_info = NULL;
 
 	g_return_if_fail(buddy != NULL);
 
@@ -1918,33 +1977,7 @@
 	/* Signal that the buddy has been removed before freeing the memory for it */
 	purple_signal_emit(purple_blist_get_handle(), "buddy-removed", buddy);
 
-	/*
-	 * Tell the owner PRPL that we're about to free the buddy so it
-	 * can free proto_data
-	 */
-	prpl = purple_find_prpl(purple_account_get_protocol_id(buddy->account));
-	if (prpl)
-		prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
-	if (prpl_info && prpl_info->buddy_free)
-		prpl_info->buddy_free(buddy);
-
-	/* Delete the node */
-	purple_buddy_icon_unref(buddy->icon);
-	g_hash_table_destroy(buddy->node.settings);
-	purple_presence_destroy(buddy->presence);
-	g_free(buddy->name);
-	g_free(buddy->alias);
-	g_free(buddy->server_alias);
-
-	PURPLE_DBUS_UNREGISTER_POINTER(buddy);
-	g_free(buddy);
-
-	/* FIXME: Once PurpleBuddy is a GObject, timeout callbacks can
-	 * g_object_ref() it when connecting the callback and
-	 * g_object_unref() it in the handler.  That way, it won't
-	 * get freed while the timeout is pending and this line can
-	 * be removed. */
-	while (g_source_remove_by_user_data((gpointer *)buddy));
+	purple_buddy_destroy(buddy);
 
 	/* If the contact is empty then remove it */
 	if ((contact != NULL) && !cnode->child)
@@ -1988,11 +2021,7 @@
 		ops->remove(purplebuddylist, node);
 
 	/* Delete the node */
-	g_hash_table_destroy(chat->components);
-	g_hash_table_destroy(chat->node.settings);
-	g_free(chat->alias);
-	PURPLE_DBUS_UNREGISTER_POINTER(chat);
-	g_free(chat);
+	purple_chat_destroy(chat);
 }
 
 void purple_blist_remove_group(PurpleGroup *group)
@@ -2033,10 +2062,7 @@
 	}
 
 	/* Delete the node */
-	g_hash_table_destroy(group->node.settings);
-	g_free(group->name);
-	PURPLE_DBUS_UNREGISTER_POINTER(group);
-	g_free(group);
+	purple_group_destroy(group);
 }
 
 PurpleBuddy *purple_contact_get_priority_buddy(PurpleContact *contact)
@@ -2587,6 +2613,28 @@
 }
 
 static void
+purple_blist_node_destroy(PurpleBlistNode *node)
+{
+	PurpleBlistNode *child, *next_child;
+  
+	child = node->child;
+	while (child) {
+		next_child = child->next;
+		purple_blist_node_destroy(child);
+		child = next_child;
+	}
+
+	if (PURPLE_BLIST_NODE_IS_BUDDY(node))
+		purple_buddy_destroy((PurpleBuddy*)node);
+	else if (PURPLE_BLIST_NODE_IS_CHAT(node))
+		purple_chat_destroy((PurpleChat*)node);
+	else if (PURPLE_BLIST_NODE_IS_CONTACT(node))
+		purple_contact_destroy((PurpleContact*)node);
+	else if (PURPLE_BLIST_NODE_IS_GROUP(node))
+		purple_group_destroy((PurpleGroup*)node);
+}
+
+static void
 purple_blist_node_setting_free(gpointer data)
 {
 	PurpleValue *value;
@@ -2874,12 +2922,20 @@
 void
 purple_blist_uninit(void)
 {
-	if (save_timer != 0)
-	{
+	PurpleBlistNode *node, *next_node;
+
+	if (save_timer != 0) {
 		purple_timeout_remove(save_timer);
 		save_timer = 0;
 		purple_blist_sync();
 	}
 
+	node = purple_blist_get_root();
+	while (node) {
+		next_node = node->next;
+		purple_blist_node_destroy(node);
+		node = next_node;
+	}
+
 	purple_signals_unregister_by_instance(purple_blist_get_handle());
 }
--- a/libpurple/blist.h	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/blist.h	Fri Apr 10 07:33:31 2009 +0000
@@ -478,6 +478,13 @@
 PurpleChat *purple_chat_new(PurpleAccount *account, const char *alias, GHashTable *components);
 
 /**
+ * Destroys a chat
+ *
+ * @param chat       The chat to destroy
+ */
+void purple_chat_destroy(PurpleChat *chat);
+
+/**
  * Adds a new chat to the buddy list.
  *
  * The chat will be inserted right after node or appended to the end
@@ -501,6 +508,13 @@
 PurpleBuddy *purple_buddy_new(PurpleAccount *account, const char *name, const char *alias);
 
 /**
+ * Destroys a buddy
+ *
+ * @param buddy     The buddy to destroy
+ */
+void purple_buddy_destroy(PurpleBuddy *buddy);
+
+/**
  * Sets a buddy's icon.
  *
  * This should only be called from within Purple. You probably want to
@@ -611,6 +625,13 @@
 PurpleGroup *purple_group_new(const char *name);
 
 /**
+ * Destroys a group
+ *
+ * @param group  The group to destroy
+*/
+void purple_group_destroy(PurpleGroup *group);
+
+/**
  * Adds a new group to the buddy list.
  *
  * The new group will be inserted after insert or prepended to the list if
@@ -629,6 +650,13 @@
 PurpleContact *purple_contact_new(void);
 
 /**
+ * Destroys a contact
+ *
+ * @param contact  The contact to destroy
+ */
+void purple_contact_destroy(PurpleContact *contact);
+
+/**
  * Adds a new contact to the buddy list.
  *
  * The new contact will be inserted after insert or prepended to the list if
--- a/libpurple/buddyicon.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/buddyicon.c	Fri Apr 10 07:33:31 2009 +0000
@@ -1299,6 +1299,7 @@
 	g_hash_table_destroy(icon_file_cache);
 	g_hash_table_destroy(pointer_icon_cache);
 	g_free(old_icons_dir);
+	g_free(cache_dir);
 }
 
 void purple_buddy_icon_get_scale_size(PurpleBuddyIconSpec *spec, int *width, int *height)
--- a/libpurple/conversation.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/conversation.c	Fri Apr 10 07:33:31 2009 +0000
@@ -33,7 +33,7 @@
 #include "signals.h"
 #include "util.h"
 
-#define SEND_TYPED_TIMEOUT 5000
+#define SEND_TYPED_TIMEOUT_SECONDS 5
 
 static GList *conversations = NULL;
 static GList *ims = NULL;
@@ -1122,8 +1122,9 @@
 {
 	g_return_if_fail(im != NULL);
 
-	im->send_typed_timeout = purple_timeout_add(SEND_TYPED_TIMEOUT, send_typed_cb,
-											  purple_conv_im_get_conversation(im));
+	im->send_typed_timeout = purple_timeout_add_seconds(SEND_TYPED_TIMEOUT_SECONDS,
+	                                                    send_typed_cb,
+	                                                    purple_conv_im_get_conversation(im));
 }
 
 void
--- a/libpurple/core.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/core.c	Fri Apr 10 07:33:31 2009 +0000
@@ -216,15 +216,10 @@
 	/* The SSL plugins must be uninit before they're unloaded */
 	purple_ssl_uninit();
 
-	/* Unload all plugins before the UI because UI plugins might call
-	 * UI-specific functions */
-	purple_debug_info("main", "Unloading all plugins\n");
-	purple_plugins_destroy_all();
-
-	/* Shut down the UI before all the subsystems */
-	ops = purple_core_get_ui_ops();
-	if (ops != NULL && ops->quit != NULL)
-		ops->quit();
+	/* Unload all non-loader, non-prpl plugins before shutting down
+	 * subsystems. */
+	purple_debug_info("main", "Unloading normal plugins\n");
+	purple_plugins_unload(PURPLE_PLUGIN_STANDARD);
 
 	/* Save .xml files, remove signals, etc. */
 	purple_smileys_uninit();
@@ -247,7 +242,16 @@
 	purple_imgstore_uninit();
 	purple_network_uninit();
 
-	/* Everything after this must not try to read any prefs */
+	/* Everything after unloading all plugins must not fail if prpls aren't
+	 * around */
+	purple_debug_info("main", "Unloading all plugins\n");
+	purple_plugins_destroy_all();
+
+	ops = purple_core_get_ui_ops();
+	if (ops != NULL && ops->quit != NULL)
+		ops->quit();
+
+	/* Everything after prefs_uninit must not try to read any prefs */
 	purple_prefs_uninit();
 	purple_plugins_uninit();
 #ifdef HAVE_DBUS
@@ -255,8 +259,9 @@
 #endif
 
 	purple_cmds_uninit();
-	/* Everything after this cannot try to write things to the confdir */
+	/* Everything after util_uninit cannot try to write things to the confdir */
 	purple_util_uninit();
+	purple_log_uninit();
 
 	purple_signals_uninit();
 
--- a/libpurple/media.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/media.c	Fri Apr 10 07:33:31 2009 +0000
@@ -28,7 +28,7 @@
 
 #include "internal.h"
 
-#include "connection.h"
+#include "account.h"
 #include "marshallers.h"
 #include "media.h"
 #include "media-gst.h"
@@ -109,7 +109,7 @@
 {
 #ifdef USE_VV
 	PurpleMediaManager *manager;
-	PurpleConnection *pc;
+	PurpleAccount *account;
 	FsConference *conference;
 	gboolean initiator;
 	gpointer prpl_data;
@@ -166,7 +166,7 @@
 enum {
 	PROP_0,
 	PROP_MANAGER,
-	PROP_CONNECTION,
+	PROP_ACCOUNT,
 	PROP_CONFERENCE,
 	PROP_INITIATOR,
 	PROP_PRPL_DATA,
@@ -298,10 +298,10 @@
 			PURPLE_TYPE_MEDIA_MANAGER,
 			G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
 
-	g_object_class_install_property(gobject_class, PROP_CONNECTION,
-			g_param_spec_pointer("connection",
-			"PurpleConnection",
-			"The connection this media session is on.",
+	g_object_class_install_property(gobject_class, PROP_ACCOUNT,
+			g_param_spec_pointer("account",
+			"PurpleAccount",
+			"The account this media session is on.",
 			G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
 
 	g_object_class_install_property(gobject_class, PROP_CONFERENCE,
@@ -528,8 +528,8 @@
 
 			purple_media_setup_pipeline(media);
 			break;
-		case PROP_CONNECTION:
-			media->priv->pc = g_value_get_pointer(value);
+		case PROP_ACCOUNT:
+			media->priv->account = g_value_get_pointer(value);
 			break;
 		case PROP_CONFERENCE: {
 			if (media->priv->conference)
@@ -564,8 +564,8 @@
 		case PROP_MANAGER:
 			g_value_set_object(value, media->priv->manager);
 			break;
-		case PROP_CONNECTION:
-			g_value_set_pointer(value, media->priv->pc);
+		case PROP_ACCOUNT:
+			g_value_set_pointer(value, media->priv->account);
 			break;
 		case PROP_CONFERENCE:
 			g_value_set_object(value, media->priv->conference);
@@ -2055,14 +2055,14 @@
 }
 #endif
 
-PurpleConnection *
-purple_media_get_connection(PurpleMedia *media)
+PurpleAccount *
+purple_media_get_account(PurpleMedia *media)
 {
 #ifdef USE_VV
-	PurpleConnection *pc;
+	PurpleAccount *account;
 	g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
-	g_object_get(G_OBJECT(media), "connection", &pc, NULL);
-	return pc;
+	g_object_get(G_OBJECT(media), "account", &account, NULL);
+	return account;
 #else
 	return NULL;
 #endif
--- a/libpurple/media.h	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/media.h	Fri Apr 10 07:33:31 2009 +0000
@@ -362,15 +362,15 @@
 GList *purple_media_get_session_names(PurpleMedia *media);
 
 /**
- * Gets the PurpleConnection this media session is on.
+ * Gets the PurpleAccount this media session is on.
  *
- * @param media The media session to retrieve the connection from.
+ * @param media The media session to retrieve the account from.
  *
- * @return The connection retrieved.
+ * @return The account retrieved.
  *
  * @since 2.6.0
  */
-PurpleConnection *purple_media_get_connection(PurpleMedia *media);
+PurpleAccount *purple_media_get_account(PurpleMedia *media);
 
 /**
  * Gets the prpl data from the media session.
--- a/libpurple/mediamanager.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/mediamanager.c	Fri Apr 10 07:33:31 2009 +0000
@@ -26,7 +26,7 @@
 
 #include "internal.h"
 
-#include "connection.h"
+#include "account.h"
 #include "debug.h"
 #include "marshallers.h"
 #include "media.h"
@@ -249,7 +249,7 @@
 
 PurpleMedia *
 purple_media_manager_create_media(PurpleMediaManager *manager,
-				  PurpleConnection *gc,
+				  PurpleAccount *account,
 				  const char *conference_type,
 				  const char *remote_user,
 				  gboolean initiator)
@@ -261,8 +261,7 @@
 	gboolean signal_ret;
 
 	if (conference == NULL) {
-		purple_conv_present_error(remote_user,
-					  purple_connection_get_account(gc),
+		purple_conv_present_error(remote_user, account,
 					  _("Error creating conference."));
 		purple_debug_error("media", "Conference == NULL\n");
 		return NULL;
@@ -270,7 +269,7 @@
 
 	media = PURPLE_MEDIA(g_object_new(purple_media_get_type(),
 			     "manager", manager,
-			     "connection", gc,
+			     "account", account,
 			     "conference", conference,
 			     "initiator", initiator,
 			     NULL));
@@ -278,8 +277,7 @@
 	ret = gst_element_set_state(GST_ELEMENT(conference), GST_STATE_PLAYING);
 
 	if (ret == GST_STATE_CHANGE_FAILURE) {
-		purple_conv_present_error(remote_user,
-					  purple_connection_get_account(gc),
+		purple_conv_present_error(remote_user, account,
 					  _("Error creating conference."));
 		purple_debug_error("media", "Failed to start conference.\n");
 		g_object_unref(media);
@@ -287,7 +285,7 @@
 	}
 
 	g_signal_emit(manager, purple_media_manager_signals[INIT_MEDIA], 0,
-			media, gc, remote_user, &signal_ret);
+			media, account, remote_user, &signal_ret);
 
 	if (signal_ret == FALSE) {
 		g_object_unref(media);
@@ -312,8 +310,8 @@
 }
 
 GList *
-purple_media_manager_get_media_by_connection(PurpleMediaManager *manager,
-		PurpleConnection *pc)
+purple_media_manager_get_media_by_account(PurpleMediaManager *manager,
+		PurpleAccount *account)
 {
 #ifdef USE_VV
 	GList *media = NULL;
@@ -323,7 +321,7 @@
 
 	iter = manager->priv->medias;
 	for (; iter; iter = g_list_next(iter)) {
-		if (purple_media_get_connection(iter->data) == pc) {
+		if (purple_media_get_account(iter->data) == account) {
 			media = g_list_prepend(media, iter->data);
 		}
 	}
@@ -497,7 +495,6 @@
 		g_object_unref(info2);
 		return FALSE;
 	}
-	g_object_unref(info2);
 
 	manager->priv->elements =
 			g_list_prepend(manager->priv->elements, info);
@@ -560,7 +557,8 @@
 
 	if (info2 == NULL)
 		purple_media_manager_register_element(manager, info);
-	g_object_unref(info2);
+	else
+		g_object_unref(info2);
 
 	type = purple_media_element_info_get_element_type(info);
 
--- a/libpurple/mediamanager.h	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/mediamanager.h	Fri Apr 10 07:33:31 2009 +0000
@@ -35,7 +35,7 @@
 /** @copydoc _PurpleMediaManagerClass */
 typedef struct _PurpleMediaManagerClass PurpleMediaManagerClass;
 
-#include "connection.h"
+#include "account.h"
 #include "media.h"
 
 G_BEGIN_DECLS
@@ -78,7 +78,7 @@
  * Creates a media session.
  *
  * @param manager The media manager to create the session under.
- * @param gc The connection to create the session on.
+ * @param account The account to create the session on.
  * @param conference_type The conference type to feed into Farsight2.
  * @param remote_user The remote user to initiate the session with.
  *
@@ -87,7 +87,7 @@
  * @since 2.6.0
  */
 PurpleMedia *purple_media_manager_create_media(PurpleMediaManager *manager,
-						PurpleConnection *gc,
+						PurpleAccount *account,
 						const char *conference_type,
 						const char *remote_user,
 						gboolean initiator);
@@ -104,17 +104,17 @@
 GList *purple_media_manager_get_media(PurpleMediaManager *manager);
 
 /**
- * Gets all of the media sessions for a given connection.
+ * Gets all of the media sessions for a given account.
  *
  * @param manager The media manager to get the sessions from.
- * @param pc The connection the sessions are on.
+ * @param account The account the sessions are on.
  *
- * @return A list of the media sessions on the given connection.
+ * @return A list of the media sessions on the given account.
  *
  * @since 2.6.0
  */
-GList *purple_media_manager_get_media_by_connection(
-		PurpleMediaManager *manager, PurpleConnection *pc);
+GList *purple_media_manager_get_media_by_account(
+		PurpleMediaManager *manager, PurpleAccount *account);
 
 /**
  * Removes a media session from the media manager.
--- a/libpurple/plugin.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/plugin.c	Fri Apr 10 07:33:31 2009 +0000
@@ -1201,6 +1201,11 @@
 
 	purple_signals_disconnect_by_handle(handle);
 	purple_signals_unregister_by_instance(handle);
+
+	while (search_paths) {
+		g_free(search_paths->data);
+		search_paths = g_list_delete_link(search_paths, search_paths);
+	}
 }
 
 /**************************************************************************
@@ -1229,6 +1234,21 @@
 }
 
 void
+purple_plugins_unload(PurplePluginType type)
+{
+#ifdef PURPLE_PLUGINS
+	GList *l;
+
+	for (l = plugins; l; l = l->next) {
+		PurplePlugin *plugin = l->data;
+		if (plugin->info->type == type && purple_plugin_is_loaded(plugin))
+			purple_plugin_unload(plugin);
+	}
+
+#endif /* PURPLE_PLUGINS */
+}
+
+void
 purple_plugins_destroy_all(void)
 {
 #ifdef PURPLE_PLUGINS
--- a/libpurple/plugin.h	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/plugin.h	Fri Apr 10 07:33:31 2009 +0000
@@ -503,6 +503,11 @@
 void purple_plugins_unload_all(void);
 
 /**
+ * Unloads all plugins of a specific type.
+ */
+void purple_plugins_unload(PurplePluginType type);
+
+/**
  * Destroys all registered plugins.
  */
 void purple_plugins_destroy_all(void);
--- a/libpurple/plugins/filectl.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/plugins/filectl.c	Fri Apr 10 07:33:31 2009 +0000
@@ -220,7 +220,7 @@
 plugin_load(PurplePlugin *plugin)
 {
 	init_file();
-	check = purple_timeout_add(5000, (GSourceFunc)check_file, NULL);
+	check = purple_timeout_add_seconds(5, (GSourceFunc)check_file, NULL);
 
 	return TRUE;
 }
--- a/libpurple/plugins/joinpart.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/plugins/joinpart.c	Fri Apr 10 07:33:31 2009 +0000
@@ -194,7 +194,7 @@
 	                    PURPLE_CALLBACK(received_chat_msg_cb), users);
 
 	/* Cleanup every 5 minutes */
-	id = purple_timeout_add(1000 * 60 * 5, (GSourceFunc)clean_users_hash, users);
+	id = purple_timeout_add_seconds(60 * 5, (GSourceFunc)clean_users_hash, users);
 
 	data = g_new(gpointer, 2);
 	data[0] = users;
--- a/libpurple/protocols/irc/msgs.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/protocols/irc/msgs.c	Fri Apr 10 07:33:31 2009 +0000
@@ -128,7 +128,7 @@
 
 	irc_blist_timeout(irc);
 	if (!irc->timer)
-		irc->timer = purple_timeout_add(45000, (GSourceFunc)irc_blist_timeout, (gpointer)irc);
+		irc->timer = purple_timeout_add_seconds(45, (GSourceFunc)irc_blist_timeout, (gpointer)irc);
 }
 
 void irc_msg_default(struct irc_conn *irc, const char *name, const char *from, char **args)
--- a/libpurple/protocols/jabber/buddy.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/protocols/jabber/buddy.c	Fri Apr 10 07:33:31 2009 +0000
@@ -1866,7 +1866,7 @@
 	}
 
 	js->pending_buddy_info_requests = g_slist_prepend(js->pending_buddy_info_requests, jbi);
-	jbi->timeout_handle = purple_timeout_add(30000, jabber_buddy_get_info_timeout, jbi);
+	jbi->timeout_handle = purple_timeout_add_seconds(30, jabber_buddy_get_info_timeout, jbi);
 }
 
 void jabber_buddy_get_info(PurpleConnection *gc, const char *who)
--- a/libpurple/protocols/jabber/google.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/protocols/jabber/google.c	Fri Apr 10 07:33:31 2009 +0000
@@ -340,7 +340,8 @@
 	session->remote_jid = jid;
 
 	session->media = purple_media_manager_create_media(
-			purple_media_manager_get(), js->gc,
+			purple_media_manager_get(),
+			purple_connection_get_account(js->gc),
 			"fsrtpconference", session->remote_jid, TRUE);
 
 	purple_media_set_prpl_data(session->media, session);
@@ -389,8 +390,10 @@
 		return;
 	}
 
-	session->media = purple_media_manager_create_media(purple_media_manager_get(), js->gc,
-							   "fsrtpconference", session->remote_jid, FALSE);
+	session->media = purple_media_manager_create_media(
+			purple_media_manager_get(),
+			purple_connection_get_account(js->gc),
+			"fsrtpconference", session->remote_jid, FALSE);
 
 	purple_media_set_prpl_data(session->media, session);
 
@@ -572,8 +575,9 @@
 	if (!id.initiator)
 		return;
 
-	iter = purple_media_manager_get_media_by_connection(
-			purple_media_manager_get(), js->gc);
+	iter = purple_media_manager_get_media_by_account(
+			purple_media_manager_get(),
+			purple_connection_get_account(js->gc));
 	for (; iter; iter = g_list_delete_link(iter, iter)) {
 		GoogleSession *gsession =
 				purple_media_get_prpl_data(iter->data);
--- a/libpurple/protocols/jabber/jabber.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Fri Apr 10 07:33:31 2009 +0000
@@ -2614,7 +2614,7 @@
 
 #ifdef USE_VV
 typedef struct {
-	PurpleConnection *pc;
+	PurpleAccount *account;
 	gchar *who;
 	PurpleMediaSessionType type;
 	
@@ -2637,7 +2637,7 @@
 	GList *labels = purple_request_field_choice_get_labels(field);
 	gchar *who = g_strdup_printf("%s/%s", request->who,
 			(gchar*)g_list_nth_data(labels, selected_id));
-	jabber_initiate_media(request->pc, who, request->type);
+	jabber_initiate_media(request->account, who, request->type);
 
 	g_free(who);
 	g_free(request->who);
@@ -2646,11 +2646,12 @@
 #endif
 
 gboolean
-jabber_initiate_media(PurpleConnection *gc, const char *who, 
+jabber_initiate_media(PurpleAccount *account, const char *who, 
 		      PurpleMediaSessionType type)
 {
 #ifdef USE_VV
-	JabberStream *js = (JabberStream *) gc->proto_data;
+	JabberStream *js = (JabberStream *)
+			purple_account_get_connection(account)->proto_data;
 	JabberBuddy *jb;
 	JabberBuddyResource *jbr = NULL;
 	char *resource;
@@ -2675,11 +2676,9 @@
 				JINGLE_APP_RTP_SUPPORT_AUDIO) &&
 				jabber_resource_has_capability(jbr,
 				GOOGLE_VOICE_CAP))
-			return jabber_google_session_initiate(
-					gc->proto_data, who, type);
+			return jabber_google_session_initiate(js, who, type);
 		else
-			return jingle_rtp_initiate_media(
-					gc->proto_data, who, type);
+			return jingle_rtp_initiate_media(js, who, type);
 	}
 
 	jb = jabber_buddy_find(js, who, FALSE);
@@ -2698,7 +2697,7 @@
 			msg = g_strdup_printf(_("Unable to initiate media with %s: not subscribed to user presence"), who);
 		}
 
-		purple_notify_error(js->gc, _("Media Initiation Failed"),
+		purple_notify_error(account, _("Media Initiation Failed"),
 				_("Media Initiation Failed"), msg);
 		g_free(msg);
 		return FALSE;
@@ -2709,7 +2708,7 @@
 		gboolean result;
 		jbr = jb->resources->data;
 		name = g_strdup_printf("%s/%s", who, jbr->name);
-		result = jabber_initiate_media(gc, name, type);
+		result = jabber_initiate_media(account, name, type);
 		g_free(name);
 		return result;
 	} else {
@@ -2729,7 +2728,7 @@
 			PurpleMediaCaps caps;
 			gchar *name;
 			name = g_strdup_printf("%s/%s", who, ljbr->name);
-			caps = jabber_get_media_caps(gc, name);
+			caps = jabber_get_media_caps(account, name);
 			g_free(name);
 
 			if ((type & PURPLE_MEDIA_AUDIO) &&
@@ -2764,7 +2763,7 @@
 			gboolean result;
 			purple_request_field_destroy(field);
 			name = g_strdup_printf("%s/%s", who, jbr->name);
-			result = jabber_initiate_media(gc, name, type);
+			result = jabber_initiate_media(account, name, type);
 			g_free(name);
 			return result;
 		}
@@ -2773,17 +2772,17 @@
 		fields = purple_request_fields_new();
 		group =	purple_request_field_group_new(NULL);
 		request = g_new0(JabberMediaRequest, 1);
-		request->pc = gc;
+		request->account = account;
 		request->who = g_strdup(who);
 		request->type = type;
 
 		purple_request_field_group_add_field(group, field);
 		purple_request_fields_add_group(fields, group);
-		purple_request_fields(gc, _("Select a Resource"), msg, NULL,
-				fields,	_("Initiate Media"),
+		purple_request_fields(account, _("Select a Resource"), msg,
+				NULL, fields, _("Initiate Media"),
 				G_CALLBACK(jabber_media_ok_cb), _("Cancel"),
 				G_CALLBACK(jabber_media_cancel_cb),
-				gc->account, who, NULL, request);
+				account, who, NULL, request);
 
 		g_free(msg);
 		return TRUE;
@@ -2792,10 +2791,11 @@
 	return FALSE;
 }
 
-PurpleMediaCaps jabber_get_media_caps(PurpleConnection *gc, const char *who)
+PurpleMediaCaps jabber_get_media_caps(PurpleAccount *account, const char *who)
 {
 #ifdef USE_VV
-	JabberStream *js = (JabberStream *) gc->proto_data;
+	JabberStream *js = (JabberStream *)
+			purple_account_get_connection(account)->proto_data;
 	JabberBuddy *jb;
 	JabberBuddyResource *jbr;
 	PurpleMediaCaps caps = PURPLE_MEDIA_CAPS_NONE;
@@ -2861,7 +2861,7 @@
 		gchar *name;
 		jbr = jb->resources->data;
 		name = g_strdup_printf("%s/%s", who, jbr->name);
-		caps = jabber_get_media_caps(gc, name);
+		caps = jabber_get_media_caps(account, name);
 		g_free(name);
 	} else {
 		/* we've got multiple resources, combine their caps */
@@ -2872,7 +2872,7 @@
 			gchar *name;
 			jbr = l->data;
 			name = g_strdup_printf("%s/%s", who, jbr->name);
-			caps |= jabber_get_media_caps(gc, name);
+			caps |= jabber_get_media_caps(account, name);
 			g_free(name);
 		}
 	}
--- a/libpurple/protocols/jabber/jabber.h	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/protocols/jabber/jabber.h	Fri Apr 10 07:33:31 2009 +0000
@@ -323,9 +323,9 @@
 gboolean jabber_offline_message(const PurpleBuddy *buddy);
 int jabber_prpl_send_raw(PurpleConnection *gc, const char *buf, int len);
 GList *jabber_actions(PurplePlugin *plugin, gpointer context);
-gboolean jabber_initiate_media(PurpleConnection *gc, const char *who,
+gboolean jabber_initiate_media(PurpleAccount *account, const char *who,
 		PurpleMediaSessionType type);
-PurpleMediaCaps jabber_get_media_caps(PurpleConnection *gc, const char *who);
+PurpleMediaCaps jabber_get_media_caps(PurpleAccount *account, const char *who);
 void jabber_register_commands(void);
 void jabber_init_plugin(PurplePlugin *plugin);
 
--- a/libpurple/protocols/jabber/jingle/rtp.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/protocols/jabber/jingle/rtp.c	Fri Apr 10 07:33:31 2009 +0000
@@ -204,8 +204,9 @@
 {
 	JabberStream *js = jingle_session_get_js(session);
 	PurpleMedia *media = NULL;
-	GList *iter = purple_media_manager_get_media_by_connection(
-			purple_media_manager_get(), js->gc);
+	GList *iter = purple_media_manager_get_media_by_account(
+			purple_media_manager_get(),
+			purple_connection_get_account(js->gc));
 
 	for (; iter; iter = g_list_delete_link(iter, iter)) {
 		JingleSession *media_session =
@@ -466,6 +467,9 @@
 {
 	purple_debug_info("jingle-rtp", "stream-info: type %d "
 			"id: %s name: %s\n", type, sid, name);
+
+	g_return_if_fail(JINGLE_IS_SESSION(session));
+
 	if (type == PURPLE_MEDIA_INFO_HANGUP) {
 		jabber_iq_send(jingle_session_terminate_packet(
 				session, "success"));
@@ -518,9 +522,11 @@
 	JabberStream *js = jingle_session_get_js(session);
 	gchar *remote_jid = jingle_session_get_remote_jid(session);
 
-	PurpleMedia *media = purple_media_manager_create_media(purple_media_manager_get(), 
-						  js->gc, "fsrtpconference", remote_jid,
-						  jingle_session_is_initiator(session));
+	PurpleMedia *media = purple_media_manager_create_media(
+			purple_media_manager_get(), 
+			purple_connection_get_account(js->gc),
+			"fsrtpconference", remote_jid,
+			jingle_session_is_initiator(session));
 	g_free(remote_jid);
 
 	if (!media) {
--- a/libpurple/protocols/msn/msg.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/protocols/msn/msg.c	Fri Apr 10 07:33:31 2009 +0000
@@ -984,3 +984,67 @@
 	g_hash_table_destroy(body);
 }
 
+void
+msn_invite_msg(MsnCmdProc *cmdproc, MsnMessage *msg)
+{
+	GHashTable *body;
+	const gchar *guid;
+
+	g_return_if_fail(cmdproc != NULL);
+	g_return_if_fail(msg != NULL);
+
+	body = msn_message_get_hashtable_from_body(msg);
+
+	if (body == NULL) {
+		purple_debug_warning("msn",
+				"Unable to parse invite msg body.\n");
+		return;
+	}
+
+	guid = g_hash_table_lookup(body, "Application-GUID");
+
+	if (guid == NULL) {
+		const gchar *cmd = g_hash_table_lookup(
+				body, "Invitation-Command");
+
+		if (cmd && !strcmp(cmd, "CANCEL")) {
+			const gchar *code = g_hash_table_lookup(
+					body, "Cancel-Code");
+			purple_debug_info("msn",
+					"MSMSGS invitation cancelled: %s.\n",
+					code ? code : "no reason given");
+		} else
+			purple_debug_warning("msn", "Invite msg missing "
+					"Application-GUID.\n");
+	} else if (!strcmp(guid, "{02D3C01F-BF30-4825-A83A-DE7AF41648AA}")) {
+		purple_debug_info("msn", "Computer call\n");
+
+		if (cmdproc->session) {
+			PurpleConversation *conv = NULL;
+			gchar *from = msg->remote_user;
+			gchar *buf = NULL;
+
+			if (from)
+				conv = purple_find_conversation_with_account(
+						PURPLE_CONV_TYPE_IM, from,
+						cmdproc->session->account);
+			if (conv)
+				buf = g_strdup_printf(
+						_("%s sent you a voice chat "
+						"invite, which is not yet "
+						"supported."), from);
+			if (buf) {
+				purple_conversation_write(conv, NULL, buf,
+						PURPLE_MESSAGE_SYSTEM |
+						PURPLE_MESSAGE_NOTIFY,
+						time(NULL));
+				g_free(buf);
+			}
+		}
+	} else
+		purple_debug_warning("msn",
+				"Unhandled invite msg with GUID %s.\n", guid);
+
+	g_hash_table_destroy(body);
+}
+
--- a/libpurple/protocols/msn/msn.h	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/protocols/msn/msn.h	Fri Apr 10 07:33:31 2009 +0000
@@ -76,6 +76,8 @@
 
 #define BUDDY_ALIAS_MAXLEN 387
 
+#define MSN_CAM_GUID "4BD96FC0-AB17-4425-A14A-439185962DC8"
+#define MSN_CAM_REQUEST_GUID "1C9AA97E-9C05-4583-A3BD-908A196F1E92"
 #define MSN_FT_GUID "5D3E02AB-6190-11D3-BBBB-00C04F795683"
 #define MSN_OBJ_GUID "A4268EEC-FEC5-49E5-95C3-F126696BDBF6"
 
--- a/libpurple/protocols/msn/slp.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/protocols/msn/slp.c	Fri Apr 10 07:33:31 2009 +0000
@@ -377,6 +377,50 @@
 
 			purple_xfer_request(xfer);
 		}
+	} else if (!strcmp(euf_guid, MSN_CAM_REQUEST_GUID)) {
+		purple_debug_info("msn", "Cam request.\n");
+		if (slpcall && slpcall->slplink &&
+				slpcall->slplink->session) {
+			PurpleConversation *conv;
+			gchar *from = slpcall->slplink->remote_user;
+			conv = purple_find_conversation_with_account(
+					PURPLE_CONV_TYPE_IM, from,
+					slpcall->slplink->session->account);
+			if (conv) {
+				char *buf;
+				buf = g_strdup_printf(
+						_("%s requests to view your "
+						"webcam, but this request is "
+						"not yet supported."), from);
+				purple_conversation_write(conv, NULL, buf,
+						PURPLE_MESSAGE_SYSTEM |
+						PURPLE_MESSAGE_NOTIFY,
+						time(NULL));
+				g_free(buf);
+			}
+		}
+	} else if (!strcmp(euf_guid, MSN_CAM_GUID)) {
+		purple_debug_info("msn", "Cam invite.\n");
+		if (slpcall && slpcall->slplink &&
+				slpcall->slplink->session) {
+			PurpleConversation *conv;
+			gchar *from = slpcall->slplink->remote_user;
+			conv = purple_find_conversation_with_account(
+					PURPLE_CONV_TYPE_IM, from,
+					slpcall->slplink->session->account);
+			if (conv) {
+				char *buf;
+				buf = g_strdup_printf(
+						_("%s has sent you a webcam "
+						"invite, which is not yet "
+						"supported."), from);
+				purple_conversation_write(conv, NULL, buf,
+						PURPLE_MESSAGE_SYSTEM |
+						PURPLE_MESSAGE_NOTIFY,
+						time(NULL));
+				g_free(buf);
+			}
+		}
 	} else
 		purple_debug_warning("msn", "SLP SessionReq with unknown EUF-GUID: %s\n", euf_guid);
 }
--- a/libpurple/protocols/msn/switchboard.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/protocols/msn/switchboard.c	Fri Apr 10 07:33:31 2009 +0000
@@ -1237,10 +1237,8 @@
 	                       msn_emoticon_msg);
 	msn_table_add_msg_type(cbs_table, "text/x-msnmsgr-datacast",
 						   msn_datacast_msg);
-#if 0
-	msn_table_add_msg_type(cbs_table, "text/x-msmmsginvite",
+	msn_table_add_msg_type(cbs_table, "text/x-msmsgsinvite",
 						   msn_invite_msg);
-#endif
 }
 
 void
--- a/libpurple/protocols/msnp9/httpconn.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/protocols/msnp9/httpconn.c	Fri Apr 10 07:33:31 2009 +0000
@@ -703,7 +703,7 @@
 		httpconn->inpa = purple_input_add(httpconn->fd, PURPLE_INPUT_READ,
 			read_cb, data);
 
-		httpconn->timer = purple_timeout_add(2000, msn_httpconn_poll, httpconn);
+		httpconn->timer = purple_timeout_add_seconds(3, msn_httpconn_poll, httpconn);
 
 		msn_httpconn_process_queue(httpconn);
 	}
--- a/libpurple/protocols/msnp9/slp.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/protocols/msnp9/slp.c	Fri Apr 10 07:33:31 2009 +0000
@@ -33,8 +33,8 @@
 
 #include "smiley.h"
 
-/* ms to delay between sending buddy icon requests to the server. */
-#define BUDDY_ICON_DELAY 20000
+/* Seconds to delay between sending buddy icon requests to the server. */
+#define BUDDY_ICON_DELAY 20
 
 static void send_ok(MsnSlpCall *slpcall, const char *branch,
 					const char *type, const char *content);
@@ -1058,8 +1058,8 @@
 		purple_timeout_remove(userlist->buddy_icon_request_timer);
 	}
 
-	/* Wait BUDDY_ICON_DELAY ms before freeing our window slot and requesting the next icon. */
-	userlist->buddy_icon_request_timer = purple_timeout_add(BUDDY_ICON_DELAY, 
+	/* Wait BUDDY_ICON_DELAY_S seconds before freeing our window slot and requesting the next icon. */
+	userlist->buddy_icon_request_timer = purple_timeout_add_seconds(BUDDY_ICON_DELAY, 
 														  msn_release_buddy_icon_request_timeout, userlist);
 }
 
--- a/libpurple/protocols/msnp9/slpcall.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/protocols/msnp9/slpcall.c	Fri Apr 10 07:33:31 2009 +0000
@@ -68,7 +68,7 @@
 
 	msn_slplink_add_slpcall(slplink, slpcall);
 
-	slpcall->timer = purple_timeout_add(MSN_SLPCALL_TIMEOUT, msn_slp_call_timeout, slpcall);
+	slpcall->timer = purple_timeout_add_seconds(MSN_SLPCALL_TIMEOUT, msn_slp_call_timeout, slpcall);
 
 	return slpcall;
 }
--- a/libpurple/protocols/msnp9/slpcall.h	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/protocols/msnp9/slpcall.h	Fri Apr 10 07:33:31 2009 +0000
@@ -33,7 +33,7 @@
 #include "slpsession.h"
 
 /* The official client seems to timeout slp calls after 5 minutes */
-#define MSN_SLPCALL_TIMEOUT 300000
+#define MSN_SLPCALL_TIMEOUT 300
 
 typedef enum
 {
--- a/libpurple/protocols/msnp9/transaction.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/protocols/msnp9/transaction.c	Fri Apr 10 07:33:31 2009 +0000
@@ -211,7 +211,7 @@
 		purple_timeout_remove(trans->timer);
 	}
 	trans->timeout_cb = cb;
-	trans->timer = purple_timeout_add(60000, transaction_timeout, trans);
+	trans->timer = purple_timeout_add_seconds(60, transaction_timeout, trans);
 }
 
 void
--- a/libpurple/protocols/myspace/myspace.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/protocols/myspace/myspace.c	Fri Apr 10 07:33:31 2009 +0000
@@ -1245,7 +1245,7 @@
 
 	/* Disable due to problems with timeouts. TODO: fix. */
 #ifdef MSIM_USE_KEEPALIVE
-	purple_timeout_add(MSIM_KEEPALIVE_INTERVAL_CHECK,
+	purple_timeout_add_seconds(MSIM_KEEPALIVE_INTERVAL_CHECK,
 			(GSourceFunc)msim_check_alive, session);
 #endif
 
--- a/libpurple/protocols/myspace/myspace.h	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/protocols/myspace/myspace.h	Fri Apr 10 07:33:31 2009 +0000
@@ -114,8 +114,8 @@
 #define MSIM_KEEPALIVE_INTERVAL     (3 * 60)
 /*#define MSIM_USE_KEEPALIVE*/
 
-/* Time to check if alive (milliseconds) */
-#define MSIM_KEEPALIVE_INTERVAL_CHECK   (30 * 1000)
+/* Time to check if alive (seconds) */
+#define MSIM_KEEPALIVE_INTERVAL_CHECK   30
 
 /* Time to check for new mail (milliseconds) */
 #define MSIM_MAIL_INTERVAL_CHECK    (60 * 1000)
--- a/libpurple/protocols/oscar/oscar.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Fri Apr 10 07:33:31 2009 +0000
@@ -1268,7 +1268,7 @@
 	aim_ssi_reqdata(od);
 	if (od->getblisttimer > 0)
 		purple_timeout_remove(od->getblisttimer);
-	od->getblisttimer = purple_timeout_add(30000, purple_ssi_rerequestdata, od);
+	od->getblisttimer = purple_timeout_add_seconds(30, purple_ssi_rerequestdata, od);
 
 	aim_locate_reqrights(od);
 	aim_buddylist_reqrights(od, conn);
@@ -5047,7 +5047,7 @@
 					_("The AIM servers were temporarily unable to send "
 					"your buddy list.  Your buddy list is not lost, and "
 					"will probably become available in a few minutes."));
-		od->getblisttimer = purple_timeout_add(30000, purple_ssi_rerequestdata, od);
+		od->getblisttimer = purple_timeout_add_seconds(30, purple_ssi_rerequestdata, od);
 		return 1;
 	}
 
--- a/libpurple/protocols/oscar/peer.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/protocols/oscar/peer.c	Fri Apr 10 07:33:31 2009 +0000
@@ -812,7 +812,7 @@
 			(conn->client_connect_data != NULL))
 		{
 			/* Connecting... */
-			conn->connect_timeout_timer = purple_timeout_add(5000,
+			conn->connect_timeout_timer = purple_timeout_add_seconds(5,
 					peer_connection_tooktoolong, conn);
 			return;
 		}
--- a/libpurple/protocols/sametime/sametime.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/protocols/sametime/sametime.c	Fri Apr 10 07:33:31 2009 +0000
@@ -808,7 +808,7 @@
 static void blist_schedule(struct mwPurplePluginData *pd) {
   if(pd->save_event) return;
 
-  pd->save_event = purple_timeout_add(BLIST_SAVE_SECONDS * 1000,
+  pd->save_event = purple_timeout_add_seconds(BLIST_SAVE_SECONDS,
 				    blist_save_cb, pd);
 }
 
--- a/libpurple/protocols/yahoo/yahoo.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/protocols/yahoo/yahoo.c	Fri Apr 10 07:33:31 2009 +0000
@@ -2829,6 +2829,7 @@
 	p2p_data->host_username = g_strdup(who);
 	p2p_data->val_13 = val_13;
 	p2p_data->connection_type = YAHOO_P2P_WE_ARE_SERVER;
+	p2p_data->source = -1;
 
 	purple_network_listen(YAHOO_PAGER_PORT_P2P, SOCK_STREAM, yahoo_p2p_server_listen_cb, p2p_data);
 
@@ -2932,10 +2933,9 @@
 
 	if (base64) {
 		guint32 ip;
-		char *tmp2;
 		YahooFriend *f;
 		char *host_ip;
-		struct yahoo_p2p_data *p2p_data = g_new0(struct yahoo_p2p_data, 1);
+		struct yahoo_p2p_data *p2p_data;
 
 		decoded = purple_base64_decode(base64, &len);
 		if (len) {
@@ -2944,9 +2944,7 @@
 			g_free(tmp);
 		}
 
-		tmp2 = g_strndup((const gchar *)decoded, len); /* so its \0 terminated...*/
-		ip = strtol(tmp2, NULL, 10);
-		g_free(tmp2);
+		ip = strtol((gchar *)decoded, NULL, 10);
 		g_free(decoded);
 		host_ip = g_strdup_printf("%u.%u.%u.%u", ip & 0xff, (ip >> 8) & 0xff, (ip >> 16) & 0xff,
 		                       (ip >> 24) & 0xff);
@@ -2964,12 +2962,14 @@
 				val_11 = f->session_id;
 		}
 
-		p2p_data->host_username = g_strdup(who);	
+		p2p_data = g_new0(struct yahoo_p2p_data, 1);
+		p2p_data->host_username = g_strdup(who);
 		p2p_data->val_13 = val_13;
 		p2p_data->session_id = val_11;
 		p2p_data->host_ip = host_ip;
 		p2p_data->gc = gc;
 		p2p_data->connection_type = YAHOO_P2P_WE_ARE_CLIENT;
+		p2p_data->source = -1;
 
 		/* connect to host */
 		if((purple_proxy_connect(NULL, account, host_ip, YAHOO_PAGER_PORT_P2P, yahoo_p2p_init_cb, p2p_data))==NULL)	{
--- a/libpurple/protocols/zephyr/zephyr.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/protocols/zephyr/zephyr.c	Fri Apr 10 07:33:31 2009 +0000
@@ -1880,7 +1880,7 @@
 	} else if (use_tzc(zephyr)) {
 		zephyr->nottimer = purple_timeout_add(100, check_notify_tzc, gc);
 	} 
-	zephyr->loctimer = purple_timeout_add(20000, check_loc, gc); 
+	zephyr->loctimer = purple_timeout_add_seconds(20, check_loc, gc); 
 
 }
 
--- a/libpurple/prpl.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/prpl.c	Fri Apr 10 07:33:31 2009 +0000
@@ -515,7 +515,7 @@
 
 	if (prpl_info && PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, initiate_media)) {
 		/* should check that the protocol supports this media type here? */
-		return prpl_info->initiate_media(gc, who, type);
+		return prpl_info->initiate_media(account, who, type);
 	} else
 #endif
 	return FALSE;
@@ -538,7 +538,7 @@
 	
 	if (prpl_info && PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info,
 			get_media_caps)) {
-		return prpl_info->get_media_caps(gc, who);
+		return prpl_info->get_media_caps(account, who);
 	}
 #endif
 	return PURPLE_MEDIA_CAPS_NONE;
--- a/libpurple/prpl.h	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/prpl.h	Fri Apr 10 07:33:31 2009 +0000
@@ -464,22 +464,22 @@
 	/**
 	 * Initiate a media session with the given contact.
 	 *
-	 * @param conn The connection to initiate the media session on.
+	 * @param account The account to initiate the media session on.
 	 * @param who The remote user to initiate the session with.
 	 * @param type The type of media session to initiate.
 	 * @return TRUE if the call succeeded else FALSE. (Doesn't imply the media session or stream will be successfully created)
 	 */
-	gboolean (*initiate_media)(PurpleConnection *gc, const char *who,
+	gboolean (*initiate_media)(PurpleAccount *account, const char *who,
 					PurpleMediaSessionType type);
 
 	/**
 	 * Checks to see if the given contact supports the given type of media session.
 	 *
-	 * @param conn The connection the contact is on.
+	 * @param account The account the contact is on.
 	 * @param who The remote user to check for media capability with.
 	 * @return The media caps the contact supports.
 	 */
-	PurpleMediaCaps (*get_media_caps)(PurpleConnection *gc,
+	PurpleMediaCaps (*get_media_caps)(PurpleAccount *account,
 					  const char *who);
 };
 
--- a/libpurple/win32/win32dep.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/libpurple/win32/win32dep.c	Fri Apr 10 07:33:31 2009 +0000
@@ -467,7 +467,14 @@
 	WSACleanup();
 
 	g_free(app_data_dir);
+	g_free(install_dir);
+	g_free(lib_dir);
+	g_free(locale_dir);
+
 	app_data_dir = NULL;
+	install_dir = NULL;
+	lib_dir = NULL;
+	locale_dir = NULL;
 
 	libpurpledll_hInstance = NULL;
 }
--- a/pidgin/gtkblist.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/pidgin/gtkblist.c	Fri Apr 10 07:33:31 2009 +0000
@@ -5509,6 +5509,7 @@
 	GtkWidget *sep;
 	GtkWidget *label;
 	char *pretty, *tmp;
+	const char *theme_name;
 	GtkAccelGroup *accel_group;
 	GtkTreeSelection *selection;
 	GtkTargetEntry dte[] = {{"PURPLE_BLIST_NODE", GTK_TARGET_SAME_APP, DRAG_ROW},
@@ -5527,7 +5528,11 @@
 	gtkblist = PIDGIN_BLIST(list);
 	priv = PIDGIN_BUDDY_LIST_GET_PRIVATE(gtkblist);
 
-	priv->current_theme = PIDGIN_BLIST_THEME(purple_theme_manager_find_theme(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/blist/theme"), "blist"));
+	theme_name = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/blist/theme");
+	if (theme_name && *theme_name)
+		priv->current_theme = PIDGIN_BLIST_THEME(purple_theme_manager_find_theme(theme_name, "blist"));
+	else
+		priv->current_theme = NULL;
 
 	gtkblist->empty_avatar = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 32, 32);
 	gdk_pixbuf_fill(gtkblist->empty_avatar, 0x00000000);
@@ -5794,7 +5799,7 @@
 	purple_blist_set_visible(purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/list_visible"));
 
 	/* start the refresh timer */
-	gtkblist->refresh_timer = g_timeout_add(30000, (GSourceFunc)pidgin_blist_refresh_timer, list);
+	gtkblist->refresh_timer = purple_timeout_add_seconds(30, (GSourceFunc)pidgin_blist_refresh_timer, list);
 
 	handle = pidgin_blist_get_handle();
 
@@ -5915,7 +5920,7 @@
 	blist = purple_get_blist();
 	gtkblist = PIDGIN_BLIST(purple_get_blist());
 
-	gtkblist->refresh_timer = g_timeout_add(30000,(GSourceFunc)pidgin_blist_refresh_timer, blist);
+	gtkblist->refresh_timer = purple_timeout_add_seconds(30,(GSourceFunc)pidgin_blist_refresh_timer, blist);
 }
 
 static gboolean get_iter_from_node(PurpleBlistNode *node, GtkTreeIter *iter) {
@@ -6636,7 +6641,7 @@
 	pidgin_blist_tooltip_destroy();
 
 	if (gtkblist->refresh_timer)
-		g_source_remove(gtkblist->refresh_timer);
+		purple_timeout_remove(gtkblist->refresh_timer);
 	if (gtkblist->timeout)
 		g_source_remove(gtkblist->timeout);
 	if (gtkblist->drag_timeout)
@@ -7451,7 +7456,7 @@
 
 	if(gtknode->recent_signonoff_timer > 0)
 		purple_timeout_remove(gtknode->recent_signonoff_timer);
-	gtknode->recent_signonoff_timer = purple_timeout_add(10000,
+	gtknode->recent_signonoff_timer = purple_timeout_add_seconds(10,
 			(GSourceFunc)buddy_signonoff_timeout_cb, buddy);
 }
 
--- a/pidgin/gtkconv.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/pidgin/gtkconv.c	Fri Apr 10 07:33:31 2009 +0000
@@ -7523,7 +7523,7 @@
 	}
 
 	/* In case a conversation is started after the buddy has signed-on/off */
-	g_timeout_add(11000, (GSourceFunc)update_buddy_status_timeout, buddy);
+	purple_timeout_add_seconds(11, (GSourceFunc)update_buddy_status_timeout, buddy);
 }
 
 static void
--- a/pidgin/gtkdebug.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/pidgin/gtkdebug.c	Fri Apr 10 07:33:31 2009 +0000
@@ -94,7 +94,7 @@
 	if(debug_win->timer != 0) {
 		const gchar *text;
 
-		g_source_remove(debug_win->timer);
+		purple_timeout_remove(debug_win->timer);
 
 		text = gtk_entry_get_text(GTK_ENTRY(debug_win->expression));
 		purple_prefs_set_string(PIDGIN_PREFS_ROOT "/debug/regex", text);
@@ -552,7 +552,7 @@
 	}
 
 	if(win->timer == 0)
-		win->timer = purple_timeout_add(5000, (GSourceFunc)regex_timer_cb, win);
+		win->timer = purple_timeout_add_seconds(5, (GSourceFunc)regex_timer_cb, win);
 
 	regex_compile(win);
 }
--- a/pidgin/gtkmedia.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/pidgin/gtkmedia.c	Fri Apr 10 07:33:31 2009 +0000
@@ -97,7 +97,6 @@
 	GtkWidget *recv_widget;
 	GtkWidget *local_video;
 	GtkWidget *remote_video;
-	PurpleConnection *pc;
 
 	guint timeout_id;
 	PurpleMediaSessionType request_type;
@@ -432,7 +431,7 @@
 {
 	PurpleConversation *conv = purple_find_conversation_with_account(
 			PURPLE_CONV_TYPE_ANY, gtkmedia->priv->screenname,
-			purple_connection_get_account(gtkmedia->priv->pc));
+			purple_media_get_account(gtkmedia->priv->media));
 	if (conv != NULL)
 		purple_conversation_write(conv, NULL, msg,
 				PURPLE_MESSAGE_SYSTEM, time(NULL));
@@ -476,7 +475,7 @@
 {
 	PurpleConversation *conv = purple_find_conversation_with_account(
 			PURPLE_CONV_TYPE_ANY, gtkmedia->priv->screenname,
-			purple_connection_get_account(gtkmedia->priv->pc));
+			purple_media_get_account(gtkmedia->priv->media));
 	if (conv != NULL)
 		purple_conversation_write(conv, NULL, error,
 				PURPLE_MESSAGE_ERROR, time(NULL));
@@ -512,15 +511,14 @@
 static gboolean
 pidgin_request_timeout_cb(PidginMedia *gtkmedia)
 {
-	PurpleConnection *pc;
+	PurpleAccount *account;
 	PurpleBuddy *buddy;
 	const gchar *alias;
 	PurpleMediaSessionType type;
 	gchar *message = NULL;
 
-	pc = purple_media_get_connection(gtkmedia->priv->media);
-	buddy = purple_find_buddy(purple_connection_get_account(pc),
-			gtkmedia->priv->screenname);
+	account = purple_media_get_account(gtkmedia->priv->media);
+	buddy = purple_find_buddy(account, gtkmedia->priv->screenname);
 	alias = buddy ? purple_buddy_get_contact_alias(buddy) :
 			gtkmedia->priv->screenname;
 	type = gtkmedia->priv->request_type;
@@ -541,7 +539,7 @@
 
 	purple_request_accept_cancel(gtkmedia, "Media invitation",
 			message, NULL, PURPLE_DEFAULT_ACTION_NONE,
-			(void*)pc, gtkmedia->priv->screenname, NULL,
+			(void*)account, gtkmedia->priv->screenname, NULL,
 			gtkmedia->priv->media,
 			pidgin_media_accept_cb,
 			pidgin_media_reject_cb);
@@ -551,21 +549,97 @@
 }
 
 static void
+#if GTK_CHECK_VERSION(2,12,0)
+pidgin_media_input_volume_changed(GtkScaleButton *range, double value,
+		PurpleMedia *media)
+{
+	double val = (double)value * 100.0;
+#else
 pidgin_media_input_volume_changed(GtkRange *range, PurpleMedia *media)
 {
 	double val = (double)gtk_range_get_value(GTK_RANGE(range));
+#endif
 	purple_prefs_set_int("/pidgin/media/audio/volume/input", val);
-	val /= 10.0;
-	purple_media_set_input_volume(media, NULL, val);
+	purple_media_set_input_volume(media, NULL, val / 10.0);
 }
 
 static void
+#if GTK_CHECK_VERSION(2,12,0)
+pidgin_media_output_volume_changed(GtkScaleButton *range, double value,
+		PurpleMedia *media)
+{
+	double val = (double)value * 100.0;
+#else
 pidgin_media_output_volume_changed(GtkRange *range, PurpleMedia *media)
 {
 	double val = (double)gtk_range_get_value(GTK_RANGE(range));
+#endif
 	purple_prefs_set_int("/pidgin/media/audio/volume/output", val);
-	val /= 10.0;
-	purple_media_set_output_volume(media, NULL, NULL, val);
+	purple_media_set_output_volume(media, NULL, NULL, val / 10.0);
+}
+
+static GtkWidget *
+pidgin_media_add_audio_widget(PidginMedia *gtkmedia,
+		PurpleMediaSessionType type)
+{
+	GtkWidget *volume_widget, *progress_parent, *volume, *progress;
+	double value;
+
+	if (type & PURPLE_MEDIA_SEND_AUDIO) {
+		value = purple_prefs_get_int(
+			"/pidgin/media/audio/volume/input");
+	} else if (type & PURPLE_MEDIA_RECV_AUDIO) {
+		value = purple_prefs_get_int(
+			"/pidgin/media/audio/volume/output");
+	} else
+		g_return_val_if_reached(NULL);
+
+#if GTK_CHECK_VERSION(2,12,0)
+	/* Setup widget structure */
+	volume_widget = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
+	progress_parent = gtk_vbox_new(FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(volume_widget),
+			progress_parent, TRUE, TRUE, 0);
+
+	/* Volume button */
+	volume = gtk_volume_button_new();
+	gtk_scale_button_set_value(GTK_SCALE_BUTTON(volume), value/100.0);
+	gtk_box_pack_end(GTK_BOX(volume_widget),
+			volume, FALSE, FALSE, 0);
+#else
+	/* Setup widget structure */
+	volume_widget = gtk_vbox_new(FALSE, 0);
+	progress_parent = volume_widget;
+
+	/* Volume slider */
+	volume = gtk_hscale_new_with_range(0.0, 100.0, 5.0);
+	gtk_range_set_increments(GTK_RANGE(volume), 5.0, 25.0);
+	gtk_range_set_value(GTK_RANGE(volume), value);
+	gtk_scale_set_draw_value(GTK_SCALE(volume), FALSE);
+	gtk_box_pack_end(GTK_BOX(volume_widget),
+			volume, TRUE, FALSE, 0);
+#endif
+
+	/* Volume level indicator */
+	progress = gtk_progress_bar_new();
+	gtk_widget_set_size_request(progress, 250, 10);
+	gtk_box_pack_end(GTK_BOX(progress_parent), progress, TRUE, FALSE, 0);
+
+	if (type & PURPLE_MEDIA_SEND_AUDIO) {
+		g_signal_connect (G_OBJECT(volume), "value-changed",
+				G_CALLBACK(pidgin_media_input_volume_changed),
+				gtkmedia->priv->media);
+		gtkmedia->priv->send_progress = progress;
+	} else if (type & PURPLE_MEDIA_RECV_AUDIO) {
+		g_signal_connect (G_OBJECT(volume), "value-changed",
+				G_CALLBACK(pidgin_media_output_volume_changed),
+				gtkmedia->priv->media);
+		gtkmedia->priv->recv_progress = progress;
+	}
+
+	gtk_widget_show_all(volume_widget);
+
+	return volume_widget;
 }
 
 static void
@@ -651,28 +725,13 @@
 	}
 
 	if (type & PURPLE_MEDIA_RECV_AUDIO) {
-		GtkWidget *volume = gtk_hscale_new_with_range(0.0, 100.0, 5.0);
-		gtk_range_set_increments(GTK_RANGE(volume), 5.0, 25.0);
-		gtk_range_set_value(GTK_RANGE(volume),
-				purple_prefs_get_int(
-				"/pidgin/media/audio/volume/output"));
-		gtk_scale_set_draw_value(GTK_SCALE(volume), FALSE);
-		g_signal_connect (G_OBJECT(volume), "value-changed",
-				G_CALLBACK(pidgin_media_output_volume_changed),
-				media);
 		gtk_box_pack_end(GTK_BOX(recv_widget),
-				volume, FALSE, FALSE, 0);
-		gtk_widget_show(volume);
-
-		gtkmedia->priv->recv_progress = gtk_progress_bar_new();
-		gtk_widget_set_size_request(gtkmedia->priv->recv_progress, 320, 10);
-		gtk_box_pack_end(GTK_BOX(recv_widget),
-				   gtkmedia->priv->recv_progress, FALSE, FALSE, 0);
-		gtk_widget_show(gtkmedia->priv->recv_progress);
+				pidgin_media_add_audio_widget(gtkmedia,
+				PURPLE_MEDIA_RECV_AUDIO), FALSE, FALSE, 0);
 	}
 	if (type & PURPLE_MEDIA_SEND_AUDIO) {
 		GstElement *media_src;
-		GtkWidget *hbox, *volume;
+		GtkWidget *hbox;
 
 		hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
 		gtk_box_pack_end(GTK_BOX(send_widget), hbox, FALSE, FALSE, 0);
@@ -686,28 +745,13 @@
 		gtk_widget_show(gtkmedia->priv->mute);
 		gtk_widget_show(GTK_WIDGET(hbox));
 
-		volume = gtk_hscale_new_with_range(0.0, 100.0, 5.0);
-		gtk_range_set_increments(GTK_RANGE(volume), 5.0, 25.0);
-		gtk_range_set_value(GTK_RANGE(volume),
-				purple_prefs_get_int(
-				"/pidgin/media/audio/volume/input"));
-		gtk_scale_set_draw_value(GTK_SCALE(volume), FALSE);
-		g_signal_connect (G_OBJECT(volume), "value-changed",
-				G_CALLBACK (pidgin_media_input_volume_changed),
-				media);
-		gtk_box_pack_end(GTK_BOX(send_widget),
-				volume, FALSE, FALSE, 0);
-		gtk_widget_show(volume);
-
 		media_src = purple_media_get_src(media, sid);
 		gtkmedia->priv->send_level = gst_bin_get_by_name(
 				GST_BIN(media_src), "sendlevel");
 
-		gtkmedia->priv->send_progress = gtk_progress_bar_new();
-		gtk_widget_set_size_request(gtkmedia->priv->send_progress, 320, 10);
 		gtk_box_pack_end(GTK_BOX(send_widget),
-				   gtkmedia->priv->send_progress, FALSE, FALSE, 0);
-		gtk_widget_show(gtkmedia->priv->send_progress);
+				pidgin_media_add_audio_widget(gtkmedia,
+				PURPLE_MEDIA_SEND_AUDIO), FALSE, FALSE, 0);
 
 		gtk_widget_show(gtkmedia->priv->mute);
 	}
@@ -883,15 +927,13 @@
 
 static gboolean
 pidgin_media_new_cb(PurpleMediaManager *manager, PurpleMedia *media,
-		PurpleConnection *pc, gchar *screenname, gpointer nul)
+		PurpleAccount *account, gchar *screenname, gpointer nul)
 {
 	PidginMedia *gtkmedia = PIDGIN_MEDIA(
 			pidgin_media_new(media, screenname));
-	PurpleBuddy *buddy = purple_find_buddy(
-			purple_connection_get_account(pc), screenname);
+	PurpleBuddy *buddy = purple_find_buddy(account, screenname);
 	const gchar *alias = buddy ? 
 			purple_buddy_get_contact_alias(buddy) : screenname; 
-	gtkmedia->priv->pc = pc;
 	gtk_window_set_title(GTK_WINDOW(gtkmedia), alias);
 
 	if (purple_media_is_initiator(media, NULL, NULL) == TRUE)
--- a/pidgin/gtkmedia.h	Fri Apr 10 05:00:13 2009 +0000
+++ b/pidgin/gtkmedia.h	Fri Apr 10 07:33:31 2009 +0000
@@ -1,8 +1,9 @@
 /**
- * @file media.h Account API
- * @ingroup core
- *
- * Pidgin 
+ * @file gtkmedia.h Pidgin Media API
+ * @ingroup pidgin
+ */
+
+/* Pidgin
  *
  * Pidgin is the legal property of its developers, whose names are too numerous
  * to list here.  Please refer to the COPYRIGHT file distributed with this
--- a/pidgin/gtksound.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/pidgin/gtksound.c	Fri Apr 10 07:33:31 2009 +0000
@@ -226,9 +226,9 @@
 account_signon_cb(PurpleConnection *gc, gpointer data)
 {
 	if (mute_login_sounds_timeout != 0)
-		g_source_remove(mute_login_sounds_timeout);
+		purple_timeout_remove(mute_login_sounds_timeout);
 	mute_login_sounds = TRUE;
-	mute_login_sounds_timeout = purple_timeout_add(10000, unmute_login_sounds_cb, NULL);
+	mute_login_sounds_timeout = purple_timeout_add_seconds(10, unmute_login_sounds_cb, NULL);
 }
 
 const char *
--- a/pidgin/gtkstatusbox.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/pidgin/gtkstatusbox.c	Fri Apr 10 07:33:31 2009 +0000
@@ -67,7 +67,8 @@
 #  endif
 #endif
 
-#define TYPING_TIMEOUT 4000
+/* Timeout for typing notifications in seconds */
+#define TYPING_TIMEOUT 4
 
 static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data);
 static void imhtml_format_changed_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, void *data);
@@ -1155,7 +1156,7 @@
 	/* Reset the status if Escape was pressed */
 	if (event->keyval == GDK_Escape)
 	{
-		g_source_remove(status_box->typing);
+		purple_timeout_remove(status_box->typing);
 		status_box->typing = 0;
 		if (status_box->account != NULL)
 			update_to_reflect_account_status(status_box, status_box->account,
@@ -1168,8 +1169,8 @@
 	}
 
 	pidgin_status_box_pulse_typing(status_box);
-	g_source_remove(status_box->typing);
-	status_box->typing = g_timeout_add(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box);
+	purple_timeout_remove(status_box->typing);
+	status_box->typing = purple_timeout_add_seconds(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box);
 
 	return FALSE;
 }
@@ -2596,7 +2597,7 @@
 		return;
 	}
 
-	g_source_remove(status_box->typing);
+	purple_timeout_remove(status_box->typing);
 	status_box->typing = 0;
 
 	activate_currently_selected_status(status_box);
@@ -2624,7 +2625,7 @@
 			   DATA_COLUMN, &data,
 			   -1);
 	if (status_box->typing != 0)
-		g_source_remove(status_box->typing);
+		purple_timeout_remove(status_box->typing);
 	status_box->typing = 0;
 
 	if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box)))
@@ -2692,7 +2693,7 @@
 			GtkTextIter start, end;
 			GtkTextBuffer *buffer;
 			gtk_widget_show_all(status_box->vbox);
-			status_box->typing = g_timeout_add(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box);
+			status_box->typing = purple_timeout_add_seconds(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box);
 			gtk_widget_grab_focus(status_box->imhtml);
 			buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(status_box->imhtml));
 			gtk_text_buffer_get_bounds(buffer, &start, &end);
@@ -2741,9 +2742,9 @@
 	{
 		if (status_box->typing != 0) {
 			pidgin_status_box_pulse_typing(status_box);
-			g_source_remove(status_box->typing);
+			purple_timeout_remove(status_box->typing);
 		}
-		status_box->typing = g_timeout_add(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box);
+		status_box->typing = purple_timeout_add_seconds(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box);
 	}
 	pidgin_status_box_refresh(status_box);
 }
--- a/pidgin/gtkutils.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/pidgin/gtkutils.c	Fri Apr 10 07:33:31 2009 +0000
@@ -950,7 +950,7 @@
 	           "accel changed, scheduling save.\n");
 
 	if (!accels_save_timer)
-		accels_save_timer = g_timeout_add(5000, pidgin_save_accels,
+		accels_save_timer = purple_timeout_add_seconds(5, pidgin_save_accels,
 		                                  NULL);
 }
 
--- a/pidgin/pidginstock.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/pidgin/pidginstock.c	Fri Apr 10 07:33:31 2009 +0000
@@ -201,7 +201,7 @@
 #ifdef USE_VV
 	{ PIDGIN_STOCK_TOOLBAR_AUDIO_CALL, "toolbar", "audio-call.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
 	{ PIDGIN_STOCK_TOOLBAR_VIDEO_CALL, "toolbar", "video-call.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
-	{ PIDGIN_STOCK_TOOLBAR_AUDIO_VIDEO_CALL, "toolbar", "audio-video-call.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
+	{ PIDGIN_STOCK_TOOLBAR_AUDIO_VIDEO_CALL, "toolbar", "audio-video-call.png", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
 #endif
 };
 
--- a/pidgin/plugins/cap/cap.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/pidgin/plugins/cap/cap.c	Fri Apr 10 07:33:31 2009 +0000
@@ -135,7 +135,7 @@
 	/* g_free(stats->hourly_usage); */
 	/* g_free(stats->daily_usage); */
 	if (stats->timeout_source_id != 0)
-		g_source_remove(stats->timeout_source_id);
+		purple_timeout_remove(stats->timeout_source_id);
 	g_free(stats);
 }
 
@@ -352,7 +352,7 @@
 	if (buddy == NULL)
 		return;
 
-	interval = purple_prefs_get_int("/plugins/gtk/cap/max_msg_difference") * 1000 * 60;
+	interval = purple_prefs_get_int("/plugins/gtk/cap/max_msg_difference") * 60;
 	words = word_count(message);
 
 	stats = get_stats_for(buddy);
@@ -361,9 +361,9 @@
 	stats->last_message = time(NULL);
 	stats->last_message_status_id = purple_status_get_id(get_status_for(buddy));
 	if(stats->timeout_source_id != 0)
-		g_source_remove(stats->timeout_source_id);
+		purple_timeout_remove(stats->timeout_source_id);
 
-	stats->timeout_source_id = g_timeout_add(interval, max_message_difference_cb, stats);
+	stats->timeout_source_id = purple_timeout_add_seconds(interval, max_message_difference_cb, stats);
 }
 
 /* received-im-msg */
@@ -386,7 +386,7 @@
 	 * then cancel the timeout callback. */
 	if(stats->timeout_source_id != 0) {
 		purple_debug_info("cap", "Cancelling timeout callback\n");
-		g_source_remove(stats->timeout_source_id);
+		purple_timeout_remove(stats->timeout_source_id);
 		stats->timeout_source_id = 0;
 	}
 
@@ -697,7 +697,7 @@
 static void cancel_conversation_timeouts(gpointer key, gpointer value, gpointer user_data) {
 	CapStatistics *stats = value;
 	if(stats->timeout_source_id != 0) {
-		g_source_remove(stats->timeout_source_id);
+		purple_timeout_remove(stats->timeout_source_id);
 		stats->timeout_source_id = 0;
 	}
 }
--- a/pidgin/plugins/mailchk.c	Fri Apr 10 05:00:13 2009 +0000
+++ b/pidgin/plugins/mailchk.c	Fri Apr 10 07:33:31 2009 +0000
@@ -13,7 +13,7 @@
 #define UNREAD_MAIL 0x02
 #define NEW_MAIL    0x04
 
-static guint32 timer = 0;
+static guint timer = 0;
 static GtkWidget *mail = NULL;
 
 static gint
@@ -93,7 +93,7 @@
 	PurpleBuddyList *list = purple_get_blist();
 	if (list && PURPLE_IS_GTK_BLIST(list) && !timer) {
 		check_timeout(NULL); /* we want the box to be drawn immediately */
-		timer = g_timeout_add(2000, check_timeout, NULL);
+		timer = purple_timeout_add_seconds(2, check_timeout, NULL);
 	}
 }
 
@@ -102,7 +102,7 @@
 {
 	PurpleBuddyList *list = purple_get_blist();
 	if ((!list || !PURPLE_IS_GTK_BLIST(list) || !PIDGIN_BLIST(list)->vbox) && timer) {
-		g_source_remove(timer);
+		purple_timeout_remove(timer);
 		timer = 0;
 	}
 }
@@ -123,7 +123,7 @@
 	}
 
 	if (list && PURPLE_IS_GTK_BLIST(list) && PIDGIN_BLIST(list)->vbox)
-		timer = g_timeout_add(2000, check_timeout, NULL);
+		timer = purple_timeout_add_seconds(2, check_timeout, NULL);
 
 	purple_signal_connect(conn_handle, "signed-on",
 						plugin, PURPLE_CALLBACK(signon_cb), NULL);
@@ -137,7 +137,7 @@
 plugin_unload(PurplePlugin *plugin)
 {
 	if (timer)
-		g_source_remove(timer);
+		purple_timeout_remove(timer);
 	timer = 0;
 	if (mail)
 		gtk_widget_destroy(mail);