~bcurtiswx/ubuntu/precise/empathy/3.4.2.1-0ubuntu1

« back to all changes in this revision

Viewing changes to src/empathy.c

  • Committer: Bazaar Package Importer
  • Author(s): Laurent Bigonville
  • Date: 2009-11-16 23:40:52 UTC
  • mfrom: (1.1.39 upstream)
  • mto: (6.3.7 experimental)
  • mto: This revision was merged to the branch mainline in revision 80.
  • Revision ID: james.westby@ubuntu.com-20091116234052-7hhwrpeln4mwdyw7
Tags: upstream-2.29.2
ImportĀ upstreamĀ versionĀ 2.29.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#include <libebook/e-book.h>
39
39
#include <libnotify/notify.h>
40
40
 
 
41
#include <telepathy-glib/account-manager.h>
41
42
#include <telepathy-glib/dbus.h>
42
43
#include <telepathy-glib/util.h>
43
44
#include <telepathy-glib/connection-manager.h>
49
50
#include <libempathy/empathy-chatroom-manager.h>
50
51
#include <libempathy/empathy-account-settings.h>
51
52
#include <libempathy/empathy-connectivity.h>
52
 
#include <libempathy/empathy-account-manager.h>
53
53
#include <libempathy/empathy-connection-managers.h>
54
54
#include <libempathy/empathy-debugger.h>
55
55
#include <libempathy/empathy-dispatcher.h>
81
81
 
82
82
#define COMMAND_ACCOUNTS_DIALOG 1
83
83
 
 
84
static gboolean account_dialog_only = FALSE;
 
85
static gboolean start_hidden = FALSE;
 
86
static gboolean no_connect = FALSE;
 
87
 
84
88
static void
85
89
dispatch_cb (EmpathyDispatcher *dispatcher,
86
90
    EmpathyDispatchOperation *operation,
100
104
        (empathy_dispatch_operation_get_channel_wrapper (operation));
101
105
 
102
106
      id = empathy_tp_chat_get_id (tp_chat);
103
 
      if (!id)
104
 
        {
105
 
          EmpathyContact *contact;
106
 
 
107
 
          contact = empathy_tp_chat_get_remote_contact (tp_chat);
108
 
          if (contact)
109
 
            id = empathy_contact_get_id (contact);
110
 
        }
111
 
 
112
 
      if (id)
113
 
        {
114
 
          EmpathyAccountManager *manager;
 
107
      if (!EMP_STR_EMPTY (id))
 
108
        {
115
109
          TpConnection *connection;
116
 
          EmpathyAccount *account;
 
110
          TpAccount *account;
117
111
 
118
 
          manager = empathy_account_manager_dup_singleton ();
119
112
          connection = empathy_tp_chat_get_connection (tp_chat);
120
 
          account = empathy_account_manager_get_account_for_connection (
121
 
              manager, connection);
 
113
          account = empathy_get_account_for_connection (connection);
122
114
          chat = empathy_chat_window_find_chat (account, id);
123
 
          g_object_unref (manager);
124
115
        }
125
116
 
126
117
      if (chat)
127
 
        empathy_chat_set_tp_chat (chat, tp_chat);
 
118
        {
 
119
          empathy_chat_set_tp_chat (chat, tp_chat);
 
120
        }
128
121
      else
129
 
        chat = empathy_chat_new (tp_chat);
 
122
        {
 
123
          chat = empathy_chat_new (tp_chat);
 
124
          /* empathy_chat_new returns a floating reference as EmpathyChat is
 
125
           * a GtkWidget. This reference will be taken by a container
 
126
           * (a GtkNotebook) when we'll call empathy_chat_window_present_chat */
 
127
        }
130
128
 
131
129
      empathy_chat_window_present_chat (chat);
132
130
 
154
152
    }
155
153
}
156
154
 
157
 
/* Salut account creation */
 
155
/* Salut account creation. The TpAccountManager first argument
 
156
 * must already be prepared when calling this function. */
