]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-log-window.c
Updated Spanish translation
[empathy.git] / libempathy-gtk / empathy-log-window.c
index f386388807f951437512509cebfd48c1fd0b9d28..d58de82e4e20b889e123ee752f5616c1a750f50f 100644 (file)
  */
 
 #include "config.h"
-
-#include <string.h>
-#include <stdlib.h>
+#include "empathy-log-window.h"
 
 #include <glib/gi18n-lib.h>
-#include <gtk/gtk.h>
-#include <webkit/webkit.h>
-
-#include <telepathy-glib/telepathy-glib.h>
 #include <telepathy-glib/proxy-subclass.h>
+#include <tp-account-widgets/tpaw-builder.h>
+#include <tp-account-widgets/tpaw-images.h>
+#include <tp-account-widgets/tpaw-camera-monitor.h>
+#include <tp-account-widgets/tpaw-utils.h>
+#include <telepathy-glib/telepathy-glib-dbus.h>
 
-#include <telepathy-logger/telepathy-logger.h>
-
-#include <extensions/extensions.h>
-
-#include <libempathy/action-chain-internal.h>
-#include <libempathy/empathy-camera-monitor.h>
-#include <libempathy/empathy-chatroom-manager.h>
-#include <libempathy/empathy-chatroom.h>
-#include <libempathy/empathy-gsettings.h>
-#include <libempathy/empathy-message.h>
-#include <libempathy/empathy-request-util.h>
-#include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-time.h>
-
-#include "empathy-log-window.h"
+#include "action-chain-internal.h"
 #include "empathy-account-chooser.h"
 #include "empathy-call-utils.h"
-#include "empathy-chat-view.h"
-#include "empathy-contact-dialogs.h"
+#include "empathy-geometry.h"
+#include "empathy-gsettings.h"
 #include "empathy-images.h"
+#include "empathy-individual-information-dialog.h"
+#include "empathy-request-util.h"
 #include "empathy-theme-manager.h"
 #include "empathy-ui-utils.h"
+#include "empathy-utils.h"
 #include "empathy-webkit-utils.h"
-#include "empathy-geometry.h"
+#include "extensions.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
-#include <libempathy/empathy-debug.h>
+#include "empathy-debug.h"
 
 #define EMPATHY_NS "http://live.gnome.org/Empathy"
 
@@ -105,7 +93,7 @@ struct _EmpathyLogWindowPriv
   EmpathyContact *selected_contact;
   EmpathyContact *events_contact;
 
-  EmpathyCameraMonitor *camera_monitor;
+  TpawCameraMonitor *camera_monitor;
   GBinding *button_video_binding;
 
   /* Used to cancel logger calls when no longer needed */
@@ -320,11 +308,17 @@ static void
 toolbutton_profile_clicked (GtkToolButton *toolbutton,
     EmpathyLogWindow *self)
 {
+  FolksIndividual *individual;
+
   g_return_if_fail (self != NULL);
   g_return_if_fail (EMPATHY_IS_CONTACT (self->priv->selected_contact));
 
-  empathy_contact_information_dialog_show (self->priv->selected_contact,
-      GTK_WINDOW (self));
+  individual = empathy_ensure_individual_from_tp_contact (
+      empathy_contact_get_tp_contact (self->priv->selected_contact));
+
+  empathy_display_individual_info (individual);
+
+  g_object_unref (individual);
 }
 
 static void
@@ -352,7 +346,7 @@ toolbutton_av_clicked (GtkToolButton *toolbutton,
   empathy_call_new_with_streams (
       empathy_contact_get_id (self->priv->selected_contact),
       empathy_contact_get_account (self->priv->selected_contact),
-      TRUE, video, gtk_get_current_event_time ());
+      video, gtk_get_current_event_time ());
 }
 
 static void
