pidgin.vv: 9857f069: Add purple_media_error.

maiku at soc.pidgin.im maiku at soc.pidgin.im
Mon Dec 15 21:15:58 EST 2008


-----------------------------------------------------------------
Revision: 9857f069b39984eba54b8dc575f9106af886ae93
Ancestor: 114f60ba0d193d3f5aa59b3dbfb7bfbb01cd3899
Author: maiku at soc.pidgin.im
Date: 2008-12-16T00:53:59
Branch: im.pidgin.pidgin.vv
URL: http://d.pidgin.im/viewmtn/revision/info/9857f069b39984eba54b8dc575f9106af886ae93

Modified files:
        libpurple/media.c libpurple/media.h pidgin/gtkconv.c
        pidgin/gtkmedia.c

ChangeLog: 

Add purple_media_error.

-------------- next part --------------
============================================================
--- libpurple/media.c	1b83ee4f60002fd4ef903288d8564b6e6b494f11
+++ libpurple/media.c	c099d65b42e1565860ea4e385609922576e6dd72
@@ -107,6 +107,7 @@ enum {
 
 
 enum {
+	ERROR,
 	READY,
 	WAIT,
 	ACCEPTED,
@@ -183,6 +184,10 @@ purple_media_class_init (PurpleMediaClas
 			"The PurpleConnection associated with this session",
 			G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
 
+	purple_media_signals[ERROR] = g_signal_new("error", G_TYPE_FROM_CLASS(klass),
+					 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+					 g_cclosure_marshal_VOID__STRING,
+					 G_TYPE_NONE, 1, G_TYPE_STRING);
 	purple_media_signals[READY] = g_signal_new("ready", G_TYPE_FROM_CLASS(klass),
 				 	 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
 					 g_cclosure_marshal_VOID__VOID,
@@ -765,6 +770,22 @@ void
 }
 
 void
+purple_media_error(PurpleMedia *media, const gchar *error, ...)
+{
+	va_list args;
+	gchar *message;
+
+	va_start(args, error);
+	message = g_strdup_vprintf(error, args);
+	va_end(args);
+
+	purple_debug_error("media", "%s\n", message);
+	g_signal_emit(media, purple_media_signals[ERROR], 0, message);
+
+	g_free(message);
+}
+
+void
 purple_media_ready(PurpleMedia *media)
 {
 	g_signal_emit(media, purple_media_signals[READY], 0);
@@ -1140,11 +1161,8 @@ purple_media_add_stream_internal(PurpleM
 		session->session = fs_conference_new_session(media->priv->conference, type, &err);
 
 		if (err != NULL) {
-			purple_debug_error("media", "Error creating session: %s\n", err->message);
+			purple_media_error(media, "Error creating session: %s\n", err->message);
 			g_error_free(err);
-			purple_conv_present_error(who,
-						  purple_connection_get_account(purple_media_get_connection(media)),
-						  _("Error creating session."));
 			g_free(session);
 			return FALSE;
 		}
============================================================
--- libpurple/media.h	35a0c2b462896adccc77fe8646336ea33b6f4b7b
+++ libpurple/media.h	3f08b48ae9b3a44240cbd35c2f3d04979fee813c
@@ -232,6 +232,15 @@ char *purple_media_get_screenname(Purple
 char *purple_media_get_screenname(PurpleMedia *media);
 
 /**
+ * Signals an error in the media session.
+ *
+ * @param media The media object to set the state on.
+ * @param error The format of the error message to send in the signal.
+ * @param ... The arguments to plug into the format.
+ */
+void purple_media_error(PurpleMedia *media, const gchar *error, ...);
+
+/**
  * Set the media session to the ready state.
  *
  * @param media The media object to set the state on.
============================================================
--- pidgin/gtkconv.c	75ff3c945008d70dc76330f8ffcf3319a08ab053
+++ pidgin/gtkconv.c	de5a51ff32192d0a40e32ad5e7a2da3166f08acd
@@ -7753,6 +7753,12 @@ static void
 }
 
 static void
+pidgin_gtkmedia_error_cb(PidginMedia *media, const char *msg, PurpleConversation *conv)
+{
+	purple_conv_im_write(PURPLE_CONV_IM(conv), NULL, msg, PURPLE_MESSAGE_ERROR, time(NULL));
+}
+
+static void
 menu_initiate_audio_call_cb(gpointer data, guint action, GtkWidget *widget)
 {
 	PidginWindow *win = (PidginWindow *)data;
@@ -7833,6 +7839,7 @@ pidgin_conv_new_media_cb(PurpleMediaMana
 	gtk_box_pack_start(GTK_BOX(gtkconv->topvbox), gtkmedia, FALSE, FALSE, 0);
 	gtk_widget_show(gtkmedia);
 	g_signal_connect(G_OBJECT(gtkmedia), "message", G_CALLBACK(pidgin_gtkmedia_message_cb), conv);
+	g_signal_connect(G_OBJECT(gtkmedia), "error", G_CALLBACK(pidgin_gtkmedia_error_cb), conv);
 
 	gtkconv->gtkmedia = gtkmedia;
 	g_signal_connect(G_OBJECT(gtkmedia), "destroy", G_CALLBACK(
============================================================
--- pidgin/gtkmedia.c	3e19f998d2ca9728a9c797c4cb7b7c053279df71
+++ pidgin/gtkmedia.c	5d8420ac559e9452e7ecc13a66075a30d5288487
@@ -85,6 +85,7 @@ enum {
 
 enum {
 	MESSAGE,
+	ERROR,
 	LAST_SIGNAL
 };
 static guint pidgin_media_signals[LAST_SIGNAL] = {0};
@@ -154,6 +155,10 @@ pidgin_media_class_init (PidginMediaClas
 					G_SIGNAL_RUN_LAST, 0, NULL, NULL,
 					g_cclosure_marshal_VOID__STRING,
 					G_TYPE_NONE, 1, G_TYPE_STRING);
+	pidgin_media_signals[ERROR] = g_signal_new("error", G_TYPE_FROM_CLASS(klass),
+					G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+					g_cclosure_marshal_VOID__STRING,
+					G_TYPE_NONE, 1, G_TYPE_STRING);
 
 	g_type_class_add_private(klass, sizeof(PidginMediaPrivate));
 }
@@ -306,6 +311,12 @@ static void
 }
 
 static void
+pidgin_media_error_cb(PidginMedia *media, const char *error, PidginMedia *gtkmedia)
+{
+	g_signal_emit(gtkmedia, pidgin_media_signals[ERROR], 0, error);
+}
+
+static void
 pidgin_media_ready_cb(PurpleMedia *media, PidginMedia *gtkmedia)
 {
 	GstElement *pipeline = purple_media_get_pipeline(media);
@@ -517,6 +528,8 @@ pidgin_media_set_property (GObject *obje
 			g_signal_connect_swapped(G_OBJECT(media->priv->hangup), "clicked",
 				 G_CALLBACK(purple_media_hangup), media->priv->media);
 
+			g_signal_connect(G_OBJECT(media->priv->media), "error",
+				G_CALLBACK(pidgin_media_error_cb), media);
 			g_signal_connect(G_OBJECT(media->priv->media), "accepted",
 				G_CALLBACK(pidgin_media_accept_cb), media);
 			g_signal_connect(G_OBJECT(media->priv->media) ,"ready",


More information about the Commits mailing list