2006-10-18 00:15:20 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
## network_manager_listener.py
|
2006-10-21 02:49:30 +02:00
|
|
|
## Copyright (C) 2006 Jeffrey C. Ollie <jeff at ocjtech.us>
|
|
|
|
## Copyright (C) 2006 Stefan Bethge <stefan at lanpartei.de>
|
2006-10-18 00:15:20 +02:00
|
|
|
##
|
2007-10-22 13:13:13 +02:00
|
|
|
## This file is part of Gajim.
|
|
|
|
##
|
|
|
|
## Gajim is free software; you can redistribute it and/or modify
|
2006-10-18 00:15:20 +02:00
|
|
|
## it under the terms of the GNU General Public License as published
|
2007-10-22 13:13:13 +02:00
|
|
|
## by the Free Software Foundation; version 3 only.
|
2006-10-18 00:15:20 +02:00
|
|
|
##
|
2007-10-22 13:13:13 +02:00
|
|
|
## Gajim is distributed in the hope that it will be useful,
|
2006-10-18 00:15:20 +02:00
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
## GNU General Public License for more details.
|
|
|
|
##
|
2007-10-22 13:13:13 +02:00
|
|
|
## You should have received a copy of the GNU General Public License
|
|
|
|
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
##
|
2006-10-18 00:15:20 +02:00
|
|
|
|
2007-11-14 20:47:52 +01:00
|
|
|
import sys
|
2006-10-21 02:49:30 +02:00
|
|
|
from common import gajim
|
|
|
|
|
|
|
|
def device_now_active(self, *args):
|
|
|
|
for connection in gajim.connections.itervalues():
|
2006-12-26 15:56:28 +01:00
|
|
|
if gajim.config.get_per('accounts', connection.name,
|
|
|
|
'listen_to_network_manager') and connection.time_to_reconnect:
|
|
|
|
connection._reconnect()
|
2006-10-21 02:49:30 +02:00
|
|
|
|
|
|
|
def device_no_longer_active(self, *args):
|
|
|
|
for connection in gajim.connections.itervalues():
|
2006-12-26 15:56:28 +01:00
|
|
|
if gajim.config.get_per('accounts', connection.name,
|
|
|
|
'listen_to_network_manager') and connection.connected > 1:
|
|
|
|
connection._disconnectedReconnCB()
|
2006-10-21 02:49:30 +02:00
|
|
|
|
2007-06-26 22:59:30 +02:00
|
|
|
supported = False
|
|
|
|
|
2007-11-14 20:47:52 +01:00
|
|
|
if sys.platform == 'darwin':
|
|
|
|
supported = True
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
from common.dbus_support import system_bus
|
|
|
|
|
|
|
|
bus = system_bus.SystemBus()
|
|
|
|
|
|
|
|
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')
|
|
|
|
except:
|
|
|
|
pass
|