158
157
static gboolean
159
 
should_create_salut_account (void)
 
158
should_create_salut_account (TpAccountManager *manager)
160
159
{
161
 
  EmpathyAccountManager *manager;
162
160
  gboolean salut_created = FALSE;
163
161
  GList *accounts, *l;
164
162
 
173
171
      return FALSE;
174
172
    }
175
173
 
176
 
  manager = empathy_account_manager_dup_singleton ();
177
 
  accounts = empathy_account_manager_dup_accounts (manager);
 
174
  accounts = tp_account_manager_get_valid_accounts (manager);
178
175
 
179
176
  for (l = accounts; l != NULL;  l = g_list_next (l))
180
177
    {
181
 
      EmpathyAccount *account = EMPATHY_ACCOUNT (l->data);
182
 
 
183
 
      if (!tp_strdiff (empathy_account_get_protocol (account), "local-xmpp"))
184
 
        salut_created = TRUE;
185
 
 
186
 
      g_object_unref (account);
 
178
      TpAccount *account = TP_ACCOUNT (l->data);
 
179
 
 
180
      if (!tp_strdiff (tp_account_get_protocol (account), "local-xmpp"))
 
181
        {
 
182
          salut_created = TRUE;
 
183
          break;
 
184
        }
187
185
    }
188
186
 
189
 
  g_object_unref (manager);
 
187
  g_list_free (accounts);
190
188
 
191
189
  if (salut_created)
192
190
    {
205
203
    gpointer user_data)
206
204
{
207
205
  EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source);
208
 
  EmpathyAccount *account;
 
206
  TpAccount *account;
209
207
  GError *error = NULL;
210
208
 
211
209
  if (!empathy_account_settings_apply_finish (settings, result, &error))
217
215
 
218
216
  account = empathy_account_settings_get_account (settings);
219
217
 
220
 
  empathy_account_set_enabled_async (account, TRUE, NULL, NULL);
 
218
  tp_account_set_enabled_async (account, TRUE, NULL, NULL);
221
219
  empathy_conf_set_bool (empathy_conf_get (),
222
220
      EMPATHY_PREFS_SALUT_ACCOUNT_CREATED,
223
221
      TRUE);
238
236
}
239
237
 
240
238
static void
241
 
create_salut_account_if_needed (EmpathyConnectionManagers *managers)
 
239
create_salut_account_am_ready_cb (GObject *source_object,
 
240
    GAsyncResult *result,
 
241
    gpointer user_data)
242
242
{
 
243
  TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
 
244
  EmpathyConnectionManagers *managers = user_data;
243
245
  EmpathyAccountSettings  *settings;
244
246
  TpConnectionManager *manager;
245
247
  const TpConnectionManagerProtocol *protocol;
252
254
  gchar      *jid = NULL;
253
255
  GError     *error = NULL;
254
256
 
 
257
  if (!tp_account_manager_prepare_finish (account_manager, result, &error))
 
258
    {
 
259
      DEBUG ("Failed to prepare account manager: %s", error->message);
 
260
      g_error_free (error);
 
261
      goto out;
 
262
    }
255
263
 
256
 
  if (!should_create_salut_account ())
257
 
    return;
 
264
  if (!should_create_salut_account (account_manager))
 
265
    goto out;
258
266
 
259
267
  manager = empathy_connection_managers_get_cm (managers, "salut");
260
268
  if (manager == NULL)
261
269
    {
262
270
      DEBUG ("Salut not installed, not making a salut account");
263
 
      return;
 
271
      goto out;
264
272
    }
265
273
 
266
274
  protocol = tp_connection_manager_get_protocol (manager, "local-xmpp");
267
275
  if (protocol == NULL)
268
276
    {
269
277
      DEBUG ("Salut doesn't support local-xmpp!!");
270
 
      return;
 
278
      goto out;
271
279
    }
272
280
 
273
281
  DEBUG ("Trying to add a salut account...");
278
286
      DEBUG ("Failed to get self econtact: %s",
279
287
          error ? error->message : "No error given");
280
288
      g_clear_error (&error);
281
 
      return;
 
289
      goto out;
282
290
    }
