fix file transfer,

add log messages for zeroconf,
refresh name changes of roster items (on resolve)
This commit is contained in:
Stefan Bethge 2006-09-28 23:38:55 +00:00
parent 341e88864c
commit f787d2c1ad
5 changed files with 17 additions and 27 deletions

View File

@ -53,7 +53,7 @@ class ZeroconfListener(IdleObject):
self._serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self._serv.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
self._serv.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
# will fail when port as busy, or we don't have rights to bind
# will fail when port is busy, or we don't have rights to bind
try:
self._serv.bind(('0.0.0.0', self.port))
except Exception, e:
@ -500,7 +500,6 @@ class ClientZeroconf:
BindPortError(port)
return None
def getRoster(self):
return self.roster.getRoster()

View File

@ -149,7 +149,7 @@ class ConnectionBytestream:
except socket.gaierror:
self.dispatch('ERROR', (_('Wrong host'), _('The host you configured as the ft_override_host_to_send advanced option is not valid, so ignored.')))
ft_override_host_to_send = self.peerhost[0]
listener = gajim.socks5queue.start_listener(self.peerhost[0], port,
listener = gajim.socks5queue.start_listener(port,
sha_str, self._result_socks5_sid, file_props['sid'])
if listener == None:
file_props['error'] = -5

View File

@ -188,11 +188,10 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
self.zeroconf.resolve_all()
diffs = self.roster.getDiffs()
for key in diffs:
print key
print self.roster.getStatus(key)
print self.roster.getMessage(key),
self.roster.setItem(key)
self.dispatch('ROSTER_INFO', (key, self.roster.getName(key), 'both', 'no', self.roster.getGroups(key)))
self.dispatch('NOTIFY', (key, self.roster.getStatus(key), self.roster.getMessage(key), 'local', 0, None, 0))
#XXX open chat windows don't get refreshed (full name), add that
return self.call_resolve_timeout
# callbacks called from zeroconf
@ -243,9 +242,9 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
self.connected = STATUS_LIST.index(show)
# refresh all contacts data every second
# refresh all contacts data every five seconds
self.call_resolve_timeout = True
gobject.timeout_add(10000, self._on_resolve_timeout)
gobject.timeout_add(5000, self._on_resolve_timeout)
else:
self.dispatch('STATUS', 'offline')
self.status = 'offline'
@ -326,8 +325,6 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
(_('Could not change status of account "%s"') % self.name,
_('Please check if avahi-daemon is running.')))
def get_status(self):
return STATUS_LIST[self.connected]
@ -399,7 +396,6 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
else:
kind = 'single_msg_sent'
gajim.logger.write(kind, jid, log_msg)
#~ self.zeroconf.send_message(jid, msgtxt, type)
self.dispatch('MSGSENT', (jid, msg, keyID))

View File

@ -115,13 +115,13 @@ 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):
print 'roster: getStatus: %s' % self._data[jid]['status']
return self._data[jid]['status']
def getMessage(self, jid):

View File

@ -21,7 +21,7 @@ from common import xmpp
try:
import avahi, gobject, dbus
except ImportError:
gajim.log.debug("Error: python-avahi and python-dbus need to be installed. No zeroconf support.")
gajim.log.debug('Error: python-avahi and python-dbus need to be installed. No zeroconf support.')
try:
import dbus.glib
@ -71,7 +71,7 @@ class Zeroconf:
self.disconnected_CB()
def new_service_callback(self, interface, protocol, name, stype, domain, flags):
print "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:
return
@ -81,7 +81,7 @@ class Zeroconf:
reply_handler=self.service_resolved_callback, error_handler=self.error_callback)
def remove_service_callback(self, interface, protocol, name, stype, domain, flags):
print "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:
# return
if name != self.name:
@ -121,8 +121,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, avahi.txt_array_to_string_array(txt))
gajim.log.debug('Service data for service %s in domain %s on %i.%i:' % (name, domain, interface, protocol))
gajim.log.debug('Host %s (%s), port %i, TXT data: %s' % (host, address, port, avahi.txt_array_to_string_array(txt)))
if not self.connected:
return
bare_name = name
@ -144,8 +144,6 @@ class Zeroconf:
# different handler when resolving all contacts
def service_resolved_all_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)))
if not self.connected:
return
bare_name = name
@ -154,16 +152,13 @@ class Zeroconf:
self.contacts[name] = (name, domain, interface, protocol, host, address, port, bare_name, txt)
def service_added_callback(self):
print 'Service successfully added'
pass
gajim.log.debug('Service successfully added')
def service_committed_callback(self):
print 'Service successfully committed'
pass
gajim.log.debug('Service successfully committed')
def service_updated_callback(self):
print 'Service successfully updated'
pass
gajim.log.debug('Service successfully updated')
def service_add_fail_callback(self, err):
gajim.log.debug('Error while adding service. %s' % str(err))
@ -222,7 +217,7 @@ class Zeroconf:
self.txt = txt
# print "Publishing service '%s' of type %s" % (self.name, self.stype)
gajim.log.debug('Publishing service %s of type %s' % (self.name, self.stype))
self.entrygroup.AddService(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, dbus.UInt32(0), self.name, self.stype, '', '', self.port, avahi.dict_to_txt_array(self.txt), reply_handler=self.service_added_callback, error_handler=self.service_add_fail_callback)
self.entrygroup.Commit(reply_handler=self.service_committed_callback,
error_handler=self.entrygroup_commit_error_CB)
@ -256,7 +251,7 @@ class Zeroconf:
else:
return False
except dbus.dbus_bindings.DBusException, e:
print "zeroconf.py: Can't remove service, avahi daemon not running?"
gajim.log.debug("Can't remove service. That should not happen")
def browse_domain(self, interface, protocol, domain):
self.new_service_type(interface, protocol, self.stype, domain, '')