Author: sb
Date: 2006-09-30 20:23:47 +0200 (Sat, 30 Sep 2006)
New Revision: 7018
Modified:
branches/zeroconf_network/src/common/zeroconf/connection_zeroconf.py
branches/zeroconf_network/src/common/zeroconf/zeroconf.py
branches/zeroconf_network/src/config.py
branches/zeroconf_network/src/gajim.py
branches/zeroconf_network/src/roster_window.py
Log:
proper handling of normal accounts with the name 'Local',
don't use account's name but is_zeroconf flag for checks
Modified: branches/zeroconf_network/src/common/zeroconf/connection_zeroconf.py
===================================================================
--- branches/zeroconf_network/src/common/zeroconf/connection_zeroconf.py 2006-09-30 14:53:05 UTC (rev 7017)
+++ branches/zeroconf_network/src/common/zeroconf/connection_zeroconf.py 2006-09-30 18:23:47 UTC (rev 7018)
@@ -140,13 +140,9 @@
self.email = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_email')
# END __init__
- def put_event(self, ev):
- if gajim.handlers.has_key(ev[0]):
- gajim.handlers[ev[0]](self.name, ev[1])
-
def dispatch(self, event, data):
- '''always passes account name as first param'''
- self.put_event((event, data))
+ if gajim.handlers.has_key(event):
+ gajim.handlers[event](self.name, data)
def _reconnect(self):
gajim.log.debug('reconnect')
Modified: branches/zeroconf_network/src/common/zeroconf/zeroconf.py
===================================================================
--- branches/zeroconf_network/src/common/zeroconf/zeroconf.py 2006-09-30 14:53:05 UTC (rev 7017)
+++ branches/zeroconf_network/src/common/zeroconf/zeroconf.py 2006-09-30 18:23:47 UTC (rev 7018)
@@ -74,18 +74,18 @@
def new_service_callback(self, interface, protocol, name, stype, domain, flags):
gajim.log.debug('Found service %s in domain %s on %i.%i.' % (name, domain, interface, protocol))
- if not self.connected:
- return
+ # if not self.connected:
+ # return
- #synchronous resolving
+ # synchronous resolving
self.server.ResolveService( int(interface), int(protocol), name, stype, \
domain, avahi.PROTO_UNSPEC, dbus.UInt32(0), \
reply_handler=self.service_resolved_callback, error_handler=self.error_callback)
def remove_service_callback(self, interface, protocol, name, stype, domain, flags):
gajim.log.debug('Service %s in domain %s on %i.%i disappeared.' % (name, domain, interface, protocol))
- #if not self.connected:
- # return
+ # if not self.connected:
+ # return
if name != self.name:
for key in self.contacts.keys():
if self.contacts[key][C_BARE_NAME] == name:
@@ -98,7 +98,6 @@
if self.service_browser:
return
-
object_path = self.server.ServiceBrowserNew(interface, protocol, \
stype, domain, dbus.UInt32(0))
Modified: branches/zeroconf_network/src/config.py
===================================================================
--- branches/zeroconf_network/src/config.py 2006-09-30 14:53:05 UTC (rev 7017)
+++ branches/zeroconf_network/src/config.py 2006-09-30 18:23:47 UTC (rev 7018)
@@ -1357,6 +1357,9 @@
config['custom_host'] = self.xml.get_widget(
'custom_host_entry').get_text().decode('utf-8')
+ # update in case the name changed to local accounts name
+ config['is_zeroconf'] = False
+
config['keyname'] = self.xml.get_widget('gpg_name_label').get_text().decode('utf-8')
if config['keyname'] == '': #no key selected
config['keyid'] = ''
@@ -1804,7 +1807,7 @@
w.set_active(st)
if os.name == 'nt' or (avahi_error and not w.get_active()):
w.set_sensitive(False)
- w.connect('toggled', self.on_enable_zeroconf_checkbutton_toggled)
+ self.zeroconf_toggled_id = w.connect('toggled', self.on_enable_zeroconf_checkbutton_toggled)
def on_accounts_window_key_press_event(self, widget, event):
if event.keyval == gtk.keysyms.Escape:
@@ -1845,7 +1848,7 @@
dialogs.ErrorDialog(_('Unread events'),
_('Read all pending events before removing this account.'))
return
- if account == gajim.ZEROCONF_ACC_NAME:
+ if gajim.config.get_per('accounts', account, 'is_zeroconf'):
w = self.xml.get_widget('enable_zeroconf_checkbutton')
w.set_active(False)
else:
@@ -1871,7 +1874,7 @@
self.show_modification_window(account)
def show_modification_window(self, account):
- if account == gajim.ZEROCONF_ACC_NAME:
+ if gajim.config.get_per('accounts', account, 'is_zeroconf'):
if gajim.interface.instances.has_key('zeroconf_properties'):
gajim.interface.instances['zeroconf_properties'].window.present()
else:
@@ -1902,6 +1905,14 @@
def on_enable_zeroconf_checkbutton_toggled(self, widget):
+ # don't do anything if there is an account with the local name but is a normal account
+ if gajim.connections.has_key(gajim.ZEROCONF_ACC_NAME) and not gajim.connections[gajim.ZEROCONF_ACC_NAME].is_zeroconf:
+ gajim.connections[gajim.ZEROCONF_ACC_NAME].dispatch('ERROR', (_('Account Local already exists.'),_('Please rename or remove it before enabling link-local messaging.')))
+ widget.disconnect(self.zeroconf_toggled_id)
+ widget.set_active(False)
+ self.zeroconf_toggled_id = widget.connect('toggled', self.on_enable_zeroconf_checkbutton_toggled)
+ return
+
if gajim.config.get('enable_zeroconf'):
#disable
gajim.interface.roster.close_all(gajim.ZEROCONF_ACC_NAME)
Modified: branches/zeroconf_network/src/gajim.py
===================================================================
--- branches/zeroconf_network/src/gajim.py 2006-09-30 14:53:05 UTC (rev 7017)
+++ branches/zeroconf_network/src/gajim.py 2006-09-30 18:23:47 UTC (rev 7018)
@@ -1888,7 +1888,7 @@
if gajim.config.get('enable_zeroconf'):
gajim.connections[gajim.ZEROCONF_ACC_NAME] = common.zeroconf.connection_zeroconf.ConnectionZeroconf(gajim.ZEROCONF_ACC_NAME)
for account in gajim.config.get_per('accounts'):
- if account != gajim.ZEROCONF_ACC_NAME:
+ if not gajim.config.get_per('accounts', account, 'is_zeroconf'):
gajim.connections[account] = common.connection.Connection(account)
# gtk hooks
Modified: branches/zeroconf_network/src/roster_window.py
===================================================================
--- branches/zeroconf_network/src/roster_window.py 2006-09-30 14:53:05 UTC (rev 7017)
+++ branches/zeroconf_network/src/roster_window.py 2006-09-30 18:23:47 UTC (rev 7018)
@@ -1369,7 +1369,7 @@
if not contact:
return
- if account == gajim.ZEROCONF_ACC_NAME:
+ if gajim.config.get_per('accounts', account, 'is_zeroconf'):
xml = gtkgui_helpers.get_glade('zeroconf_contact_context_menu.glade')
zeroconf_contact_context_menu = xml.get_widget('zeroconf_contact_context_menu')
@@ -3730,7 +3730,7 @@
account_dest, c_dest, path)
return
- if account_dest == gajim.ZEROCONF_ACC_NAME:
+ if gajim.config.get_per('accounts', account_dest, 'is_zeroconf'):
# drop on zeroconf account, no contact adds possible
return
@@ -3745,7 +3745,7 @@
return
if type_dest == 'account' and account_source == account_dest:
return
- if account_source == gajim.ZEROCONF_ACC_NAME:
+ if gajim.config.get_per('accounts', account_source, 'is_zeroconf'):
return
it = iter_source
while model[it][C_TYPE] == 'contact':