]> git.0d.be Git - empathy.git/blobdiff - src/empathy.c
Updated Polish translation
[empathy.git] / src / empathy.c
index a68d0d22650801927ad41cc47ed048f6147d0f10..f8479142316c8b30f99dd2bf3a0ca3a2e9ff9e3b 100644 (file)
 #include <telepathy-glib/connection-manager.h>
 #include <telepathy-glib/interfaces.h>
 
+#ifdef ENABLE_TPL
+#include <telepathy-logger/log-manager.h>
+#include <telepathy-logger/log-store-empathy.h>
+#else
+
+#include <libempathy/empathy-log-manager.h>
+#endif /* ENABLE_TPL */
 #include <libempathy/empathy-idle.h>
 #include <libempathy/empathy-utils.h>
 #include <libempathy/empathy-call-factory.h>
@@ -53,7 +60,6 @@
 #include <libempathy/empathy-connection-managers.h>
 #include <libempathy/empathy-dispatcher.h>
 #include <libempathy/empathy-dispatch-operation.h>
-#include <libempathy/empathy-log-manager.h>
 #include <libempathy/empathy-ft-factory.h>
 #include <libempathy/empathy-tp-chat.h>
 #include <libempathy/empathy-tp-call.h>
@@ -63,6 +69,8 @@
 #include <libempathy-gtk/empathy-location-manager.h>
 
 #include "empathy-main-window.h"
+#include "empathy-import-mc4-accounts.h"
+#include "empathy-accounts-common.h"
 #include "empathy-accounts-dialog.h"
 #include "empathy-status-icon.h"
 #include "empathy-call-window.h"
 
 #include <gst/gst.h>
 
-#define COMMAND_ACCOUNTS_DIALOG 1
-
-static gboolean account_dialog_only = FALSE;
 static gboolean start_hidden = FALSE;
 static gboolean no_connect = FALSE;
 
+static void account_manager_ready_cb (GObject *source_object,
+    GAsyncResult *result,
+    gpointer user_data);
+
 static void
 dispatch_cb (EmpathyDispatcher *dispatcher,
     EmpathyDispatchOperation *operation,
@@ -241,17 +250,14 @@ accounts_application_exited_cb (GPid pid,
       g_warning ("accounts application exited with status %d: '%s'",
           status, g_strerror (status));
     }
-
-  if (account_dialog_only)
-    gtk_main_quit ();
 }
 
 static void
 show_accounts_ui (GdkScreen *screen,
-    gboolean try_import)
+    gboolean if_needed)
 {
   empathy_accounts_dialog_show_application (screen,
-      accounts_application_exited_cb, NULL, NULL, try_import, start_hidden);
+      accounts_application_exited_cb, NULL, NULL, if_needed, start_hidden);
 }
 
 static UniqueResponse
@@ -262,30 +268,30 @@ unique_app_message_cb (UniqueApp *unique_app,
     gpointer user_data)
 {
   GtkWindow *window = user_data;
+  TpAccountManager *account_manager;
 
   DEBUG ("Other instance launched, presenting the main window. "
       "Command=%d, timestamp %u", command, timestamp);
 
-  if (command == COMMAND_ACCOUNTS_DIALOG)
-    {
-      show_accounts_ui (gdk_screen_get_default (), TRUE);
-    }
-  else
-    {
-      /* XXX: the standalone app somewhat breaks this case, since
-       * communicating it would be a pain */
+  /* XXX: the standalone app somewhat breaks this case, since
+   * communicating it would be a pain */
 
-      /* We're requested to show stuff again, disable the start hidden global
-       * in case the accounts wizard wants to pop up.
-       */
-      start_hidden = FALSE;
+  /* We're requested to show stuff again, disable the start hidden global
+   * in case the accounts wizard wants to pop up.
+   */
+  start_hidden = FALSE;
 
-      gtk_window_set_screen (GTK_WINDOW (window),
-          unique_message_data_get_screen (data));
-      gtk_window_set_startup_id (GTK_WINDOW (window),
-          unique_message_data_get_startup_id (data));
-      gtk_window_present_with_time (GTK_WINDOW (window), timestamp);
-    }
+  gtk_window_set_screen (GTK_WINDOW (window),
+      unique_message_data_get_screen (data));
+  gtk_window_set_startup_id (GTK_WINDOW (window),
+      unique_message_data_get_startup_id (data));
+  gtk_window_present_with_time (GTK_WINDOW (window), timestamp);
+  gtk_window_set_skip_taskbar_hint (window, FALSE);
+
+  account_manager = tp_account_manager_dup ();
+  tp_account_manager_prepare_async (account_manager, NULL,
+      account_manager_ready_cb, NULL);
+  g_object_unref (account_manager);
 
   return UNIQUE_RESPONSE_OK;
 }
