]> git.0d.be Git - empathy.git/commitdiff
Merge back from master
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>
Fri, 21 Aug 2009 16:37:48 +0000 (17:37 +0100)
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>
Fri, 21 Aug 2009 16:37:48 +0000 (17:37 +0100)
21 files changed:
1  2 
configure.ac
data/Makefile.am
libempathy-gtk/empathy-chat.c
libempathy-gtk/empathy-contact-list-view.c
libempathy-gtk/empathy-share-my-desktop.c
libempathy-gtk/empathy-theme-adium.c
libempathy-gtk/empathy-ui-utils.c
libempathy-gtk/empathy-ui-utils.h
libempathy/Makefile.am
libempathy/empathy-call-handler.c
libempathy/empathy-idle.c
libempathy/empathy-idle.h
libempathy/empathy-tp-chat.c
libempathy/empathy-tp-contact-factory.c
libempathy/empathy-tp-contact-list.c
po/POTFILES.in
python/pyempathy/pyempathy.defs
python/pyempathygtk/pyempathygtk.defs
src/empathy-chat-window.c
src/empathy-status-icon.c
src/empathy.c

diff --combined configure.ac
index 0e11a66d8965add5a4112eea9ada2309ffabfb79,bc0491cae2c0ce97e237283b12366ada98f969e2..7576c8e9dace19ea68fbcec2eda0abf0429a4ddb
@@@ -29,14 -29,15 +29,14 @@@ GLIB_REQUIRED=2.16.
  GTK_REQUIRED=2.16.0
  GCONF_REQUIRED=1.2.0
  LIBPANELAPPLET_REQUIRED=2.10.0
- TELEPATHY_GLIB_REQUIRED=0.7.31
+ TELEPATHY_GLIB_REQUIRED=0.7.34
 -MISSION_CONTROL_REQUIRED=4.61
  ENCHANT_REQUIRED=1.2.0
  ISO_CODES_REQUIRED=0.35
  LIBNOTIFY_REQUIRED=0.4.4
  LIBCANBERRA_GTK_REQUIRED=0.4
- LIBCHAMPLAIN_REQUIRED=0.3.3
- LIBCHAMPLAIN_GTK_REQUIRED=0.3.3
- CLUTTER_GTK_REQUIRED=0.8.2
+ LIBCHAMPLAIN_REQUIRED=0.3.6
+ LIBCHAMPLAIN_GTK_REQUIRED=0.3.6
+ CLUTTER_GTK_REQUIRED=0.10
  GEOCLUE_REQUIRED=0.11
  WEBKIT_REQUIRED=1.1.7
  NETWORK_MANAGER_REQUIRED=0.7.0