283
291
 
284
292
  settings = empathy_account_settings_new ("salut", "local-xmpp",
320
328
  g_object_unref (settings);
321
329
  g_object_unref (contact);
322
330
  g_object_unref (book);
 
331
 
 
332
 out:
 
333
  g_object_unref (managers);
 
334
}
 
335
 
 
336
static void
 
337
create_salut_account_if_needed (EmpathyConnectionManagers *managers)
 
338
{
 
339
  TpAccountManager *manager;
 
340
 
 
341
  manager = tp_account_manager_dup ();
 
342
 
 
343
  tp_account_manager_prepare_async (manager, NULL,
 
344
      create_salut_account_am_ready_cb, g_object_ref (managers));
 
345
 
 
346
  g_object_unref (manager);
 
347
}
 
348
 
 
349
static gboolean
 
350
has_non_salut_accounts (TpAccountManager *manager)
 
351
{
 
352
  gboolean ret = FALSE;
 
353
  GList *accounts, *l;
 
354
 
 
355
  accounts = tp_account_manager_get_valid_accounts (manager);
 
356
 
 
357
  for (l = accounts ; l != NULL; l = g_list_next (l))
 
358
    {
 
359
      if (tp_strdiff (tp_account_get_protocol (l->data), "local-xmpp"))
 
360
        {
 
361
          ret = TRUE;
 
362
          break;
 
363
        }
 
364
    }
 
365
 
 
366
  g_list_free (accounts);
 
367
 
 
368
  return ret;
323
369
}
324
370
 
325
371
static void
326
372
maybe_show_account_assistant (void)
327
373
{
328
 
  EmpathyAccountManager *manager;
329
 
  manager = empathy_account_manager_dup_singleton ();
330
 
 
331
 
  if (empathy_account_manager_get_count (manager) == 0)
332
 
    {
333
 
      GtkWidget * assistant = empathy_account_assistant_new (
334
 
        GTK_WINDOW (empathy_main_window_get ()));
335
 
      gtk_window_present (GTK_WINDOW (assistant));
336
 
    }
 
374
  TpAccountManager *manager;
 
375
  manager = tp_account_manager_dup ();
 
376
 
 
377
  if (!has_non_salut_accounts (manager))
 
378
    empathy_account_assistant_show (GTK_WINDOW (empathy_main_window_get ()));
 
379
 
 
380
  g_object_unref (manager);
337
381
}
338
382
 
339
383
static gboolean
341
385
{
342
386
  if (empathy_connection_managers_is_ready (managers))
343
387
    {
344
 
      if (!empathy_import_mc4_accounts (managers))
 
388
      if (!empathy_import_mc4_accounts (managers) && !start_hidden)
345
389
        maybe_show_account_assistant ();
346
390
 
347
391
      create_salut_account_if_needed (managers);
428
472
  g_free (old_dir);
429
473
}
430
474
 
 
475
static void
 
476
do_show_accounts_ui (GtkWindow *window,
 
477
    TpAccountManager *manager)
 
478
{
 
479
 
 
480
  GtkWidget *ui;
 
481
 
 
482
  if (has_non_salut_accounts (manager))
 
483
    ui = empathy_accounts_dialog_show (window, NULL);
 
484
  else
 
485
    ui = empathy_account_assistant_show (window);
 
486
 
 
487
  if (account_dialog_only)
 
488
    g_signal_connect (ui, "destroy",
 
489
      G_CALLBACK (gtk_main_quit), NULL);
 
490
}
 
491
 
 
492
static void
 
493
account_manager_ready_for_accounts_cb (GObject *source_object,
 
494
    GAsyncResult *result,
 
495
    gpointer user_data)
 
496
{
 
497
  TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
 
498
  GError *error = NULL;
 
499
 
 
500
  if (!tp_account_manager_prepare_finish (manager, result, &error))
 
501
    {
 
502
      DEBUG ("Failed to prepare account manager: %s", error->message);
 
503
      g_error_free (error);
 
504
      return;
 
505
    }
 
506
 
 
507
  do_show_accounts_ui (user_data, manager);
 
508
}
 
509
 
 
510
static void
 
511
show_accounts_ui (GtkWindow *window,
 
512
    gboolean force)
 
513
{
 
514
  TpAccountManager *manager;
 
515
 
 
516
  if (!force)
 
517
    return;
 
518
 
 
519
  manager = tp_account_manager_dup ();
 
520
 
 
521
  tp_account_manager_prepare_async (manager, NULL,
 
522
      account_manager_ready_for_accounts_cb, window);
 
523
 
 
524
  g_object_unref (manager);
 
525
}
 
526
 
431
527
static UniqueResponse
432
528
unique_app_message_cb (UniqueApp *unique_app,
433
529
    gint command,
435
531
    guint timestamp,
436
532
    gpointer user_data)
437
533
{
438
 
  GtkWidget *window = user_data;
 
534
  GtkWindow *window = user_data;
439
535
 
440
536
  DEBUG ("Other instance launched, presenting the main window. "
441
537
      "Command=%d, timestamp %u", command, timestamp);
442
538
 
443
539
  if (command == COMMAND_ACCOUNTS_DIALOG)
444
540
    {
445
 
      empathy_accounts_dialog_show (GTK_WINDOW (window), NULL);
 
541
      show_accounts_ui (window, TRUE);
446
542
    }
447
543
  else
448
544
    {
 
545
      /* We're requested to show stuff again, disable the start hidden global
 
546
       * in case the accounts wizard wants to pop up.
 
547
       */
 
548
      start_hidden = FALSE;
 
549
 
 
550
      show_accounts_ui (window, FALSE);
 
551
 
449
552
      gtk_window_set_screen (GTK_WINDOW (window),
450
553
          unique_message_data_get_screen (data));
451
554
      gtk_window_set_startup_id (GTK_WINDOW (window),
534
637
#endif /* ENABLE_DEBUG */
535
638
 
536
639
static void
537
 
account_manager_ready_cb (EmpathyAccountManager *manager,
538
 
    GParamSpec *spec,
 
640
account_manager_ready_cb (GObject *source_object,
 
641
    GAsyncResult *result,
539
642
    gpointer user_data)
540
643
{
541
 
  if (!empathy_account_manager_is_ready (manager))
542
 
    return;
543
 
 
544
 
  if (should_create_salut_account () || !empathy_import_mc4_has_imported ())
 
644
  TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
 
645
  GError *error = NULL;
 
646
  EmpathyIdle *idle;
 
647
  EmpathyConnectivity *connectivity;
 
648
  gboolean autoconnect = TRUE;
 
649
 
 
650
  if (!tp_account_manager_prepare_finish (manager, result, &error))
 
651
    {
 
652
      DEBUG ("Failed to prepare account manager: %s", error->message);
 
653
      g_error_free (error);
 
654
      return;
 
655
    }
 
656
 
 
657
  /* Autoconnect */
 
658
  idle = empathy_idle_dup_singleton ();
 
659
  connectivity = empathy_connectivity_dup_singleton ();
 
660
 
 
661
  empathy_conf_get_bool (empathy_conf_get (),
 
662
      EMPATHY_PREFS_AUTOCONNECT, &autoconnect);
 
663
  if (autoconnect && !no_connect &&
 
664
      tp_connection_presence_type_cmp_availability
 
665
          (empathy_idle_get_state (idle), TP_CONNECTION_PRESENCE_TYPE_OFFLINE)
 
666
            <= 0)
 
667
      /* if current state is Offline, then put it online */
 
668
      empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_AVAILABLE);
 
669
 
 
670
  if (should_create_salut_account (manager)
 
671
      || !empathy_import_mc4_has_imported ())
545
672
    {
546
673
      EmpathyConnectionManagers *managers;
547
674
      managers = empathy_connection_managers_dup_singleton ();
552
679
            G_CALLBACK (connection_managers_ready_cb), NULL);
553
680
        }
554
681
    }
555
 
  else
 
682
  else if (!start_hidden)
556
683
    {
557
684
      maybe_show_account_assistant ();
558
685
    }
 
686
 
 
687
  g_object_unref (idle);
 
688
  g_object_unref (connectivity);
559
689
}
560
690
 
561
691
static EmpathyDispatcher *
589
719
    "org.freedesktop.Telepathy.Channel.Interface.MediaSignalling/gtalk-p2p",
590
720
    NULL };
591
721
  GHashTable *asv;
592
 
  int i;
 
722
  guint i;
593
723
 
594
724
  /* Setup the basic Client.Handler that matches our client filter */
595
725
  filters = g_ptr_array_new ();
618
748
      g_ptr_array_add (filters, asv);
619
749
    }
620
750
 
 
751
  asv = tp_asv_new (
 
752
        TP_IFACE_CHANNEL ".ChannelType",
 
753
          G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
 
754
        TP_IFACE_CHANNEL ".TargetHandleType",
 
755
          G_TYPE_INT, TP_HANDLE_TYPE_CONTACT,
 
756
        TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA ".InitialAudio",
 
757
          G_TYPE_BOOLEAN, TRUE,
 
758
        NULL);
 
759
  g_ptr_array_add (filters, asv);
 
760
 
 
761
  asv = tp_asv_new (
 
762
        TP_IFACE_CHANNEL ".ChannelType",
 
763
          G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
 
764
        TP_IFACE_CHANNEL ".TargetHandleType",
 
765
          G_TYPE_INT, TP_HANDLE_TYPE_CONTACT,
 
766
        TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA ".InitialVideo",
 
767
          G_TYPE_BOOLEAN, TRUE,
 
768
        NULL);
 
769
  g_ptr_array_add (filters, asv);
 
770
 
 
771
 
621
772
  empathy_dispatcher_add_handler (d, PACKAGE_NAME"MoreThanMeetsTheEye",
622
773
    filters, capabilities);
623
774
 
628
779
}
629
780
 
630
781
static void
631
 
account_connection_notify_cb (EmpathyAccount *account,
632
 
    GParamSpec *pspec,
 
782
account_status_changed_cb (TpAccount *account,
 
783
    guint old_status,
 
784
    guint new_status,
 
785
    guint reason,
 
786
    gchar *dbus_error_name,
 
787
    GHashTable *details,
633
788
    EmpathyChatroom *room)
634
789
{
635
790
  TpConnection *conn;
636
791
 
637
 
  conn = empathy_account_get_connection (account);
638
 
 
639
 
  if (conn == NULL)
640
 
    return;
 
792
  conn = tp_account_get_connection (account);
641
793
 
642
794
  empathy_dispatcher_join_muc (conn,
643
795
      empathy_chatroom_get_room (room), NULL, NULL);
644
796
}
645
797
 
646
798
static void
647
 
account_manager_chatroom_ready_cb (EmpathyAccountManager *account_manager,
648
 
    GParamSpec *pspec,
649
 
    EmpathyChatroomManager *chatroom_manager)
 
799
account_manager_chatroom_ready_cb (GObject *source_object,
 
800
    GAsyncResult *result,
 
801
    gpointer user_data)
650
802
{
 
803
  TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
 
804
  EmpathyChatroomManager *chatroom_manager = user_data;
651
805
  GList *accounts, *l;
652
 
 
653
 
  accounts = empathy_account_manager_dup_accounts (account_manager);
 
806
  GError *error = NULL;
 
807
 
 
808
  if (!tp_account_manager_prepare_finish (account_manager, result, &error))
 
809
    {
 
810
      DEBUG ("Failed to prepare account manager: %s", error->message);
 
811
      g_error_free (error);
 
812
      return;
 
813
    }
 
814
 
 
815
  accounts = tp_account_manager_get_valid_accounts (account_manager);
654
816
 
655
817
  for (l = accounts; l != NULL; l = g_list_next (l))
656
818
    {
657
 
      EmpathyAccount *account = EMPATHY_ACCOUNT (l->data);
 
819
      TpAccount *account = TP_ACCOUNT (l->data);
658
820
      TpConnection *conn;
659
821
      GList *chatrooms, *p;
660
822
 
661
 
      conn = empathy_account_get_connection (account);
 
823
      conn = tp_account_get_connection (account);
662
824
 
663
825
      chatrooms = empathy_chatroom_manager_get_chatrooms (
664
826
          chatroom_manager, account);
672
834
 
673
835
          if (conn == NULL)
674
836
            {
675
 
              g_signal_connect (G_OBJECT (account), "notify::connection",
676
 
                  G_CALLBACK (account_connection_notify_cb), room);
 
837
              g_signal_connect (G_OBJECT (account), "status-changed",
 
838
                  G_CALLBACK (account_status_changed_cb), room);
677
839
            }
678
840
          else
679
841
            {
685
847
      g_list_free (chatrooms);
686
848
    }
687
849
 
688
 
  g_list_foreach (accounts, (GFunc) g_object_unref, NULL);
689
850
  g_list_free (accounts);
690
851
}
691
852
 
692
853
static void
693
854
chatroom_manager_ready_cb (EmpathyChatroomManager *chatroom_manager,
694
855
    GParamSpec *pspec,
695
 
    EmpathyAccountManager *account_manager)
 
856
    gpointer user_data)
696
857
{
697
 
  gboolean ready;
698
 
 
699
 
  g_object_get (G_OBJECT (account_manager), "ready", &ready, NULL);
700
 
 
701
 
  if (ready)
702
 
    {
703
 
      account_manager_chatroom_ready_cb (account_manager, NULL,
704
 
          chatroom_manager);
705
 
    }
706
 
  else
707
 
    {
708
 
      g_signal_connect (account_manager, "notify::ready",
709
 
          G_CALLBACK (account_manager_chatroom_ready_cb), chatroom_manager);
710
 
    }
 
858
  TpAccountManager *account_manager = user_data;
 
859
 
 
860
  tp_account_manager_prepare_async (account_manager, NULL,
 
861
      account_manager_chatroom_ready_cb, chatroom_manager);
711
862
}
712
863
 
713
864
int
718
869
#endif
719
870
  EmpathyStatusIcon *icon;
720
871
  EmpathyDispatcher *dispatcher;
721
 
  EmpathyAccountManager *account_manager;
 
872
  TpAccountManager *account_manager;
722
873
  EmpathyLogManager *log_manager;
723
874
  EmpathyChatroomManager *chatroom_manager;
724
875
  EmpathyCallFactory *call_factory;
726
877
  GtkWidget *window;
727
878
  EmpathyIdle *idle;
728
879
  EmpathyConnectivity *connectivity;
729
 
  gboolean autoconnect = TRUE;
730
 
  gboolean no_connect = FALSE;
731
 
  gboolean hide_contact_list = FALSE;
732
 
  gboolean accounts_dialog = FALSE;
733
880
  GError *error = NULL;
734
881
  TpDBusDaemon *dbus_daemon;
735
882
  UniqueApp *unique_app;
741
888
        0, G_OPTION_ARG_NONE, &no_connect,
742
889
        N_("Don't connect on startup"),
743
890
        NULL },
744
 
      { "hide-contact-list", 'h',
745
 
        0, G_OPTION_ARG_NONE, &hide_contact_list,
746
 
        N_("Don't show the contact list on startup"),
 
891
      { "start-hidden", 'h',
 
892
        0, G_OPTION_ARG_NONE, &start_hidden,
 
893
        N_("Don't display the contact list or any other dialogs on startup"),
747
894
        NULL },
748
895
      { "accounts", 'a',
749
 
        0, G_OPTION_ARG_NONE, &accounts_dialog,
 
896
        0, G_OPTION_ARG_NONE, &account_dialog_only,
750
897
        N_("Show the accounts dialog"),
751
898
        NULL },
752
899
      { "version", 'v',
794
941
 
795
942
  if (unique_app_is_running (unique_app))
796
943
    {
797
 
      unique_app_send_message (unique_app, accounts_dialog ?
 
944
      unique_app_send_message (unique_app, account_dialog_only ?
798
945
          COMMAND_ACCOUNTS_DIALOG : UNIQUE_ACTIVATE, NULL);
799
946
 
800
947
      g_object_unref (unique_app);
821
968
      g_clear_error (&error);
822
969
    }
823
970
 
824
 
  if (accounts_dialog)
 
971
  if (account_dialog_only)
825
972
    {
826
 
      GtkWidget *dialog;
827
 
 
828
 
      dialog = empathy_accounts_dialog_show (NULL, NULL);
829
 
      g_signal_connect (dialog, "destroy",
830
 
                        G_CALLBACK (gtk_main_quit), NULL);
 
973
      account_manager = tp_account_manager_dup ();
 
974
      show_accounts_ui (NULL, TRUE);
831
975
 
832
976
      gtk_main ();
 
977
 
 
978
      g_object_unref (account_manager);
833
979
      return 0;
834
980
    }
835
981
 
 
982
  notify_init (_(PACKAGE_NAME));
 
983
 
836
984
  /* Setting up Idle */
837
985
  idle = empathy_idle_dup_singleton ();
838
986
  empathy_idle_set_auto_away (idle, TRUE);
844
992
  empathy_conf_notify_add (empathy_conf_get (), EMPATHY_PREFS_USE_CONN,
845
993
      use_conn_notify_cb, connectivity);
846
994
 
847
 
  /* Autoconnect */
848
 
  empathy_conf_get_bool (empathy_conf_get (),
849
 
      EMPATHY_PREFS_AUTOCONNECT, &autoconnect);
850
 
  if (autoconnect && !no_connect &&
851
 
      tp_connection_presence_type_cmp_availability
852
 
          (empathy_idle_get_state (idle), TP_CONNECTION_PRESENCE_TYPE_OFFLINE)
853
 
            <= 0)
854
 
      empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_AVAILABLE);
855
 
 
856
995
  /* account management */
857
 
  account_manager = empathy_account_manager_dup_singleton ();
858
 
  g_signal_connect (account_manager, "notify::ready",
859
 
      G_CALLBACK (account_manager_ready_cb), NULL);
 
996
  account_manager = tp_account_manager_dup ();
 
997
  tp_account_manager_prepare_async (account_manager, NULL,
 
998
      account_manager_ready_cb, NULL);
860
999
 
861
1000
  /* Handle channels */
862
1001
  dispatcher = setup_dispatcher ();
866
1005
 
867
1006
  /* Setting up UI */
868
1007
  window = empathy_main_window_show ();
869
 
  icon = empathy_status_icon_new (GTK_WINDOW (window), hide_contact_list);
 
1008
  icon = empathy_status_icon_new (GTK_WINDOW (window), start_hidden);
870
1009
 
871
1010
  g_signal_connect (unique_app, "message-received",
872
1011
      G_CALLBACK (unique_app_message_cb), window);
889
1028
      chatroom_manager_ready_cb (chatroom_manager, NULL, account_manager);
890
1029
    }
891
1030
 
892
 
  notify_init (_(PACKAGE_NAME));
893
1031
  /* Create the call factory */
894
1032
  call_factory = empathy_call_factory_initialise ();
895
1033
  g_signal_connect (G_OBJECT (call_factory), "new-call-handler",