]> git.0d.be Git - empathy.git/commitdiff
Merge remote-tracking branch 'pochu/error-dialog'
authorDanielle Madeley <danielle.madeley@collabora.co.uk>
Fri, 14 Oct 2011 04:31:16 +0000 (15:31 +1100)
committerDanielle Madeley <danielle.madeley@collabora.co.uk>
Fri, 14 Oct 2011 04:32:13 +0000 (15:32 +1100)
1  2 
libempathy-gtk/empathy-chat.c
libempathy-gtk/empathy-individual-menu.c
libempathy/empathy-auth-factory.c
src/empathy-chat-manager.c
src/empathy-chat-window.c

index bdb97be3a5a10bcea1529cdebabdb496a2b8698c,cf01632b48f6645e61d93a49b729f9ce18eb6022..b1d469f3f2c8d7ae3ccad16077d1598ff16b5c1c
  #include "empathy-contact-list-store.h"
  #include "empathy-contact-list-view.h"
  #include "empathy-contact-menu.h"
 -#include "empathy-gtk-marshal.h"
  #include "empathy-input-text-view.h"
  #include "empathy-search-bar.h"
  #include "empathy-theme-manager.h"
 +#include "empathy-theme-adium.h"
  #include "empathy-smiley-manager.h"
  #include "empathy-ui-utils.h"
  #include "empathy-string-parser.h"
@@@ -106,8 -106,6 +106,8 @@@ struct _EmpathyChatPriv 
        guint              update_misspelled_words_id;
        /* Source func ID for save_paned_pos_timeout () */
        guint              save_paned_pos_id;
 +      /* Source func ID for chat_contacts_visible_timeout_cb () */
 +      guint              contacts_visible_id;
  
        GtkWidget         *widget;
        GtkWidget         *hpaned;
@@@ -277,11 -275,13 +277,13 @@@ account_reconnected (EmpathyChat *chat
                        if (priv->sms_channel)
                                empathy_sms_contact_id (
                                        account, priv->id,
-                                       TP_USER_ACTION_TIME_NOT_USER_ACTION);
+                                       TP_USER_ACTION_TIME_NOT_USER_ACTION,
+                                       NULL, NULL);
                        else
                                empathy_chat_with_contact_id (
                                        account, priv->id,
-                                       TP_USER_ACTION_TIME_NOT_USER_ACTION);
+                                       TP_USER_ACTION_TIME_NOT_USER_ACTION,
+                                       NULL, NULL);
                        break;
                case TP_HANDLE_TYPE_ROOM:
                        empathy_join_muc (account, priv->id,
@@@ -1014,44 -1014,6 +1016,44 @@@ chat_command_whois (EmpathyChat *chat
                whois_got_contact_cb, NULL, NULL, G_OBJECT (chat));
  }
  
 +static void
 +chat_command_whale (EmpathyChat *chat,
 +                  GStrv        strv)
 +{
 +      EmpathyChatPriv *priv = GET_PRIV (chat);
 +      TpMessage *message;
 +
 +      message = tp_client_message_new_text (TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL,
 +              "\n\n\n"
 +              "•_______________•");
 +      empathy_tp_chat_send (priv->tp_chat, message);
 +      g_object_unref (message);
 +}
 +
 +static void
 +chat_command_babywhale (EmpathyChat *chat,
 +                      GStrv        strv)
 +{
 +      EmpathyChatPriv *priv = GET_PRIV (chat);
 +      TpMessage *message;
 +
 +      message = tp_client_message_new_text (TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL,
 +              "\n"
 +              "•_____•");
 +      empathy_tp_chat_send (priv->tp_chat, message);
 +      g_object_unref (message);
 +}
 +
 +static void
 +chat_command_inspector (EmpathyChat *chat,
 +                  GStrv        strv)
 +{
 +      if (EMPATHY_IS_THEME_ADIUM (chat->view)) {
 +              empathy_theme_adium_show_inspector (
 +                      EMPATHY_THEME_ADIUM (chat->view));
 +      }
 +}
 +
  static void chat_command_help (EmpathyChat *chat, GStrv strv);
  
  typedef void (*ChatCommandFunc) (EmpathyChat *chat, GStrv strv);
