[gnome-applets] invest-applet: enabled to use network manager also with spec 0.9 - with 0.8.995, NM uses different v
- From: Enrico Minack <eminack src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-applets] invest-applet: enabled to use network manager also with spec 0.9 - with 0.8.995, NM uses different v
- Date: Sun, 17 Apr 2011 16:49:18 +0000 (UTC)
commit c6bcd368e2356e9cd01e28032b01059bd23771ae
Author: Enrico Minack <enrico-minack gmx de>
Date: Sun Apr 17 18:45:28 2011 +0200
invest-applet: enabled to use network manager also with spec 0.9
- with 0.8.995, NM uses different values for states, see bug 647965
configure.in | 3 +++
invest-applet/invest/defs.py.in | 1 +
invest-applet/invest/networkmanager.py | 24 +++++++++++++++++++++++-
3 files changed, 27 insertions(+), 1 deletions(-)
---
diff --git a/configure.in b/configure.in
index dae8381..6618796 100644
--- a/configure.in
+++ b/configure.in
@@ -267,14 +267,17 @@ AC_ARG_ENABLE([networkmanager],
ENABLE_NETWORKMANAGER=$enableval, ENABLE_NETWORKMANAGER=yes)
HAVE_NETWORKMANAGER=no
+NETWORKMANAGER_VERSION=unkown
if test "x$ENABLE_NETWORKMANAGER" = "xyes"; then
PKG_CHECK_MODULES(NETWORKMANAGER, NetworkManager >= $NETWORKMANAGER_REQUIRED,
HAVE_NETWORKMANAGER=yes, HAVE_NETWORKMANAGER=no)
if test "x$HAVE_NETWORKMANAGER" = "xyes"; then
AC_DEFINE(HAVE_NETWORKMANAGER, 1, [NetworkManager available])
+ NETWORKMANAGER_VERSION=`$PKG_CONFIG --modversion NetworkManager`
AC_SUBST(NETWORKMANAGER_CFLAGS)
AC_SUBST(NETWORKMANAGER_LIBS)
+ AC_SUBST(NETWORKMANAGER_VERSION)
fi
fi
diff --git a/invest-applet/invest/defs.py.in b/invest-applet/invest/defs.py.in
index cf410e9..6bca4c7 100644
--- a/invest-applet/invest/defs.py.in
+++ b/invest-applet/invest/defs.py.in
@@ -6,3 +6,4 @@ PYTHONDIR = "@PYTHONDIR@"
GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@"
GNOMELOCALEDIR = "@GNOMELOCALEDIR@"
BUILDERDIR = "@BUILDERDIR@"
+NETWORKMANAGER_VERSION = "@NETWORKMANAGER_VERSION@"
diff --git a/invest-applet/invest/networkmanager.py b/invest-applet/invest/networkmanager.py
index 00863ad..58a52b2 100644
--- a/invest-applet/invest/networkmanager.py
+++ b/invest-applet/invest/networkmanager.py
@@ -1,14 +1,36 @@
import invest
+from invest.defs import NETWORKMANAGER_VERSION
from dbus.mainloop.glib import DBusGMainLoop
import dbus
-# possible states, see http://projects.gnome.org/NetworkManager/developers/spec-08.html#type-NM_STATE
+# possible states, see http://projects.gnome.org/NetworkManager/developers/ -> spec 0.8 -> NM_STATE
STATE_UNKNOWN = dbus.UInt32(0)
STATE_ASLEEP = dbus.UInt32(1)
STATE_CONNECTING = dbus.UInt32(2)
STATE_CONNECTED = dbus.UInt32(3)
STATE_DISCONNEDTED = dbus.UInt32(4)
+# numerical values of these states depend on the network manager version, they changed with 0.8.995
+fields = NETWORKMANAGER_VERSION.split('.')
+if len(fields) >= 2:
+ major = int(fields[0])
+ minor = int(fields[1])
+ if len(fields) > 2:
+ micro = int(fields[2])
+
+ if major > 0 or major == 0 and (minor >= 9 or len(fields) > 2 and minor == 8 and micro >= 995):
+ # see http://projects.gnome.org/NetworkManager/developers/ -> spec 0.9 -> NM_STATE
+ print("Found NetworkManager spec 0.9 (%s)" % NETWORKMANAGER_VERSION)
+ STATE_UNKNOWN = dbus.UInt32(0)
+ STATE_ASLEEP = dbus.UInt32(10)
+ STATE_DISCONNECTED = dbus.UInt32(20)
+ STATE_DISCONNECTING = dbus.UInt32(30)
+ STATE_CONNECTING = dbus.UInt32(40)
+ STATE_CONNECTED_LOCAL = dbus.UInt32(50)
+ STATE_CONNECTED_SITE = dbus.UInt32(60)
+ STATE_CONNECTED_GLOBAL = dbus.UInt32(70)
+ STATE_CONNECTED = STATE_CONNECTED_GLOBAL # backward comparitibility with < 0.9
+
class NetworkManager:
def __init__(self):
self.state = STATE_UNKNOWN
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]