root/branches/gajim_0.11.1/src/network_manager_listener.py

Revision 8695, 1.7 kB (checked in by asterix, 12 months ago)

fix stupid traceback

Line 
1# -*- coding: utf-8 -*-
2##      network_manager_listener.py
3## Copyright (C) 2006 Jeffrey C. Ollie <jeff at ocjtech.us>
4## Copyright (C) 2006 Stefan Bethge <stefan at lanpartei.de>
5##
6## This program is free software; you can redistribute it and/or modify
7## it under the terms of the GNU General Public License as published
8## by the Free Software Foundation; version 2 only.
9##
10## This program is distributed in the hope that it will be useful,
11## but WITHOUT ANY WARRANTY; without even the implied warranty of
12## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13## GNU General Public License for more details.
14##
15
16from common import gajim
17
18def device_now_active(self, *args):
19        for connection in gajim.connections.itervalues():
20                if gajim.config.get_per('accounts', connection.name,
21                'listen_to_network_manager') and connection.time_to_reconnect:
22                        connection._reconnect()
23
24def device_no_longer_active(self, *args):
25        for connection in gajim.connections.itervalues():
26                if gajim.config.get_per('accounts', connection.name,
27                'listen_to_network_manager') and connection.connected > 1:
28                        connection._disconnectedReconnCB()
29
30supported = False
31
32try:
33        from common.dbus_support import system_bus
34
35        bus = system_bus.SystemBus()
36
37        if 'org.freedesktop.NetworkManager' in bus.list_names():
38                supported = True
39                bus.add_signal_receiver(device_no_longer_active,
40                        'DeviceNoLongerActive',
41                        'org.freedesktop.NetworkManager',
42                        'org.freedesktop.NetworkManager',
43                        '/org/freedesktop/NetworkManager')
44
45                bus.add_signal_receiver(device_now_active,
46                        'DeviceNowActive',
47                        'org.freedesktop.NetworkManager',
48                        'org.freedesktop.NetworkManager',
49                        '/org/freedesktop/NetworkManager')
50except:
51        pass
Note: See TracBrowser for help on using the browser.