pidgin.vv: 79d15afc: Don't assume a PurpleMedia instance will...

maiku at soc.pidgin.im maiku at soc.pidgin.im
Sun Mar 29 21:25:37 EDT 2009


-----------------------------------------------------------------
Revision: 79d15afc25b78fa264fb19724f9b2621cdf5891a
Ancestor: 33b1fdcc904b503b5e0f40ebbe9e1b110afb598c
Author: maiku at soc.pidgin.im
Date: 2009-03-28T00:58:02
Branch: im.pidgin.pidgin.vv
URL: http://d.pidgin.im/viewmtn/revision/info/79d15afc25b78fa264fb19724f9b2621cdf5891a

Modified 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

ChangeLog: 

Don't assume a PurpleMedia instance will be created immediately.

-------------- next part --------------
============================================================
--- finch/gntmedia.c	9abc32446e63b4cca89f99a085bcddc013b5fcf3
+++ finch/gntmedia.c	7437097016f62a4f83f7448645105a9b7831bf30
@@ -339,11 +339,9 @@ call_cmd_cb(PurpleConversation *conv, co
 {
 	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;
============================================================
--- libpurple/protocols/jabber/google.c	aa2ae3714a98c238489f50609517162cbe78d9d4
+++ libpurple/protocols/jabber/google.c	74635706b2c916b51a6fd93eccf98940b659d07f
@@ -281,7 +281,7 @@ jabber_google_session_get_params(JabberS
 }
 
 
-PurpleMedia*
+gboolean
 jabber_google_session_initiate(JabberStream *js, const gchar *who, PurpleMediaSessionType type)
 {
 	GoogleSession *session;
@@ -296,7 +296,7 @@ jabber_google_session_initiate(JabberStr
 	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 @@ jabber_google_session_initiate(JabberStr
 		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 @@ jabber_google_session_initiate(JabberStr
 
 	g_free(params);
 
-	return session->media;
+	return (session->media != NULL) ? TRUE : FALSE;
 }
 
 static void
============================================================
--- libpurple/protocols/jabber/google.h	cd75215e878c3223b9dec81966827c2c24d0b28e
+++ libpurple/protocols/jabber/google.h	e01763a6bedbb3993cda179972ec965e27ff448f
@@ -49,7 +49,7 @@ char *jabber_google_format_to_html(const
 
 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);
============================================================
--- libpurple/protocols/jabber/jabber.c	811b16bd2f8ed65cf646a10868ff2617282cbd8a
+++ libpurple/protocols/jabber/jabber.c	b005d363a6e8b6eb9085c132fdb1239c47a0e79f
@@ -2612,7 +2612,7 @@ gboolean jabber_offline_message(const Pu
 	return TRUE;
 }
 
-PurpleMedia *
+gboolean
 jabber_initiate_media(PurpleConnection *gc, const char *who, 
 		      PurpleMediaSessionType type)
 {
@@ -2623,14 +2623,14 @@ jabber_initiate_media(PurpleConnection *
 	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 @@ jabber_initiate_media(PurpleConnection *
 	else
 		return jingle_rtp_initiate_media(gc->proto_data, who, type);
 #else
-	return NULL;
+	return FALSE;
 #endif
 }
 
============================================================
--- libpurple/protocols/jabber/jabber.h	47962a04762e50da9d193b9847d8f1dd0611fbd9
+++ libpurple/protocols/jabber/jabber.h	bdc9dd684bbe78a19a7f043e5750c06cb5997ed0
@@ -321,7 +321,7 @@ 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);
-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);
============================================================
--- libpurple/protocols/jabber/jingle/rtp.c	ad16b3e0684052d3059e6f7bdde74a5a3a6d7fd7
+++ libpurple/protocols/jabber/jingle/rtp.c	c0708258a4b4a0c3fd140cb6bcc0ac2d62cfff83
@@ -787,7 +787,7 @@ jingle_rtp_handle_action_internal(Jingle
 	}
 }
 
-PurpleMedia *
+gboolean
 jingle_rtp_initiate_media(JabberStream *js, const gchar *who, 
 		      PurpleMediaSessionType type)
 {
@@ -797,7 +797,6 @@ jingle_rtp_initiate_media(JabberStream *
 	JingleTransport *transport;
 	JabberBuddy *jb;
 	JabberBuddyResource *jbr;
-	PurpleMedia *media;
 	const gchar *transport_type;
 	
 	gchar *jid = NULL, *me = NULL, *sid = NULL;
@@ -806,7 +805,7 @@ jingle_rtp_initiate_media(JabberStream *
 	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 @@ jingle_rtp_initiate_media(JabberStream *
 	} 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_initiate_media(JabberStream *
 		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
============================================================
--- libpurple/protocols/jabber/jingle/rtp.h	941805ea7771bc315daae4a39dc9c685647b373b
+++ libpurple/protocols/jabber/jingle/rtp.h	a39ea0866c396cc5ca548dbe39c4a9655a505017
@@ -75,7 +75,7 @@ gchar *jingle_rtp_get_ssrc(JingleContent
 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);
============================================================
--- libpurple/prpl.c	8cbef9c9f08643a4a5656c4e3c03c25698364420
+++ libpurple/prpl.c	a4c99b76d4da453e847d3c4e5e138267448ef822
@@ -496,7 +496,7 @@ purple_prpl_got_attention_in_chat(Purple
 	got_attention(gc, id, who, type_code);
 }
 
-PurpleMedia *
+gboolean
 purple_prpl_initiate_media(PurpleAccount *account,
 			   const char *who,
 			   PurpleMediaSessionType type)
@@ -516,12 +516,9 @@ 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);
-	} else {
-		return NULL;
-	}
-#else
-	return NULL;
+	} else
 #endif
+	return FALSE;
 }
 
 PurpleMediaCaps
============================================================
--- libpurple/prpl.h	fd8eaac0428c051b7f7c7be82ba2aabda4da4554
+++ libpurple/prpl.h	e8be9ae7556d93eac1092f37901e0d1dfd07b19f
@@ -459,9 +459,9 @@ struct _PurplePluginProtocolInfo
 	 * @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 @@ PurpleMediaCaps purple_prpl_get_media_ca
  * @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);
 


More information about the Commits mailing list