pidgin: c3b20c49: Switch media to store accounts rather th...

maiku at soc.pidgin.im maiku at soc.pidgin.im
Thu Apr 9 17:40:29 EDT 2009


-----------------------------------------------------------------
Revision: c3b20c49337ce820dcbfabcf0d7908cb513d5ca3
Ancestor: fc26d302a61e3648254ec66268cae7f18fd780d1
Author: maiku at soc.pidgin.im
Date: 2009-04-09T21:35:06
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/c3b20c49337ce820dcbfabcf0d7908cb513d5ca3

Modified 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

ChangeLog: 

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.

-------------- next part --------------
============================================================
--- finch/gntmedia.c	c641d8c76002069d530ec31045a4458f030494ed
+++ finch/gntmedia.c	c9d4673eb2af601587d2d4d01600d362b019e0b3
@@ -254,16 +254,15 @@ finch_media_state_changed_cb(PurpleMedia
 	} 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 @@ finch_new_media(PurpleMediaManager *mana
 
 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);
============================================================
--- libpurple/media.c	a524e919d4dac7fad86ab5a802547bb495c50afc
+++ libpurple/media.c	714ccaeba61d0b1228b56efc5d10b912375e6db7
@@ -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 @@ struct _PurpleMediaPrivate
 {
 #ifdef USE_VV
 	PurpleMediaManager *manager;
-	PurpleConnection *pc;
+	PurpleAccount *account;
 	FsConference *conference;
 	gboolean initiator;
 	gpointer prpl_data;
@@ -166,7 +166,7 @@ enum {
 enum {
 	PROP_0,
 	PROP_MANAGER,
-	PROP_CONNECTION,
+	PROP_ACCOUNT,
 	PROP_CONFERENCE,
 	PROP_INITIATOR,
 	PROP_PRPL_DATA,
@@ -298,10 +298,10 @@ purple_media_class_init (PurpleMediaClas
 			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_set_property (GObject *obje
 
 			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 @@ purple_media_get_property (GObject *obje
 		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 @@ media_bus_call(GstBus *bus, GstMessage *
 }
 #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
============================================================
--- libpurple/media.h	4c1dcb02c72b8557990b82685642fa13da3ec96f
+++ libpurple/media.h	c3df1ca1001cf1e9b293b752e3798d22d833eb14
@@ -362,15 +362,15 @@ GList *purple_media_get_session_names(Pu
 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.
============================================================
--- libpurple/mediamanager.c	c88c26079b495e11ede51095e95ccc228146f09a
+++ libpurple/mediamanager.c	44dd52a657123bc6cafd4e864076141f63f745b6
@@ -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 @@ purple_media_manager_create_media(Purple
 
 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 @@ purple_media_manager_create_media(Purple
 	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 @@ purple_media_manager_create_media(Purple
 
 	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 @@ purple_media_manager_create_media(Purple
 	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 @@ purple_media_manager_create_media(Purple
 	}
 
 	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 *
 }
 
 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 @@ purple_media_manager_get_media_by_connec
 
 	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);
 		}
 	}
============================================================
--- libpurple/mediamanager.h	22c4034cd150d0000bb47b4a9abce3556e80416f
+++ libpurple/mediamanager.h	5cec0979236f0caaa7fcaaed8ff80f32eb7f84e5
@@ -35,7 +35,7 @@ typedef struct _PurpleMediaManagerClass 
 /** @copydoc _PurpleMediaManagerClass */
 typedef struct _PurpleMediaManagerClass PurpleMediaManagerClass;
 
-#include "connection.h"
+#include "account.h"
 #include "media.h"
 
 G_BEGIN_DECLS
@@ -78,7 +78,7 @@ PurpleMediaManager *purple_media_manager
  * 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 @@ PurpleMedia *purple_media_manager_create
  * @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(Pu
 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.
============================================================
--- libpurple/protocols/jabber/google.c	949581561107d027e5a7a6c3171dbe7b35e6a107
+++ libpurple/protocols/jabber/google.c	d2dd0de84617dea9ccca9b7d9ffe345cbfa31e60
@@ -340,7 +340,8 @@ jabber_google_session_initiate(JabberStr
 	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 @@ google_session_handle_initiate(JabberStr
 		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 @@ jabber_google_session_parse(JabberStream
 	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);
============================================================
--- libpurple/protocols/jabber/jabber.c	c58fca2d67d7c21fc501029d6343d18c4a566575
+++ libpurple/protocols/jabber/jabber.c	2f1344c43177016f76dbc456fe22e20a087d4ebe
@@ -2614,7 +2614,7 @@ typedef struct {
 
 #ifdef USE_VV
 typedef struct {
-	PurpleConnection *pc;
+	PurpleAccount *account;
 	gchar *who;
 	PurpleMediaSessionType type;
 	
@@ -2637,7 +2637,7 @@ jabber_media_ok_cb(JabberMediaRequest *r
 	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 @@ gboolean
 #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 @@ jabber_initiate_media(PurpleConnection *
 				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 @@ jabber_initiate_media(PurpleConnection *
 			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 @@ jabber_initiate_media(PurpleConnection *
 		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 @@ jabber_initiate_media(PurpleConnection *
 			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 @@ jabber_initiate_media(PurpleConnection *
 			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 @@ jabber_initiate_media(PurpleConnection *
 		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 @@ jabber_initiate_media(PurpleConnection *
 	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 @@ PurpleMediaCaps jabber_get_media_caps(Pu
 		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 @@ PurpleMediaCaps jabber_get_media_caps(Pu
 			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);
 		}
 	}
============================================================
--- libpurple/protocols/jabber/jabber.h	ced1b9a91d958b4522fd9ca54d3d0776eee9a50e
+++ libpurple/protocols/jabber/jabber.h	0bfa725ba93184cbc2872886a20dbc5803c215bd
@@ -323,9 +323,9 @@ GList *jabber_actions(PurplePlugin *plug
 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);
 
============================================================
--- libpurple/protocols/jabber/jingle/rtp.c	31df7e241ef1e398fdc9e4c4a58622c58710b640
+++ libpurple/protocols/jabber/jingle/rtp.c	1721599bb218f4fbcc5fc9dea1dd168260e5277f
@@ -204,8 +204,9 @@ jingle_rtp_get_media(JingleSession *sess
 {
 	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 @@ jingle_rtp_stream_info_cb(PurpleMedia *m
 {
 	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 @@ jingle_rtp_create_media(JingleContent *c
 	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) {
============================================================
--- libpurple/prpl.c	a4c99b76d4da453e847d3c4e5e138267448ef822
+++ libpurple/prpl.c	956491630baa6b5447264e8a4e44d4e1a7782d1e
@@ -515,7 +515,7 @@ purple_prpl_initiate_media(PurpleAccount
 
 	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 @@ purple_prpl_get_media_caps(PurpleAccount
 	
 	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;
============================================================
--- libpurple/prpl.h	a6ca085c38dcf76ba0c6be47d1a38fc2d74fa7df
+++ libpurple/prpl.h	b7845aba7e07168be2cea73ea1ea4179d29036dd
@@ -464,22 +464,22 @@ struct _PurplePluginProtocolInfo
 	/**
 	 * 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);
 };
 
============================================================
--- pidgin/gtkmedia.c	edfac35fb82ec74459f641a24f66cbf9d6f52f48
+++ pidgin/gtkmedia.c	b95fccb6922ee9995300b2298a5d2c7ff5bd6df9
@@ -97,7 +97,6 @@ struct _PidginMediaPrivate
 	GtkWidget *recv_widget;
 	GtkWidget *local_video;
 	GtkWidget *remote_video;
-	PurpleConnection *pc;
 
 	guint timeout_id;
 	PurpleMediaSessionType request_type;
@@ -432,7 +431,7 @@ pidgin_media_emit_message(PidginMedia *g
 {
 	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 @@ pidgin_media_error_cb(PidginMedia *media
 {
 	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 @@ pidgin_request_timeout_cb(PidginMedia *g
 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 @@ pidgin_request_timeout_cb(PidginMedia *g
 
 	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 @@ pidgin_media_new_cb(PurpleMediaManager *
 
 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)


More information about the Commits mailing list