Mercurial > pidgin.yaz
changeset 26058:0ad1b8e950d7
Add purple_media_error.
author | Mike Ruprecht <maiku@soc.pidgin.im> |
---|---|
date | Tue, 16 Dec 2008 00:53:59 +0000 |
parents | 584a4f5ce4dc |
children | 18b71033ea6e |
files | libpurple/media.c libpurple/media.h pidgin/gtkconv.c pidgin/gtkmedia.c |
diffstat | 4 files changed, 51 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/media.c Mon Dec 15 09:55:25 2008 +0000 +++ b/libpurple/media.c Tue Dec 16 00:53:59 2008 +0000 @@ -107,6 +107,7 @@ enum { + ERROR, READY, WAIT, ACCEPTED, @@ -183,6 +184,10 @@ "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 +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 @@ 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; }
--- a/libpurple/media.h Mon Dec 15 09:55:25 2008 +0000 +++ b/libpurple/media.h Tue Dec 16 00:53:59 2008 +0000 @@ -232,6 +232,15 @@ 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.
--- a/pidgin/gtkconv.c Mon Dec 15 09:55:25 2008 +0000 +++ b/pidgin/gtkconv.c Tue Dec 16 00:53:59 2008 +0000 @@ -7753,6 +7753,12 @@ } 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 @@ 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(
--- a/pidgin/gtkmedia.c Mon Dec 15 09:55:25 2008 +0000 +++ b/pidgin/gtkmedia.c Tue Dec 16 00:53:59 2008 +0000 @@ -85,6 +85,7 @@ enum { MESSAGE, + ERROR, LAST_SIGNAL }; static guint pidgin_media_signals[LAST_SIGNAL] = {0}; @@ -154,6 +155,10 @@ 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 +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 @@ 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",