@@@ -94,6 -95,7 +94,6 @@@ PKG_CHECK_MODULES(LIBEMPATHY
     gio-unix-2.0 >= $GLIB_REQUIRED
     libxml-2.0
     telepathy-glib >= $TELEPATHY_GLIB_REQUIRED
 -   libmissioncontrol >= $MISSION_CONTROL_REQUIRED
     telepathy-farsight
     farsight2-0.10
     gstreamer-0.10
@@@ -109,6 -111,7 +109,6 @@@ PKG_CHECK_MODULES(LIBEMPATHYGTK
     gtk+-2.0 >= $GTK_REQUIRED
     libcanberra-gtk >= $LIBCANBERRA_GTK_REQUIRED
     telepathy-glib >= $TELEPATHY_GLIB_REQUIRED
 -   libmissioncontrol >= $MISSION_CONTROL_REQUIRED
     farsight2-0.10
     gstreamer-0.10
     gstreamer-interfaces-0.10
@@@ -124,9 -127,9 +124,9 @@@ PKG_CHECK_MODULES(EMPATHY
     libebook-1.2
     dbus-glib-1
     telepathy-glib >= $TELEPATHY_GLIB_REQUIRED
 -   libmissioncontrol >= $MISSION_CONTROL_REQUIRED
     telepathy-farsight
     gstreamer-0.10
 +   unique-1.0
  ])
  
  PKG_CHECK_MODULES(LIBNOTIFY, libnotify >= $LIBNOTIFY_REQUIRED)
@@@ -154,14 -157,31 +154,31 @@@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GE
  AM_GLIB_GNU_GETTEXT
  
  # -----------------------------------------------------------
- # NM integration
+ # Connectivity integration
  # -----------------------------------------------------------
- AC_ARG_ENABLE(network-manager,
-               AS_HELP_STRING([--enable-network-manager=@<:@no/yes/auto@:>@],
-                              [build with network-manager support]), ,
-                              enable_network_manager=auto)
+ AC_ARG_WITH(connectivity,
+               AS_HELP_STRING([--with-connectivity=@<:@nm/connman/auto/no@:>@],
+                              [build with connectivity support]), ,
+                              with_connectivity=auto)
+ if test "x$with_connectivity" = "xno"; then
+    have_nm=no
+    have_connman=no
+ elif test "x$with_connectivity" = "xconnman"; then
+    PKG_CHECK_MODULES(CONNMAN,
+    [
+       dbus-glib-1
+    ], have_connman="yes", have_connman="no")
+    if test "x$have_connman" = "xyes"; then
+       AC_DEFINE(HAVE_CONNMAN, 1, [Define if you have connman dependencies])
+       have_nm=no
+    fi
+ else
  
- if test "x$enable_network_manager" != "xno"; then
     PKG_CHECK_MODULES(NETWORK_MANAGER,
     [
        libnm_glib >= $NETWORK_MANAGER_REQUIRED
  
     if test "x$have_nm" = "xyes"; then
        AC_DEFINE(HAVE_NM, 1, [Define if you have libnm-glib])
+       have_connman=no
     fi
- else
-    have_nm=no
  fi
  
- if test "x$enable_network_manager" = "xyes" -a "x$have_nm" != "xyes"; then
+ if test "x$with_connectivity" = "xconnman" -a "x$have_connman" != "xyes"; then
+    AC_MSG_ERROR([Couldn't find connman dependencies.])
+ fi
+ if test "x$with_connectivity" = "xnm" -a "x$have_nm" != "xyes"; then
     AC_MSG_ERROR([Couldn't find libnm-glib dependencies.])
  fi
- AM_CONDITIONAL(HAVE_NM, test "x$have_NM" = "xyes")
+ AM_CONDITIONAL(HAVE_NM, test "x$have_nm" = "xyes")
+ AM_CONDITIONAL(HAVE_CONNMAN, test "x$have_connman" = "xyes")
  
  # -----------------------------------------------------------
  # Webkit
@@@ -256,7 -281,7 +278,7 @@@ if test "x$enable_map" != "xno"; the
     [
        champlain-0.3 >= $LIBCHAMPLAIN_REQUIRED,
        champlain-gtk-0.3 >= $LIBCHAMPLAIN_GTK_REQUIRED
-       clutter-gtk-0.8 >= $CLUTTER_GTK_REQUIRED
+       clutter-gtk-0.10 >= $CLUTTER_GTK_REQUIRED
     ], have_libchamplain="yes", have_libchamplain="no")
  
     if test "x$have_libchamplain" = "xyes"; then
@@@ -316,7 -341,7 +338,7 @@@ if test "x$enable_megaphone" != "xno"; 
        glib-2.0 >= $GLIB_REQUIRED
        gtk+-2.0 >= $GTK_REQUIRED
        gconf-2.0 >= $GCONF_REQUIRED
 -      libmissioncontrol >= $MISSION_CONTROL_REQUIRED
 +      telepathy-glib >= $TELEPATHY_GLIB_REQUIRED
     ], have_megaphone="yes", have_megaphone="no")
  else
     have_megaphone=no
@@@ -343,7 -368,7 +365,7 @@@ if test "x$enable_nothere" != "xno"; th
        glib-2.0 >= $GLIB_REQUIRED
        gtk+-2.0 >= $GTK_REQUIRED
        gconf-2.0 >= $GCONF_REQUIRED
 -      libmissioncontrol >= $MISSION_CONTROL_REQUIRED
 +      telepathy-glib >= $TELEPATHY_GLIB_REQUIRED
     ], have_nothere="yes", have_nothere="no")
  else
     have_nothere=no
@@@ -394,6 -419,7 +416,6 @@@ if test "x$enable_python" != "xno"; the
        gobject-2.0
        gconf-2.0 >= $GCONF_REQUIRED
        libxml-2.0
 -      libmissioncontrol >= $MISSION_CONTROL_REQUIRED
        gtk+-2.0 >= $GTK_REQUIRED
        gstreamer-0.10
        gstreamer-interfaces-0.10
@@@ -475,7 -501,10 +497,10 @@@ Configure summary
        Display maps (libchamplain).:  ${have_libchamplain}
        Location awareness (Geoclue):  ${have_geoclue}
        Adium themes (Webkit).......:  ${have_webkit}
+     Connectivity:
        NetworkManager integration..:  ${have_nm}
+       ConnMan integration.........:  ${have_connman}
  
      Extras:
        Documentation...............:  ${enable_gtk_doc}
diff --combined data/Makefile.am
index 2182ed0f526e8fb09ba144a0c0b1d566ec57a6b5,7391b409e9ac31f75330697f33d88be777c67d28..43c3bb66c530ac9c9fec6796034e205cbafde7a1
@@@ -1,5 -1,25 +1,5 @@@
  SUBDIRS = icons
  
 -profiledir = $(datadir)/mission-control/profiles
 -profile_DATA =                                \
 -      aim.profile                     \
 -      icq.profile                     \
 -      jabber.profile                  \
 -      salut.profile                   \
 -      yahoo.profile                   \
 -      gtalk.profile                   \
 -      irc.profile                     \
 -      msn.profile                     \
 -      msn-haze.profile                \
 -      sofiasip.profile                \
 -      ekiga.profile                   \
 -      fwd.profile                     \
 -      sipphone.profile                \
 -      groupwise.profile               \
 -      gadugadu.profile                \
 -      qq.profile                      \
 -      sametime.profile
 -
  desktopdir = $(datadir)/applications
  desktop_in_files = empathy.desktop.in
  desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
@@@ -10,6 -30,11 +10,11 @@@ schemas_in_files = empathy.schemas.i
  schemas_DATA   = $(schemas_in_files:.schemas.in=.schemas)
  @INTLTOOL_SCHEMAS_RULE@
  
+ streamingprefsdir =  $(datadir)/empathy
+ streamingprefs_DATA =         \
+       codec-preferences       \
+       element-properties
  if GCONF_SCHEMAS_INSTALL
  install-data-local:
        if test -z "$(DESTDIR)" ; then \
@@@ -25,10 -50,12 +30,11 @@@ htmldir = $(datadir)/empath
  html_DATA = Template.html
  
  EXTRA_DIST =                          \
 -      $(profile_DATA)                 \
        $(desktop_in_files)             \
        $(desktop_DATA)                 \
        $(schemas_in_files)             \
        $(schemas_DATA)                 \
+       $(streamingprefs_DATA)          \
        $(html_DATA)
  
  DISTCLEANFILES =                      \
index d52d7af939cd6013dc704900e9a837a2e7772e1d,9fa51fb85907b4c44553e079b25565a44f92c6a4..9096beeae86446f4c782497958874b86dc709143
@@@ -203,9 -203,8 +203,9 @@@ chat_new_connection_cb (EmpathyAccountM
        EmpathyChatPriv *priv = GET_PRIV (chat);
        EmpathyAccount *account;
  
 -      account = empathy_account_manager_get_account (manager, connection);
 -      if (!priv->tp_chat && empathy_account_equal (account, priv->account) &&
 +      account = empathy_account_manager_get_account_for_connection (manager,
 +              connection);
 +      if (!priv->tp_chat && account == priv->account &&
            priv->handle_type != TP_HANDLE_TYPE_NONE &&
            !EMP_STR_EMPTY (priv->id)) {
  
@@@ -401,9 -400,18 +401,18 @@@ chat_send (EmpathyChat  *chat
        if (msg[0] == '/' &&
            !g_str_has_prefix (msg, "/me") &&
            !g_str_has_prefix (msg, "/say")) {
-               empathy_chat_view_append_event (chat->view,
-                       _("Unsupported command"));
-               return;
+               /* Also allow messages with two slashes before the first space,
+                * so it is possible to send an /unix/path */
+               int slash_count = 0, i;
+               for (i = 0; msg[i] && msg[i] != ' ' && slash_count < 2; i++) {
+                       if (msg[i] == '/')
+                               slash_count++;
+               }
+               if (slash_count == 1) {
+                       empathy_chat_view_append_event (chat->view,
+                               _("Unsupported command"));
+                       return;
+               }
        }
  
        /* We can send the message */
@@@ -1183,7 -1191,10 +1192,10 @@@ build_part_message (guint           rea
                break;
        case TP_CHANNEL_GROUP_CHANGE_REASON_KICKED:
                if (actor_name != NULL) {
-                       g_string_append_printf (s, _("%s was kicked by %s"),
+                       /* translators: reverse the order of these arguments
+                        * if the kicked should come before the kicker in your locale.
+                        */
+                       g_string_append_printf (s, _("%1$s was kicked by %2$s"),
                                name, actor_name);
                } else {
                        g_string_append_printf (s, _("%s was kicked"), name);
                break;
        case TP_CHANNEL_GROUP_CHANGE_REASON_BANNED:
                if (actor_name != NULL) {
-                       g_string_append_printf (s, _("%s was banned by %s"),
+                       /* translators: reverse the order of these arguments
+                        * if the banned should come before the banner in your locale.
+                        */
+                       g_string_append_printf (s, _("%1$s was banned by %2$s"),
                                name, actor_name);
                } else {
                        g_string_append_printf (s, _("%s was banned"), name);
@@@ -1767,8 -1781,7 +1782,8 @@@ empathy_chat_set_tp_chat (EmpathyCha
  
        priv->tp_chat = g_object_ref (tp_chat);
        connection = empathy_tp_chat_get_connection (priv->tp_chat);
 -      priv->account = empathy_account_manager_get_account (priv->account_manager,
 +      priv->account = empathy_account_manager_get_account_for_connection (
 +                                                           priv->account_manager,
                                                             connection);
        g_object_ref (priv->account);
  
index 2ff27b1305eedf72eff1cf09c234bca0eac94d25,a4dfa0f596d52b0070f3ff5c7ac8db0c4a318fb5..dcbbb18bf57ffccf276ed544ef5c21e8b24ed02e
@@@ -302,7 -302,7 +302,7 @@@ contact_list_view_drag_data_received (G
        account_id = strv[0];
        contact_id = strv[1];
    account_manager = empathy_account_manager_dup_singleton ();
 -      account = empathy_account_manager_lookup (account_manager, account_id);
 +      account = empathy_account_manager_get_account (account_manager, account_id);
        if (account) {
                TpConnection *connection;
  
@@@ -364,6 -364,7 +364,7 @@@ contact_list_view_drag_motion (GtkWidge
        gboolean               is_row;
        gboolean               is_different = FALSE;
        gboolean               cleanup = TRUE;
+       int                    action = 0;
  
        is_row = gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
                                                x,
                cleanup &= FALSE;
        }
  
+       if (context->actions == GDK_ACTION_COPY) {
+               action = context->suggested_action;
+       } else if (context->actions & GDK_ACTION_MOVE) {
+               action = GDK_ACTION_MOVE;
+       }
+       gdk_drag_status (context, action, time);
        if (!is_different && !cleanup) {
                return TRUE;
        }
index 4c60e435fb24ab833f5ca865950fede5c68f7809,b981d5ade793c1932163c5b75fdd34138d21b68c..01c2e183ff3c98cbadf937f1ee55847eb73db971
@@@ -23,8 -23,6 +23,8 @@@
  #include <dbus/dbus-glib.h>
  #include <telepathy-glib/util.h>
  #include <telepathy-glib/contact.h>
 +#include <telepathy-glib/channel.h>
 +#include <telepathy-glib/interfaces.h>
  #define DEBUG_FLAG EMPATHY_DEBUG_SHARE_DESKTOP
  #include <libempathy/empathy-debug.h>
  
@@@ -212,7 -210,7 +212,7 @@@ empathy_share_my_desktop_connection_rea
    g_hash_table_insert (request, TP_IFACE_CHANNEL ".TargetHandle", value);
  
    /* org.freedesktop.Telepathy.Channel.Type.StreamTube.Service */
-   value = tp_g_value_slice_new_static_string ("x_vnc");
+   value = tp_g_value_slice_new_static_string ("rfb");
    g_hash_table_insert (request,
        TP_IFACE_CHANNEL_TYPE_STREAM_TUBE  ".Service",
        value);
index 2889aa304bf0526e0ba9e8e423dac157c29588ef,b286464d282b619c004177ba44a4a8958b02f7ef..e1094f1be6da498f292158a6b99f724e02c87c72
@@@ -31,6 -31,7 +31,6 @@@
  
  #include <libempathy/empathy-time.h>
  #include <libempathy/empathy-utils.h>
 -#include <libmissioncontrol/mc-profile.h>
  
  #include "empathy-theme-adium.h"
  #include "empathy-smiley-manager.h"
@@@ -298,33 -299,6 +298,6 @@@ theme_adium_parse_body (EmpathyThemeAdi
                               EMPATHY_PREFS_CHAT_SHOW_SMILEYS,
                               &use_smileys);
  
-       if (use_smileys) {
-               /* Replace smileys by a <img/> tag */
-               string = g_string_sized_new (strlen (text));
-               smileys = empathy_smiley_manager_parse (priv->smiley_manager, text);
-               for (l = smileys; l; l = l->next) {
-                       EmpathySmiley *smiley;
-                       smiley = l->data;
-                       if (smiley->path) {
-                               g_string_append_printf (string,
-                                                       "<abbr title='%s'><img src=\"%s\"/ alt=\"%s\"/></abbr>",
-                                                       smiley->str, smiley->path, smiley->str);
-                       } else {
-                               gchar *str;
-                               str = g_markup_escape_text (smiley->str, -1);
-                               g_string_append (string, str);
-                               g_free (str);
-                       }
-                       empathy_smiley_free (smiley);
-               }
-               g_slist_free (smileys);
-               g_free (ret);
-               text = ret = g_string_free (string, FALSE);
-       }
        /* Add <a href></a> arround links */
        uri_regex = empathy_uri_regex_dup_singleton ();
        match = g_regex_match (uri_regex, text, 0, &match_info);
  
                string = g_string_sized_new (strlen (text));
                do {
+                       gchar *real_url;
                        g_match_info_fetch_pos (match_info, 0, &s, &e);
  
                        if (s > last) {
                        }
  
                        /* Append the link inside <a href=""></a> tag */
+                       real_url = empathy_make_absolute_url (text + s);
                        g_string_append (string, "<a href=\"");
-                       g_string_append_len (string, text + s, e - s);
+                       g_string_append (string, real_url);
                        g_string_append (string, "\">");
                        g_string_append_len (string, text + s, e - s);
                        g_string_append (string, "</a>");
  
+                       g_free (real_url);
                        last = e;
                } while (g_match_info_next (match_info, NULL));
  
                        g_string_append_len (string, text + e, strlen (text) - e);
                }
  
+               g_free (ret);
+               text = ret = g_string_free (string, FALSE);
+       } else if (use_smileys) {
+               /* Replace smileys by a <img/> tag */
+               string = g_string_sized_new (strlen (text));
+               smileys = empathy_smiley_manager_parse (priv->smiley_manager, text);
+               for (l = smileys; l; l = l->next) {
+                       EmpathySmiley *smiley;
+                       smiley = l->data;
+                       if (smiley->path) {
+                               g_string_append_printf (string,
+                                                       "<abbr title='%s'><img src=\"%s\"/ alt=\"%s\"/></abbr>",
+                                                       smiley->str, smiley->path, smiley->str);
+                       } else {
+                               gchar *str;
+                               str = g_markup_escape_text (smiley->str, -1);
+                               g_string_append (string, str);
+                               g_free (str);
+                       }
+                       empathy_smiley_free (smiley);
+               }
+               g_slist_free (smileys);
                g_free (ret);
                text = ret = g_string_free (string, FALSE);
        }
        g_match_info_free (match_info);
        g_regex_unref (uri_regex);
  
@@@ -474,6 -479,7 +478,6 @@@ theme_adium_append_html (EmpathyThemeAd
                } else if (theme_adium_match (&cur, "%time")) {
                        gchar *format = NULL;
                        gchar *end;
 -
                        /* Time can be in 2 formats:
                         * %time% or %time{strftime format}%
                         * Extract the time format if provided. */
@@@ -518,6 -524,7 +522,6 @@@ theme_adium_append_message (EmpathyChat
        EmpathyThemeAdiumPriv *priv = GET_PRIV (theme);
        EmpathyContact        *sender;
        EmpathyAccount        *account;
 -      McProfile             *account_profile;
        gchar                 *dup_body = NULL;
        const gchar           *body;
        const gchar           *name;
        /* Get information */
        sender = empathy_message_get_sender (msg);
        account = empathy_contact_get_account (sender);
 -      account_profile = empathy_account_get_profile (account);
 -      service_name = mc_profile_get_display_name (account_profile);
 +      service_name = empathy_account_get_protocol (account);
        timestamp = empathy_message_get_timestamp (msg);
        body = empathy_message_get_body (msg);
        dup_body = theme_adium_parse_body (theme, body);
index 3dcefdcfbe67319ae70a7ce6f8cc763378b45093,32abc58842398a335471c87446678b9db580b174..c12cbd1c9ce31c783ce8f9a7f373e30d74f0b183
@@@ -38,6 -38,8 +38,6 @@@
  #include <gtk/gtk.h>
  #include <gio/gio.h>
  
 -#include <libmissioncontrol/mc-profile.h>
 -
  #include "empathy-ui-utils.h"
  #include "empathy-images.h"
  #include "empathy-conf.h"
@@@ -180,6 -182,16 +180,6 @@@ empathy_builder_unref_and_keep_widget (
        return widget;
  }
  
 -const gchar *
 -empathy_icon_name_from_account (EmpathyAccount *account)
 -{
 -      McProfile *profile;
 -
 -      profile = empathy_account_get_profile (account);
 -
 -      return mc_profile_get_icon_name (profile);
 -}
 -
  const gchar *
  empathy_icon_name_for_presence (TpConnectionPresenceType presence)
  {
@@@ -1321,20 -1333,26 +1321,26 @@@ empathy_get_toplevel_window (GtkWidget 
        return NULL;
  }
  
- /* The URL opening code can't handle schemeless strings, so we try to be
+ /** empathy_make_absolute_url:
+  * @url: an url
+  *
+  * The URL opening code can't handle schemeless strings, so we try to be
   * smart and add http if there is no scheme or doesn't look like a mail
   * address. This should work in most cases, and let us click on strings
   * like "www.gnome.org".
+  *
+  * Returns: a newly allocated url with proper mailto: or http:// prefix, use
+  * g_free when your are done with it
   */
static gchar *
fixup_url (const gchar *url)
+ gchar *
empathy_make_absolute_url (const gchar *url)
  {
        g_return_val_if_fail (url != NULL, NULL);
  
        if (g_str_has_prefix (url, "ghelp:") ||
            g_str_has_prefix (url, "mailto:") ||
            strstr (url, ":/")) {
-               return NULL;
+               return g_strdup (url);
        }
  
        if (strstr (url, "@")) {
@@@ -1354,12 -1372,9 +1360,9 @@@ empathy_url_show (GtkWidget *parent
        g_return_if_fail (parent == NULL || GTK_IS_WIDGET (parent));
        g_return_if_fail (url != NULL);
  
-       real_url = fixup_url (url);
-       if (real_url) {
-               url = real_url;
-       }
+       real_url = empathy_make_absolute_url (url);
  
-       gtk_show_uri (parent ? gtk_widget_get_screen (parent) : NULL, url,
+       gtk_show_uri (parent ? gtk_widget_get_screen (parent) : NULL, real_url,
                      gtk_get_current_event_time (), &error);
  
        if (error) {
@@@ -1476,6 -1491,8 +1479,8 @@@ empathy_send_file_with_file_chooser (Em
        gtk_dialog_set_default_response (GTK_DIALOG (widget),
                                         GTK_RESPONSE_OK);
  
+       gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (widget), FALSE);
        g_signal_connect (widget, "response",
                          G_CALLBACK (file_manager_send_file_response_cb),
                          contact);
index 312835f0c3c69dbf577045cf97d9c8e18c2d6a9c,3299a44e0e3f3a8bd13e766609c31370f2d5118a..afb409af430b1115a5119fe2a4526bb0046d8d5f
@@@ -34,6 -34,8 +34,6 @@@
  
  #include <gtk/gtk.h>
  
 -#include <libmissioncontrol/mc-profile.h>
 -
  #include <libempathy/empathy-contact.h>
  #include <libempathy/empathy-account.h>
  #include <libempathy/empathy-ft-handler.h>
@@@ -57,6 -59,7 +57,6 @@@ GtkWidget     *empathy_builder_unref_an
                                                         GtkWidget        *root);
  
  /* Pixbufs */
 -const gchar * empathy_icon_name_from_account            (EmpathyAccount   *account);
  const gchar * empathy_icon_name_for_presence            (TpConnectionPresenceType  presence);
  const gchar * empathy_icon_name_for_contact             (EmpathyContact   *contact);
  GdkPixbuf *   empathy_pixbuf_from_data                  (gchar            *data,
@@@ -109,6 -112,8 +109,8 @@@ GtkWidget * empathy_link_button_ne
  void        empathy_send_file_with_file_chooser         (EmpathyContact   *contact);
  void        empathy_receive_file_with_file_chooser      (EmpathyFTHandler *handler);
  
+ gchar *     empathy_make_absolute_url                   (const gchar *url);
  G_END_DECLS
  
  #endif /*  __EMPATHY_UI_UTILS_H__ */
diff --combined libempathy/Makefile.am
index cdaa144fcbce7b52e03276b662506a7fcda5a84b,0250a63d884168a91a6d03baa33c0d4a6db438fc..5fe4a9df7f6c955034f28645ed0cd45545f6b051
@@@ -10,7 -10,8 +10,8 @@@ AM_CPPFLAGS 
        -DG_LOG_DOMAIN=\"empathy\"                      \
        $(LIBEMPATHY_CFLAGS)                            \
        $(GEOCLUE_CFLAGS)                               \
-       $(NETWORK_MANAGER_CFLAGS) \
+       $(NETWORK_MANAGER_CFLAGS)                       \
+       $(CONNMAN_CFLAGS)                               \
        $(WARN_CFLAGS)                                  \
        $(DISABLE_DEPRECATED)
  
@@@ -25,18 -26,18 +26,19 @@@ lib_LTLIBRARIES = libempathy.l
  
  libempathy_la_SOURCES =                                       \
        empathy-account.c                       \
 -      empathy-account-priv.h                  \
 +      empathy-account-settings.c                      \
        empathy-account-manager.c                       \
        empathy-chatroom.c                              \
        empathy-chatroom-manager.c                      \
        empathy-call-factory.c                          \
        empathy-call-handler.c                          \
+       empathy-connectivity.c                          \
        empathy-contact.c                               \
        empathy-contact-groups.c                        \
        empathy-contact-list.c                          \
        empathy-contact-manager.c                       \
        empathy-contact-monitor.c                       \
 +      empathy-connection-managers.c                   \
        empathy-debug.c                                 \
        empathy-debugger.c                              \
        empathy-dispatcher.c                            \
@@@ -70,26 -71,26 +72,28 @@@ libempathy_la_LIBADD =             
        $(top_builddir)/extensions/libemp-extensions.la \
        $(LIBEMPATHY_LIBS) \
        $(GEOCLUE_LIBS) \
-       $(NETWORK_MANAGER_LIBS)
+       $(NETWORK_MANAGER_LIBS) \
+       $(CONNMAN_LIBS)
  
  libempathy_la_LDFLAGS =               \
         -version-info ${LIBEMPATHY_CURRENT}:${LIBEMPATHY_REVISION}:${LIBEMPATHY_AGE} \
         -export-symbols-regex ^empathy_
  
  libempathy_headers =                          \
 +      empathy-account-settings.h              \
        empathy-account.h               \
        empathy-account-manager.h               \
        empathy-chatroom.h                      \
        empathy-chatroom-manager.h              \
        empathy-call-factory.h                  \
        empathy-call-handler.h                  \
+       empathy-connectivity.h                  \
        empathy-contact.h                       \
        empathy-contact-groups.h                \
        empathy-contact-list.h                  \
        empathy-contact-manager.h               \
        empathy-contact-monitor.h               \
 +      empathy-connection-managers.h           \
        empathy-debug.h                         \
        empathy-debugger.h                      \
        empathy-dispatcher.h                    \
index 39f950f868079db13e65b4837861d0cd7b443e35,72c317b7f7a6a4661f967e2b35e3382f9278f772..1c6e53c6c36cb6148e4cdec655b72c2005db058e
  #include <stdlib.h>
  
  #include <telepathy-glib/util.h>
 +#include <telepathy-glib/interfaces.h>
  
  #include <telepathy-farsight/channel.h>
  #include <telepathy-farsight/stream.h>
  
- #include <gst/farsight/fs-element-added-notifier.h>
  #include "empathy-call-handler.h"
  #include "empathy-dispatcher.h"
  #include "empathy-marshal.h"
@@@ -66,7 -63,6 +64,6 @@@ typedef struct 
    TfChannel *tfchannel;
    gboolean initial_audio;
    gboolean initial_video;
-   FsElementAddedNotifier *fsnotifier;
  } EmpathyCallHandlerPriv;
  
  #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyCallHandler)
@@@ -99,12 -95,6 +96,6 @@@ empathy_call_handler_dispose (GObject *
  
    priv->call = NULL;
  
-   if (priv->fsnotifier != NULL)
-     {
-       g_object_unref (priv->fsnotifier);
-     }
-   priv->fsnotifier = NULL;
    /* release any references held by the object here */
    if (G_OBJECT_CLASS (empathy_call_handler_parent_class)->dispose)
      G_OBJECT_CLASS (empathy_call_handler_parent_class)->dispose (object);
@@@ -322,50 -312,11 +313,11 @@@ empathy_call_handler_bus_message (Empat
    tf_channel_bus_message (priv->tfchannel, message);
  }
  
- static void
- conference_element_added (FsElementAddedNotifier *notifier,
-     GstBin *bin,
-     GstElement *element,
-     gpointer user_data)
- {
-   GstElementFactory *factory;
-   const gchar *name;
-   factory = gst_element_get_factory (element);
-   name = gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory));
-   if (!tp_strdiff (name, "x264enc"))
-     {
-       /* Ensure that the encoder creates the baseline profile */
-       g_object_set (element,
-           "byte-stream", TRUE,
-           "bframes", 0,
-           "b-adapt", FALSE,
-           "cabac", FALSE,
-           "dct8x8", FALSE,
-           NULL);
-     }
-   else if (!tp_strdiff (name, "gstrtpbin"))
-     {
-       /* Lower the jitterbuffer latency to make it more suitable for video
-        * conferencing */
-       g_object_set (element, "latency", 100, NULL);
-     }
- }
  static void
  empathy_call_handler_tf_channel_session_created_cb (TfChannel *tfchannel,
    FsConference *conference, FsParticipant *participant,
    EmpathyCallHandler *self)
  {
-   EmpathyCallHandlerPriv *priv = GET_PRIV (self);
-   priv->fsnotifier = fs_element_added_notifier_new ();
-   fs_element_added_notifier_add (priv->fsnotifier, GST_BIN (conference));
-   g_signal_connect (priv->fsnotifier, "element-added",
-     G_CALLBACK (conference_element_added), NULL);
    g_signal_emit (G_OBJECT (self), signals[CONFERENCE_ADDED], 0,
      GST_ELEMENT (conference));
  }
@@@ -427,54 -378,25 +379,25 @@@ empathy_call_handler_tf_channel_closed_
    g_signal_emit (G_OBJECT (handler), signals[CLOSED], 0);
  }
  
- static GList *
- empathy_call_handler_tf_channel_codec_config_get_defaults (FsCodec *codecs)
- {
-   GList *l = NULL;
-   int i;
-   for (i = 0; codecs[i].encoding_name != NULL; i++)
-       l = g_list_append (l, fs_codec_copy (codecs + i));
-   return l;
- }
  static GList *
  empathy_call_handler_tf_channel_codec_config_cb (TfChannel *channel,
    guint stream_id, FsMediaType media_type, guint direction, gpointer user_data)
  {
-   FsCodec audio_codecs[] = {
-     { FS_CODEC_ID_ANY, "SPEEX", FS_MEDIA_TYPE_AUDIO, 16000, },
-     { FS_CODEC_ID_ANY, "SPEEX", FS_MEDIA_TYPE_AUDIO, 8000, },
-     { FS_CODEC_ID_DISABLE, "DV",     FS_MEDIA_TYPE_AUDIO, },
-     { FS_CODEC_ID_DISABLE, "MPA",    FS_MEDIA_TYPE_AUDIO, },
-     { FS_CODEC_ID_DISABLE, "VORBIS", FS_MEDIA_TYPE_AUDIO, },
-     { FS_CODEC_ID_DISABLE, "MP3",    FS_MEDIA_TYPE_AUDIO, },
-     { 0, NULL, 0,}
-   };
-   FsCodec video_codecs[] = {
-     { FS_CODEC_ID_ANY, "H264",   FS_MEDIA_TYPE_VIDEO, },
-     { FS_CODEC_ID_ANY, "THEORA", FS_MEDIA_TYPE_VIDEO, },
-     { FS_CODEC_ID_ANY, "H263",   FS_MEDIA_TYPE_VIDEO, },
-     { FS_CODEC_ID_DISABLE, "DV",   FS_MEDIA_TYPE_VIDEO, },
-     { FS_CODEC_ID_DISABLE, "JPEG", FS_MEDIA_TYPE_VIDEO, },
-     { FS_CODEC_ID_DISABLE, "MPV",  FS_MEDIA_TYPE_VIDEO, },
-     { 0, NULL, 0}
-   };
-   switch (media_type)
+   gchar *filename = empathy_file_lookup ("codec-preferences", "data");
+   GList *codecs;
+   GError *error = NULL;
+   codecs = fs_codec_list_from_keyfile (filename, &error);
+   g_free (filename);
+   if (!codecs)
      {
-       case FS_MEDIA_TYPE_AUDIO:
-         return empathy_call_handler_tf_channel_codec_config_get_defaults
-           (audio_codecs);
-       case FS_MEDIA_TYPE_VIDEO:
-         return empathy_call_handler_tf_channel_codec_config_get_defaults
-           (video_codecs);
+       g_warning ("No codec-preferences file: %s",
+           error ? error->message : "No error message");
      }
+   g_clear_error (&error);
  
-   return NULL;
+   return codecs;
  }
  
  static void
index 94764f420f75f5458a9026e2ece8a0eaf40725b9,ac0ca72f680ef0aa04ba13391dcc17ea0b537049..c86b997afc929860ca69b73173cae349c509ef22
  
  #include <glib/gi18n-lib.h>
  #include <dbus/dbus-glib.h>
- #ifdef HAVE_NM
- #include <nm-client.h>
- #endif
  
  #include <telepathy-glib/dbus.h>
  #include <telepathy-glib/util.h>
 -#include <libmissioncontrol/mc-enum-types.h>
  
 +#include "empathy-account-manager.h"
  #include "empathy-idle.h"
  #include "empathy-utils.h"
+ #include "empathy-connectivity.h"
  
  #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
  #include "empathy-debug.h"
  
  #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyIdle)
  typedef struct {
 -      MissionControl *mc;
        DBusGProxy     *gs_proxy;
- #ifdef HAVE_NM
-       NMClient       *nm_client;
- #endif
+       EmpathyConnectivity *connectivity;
+       gulong state_change_signal_id;
  
        TpConnectionPresenceType      state;
        gchar          *status;
        TpConnectionPresenceType      flash_state;
        gboolean        auto_away;
-       gboolean        use_nm;
  
        TpConnectionPresenceType      away_saved_state;
-       TpConnectionPresenceType      nm_saved_state;
-       gchar          *nm_saved_status;
+       TpConnectionPresenceType      saved_state;
+       gchar          *saved_status;
  
        gboolean        is_idle;
-       gboolean        nm_connected;
        guint           ext_away_timeout;
 +
 +      EmpathyAccountManager *manager;
  } EmpathyIdlePriv;
  
  typedef enum {
@@@ -79,8 -73,7 +74,7 @@@ enum 
        PROP_STATE,
        PROP_STATUS,
        PROP_FLASH_STATE,
-       PROP_AUTO_AWAY,
-       PROP_USE_NM
+       PROP_AUTO_AWAY
  };
  
  G_DEFINE_TYPE (EmpathyIdle, empathy_idle, G_TYPE_OBJECT);
  static EmpathyIdle * idle_singleton = NULL;
  
  static void
 -idle_presence_changed_cb (MissionControl *mc,
 +idle_presence_changed_cb (EmpathyAccountManager *manager,
                          TpConnectionPresenceType state,
                          gchar          *status,
 +                        gchar          *status_message,
                          EmpathyIdle    *idle)
  {
        EmpathyIdlePriv *priv;
                /* Assume our presence is offline if MC reports UNSET */
                state = TP_CONNECTION_PRESENCE_TYPE_OFFLINE;
  
 -      DEBUG ("Presence changed to '%s' (%d)", status, state);
 +      DEBUG ("Presence changed to '%s' (%d) \"%s\"", status, state,
 +              status_message);
  
        g_free (priv->status);
        priv->state = state;
 -      priv->status = NULL;
 -      if (!EMP_STR_EMPTY (status)) {
 -              priv->status = g_strdup (status);
 -      }
 +      if (EMP_STR_EMPTY (status_message))
 +              priv->status = NULL;
 +      else
 +              priv->status = g_strdup (status_message);
  
        g_object_notify (G_OBJECT (idle), "state");
        g_object_notify (G_OBJECT (idle), "status");
@@@ -175,7 -166,7 +169,7 @@@ idle_session_status_changed_cb (DBusGPr
                is_idle ? "yes" : "no");
  
        if (!priv->auto_away ||
-           (priv->nm_saved_state == TP_CONNECTION_PRESENCE_TYPE_UNSET &&
+           (priv->saved_state == TP_CONNECTION_PRESENCE_TYPE_UNSET &&
             (priv->state <= TP_CONNECTION_PRESENCE_TYPE_OFFLINE ||
              priv->state == TP_CONNECTION_PRESENCE_TYPE_HIDDEN))) {
                /* We don't want to go auto away OR we explicitely asked to be
  
                idle_ext_away_start (idle);
  
-               if (priv->nm_saved_state != TP_CONNECTION_PRESENCE_TYPE_UNSET) {
+               if (priv->saved_state != TP_CONNECTION_PRESENCE_TYPE_UNSET) {
                        /* We are disconnected, when coming back from away
                         * we want to restore the presence before the
                         * disconnection. */
-                       priv->away_saved_state = priv->nm_saved_state;
+                       priv->away_saved_state = priv->saved_state;
                } else {
                        priv->away_saved_state = priv->state;
                }
        priv->is_idle = is_idle;
  }
  
- #ifdef HAVE_NM
  static void
- idle_nm_state_change_cb (NMClient         *client,
-                        const GParamSpec *pspec,
-                        EmpathyIdle      *idle)
+ idle_state_change_cb (EmpathyConnectivity *connectivity,
+                     gboolean new_online,
+                     EmpathyIdle *idle)
  {
        EmpathyIdlePriv *priv;
-       gboolean         old_nm_connected;
-       gboolean         new_nm_connected;
-       NMState          state;
  
        priv = GET_PRIV (idle);
  
-       if (!priv->use_nm) {
-               return;
-       }
-       state = nm_client_get_state (priv->nm_client);
-       old_nm_connected = priv->nm_connected;
-       new_nm_connected = !(state == NM_STATE_CONNECTING ||
-                            state == NM_STATE_DISCONNECTED);
-       priv->nm_connected = TRUE; /* To be sure _set_state will work */
-       DEBUG ("New network state %d", state);
-       if (old_nm_connected && !new_nm_connected) {
-               /* We are no more connected */
+       if (!new_online) {
+               /* We are no longer connected */
                DEBUG ("Disconnected: Save state %d (%s)",
                                priv->state, priv->status);
-               priv->nm_saved_state = priv->state;
-               g_free (priv->nm_saved_status);
-               priv->nm_saved_status = g_strdup (priv->status);
+               priv->saved_state = priv->state;
+               g_free (priv->saved_status);
+               priv->saved_status = g_strdup (priv->status);
                empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_OFFLINE);
        }
-       else if (!old_nm_connected && new_nm_connected
-                       && priv->nm_saved_state != TP_CONNECTION_PRESENCE_TYPE_UNSET) {
+       else if (new_online
+                       && priv->saved_state != TP_CONNECTION_PRESENCE_TYPE_UNSET) {
                /* We are now connected */
                DEBUG ("Reconnected: Restore state %d (%s)",
-                               priv->nm_saved_state, priv->nm_saved_status);
+                               priv->saved_state, priv->saved_status);
                empathy_idle_set_presence (idle,
-                               priv->nm_saved_state,
-                               priv->nm_saved_status);
-               priv->nm_saved_state = TP_CONNECTION_PRESENCE_TYPE_UNSET;
-               g_free (priv->nm_saved_status);
-               priv->nm_saved_status = NULL;
+                               priv->saved_state,
+                               priv->saved_status);
+               priv->saved_state = TP_CONNECTION_PRESENCE_TYPE_UNSET;
+               g_free (priv->saved_status);
+               priv->saved_status = NULL;
        }
-       priv->nm_connected = new_nm_connected;
  }
- #endif
  
  static void
  idle_finalize (GObject *object)
        priv = GET_PRIV (object);
  
        g_free (priv->status);
 -      g_object_unref (priv->mc);
  
        if (priv->gs_proxy) {
                g_object_unref (priv->gs_proxy);
        }
  
-       if (priv->manager != NULL)
-               g_object_unref (priv->manager);
+       g_signal_handler_disconnect (priv->connectivity,
+                                    priv->state_change_signal_id);
+       priv->state_change_signal_id = 0;
  
- #ifdef HAVE_NM
-       if (priv->nm_client) {
-               g_object_unref (priv->nm_client);
-       }
- #endif
+       g_object_unref (priv->connectivity);
  
        idle_ext_away_stop (EMPATHY_IDLE (object));
  }
@@@ -355,9 -325,6 +327,6 @@@ idle_get_property (GObject    *object
        case PROP_AUTO_AWAY:
                g_value_set_boolean (value, empathy_idle_get_auto_away (idle));
                break;
-       case PROP_USE_NM:
-               g_value_set_boolean (value, empathy_idle_get_use_nm (idle));
-               break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
                break;
@@@ -389,9 -356,6 +358,6 @@@ idle_set_property (GObject      *object
        case PROP_AUTO_AWAY:
                empathy_idle_set_auto_away (idle, g_value_get_boolean (value));
                break;
-       case PROP_USE_NM:
-               empathy_idle_set_use_nm (idle, g_value_get_boolean (value));
-               break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
                break;
@@@ -440,33 -404,70 +406,25 @@@ empathy_idle_class_init (EmpathyIdleCla
                                                                FALSE,
                                                                G_PARAM_READWRITE));
  
-        g_object_class_install_property (object_class,
-                                         PROP_USE_NM,
-                                         g_param_spec_boolean ("use-nm",
-                                                               "Use Network Manager",
-                                                               "Set presence according to Network Manager",
-                                                               TRUE,
-                                                               G_PARAM_CONSTRUCT | G_PARAM_READWRITE));
        g_type_class_add_private (object_class, sizeof (EmpathyIdlePriv));
  }
  
 -static TpConnectionPresenceType
 -empathy_idle_get_actual_presence (EmpathyIdle *idle, GError **error)
 -{
 -      McPresence presence;
 -      EmpathyIdlePriv *priv = GET_PRIV (idle);
 -
 -      presence = mission_control_get_presence_actual (priv->mc, error);
 -
 -      switch (presence) {
 -      case MC_PRESENCE_OFFLINE:
 -              return TP_CONNECTION_PRESENCE_TYPE_OFFLINE;
 -      case MC_PRESENCE_AVAILABLE:
 -              return TP_CONNECTION_PRESENCE_TYPE_AVAILABLE;
 -      case MC_PRESENCE_AWAY:
 -              return TP_CONNECTION_PRESENCE_TYPE_AWAY;
 -      case MC_PRESENCE_EXTENDED_AWAY:
 -              return TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY;
 -      case MC_PRESENCE_HIDDEN:
 -              return TP_CONNECTION_PRESENCE_TYPE_HIDDEN;
 -      case MC_PRESENCE_DO_NOT_DISTURB:
 -              return TP_CONNECTION_PRESENCE_TYPE_BUSY;
 -      default:
 -              return TP_CONNECTION_PRESENCE_TYPE_OFFLINE;
 -      }
 -}
 -
  static void
  empathy_idle_init (EmpathyIdle *idle)
  {
 -      GError          *error = NULL;
        EmpathyIdlePriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (idle,
                EMPATHY_TYPE_IDLE, EmpathyIdlePriv);
  
        idle->priv = priv;
        priv->is_idle = FALSE;
 -      priv->mc = empathy_mission_control_dup_singleton ();
 -      priv->state = empathy_idle_get_actual_presence (idle, &error);
 -      if (error) {
 -              DEBUG ("Error getting actual presence: %s", error->message);
 -
 -              /* Fallback to OFFLINE as that's what mission_control_get_presence_actual
 -              does. This also ensure to always display the status icon (there is no
 -              unset presence icon). */
 -              priv->state = TP_CONNECTION_PRESENCE_TYPE_OFFLINE;
 -              g_clear_error (&error);
 -      }
 -      priv->status = mission_control_get_presence_message_actual (priv->mc, &error);
 -      if (error || EMP_STR_EMPTY (priv->status)) {
 -              g_free (priv->status);
 -              priv->status = NULL;
  
 -              if (error) {
 -                      DEBUG ("Error getting actual presence message: %s", error->message);
 -                      g_clear_error (&error);
 -              }
 -      }
 +      priv->manager = empathy_account_manager_dup_singleton ();
 +      priv->state = empathy_account_manager_get_global_presence (priv->manager,
 +              NULL, &priv->status);
  
 -      dbus_g_proxy_connect_signal (DBUS_G_PROXY (priv->mc),
 -                                   "PresenceChanged",
 -                                   G_CALLBACK (idle_presence_changed_cb),
 -                                   idle, NULL);
 +
 +      g_signal_connect (priv->manager, "global-presence-changed",
 +              G_CALLBACK (idle_presence_changed_cb), idle);
  
        priv->gs_proxy = dbus_g_proxy_new_for_name (tp_get_bus (),
                                                    "org.gnome.SessionManager",
                DEBUG ("Failed to get gs proxy");
        }
  
- #ifdef HAVE_NM
-       priv->nm_client = nm_client_new ();
-       if (priv->nm_client) {
-               g_signal_connect (priv->nm_client, "notify::" NM_CLIENT_STATE,
-                                 G_CALLBACK (idle_nm_state_change_cb),
-                                 idle);
-       } else {
-               DEBUG ("Failed to get nm proxy");
-       }
- #endif
+       priv->connectivity = empathy_connectivity_dup_singleton ();
+       priv->state_change_signal_id = g_signal_connect (priv->connectivity,
+           "state-change", G_CALLBACK (idle_state_change_cb), idle);
  }
  
  EmpathyIdle *
@@@ -574,31 -568,36 +525,31 @@@ empathy_idle_set_flash_state (EmpathyId
  
  static void
  empathy_idle_do_set_presence (EmpathyIdle *idle,
 -                         TpConnectionPresenceType   state,
 -                         const gchar *status)
 +                         TpConnectionPresenceType status_type,
 +                         const gchar *status_message)
  {
 -      McPresence mc_state = MC_PRESENCE_UNSET;
        EmpathyIdlePriv *priv = GET_PRIV (idle);
 +      const gchar *statuses[NUM_TP_CONNECTION_PRESENCE_TYPES] = {
 +              NULL,
 +              "offline",
 +              "available",
 +              "away",
 +              "xa",
 +              "hidden",
 +              "busy",
 +              NULL,
 +              NULL,
 +      };
 +      const gchar *status;
  
 -      switch (state) {
 -              case TP_CONNECTION_PRESENCE_TYPE_OFFLINE:
 -                      mc_state = MC_PRESENCE_OFFLINE;
 -                      break;
 -              case TP_CONNECTION_PRESENCE_TYPE_AVAILABLE:
 -                      mc_state = MC_PRESENCE_AVAILABLE;
 -                      break;
 -              case TP_CONNECTION_PRESENCE_TYPE_AWAY:
 -                      mc_state = MC_PRESENCE_AWAY;
 -                      break;
 -              case TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY:
 -                      mc_state = MC_PRESENCE_EXTENDED_AWAY;
 -                      break;
 -              case TP_CONNECTION_PRESENCE_TYPE_HIDDEN:
 -                      mc_state = MC_PRESENCE_HIDDEN;
 -                      break;
 -              case TP_CONNECTION_PRESENCE_TYPE_BUSY:
 -                      mc_state = MC_PRESENCE_DO_NOT_DISTURB;
 -                      break;
 -              default:
 -                      g_assert_not_reached ();
 -      }
 +      g_assert (status_type > 0 && status_type < NUM_TP_CONNECTION_PRESENCE_TYPES);
 +
 +      status = statuses[status_type];
 +
 +      g_return_if_fail (status != NULL);
  
 -      mission_control_set_presence (priv->mc, mc_state, status, NULL, NULL);
 +      empathy_account_manager_request_global_presence (priv->manager,
 +              status_type, status, status_message);
  }
  
  void
@@@ -619,10 -618,9 +570,9 @@@ empathy_idle_set_presence (EmpathyIdle 
                status = NULL;
        }
  
-       if (!priv->nm_connected) {
-               DEBUG ("NM not connected");
+       if (!empathy_connectivity_is_online (priv->connectivity)) {
+               DEBUG ("Empathy is not online");
  
-               priv->nm_saved_state = state;
                if (tp_strdiff (priv->status, status)) {
                        g_free (priv->status);
                        priv->status = NULL;
                        }
                        g_object_notify (G_OBJECT (idle), "status");
                }
-               return;
        }
  
        empathy_idle_do_set_presence (idle, state, status);
@@@ -657,42 -653,3 +605,3 @@@ empathy_idle_set_auto_away (EmpathyIdl
        g_object_notify (G_OBJECT (idle), "auto-away");
  }
  
- gboolean
- empathy_idle_get_use_nm (EmpathyIdle *idle)
- {
-       EmpathyIdlePriv *priv = GET_PRIV (idle);
-       return priv->use_nm;
- }
- void
- empathy_idle_set_use_nm (EmpathyIdle *idle,
-                        gboolean     use_nm)
- {
-       EmpathyIdlePriv *priv = GET_PRIV (idle);
- #ifdef HAVE_NM
-       if (!priv->nm_client || use_nm == priv->use_nm) {
-               return;
-       }
- #endif
-       priv->use_nm = use_nm;
- #ifdef HAVE_NM
-       if (use_nm) {
-               idle_nm_state_change_cb (priv->nm_client, NULL, idle);
- #else
-       if (0) {
- #endif
-       } else {
-               priv->nm_connected = TRUE;
-               if (priv->nm_saved_state != TP_CONNECTION_PRESENCE_TYPE_UNSET) {
-                       empathy_idle_set_state (idle, priv->nm_saved_state);
-               }
-               priv->nm_saved_state = TP_CONNECTION_PRESENCE_TYPE_UNSET;
-       }
-       g_object_notify (G_OBJECT (idle), "use-nm");
- }
index d2a8023355a2311e25203b05a15534eb71d37e53,d0b426e59a3a2ca06947455e94233453642ed093..47dcfee23a55a8ade017e9992152552b9ad7794e
@@@ -24,7 -24,7 +24,7 @@@
  
  #include <glib.h>
  
 -#include <libmissioncontrol/mission-control.h>
 +#include <telepathy-glib/enums.h>
  
  G_BEGIN_DECLS
  
@@@ -64,9 -64,6 +64,6 @@@ void         empathy_idle_set_presenc
  gboolean     empathy_idle_get_auto_away       (EmpathyIdle *idle);
  void         empathy_idle_set_auto_away       (EmpathyIdle *idle,
                                               gboolean     auto_away);
- gboolean     empathy_idle_get_use_nm          (EmpathyIdle *idle);
- void         empathy_idle_set_use_nm          (EmpathyIdle *idle,
-                                              gboolean     use_nm);
  
  G_END_DECLS
  
index 51ce79bb676946e0a90fd4445c5772e47f9e6e23,9300364d5202a8d3dab02c8f9aafb602dddfbfb6..69057a87860214cb611ec2f308018fd7d6ada127
@@@ -26,7 -26,6 +26,7 @@@
  #include <telepathy-glib/channel.h>
  #include <telepathy-glib/dbus.h>
  #include <telepathy-glib/util.h>
 +#include <telepathy-glib/interfaces.h>
  
  #include "empathy-tp-chat.h"
  #include "empathy-tp-contact-factory.h"
@@@ -1329,13 -1328,16 +1329,16 @@@ empathy_tp_chat_set_state (EmpathyTpCha
        g_return_if_fail (EMPATHY_IS_TP_CHAT (chat));
        g_return_if_fail (priv->ready);
  
-       DEBUG ("Set state: %d", state);
-       tp_cli_channel_interface_chat_state_call_set_chat_state (priv->channel, -1,
-                                                                state,
-                                                                tp_chat_async_cb,
-                                                                "setting chat state",
-                                                                NULL,
-                                                                G_OBJECT (chat));
+       if (tp_proxy_has_interface_by_id (priv->channel,
+                                         TP_IFACE_QUARK_CHANNEL_INTERFACE_CHAT_STATE)) {
+               DEBUG ("Set state: %d", state);
+               tp_cli_channel_interface_chat_state_call_set_chat_state (priv->channel, -1,
+                                                                        state,
+                                                                        tp_chat_async_cb,
+                                                                        "setting chat state",
+                                                                        NULL,
+                                                                        G_OBJECT (chat));
+       }
  }
  
  
index 29148feec8c9d6a122dd4f940843c306429c164e,f62c7f12f395fd648ed8f1fd8433449ffa0d6def..6b4c20b5376a19ba1be7647bc30f9c3706ccd268
@@@ -26,8 -26,6 +26,8 @@@
  #include <telepathy-glib/util.h>
  #include <telepathy-glib/gtypes.h>
  #include <telepathy-glib/dbus.h>
 +#include <telepathy-glib/interfaces.h>
 +
  #if HAVE_GEOCLUE
  #include <geoclue/geoclue-geocode.h>
  #endif
@@@ -130,7 -128,7 +130,7 @@@ tp_contact_factory_set_aliases_cb (TpCo
  }
  
  static void
- tp_contact_factory_set_location_cb (TpProxy *proxy,
+ tp_contact_factory_set_location_cb (TpConnection *tp_conn,
                                    const GError *error,
                                    gpointer user_data,
                                    GObject *weak_object)
@@@ -570,7 -568,7 +570,7 @@@ tp_contact_factory_update_location (Emp
  }
  
  static void
- tp_contact_factory_got_locations (TpProxy                 *tp_proxy,
+ tp_contact_factory_got_locations (TpConnection                 *tp_conn,
                                  GHashTable              *locations,
                                  const GError            *error,
                                  gpointer                 user_data,
@@@ -626,7 -624,7 +626,7 @@@ tp_contact_factory_capabilities_changed
  }
  
  static void
- tp_contact_factory_location_updated_cb (TpProxy      *proxy,
+ tp_contact_factory_location_updated_cb (TpConnection      *tp_conn,
                                        guint         handle,
                                        GHashTable   *location,
                                        gpointer      user_data,
@@@ -797,8 -795,8 +797,8 @@@ tp_contact_factory_add_contact (Empathy
        g_clear_error (&error);
  
        if (tp_proxy_has_interface_by_id (TP_PROXY (priv->connection),
-               EMP_IFACE_QUARK_CONNECTION_INTERFACE_LOCATION)) {
-               emp_cli_connection_interface_location_call_get_locations (TP_PROXY (priv->connection),
+               TP_IFACE_QUARK_CONNECTION_INTERFACE_LOCATION)) {
+               tp_cli_connection_interface_location_call_get_locations (priv->connection,
                                                                         -1,
                                                                         &handles,
                                                                         tp_contact_factory_got_locations,
@@@ -1204,7 -1202,7 +1204,7 @@@ empathy_tp_contact_factory_set_locatio
  
        DEBUG ("Setting location");
  
-       emp_cli_connection_interface_location_call_set_location (TP_PROXY (priv->connection),
+       tp_cli_connection_interface_location_call_set_location (priv->connection,
                                                                 -1,
                                                                 location,
                                                                 tp_contact_factory_set_location_cb,
@@@ -1318,7 -1316,7 +1318,7 @@@ tp_contact_factory_constructor (GTyp
                                                                                  NULL);
  
  
-       emp_cli_connection_interface_location_connect_to_location_updated (TP_PROXY (priv->connection),
+       tp_cli_connection_interface_location_connect_to_location_updated (priv->connection,
                                                                           tp_contact_factory_location_updated_cb,
                                                                           NULL, NULL,
                                                                           G_OBJECT (tp_factory),
index 4bbe46b4f570311c55a40daacec7acfbc95345bb,71d8efa6778106b09f9025ef0a7d805f73e44e88..2bf2ec4161e5b8c4ae8e434cc99da3250830de9f
@@@ -29,7 -29,6 +29,7 @@@
  #include <telepathy-glib/connection.h>
  #include <telepathy-glib/util.h>
  #include <telepathy-glib/dbus.h>
 +#include <telepathy-glib/interfaces.h>
  
  #include "empathy-tp-contact-list.h"
  #include "empathy-tp-contact-factory.h"
@@@ -974,10 -973,13 +974,13 @@@ tp_contact_list_add (EmpathyContactLis
                tp_cli_channel_interface_group_call_add_members (priv->subscribe,
                        -1, &handles, message, NULL, NULL, NULL, NULL);
        }
-       if (priv->publish &&
-           g_hash_table_lookup (priv->pendings, GUINT_TO_POINTER (handle))) {
-               tp_cli_channel_interface_group_call_add_members (priv->publish,
-                       -1, &handles, message, NULL, NULL, NULL, NULL);
+       if (priv->publish) {
+               TpChannelGroupFlags flags = tp_channel_group_get_flags (priv->subscribe);
+               if (flags & TP_CHANNEL_GROUP_FLAG_CAN_ADD ||
+                   g_hash_table_lookup (priv->pendings, GUINT_TO_POINTER (handle))) {
+                       tp_cli_channel_interface_group_call_add_members (priv->publish,
+                               -1, &handles, message, NULL, NULL, NULL, NULL);
+               }
        }
  }
  
@@@ -1166,21 -1168,24 +1169,24 @@@ tp_contact_list_get_flags (EmpathyConta
  {
        EmpathyTpContactListPriv *priv;
        EmpathyContactListFlags flags;
-       TpChannelGroupFlags group_flags;
  
        g_return_val_if_fail (EMPATHY_IS_TP_CONTACT_LIST (list), FALSE);
  
        priv = GET_PRIV (list);
        flags = priv->flags;
  
-       group_flags = tp_channel_group_get_flags (priv->subscribe);
+       if (priv->subscribe != NULL) {
+               TpChannelGroupFlags group_flags;
  
-       if (group_flags & TP_CHANNEL_GROUP_FLAG_CAN_ADD) {
-               flags |= EMPATHY_CONTACT_LIST_CAN_ADD;
-       }
+               group_flags = tp_channel_group_get_flags (priv->subscribe);
+               if (group_flags & TP_CHANNEL_GROUP_FLAG_CAN_ADD) {
+                       flags |= EMPATHY_CONTACT_LIST_CAN_ADD;
+               }
  
-       if (group_flags & TP_CHANNEL_GROUP_FLAG_CAN_REMOVE) {
-               flags |= EMPATHY_CONTACT_LIST_CAN_REMOVE;
+               if (group_flags & TP_CHANNEL_GROUP_FLAG_CAN_REMOVE) {
+                       flags |= EMPATHY_CONTACT_LIST_CAN_REMOVE;
+               }
        }
  
        return flags;
diff --combined po/POTFILES.in
index 89387f58df04f2c5f4fb5dc2fa1fa2a8ed6e6a70,9d36f245b80618aad887fd4b4ea4e4ad49c9bce0..ec6aea64fde3c46aceb3f2549f7ffa99ba2fbc60
@@@ -4,7 -4,6 +4,7 @@@
  data/empathy.desktop.in.in
  data/empathy.schemas.in
  
 +libempathy/empathy-account.c
  libempathy/empathy-ft-handler.c
  libempathy/empathy-tp-contact-list.c
  libempathy/empathy-tp-file.c
@@@ -21,7 -20,7 +21,7 @@@ libempathy-gtk/empathy-account-widget-i
  [type: gettext/glade]libempathy-gtk/empathy-account-widget-irc.ui
  [type: gettext/glade]libempathy-gtk/empathy-account-widget-jabber.ui
  [type: gettext/glade]libempathy-gtk/empathy-account-widget-msn.ui
 -[type: gettext/glade]libempathy-gtk/empathy-account-widget-salut.ui
 +[type: gettext/glade]libempathy-gtk/empathy-account-widget-local-xmpp.ui
  [type: gettext/glade]libempathy-gtk/empathy-account-widget-sip.ui
  [type: gettext/glade]libempathy-gtk/empathy-account-widget-yahoo.ui
  libempathy-gtk/empathy-avatar-chooser.c
@@@ -67,7 -66,7 +67,7 @@@ src/empathy-accounts-dialog.
  src/empathy-call-window.c
  [type: gettext/glade]src/empathy-call-window.ui
  src/empathy-chat-window.c
- src/empathy-chat-window.ui
[type: gettext/glade]src/empathy-chat-window.ui
  src/empathy-chatrooms-window.c
  [type: gettext/glade]src/empathy-chatrooms-window.ui
  src/empathy-event-manager.c
index 669c0901348fa00c7b4604e02484dbb2b9f968e1,488f5b3ac8246a4cd3d17549bf309cf706d9904b..b8f0b40aa6bb42c89adc2218157baedcf19c5a6e
      '("location" "EMPATHY_DEBUG_LOCATION")
      '("other" "EMPATHY_DEBUG_OTHER")
      '("share-desktop" "EMPATHY_DEBUG_SHARE_DESKTOP")
+     '("connectivity" "EMPATHY_DEBUG_CONNECTIVITY")
    )
  )
  
    (return-type "EmpathyAccountManager*")
  )
  
 -(define-method create
 +(define-method is_ready
    (of-object "EmpathyAccountManager")
 -  (c-name "empathy_account_manager_create")
 -  (return-type "EmpathyAccount*")
 -  (parameters
 -    '("McProfile*" "profile")
 -  )
 +  (c-name "empathy_account_manager_is_ready")
 +  (return-type "gboolean")
  )
  
  (define-method get_connected_accounts
    (return-type "int")
  )
  
 -(define-method get_account
 +(define-method get_account_for_connection
    (of-object "EmpathyAccountManager")
 -  (c-name "empathy_account_manager_get_account")
 +  (c-name "empathy_account_manager_get_account_for_connection")
    (return-type "EmpathyAccount*")
    (parameters
      '("TpConnection*" "connection")
    )
  )
  
 -(define-method lookup
 +(define-method get_account
    (of-object "EmpathyAccountManager")
 -  (c-name "empathy_account_manager_lookup")
 +  (c-name "empathy_account_manager_get_account")
    (return-type "EmpathyAccount*")
    (parameters
      '("const-gchar*" "unique_name")
    )
  )
  
 +(define-method request_global_presence
 +  (of-object "EmpathyAccountManager")
 +  (c-name "empathy_account_manager_request_global_presence")
 +  (return-type "none")
 +  (parameters
 +    '("TpConnectionPresenceType" "type")
 +    '("const-gchar*" "status")
 +    '("const-gchar*" "message")
 +  )
 +)
 +
 +(define-method get_global_presence
 +  (of-object "EmpathyAccountManager")
 +  (c-name "empathy_account_manager_get_global_presence")
 +  (return-type "TpConnectionPresenceType")
 +  (parameters
 +    '("gchar**" "status")
 +    '("gchar**" "message")
 +  )
 +)
 +
 +(define-method create_account_async
 +  (of-object "EmpathyAccountManager")
 +  (c-name "empathy_account_manager_create_account_async")
 +  (return-type "none")
 +  (parameters
 +    '("const-gchar*" "connection_manager")
 +    '("const-gchar*" "protocol")
 +    '("const-gchar*" "display_name")
 +    '("GHashTable*" "parameters")
 +    '("GHashTable*" "properties")
 +    '("GAsyncReadyCallback" "callback")
 +    '("gpointer" "user_data")
 +  )
 +)
 +
 +(define-method create_account_finish
 +  (of-object "EmpathyAccountManager")
 +  (c-name "empathy_account_manager_create_account_finish")
 +  (return-type "EmpathyAccount*")
 +  (parameters
 +    '("GAsyncResult*" "result")
 +    '("GError**" "error")
 +  )
 +)
 +
  
  
  ;; From empathy-chatroom.h
    )
  )
  
- (define-method get_use_nm
-   (of-object "EmpathyIdle")
-   (c-name "empathy_idle_get_use_nm")
-   (return-type "gboolean")
- )
- (define-method set_use_nm
-   (of-object "EmpathyIdle")
-   (c-name "empathy_idle_set_use_nm")
-   (return-type "none")
-   (parameters
-     '("gboolean" "use_nm")
-   )
- )
  
  
  ;; From empathy-irc-network.h
    )
  )
  
 -(define-function account_hash
 -  (c-name "empathy_account_hash")
 -  (return-type "guint")
 -  (parameters
 -    '("gconstpointer" "key")
 -  )
 -)
 -
 -(define-function account_equal
 -  (c-name "empathy_account_equal")
 -  (return-type "gboolean")
 -  (parameters
 -    '("gconstpointer" "a")
 -    '("gconstpointer" "b")
 -  )
 -)
 -
 -(define-function mission_control_dup_singleton
 -  (c-name "empathy_mission_control_dup_singleton")
 -  (return-type "MissionControl*")
 -)
 -
  (define-function presence_get_default_message
    (c-name "empathy_presence_get_default_message")
    (return-type "const-gchar*")
    )
  )
  
 +(define-function protocol_icon_name
 +  (c-name "empathy_protocol_icon_name")
 +  (return-type "gchar*")
 +  (parameters
 +    '("const-gchar*" "protocol")
 +  )
 +)
 +
 +(define-function type_dbus_ao
 +  (c-name "empathy_type_dbus_ao")
 +  (return-type "GType")
 +)
 +
  
index 5b23def9a0bbf00c51497da865bdc946096e0e47,d4601b211540abc7e1d308187a6439508bd11e3a..51d32709e9fdaa53800525b067e2ecf3baeb2648
    (gtype-id "EMPATHY_TYPE_PRESENCE_CHOOSER")
  )
  
 -(define-object ProfileChooser
 +(define-object ProtocolChooser
    (in-module "Empathy")
    (parent "GtkComboBox")
 -  (c-name "EmpathyProfileChooser")
 -  (gtype-id "EMPATHY_TYPE_PROFILE_CHOOSER")
 +  (c-name "EmpathyProtocolChooser")
 +  (gtype-id "EMPATHY_TYPE_PROTOCOL_CHOOSER")
  )
  
  (define-object SmileyManager
  
  ;; From empathy-account-widget.h
  
 -(define-method widget_handle_params
 -  (of-object "EmpathyAccount")
 +(define-function account_widget_handle_params
    (c-name "empathy_account_widget_handle_params")
    (return-type "none")
    (parameters
 +    '("EmpathyAccountSettings*" "settings")
      '("GtkBuilder*" "gui")
      '("const-gchar*" "first_widget")
    )
    (varargs #t)
  )
  
 -(define-method widget_add_forget_button
 -  (of-object "EmpathyAccount")
 +(define-function account_widget_add_forget_button
    (c-name "empathy_account_widget_add_forget_button")
    (return-type "none")
    (parameters
 +    '("EmpathyAccountSettings*" "settings")
      '("GtkBuilder*" "gui")
      '("const-gchar*" "button")
      '("const-gchar*" "entry")
    )
  )
  
 +(define-function account_widget_add_apply_button
 +  (c-name "empathy_account_widget_add_apply_button")
 +  (return-type "none")
 +  (parameters
 +    '("EmpathyAccountSettings*" "settings")
 +    '("GtkWidget*" "vbox")
 +  )
 +)
 +
  (define-function account_widget_set_default_focus
    (c-name "empathy_account_widget_set_default_focus")
    (return-type "none")
    )
  )
  
 -(define-method widget_generic_new
 -  (of-object "EmpathyAccount")
 +(define-function account_widget_generic_new
    (c-name "empathy_account_widget_generic_new")
 +  (is-constructor-of "EmpathyAccountWidgetGeneric")
    (return-type "GtkWidget*")
 +  (parameters
 +    '("EmpathyAccountSettings*" "settings")
 +  )
  )
  
 -(define-method widget_salut_new
 -  (of-object "EmpathyAccount")
 +(define-function account_widget_salut_new
    (c-name "empathy_account_widget_salut_new")
 +  (is-constructor-of "EmpathyAccountWidgetSalut")
    (return-type "GtkWidget*")
 +  (parameters
 +    '("EmpathyAccountSettings*" "settings")
 +  )
  )
  
 -(define-method widget_msn_new
 -  (of-object "EmpathyAccount")
 +(define-function account_widget_msn_new
    (c-name "empathy_account_widget_msn_new")
 +  (is-constructor-of "EmpathyAccountWidgetMsn")
    (return-type "GtkWidget*")
 +  (parameters
 +    '("EmpathyAccountSettings*" "settings")
 +  )
  )
  
 -(define-method widget_jabber_new
 -  (of-object "EmpathyAccount")
 +(define-function account_widget_jabber_new
    (c-name "empathy_account_widget_jabber_new")
 +  (is-constructor-of "EmpathyAccountWidgetJabber")
    (return-type "GtkWidget*")
 +  (parameters
 +    '("EmpathyAccountSettings*" "settings")
 +  )
  )
  
 -(define-method widget_icq_new
 -  (of-object "EmpathyAccount")
 +(define-function account_widget_icq_new
    (c-name "empathy_account_widget_icq_new")
 +  (is-constructor-of "EmpathyAccountWidgetIcq")
    (return-type "GtkWidget*")
 +  (parameters
 +    '("EmpathyAccountSettings*" "settings")
 +  )
  )
  
 -(define-method widget_aim_new
 -  (of-object "EmpathyAccount")
 +(define-function account_widget_aim_new
    (c-name "empathy_account_widget_aim_new")
 +  (is-constructor-of "EmpathyAccountWidgetAim")
    (return-type "GtkWidget*")
 +  (parameters
 +    '("EmpathyAccountSettings*" "settings")
 +  )
  )
  
 -(define-method widget_yahoo_new
 -  (of-object "EmpathyAccount")
 +(define-function account_widget_yahoo_new
    (c-name "empathy_account_widget_yahoo_new")
 +  (is-constructor-of "EmpathyAccountWidgetYahoo")
    (return-type "GtkWidget*")
 +  (parameters
 +    '("EmpathyAccountSettings*" "settings")
 +  )
  )
  
 -(define-method widget_groupwise_new
 -  (of-object "EmpathyAccount")
 +(define-function account_widget_groupwise_new
    (c-name "empathy_account_widget_groupwise_new")
 +  (is-constructor-of "EmpathyAccountWidgetGroupwise")
    (return-type "GtkWidget*")
 +  (parameters
 +    '("EmpathyAccountSettings*" "settings")
 +  )
  )
  
  
  
  ;; From empathy-account-widget-irc.h
  
 -(define-method widget_irc_new
 -  (of-object "EmpathyAccount")
 +(define-function account_widget_irc_new
    (c-name "empathy_account_widget_irc_new")
 +  (is-constructor-of "EmpathyAccountWidgetIrc")
    (return-type "GtkWidget*")
 +  (parameters
 +    '("EmpathyAccountSettings*" "settings")
 +  )
  )
  
  
  
  ;; From empathy-account-widget-sip.h
  
 -(define-method widget_sip_new
 -  (of-object "EmpathyAccount")
 +(define-function account_widget_sip_new
    (c-name "empathy_account_widget_sip_new")
 +  (is-constructor-of "EmpathyAccountWidgetSip")
    (return-type "GtkWidget*")
 +  (parameters
 +    '("EmpathyAccountSettings*" "settings")
 +  )
  )
  
  
  
  
  
 -;; From empathy-profile-chooser.h
 +;; From empathy-protocol-chooser.h
  
 -(define-function profile_chooser_get_type
 -  (c-name "empathy_profile_chooser_get_type")
 +(define-function protocol_chooser_get_type
 +  (c-name "empathy_protocol_chooser_get_type")
    (return-type "GType")
  )
  
 -(define-function profile_chooser_new
 -  (c-name "empathy_profile_chooser_new")
 -  (is-constructor-of "EmpathyProfileChooser")
 +(define-function protocol_chooser_new
 +  (c-name "empathy_protocol_chooser_new")
 +  (is-constructor-of "EmpathyProtocolChooser")
    (return-type "GtkWidget*")
  )
  
  (define-method dup_selected
 -  (of-object "EmpathyProfileChooser")
 -  (c-name "empathy_profile_chooser_dup_selected")
 -  (return-type "McProfile*")
 +  (of-object "EmpathyProtocolChooser")
 +  (c-name "empathy_protocol_chooser_dup_selected")
 +  (return-type "TpConnectionManager*")
 +  (parameters
 +    '("TpConnectionManagerProtocol**" "protocol")
 +  )
  )
  
 -(define-method n_profiles
 -  (of-object "EmpathyProfileChooser")
 -  (c-name "empathy_profile_chooser_n_profiles")
 +(define-method n_protocols
 +  (of-object "EmpathyProtocolChooser")
 +  (c-name "empathy_protocol_chooser_n_protocols")
    (return-type "gint")
  )
  
    )
  )
  
 -(define-function icon_name_from_account
 -  (c-name "empathy_icon_name_from_account")
 -  (return-type "const-gchar*")
 -  (parameters
 -    '("EmpathyAccount*" "account")
 -  )
 -)
 -
  (define-function icon_name_for_presence
    (c-name "empathy_icon_name_for_presence")
    (return-type "const-gchar*")
    )
  )
  
+ (define-function make_absolute_url
+   (c-name "empathy_make_absolute_url")
+   (return-type "gchar*")
+   (parameters
+     '("const-gchar*" "url")
+   )
+ )
  
index 822f228268820fa7d3be7ced6500fc4ff1cb77c9,fb5a5c796f6c3495b3f0061e96d2f0284fce6892..5f81ac167b5aade48d4183c40a141192f6ae61e8
@@@ -35,6 -35,7 +35,6 @@@
  #include <libnotify/notification.h>
  
  #include <telepathy-glib/util.h>
 -#include <libmissioncontrol/mission-control.h>
  
  #include <libempathy/empathy-contact.h>
  #include <libempathy/empathy-message.h>
@@@ -850,7 -851,7 +850,7 @@@ chat_window_help_contents_activate_cb (
  {
        EmpathyChatWindowPriv *priv = GET_PRIV (window);
  
-       empathy_url_show (priv->dialog, "ghelp:empathy?chat");
+       empathy_url_show (priv->dialog, "ghelp:empathy");
  }
  
  static void
@@@ -945,7 -946,6 +945,6 @@@ chat_window_show_or_update_notificatio
        char *escaped;
        const char *body;
        GdkPixbuf *pixbuf;
-       NotificationData *cb_data;
        EmpathyChatWindowPriv *priv = GET_PRIV (window);
        gboolean res;
  
                }
        }
  
-       cb_data = g_slice_new0 (NotificationData);
-       cb_data->chat = g_object_ref (chat);
-       cb_data->window = window;
        sender = empathy_message_get_sender (message);
        header = empathy_contact_get_name (sender);
        body = empathy_message_get_body (message);
        escaped = g_markup_escape_text (body, -1);
  
-       pixbuf = empathy_misc_get_pixbuf_for_notification (sender, EMPATHY_IMAGE_NEW_MESSAGE);
        if (priv->notification != NULL) {
                notify_notification_update (priv->notification,
                                            header, escaped, NULL);
-               /* if icon doesn't exist libnotify will crash */
-               if (pixbuf != NULL)
-                       notify_notification_set_icon_from_pixbuf (priv->notification, pixbuf);
        } else {
+               NotificationData *cb_data = cb_data = g_slice_new0 (NotificationData);
+               cb_data->chat = g_object_ref (chat);
+               cb_data->window = window;
                priv->notification = notify_notification_new (header, escaped, NULL, NULL);
                notify_notification_set_timeout (priv->notification, NOTIFY_EXPIRES_DEFAULT);
-               /* if icon doesn't exist libnotify will crash */
-               if (pixbuf != NULL)
-                       notify_notification_set_icon_from_pixbuf (priv->notification, pixbuf);
  
                g_signal_connect (priv->notification, "closed",
                                  G_CALLBACK (chat_window_notification_closed_cb), cb_data);
        }
  
+       pixbuf = empathy_misc_get_pixbuf_for_notification (sender, EMPATHY_IMAGE_NEW_MESSAGE);
+       if (pixbuf != NULL) {
+               notify_notification_set_icon_from_pixbuf (priv->notification, pixbuf);
+               g_object_unref (pixbuf);
+       }
        notify_notification_show (priv->notification, NULL);
  
-       g_object_unref (pixbuf);
        g_free (escaped);
  }
  
@@@ -1002,7 -1001,8 +1000,8 @@@ chat_window_set_highlight_room_tab_labe
        if (!empathy_chat_is_room (chat))
                return;
  
-       markup = g_markup_printf_escaped ("<span color=\"red\">%s</span>",
+       markup = g_markup_printf_escaped (
+               "<span color=\"red\" weight=\"bold\">%s</span>",
                empathy_chat_get_name (chat));
  
        widget = g_object_get_data (G_OBJECT (chat), "chat-window-tab-label");
@@@ -1268,7 -1268,7 +1267,7 @@@ chat_window_drag_data_received (GtkWidg
                strv = g_strsplit (id, "/", 2);
                account_id = strv[0];
                contact_id = strv[1];
 -              account = empathy_account_manager_lookup (account_manager, account_id);
 +              account = empathy_account_manager_get_account (account_manager, account_id);
                chat = empathy_chat_window_find_chat (account, contact_id);
  
                if (!chat) {
                                        connection, contact_id, NULL, NULL);
                        }
  
 -                      g_object_unref (account);
                        g_strfreev (strv);
                        return;
                }
 -              g_object_unref (account);
                g_object_unref (account_manager);
                g_strfreev (strv);
  
@@@ -1775,7 -1777,7 +1774,7 @@@ empathy_chat_window_find_chat (EmpathyA
  
                        chat = ll->data;
  
 -                      if (empathy_account_equal (account, empathy_chat_get_account (chat)) &&
 +                      if (account == empathy_chat_get_account (chat) &&
                            !tp_strdiff (id, empathy_chat_get_id (chat))) {
                                return chat;
                        }
index aca2d85c2924fa08aec368f12a7f8397f519079d,bbb97f410264615d2c52da98370f63fdd3c7c81e..430c9334393778c00d2f4538ed8736f97b264ca1
@@@ -23,6 -23,8 +23,8 @@@
  
  #include <string.h>
  
+ #include <glib.h>
  #include <gtk/gtk.h>
  #include <gdk/gdkkeysyms.h>
  
@@@ -136,30 -138,37 +138,37 @@@ status_icon_update_notification (Empath
        }
  
        if (priv->event) {
-               pixbuf = empathy_misc_get_pixbuf_for_notification (priv->event->contact,
-                                                                  priv->event->icon_name);
+               gchar *message_esc = NULL;
+               if (priv->event->message != NULL)
+                       message_esc = g_markup_escape_text (priv->event->message, -1);
  
                if (priv->notification) {
                        notify_notification_update (priv->notification,
-                                                   priv->event->header, priv->event->message,
+                                                   priv->event->header, message_esc,
                                                    NULL);
                } else {
                        priv->notification = notify_notification_new_with_status_icon
-                               (priv->event->header, priv->event->message, NULL, priv->icon);
+                               (priv->event->header, message_esc, NULL, priv->icon);
                        notify_notification_set_timeout (priv->notification,
                                                         NOTIFY_EXPIRES_DEFAULT);
  
                        g_signal_connect (priv->notification, "closed",
                                          G_CALLBACK (status_icon_notification_closed_cb), icon);
+               }
  
-               }
-               /* if icon doesn't exist libnotify will crash */
-               if (pixbuf != NULL)
+               pixbuf = empathy_misc_get_pixbuf_for_notification (priv->event->contact,
+                                                                  priv->event->icon_name);
+               if (pixbuf != NULL) {
                        notify_notification_set_icon_from_pixbuf (priv->notification,
                                                          pixbuf);
+                       g_object_unref (pixbuf);
+               }
                notify_notification_show (priv->notification, NULL);
  
-               g_object_unref (pixbuf);
+               g_free (message_esc);
        } else {
                notification_close_helper (priv);
        }
@@@ -173,12 -182,12 +182,12 @@@ status_icon_update_tooltip (EmpathyStat
  
        if (priv->event) {
                if (priv->event->message != NULL)
-                               tooltip = g_strdup_printf ("<i>%s</i>\n%s",
-                                                          priv->event->header,
-                                                          priv->event->message);
+                               tooltip = g_markup_printf_escaped ("<i>%s</i>\n%s",
+                                                                  priv->event->header,
+                                                                  priv->event->message);
                else
-                               tooltip = g_strdup_printf ("<i>%s</i>",
-                                                          priv->event->header);
+                               tooltip = g_markup_printf_escaped ("<i>%s</i>",
+                                                                  priv->event->header);
                gtk_status_icon_set_tooltip_markup (priv->icon, tooltip);
        } else {
                tooltip = g_strdup (empathy_idle_get_status (priv->idle));
@@@ -305,7 -314,24 +314,7 @@@ status_icon_set_visibility (EmpathyStat
        if (!visible) {
                empathy_window_iconify (priv->window, priv->icon);
        } else {
 -              GList *accounts;
 -              GList *l;
 -              gboolean one_enabled = FALSE;
 -
                empathy_window_present (GTK_WINDOW (priv->window), TRUE);
 -
 -              /* Show the accounts dialog if there is no enabled accounts */
 -              accounts = empathy_account_manager_dup_accounts (priv->account_manager);
 -              for (l = accounts ; l != NULL ; l = g_list_next (l)) {
 -                      one_enabled = empathy_account_is_enabled (EMPATHY_ACCOUNT (l->data))
 -                              || one_enabled;
 -                      g_object_unref (l->data);
 -              }
 -              g_list_free (accounts);
 -              if (!one_enabled) {
 -                      DEBUG ("No enabled account, Showing account dialog");
 -                      empathy_accounts_dialog_show (GTK_WINDOW (priv->window), NULL);
 -              }
        }
  }
  
diff --combined src/empathy.c
index 3cc494a94480a19cf4f23e5e7464fa1b26127671,660e47cea42d11a7251935e94fe228636cf40338..718fe70bfc7a5324deb5cb53365411d54413b072
  #include <glib/gi18n.h>
  #include <gtk/gtk.h>
  #include <gdk/gdkx.h>
 +#include <unique/unique.h>
  
  #if HAVE_LIBCHAMPLAIN
- #include <clutter-gtk/gtk-clutter-embed.h>
+ #include <clutter-gtk/clutter-gtk.h>
  #endif
  
  #include <libebook/e-book.h>
  
  #include <telepathy-glib/dbus.h>
  #include <telepathy-glib/util.h>
 -#include <libmissioncontrol/mission-control.h>
 +#include <telepathy-glib/connection-manager.h>
 +#include <telepathy-glib/interfaces.h>
  
  #include <libempathy/empathy-idle.h>
  #include <libempathy/empathy-utils.h>
  #include <libempathy/empathy-call-factory.h>
  #include <libempathy/empathy-chatroom-manager.h>
 +#include <libempathy/empathy-account-settings.h>
+ #include <libempathy/empathy-connectivity.h>
  #include <libempathy/empathy-account-manager.h>
 +#include <libempathy/empathy-connection-managers.h>
  #include <libempathy/empathy-debugger.h>
  #include <libempathy/empathy-dispatcher.h>
  #include <libempathy/empathy-dispatch-operation.h>
@@@ -69,6 -66,7 +70,6 @@@
  #include "empathy-call-window.h"
  #include "empathy-chat-window.h"
  #include "empathy-ft-manager.h"
 -#include "bacon-message-connection.h"
  
  #include "extensions/extensions.h"
  
@@@ -77,7 -75,7 +78,7 @@@
  
  #include <gst/gst.h>
  
 -static BaconMessageConnection *connection = NULL;
 +#define COMMAND_ACCOUNTS_DIALOG 1
  
  static void
  dispatch_cb (EmpathyDispatcher *dispatcher,
  
                        manager = empathy_account_manager_dup_singleton ();
                        connection = empathy_tp_chat_get_connection (tp_chat);
 -                      account = empathy_account_manager_get_account (manager,
 +                      account = empathy_account_manager_get_account_for_connection (manager,
                                                                       connection);
                        chat = empathy_chat_window_find_chat (account, id);
                        g_object_unref (manager);
        }
  }
  
--static void
- use_nm_notify_cb (EmpathyConf *conf,
-                 const gchar *key,
-                 gpointer     user_data)
- {
-       EmpathyIdle *idle = user_data;
-       gboolean     use_nm;
-       if (empathy_conf_get_bool (conf, key, &use_nm)) {
-               empathy_idle_set_use_nm (idle, use_nm);
-       }
- }
 -service_ended_cb (MissionControl *mc,
 -                gpointer        user_data)
 +/* Salut account creation */
 +static gboolean
 +should_create_salut_account (void)
  {
 -      DEBUG ("Mission Control stopped");
 +      EmpathyAccountManager *manager;
 +      gboolean salut_created = FALSE;
 +      GList *accounts, *l;
 +
 +      /* Check if we already created a salut account */
 +      empathy_conf_get_bool (empathy_conf_get (),
 +                             EMPATHY_PREFS_SALUT_ACCOUNT_CREATED,
 +                             &salut_created);
 +
 +      if (salut_created)
 +              {
 +                      DEBUG ("Gconf says we already created a salut account once");
 +                      return FALSE;
 +              }
 +
 +      manager = empathy_account_manager_dup_singleton ();
 +      accounts = empathy_account_manager_dup_accounts (manager);
 +
 +      for (l = accounts; l != NULL;  l = g_list_next (l)) {
 +              EmpathyAccount *account = EMPATHY_ACCOUNT (l->data);
 +
 +              if (!tp_strdiff (empathy_account_get_protocol (account), "local-xmpp"))
 +                      salut_created = TRUE;
 +
 +              g_object_unref (account);
 +      }
 +
 +      g_object_unref (manager);
 +
 +      if (salut_created)
 +              {
 +                      DEBUG ("Existing salut account already exists, flagging so in gconf");
 +                      empathy_conf_set_bool (empathy_conf_get (),
 +                              EMPATHY_PREFS_SALUT_ACCOUNT_CREATED,
 +                              TRUE);
 +              }
 +
 +      return !salut_created;
  }
  
  static void
 -operation_error_cb (MissionControl *mc,
 -                  guint           operation_id,
 -                  guint           error_code,
 -                  gpointer        user_data)
 +salut_account_created (GObject *source,
 +      GAsyncResult *result, gpointer user_data)
  {
 -      const gchar *message;
 -
 -      switch (error_code) {
 -      case MC_DISCONNECTED_ERROR:
 -              message = "Disconnected";
 -              break;
 -      case MC_INVALID_HANDLE_ERROR:
 -              message = "Invalid handle";
 -              break;
 -      case MC_NO_MATCHING_CONNECTION_ERROR:
 -              message = "No matching connection";
 -              break;
 -      case MC_INVALID_ACCOUNT_ERROR:
 -              message = "Invalid account";
 -              break;
 -      case MC_PRESENCE_FAILURE_ERROR:
 -              message = "Presence failure";
 -              break;
 -      case MC_NO_ACCOUNTS_ERROR:
 -              message = "No accounts";
 -              break;
 -      case MC_NETWORK_ERROR:
 -              message = "Network error";
 -              break;
 -      case MC_CONTACT_DOES_NOT_SUPPORT_VOICE_ERROR:
 -              message = "Contact does not support voice";
 -              break;
 -      case MC_LOWMEM_ERROR:
 -              message = "Lowmem";
 -              break;
 -      case MC_CHANNEL_REQUEST_GENERIC_ERROR:
 -              message = "Channel request generic error";
 -              break;
 -      case MC_CHANNEL_BANNED_ERROR:
 -              message = "Channel banned";
 -              break;
 -      case MC_CHANNEL_FULL_ERROR:
 -              message = "Channel full";
 -              break;
 -      case MC_CHANNEL_INVITE_ONLY_ERROR:
 -              message = "Channel invite only";
 -              break;
 -      default:
 -              message = "Unknown error code";
 -      }
 +      EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source);
 +      EmpathyAccount *account;
 +      GError *error = NULL;
 +
 +      if (!empathy_account_settings_apply_finish (settings, result, &error))
 +              {
 +                      DEBUG ("Failed to create salut account: %s", error->message);
 +                      g_error_free (error);
 +                      return;
 +              }
 +
 +      account = empathy_account_settings_get_account (settings);
  
 -      DEBUG ("Error during operation %d: %s", operation_id, message);
 +      empathy_account_set_enabled (account, TRUE);
 +      empathy_conf_set_bool (empathy_conf_get (),
 +                             EMPATHY_PREFS_SALUT_ACCOUNT_CREATED,
 +                             TRUE);
  }
  
+ static void
+ use_conn_notify_cb (EmpathyConf *conf,
+                   const gchar *key,
+                   gpointer     user_data)
+ {
+       EmpathyConnectivity *connectivity = user_data;
+       gboolean     use_conn;
+       if (empathy_conf_get_bool (conf, key, &use_conn)) {
+               empathy_connectivity_set_use_conn (connectivity, use_conn);
+       }
+ }
  static void
 -create_salut_account (void)
 +create_salut_account_if_needed (EmpathyConnectionManagers *managers)
  {
 -      McProfile  *profile;
 -      McProtocol *protocol;
 -      gboolean    salut_created = FALSE;
 -      EmpathyAccount  *account;
 -      EmpathyAccountManager *account_manager;
 -      GList      *accounts;
 +      EmpathyAccountSettings  *settings;
 +      TpConnectionManager *manager;
 +      const TpConnectionManagerProtocol *protocol;
        EBook      *book;
        EContact   *contact;
        gchar      *nickname = NULL;
        gchar      *jid = NULL;
        GError     *error = NULL;
  
 -      /* Check if we already created a salut account */
 -      empathy_conf_get_bool (empathy_conf_get (),
 -                             EMPATHY_PREFS_SALUT_ACCOUNT_CREATED,
 -                             &salut_created);
 -      if (salut_created) {
 +
 +      if (!should_create_salut_account ())
                return;
 -      }
  
 -      DEBUG ("Try to add a salut account...");
 +      manager = empathy_connection_managers_get_cm (managers, "salut");
 +      if (manager == NULL)
 +              {
 +                      DEBUG ("Salut not installed, not making a salut account");
 +                      return;
 +              }
  
 -      /* Check if the salut CM is installed */
 -      profile = mc_profile_lookup ("salut");
 -      if (!profile) {
 -              DEBUG ("No salut profile");
 -              return;
 -      }
 -      protocol = mc_profile_get_protocol (profile);
 -      if (!protocol) {
 -              DEBUG ("Salut not installed");
 -              g_object_unref (profile);
 -              return;
 -      }
 -      g_object_unref (protocol);
 +      protocol = tp_connection_manager_get_protocol (manager, "local-xmpp");
 +      if (protocol == NULL)
 +              {
 +                      DEBUG ("Salut doesn't support local-xmpp!!");
 +                      return;
 +              }
 +
 +      DEBUG ("Trying to add a salut account...");
  
        /* Get self EContact from EDS */
        if (!e_book_get_self (&contact, &book, &error)) {
                DEBUG ("Failed to get self econtact: %s",
                        error ? error->message : "No error given");
                g_clear_error (&error);
 -              g_object_unref (profile);
 -              return;
 -      }
 -
 -      empathy_conf_set_bool (empathy_conf_get (),
 -                             EMPATHY_PREFS_SALUT_ACCOUNT_CREATED,
 -                             TRUE);
 -
 -      /* Check if there is already a salut account */
 -      accounts = mc_accounts_list_by_profile (profile);
 -      if (accounts) {
 -              DEBUG ("There is already a salut account");
 -              mc_accounts_list_free (accounts);
 -              g_object_unref (profile);
                return;
        }
  
 -      account_manager = empathy_account_manager_dup_singleton ();
 -      account = empathy_account_manager_create (account_manager, profile);
 -      empathy_account_set_display_name (account, _("People nearby"));
 -      g_object_unref (account_manager);
 +      settings = empathy_account_settings_new ("salut", "local-xmpp",
 +              _("People nearby"));
  
        nickname = e_contact_get (contact, E_CONTACT_NICKNAME);
        first_name = e_contact_get (contact, E_CONTACT_GIVEN_NAME);
                "last-name=%s\nemail=%s\njid=%s\n",
                nickname, first_name, last_name, email, jid);
  
 -      empathy_account_set_param_string (account, "nickname", nickname ? nickname : "");
 -      empathy_account_set_param_string (account, "first-name", first_name ? first_name : "");
 -      empathy_account_set_param_string (account, "last-name", last_name ? last_name : "");
 -      empathy_account_set_param_string (account, "email", email ? email : "");
 -      empathy_account_set_param_string (account, "jid", jid ? jid : "");
 +      empathy_account_settings_set_string (settings, "nickname", nickname ? nickname : "");
 +      empathy_account_settings_set_string (settings, "first-name", first_name ? first_name : "");
 +      empathy_account_settings_set_string (settings, "last-name", last_name ? last_name : "");
 +      empathy_account_settings_set_string (settings, "email", email ? email : "");
 +      empathy_account_settings_set_string (settings, "jid", jid ? jid : "");
 +
 +      empathy_account_settings_apply_async (settings,
 +              salut_account_created, NULL);
  
        g_free (nickname);
        g_free (first_name);
        g_free (last_name);
        g_free (email);
        g_free (jid);
 -      g_object_unref (account);
 -      g_object_unref (profile);
 +      g_object_unref (settings);
        g_object_unref (contact);
        g_object_unref (book);
  }
  
 +static void
 +connection_managers_ready_cb (EmpathyConnectionManagers *managers,
 +      GParamSpec *spec, gpointer user_data)
 +{
 +      if (empathy_connection_managers_is_ready (managers))
 +              {
 +                      create_salut_account_if_needed (managers);
 +                      g_object_unref (managers);
 +                      managers = NULL;
 +              }
 +}
 +
 +static void
 +create_salut_account (void)
 +{
 +      EmpathyConnectionManagers *managers;
 +
 +      if (!should_create_salut_account ())
 +              return;
 +
 +      managers = empathy_connection_managers_dup_singleton ();
 +
 +      if (empathy_connection_managers_is_ready (managers))
 +              {
 +                      create_salut_account_if_needed (managers);
 +                      g_object_unref (managers);
 +              }
 +      else
 +              {
 +                      g_signal_connect (managers, "notify::ready",
 +                              G_CALLBACK (connection_managers_ready_cb), NULL);
 +              }
 +}
 +
  static void
  migrate_config_to_xdg_dir (void)
  {
        g_free (old_dir);
  }
  
 -/* The code that handles single-instance and startup notification is
 - * copied from gedit.
 - *
 - * Copyright (C) 2005 - Paolo Maggi
 - */
 -static void
 -on_bacon_message_received (const char *message,
 -                         gpointer    data)
 +static UniqueResponse
 +unique_app_message_cb (UniqueApp *unique_app,
 +                       gint command,
 +                       UniqueMessageData *data,
 +                       guint timestamp,
 +                       gpointer user_data)
  {
 -      GtkWidget *window = data;
 -      guint32    startup_timestamp;
 -
 -      g_return_if_fail (message != NULL);
 +      GtkWidget *window = user_data;
  
 -      DEBUG ("Other instance launched, presenting the main window. message='%s'",
 -              message);
 +      DEBUG ("Other instance launched, presenting the main window. "
 +             "Command=%d, timestamp %u", command, timestamp);
  
 -      if (strcmp (message, "accounts") == 0) {
 -              /* accounts dialog requested */
 +      if (command == COMMAND_ACCOUNTS_DIALOG) {
                empathy_accounts_dialog_show (GTK_WINDOW (window), NULL);
        } else {
 -              startup_timestamp = atoi (message);
 -
 -              /* Set the proper interaction time on the window.
 -               * Fall back to roundtripping to the X server when we
 -               * don't have the timestamp, e.g. when launched from
 -               * terminal. We also need to make sure that the window
 -               * has been realized otherwise it will not work. lame. */
 -              if (startup_timestamp == 0) {
 -                      /* Work if launched from the terminal */
 -                      DEBUG ("Using X server timestamp as a fallback");
 -
 -                      if (!GTK_WIDGET_REALIZED (window)) {
 -                              gtk_widget_realize (GTK_WIDGET (window));
 -                      }
 -
 -                      startup_timestamp = gdk_x11_get_server_time (gtk_widget_get_window (window));
 -              }
 -
 -              gtk_window_present_with_time (GTK_WINDOW (window), startup_timestamp);
 -      }
 -}
 -
 -static guint32
 -get_startup_timestamp ()
 -{
 -      const gchar *startup_id_env;
 -      gchar       *startup_id = NULL;
 -      gchar       *time_str;
 -      gchar       *end;
 -      gulong       retval = 0;
 -
 -      /* we don't unset the env, since startup-notification
 -       * may still need it */
 -      startup_id_env = g_getenv ("DESKTOP_STARTUP_ID");
 -      if (startup_id_env == NULL) {
 -              goto out;
 +              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);
        }
  
 -      startup_id = g_strdup (startup_id_env);
 -
 -      time_str = g_strrstr (startup_id, "_TIME");
 -      if (time_str == NULL) {
 -              goto out;
 -      }
 -
 -      errno = 0;
 -
 -      /* Skip past the "_TIME" part */
 -      time_str += 5;
 -
 -      retval = strtoul (time_str, &end, 0);
 -      if (end == time_str || errno != 0)
 -              retval = 0;
 -
 - out:
 -      g_free (startup_id);
 -
 -      return (retval > 0) ? retval : 0;
 +      return UNIQUE_RESPONSE_OK;
  }
  
  static gboolean
@@@ -504,44 -540,29 +505,45 @@@ default_log_handler (const gchar *log_d
  }
  #endif /* ENABLE_DEBUG */
  
 +static void
 +account_manager_ready_cb (EmpathyAccountManager *manager,
 +      GParamSpec *spec,
 +      gpointer user_data)
 +{
 +      if (!empathy_account_manager_is_ready (manager))
 +              return;
 +
 +      if (empathy_account_manager_get_count (manager) == 0)
 +              {
 +                      empathy_accounts_dialog_show (GTK_WINDOW (empathy_main_window_get ()),
 +                              NULL);
 +              }
 +      create_salut_account ();
 +}
 +
  int
  main (int argc, char *argv[])
  {
 -      guint32            startup_timestamp;
  #if HAVE_GEOCLUE
        EmpathyLocationManager *location_manager = NULL;
  #endif
        EmpathyStatusIcon *icon;
        EmpathyDispatcher *dispatcher;
 +      EmpathyAccountManager *account_manager;
        EmpathyLogManager *log_manager;
        EmpathyChatroomManager *chatroom_manager;
        EmpathyCallFactory *call_factory;
        EmpathyFTFactory  *ft_factory;
        GtkWidget         *window;
 -      MissionControl    *mc;
        EmpathyIdle       *idle;
+       EmpathyConnectivity *connectivity;
        gboolean           autoconnect = TRUE;
        gboolean           no_connect = FALSE;
        gboolean           hide_contact_list = FALSE;
        gboolean           accounts_dialog = FALSE;
        GError            *error = NULL;
        TpDBusDaemon      *dbus_daemon;
 +      UniqueApp         *unique_app;
        GOptionEntry       options[] = {
                { "no-connect", 'n',
                  0, G_OPTION_ARG_NONE, &no_connect,
        g_log_set_default_handler (default_log_handler, NULL);
  #endif
  
 -        /* Setting up the bacon connection */
 -      startup_timestamp = get_startup_timestamp ();
 -      connection = bacon_message_connection_new ("empathy");
 -      if (connection != NULL) {
 -              if (!bacon_message_connection_get_is_server (connection)) {
 -                      gchar *message;
 -
 -                      if (accounts_dialog) {
 -                              DEBUG ("Showing accounts dialog from existing Empathy instance");
 -
 -                              message = g_strdup ("accounts");
 -
 -                      } else {
 -
 -                              DEBUG ("Activating existing instance");
 -
 -                              message = g_strdup_printf ("%" G_GUINT32_FORMAT,
 -                                                         startup_timestamp);
 -                      }
 -
 -                      bacon_message_connection_send (connection, message);
 -
 -                      /* We never popup a window, so tell startup-notification
 -                       * that we are done. */
 -                      gdk_notify_startup_complete ();
 -
 -                      g_free (message);
 -                      bacon_message_connection_free (connection);
 -
 -                      return EXIT_SUCCESS;
 -              }
 -      } else {
 -              g_warning ("Cannot create the 'empathy' bacon connection.");
 +      unique_app = unique_app_new_with_commands ("org.gnome.Empathy",
 +                                                 NULL,
 +                                                 "accounts_dialog",
 +                                                 COMMAND_ACCOUNTS_DIALOG,
 +                                                 NULL);
 +
 +      if (unique_app_is_running (unique_app)) {
 +              unique_app_send_message (unique_app,
 +                                       accounts_dialog ?
 +                                       COMMAND_ACCOUNTS_DIALOG :
 +                                               UNIQUE_ACTIVATE,
 +                                       NULL);
 +              g_object_unref (unique_app);
 +              return EXIT_SUCCESS;
        }
  
        /* Take well-known name */
                g_clear_error (&error);
        }
  
 -      /* Setting up MC */
 -      mc = empathy_mission_control_dup_singleton ();
 -      g_signal_connect (mc, "ServiceEnded",
 -                        G_CALLBACK (service_ended_cb),
 -                        NULL);
 -      g_signal_connect (mc, "Error",
 -                        G_CALLBACK (operation_error_cb),
 -                        NULL);
 -
        if (accounts_dialog) {
                GtkWidget *dialog;
  
        /* Setting up Idle */
        idle = empathy_idle_dup_singleton ();
        empathy_idle_set_auto_away (idle, TRUE);
-       use_nm_notify_cb (empathy_conf_get (), EMPATHY_PREFS_USE_NM, idle);
-       empathy_conf_notify_add (empathy_conf_get (), EMPATHY_PREFS_USE_NM,
-                                use_nm_notify_cb, idle);
+       /* Setting up Connectivity */
+       connectivity = empathy_connectivity_dup_singleton ();
+       use_conn_notify_cb (empathy_conf_get (), EMPATHY_PREFS_USE_CONN,
+                           connectivity);
+       empathy_conf_notify_add (empathy_conf_get (), EMPATHY_PREFS_USE_CONN,
+                                use_conn_notify_cb, connectivity);
  
        /* Autoconnect */
        empathy_conf_get_bool (empathy_conf_get (),
        if (autoconnect && ! no_connect &&
                tp_connection_presence_type_cmp_availability (empathy_idle_get_state
                        (idle), TP_CONNECTION_PRESENCE_TYPE_OFFLINE) <= 0) {
 -              empathy_idle_set_state (idle, MC_PRESENCE_AVAILABLE);
 +              empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_AVAILABLE);
        }
  
 +      /* account management */
 +      account_manager = empathy_account_manager_dup_singleton ();
 +      g_signal_connect (account_manager, "notify::ready",
 +              G_CALLBACK (account_manager_ready_cb), NULL);
  
        migrate_config_to_xdg_dir ();
 -      create_salut_account ();
  
        /* Setting up UI */
        window = empathy_main_window_show ();
        icon = empathy_status_icon_new (GTK_WINDOW (window), hide_contact_list);
  
 -      if (connection) {
 -              /* We se the callback here because we need window */
 -              bacon_message_connection_set_callback (connection,
 -                                                     on_bacon_message_received,
 -                                                     window);
 -      }
 +      g_signal_connect (unique_app, "message-received",
 +                        G_CALLBACK (unique_app_message_cb),
 +                        window);
  
        /* Handle channels */
        dispatcher = empathy_dispatcher_dup_singleton ();
  
        empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_OFFLINE);
  
 -      g_object_unref (mc);
        g_object_unref (idle);
+       g_object_unref (connectivity);
        g_object_unref (icon);
 +      g_object_unref (account_manager);
        g_object_unref (log_manager);
        g_object_unref (dispatcher);
        g_object_unref (chatroom_manager);
        g_object_unref (location_manager);
  #endif
        g_object_unref (ft_factory);
 +      g_object_unref (unique_app);
  
        notify_uninit ();
  
        return EXIT_SUCCESS;
  }
 -