@@@ -1106,11 -1068,6 +1108,11 @@@ static ChatCommandItem commands[] = 
        {"help", 1, 2, chat_command_help, NULL,
         N_("/help [<command>]: show all supported commands. "
            "If <command> is defined, show its usage.")},
 +
 +      {"inspector", 1, 1, chat_command_inspector, NULL, NULL},
 +
 +      {"whale", 1, 1, chat_command_whale, NULL, NULL},
 +      {"babywhale", 1, 1, chat_command_babywhale, NULL, NULL},
  };
  
  static void
@@@ -1119,10 -1076,6 +1121,10 @@@ chat_command_show_help (EmpathyCha
  {
        gchar *str;
  
 +      if (item->help == NULL) {
 +              return;
 +      }
 +
        str = g_strdup_printf (_("Usage: %s"), _(item->help));
        empathy_chat_view_append_event (chat->view, str);
        g_free (str);
@@@ -1143,11 -1096,8 +1145,11 @@@ chat_command_help (EmpathyChat *chat
                                        continue;
                                }
                        }
 -                  empathy_chat_view_append_event (chat->view,
 -                          _(commands[i].help));
 +                      if (commands[i].help == NULL) {
 +                              continue;
 +                      }
 +                      empathy_chat_view_append_event (chat->view,
 +                              _(commands[i].help));
                }
                return;
        }
                                        break;
                                }
                        }
 +                      if (commands[i].help == NULL) {
 +                              break;
 +                      }
                        chat_command_show_help (chat, &commands[i]);
                        return;
                }
