Commit 227cdb74 authored by sb's avatar sb

proper handling of normal accounts with the name 'Local',

don't use account's name but is_zeroconf flag for checks
parent 6ec6ec43
......@@ -140,13 +140,9 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
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')
......
......@@ -74,18 +74,18 @@ class Zeroconf:
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 @@ class Zeroconf:
if self.service_browser:
return
object_path = self.server.ServiceBrowserNew(interface, protocol, \
stype, domain, dbus.UInt32(0))
......
......@@ -1357,6 +1357,9 @@ class AccountModificationWindow:
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 @@ class AccountsWindow:
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 @@ class AccountsWindow:
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 @@ class AccountsWindow:
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 @@ class AccountsWindow:
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)
......
......@@ -1888,7 +1888,7 @@ class Interface:
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
......
......@@ -1369,7 +1369,7 @@ class RosterWindow:
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 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
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 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
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':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment