display full name on roster if available

This commit is contained in:
Stefan Bethge 2006-07-27 20:36:21 +00:00
parent dbbf1b6b77
commit d7719e73b3
5 changed files with 62 additions and 11 deletions

View File

@ -1,3 +1,17 @@
## common/zeroconf/client_zeroconf.py
##
## Copyright (C) 2006 Stefan Bethge <stefan@lanpartei.de>
##
## 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

View File

@ -6,6 +6,7 @@
## - Nikos Kouremenos <nkour@jabber.org>
## - Dimitur Kirov <dkirov@gmail.com>
## - Travis Shirk <travis@pobox.com>
## - Stefan Bethge <stefan@lanpartei.de>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published

View File

@ -1,19 +1,21 @@
## common/connection_zeroconf.py
## common/zeroconf/connection_zeroconf.py
##
## Contributors for this file:
## - Yann Le Boulanger <asterix@lagaule.org>
## - Nikos Kouremenos <nkour@jabber.org>
## - Dimitur Kirov <dkirov@gmail.com>
## - Travis Shirk <travis@pobox.com>
## - Stefan Bethge <stefan@lanpartei.de>
##
## Copyright (C) 2003-2004 Yann Le Boulanger <asterix@lagaule.org>
## Vincent Hanquez <tab@snarc.org>
## Copyright (C) 2005 Yann Le Boulanger <asterix@lagaule.org>
## Copyright (C) 2006 Yann Le Boulanger <asterix@lagaule.org>
## Vincent Hanquez <tab@snarc.org>
## Nikos Kouremenos <nkour@jabber.org>
## Dimitur Kirov <dkirov@gmail.com>
## Travis Shirk <travis@pobox.com>
## Norman Rasmussen <norman@rasmussen.co.za>
## Stefan Bethge <stefan@lanpartei.de>
##
## 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)

View File

@ -1,3 +1,18 @@
## common/zeroconf/roster_zeroconf.py
##
## Copyright (C) 2006 Stefan Bethge <stefan@lanpartei.de>
##
## 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']

View File

@ -1,3 +1,17 @@
## common/zeroconf/zeroconf.py
##
## Copyright (C) 2006 Stefan Bethge <stefan@lanpartei.de>
##
## 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'):