[balsa] Use GObject-based nm-glib API
- From: Peter Bloomfield <PeterB src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [balsa] Use GObject-based nm-glib API
- Date: Thu, 14 Jan 2010 20:43:29 +0000 (UTC)
commit 62c8cd84d104b8d25e370f6a9893e4189c116054
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Thu Jan 14 15:42:09 2010 -0500
Use GObject-based nm-glib API
* configure.in: require NetworkManager version 0.7.
* src/main-window.c: use GObject-based API instead of deprecated
older API.
ChangeLog | 6 ++++++
configure.in | 5 +++--
src/main-window.c | 47 ++++++++++++++++++++++-------------------------
3 files changed, 31 insertions(+), 27 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f4b86d6..13a0566 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-01-14 Peter Bloomfield
+
+ * configure.in: require NetworkManager version 0.7.
+ * src/main-window.c: use GObject-based API instead of deprecated
+ older API.
+
2010-01-12 Pawel Salek
* libbalsa/html.c: fix libbalsa_html_popup_menu_widget() arg list.
diff --git a/configure.in b/configure.in
index 032d875..063e368 100644
--- a/configure.in
+++ b/configure.in
@@ -733,8 +733,8 @@ fi
# NetworkManager
if test "$with_nm" != no ; then
PKG_CHECK_EXISTS([libnm-glib],
- [ PKG_CHECK_MODULES(LIBNM_GLIB, [ libnm-glib ]) ],
- [ PKG_CHECK_MODULES(LIBNM_GLIB, [ libnm_glib ]) ])
+ [ PKG_CHECK_MODULES(LIBNM_GLIB, [ libnm-glib >= 0.7.0]) ],
+ [ PKG_CHECK_MODULES(LIBNM_GLIB, [ libnm_glib >= 0.7.0]) ])
AC_DEFINE(HAVE_LIBNM_GLIB,1,[ Defined if NetworkManager-glib-devel is found.])
BALSA_CFLAGS="$BALSA_CFLAGS $LIBNM_GLIB_CFLAGS"
@@ -905,6 +905,7 @@ if test -d "${srcdir}/.git" ; then
-DGNOME_DISABLE_DEPRECATED_SOURCE \
-DGNOME_VFS_DISABLE_DEPRECATED \
-DGTK_DISABLE_DEPRECATED \
+-DNM_DISABLE_DEPRECATED \
-DPANGO_DISABLE_DEPRECATED \
-D_FORTIFY_SOURCE=2 \
"
diff --git a/src/main-window.c b/src/main-window.c
index 46df573..bb2fa0a 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -47,7 +47,7 @@
#endif
#if defined(HAVE_LIBNM_GLIB)
-#include <libnm_glib.h>
+#include <nm-client.h>
#endif
#include "ab-window.h"
@@ -121,7 +121,9 @@ static void bw_check_messages_thread(struct check_messages_thread_info
static void bw_display_new_mail_notification(int num_new, int has_new);
#if defined(HAVE_LIBNM_GLIB)
-static void mw_change_connection_status(libnm_glib_ctx *ctx, gpointer data);
+static void bw_nm_client_state_changed_cb(GObject * gobject,
+ GParamSpec * pspec,
+ gpointer data);
#endif
static void balsa_window_class_init(BalsaWindowClass * klass);
@@ -998,17 +1000,12 @@ static void
balsa_window_init(BalsaWindow * window)
{
#if defined(HAVE_LIBNM_GLIB)
- libnm_glib_ctx *ctx;
- guint id;
-
- ctx = libnm_glib_init ();
- if (!ctx) {
- fprintf (stderr, "Could not initialize libnm.\n");
- return;
- }
-
- id = libnm_glib_register_callback(ctx, mw_change_connection_status,
- window, NULL);
+ NMClient *client = nm_client_new();
+ if (client)
+ g_signal_connect(client, "notify::state",
+ G_CALLBACK(bw_nm_client_state_changed_cb), NULL);
+ else
+ fprintf (stderr, "Could not get NetworkManager client.\n");
#endif /* LIBNM_GLIB */
}
@@ -3477,29 +3474,29 @@ bw_change_connection_status_thread(void *arg)
/** Responds to NetworkManager events and creates, alternatively
forcefully destroys the IMAP connections. */
static void
-mw_change_connection_status(libnm_glib_ctx *ctx, gpointer data)
+bw_nm_client_state_changed_cb(GObject * gobject, GParamSpec * pspec,
+ gpointer data)
{
+ NMClient *client = NM_CLIENT(gobject);
+ NMState state = nm_client_get_state(client);
gboolean is_connected;
- libnm_glib_state state = libnm_glib_get_network_state (ctx);
switch (state) {
- case LIBNM_NO_DBUS:
- fprintf(stderr, "Status: No DBUS\n");
- return;
- case LIBNM_NO_NETWORKMANAGER:
- fprintf(stderr, "Status: No NetworkManager\n");
+ case NM_STATE_ASLEEP:
+ fprintf(stderr, "Status: Asleep\n");
return;
- case LIBNM_NO_NETWORK_CONNECTION:
+ case NM_STATE_DISCONNECTED:
fprintf (stderr, "Status: Inactive Connection\n");
is_connected = FALSE;
break;
- case LIBNM_ACTIVE_NETWORK_CONNECTION:
+ case NM_STATE_CONNECTING:
+ fprintf(stderr, "Status: Connecting...\n");
+ return;
+ case NM_STATE_CONNECTED:
fprintf (stderr, "Status: Active Connection\n");
is_connected = TRUE;
break;
- case LIBNM_INVALID_CONTEXT:
- fprintf (stderr, "Status: Error\n");
- return;
+ case NM_STATE_UNKNOWN:
default:
fprintf (stderr, "Status: unknown\n");
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]