@@ -364,7 +358,9 @@ insert_or_change_row (EmpathyLogWindow *self,
 {
   char *str = gtk_tree_path_to_string (path);
   char *script, *text, *date, *stock_icon;
+  GString *escaped_text;
   char *icon = NULL;
+  gint i;
 
   gtk_tree_model_get (model, iter,
       COL_EVENTS_TEXT, &text,
@@ -382,19 +378,37 @@ insert_or_change_row (EmpathyLogWindow *self,
       if (icon_info != NULL)
         icon = g_strdup (gtk_icon_info_get_filename (icon_info));
 
-      gtk_icon_info_free (icon_info);
+      g_object_unref (icon_info);
+    }
+
+  escaped_text = g_string_new (NULL);
+
+  /* Only need to deal with «'» and «\».
+   *
+   * Note that these never appear in non-ascii utf8 characters, so just
+   * pretend like we have an ascii string...
+   */
+  for (i = 0; text && text[i]; i++)
+    {
+      gchar c = text[i];
+
+      if (c == '\'' || c == '\\')
+        g_string_append_c (escaped_text, '\\');
+
+      g_string_append_c (escaped_text, c);
     }
 
   script = g_strdup_printf ("javascript:%s([%s], '%s', '%s', '%s');",
       method,
       g_strdelimit (str, ":", ','),
-      text,
+      escaped_text->str,
       icon != NULL ? icon : "",
       date);
 
   webkit_web_view_execute_script (WEBKIT_WEB_VIEW (self->priv->webview),
       script);
 
+  g_string_free (escaped_text, TRUE);
   g_free (str);
   g_free (text);
   g_free (date);
@@ -606,7 +620,7 @@ empathy_log_window_init (EmpathyLogWindow *self)
 
   self->priv->chain = _tpl_action_chain_new_async (NULL, NULL, NULL);
 
-  self->priv->camera_monitor = empathy_camera_monitor_dup_singleton ();
+  self->priv->camera_monitor = tpaw_camera_monitor_dup_singleton ();
 
   self->priv->log_manager = tpl_log_manager_dup_singleton ();
 
@@ -619,7 +633,7 @@ empathy_log_window_init (EmpathyLogWindow *self)
   gtk_window_set_default_size (GTK_WINDOW (self), 800, 600);
 
   filename = empathy_file_lookup ("empathy-log-window.ui", "libempathy-gtk");
-  gui = empathy_builder_get_file (filename,
+  gui = tpaw_builder_get_file (filename,
       "vbox1", &self->priv->vbox,
       "toolbutton_profile", &self->priv->button_profile,
       "toolbutton_chat", &self->priv->button_chat,
@@ -637,7 +651,7 @@ empathy_log_window_init (EmpathyLogWindow *self)
       NULL);
   g_free (filename);
 
-  empathy_builder_connect (gui, self,
+  tpaw_builder_connect (gui, self,
       "toolbutton_profile", "clicked", toolbutton_profile_clicked,
       "toolbutton_chat", "clicked", toolbutton_chat_clicked,
       "toolbutton_call", "clicked", toolbutton_av_clicked,
@@ -867,8 +881,7 @@ maybe_refresh_logs (TpChannel *channel,
   if (!tp_strdiff (type, TP_IFACE_CHANNEL_TYPE_TEXT) &&
       !(event_mask & TPL_EVENT_MASK_TEXT))
     goto out;
-  if ((!tp_strdiff (type, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA) ||
-       !tp_strdiff (type, TP_IFACE_CHANNEL_TYPE_CALL)) &&
+  if ((!tp_strdiff (type, TP_IFACE_CHANNEL_TYPE_CALL)) &&
       !(event_mask & TPL_EVENT_MASK_CALL))
     goto out;
 
@@ -1010,8 +1023,7 @@ observe_channels (TpSimpleObserver *observer,
           tp_g_signal_connect_object (channel, "invalidated",
               G_CALLBACK (on_channel_ended), self, 0);
         }
-      else if (!tp_strdiff (type, TP_IFACE_CHANNEL_TYPE_CALL) ||
-          !tp_strdiff (type, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA))
+      else if (!tp_strdiff (type, TP_IFACE_CHANNEL_TYPE_CALL))
         {
           g_hash_table_insert (self->priv->channels,
               g_object_ref (channel), g_object_ref (account));
@@ -1047,11 +1059,6 @@ log_window_create_observer (EmpathyLogWindow *self)
           TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
             TP_IFACE_CHANNEL_TYPE_TEXT,
           NULL));
-  tp_base_client_take_observer_filter (self->priv->observer,
-      tp_asv_new (
-          TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
-            TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
-          NULL));
   tp_base_client_take_observer_filter (self->priv->observer,
       tp_asv_new (
           TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
@@ -1255,7 +1262,7 @@ log_window_append_chat_message (TplEvent *event,
   GtkTreeIter iter, parent;
   gchar *pretty_date, *alias, *body;
   GDateTime *date;
-  EmpathyStringParser *parsers;
+  TpawStringParser *parsers;
   GString *msg;
 
   date = g_date_time_new_from_unix_local (
@@ -1274,7 +1281,7 @@ log_window_append_chat_message (TplEvent *event,
         EMPATHY_PREFS_CHAT_SHOW_SMILEYS));
   msg = g_string_new ("");
 
-  empathy_string_parser_substr (empathy_message_get_body (message), -1,
+  tpaw_string_parser_substr (empathy_message_get_body (message), -1,
       parsers, msg);
 
   if (tpl_text_event_get_message_type (TPL_TEXT_EVENT (event))
@@ -1320,7 +1327,7 @@ log_window_append_call (TplEvent *event,
   GTimeSpan span;
 
   /* If searching, only add the call if the search string appears anywhere */
-  if (!EMP_STR_EMPTY (log_window->priv->last_find))
+  if (!TPAW_STR_EMPTY (log_window->priv->last_find))
     {
       if (strstr (tpl_entity_get_identifier (tpl_event_get_sender (event)),
               log_window->priv->last_find) == NULL &&
@@ -1864,7 +1871,7 @@ add_event_to_store (EmpathyLogWindow *self,
   gtk_list_store_insert_with_values (store, NULL, -1,
       COL_WHO_TYPE, COL_TYPE_NORMAL,
       COL_WHO_ICON, room ? EMPATHY_IMAGE_GROUP_MESSAGE
-                         : EMPATHY_IMAGE_AVATAR_DEFAULT,
+                         : TPAW_IMAGE_AVATAR_DEFAULT,
       COL_WHO_NAME, name,
       COL_WHO_NAME_SORT_KEY, sort_key,
       COL_WHO_ID, tpl_entity_get_identifier (entity),
@@ -1997,7 +2004,7 @@ log_window_find_populate (EmpathyLogWindow *self,
 
   gtk_list_store_clear (store);
 
-  if (EMP_STR_EMPTY (search_criteria))
+  if (TPAW_STR_EMPTY (search_criteria))
     {
       tp_clear_pointer (&self->priv->hits, tpl_log_manager_search_free);
       webkit_web_view_set_highlight_text_matches (
@@ -2494,7 +2501,7 @@ log_window_who_populate (EmpathyLogWindow *self)
       GList *accounts, *l;
 
       manager = empathy_account_chooser_get_account_manager (account_chooser);
-      accounts = tp_account_manager_get_valid_accounts (manager);
+      accounts = tp_account_manager_dup_valid_accounts (manager);
 
       for (l = accounts; l != NULL; l = l->next)
         {
@@ -2505,7 +2512,7 @@ log_window_who_populate (EmpathyLogWindow *self)
               get_entities_for_account, ctx);
         }
 
-      g_list_free (accounts);
+      g_list_free_full (accounts, g_object_unref);
     }
   _tpl_action_chain_append (self->priv->chain, select_first_entity, self);
   _tpl_action_chain_start (self->priv->chain);