[empathy: 1/7] Use dbus-error from delivery report for better errors
- From: Danielle Madeley <daniellem src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy: 1/7] Use dbus-error from delivery report for better errors
- Date: Thu, 5 May 2011 08:22:44 +0000 (UTC)
commit b0aaacf05d0b46ca53f3b6b9f2dd0565cea0f5d0
Author: Danielle Madeley <danielle madeley collabora co uk>
Date: Thu Apr 21 15:03:52 2011 +1000
Use dbus-error from delivery report for better errors
libempathy-gtk/empathy-chat.c | 52 ++++++++++++++++++++++++----------------
libempathy/empathy-tp-chat.c | 12 ++++++---
2 files changed, 39 insertions(+), 25 deletions(-)
---
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index 5c8bbce..d4e025f 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -1282,31 +1282,41 @@ static void
chat_send_error_cb (EmpathyTpChat *tp_chat,
const gchar *message_body,
TpChannelTextSendError error_code,
+ const gchar *dbus_error,
EmpathyChat *chat)
{
- const gchar *error;
+ const gchar *error = NULL;
gchar *str;
- switch (error_code) {
- case TP_CHANNEL_TEXT_SEND_ERROR_OFFLINE:
- error = _("offline");
- break;
- case TP_CHANNEL_TEXT_SEND_ERROR_INVALID_CONTACT:
- error = _("invalid contact");
- break;
- case TP_CHANNEL_TEXT_SEND_ERROR_PERMISSION_DENIED:
- error = _("permission denied");
- break;
- case TP_CHANNEL_TEXT_SEND_ERROR_TOO_LONG:
- error = _("too long message");
- break;
- case TP_CHANNEL_TEXT_SEND_ERROR_NOT_IMPLEMENTED:
- error = _("not implemented");
- break;
- case TP_CHANNEL_TEXT_SEND_ERROR_UNKNOWN:
- default:
- error = _("unknown");
- break;
+ if (!tp_strdiff (dbus_error, TP_ERROR_STR_INSUFFICIENT_BALANCE)) {
+ error = _("insufficient balance to send message");
+ } else if (!tp_strdiff (dbus_error, TP_ERROR_STR_NOT_CAPABLE)) {
+ error = _("not capable");
+ }
+
+ if (error == NULL) {
+ /* if we didn't find a dbus-error, try the old error */
+ switch (error_code) {
+ case TP_CHANNEL_TEXT_SEND_ERROR_OFFLINE:
+ error = _("offline");
+ break;
+ case TP_CHANNEL_TEXT_SEND_ERROR_INVALID_CONTACT:
+ error = _("invalid contact");
+ break;
+ case TP_CHANNEL_TEXT_SEND_ERROR_PERMISSION_DENIED:
+ error = _("permission denied");
+ break;
+ case TP_CHANNEL_TEXT_SEND_ERROR_TOO_LONG:
+ error = _("too long message");
+ break;
+ case TP_CHANNEL_TEXT_SEND_ERROR_NOT_IMPLEMENTED:
+ error = _("not implemented");
+ break;
+ case TP_CHANNEL_TEXT_SEND_ERROR_UNKNOWN:
+ default:
+ error = _("unknown");
+ break;
+ }
}
if (message_body != NULL) {
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index b8e4cdf..4b3bca4 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -322,6 +322,7 @@ handle_delivery_report (EmpathyTpChat *self,
gboolean valid;
GPtrArray *echo;
const gchar *message_body = NULL;
+ const gchar *delivery_dbus_error;
header = tp_message_peek (message, 0);
if (header == NULL)
@@ -335,6 +336,8 @@ handle_delivery_report (EmpathyTpChat *self,
if (!valid)
delivery_error = TP_CHANNEL_TEXT_SEND_ERROR_UNKNOWN;
+ delivery_dbus_error = tp_asv_get_string (header, "delivery-dbus-error");
+
/* TODO: ideally we should use tp-glib API giving us the echoed message as a
* TpMessage. (fdo #35884) */
echo = tp_asv_get_boxed (header, "delivery-echo",
@@ -347,7 +350,8 @@ handle_delivery_report (EmpathyTpChat *self,
message_body = tp_asv_get_string (echo_body, "content");
}
- g_signal_emit (self, signals[SEND_ERROR], 0, message_body, delivery_error);
+ g_signal_emit (self, signals[SEND_ERROR], 0, message_body,
+ delivery_error, delivery_dbus_error);
out:
tp_text_channel_ack_message_async (TP_TEXT_CHANNEL (priv->channel),
@@ -449,7 +453,7 @@ message_send_cb (GObject *source,
* we'll have rebased EmpathyTpChat on top of TpTextChannel we'll be able
* to use the user_data pointer to pass the message and fix this. */
g_signal_emit (chat, signals[SEND_ERROR], 0,
- NULL, error_to_text_send_error (error));
+ NULL, error_to_text_send_error (error), NULL);
g_error_free (error);
}
@@ -1521,9 +1525,9 @@ empathy_tp_chat_class_init (EmpathyTpChatClass *klass)
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
- _empathy_marshal_VOID__STRING_UINT,
+ _empathy_marshal_VOID__STRING_UINT_STRING,
G_TYPE_NONE,
- 2, G_TYPE_STRING, G_TYPE_UINT);
+ 3, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING);
signals[CHAT_STATE_CHANGED] =
g_signal_new ("chat-state-changed",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]