aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2011-10-14 12:31:16 +0800
committerDanielle Madeley <danielle.madeley@collabora.co.uk>2011-10-14 12:32:13 +0800
commitfecbf935f2b9be2cd6229099334279028fc517f1 (patch)
tree055bc011da6b83f607016f10e8a5da5d7bc017d6 /libempathy-gtk
parent7b6b8da406493311445f6c2470a005a542972693 (diff)
parent16e0d5a45bb1e11d57c4d5e512f021ebb6d2da12 (diff)
downloadgsoc2013-empathy-fecbf935f2b9be2cd6229099334279028fc517f1.tar
gsoc2013-empathy-fecbf935f2b9be2cd6229099334279028fc517f1.tar.gz
gsoc2013-empathy-fecbf935f2b9be2cd6229099334279028fc517f1.tar.bz2
gsoc2013-empathy-fecbf935f2b9be2cd6229099334279028fc517f1.tar.lz
gsoc2013-empathy-fecbf935f2b9be2cd6229099334279028fc517f1.tar.xz
gsoc2013-empathy-fecbf935f2b9be2cd6229099334279028fc517f1.tar.zst
gsoc2013-empathy-fecbf935f2b9be2cd6229099334279028fc517f1.zip
Merge remote-tracking branch 'pochu/error-dialog'
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-chat.c6
-rw-r--r--libempathy-gtk/empathy-individual-menu.c3
-rw-r--r--libempathy-gtk/empathy-new-message-dialog.c84
3 files changed, 88 insertions, 5 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index bdb97be3a..b1d469f3f 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -277,11 +277,13 @@ account_reconnected (EmpathyChat *chat,
if (priv->sms_channel)
empathy_sms_contact_id (
account, priv->id,
- TP_USER_ACTION_TIME_NOT_USER_ACTION);
+ TP_USER_ACTION_TIME_NOT_USER_ACTION,
+ NULL, NULL);
else
empathy_chat_with_contact_id (
account, priv->id,
- TP_USER_ACTION_TIME_NOT_USER_ACTION);
+ TP_USER_ACTION_TIME_NOT_USER_ACTION,
+ NULL, NULL);
break;
case TP_HANDLE_TYPE_ROOM:
empathy_join_muc (account, priv->id,
diff --git a/libempathy-gtk/empathy-individual-menu.c b/libempathy-gtk/empathy-individual-menu.c
index 77cbc57d5..2209e1538 100644
--- a/libempathy-gtk/empathy-individual-menu.c
+++ b/libempathy-gtk/empathy-individual-menu.c
@@ -786,7 +786,8 @@ empathy_individual_sms_menu_item_activated (GtkMenuItem *item,
empathy_sms_contact_id (
empathy_contact_get_account (contact),
empathy_contact_get_id (contact),
- empathy_get_current_action_time ());
+ empathy_get_current_action_time (),
+ NULL, NULL);
}
GtkWidget *
diff --git a/libempathy-gtk/empathy-new-message-dialog.c b/libempathy-gtk/empathy-new-message-dialog.c
index 1c4bbaad5..027ef8721 100644
--- a/libempathy-gtk/empathy-new-message-dialog.c
+++ b/libempathy-gtk/empathy-new-message-dialog.c
@@ -63,6 +63,82 @@ enum
EMP_NEW_MESSAGE_SMS,
};
+static const gchar *
+get_error_display_message (GError *error)
+{
+ if (error->domain != TP_ERROR)
+ goto out;
+
+ switch (error->code)
+ {
+ case TP_ERROR_NETWORK_ERROR:
+ return _("Network error");
+ case TP_ERROR_OFFLINE:
+ return _("The contact is offline");
+ case TP_ERROR_INVALID_HANDLE:
+ return _("The specified contact is either invalid or unknown");
+ case TP_ERROR_NOT_CAPABLE:
+ return _("The contact does not support this kind of conversation");
+ case TP_ERROR_NOT_IMPLEMENTED:
+ return _("The requested functionality is not implemented "
+ "for this protocol");
+ case TP_ERROR_INVALID_ARGUMENT:
+ /* Not very user friendly to say 'invalid arguments' */
+ break;
+ case TP_ERROR_NOT_AVAILABLE:
+ return _("Could not start a conversation with the given contact");
+ case TP_ERROR_CHANNEL_BANNED:
+ return _("You are banned from this channel");
+ case TP_ERROR_CHANNEL_FULL:
+ return _("This channel is full");
+ case TP_ERROR_CHANNEL_INVITE_ONLY:
+ return _("You must be invited to join this channel");
+ case TP_ERROR_DISCONNECTED:
+ return _("Can't proceed while disconnected");
+ case TP_ERROR_PERMISSION_DENIED:
+ return _("Permission denied");
+ default:
+ DEBUG ("Unhandled error code: %d", error->code);
+ }
+
+out:
+ return _("There was an error starting the conversation");
+}
+
+static void
+show_chat_error (GError *error,
+ GtkWindow *parent)
+{
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (parent, GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
+ "%s",
+ get_error_display_message (error));
+
+ g_signal_connect_swapped (dialog, "response",
+ G_CALLBACK (gtk_widget_destroy),
+ dialog);
+
+ gtk_widget_show (dialog);
+}
+
+static void
+ensure_text_channel_cb (GObject *source,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GError *error = NULL;
+
+ if (!tp_account_channel_request_ensure_channel_finish (
+ TP_ACCOUNT_CHANNEL_REQUEST (source), result, &error))
+ {
+ DEBUG ("Failed to ensure text channel: %s", error->message);
+ show_chat_error (error, user_data);
+ g_error_free (error);
+ }
+}
+
static void
empathy_new_message_dialog_response (GtkDialog *dialog, int response_id)
{
@@ -80,12 +156,16 @@ empathy_new_message_dialog_response (GtkDialog *dialog, int response_id)
{
case EMP_NEW_MESSAGE_TEXT:
empathy_chat_with_contact_id (account, contact_id,
- empathy_get_current_action_time ());
+ empathy_get_current_action_time (),
+ ensure_text_channel_cb,
+ gtk_widget_get_parent_window (GTK_WIDGET (dialog)));
break;
case EMP_NEW_MESSAGE_SMS:
empathy_sms_contact_id (account, contact_id,
- empathy_get_current_action_time ());
+ empathy_get_current_action_time (),
+ ensure_text_channel_cb,
+ gtk_widget_get_parent_window (GTK_WIDGET (dialog)));
break;
default: