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 @@ def get_config_values_or_default(self): ...@@ -140,13 +140,9 @@ def get_config_values_or_default(self):
self.email = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_email') self.email = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_email')
# END __init__ # 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): def dispatch(self, event, data):
'''always passes account name as first param''' if gajim.handlers.has_key(event):
self.put_event((event, data)) gajim.handlers[event](self.name, data)
def _reconnect(self): def _reconnect(self):
gajim.log.debug('reconnect') gajim.log.debug('reconnect')
......
...@@ -74,18 +74,18 @@ def error_callback(self, err): ...@@ -74,18 +74,18 @@ def error_callback(self, err):
def new_service_callback(self, interface, protocol, name, stype, domain, flags): 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)) gajim.log.debug('Found service %s in domain %s on %i.%i.' % (name, domain, interface, protocol))
if not self.connected: # if not self.connected:
return # return
#synchronous resolving # synchronous resolving
self.server.ResolveService( int(interface), int(protocol), name, stype, \ self.server.ResolveService( int(interface), int(protocol), name, stype, \
domain, avahi.PROTO_UNSPEC, dbus.UInt32(0), \ domain, avahi.PROTO_UNSPEC, dbus.UInt32(0), \
reply_handler=self.service_resolved_callback, error_handler=self.error_callback) reply_handler=self.service_resolved_callback, error_handler=self.error_callback)
def remove_service_callback(self, interface, protocol, name, stype, domain, flags): 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)) gajim.log.debug('Service %s in domain %s on %i.%i disappeared.' % (name, domain, interface, protocol))
#if not self.connected: # if not self.connected:
# return # return
if name != self.name: if name != self.name:
for key in self.contacts.keys(): for key in self.contacts.keys():
if self.contacts[key][C_BARE_NAME] == name: if self.contacts[key][C_BARE_NAME] == name:
...@@ -98,7 +98,6 @@ def new_service_type(self, interface, protocol, stype, domain, flags): ...@@ -98,7 +98,6 @@ def new_service_type(self, interface, protocol, stype, domain, flags):
if self.service_browser: if self.service_browser:
return return
object_path = self.server.ServiceBrowserNew(interface, protocol, \ object_path = self.server.ServiceBrowserNew(interface, protocol, \
stype, domain, dbus.UInt32(0)) stype, domain, dbus.UInt32(0))
......
...@@ -1357,6 +1357,9 @@ def on_save_button_clicked(self, widget): ...@@ -1357,6 +1357,9 @@ def on_save_button_clicked(self, widget):
config['custom_host'] = self.xml.get_widget( config['custom_host'] = self.xml.get_widget(
'custom_host_entry').get_text().decode('utf-8') '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') config['keyname'] = self.xml.get_widget('gpg_name_label').get_text().decode('utf-8')
if config['keyname'] == '': #no key selected if config['keyname'] == '': #no key selected
config['keyid'] = '' config['keyid'] = ''
...@@ -1804,7 +1807,7 @@ def __init__(self): ...@@ -1804,7 +1807,7 @@ def __init__(self):
w.set_active(st) w.set_active(st)
if os.name == 'nt' or (avahi_error and not w.get_active()): if os.name == 'nt' or (avahi_error and not w.get_active()):
w.set_sensitive(False) 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): def on_accounts_window_key_press_event(self, widget, event):
if event.keyval == gtk.keysyms.Escape: if event.keyval == gtk.keysyms.Escape:
...@@ -1845,7 +1848,7 @@ def on_remove_button_clicked(self, widget): ...@@ -1845,7 +1848,7 @@ def on_remove_button_clicked(self, widget):
dialogs.ErrorDialog(_('Unread events'), dialogs.ErrorDialog(_('Unread events'),
_('Read all pending events before removing this account.')) _('Read all pending events before removing this account.'))
return 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 = self.xml.get_widget('enable_zeroconf_checkbutton')
w.set_active(False) w.set_active(False)
else: else:
...@@ -1871,7 +1874,7 @@ def on_accounts_treeview_row_activated(self, widget, path, column): ...@@ -1871,7 +1874,7 @@ def on_accounts_treeview_row_activated(self, widget, path, column):
self.show_modification_window(account) self.show_modification_window(account)
def show_modification_window(self, 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'): if gajim.interface.instances.has_key('zeroconf_properties'):
gajim.interface.instances['zeroconf_properties'].window.present() gajim.interface.instances['zeroconf_properties'].window.present()
else: else:
...@@ -1902,6 +1905,14 @@ def on_merge_checkbutton_toggled(self, widget): ...@@ -1902,6 +1905,14 @@ def on_merge_checkbutton_toggled(self, widget):
def on_enable_zeroconf_checkbutton_toggled(self, widget): 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'): if gajim.config.get('enable_zeroconf'):
#disable #disable
gajim.interface.roster.close_all(gajim.ZEROCONF_ACC_NAME) gajim.interface.roster.close_all(gajim.ZEROCONF_ACC_NAME)
......
...@@ -1888,7 +1888,7 @@ def __init__(self): ...@@ -1888,7 +1888,7 @@ def __init__(self):
if gajim.config.get('enable_zeroconf'): if gajim.config.get('enable_zeroconf'):
gajim.connections[gajim.ZEROCONF_ACC_NAME] = common.zeroconf.connection_zeroconf.ConnectionZeroconf(gajim.ZEROCONF_ACC_NAME) gajim.connections[gajim.ZEROCONF_ACC_NAME] = common.zeroconf.connection_zeroconf.ConnectionZeroconf(gajim.ZEROCONF_ACC_NAME)
for account in gajim.config.get_per('accounts'): 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) gajim.connections[account] = common.connection.Connection(account)
# gtk hooks # gtk hooks
......
...@@ -1369,7 +1369,7 @@ def make_contact_menu(self, event, iter): ...@@ -1369,7 +1369,7 @@ def make_contact_menu(self, event, iter):
if not contact: if not contact:
return 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') xml = gtkgui_helpers.get_glade('zeroconf_contact_context_menu.glade')
zeroconf_contact_context_menu = xml.get_widget('zeroconf_contact_context_menu') zeroconf_contact_context_menu = xml.get_widget('zeroconf_contact_context_menu')
...@@ -3730,7 +3730,7 @@ def drag_data_received_data(self, treeview, context, x, y, selection, info, ...@@ -3730,7 +3730,7 @@ def drag_data_received_data(self, treeview, context, x, y, selection, info,
account_dest, c_dest, path) account_dest, c_dest, path)
return 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 # drop on zeroconf account, no contact adds possible
return return
...@@ -3745,7 +3745,7 @@ def drag_data_received_data(self, treeview, context, x, y, selection, info, ...@@ -3745,7 +3745,7 @@ def drag_data_received_data(self, treeview, context, x, y, selection, info,
return return
if type_dest == 'account' and account_source == account_dest: if type_dest == 'account' and account_source == account_dest:
return return
if account_source == gajim.ZEROCONF_ACC_NAME: if gajim.config.get_per('accounts', account_source, 'is_zeroconf'):
return return
it = iter_source it = iter_source
while model[it][C_TYPE] == 'contact': 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