fix #860, add patch from <jeff at ocjtech.us>, add per account options,

(options are in ACE only)
This commit is contained in:
Stefan Bethge 2006-10-21 00:49:30 +00:00
parent 2875fbda4b
commit 0465e3dcdb
5 changed files with 71 additions and 36 deletions

View File

@ -151,6 +151,7 @@ class Config:
'always_english_wikipedia': [opt_bool, False],
'always_english_wiktionary': [opt_bool, True],
'remote_control': [opt_bool, True, _('If checked, Gajim can be controlled remotely using gajim-remote.'), True],
'networkmanager_support': [opt_bool, True, _('If checked, listen for DBus signals from NetworkManager and change the status of your Jabber connections based upon the status of your network connection.'), True],
'chat_state_notifications': [opt_str, 'all'], # 'all', 'composing_only', 'disabled'
'autodetect_browser_mailer': [opt_bool, False, '', True],
'print_ichat_every_foo_minutes': [opt_int, 5, _('When not printing time for every message (print_time==sometimes), print it every x minutes.')],
@ -263,6 +264,7 @@ class Config:
'msgwin-y-position': [opt_int, -1], # Default is to let the wm decide
'msgwin-width': [opt_int, 480],
'msgwin-height': [opt_int, 440],
'listen_to_network_manager' : [opt_bool, True],
'is_zeroconf': [opt_bool, False],
'zeroconf_first_name': [ opt_str, '', '', True ],
'zeroconf_last_name': [ opt_str, '', '', True ],

View File

@ -34,6 +34,37 @@ except ImportError:
print _('D-Bus python bindings are missing in this computer')
print _('D-Bus capabilities of Gajim cannot be used')
class SystemBus:
'''A Singleton for the DBus SystemBus'''
def __init__(self):
self.system_bus = None
def SystemBus(self):
if not supported:
raise exceptions.DbusNotSupported
if not self.present():
raise exceptions.SystemBusNotPresent
return self.system_bus
def bus(self):
return self.SystemBus()
def present(self):
if not supported:
return False
if self.system_bus is None:
try:
self.system_bus = dbus.SystemBus()
except dbus.dbus_bindings.DBusException:
self.system_bus = None
return False
if self.system_bus is None:
return False
return True
system_bus = SystemBus()
class SessionBus:
'''A Singleton for the D-Bus SessionBus'''
def __init__(self):

View File

@ -1430,7 +1430,8 @@ class Interface:
status = gajim.connections[account].status
gajim.connections[account].username = new_name
gajim.connections[account].change_status(status, '')
else:
gajim.connections[account].change_status('offline','')
def read_sleepy(self):
'''Check idle status and change that status if needed'''
@ -1937,6 +1938,12 @@ class Interface:
else:
self.remote_ctrl = None
if gajim.config.get('networkmanager_support'):
try:
import network_manager_listener
except ImportError:
pass
self.show_vcard_when_connect = []
path_to_file = os.path.join(gajim.DATA_DIR, 'pixmaps/gajim.png')

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
## network_manager_listener.py
##
## Copyright (C) 2006 Stefan Bethge <stefan@lanpartei.de>
## Copyright (C) 2006 Jeffrey C. Ollie <jeff at ocjtech.us>
## Copyright (C) 2006 Stefan Bethge <stefan at lanpartei.de>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published
@ -13,22 +13,35 @@
## GNU General Public License for more details.
##
from common import gajim
def device_now_active(self, *args):
for connection in gajim.connections.itervalues():
if gajim.config.get_per('accounts', connection.name, 'listen_to_network_manager'):
connection.change_status('online', '')
def device_no_longer_active(self, *args):
for connection in gajim.connections.itervalues():
if gajim.config.get_per('accounts', connection.name, 'listen_to_network_manager'):
connection.change_status('offline', '')
from common.dbus_support import system_bus
import dbus
import dbus.glib
NM_OBJ_PATH = '/org/freedesktop/NetworkManager'
NM_INTERFACE = 'org.freedesktop.NetworkManager'
NM_SERVICE = 'org.freedesktop.NetworkManager'
bus = system_bus.SystemBus()
class NetworkManagerListener:
def __init__(self, nm_activated_CB, nm_deactivated_CB):
sys_bus = dbus.SystemBus()
proxy_obj = sys_bus.get_object(NM_SERVICE, NM_OBJ_PATH)
self._nm_iface = dbus.Interface(proxy_obj, NM_INTERFACE)
bus.add_signal_receiver(device_no_longer_active,
'DeviceNoLongerActive',
'org.freedesktop.NetworkManager',
'org.freedesktop.NetworkManager',
'/org/freedesktop/NetworkManager')
self._devices = self._nm_iface.getDevices()
bus.add_signal_receiver(device_now_active,
'DeviceNowActive',
'org.freedesktop.NetworkManager',
'org.freedesktop.NetworkManager',
'/org/freedesktop/NetworkManager')
self._nm_iface.connect_to_signal('DeviceNowActive',
nm_activated_CB)
self._nm_iface.connect_to_signal('DeviceNoLongerActive',
nm_deactivated_CB)

View File

@ -48,10 +48,6 @@ from common import dbus_support
if dbus_support.supported:
from music_track_listener import MusicTrackListener
from common import dbus_support
if dbus_support.supported:
from network_manager_listener import NetworkManagerListener
#(icon, name, type, jid, account, editable, second pixbuf)
(
C_IMG, # image to show state (online, new message etc)
@ -3121,8 +3117,9 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
gajim.last_message_time[account][ctrl.get_full_jid()] = 0
win.set_active_tab(fjid, account)
if gajim.connections[account].is_zeroconf and \
gajim.connections[account].status in ('offline', 'invisible'):
gajim.connections[account].status in ('offline', 'invisible')
win.get_control(fjid, account).got_disconnected()
win.window.present()
def on_roster_treeview_row_activated(self, widget, path, col = 0):
@ -4176,18 +4173,3 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
if len(gajim.connections) == 0: # if we have no account
gajim.interface.instances['account_creation_wizard'] = \
config.AccountCreationWizardWindow()
try:
nm_listener = NetworkManagerListener(self.nm_activated_CB,
self.nm_deactivated_CB)
except:
print >> sys.stderr, _('Network Manager support not available')
def nm_activated_CB(self, dev, net):
for acc in gajim.contacts.get_accounts():
gajim.interface.roster.send_status(acc, 'online', '')
def nm_deactivated_CB(self, dev):
for acc in gajim.contacts.get_accounts():
gajim.interface.roster.send_status(acc, 'offline', '')