changeset 26447:34eb898478b4

Don't assume a PurpleMedia instance will be created immediately.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Sat, 28 Mar 2009 00:58:02 +0000
parents e114ed3c8cfe
children 4e1286e76f1f
files finch/gntmedia.c libpurple/protocols/jabber/google.c libpurple/protocols/jabber/google.h libpurple/protocols/jabber/jabber.c libpurple/protocols/jabber/jabber.h libpurple/protocols/jabber/jingle/rtp.c libpurple/protocols/jabber/jingle/rtp.h libpurple/prpl.c libpurple/prpl.h
diffstat 9 files changed, 28 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/finch/gntmedia.c	Tue Mar 24 07:11:26 2009 +0000
+++ b/finch/gntmedia.c	Sat Mar 28 00:58:02 2009 +0000
@@ -339,11 +339,9 @@
 {
 	PurpleAccount *account = purple_conversation_get_account(conv);
 
-	PurpleMedia *media = purple_prpl_initiate_media(account,
+	if (!purple_prpl_initiate_media(account,
 			purple_conversation_get_name(conv),
-			PURPLE_MEDIA_AUDIO);
-
-	if (!media)
+			PURPLE_MEDIA_AUDIO))
 		return PURPLE_CMD_STATUS_FAILED;
 
 	return PURPLE_CMD_STATUS_OK;
--- a/libpurple/protocols/jabber/google.c	Tue Mar 24 07:11:26 2009 +0000
+++ b/libpurple/protocols/jabber/google.c	Sat Mar 28 00:58:02 2009 +0000
@@ -281,7 +281,7 @@
 }
 
 
-PurpleMedia*
+gboolean
 jabber_google_session_initiate(JabberStream *js, const gchar *who, PurpleMediaSessionType type)
 {
 	GoogleSession *session;
@@ -296,7 +296,7 @@
 	if (!jb) {
 		purple_debug_error("jingle-rtp",
 				"Could not find Jabber buddy\n");
-		return NULL;
+		return FALSE;
 	}
 	jbr = jabber_buddy_find_resource(jb, NULL);
 	if (!jbr) {
@@ -333,7 +333,7 @@
 		purple_media_hangup(session->media);
 		google_session_destroy(session);
 		g_free(params);
-		return NULL;
+		return FALSE;
 	}
 
 	g_signal_connect_swapped(G_OBJECT(session->media),
@@ -348,7 +348,7 @@
 
 	g_free(params);
 
-	return session->media;
+	return (session->media != NULL) ? TRUE : FALSE;
 }
 
 static void
--- a/libpurple/protocols/jabber/google.h	Tue Mar 24 07:11:26 2009 +0000
+++ b/libpurple/protocols/jabber/google.h	Sat Mar 28 00:58:02 2009 +0000
@@ -49,7 +49,7 @@
 
 char *jabber_google_format_to_html(const char *text);
 
-PurpleMedia *jabber_google_session_initiate(JabberStream *js, const gchar *who, PurpleMediaSessionType type);
+gboolean jabber_google_session_initiate(JabberStream *js, const gchar *who, PurpleMediaSessionType type);
 void jabber_google_session_parse(JabberStream *js, xmlnode *node);
 
 void jabber_google_handle_jingle_info(JabberStream *js, xmlnode *packet);
--- a/libpurple/protocols/jabber/jabber.c	Tue Mar 24 07:11:26 2009 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Sat Mar 28 00:58:02 2009 +0000
@@ -2612,7 +2612,7 @@
 	return TRUE;
 }
 
-PurpleMedia *
+gboolean
 jabber_initiate_media(PurpleConnection *gc, const char *who, 
 		      PurpleMediaSessionType type)
 {
@@ -2623,14 +2623,14 @@
 	if (!js) {
 		purple_debug_error("jabber",
 				"jabber_initiate_media: NULL stream\n");
-		return NULL;
+		return FALSE;
 	}
 
 	jb = jabber_buddy_find(js, who, FALSE);
 
 	if (!jb) {
 		purple_debug_error("jabber", "Could not find buddy\n");
-		return NULL;
+		return FALSE;
 	}
 
 	if (type & PURPLE_MEDIA_AUDIO &&
@@ -2641,7 +2641,7 @@
 	else
 		return jingle_rtp_initiate_media(gc->proto_data, who, type);
 #else
-	return NULL;
+	return FALSE;
 #endif
 }
 
--- a/libpurple/protocols/jabber/jabber.h	Tue Mar 24 07:11:26 2009 +0000
+++ b/libpurple/protocols/jabber/jabber.h	Sat Mar 28 00:58:02 2009 +0000
@@ -321,7 +321,7 @@
 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);
