aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libempathy-gtk/empathy-chat.c12
-rw-r--r--libempathy/empathy-tp-chat.c121
-rw-r--r--libempathy/empathy-tp-chat.h3
3 files changed, 82 insertions, 54 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index 3810e209b..c40548b19 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -1644,21 +1644,16 @@ void
empathy_chat_set_tp_chat (EmpathyChat *chat,
EmpathyTpChat *tp_chat)
{
- EmpathyChatPriv *priv;
+ EmpathyChatPriv *priv = GET_PRIV (chat);
g_return_if_fail (EMPATHY_IS_CHAT (chat));
g_return_if_fail (EMPATHY_IS_TP_CHAT (tp_chat));
g_return_if_fail (empathy_tp_chat_is_ready (tp_chat));
- priv = GET_PRIV (chat);
-
- if (tp_chat == priv->tp_chat) {
+ if (priv->tp_chat) {
return;
}
- if (priv->tp_chat) {
- g_object_unref (priv->tp_chat);
- }
if (priv->account) {
g_object_unref (priv->account);
}
@@ -1699,6 +1694,9 @@ empathy_chat_set_tp_chat (EmpathyChat *chat,
}
}
+ empathy_tp_chat_set_acknowledge (priv->tp_chat, TRUE);
+ empathy_tp_chat_emit_pendings (priv->tp_chat);
+
g_object_notify (G_OBJECT (chat), "tp-chat");
g_object_notify (G_OBJECT (chat), "id");
g_object_notify (G_OBJECT (chat), "account");
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index 430014759..34fcf64dc 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -796,7 +796,7 @@ tp_chat_channel_ready_cb (EmpathyTpChat *chat)
}
tp_cli_channel_type_text_call_list_pending_messages (priv->channel, -1,
- priv->acknowledge,
+ FALSE,
tp_chat_list_pending_messages_cb,
NULL, NULL,
G_OBJECT (chat));
@@ -1075,48 +1075,6 @@ empathy_tp_chat_new (TpChannel *channel,
NULL);
}
-void
-empathy_tp_chat_send (EmpathyTpChat *chat,
- EmpathyMessage *message)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
- const gchar *message_body;
- EmpathyMessageType message_type;
-
- g_return_if_fail (EMPATHY_IS_TP_CHAT (chat));
- g_return_if_fail (EMPATHY_IS_MESSAGE (message));
- g_return_if_fail (priv->ready);
-
- message_body = empathy_message_get_body (message);
- message_type = empathy_message_get_type (message);
-
- empathy_debug (DEBUG_DOMAIN, "Sending message: %s", message_body);
- tp_cli_channel_type_text_call_send (priv->channel, -1,
- message_type,
- message_body,
- tp_chat_async_cb,
- "sending message", NULL,
- G_OBJECT (chat));
-}
-
-void
-empathy_tp_chat_set_state (EmpathyTpChat *chat,
- TpChannelChatState state)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
-
- g_return_if_fail (EMPATHY_IS_TP_CHAT (chat));
- g_return_if_fail (priv->ready);
-
- empathy_debug (DEBUG_DOMAIN, "Set state: %d", state);
- tp_cli_channel_interface_chat_state_call_set_chat_state (priv->channel, -1,
- state,
- tp_chat_async_cb,
- "setting chat state",
- NULL,
- G_OBJECT (chat));
-}
-
const gchar *
empathy_tp_chat_get_id (EmpathyTpChat *chat)
{
@@ -1138,6 +1096,16 @@ empathy_tp_chat_get_remote_contact (EmpathyTpChat *chat)
return priv->remote_contact;
}
+McAccount *
+empathy_tp_chat_get_account (EmpathyTpChat *chat)
+{
+ EmpathyTpChatPriv *priv = GET_PRIV (chat);
+
+ g_return_val_if_fail (EMPATHY_IS_TP_CHAT (chat), FALSE);
+
+ return priv->account;
+}
+
gboolean
empathy_tp_chat_is_ready (EmpathyTpChat *chat)
{
@@ -1158,13 +1126,72 @@ empathy_tp_chat_get_members_count (EmpathyTpChat *chat)
return priv->members_count;
}
-McAccount *
-empathy_tp_chat_get_account (EmpathyTpChat *chat)
+void
+empathy_tp_chat_set_acknowledge (EmpathyTpChat *chat,
+ gboolean acknowledge)
{
EmpathyTpChatPriv *priv = GET_PRIV (chat);
- g_return_val_if_fail (EMPATHY_IS_TP_CHAT (chat), FALSE);
+ g_return_if_fail (EMPATHY_IS_TP_CHAT (chat));
- return priv->account;
+ priv->acknowledge = acknowledge;
+ g_object_notify (G_OBJECT (chat), "acknowledge");
+}
+
+void
+empathy_tp_chat_emit_pendings (EmpathyTpChat *chat)
+{
+ EmpathyTpChatPriv *priv = GET_PRIV (chat);
+
+ g_return_if_fail (EMPATHY_IS_TP_CHAT (chat));
+ g_return_if_fail (priv->ready);
+
+ tp_cli_channel_type_text_call_list_pending_messages (priv->channel, -1,
+ FALSE,
+ tp_chat_list_pending_messages_cb,
+ NULL, NULL,
+ G_OBJECT (chat));
+}
+
+void
+empathy_tp_chat_send (EmpathyTpChat *chat,
+ EmpathyMessage *message)
+{
+ EmpathyTpChatPriv *priv = GET_PRIV (chat);
+ const gchar *message_body;
+ EmpathyMessageType message_type;
+
+ g_return_if_fail (EMPATHY_IS_TP_CHAT (chat));
+ g_return_if_fail (EMPATHY_IS_MESSAGE (message));
+ g_return_if_fail (priv->ready);
+
+ message_body = empathy_message_get_body (message);
+ message_type = empathy_message_get_type (message);
+
+ empathy_debug (DEBUG_DOMAIN, "Sending message: %s", message_body);
+ tp_cli_channel_type_text_call_send (priv->channel, -1,
+ message_type,
+ message_body,
+ tp_chat_async_cb,
+ "sending message", NULL,
+ G_OBJECT (chat));
+}
+
+void
+empathy_tp_chat_set_state (EmpathyTpChat *chat,
+ TpChannelChatState state)
+{
+ EmpathyTpChatPriv *priv = GET_PRIV (chat);
+
+ g_return_if_fail (EMPATHY_IS_TP_CHAT (chat));
+ g_return_if_fail (priv->ready);
+
+ empathy_debug (DEBUG_DOMAIN, "Set state: %d", state);
+ tp_cli_channel_interface_chat_state_call_set_chat_state (priv->channel, -1,
+ state,
+ tp_chat_async_cb,
+ "setting chat state",
+ NULL,
+ G_OBJECT (chat));
}
diff --git a/libempathy/empathy-tp-chat.h b/libempathy/empathy-tp-chat.h
index 22ebee57a..a6ac3598b 100644
--- a/libempathy/empathy-tp-chat.h
+++ b/libempathy/empathy-tp-chat.h
@@ -60,6 +60,9 @@ EmpathyContact*empathy_tp_chat_get_remote_contact (EmpathyTpChat *chat);
McAccount * empathy_tp_chat_get_account (EmpathyTpChat *chat);
gboolean empathy_tp_chat_is_ready (EmpathyTpChat *chat);
guint empathy_tp_chat_get_members_count (EmpathyTpChat *chat);
+void empathy_tp_chat_set_acknowledge (EmpathyTpChat *chat,
+ gboolean acknowledge);
+void empathy_tp_chat_emit_pendings (EmpathyTpChat *chat);
void empathy_tp_chat_send (EmpathyTpChat *chat,
EmpathyMessage *message);
void empathy_tp_chat_set_state (EmpathyTpChat *chat,