From 9dbdbe692285c70d2b2bf713f2b21b156a87055c Mon Sep 17 00:00:00 2001 From: Chandni Verma Date: Sat, 26 Feb 2011 04:29:46 +0530 Subject: Fire a "part-command-entered" signal from libempathy-gtk/empathy-chat.c to be caught in src/empathy-chat-window.c Fixes linking issues: https://bugzilla.gnome.org/show_bug.cgi?id=643295 --- libempathy-gtk/empathy-chat.c | 41 ++++++++++++----------------------------- libempathy-gtk/empathy-chat.h | 1 - src/empathy-chat-window.c | 24 ++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 30 deletions(-) diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index c146941b3..0b61d53f5 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -44,7 +44,6 @@ #include #include #include -#include #include "empathy-chat.h" #include "empathy-spell.h" @@ -158,6 +157,7 @@ typedef struct { enum { COMPOSING, NEW_MESSAGE, + PART_COMMAND_ENTERED, LAST_SIGNAL }; @@ -683,7 +683,6 @@ nick_command_supported (EmpathyChat *chat) EMP_IFACE_QUARK_CONNECTION_INTERFACE_RENAMING); } -#if 0 static gboolean part_command_supported (EmpathyChat *chat) { @@ -694,7 +693,6 @@ part_command_supported (EmpathyChat *chat) return tp_proxy_has_interface_by_id (channel, TP_IFACE_QUARK_CHANNEL_INTERFACE_GROUP); } -#endif static void chat_command_clear (EmpathyChat *chat, @@ -761,35 +759,12 @@ chat_command_join (EmpathyChat *chat, g_strfreev (rooms); } -void -empathy_chat_leave_chat (EmpathyChat *chat) -{ - EmpathyChatPriv *priv = GET_PRIV (chat); - - empathy_tp_chat_leave (priv->tp_chat, ""); -} - -#if 0 static void chat_command_part (EmpathyChat *chat, GStrv strv) { - EmpathyChatPriv *priv = GET_PRIV (chat); - EmpathyChat *chat_to_be_parted; - - if (strv[1] == NULL) { - empathy_tp_chat_leave (priv->tp_chat, ""); - return; - } - chat_to_be_parted = empathy_chat_window_find_chat (priv->account, strv[1]); - - if (chat_to_be_parted != NULL) { - empathy_tp_chat_leave (empathy_chat_get_tp_chat (chat_to_be_parted), strv[2]); - } else { - empathy_tp_chat_leave (priv->tp_chat, strv[1]); - } + g_signal_emit (chat, signals[PART_COMMAND_ENTERED], 0, strv); } -#endif static void chat_command_msg_internal (EmpathyChat *chat, @@ -940,12 +915,10 @@ static ChatCommandItem commands[] = { {"j", 2, 2, chat_command_join, NULL, N_("/j : join a new chat room")}, -#if 0 /* FIXME: https://bugzilla.gnome.org/show_bug.cgi?id=643295 */ {"part", 1, 3, chat_command_part, part_command_supported, N_("/part [] []: leave the chat room, " "by default the current one")}, -#endif {"query", 2, 3, chat_command_query, NULL, N_("/query []: open a private chat")}, @@ -2983,6 +2956,16 @@ empathy_chat_class_init (EmpathyChatClass *klass) G_TYPE_NONE, 2, EMPATHY_TYPE_MESSAGE, G_TYPE_BOOLEAN); + signals[PART_COMMAND_ENTERED] = + g_signal_new ("part-command-entered", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__POINTER, + G_TYPE_NONE, + 1, G_TYPE_STRV); + g_type_class_add_private (object_class, sizeof (EmpathyChatPriv)); } diff --git a/libempathy-gtk/empathy-chat.h b/libempathy-gtk/empathy-chat.h index 77122f7c8..6ec957536 100644 --- a/libempathy-gtk/empathy-chat.h +++ b/libempathy-gtk/empathy-chat.h @@ -85,7 +85,6 @@ void empathy_chat_correct_word (EmpathyChat *chat, const gchar *new_word); void empathy_chat_join_muc (EmpathyChat *chat, const gchar *room); -void empathy_chat_leave_chat (EmpathyChat *chat); gboolean empathy_chat_is_room (EmpathyChat *chat); void empathy_chat_set_show_contacts (EmpathyChat *chat, gboolean show); diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index 94f93e2bf..8da1cc2f2 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -1482,6 +1482,27 @@ chat_window_new_message_cb (EmpathyChat *chat, chat_window_icon_update (priv, TRUE); } +static void +chat_window_command_part (EmpathyChat *chat, + GStrv strv) +{ + EmpathyChat *chat_to_be_parted; + + if (strv[1] == NULL) { + empathy_tp_chat_leave (empathy_chat_get_tp_chat (chat), ""); + return; + } + chat_to_be_parted = empathy_chat_window_find_chat ( + empathy_chat_get_account (chat), strv[1]); + + if (chat_to_be_parted != NULL) { + empathy_tp_chat_leave (empathy_chat_get_tp_chat (chat_to_be_parted), + strv[2]); + } else { + empathy_tp_chat_leave (empathy_chat_get_tp_chat (chat), strv[1]); + } +} + static GtkNotebook * notebook_create_window_cb (GtkNotebook *source, GtkWidget *page, @@ -1567,6 +1588,9 @@ chat_window_page_added_cb (GtkNotebook *notebook, g_signal_connect (chat, "new-message", G_CALLBACK (chat_window_new_message_cb), window); + g_signal_connect (chat, "part-command-entered", + G_CALLBACK (chat_window_command_part), + NULL); g_signal_connect (chat, "notify::tp-chat", G_CALLBACK (chat_window_update_chat_tab), window); -- cgit v1.2.3 From 5324df2fe08ece901d34271afc56ac41e5100fbf Mon Sep 17 00:00:00 2001 From: Chandni Verma Date: Mon, 28 Feb 2011 05:07:31 +0530 Subject: Send full message for the default chat parted on part command --- libempathy/empathy-tp-chat.c | 3 +++ src/empathy-chat-window.c | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c index a56c08a32..87540f21a 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -1837,6 +1837,9 @@ empathy_tp_chat_leave (EmpathyTpChat *self, { EmpathyTpChatPriv *priv = GET_PRIV (self); + DEBUG ("Leaving channel %s with message \"%s\"", + tp_channel_get_identifier (priv->channel), message); + tp_channel_leave_async (priv->channel, TP_CHANNEL_GROUP_CHANGE_REASON_NONE, message, tp_channel_leave_async_cb, self); } diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index 8da1cc2f2..b7bb6c874 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -1499,7 +1499,20 @@ chat_window_command_part (EmpathyChat *chat, empathy_tp_chat_leave (empathy_chat_get_tp_chat (chat_to_be_parted), strv[2]); } else { - empathy_tp_chat_leave (empathy_chat_get_tp_chat (chat), strv[1]); + gchar *message; + + /* Going by the syntax of PART command: + * + * /PART [] [] + * + * Chatroom-ID is not a must to specify a reason. + * If strv[1] (chatroom-ID) is not a valid identifier for a connected + * MUC then the current chatroom should be parted and srtv[1] should + * be treated as part of the optional part-message. */ + message = g_strconcat (strv[1], " ", strv[2], NULL); + empathy_tp_chat_leave (empathy_chat_get_tp_chat (chat), message); + + g_free (message); } } -- cgit v1.2.3 From 0c9a992db9d0f8426264b097f0aa0cfaca860509 Mon Sep 17 00:00:00 2001 From: Chandni Verma Date: Mon, 9 May 2011 16:26:30 +0530 Subject: Leave chatroom only if tp_chat exists --- src/empathy-chat-window.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index b7bb6c874..61a1c5d47 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -1487,17 +1487,23 @@ chat_window_command_part (EmpathyChat *chat, GStrv strv) { EmpathyChat *chat_to_be_parted; + EmpathyTpChat *tp_chat = NULL; if (strv[1] == NULL) { - empathy_tp_chat_leave (empathy_chat_get_tp_chat (chat), ""); + /* No chatroom ID specified */ + tp_chat = empathy_chat_get_tp_chat (chat); + if (tp_chat) + empathy_tp_chat_leave (tp_chat, ""); return; } chat_to_be_parted = empathy_chat_window_find_chat ( empathy_chat_get_account (chat), strv[1]); if (chat_to_be_parted != NULL) { - empathy_tp_chat_leave (empathy_chat_get_tp_chat (chat_to_be_parted), - strv[2]); + /* Found a chatroom matching the specified ID */ + tp_chat = empathy_chat_get_tp_chat (chat_to_be_parted); + if (tp_chat) + empathy_tp_chat_leave (tp_chat, strv[2]); } else { gchar *message; @@ -1510,7 +1516,9 @@ chat_window_command_part (EmpathyChat *chat, * MUC then the current chatroom should be parted and srtv[1] should * be treated as part of the optional part-message. */ message = g_strconcat (strv[1], " ", strv[2], NULL); - empathy_tp_chat_leave (empathy_chat_get_tp_chat (chat), message); + tp_chat = empathy_chat_get_tp_chat (chat); + if (tp_chat) + empathy_tp_chat_leave (tp_chat, message); g_free (message); } -- cgit v1.2.3 From 34a7a0b348e1cdd3cfc184f135a8371d79741272 Mon Sep 17 00:00:00 2001 From: Chandni Verma Date: Mon, 9 May 2011 04:52:16 +0530 Subject: Password infobar amendments Destroy password infobar on parting password protected chatrooms and insensitivate input-text-view when displaying a new infobar --- libempathy-gtk/empathy-chat.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index 0b61d53f5..b2d091518 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -3287,6 +3287,18 @@ password_entry_changed_cb (GtkEditable *entry, GTK_ENTRY_ICON_SECONDARY, !EMP_STR_EMPTY (str)); } +static void +chat_invalidated_cb (TpProxy *proxy, + guint domain, + gint code, + gchar *message, + gpointer password_infobar) +{ + /* Destroy the password infobar whenever a channel is invalidated + * so we don't have multiple infobars when the MUC is rejoined */ + gtk_widget_destroy (GTK_WIDGET (password_infobar)); +} + static void display_password_info_bar (EmpathyChat *self) { @@ -3369,12 +3381,19 @@ display_password_info_bar (EmpathyChat *self) TRUE, TRUE, 3); gtk_widget_show_all (hbox); + tp_g_signal_connect_object (empathy_tp_chat_get_channel (priv->tp_chat), + "invalidated", G_CALLBACK (chat_invalidated_cb), + info_bar, 0); + data->response_id = g_signal_connect (info_bar, "response", G_CALLBACK (password_infobar_response_cb), data); gtk_widget_show_all (info_bar); /* ... but hide the spinner */ gtk_widget_hide (spinner); + + /* prevent the user from typing anything */ + gtk_widget_set_sensitive (self->input_text_view, FALSE); } static void -- cgit v1.2.3