aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac29
-rw-r--r--libempathy/Makefile.am4
-rw-r--r--libempathy/empathy-idle.c81
3 files changed, 65 insertions, 49 deletions
diff --git a/configure.ac b/configure.ac
index df6ec7ec0..0dab5e4fc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,6 +40,7 @@ LIBCHAMPLAIN_GTK_REQUIRED=0.3.3
CLUTTER_GTK_REQUIRED=0.8.2
GEOCLUE_REQUIRED=0.11
WEBKIT_REQUIRED=1.1.7
+NETWORK_MANAGER_REQUIRED=0.7.0
# Use --enable-maintainer-mode to disabled deprecated symbols
GNOME_MAINTAINER_MODE_DEFINES
@@ -156,6 +157,32 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[Gettext package name])
AM_GLIB_GNU_GETTEXT
# -----------------------------------------------------------
+# NM integration
+# -----------------------------------------------------------
+AC_ARG_ENABLE(network-manager,
+ AS_HELP_STRING([--enable-network-manager=@<:@no/yes/auto@:>@],
+ [build with network-manager support]), ,
+ enable_webkit=auto)
+
+if test "x$enable_network_manager" != "xno"; then
+ PKG_CHECK_MODULES(NETWORK_MANAGER,
+ [
+ libnm_glib >= $NETWORK_MANAGER_REQUIRED
+ ], have_nm="yes", have_nm="no")
+
+ if test "x$have_nm" = "xyes"; then
+ AC_DEFINE(HAVE_NM, 1, [Define if you have libnm-glib])
+ fi
+else
+ have_nm=no
+fi
+
+if test "x$enable_network_manager" = "xyes" -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")
+
+# -----------------------------------------------------------
# Webkit
# -----------------------------------------------------------
AC_ARG_ENABLE(webkit,
@@ -179,7 +206,6 @@ fi
if test "x$enable_webkit" = "xyes" -a "x$have_webkit" != "xyes"; then
AC_MSG_ERROR([Couldn't find webkit dependencies.])
fi
-
AM_CONDITIONAL(HAVE_WEBKIT, test "x$have_webkit" = "xyes")
# -----------------------------------------------------------
@@ -453,6 +479,7 @@ Configure summary:
Display maps (libchamplain).: ${have_libchamplain}
Location awareness (Geoclue): ${have_geoclue}
Adium themes (Webkit).......: ${have_webkit}
+ NetworkManager integration..: ${have_nm}
Extras:
Documentation...............: ${enable_gtk_doc}
diff --git a/libempathy/Makefile.am b/libempathy/Makefile.am
index 87b728464..2877dc6ae 100644
--- a/libempathy/Makefile.am
+++ b/libempathy/Makefile.am
@@ -10,6 +10,7 @@ AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"empathy\" \
$(LIBEMPATHY_CFLAGS) \
$(GEOCLUE_CFLAGS) \
+ $(NETWORK_MANAGER_CFLAGS) \
$(WARN_CFLAGS) \
$(DISABLE_DEPRECATED)
@@ -65,7 +66,8 @@ nodist_libempathy_la_SOURCES =\
libempathy_la_LIBADD = \
$(top_builddir)/extensions/libemp-extensions.la \
$(LIBEMPATHY_LIBS) \
- $(GEOCLUE_LIBS)
+ $(GEOCLUE_LIBS) \
+ $(NETWORK_MANAGER_LIBS)
libempathy_la_LDFLAGS = \
-version-info ${LIBEMPATHY_CURRENT}:${LIBEMPATHY_REVISION}:${LIBEMPATHY_AGE} \
diff --git a/libempathy/empathy-idle.c b/libempathy/empathy-idle.c
index 2ed1440fc..78366e021 100644
--- a/libempathy/empathy-idle.c
+++ b/libempathy/empathy-idle.c
@@ -25,6 +25,9 @@
#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>
@@ -43,7 +46,9 @@
typedef struct {
MissionControl *mc;
DBusGProxy *gs_proxy;
- DBusGProxy *nm_proxy;
+#ifdef HAVE_NM
+ NMClient *nm_client;
+#endif
TpConnectionPresenceType state;
gchar *status;
@@ -61,14 +66,6 @@ typedef struct {
} EmpathyIdlePriv;
typedef enum {
- NM_STATE_UNKNOWN,
- NM_STATE_ASLEEP,
- NM_STATE_CONNECTING,
- NM_STATE_CONNECTED,
- NM_STATE_DISCONNECTED
-} NMState;
-
-typedef enum {
SESSION_STATUS_AVAILABLE,
SESSION_STATUS_INVISIBLE,
SESSION_STATUS_BUSY,
@@ -234,14 +231,16 @@ idle_session_status_changed_cb (DBusGProxy *gs_proxy,
priv->is_idle = is_idle;
}
+#ifdef HAVE_NM
static void
-idle_nm_state_change_cb (DBusGProxy *proxy,
- guint state,
- EmpathyIdle *idle)
+idle_nm_state_change_cb (NMClient *client,
+ const GParamSpec *pspec,
+ EmpathyIdle *idle)
{
EmpathyIdlePriv *priv;
gboolean old_nm_connected;
gboolean new_nm_connected;
+ NMState state;
priv = GET_PRIV (idle);
@@ -250,6 +249,7 @@ idle_nm_state_change_cb (DBusGProxy *proxy,
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);
@@ -280,6 +280,7 @@ idle_nm_state_change_cb (DBusGProxy *proxy,
priv->nm_connected = new_nm_connected;
}
+#endif
static void
idle_finalize (GObject *object)
@@ -295,6 +296,12 @@ idle_finalize (GObject *object)
g_object_unref (priv->gs_proxy);
}
+#ifdef HAVE_NM
+ if (priv->nm_client) {
+ g_object_unref (priv->nm_client);
+ }
+#endif
+
idle_ext_away_stop (EMPATHY_IDLE (object));
}
@@ -468,7 +475,6 @@ empathy_idle_get_actual_presence (EmpathyIdle *idle, GError **error)
static void
empathy_idle_init (EmpathyIdle *idle)
{
- DBusGConnection *system_bus;
GError *error = NULL;
EmpathyIdlePriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (idle,
EMPATHY_TYPE_IDLE, EmpathyIdlePriv);
@@ -516,28 +522,18 @@ empathy_idle_init (EmpathyIdle *idle)
DEBUG ("Failed to get gs proxy");
}
-
- system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
- if (!system_bus) {
- DEBUG ("Failed to get system bus: %s",
- error ? error->message : "No error given");
- } else {
- priv->nm_proxy = dbus_g_proxy_new_for_name (system_bus,
- "org.freedesktop.NetworkManager",
- "/org/freedesktop/NetworkManager",
- "org.freedesktop.NetworkManager");
- }
- if (priv->nm_proxy) {
- dbus_g_proxy_add_signal (priv->nm_proxy, "StateChange",
- G_TYPE_UINT, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (priv->nm_proxy, "StateChange",
- G_CALLBACK (idle_nm_state_change_cb),
- idle, NULL);
+#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");
}
priv->nm_connected = TRUE;
+#endif
}
EmpathyIdle *
@@ -722,29 +718,20 @@ empathy_idle_set_use_nm (EmpathyIdle *idle,
{
EmpathyIdlePriv *priv = GET_PRIV (idle);
- if (!priv->nm_proxy || use_nm == priv->use_nm) {
+#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) {
- guint nm_status;
- GError *error = NULL;
-
- dbus_g_proxy_call (priv->nm_proxy, "state",
- &error,
- G_TYPE_INVALID,
- G_TYPE_UINT, &nm_status,
- G_TYPE_INVALID);
-
- if (error) {
- DEBUG ("Couldn't get NM state: %s", error->message);
- g_clear_error (&error);
- nm_status = NM_STATE_ASLEEP;
- }
-
- idle_nm_state_change_cb (priv->nm_proxy, nm_status, idle);
+ 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) {