changeset 26606:df9042312063

Switch media to store accounts rather than connections. This for the most part stops it from crashing when ending a session when the connection has been interrupted.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Thu, 09 Apr 2009 21:35:06 +0000
parents 6a3943412f2d
children 335826210c02
files finch/gntmedia.c libpurple/media.c libpurple/media.h libpurple/mediamanager.c libpurple/mediamanager.h libpurple/protocols/jabber/google.c libpurple/protocols/jabber/jabber.c libpurple/protocols/jabber/jabber.h libpurple/protocols/jabber/jingle/rtp.c libpurple/prpl.c libpurple/prpl.h pidgin/gtkmedia.c
diffstat 12 files changed, 98 insertions(+), 96 deletions(-) [+]
line wrap: on
line diff
--- a/finch/gntmedia.c	Thu Apr 09 17:59:35 2009 +0000
+++ b/finch/gntmedia.c	Thu Apr 09 21:35:06 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/libpurple/media.c	Thu Apr 09 17:59:35 2009 +0000
+++ b/libpurple/media.c	Thu Apr 09 21:35:06 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	Thu Apr 09 17:59:35 2009 +0000
+++ b/libpurple/media.h	Thu Apr 09 21:35:06 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	Thu Apr 09 17:59:35 2009 +0000
+++ b/libpurple/mediamanager.c	Thu Apr 09 21:35:06 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);
 		}
 	}
--- a/libpurple/mediamanager.h	Thu Apr 09 17:59:35 2009 +0000
+++ b/libpurple/mediamanager.h	Thu Apr 09 21:35:06 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/protocols/jabber/google.c	Thu Apr 09 17:59:35 2009 +0000
+++ b/libpurple/protocols/jabber/google.c	Thu Apr 09 21:35:06 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	Thu Apr 09 17:59:35 2009 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Thu Apr 09 21:35:06 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	Thu Apr 09 17:59:35 2009 +0000
+++ b/libpurple/protocols/jabber/jabber.h	Thu Apr 09 21:35:06 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	Thu Apr 09 17:59:35 2009 +0000
+++ b/libpurple/protocols/jabber/jingle/rtp.c	Thu Apr 09 21:35:06 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/prpl.c	Thu Apr 09 17:59:35 2009 +0000
+++ b/libpurple/prpl.c	Thu Apr 09 21:35:06 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	Thu Apr 09 17:59:35 2009 +0000
+++ b/libpurple/prpl.h	Thu Apr 09 21:35:06 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/pidgin/gtkmedia.c	Thu Apr 09 17:59:35 2009 +0000
+++ b/pidgin/gtkmedia.c	Thu Apr 09 21:35:06 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);
@@ -929,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)