From 73a749cafbd78b45494aa5eba645ef2fe9c4e21a Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Fri, 20 Jul 2007 15:26:30 +0000 Subject: Initial room list support. It does not works yet. 2007-07-20 Xavier Claessens * libempathy/Makefile.am: * libempathy/empathy-tp-roomlist.h: * libempathy/empathy-tp-roomlist.c: * libempathy-gtk/empathy-chatrooms-window.c: * libempathy-gtk/empathy-new-chatroom-dialog.c: Initial room list support. It does not works yet. * libempathy-gtk/empathy-account-widget-generic.c: Add support for all types of integer and float. Fixes bug #457740 (Jamey Hicks). * libempathy/empathy-tp-chat.c: * libempathy-gtk/empathy-chat.c: If there is an error sending a message, show an error message to the user. * libempathy-gtk/empathy-accounts-dialog.c: Fix a leak, profile should be unrefed after mc_account_get_profile. * libempathy/empathy-utils.c: * libempathy/empathy-utils.h: * libempathy/empathy-tp-chatroom.c: * libempathy/empathy-tp-group.h: * libempathy/empathy-tp-group.c: * src/empathy.c: Rename empathy_get_channel_id() to empathy_inspect_channel(). We now have empathy_inspect_handle(). * po/POTFILES.in: * libempathy/empathy-tp-contact-list.c: Set all contacts from salut protocol to the "Local Network" group. * libempathy/empathy-idle.c: Fix NetworkManager support. * libempathy/empathy-chatroom.h: Fix indentation. * libempathy-gtk/empathy-status-icon.c: * libempathy-gtk/empathy-ui-utils.c: * libempathy-gtk/empathy-ui-utils.h: - Iconify main window to the status icon like in rhythmbox. Fixes bug #458106 (Jaap A. Haitsma). - Rounded avatars. Fixes bug #457992 (Raphael Slinckx) * Makefile.am: Fix distcheck for gtkdoc (Vincent Untz) * data/empathy.desktop.in.in: Change application description (Jaap A. Haitsma). svn path=/trunk/; revision=190 --- libempathy-gtk/empathy-chat.c | 147 ++++++++++++++++++++++++++++-------------- 1 file changed, 97 insertions(+), 50 deletions(-) (limited to 'libempathy-gtk/empathy-chat.c') diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index 8f6ca3705..304e8d447 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -94,56 +94,60 @@ typedef struct { GtkTextIter end; } EmpathyChatSpell; -static void empathy_chat_class_init (EmpathyChatClass *klass); -static void empathy_chat_init (EmpathyChat *chat); -static void chat_finalize (GObject *object); -static void chat_destroy_cb (EmpathyTpChat *tp_chat, - EmpathyChat *chat); -static void chat_send (EmpathyChat *chat, - const gchar *msg); -static void chat_input_text_view_send (EmpathyChat *chat); -static void chat_message_received_cb (EmpathyTpChat *tp_chat, - EmpathyMessage *message, - EmpathyChat *chat); -void chat_sent_message_add (EmpathyChat *chat, - const gchar *str); -const gchar * chat_sent_message_get_next (EmpathyChat *chat); -const gchar * chat_sent_message_get_last (EmpathyChat *chat); -static gboolean chat_input_key_press_event_cb (GtkWidget *widget, - GdkEventKey *event, - EmpathyChat *chat); -static void chat_input_text_buffer_changed_cb (GtkTextBuffer *buffer, - EmpathyChat *chat); -static gboolean chat_text_view_focus_in_event_cb (GtkWidget *widget, - GdkEvent *event, - EmpathyChat *chat); -static void chat_text_view_scroll_hide_cb (GtkWidget *widget, - EmpathyChat *chat); -static void chat_text_view_size_allocate_cb (GtkWidget *widget, - GtkAllocation *allocation, - EmpathyChat *chat); -static void chat_text_view_realize_cb (GtkWidget *widget, - EmpathyChat *chat); -static void chat_text_populate_popup_cb (GtkTextView *view, - GtkMenu *menu, - EmpathyChat *chat); -static void chat_text_check_word_spelling_cb (GtkMenuItem *menuitem, - EmpathyChatSpell *chat_spell); -static EmpathyChatSpell *chat_spell_new (EmpathyChat *chat, - const gchar *word, - GtkTextIter start, - GtkTextIter end); -static void chat_spell_free (EmpathyChatSpell *chat_spell); -static void chat_composing_start (EmpathyChat *chat); -static void chat_composing_stop (EmpathyChat *chat); -static void chat_composing_remove_timeout (EmpathyChat *chat); -static gboolean chat_composing_stop_timeout_cb (EmpathyChat *chat); -static void chat_state_changed_cb (EmpathyTpChat *tp_chat, - EmpathyContact *contact, - TelepathyChannelChatState state, - EmpathyChat *chat); -static void chat_add_logs (EmpathyChat *chat); -static gboolean chat_scroll_down_idle_func (EmpathyChat *chat); +static void empathy_chat_class_init (EmpathyChatClass *klass); +static void empathy_chat_init (EmpathyChat *chat); +static void chat_finalize (GObject *object); +static void chat_destroy_cb (EmpathyTpChat *tp_chat, + EmpathyChat *chat); +static void chat_send (EmpathyChat *chat, + const gchar *msg); +static void chat_input_text_view_send (EmpathyChat *chat); +static void chat_message_received_cb (EmpathyTpChat *tp_chat, + EmpathyMessage *message, + EmpathyChat *chat); +static void chat_send_error_cb (EmpathyTpChat *tp_chat, + EmpathyMessage *message, + TelepathyChannelTextSendError error_code, + EmpathyChat *chat); +void chat_sent_message_add (EmpathyChat *chat, + const gchar *str); +const gchar * chat_sent_message_get_next (EmpathyChat *chat); +const gchar * chat_sent_message_get_last (EmpathyChat *chat); +static gboolean chat_input_key_press_event_cb (GtkWidget *widget, + GdkEventKey *event, + EmpathyChat *chat); +static void chat_input_text_buffer_changed_cb (GtkTextBuffer *buffer, + EmpathyChat *chat); +static gboolean chat_text_view_focus_in_event_cb (GtkWidget *widget, + GdkEvent *event, + EmpathyChat *chat); +static void chat_text_view_scroll_hide_cb (GtkWidget *widget, + EmpathyChat *chat); +static void chat_text_view_size_allocate_cb (GtkWidget *widget, + GtkAllocation *allocation, + EmpathyChat *chat); +static void chat_text_view_realize_cb (GtkWidget *widget, + EmpathyChat *chat); +static void chat_text_populate_popup_cb (GtkTextView *view, + GtkMenu *menu, + EmpathyChat *chat); +static void chat_text_check_word_spelling_cb (GtkMenuItem *menuitem, + EmpathyChatSpell *chat_spell); +static EmpathyChatSpell *chat_spell_new (EmpathyChat *chat, + const gchar *word, + GtkTextIter start, + GtkTextIter end); +static void chat_spell_free (EmpathyChatSpell *chat_spell); +static void chat_composing_start (EmpathyChat *chat); +static void chat_composing_stop (EmpathyChat *chat); +static void chat_composing_remove_timeout (EmpathyChat *chat); +static gboolean chat_composing_stop_timeout_cb (EmpathyChat *chat); +static void chat_state_changed_cb (EmpathyTpChat *tp_chat, + EmpathyContact *contact, + TelepathyChannelChatState state, + EmpathyChat *chat); +static void chat_add_logs (EmpathyChat *chat); +static gboolean chat_scroll_down_idle_func (EmpathyChat *chat); enum { COMPOSING, @@ -424,6 +428,43 @@ chat_message_received_cb (EmpathyTpChat *tp_chat, g_signal_emit (chat, signals[NEW_MESSAGE], 0, message, FALSE); } +static void +chat_send_error_cb (EmpathyTpChat *tp_chat, + EmpathyMessage *message, + TelepathyChannelTextSendError error_code, + EmpathyChat *chat) +{ + const gchar *error; + gchar *str; + + switch (error_code) { + case TP_CHANNEL_TEXT_SEND_ERROR_OFFLINE: + error = _("offline"); + break; + case TP_CHANNEL_TEXT_SEND_ERROR_INVALID_CONTACT: + error = _("invalid contact"); + break; + case TP_CHANNEL_TEXT_SEND_ERROR_PERMISSION_DENIED: + error = _("permission denied"); + break; + case TP_CHANNEL_TEXT_SEND_ERROR_TOO_LONG: + error = _("too long message"); + break; + case TP_CHANNEL_TEXT_SEND_ERROR_NOT_IMPLEMENTED: + error = _("not implemented"); + break; + default: + error = _("unknown"); + break; + } + + str = g_strdup_printf (_("Error sending message '%s': %s"), + empathy_message_get_body (message), + error); + empathy_chat_view_append_event (chat->view, str); + g_free (str); +} + void chat_sent_message_add (EmpathyChat *chat, const gchar *str) @@ -1307,6 +1348,9 @@ empathy_chat_set_tp_chat (EmpathyChat *chat, g_signal_handlers_disconnect_by_func (priv->tp_chat, chat_message_received_cb, chat); + g_signal_handlers_disconnect_by_func (priv->tp_chat, + chat_send_error_cb, + chat); g_signal_handlers_disconnect_by_func (priv->tp_chat, chat_destroy_cb, chat); @@ -1326,6 +1370,9 @@ empathy_chat_set_tp_chat (EmpathyChat *chat, g_signal_connect (tp_chat, "message-received", G_CALLBACK (chat_message_received_cb), chat); + g_signal_connect (tp_chat, "send-error", + G_CALLBACK (chat_send_error_cb), + chat); g_signal_connect (tp_chat, "chat-state-changed", G_CALLBACK (chat_state_changed_cb), chat); -- cgit v1.2.3