better handling of multiple gajim instances on one machine

This commit is contained in:
Stefan Bethge 2006-09-17 20:54:32 +00:00
parent 25b5b85aaa
commit 5d1410d17a
2 changed files with 25 additions and 12 deletions

View File

@ -179,7 +179,6 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
# 'NOTIFY' (account, (jid, status, status message, resource, priority,
# keyID, timestamp))
self.dispatch('NOTIFY', (jid, 'offline', '', 'local', 0, None, 0))
print 'connection_zeroconf:186'
def connect(self, data = None, show = 'online'):
@ -203,7 +202,7 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
gobject.timeout_add(1000, self._on_resolve_timeout)
else:
pass
# display visual notification that we could not connect to avahi
#TODO: display visual notification that we could not connect to avahi
def connect_and_init(self, show, msg, signed):
self.continue_connect_info = [show, msg, signed]

View File

@ -50,6 +50,8 @@ class Zeroconf:
self.entrygroup = None
self.connected = False
self.announced = False
self.invalid_self_contact = {}
## handlers for dbus callbacks
@ -58,8 +60,6 @@ class Zeroconf:
print "Error:", str(err)
def new_service_callback(self, interface, protocol, name, stype, domain, flags):
# we don't want to see ourselves in the list
if name != self.name:
# print "Found service '%s' in domain '%s' on %i.%i." % (name, domain, interface, protocol)
#synchronous resolving
@ -112,9 +112,18 @@ class Zeroconf:
if name.find('@') == -1:
name = name + '@' + name
# we don't want to see ourselves in the list
if name != self.name:
self.contacts[name] = (name, domain, interface, protocol, host, address, port,
bare_name, txt)
self.new_serviceCB(name)
else:
# remember data
# In case this is not our own record but of another
# gajim instance on the same machine,
# it will be used when we get a new name.
self.invalid_self_contact[name] = (name, domain, interface, protocol, host, address, port, bare_name, txt)
# different handler when resolving all contacts
def service_resolved_all_callback(self, interface, protocol, name, stype, domain, host, aprotocol, address, port, txt, flags):
@ -139,8 +148,13 @@ class Zeroconf:
def service_add_fail_callback(self, err):
print 'Error while adding service:', str(err)
old_name = self.name
self.name = self.server.GetAlternativeServiceName(self.name)
self.create_service()
if self.invalid_self_contact.has_key(old_name):
self.contacts[old_name] = self.invalid_self_contact[old_name]
self.new_serviceCB(old_name)
del self.invalid_self_contact[old_name]
def server_state_changed_callback(self, state, error):
print 'server.state %s' % state