-PurpleMedia *jabber_initiate_media(PurpleConnection *gc, const char *who,
+gboolean jabber_initiate_media(PurpleConnection *gc, const char *who,
 		PurpleMediaSessionType type);
 PurpleMediaCaps jabber_get_media_caps(PurpleConnection *gc, const char *who);
 void jabber_register_commands(void);
--- a/libpurple/protocols/jabber/jingle/rtp.c	Tue Mar 24 07:11:26 2009 +0000
+++ b/libpurple/protocols/jabber/jingle/rtp.c	Sat Mar 28 00:58:02 2009 +0000
@@ -787,7 +787,7 @@
 	}
 }
 
-PurpleMedia *
+gboolean
 jingle_rtp_initiate_media(JabberStream *js, const gchar *who, 
 		      PurpleMediaSessionType type)
 {
@@ -797,7 +797,6 @@
 	JingleTransport *transport;
 	JabberBuddy *jb;
 	JabberBuddyResource *jbr;
-	PurpleMedia *media;
 	const gchar *transport_type;
 	
 	gchar *jid = NULL, *me = NULL, *sid = NULL;
@@ -806,7 +805,7 @@
 	jb = jabber_buddy_find(js, who, FALSE);
 	if (!jb) {
 		purple_debug_error("jingle-rtp", "Could not find Jabber buddy\n");
-		return NULL;
+		return FALSE;
 	}
 	jbr = jabber_buddy_find_resource(jb, NULL);
 	if (!jbr) {
@@ -820,7 +819,7 @@
 	} else {
 		purple_debug_error("jingle-rtp", "Resource doesn't support "
 				"the same transport types\n");
-		return NULL;
+		return FALSE;
 	}
 
 	if ((strchr(who, '/') == NULL) && jbr && (jbr->name != NULL)) {
@@ -854,14 +853,14 @@
 		jingle_rtp_init_media(content);
 	}
 
-	if ((media = jingle_rtp_get_media(session)) == NULL) {
-		return NULL;
-	}
-
 	g_free(jid);
 	g_free(me);
 
-	return media;
+	if (jingle_rtp_get_media(session) == NULL) {
+		return FALSE;
+	}
+
+	return TRUE;
 }
 
 void
--- a/libpurple/protocols/jabber/jingle/rtp.h	Tue Mar 24 07:11:26 2009 +0000
+++ b/libpurple/protocols/jabber/jingle/rtp.h	Sat Mar 28 00:58:02 2009 +0000
@@ -75,7 +75,7 @@
 gchar *jingle_rtp_get_media_type(JingleContent *content);
 gchar *jingle_rtp_get_ssrc(JingleContent *content);
 
-PurpleMedia *jingle_rtp_initiate_media(JabberStream *js,
+gboolean jingle_rtp_initiate_media(JabberStream *js,
 				   const gchar *who,
 				   PurpleMediaSessionType type);
 void jingle_rtp_terminate_session(JabberStream *js, const gchar *who);
--- a/libpurple/prpl.c	Tue Mar 24 07:11:26 2009 +0000
+++ b/libpurple/prpl.c	Sat Mar 28 00:58:02 2009 +0000
@@ -496,7 +496,7 @@
 	got_attention(gc, id, who, type_code);
 }
 
-PurpleMedia *
+gboolean
 purple_prpl_initiate_media(PurpleAccount *account,
 			   const char *who,
 			   PurpleMediaSessionType type)
@@ -516,12 +516,9 @@
 	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);
-	} else {
-		return NULL;
-	}
-#else
-	return NULL;
+	} else
 #endif
+	return FALSE;
 }
 
 PurpleMediaCaps
--- a/libpurple/prpl.h	Tue Mar 24 07:11:26 2009 +0000
+++ b/libpurple/prpl.h	Sat Mar 28 00:58:02 2009 +0000
@@ -459,9 +459,9 @@
 	 * @param conn The connection 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 The newly created media object.
+	 * @return TRUE if the call succeeded else FALSE. (Doesn't imply the media session or stream will be successfully created)
 	 */
-	PurpleMedia  *(*initiate_media)(PurpleConnection *gc, const char *who,
+	gboolean (*initiate_media)(PurpleConnection *gc, const char *who,
 					PurpleMediaSessionType type);
 
 	/**
@@ -787,9 +787,9 @@
  * @param who The name of the contact to start a session with.
  * @param type The type of media session to start.
  *
- * @return The newly created session object.
+ * @return TRUE if the call succeeded else FALSE. (Doesn't imply the media session or stream will be successfully created)
  */
-PurpleMedia *purple_prpl_initiate_media(PurpleAccount *account,
+gboolean purple_prpl_initiate_media(PurpleAccount *account,
 					const char *who,
 					PurpleMediaSessionType type);