From a1bf7363c7cf751bae69cd8d95fcdd132e8a721b Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Tue, 26 Jun 2007 20:59:30 +0000 Subject: [PATCH] better network_manager detection --- src/gajim.py | 5 ++--- src/network_manager_listener.py | 32 ++++++++++++++++---------------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/gajim.py b/src/gajim.py index 380869773..d0fcf0c7b 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -2370,9 +2370,8 @@ class Interface: self.remote_ctrl = None if gajim.config.get('networkmanager_support') and dbus_support.supported: - try: - import network_manager_listener - except: + import network_manager_listener + if not network_manager_listener.supported: print >> sys.stderr, _('Network Manager support not available') self.show_vcard_when_connect = [] diff --git a/src/network_manager_listener.py b/src/network_manager_listener.py index aeeb13a34..00300232a 100644 --- a/src/network_manager_listener.py +++ b/src/network_manager_listener.py @@ -27,23 +27,23 @@ def device_no_longer_active(self, *args): 'listen_to_network_manager') and connection.connected > 1: connection._disconnectedReconnCB() +supported = False -from common.dbus_support import system_bus +try: + from common.dbus_support import system_bus -import dbus -import dbus.glib + bus = system_bus.SystemBus() -bus = system_bus.SystemBus() - -bus.add_signal_receiver(device_no_longer_active, - 'DeviceNoLongerActive', - 'org.freedesktop.NetworkManager', - 'org.freedesktop.NetworkManager', - '/org/freedesktop/NetworkManager') - -bus.add_signal_receiver(device_now_active, - 'DeviceNowActive', - 'org.freedesktop.NetworkManager', - 'org.freedesktop.NetworkManager', - '/org/freedesktop/NetworkManager') + if 'org.freedesktop.NetworkManager' in bus.list_names(): + supported = True + bus.add_signal_receiver(device_no_longer_active, + 'DeviceNoLongerActive', + 'org.freedesktop.NetworkManager', + 'org.freedesktop.NetworkManager', + '/org/freedesktop/NetworkManager') + bus.add_signal_receiver(device_now_active, + 'DeviceNowActive', + 'org.freedesktop.NetworkManager', + 'org.freedesktop.NetworkManager', + '/org/freedesktop/NetworkManager')