@@@ -1451,51 -1398,6 +1453,51 @@@ chat_message_acknowledged_cb (EmpathyTp
        }
  }
  
 +static void
 +append_balance_error (EmpathyChat *chat,
 +                    const gchar *message_body)
 +{
 +      EmpathyChatPriv *priv = GET_PRIV (chat);
 +      TpConnection *conn = tp_channel_borrow_connection (TP_CHANNEL (priv->tp_chat));
 +      const gchar *uri = tp_connection_get_balance_uri (conn);
 +      const gchar *error = _("insufficient balance to send message");
 +      gchar *str, *str_markup = NULL;
 +
 +      if (message_body != NULL) {
 +              str = g_strdup_printf (_("Error sending message '%s': %s"), message_body, error);
 +      } else {
 +              str = g_strdup_printf (_("Error sending message: %s"), error);
 +      }
 +
 +      if (!tp_str_empty (uri)) {
 +              /* translators: error used when user doesn't have enough credit on his
 +               * account to send the message. */
 +              gchar *markup_error = g_strdup_printf (_("insufficient balance to send message."
 +                                                       " <a href='%s'>Top up</a>."), uri);
 +
 +              if (message_body != NULL) {
 +                      gchar *escaped_body = g_markup_escape_text (message_body, -1);
 +
 +                      str_markup = g_strdup_printf (_("Error sending message '%s': %s"),
 +                              escaped_body, markup_error);
 +
 +                      g_free (escaped_body);
 +              } else {
 +                      str_markup = g_strdup_printf (_("Error sending message: %s"), markup_error);
 +              }
 +
 +              g_free (markup_error);
 +      }
 +
 +      if (str_markup != NULL)
 +              empathy_chat_view_append_event_markup (chat->view, str_markup, str);
 +      else
 +              empathy_chat_view_append_event (chat->view, str);
 +
 +      g_free (str);
 +      g_free (str_markup);
 +}
 +
  static void
  chat_send_error_cb (EmpathyTpChat          *tp_chat,
                    const gchar            *message_body,
        gchar       *str;
  
        if (!tp_strdiff (dbus_error, TP_ERROR_STR_INSUFFICIENT_BALANCE)) {
 -              /* translators: error used when user doesn't have enough credit on his
 -               * account to send the message. */
 -              error = _("insufficient balance to send message");
 +              append_balance_error (chat, message_body);
 +              return;
        } else if (!tp_strdiff (dbus_error, TP_ERROR_STR_NOT_CAPABLE)) {
                error = _("not capable");
        }
@@@ -2694,22 -2597,9 +2696,22 @@@ chat_member_renamed_cb (EmpathyTpChat  
  }
  
  static gboolean
 -chat_reset_size_request (gpointer widget)
 +chat_contacts_visible_timeout_cb (gpointer chat)
  {
 -      gtk_widget_set_size_request (widget, -1, -1);
 +      EmpathyChatPriv *priv = GET_PRIV (chat);
 +
 +      /* Relax the size request */
 +      gtk_widget_set_size_request (priv->vbox_left, -1, -1);
 +
 +      /* Set the position of the slider. This must be done here because
 +       * GtkPaned need to know its size allocation and it will be settled only
 +       * after the gtk_window_resize () tough effect. */
 +      if (priv->contacts_width > 0) {
 +              gtk_paned_set_position (GTK_PANED (priv->hpaned),
 +                                      priv->contacts_width);
 +      }
 +
 +      priv->contacts_visible_id = 0;
  
        return FALSE;
  }
@@@ -2719,6 -2609,7 +2721,6 @@@ chat_update_contacts_visibility (Empath
                         gboolean show)
  {
        EmpathyChatPriv *priv = GET_PRIV (chat);
 -      GtkAllocation allocation;
  
        if (!priv->scrolled_window_contacts) {
                return;
        if (show && priv->contact_list_view == NULL) {
                EmpathyContactListStore *store;
                gint                     min_width;
 +              GtkAllocation            allocation;
  
                /* We are adding the contact list to the chat, we don't want the
                 * chat view to become too small. If the chat view is already
                gtk_widget_get_allocation (priv->vbox_left, &allocation);
                min_width = MIN (allocation.width, 250);
                gtk_widget_set_size_request (priv->vbox_left, min_width, -1);
 -              g_idle_add (chat_reset_size_request, priv->vbox_left);
  
 -              if (priv->contacts_width > 0) {
 -                      gtk_paned_set_position (GTK_PANED (priv->hpaned),
 -                                              priv->contacts_width);
 -              }
 +              /* There is no way to know when the window resize will happen
 +               * since it is WM's decision. Let's hope it won't be longer. */
 +              if (priv->contacts_visible_id != 0)
 +                      g_source_remove (priv->contacts_visible_id);
 +              priv->contacts_visible_id = g_timeout_add (500,
 +                      chat_contacts_visible_timeout_cb, chat);
  
                store = empathy_contact_list_store_new (
                                EMPATHY_CONTACT_LIST (priv->tp_chat));
@@@ -2990,6 -2879,7 +2992,6 @@@ chat_create_ui (EmpathyChat *chat
        GList           *list = NULL;
        gchar           *filename;
        GtkTextBuffer   *buffer;
 -      gint              paned_pos;
        EmpathyThemeManager *theme_mgr;
  
        filename = empathy_file_lookup ("empathy-chat.ui",
                          G_CALLBACK (chat_hpaned_pos_changed_cb),
                          chat);
  
 -        /* Load the paned position */
 -      paned_pos = g_settings_get_int (priv->gsettings_ui,
 -                      EMPATHY_PREFS_UI_CHAT_WINDOW_PANED_POS);
 -      if (paned_pos != 0)
 -              gtk_paned_set_position (GTK_PANED(priv->hpaned), paned_pos);
 -
        /* Set widget focus order */
        list = g_list_append (NULL, priv->search_bar);
        list = g_list_append (list, priv->scrolled_window_input);
@@@ -3113,9 -3009,6 +3115,9 @@@ chat_finalize (GObject *object
        if (priv->save_paned_pos_id != 0)
                g_source_remove (priv->save_paned_pos_id);
  
 +      if (priv->contacts_visible_id != 0)
 +              g_source_remove (priv->contacts_visible_id);
 +
        g_object_unref (priv->gsettings_chat);
        g_object_unref (priv->gsettings_ui);
  
@@@ -3284,7 -3177,7 +3286,7 @@@ empathy_chat_class_init (EmpathyChatCla
                              G_SIGNAL_RUN_LAST,
                              0,
                              NULL, NULL,
 -                            g_cclosure_marshal_VOID__BOOLEAN,
 +                            g_cclosure_marshal_generic,
                              G_TYPE_NONE,
                              1, G_TYPE_BOOLEAN);
  
                              G_SIGNAL_RUN_LAST,
                              0,
                              NULL, NULL,
 -                            _empathy_gtk_marshal_VOID__OBJECT_BOOLEAN,
 +                            g_cclosure_marshal_generic,
                              G_TYPE_NONE,
                              2, EMPATHY_TYPE_MESSAGE, G_TYPE_BOOLEAN);
  
                                  G_SIGNAL_RUN_LAST,
                                  0,
                                  NULL, NULL,
 -                                g_cclosure_marshal_VOID__POINTER,
 +                                g_cclosure_marshal_generic,
                                  G_TYPE_NONE,
                                  1, G_TYPE_STRV);
  
@@@ -3331,7 -3224,7 +3333,7 @@@ account_manager_prepared_cb (GObject *s
        EmpathyChat *chat = user_data;
        GError *error = NULL;
  
 -      if (!tp_account_manager_prepare_finish (account_manager, result, &error)) {
 +      if (!tp_proxy_prepare_finish (account_manager, result, &error)) {
                DEBUG ("Failed to prepare the account manager: %s", error->message);
                g_error_free (error);
                return;
@@@ -3360,13 -3253,12 +3362,13 @@@ empathy_chat_init (EmpathyChat *chat
        priv->gsettings_chat = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA);
        priv->gsettings_ui = g_settings_new (EMPATHY_PREFS_UI_SCHEMA);
  
 -      priv->contacts_width = -1;
 +      priv->contacts_width = g_settings_get_int (priv->gsettings_ui,
 +              EMPATHY_PREFS_UI_CHAT_WINDOW_PANED_POS);
        priv->input_history = NULL;
        priv->input_history_current = NULL;
        priv->account_manager = tp_account_manager_dup ();
  
 -      tp_account_manager_prepare_async (priv->account_manager, NULL,
 +      tp_proxy_prepare_async (priv->account_manager, NULL,
                                          account_manager_prepared_cb, chat);
  
        priv->show_contacts = g_settings_get_boolean (priv->gsettings_chat,
index 77cbc57d5427eb11550dbe5574cda0c15c9cac77,1a3dbb7e1e8be7750ad86b5680bd9510e42a861c..2209e1538915861cf476bdda6c256f5782b72d6b
@@@ -664,7 -664,7 +664,7 @@@ empathy_individual_menu_class_init (Emp
    signals[SIGNAL_LINK_CONTACTS_ACTIVATED] =
        g_signal_new ("link-contacts-activated", G_OBJECT_CLASS_TYPE (klass),
            G_SIGNAL_RUN_LAST, 0, NULL, NULL,
 -          g_cclosure_marshal_VOID__OBJECT,
 +          g_cclosure_marshal_generic,
            G_TYPE_NONE, 1, EMPATHY_TYPE_LINKING_DIALOG);
  
    g_type_class_add_private (object_class, sizeof (EmpathyIndividualMenuPriv));
@@@ -786,7 -786,8 +786,8 @@@ empathy_individual_sms_menu_item_activa
    empathy_sms_contact_id (
        empathy_contact_get_account (contact),
        empathy_contact_get_id (contact),
-       empathy_get_current_action_time ());
+       empathy_get_current_action_time (),
+       NULL, NULL);
  }
  
  GtkWidget *
@@@ -1131,9 -1132,8 +1132,9 @@@ empathy_individual_edit_menu_item_new (
        manager = empathy_individual_manager_dup_singleton ();
        connection = empathy_contact_get_connection (contact);
  
 -      enable = (empathy_connection_can_alias_personas (connection) &&
 -                empathy_connection_can_group_personas (connection));
 +      enable = (empathy_connection_can_alias_personas (connection,
 +                                                     individual) &&
 +                empathy_connection_can_group_personas (connection, individual));
  
        g_object_unref (manager);
      }
index 4eb5134ddf5b44dee2c24cc4ae18b90d6a04c983,069f60756504f7e795b5258ca6c6ab12ce2049e3..6368b1d7d914852506f49e444d351a7810d6d3c3
@@@ -20,9 -20,7 +20,7 @@@
  
  #include "empathy-auth-factory.h"
  
- #include <telepathy-glib/interfaces.h>
- #include <telepathy-glib/simple-handler.h>
- #include <telepathy-glib/util.h>
+ #include <telepathy-glib/telepathy-glib.h>
  
  #define DEBUG_FLAG EMPATHY_DEBUG_TLS
  #include "empathy-debug.h"
@@@ -552,7 -550,7 +550,7 @@@ empathy_auth_factory_class_init (Empath
        G_TYPE_FROM_CLASS (klass),
        G_SIGNAL_RUN_LAST, 0,
        NULL, NULL,
 -      g_cclosure_marshal_VOID__OBJECT,
 +      g_cclosure_marshal_generic,
        G_TYPE_NONE,
        1, EMPATHY_TYPE_SERVER_TLS_HANDLER);
  
        G_TYPE_FROM_CLASS (klass),
        G_SIGNAL_RUN_LAST, 0,
        NULL, NULL,
 -      g_cclosure_marshal_VOID__OBJECT,
 +      g_cclosure_marshal_generic,
        G_TYPE_NONE,
        1, EMPATHY_TYPE_SERVER_SASL_HANDLER);
  }
index 7f37cc5c4633f60d60382d5ffeb4db45a4be259a,5f19159c5aa29f70a46d0da4818d91b0f67f2a55..a52585736d51426183b0d0f64d0ce553ecee5336
@@@ -349,7 -349,7 +349,7 @@@ empathy_chat_manager_class_init 
          G_SIGNAL_RUN_LAST,
          0,
          NULL, NULL,
 -        g_cclosure_marshal_VOID__UINT,
 +        g_cclosure_marshal_generic,
          G_TYPE_NONE,
          1, G_TYPE_UINT, NULL);
  
          G_SIGNAL_RUN_LAST,
          0,
          NULL, NULL,
 -        g_cclosure_marshal_VOID__UINT,
 +        g_cclosure_marshal_generic,
          G_TYPE_NONE,
          1, G_TYPE_UINT, NULL);
  
@@@ -448,9 -448,11 +448,11 @@@ empathy_chat_manager_undo_closed_chat (
    if (data->room)
      empathy_join_muc (data->account, data->id, timestamp);
    else if (data->sms)
-     empathy_sms_contact_id (data->account, data->id, timestamp);
+     empathy_sms_contact_id (data->account, data->id, timestamp,
+         NULL, NULL);
    else
-     empathy_chat_with_contact_id (data->account, data->id, timestamp);
+     empathy_chat_with_contact_id (data->account, data->id, timestamp,
+         NULL, NULL);
  
    g_signal_emit (self, signals[CLOSED_CHATS_CHANGED], 0,
        g_queue_get_length (priv->closed_queue));
index 44f3dcce39d761ef9177a3ed130168ce83d792d1,a84eef7a0322d5fbe429f1fac50d48ebb7e05ba1..46f76466b2d838b9ea945a7e9b98a72572453138
@@@ -1482,7 -1482,8 +1482,7 @@@ chat_window_new_message_cb (EmpathyCha
         *   a) the chatroom's always_urgent property is TRUE
         *   b) the message contains our alias
         */
 -      if (empathy_chat_is_room (chat) ||
 -          empathy_chat_get_remote_contact (chat) == NULL) {
 +      if (empathy_chat_is_room (chat)) {
                TpAccount             *account;
                const gchar           *room;
                EmpathyChatroom       *chatroom;
@@@ -1865,7 -1866,9 +1865,9 @@@ chat_window_drag_data_received (GtkWidg
  
                if (!chat) {
                        empathy_chat_with_contact_id (
-                               account, contact_id, empathy_get_current_action_time ());
+                               account, contact_id,
+                               empathy_get_current_action_time (),
+                               NULL, NULL);
  
                        g_strfreev (strv);
                        return;