aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2009-08-31 17:59:21 +0800
committerWill Thompson <will.thompson@collabora.co.uk>2009-08-31 17:59:21 +0800
commit9eebd23f8a4a83cef5b13204a1bb377d59160bbf (patch)
treeb12ef17d2f7ed10542bee4f6dd1bc8c0591a6639
parentd181f7ba0031ad758911e6f0c6f6530d3833b76e (diff)
parente92cc2a571051be566895ed3f09faebd8c56716f (diff)
downloadgsoc2013-empathy-9eebd23f8a4a83cef5b13204a1bb377d59160bbf.tar
gsoc2013-empathy-9eebd23f8a4a83cef5b13204a1bb377d59160bbf.tar.gz
gsoc2013-empathy-9eebd23f8a4a83cef5b13204a1bb377d59160bbf.tar.bz2
gsoc2013-empathy-9eebd23f8a4a83cef5b13204a1bb377d59160bbf.tar.lz
gsoc2013-empathy-9eebd23f8a4a83cef5b13204a1bb377d59160bbf.tar.xz
gsoc2013-empathy-9eebd23f8a4a83cef5b13204a1bb377d59160bbf.tar.zst
gsoc2013-empathy-9eebd23f8a4a83cef5b13204a1bb377d59160bbf.zip
Merge branch 'send-errors'
-rw-r--r--libempathy-gtk/empathy-chat.c4
-rw-r--r--libempathy/empathy-message.c40
-rw-r--r--libempathy/empathy-message.h4
-rw-r--r--libempathy/empathy-tp-chat.c26
4 files changed, 60 insertions, 14 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index a979c9e76..c08b49c3f 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -523,7 +523,7 @@ chat_message_received_cb (EmpathyTpChat *tp_chat,
static void
chat_send_error_cb (EmpathyTpChat *tp_chat,
- EmpathyMessage *message,
+ const gchar *message_body,
TpChannelTextSendError error_code,
EmpathyChat *chat)
{
@@ -552,7 +552,7 @@ chat_send_error_cb (EmpathyTpChat *tp_chat,
}
str = g_strdup_printf (_("Error sending message '%s': %s"),
- empathy_message_get_body (message),
+ message_body,
error);
empathy_chat_view_append_event (chat->view, str);
g_free (str);
diff --git a/libempathy/empathy-message.c b/libempathy/empathy-message.c
index 34a466752..a403766e4 100644
--- a/libempathy/empathy-message.c
+++ b/libempathy/empathy-message.c
@@ -41,6 +41,7 @@ typedef struct {
time_t timestamp;
gboolean is_backlog;
guint id;
+ gboolean incoming;
} EmpathyMessagePriv;
static void empathy_message_finalize (GObject *object);
@@ -63,6 +64,7 @@ enum {
PROP_BODY,
PROP_TIMESTAMP,
PROP_IS_BACKLOG,
+ PROP_INCOMING,
};
static void
@@ -123,6 +125,14 @@ empathy_message_class_init (EmpathyMessageClass *class)
G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_INCOMING,
+ g_param_spec_boolean ("incoming",
+ "Incoming",
+ "If this is an incoming (as opposed to sent) message",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
g_type_class_add_private (object_class, sizeof (EmpathyMessagePriv));
}
@@ -179,6 +189,9 @@ message_get_property (GObject *object,
case PROP_BODY:
g_value_set_string (value, priv->body);
break;
+ case PROP_INCOMING:
+ g_value_set_boolean (value, priv->incoming);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -212,6 +225,9 @@ message_set_property (GObject *object,
empathy_message_set_body (EMPATHY_MESSAGE (object),
g_value_get_string (value));
break;
+ case PROP_INCOMING:
+ priv->incoming = g_value_get_boolean (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -579,6 +595,30 @@ empathy_message_set_id (EmpathyMessage *message, guint id)
priv->id = id;
}
+void
+empathy_message_set_incoming (EmpathyMessage *message, gboolean incoming)
+{
+ EmpathyMessagePriv *priv;
+
+ g_return_if_fail (EMPATHY_IS_MESSAGE (message));
+
+ priv = GET_PRIV (message);
+
+ priv->incoming = incoming;
+
+ g_object_notify (G_OBJECT (message), "incoming");
+}
+
+gboolean
+empathy_message_is_incoming (EmpathyMessage *message)
+{
+ EmpathyMessagePriv *priv = GET_PRIV (message);
+
+ g_return_val_if_fail (EMPATHY_IS_MESSAGE (message), FALSE);
+
+ return priv->incoming;
+}
+
gboolean
empathy_message_equal (EmpathyMessage *message1, EmpathyMessage *message2)
{
diff --git a/libempathy/empathy-message.h b/libempathy/empathy-message.h
index f9a488703..7ca624031 100644
--- a/libempathy/empathy-message.h
+++ b/libempathy/empathy-message.h
@@ -72,6 +72,10 @@ void empathy_message_set_timestamp (EmpathyMessage
gboolean empathy_message_is_backlog (EmpathyMessage *message);
void empathy_message_set_is_backlog (EmpathyMessage *message,
gboolean is_backlog);
+gboolean empathy_message_is_incoming (EmpathyMessage *message);
+void empathy_message_set_incoming (EmpathyMessage *message,
+ gboolean incoming);
+
gboolean empathy_message_should_highlight (EmpathyMessage *message);
TpChannelTextMessageType empathy_message_type_from_str (const gchar *type_str);
const gchar * empathy_message_type_to_str (TpChannelTextMessageType type);
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index 69057a878..a64f06a2f 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -227,6 +227,7 @@ tp_chat_got_sender_cb (EmpathyTpContactFactory *factory,
static void
tp_chat_build_message (EmpathyTpChat *chat,
+ gboolean incoming,
guint id,
guint type,
guint timestamp,
@@ -243,6 +244,8 @@ tp_chat_build_message (EmpathyTpChat *chat,
empathy_message_set_receiver (message, priv->user);
empathy_message_set_timestamp (message, timestamp);
empathy_message_set_id (message, id);
+ empathy_message_set_incoming (message, incoming);
+
g_queue_push_tail (priv->messages_queue, message);
if (from_handle == 0) {
@@ -294,6 +297,7 @@ tp_chat_received_cb (TpChannel *channel,
}
tp_chat_build_message (chat,
+ TRUE,
message_id,
message_type,
timestamp,
@@ -318,6 +322,7 @@ tp_chat_sent_cb (TpChannel *channel,
DEBUG ("Message sent: %s", message_body);
tp_chat_build_message (chat,
+ FALSE,
0,
message_type,
timestamp,
@@ -339,14 +344,9 @@ tp_chat_send_error_cb (TpChannel *channel,
if (priv->channel == NULL)
return;
- DEBUG ("Message sent error: %s (%d)", message_body, error_code);
+ DEBUG ("Error sending '%s' (%d)", message_body, error_code);
- tp_chat_build_message (EMPATHY_TP_CHAT (chat),
- 0,
- message_type,
- timestamp,
- 0,
- message_body);
+ g_signal_emit (chat, signals[SEND_ERROR], 0, message_body, error_code);
}
static void
@@ -359,7 +359,8 @@ tp_chat_send_cb (TpChannel *proxy,
if (error) {
DEBUG ("Error: %s", error->message);
- g_signal_emit (chat, signals[SEND_ERROR], 0, message,
+ g_signal_emit (chat, signals[SEND_ERROR], 0,
+ empathy_message_get_body (message),
TP_CHANNEL_TEXT_SEND_ERROR_UNKNOWN);
}
}
@@ -460,6 +461,7 @@ tp_chat_list_pending_messages_cb (TpChannel *channel,
}
tp_chat_build_message (chat,
+ TRUE,
message_id,
message_type,
timestamp,
@@ -1168,9 +1170,9 @@ empathy_tp_chat_class_init (EmpathyTpChatClass *klass)
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
- _empathy_marshal_VOID__OBJECT_UINT,
+ _empathy_marshal_VOID__STRING_UINT,
G_TYPE_NONE,
- 2, EMPATHY_TYPE_MESSAGE, G_TYPE_UINT);
+ 2, G_TYPE_STRING, G_TYPE_UINT);
signals[CHAT_STATE_CHANGED] =
g_signal_new ("chat-state-changed",
@@ -1373,7 +1375,7 @@ empathy_tp_chat_acknowledge_message (EmpathyTpChat *chat,
g_return_if_fail (EMPATHY_IS_TP_CHAT (chat));
g_return_if_fail (priv->ready);
- if (empathy_message_get_sender (message) == priv->user)
+ if (!empathy_message_is_incoming (message))
goto out;
message_ids = g_array_sized_new (FALSE, FALSE, sizeof (guint), 1);
@@ -1419,7 +1421,7 @@ empathy_tp_chat_acknowledge_messages (EmpathyTpChat *chat,
g_assert (m != NULL);
g_queue_delete_link (priv->pending_messages_queue, m);
- if (empathy_message_get_sender (message) != priv->user) {
+ if (empathy_message_is_incoming (message)) {
guint id = empathy_message_get_id (message);
g_array_append_val (message_ids, id);
}