diff --git a/src/common/zeroconf/client_zeroconf.py b/src/common/zeroconf/client_zeroconf.py index d189a7d22..e487ec5e6 100644 --- a/src/common/zeroconf/client_zeroconf.py +++ b/src/common/zeroconf/client_zeroconf.py @@ -1,3 +1,17 @@ +## common/zeroconf/client_zeroconf.py +## +## Copyright (C) 2006 Stefan Bethge +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published +## by the Free Software Foundation; version 2 only. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## + from common.zeroconf import roster_zeroconf diff --git a/src/common/zeroconf/connection_handlers_zeroconf.py b/src/common/zeroconf/connection_handlers_zeroconf.py index d73c385ba..68cc14a41 100644 --- a/src/common/zeroconf/connection_handlers_zeroconf.py +++ b/src/common/zeroconf/connection_handlers_zeroconf.py @@ -6,6 +6,7 @@ ## - Nikos Kouremenos ## - Dimitur Kirov ## - Travis Shirk +## - Stefan Bethge ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published diff --git a/src/common/zeroconf/connection_zeroconf.py b/src/common/zeroconf/connection_zeroconf.py index 827c541cb..561980dda 100644 --- a/src/common/zeroconf/connection_zeroconf.py +++ b/src/common/zeroconf/connection_zeroconf.py @@ -1,19 +1,21 @@ -## common/connection_zeroconf.py +## common/zeroconf/connection_zeroconf.py ## ## Contributors for this file: ## - Yann Le Boulanger ## - Nikos Kouremenos ## - Dimitur Kirov ## - Travis Shirk +## - Stefan Bethge ## ## Copyright (C) 2003-2004 Yann Le Boulanger ## Vincent Hanquez -## Copyright (C) 2005 Yann Le Boulanger +## Copyright (C) 2006 Yann Le Boulanger ## Vincent Hanquez ## Nikos Kouremenos ## Dimitur Kirov ## Travis Shirk ## Norman Rasmussen +## Stefan Bethge ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published @@ -121,14 +123,11 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf): '''always passes account name as first param''' self.put_event((event, data)) - def _reconnect(self): gajim.log.debug('reconnect') signed = self.get_signed_msg(self.status) - - def quit(self, kill_core): if kill_core and self.connected > 1: @@ -172,9 +171,9 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf): # callbacks called from zeroconf def _on_new_service(self,jid): - self.roster.setItem(jid) + self.roster.setItem(jid) display_jid = self.zeroconf.check_jid(jid) - self.dispatch('ROSTER_INFO', (display_jid, display_jid, 'both', 'no', self.roster.getGroups(jid))) + self.dispatch('ROSTER_INFO', (display_jid, self.roster.getName(jid), 'both', 'no', self.roster.getGroups(jid))) self.dispatch('NOTIFY', (display_jid, self.roster.getStatus(jid), self.roster.getMessage(jid), 'local', 0, None, 0)) @@ -198,7 +197,7 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf): #display contacts already detected and resolved for jid in self.roster.keys(): display_jid = self.zeroconf.check_jid(jid) - self.dispatch('ROSTER_INFO', (display_jid, display_jid, 'both', 'no', self.roster.getGroups(jid))) + self.dispatch('ROSTER_INFO', (display_jid, self.roster.getName(jid), 'both', 'no', self.roster.getGroups(jid))) self.dispatch('NOTIFY', (display_jid, self.roster.getStatus(jid), self.roster.getMessage(jid), 'local', 0, None, 0)) self.connected = STATUS_LIST.index(show) diff --git a/src/common/zeroconf/roster_zeroconf.py b/src/common/zeroconf/roster_zeroconf.py index 3a428a38c..1a8a3e351 100644 --- a/src/common/zeroconf/roster_zeroconf.py +++ b/src/common/zeroconf/roster_zeroconf.py @@ -1,3 +1,18 @@ +## common/zeroconf/roster_zeroconf.py +## +## Copyright (C) 2006 Stefan Bethge +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published +## by the Free Software Foundation; version 2 only. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## + + from common.zeroconf import zeroconf class Roster: @@ -36,7 +51,6 @@ class Roster: = self.zeroconf.get_contact(jid) self._data[jid]={} - self._data[jid]['name']=jid[:jid.find('@')] self._data[jid]['ask'] = 'no' #? self._data[jid]['subscription'] = 'both' self._data[jid]['groups'] = [] @@ -49,6 +63,10 @@ class Roster: status = txt_dict['status'] else: status = '' + if txt_dict.has_key('1st') and txt_dict.has_key('last'): + self._data[jid]['name']=txt_dict['1st']+' '+txt_dict['last'] + else: + self._data[jid]['name']=jid if status == 'avail': status = 'online' self._data[jid]['txt_dict'] = txt_dict if not self._data[jid]['txt_dict'].has_key('msg'): @@ -91,7 +109,10 @@ class Roster: def getGroups(self, jid): return self._data[jid]['groups'] - + def getName(self, jid): + if self._data.has_key(jid): + return self._data[jid]['name'] + def getStatus(self, jid): if self._data.has_key(jid): return self._data[jid]['status'] diff --git a/src/common/zeroconf/zeroconf.py b/src/common/zeroconf/zeroconf.py index 6d44bd5ff..ccab0430d 100755 --- a/src/common/zeroconf/zeroconf.py +++ b/src/common/zeroconf/zeroconf.py @@ -1,3 +1,17 @@ +## common/zeroconf/zeroconf.py +## +## Copyright (C) 2006 Stefan Bethge +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published +## by the Free Software Foundation; version 2 only. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## + import os import sys import socket @@ -95,6 +109,8 @@ class Zeroconf: return items def service_resolved_callback(self, interface, protocol, name, stype, domain, host, aprotocol, address, port, txt, flags): + print "Service data for service '%s' in domain '%s' on %i.%i:" % (name, domain, interface, protocol) + print "\tHost %s (%s), port %i, TXT data: %s" % (host, address, port, str(avahi.txt_array_to_string_array(txt))) self.contacts[name] = (name, domain, interface, protocol, host, address, port, txt) self.new_serviceCB(name) @@ -155,7 +171,7 @@ class Zeroconf: self.txt['port.p2pj'] = self.port self.txt['version'] = 1 - self.txt['textvers'] = 1 + self.txt['txtvers'] = 1 # replace gajim's status messages with proper ones if self.txt.has_key('status'):