@@ -376,7 +382,11 @@ account_manager_ready_cb (GObject *source_object,
       /* if current state is Offline, then put it online */
       empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_AVAILABLE);
 
-  show_accounts_ui (gdk_screen_get_default (), TRUE);
+  /* Pop up the accounts dialog if it's needed (either when we don't have any
+   * accounts yet or when we haven't imported mc4 accounts yet */
+  if (!empathy_accounts_has_accounts (manager)
+      || !empathy_import_mc4_has_imported ())
+    show_accounts_ui (gdk_screen_get_default (), TRUE);
 
   g_object_unref (idle);
   g_object_unref (connectivity);
@@ -560,7 +570,11 @@ main (int argc, char *argv[])
   EmpathyStatusIcon *icon;
   EmpathyDispatcher *dispatcher;
   TpAccountManager *account_manager;
+#ifdef ENABLE_TPL
+  TplLogManager *log_manager;
+#else
   EmpathyLogManager *log_manager;
+#endif /* ENABLE_TPL */
   EmpathyChatroomManager *chatroom_manager;
   EmpathyCallFactory *call_factory;
   EmpathyFTFactory  *ft_factory;
@@ -573,7 +587,7 @@ main (int argc, char *argv[])
 
 #ifdef ENABLE_DEBUG
   TpDebugSender *debug_sender;
-#endif
+#endif /* ENABLE_TPL */
 
   GOptionContext *optcontext;
   GOptionEntry options[] = {
@@ -585,10 +599,6 @@ main (int argc, char *argv[])
         0, G_OPTION_ARG_NONE, &start_hidden,
         N_("Don't display the contact list or any other dialogs on startup"),
         NULL },
-      { "accounts", 'a',
-        0, G_OPTION_ARG_NONE, &account_dialog_only,
-        N_("Show the accounts dialog"),
-        NULL },
       { "version", 'v',
         G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, show_version_cb,
         NULL, NULL },
@@ -629,30 +639,16 @@ main (int argc, char *argv[])
   g_log_set_default_handler (tp_debug_sender_log_handler, G_LOG_DOMAIN);
 #endif
 
-  unique_app = unique_app_new_with_commands (
-      "org.freedesktop.Telepathy.Client.Empathy",
-      NULL, "accounts_dialog", COMMAND_ACCOUNTS_DIALOG, NULL);
+  unique_app = unique_app_new ("org.gnome."PACKAGE_NAME, NULL);
 
   if (unique_app_is_running (unique_app))
     {
-      unique_app_send_message (unique_app, account_dialog_only ?
-          COMMAND_ACCOUNTS_DIALOG : UNIQUE_ACTIVATE, NULL);
+      unique_app_send_message (unique_app, UNIQUE_ACTIVATE, NULL);
 
       g_object_unref (unique_app);
       return EXIT_SUCCESS;
     }
 
-  if (account_dialog_only)
-    {
-      account_manager = tp_account_manager_dup ();
-      show_accounts_ui (gdk_screen_get_default (), FALSE);
-
-      gtk_main ();
-
-      g_object_unref (account_manager);
-      return 0;
-    }
-
   notify_init (_(PACKAGE_NAME));
 
   /* Setting up Idle */
@@ -685,8 +681,12 @@ main (int argc, char *argv[])
       G_CALLBACK (unique_app_message_cb), window);
 
   /* Logging */
+#ifdef ENABLE_TPL
+  log_manager = tpl_log_manager_dup_singleton ();
+#else
   log_manager = empathy_log_manager_dup_singleton ();
   empathy_log_manager_observe (log_manager, dispatcher);
+#endif
 
   chatroom_manager = empathy_chatroom_manager_dup_singleton (NULL);
   empathy_chatroom_manager_observe (chatroom_manager, dispatcher);