temporarily replace unicode txt data from local contacts with a dot until we get info from avahi

This commit is contained in:
Stefan Bethge 2006-10-17 19:18:25 +00:00
parent e5806104ce
commit 4aeb92e52f
1 changed files with 15 additions and 9 deletions

View File

@ -116,22 +116,26 @@ class Zeroconf:
for els in txt_array: for els in txt_array:
key, val = '', None key, val = '', None
for c in els: for c in els:
c = chr(c) if c < 0 or c > 255:
if val is None: c = '.'
if c == '=':
val = ''
else: else:
key += c c = chr(c)
else: if val is None:
val += c if c == '=':
val = ''
else:
key += c
else:
val += c
if val is None: # missing '=' if val is None: # missing '='
val = '' val = ''
txt_dict[key] = val.decode('utf-8') txt_dict[key] = val.decode('utf-8')
return txt_dict return txt_dict
def service_resolved_callback(self, interface, protocol, name, stype, domain, host, aprotocol, address, port, txt, flags): def service_resolved_callback(self, interface, protocol, name, stype, domain, host, aprotocol, address, port, txt, flags):
gajim.log.debug('Service data for service %s in domain %s on %i.%i:' % (name, domain, interface, protocol)) gajim.log.debug('Service data for service %s in domain %s on %i.%i:'
gajim.log.debug('Host %s (%s), port %i, TXT data: %s' % (host, address, port, % (name, domain, interface, protocol))
gajim.log.debug('Host %s (%s), port %i, TXT data: %s' % (host, address, port,
self.txt_array_to_dict(txt))) self.txt_array_to_dict(txt)))
if not self.connected: if not self.connected:
return return
@ -393,6 +397,8 @@ class Zeroconf:
reply_handler=self.service_resolved_all_callback, error_handler=self.error_callback) reply_handler=self.service_resolved_all_callback, error_handler=self.error_callback)
def get_contacts(self): def get_contacts(self):
if not jid in self.contacts:
return None
return self.contacts return self.contacts
def get_contact(self, jid): def get_contact(self, jid):