aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-chat.c
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2011-10-14 12:21:17 +0800
committerDanielle Madeley <danielle.madeley@collabora.co.uk>2011-10-14 12:21:35 +0800
commit1180b055b932a8f1a1a6b207093e81b412e62da2 (patch)
treeee561960f46252199ff32a468f506ace6dd3b689 /libempathy-gtk/empathy-chat.c
parent8b6c644661a69599a86a5957bcb559383fb857c1 (diff)
parent601297c0ea82f38432445a2dc4a211cbdb98e915 (diff)
downloadgsoc2013-empathy-1180b055b932a8f1a1a6b207093e81b412e62da2.tar
gsoc2013-empathy-1180b055b932a8f1a1a6b207093e81b412e62da2.tar.gz
gsoc2013-empathy-1180b055b932a8f1a1a6b207093e81b412e62da2.tar.bz2
gsoc2013-empathy-1180b055b932a8f1a1a6b207093e81b412e62da2.tar.lz
gsoc2013-empathy-1180b055b932a8f1a1a6b207093e81b412e62da2.tar.xz
gsoc2013-empathy-1180b055b932a8f1a1a6b207093e81b412e62da2.tar.zst
gsoc2013-empathy-1180b055b932a8f1a1a6b207093e81b412e62da2.zip
Merge branch: 'Add top-up link to chat text when there is insufficient credit'
Diffstat (limited to 'libempathy-gtk/empathy-chat.c')
-rw-r--r--libempathy-gtk/empathy-chat.c50
1 files changed, 47 insertions, 3 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index a8903b476..bdb97be3a 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -1452,6 +1452,51 @@ chat_message_acknowledged_cb (EmpathyTpChat *tp_chat,
}
static void
+append_balance_error (EmpathyChat *chat,
+ const gchar *message_body)
+{
+ EmpathyChatPriv *priv = GET_PRIV (chat);
+ TpConnection *conn = tp_channel_borrow_connection (TP_CHANNEL (priv->tp_chat));
+ const gchar *uri = tp_connection_get_balance_uri (conn);
+ const gchar *error = _("insufficient balance to send message");
+ gchar *str, *str_markup = NULL;
+
+ if (message_body != NULL) {
+ str = g_strdup_printf (_("Error sending message '%s': %s"), message_body, error);
+ } else {
+ str = g_strdup_printf (_("Error sending message: %s"), error);
+ }
+
+ if (!tp_str_empty (uri)) {
+ /* translators: error used when user doesn't have enough credit on his
+ * account to send the message. */
+ gchar *markup_error = g_strdup_printf (_("insufficient balance to send message."
+ " <a href='%s'>Top up</a>."), uri);
+
+ if (message_body != NULL) {
+ gchar *escaped_body = g_markup_escape_text (message_body, -1);
+
+ str_markup = g_strdup_printf (_("Error sending message '%s': %s"),
+ escaped_body, markup_error);
+
+ g_free (escaped_body);
+ } else {
+ str_markup = g_strdup_printf (_("Error sending message: %s"), markup_error);
+ }
+
+ g_free (markup_error);
+ }
+
+ if (str_markup != NULL)
+ empathy_chat_view_append_event_markup (chat->view, str_markup, str);
+ else
+ empathy_chat_view_append_event (chat->view, str);
+
+ g_free (str);
+ g_free (str_markup);
+}
+
+static void
chat_send_error_cb (EmpathyTpChat *tp_chat,
const gchar *message_body,
TpChannelTextSendError error_code,
@@ -1462,9 +1507,8 @@ chat_send_error_cb (EmpathyTpChat *tp_chat,
gchar *str;
if (!tp_strdiff (dbus_error, TP_ERROR_STR_INSUFFICIENT_BALANCE)) {
- /* translators: error used when user doesn't have enough credit on his
- * account to send the message. */
- error = _("insufficient balance to send message");
+ append_balance_error (chat, message_body);
+ return;
} else if (!tp_strdiff (dbus_error, TP_ERROR_STR_NOT_CAPABLE)) {
error = _("not capable");
}