From aa2be89aed362db3656d7b8938f78e3a9c64f142 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Thu, 8 May 2008 17:30:32 +0000 Subject: Avoid calling ListPendingMessage if it's already running. svn path=/trunk/; revision=1090 --- libempathy/empathy-tp-chat.c | 19 +++++++++++-------- libempathy/empathy-tp-chat.h | 3 +-- 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c index d4eedf492..f0d7820a9 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -47,7 +47,7 @@ typedef struct { TpChannel *channel; gchar *id; gboolean acknowledge; - gboolean had_pending_messages; + gboolean listing_pending_messages; GSList *message_queue; gboolean had_properties_list; GPtrArray *properties; @@ -370,7 +370,7 @@ tp_chat_received_cb (TpChannel *channel, EmpathyTpChatPriv *priv = GET_PRIV (chat); EmpathyMessage *message; - if (!priv->had_pending_messages) { + if (priv->listing_pending_messages) { return; } @@ -478,7 +478,7 @@ tp_chat_list_pending_messages_cb (TpChannel *channel, guint i; GArray *message_ids = NULL; - priv->had_pending_messages = TRUE; + priv->listing_pending_messages = FALSE; if (error) { DEBUG ("Error listing pending messages: %s", error->message); @@ -796,6 +796,7 @@ tp_chat_channel_ready_cb (EmpathyTpChat *chat) G_OBJECT (chat), NULL); } + priv->listing_pending_messages = TRUE; tp_cli_channel_type_text_call_list_pending_messages (priv->channel, -1, FALSE, tp_chat_list_pending_messages_cb, @@ -981,8 +982,7 @@ empathy_tp_chat_class_init (EmpathyTpChatClass *klass) "acknowledge messages", "Wheter or not received messages should be acknowledged", FALSE, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT)); + G_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_REMOTE_CONTACT, @@ -1071,12 +1071,10 @@ tp_chat_iface_init (EmpathyContactListIface *iface) } EmpathyTpChat * -empathy_tp_chat_new (TpChannel *channel, - gboolean acknowledge) +empathy_tp_chat_new (TpChannel *channel) { return g_object_new (EMPATHY_TYPE_TP_CHAT, "channel", channel, - "acknowledge", acknowledge, NULL); } @@ -1161,6 +1159,11 @@ empathy_tp_chat_emit_pendings (EmpathyTpChat *chat) g_return_if_fail (EMPATHY_IS_TP_CHAT (chat)); g_return_if_fail (priv->ready); + if (priv->listing_pending_messages) { + return; + } + + priv->listing_pending_messages = TRUE; tp_cli_channel_type_text_call_list_pending_messages (priv->channel, -1, FALSE, tp_chat_list_pending_messages_cb, diff --git a/libempathy/empathy-tp-chat.h b/libempathy/empathy-tp-chat.h index 0d5b4f94d..4aae240b8 100644 --- a/libempathy/empathy-tp-chat.h +++ b/libempathy/empathy-tp-chat.h @@ -53,8 +53,7 @@ struct _EmpathyTpChatClass { }; GType empathy_tp_chat_get_type (void) G_GNUC_CONST; -EmpathyTpChat *empathy_tp_chat_new (TpChannel *channel, - gboolean acknowledge); +EmpathyTpChat *empathy_tp_chat_new (TpChannel *channel); const gchar * empathy_tp_chat_get_id (EmpathyTpChat *chat); EmpathyContact*empathy_tp_chat_get_remote_contact (EmpathyTpChat *chat); McAccount * empathy_tp_chat_get_account (EmpathyTpChat *chat); -- cgit v1.2.3