merge from trunk

This commit is contained in:
Yann Leboulanger 2010-08-17 15:45:34 +02:00
commit 092bde6389
5 changed files with 438 additions and 680 deletions

View File

@ -1,7 +1,8 @@
#!/usr/bin/env bash
gajimversion="0.13.90.1"
if [ -d ".hg" ]; then
hgversion="-$(hexdump -n6 -e'6/1 "%02x"' .hg/dirstate)"
node=$(hg tip --template "{node}")
hgversion="-${node:0:12}"
else
hgversion=""
fi

960
po/kk.po

File diff suppressed because it is too large Load Diff

View File

@ -1084,6 +1084,14 @@ ConnectionJingle, ConnectionIBBytestream):
gajim.ged.register_event_handler('http-auth-received', ged.CORE,
self._nec_http_auth_received)
gajim.ged.register_event_handler('version-request-received', ged.CORE,
self._nec_version_request_received)
gajim.ged.register_event_handler('last-request-received', ged.CORE,
self._nec_last_request_received)
gajim.ged.register_event_handler('time-request-received', ged.CORE,
self._nec_time_request_received)
gajim.ged.register_event_handler('time-revised-request-received',
ged.CORE, self._nec_time_revised_request_received)
def build_http_auth_answer(self, iq_obj, answer):
if not self.connection or self.connected < 2:
@ -1262,7 +1270,14 @@ ConnectionJingle, ConnectionIBBytestream):
log.debug('VersionCB')
if not self.connection or self.connected < 2:
return
iq_obj = iq_obj.buildReply('result')
gajim.nec.push_incoming_event(VersionRequestEvent(None,
conn=self, iq_obj=iq_obj))
raise common.xmpp.NodeProcessed
def _nec_version_request_received(self, obj):
if obj.conn.name != self.name:
return
iq_obj = obj.iq_obj.buildReply('result')
qp = iq_obj.getTag('query')
qp.setTagData('name', 'Gajim')
qp.setTagData('version', gajim.version)
@ -1270,25 +1285,30 @@ ConnectionJingle, ConnectionIBBytestream):
if send_os:
qp.setTagData('os', helpers.get_os_info())
self.connection.send(iq_obj)
raise common.xmpp.NodeProcessed
def _LastCB(self, con, iq_obj):
global HAS_IDLE
log.debug('LastCB')
if not self.connection or self.connected < 2:
return
gajim.nec.push_incoming_event(LastRequestEvent(None,
conn=self, iq_obj=iq_obj))
raise common.xmpp.NodeProcessed
def _nec_last_request_received(self, obj):
global HAS_IDLE
if obj.conn.name != self.name:
return
if HAS_IDLE and gajim.config.get_per('accounts', self.name,
'send_idle_time'):
iq_obj = iq_obj.buildReply('result')
iq_obj = obj.iq_obj.buildReply('result')
qp = iq_obj.getTag('query')
qp.attrs['seconds'] = int(self.sleeper.getIdleSec())
else:
iq_obj = iq_obj.buildReply('error')
err = common.xmpp.ErrorNode(name=common.xmpp.NS_STANZAS+' service-unavailable')
iq_obj = obj.iq_obj.buildReply('error')
err = common.xmpp.ErrorNode(name=common.xmpp.NS_STANZASi + \
' service-unavailable')
iq_obj.addChild(node=err)
self.connection.send(iq_obj)
raise common.xmpp.NodeProcessed
def _VersionResultCB(self, con, iq_obj):
log.debug('VersionResultCB')
@ -1299,29 +1319,40 @@ ConnectionJingle, ConnectionIBBytestream):
log.debug('TimeCB')
if not self.connection or self.connected < 2:
return
iq_obj = iq_obj.buildReply('result')
gajim.nec.push_incoming_event(TimeRequestEvent(None,
conn=self, iq_obj=iq_obj))
raise common.xmpp.NodeProcessed
def _nec_time_request_received(self, obj):
if obj.conn.name != self.name:
return
iq_obj = obj.iq_obj.buildReply('result')
qp = iq_obj.getTag('query')
qp.setTagData('utc', strftime('%Y%m%dT%H:%M:%S', gmtime()))
qp.setTagData('tz', helpers.decode_string(tzname[daylight]))
qp.setTagData('display', helpers.decode_string(strftime('%c',
localtime())))
localtime())))
self.connection.send(iq_obj)
raise common.xmpp.NodeProcessed
def _TimeRevisedCB(self, con, iq_obj):
log.debug('TimeRevisedCB')
if not self.connection or self.connected < 2:
return
iq_obj = iq_obj.buildReply('result')
qp = iq_obj.setTag('time',
namespace=common.xmpp.NS_TIME_REVISED)
gajim.nec.push_incoming_event(TimeRevisedRequestEvent(None,
conn=self, iq_obj=iq_obj))
raise common.xmpp.NodeProcessed
def _nec_time_revised_request_received(self, obj):
if obj.conn.name != self.name:
return
iq_obj = obj.iq_obj.buildReply('result')
qp = iq_obj.setTag('time', namespace=common.xmpp.NS_TIME_REVISED)
qp.setTagData('utc', strftime('%Y-%m-%dT%H:%M:%SZ', gmtime()))
isdst = localtime().tm_isdst
zone = -(timezone, altzone)[isdst] / 60
tzo = (zone / 60, abs(zone % 60))
qp.setTagData('tzo', '%+03d:%02d' % (tzo))
self.connection.send(iq_obj)
raise common.xmpp.NodeProcessed
def _TimeRevisedResultCB(self, con, iq_obj):
log.debug('TimeRevisedResultCB')
@ -2355,7 +2386,7 @@ ConnectionJingle, ConnectionIBBytestream):
common.xmpp.NS_BYTESTREAM)
con.RegisterHandler('iq', self._bytestreamErrorCB, 'error',
common.xmpp.NS_BYTESTREAM)
con.RegisterHandlerOnce('iq', self.StreamOpenReplyHandler)
con.RegisterHandlerOnce('iq', self.IBBAllIqHandler)
con.RegisterHandler('iq', self.IBBIqHandler, ns=common.xmpp.NS_IBB)
con.RegisterHandler('message', self.IBBMessageHandler,
ns=common.xmpp.NS_IBB)
@ -2683,3 +2714,51 @@ class RosterItemExchangeEvent(nec.NetworkIncomingEvent, HelperEvent):
self.exchange_items_list[jid].append(groups)
if exchange_items_list:
return True
class VersionRequestEvent(nec.NetworkIncomingEvent):
name = 'version-request-received'
base_network_events = []
def generate(self):
if not self.conn:
self.conn = self.base_event.conn
if not self.iq_obj:
self.iq_obj = self.base_event.xmpp_iq
return True
class LastRequestEvent(nec.NetworkIncomingEvent):
name = 'last-request-received'
base_network_events = []
def generate(self):
if not self.conn:
self.conn = self.base_event.conn
if not self.iq_obj:
self.iq_obj = self.base_event.xmpp_iq
return True
class TimeRequestEvent(nec.NetworkIncomingEvent):
name = 'time-request-received'
base_network_events = []
def generate(self):
if not self.conn:
self.conn = self.base_event.conn
if not self.iq_obj:
self.iq_obj = self.base_event.xmpp_iq
return True
class TimeRevisedRequestEvent(nec.NetworkIncomingEvent):
name = 'time-revised-request-received'
base_network_events = []
def generate(self):
if not self.conn:
self.conn = self.base_event.conn
if not self.iq_obj:
self.iq_obj = self.base_event.xmpp_iq
return True

View File

@ -30,8 +30,9 @@ localedir = '../po'
version = '0.13.90.1'
import subprocess
try:
hgversion = subprocess.Popen('hexdump -n6 -e\'6/1 "%02x"\' ../.hg/dirstate',
shell=True, stdout=subprocess.PIPE).communicate()[0]
node = subprocess.Popen('hg tip --template {node}', shell=True,
stdout=subprocess.PIPE).communicate()[0]
hgversion = node[:12]
version += '-' + hgversion
except Exception:
pass

View File

@ -121,7 +121,7 @@ class ConnectionBytestream:
feature.addChild(node=_feature)
field = _feature.setField('stream-method')
field.setAttr('type', 'list-single')
field.addOption(xmpp.NS_BYTESTREAM)
#field.addOption(xmpp.NS_BYTESTREAM)
field.addOption(xmpp.NS_IBB)
self.connection.send(iq)
@ -688,7 +688,7 @@ class ConnectionIBBytestream(ConnectionBytestream):
'action': 'error'}), xmpp.Node('rule',
{'condition': 'match-resource', 'value': 'exact',
'action':'error'})])
self.timout_id = None
self.last_sent_ibb_id = None
def IBBIqHandler(self, conn, stanza):
"""
@ -746,7 +746,7 @@ class ConnectionIBBytestream(ConnectionBytestream):
file_props['fp'] = open(file_props['file-name'], 'w')
conn.send(rep)
def OpenStream(self, sid, to, fp, blocksize=3000):
def OpenStream(self, sid, to, fp, blocksize=4096):
"""
Start new stream. You should provide stream id 'sid', the endpoind jid
'to', the file object containing info for send 'fp'. Also the desired
@ -770,11 +770,8 @@ class ConnectionIBBytestream(ConnectionBytestream):
self.files_props[sid]['completed'] = False
self.files_props[sid]['disconnect_cb'] = None
self.files_props[sid]['continue_cb'] = None
if not self.timout_id:
self.timout_id = gobject.timeout_add_seconds(3, self.SendHandler)
self.SendHandler() # start sending now
syn = xmpp.Protocol('iq', to, 'set', payload=[xmpp.Node(xmpp.NS_IBB + \
' open', {'sid': sid, 'block-size': blocksize})])
' open', {'sid': sid, 'block-size': blocksize, 'stanza': 'iq'})])
self.connection.send(syn)
self.files_props[sid]['syn_id'] = syn.getID()
return self.files_props[sid]
@ -785,8 +782,7 @@ class ConnectionIBBytestream(ConnectionBytestream):
"""
log.debug('SendHandler called')
if not self.files_props:
self.timout_id = None
return False
return
for file_props in self.files_props.values():
if 'direction' not in file_props:
# it's socks5 bytestream
@ -806,7 +802,7 @@ class ConnectionIBBytestream(ConnectionBytestream):
file_props['started'] = True
if file_props['seq'] == 65536:
file_props['seq'] = 0
self.connection.send(xmpp.Protocol('message',
self.last_sent_ibb_id = self.connection.send(xmpp.Protocol('iq',
file_props['direction'][1:], payload=[datanode,
self._ampnode]))
current_time = time.time()
@ -826,11 +822,7 @@ class ConnectionIBBytestream(ConnectionBytestream):
{'sid':sid})]))
file_props['completed'] = True
del self.files_props[sid]
if not self.files_props:
self.timout_id = None
return False
return True
def IBBMessageHandler(self, conn, stanza):
"""
Receive next portion of incoming datastream and store it write
@ -874,6 +866,8 @@ class ConnectionIBBytestream(ConnectionBytestream):
conn.send(xmpp.Error(xmpp.Iq(to=stanza.getFrom(),
frm=stanza.getTo(),
payload=[xmpp.Node(xmpp.NS_IBB + ' close')]), err, reply=0))
else:
return True
def StreamCloseHandler(self, conn, stanza):
"""
@ -897,7 +891,7 @@ class ConnectionIBBytestream(ConnectionBytestream):
else:
conn.send(xmpp.Error(stanza, xmpp.ERR_ITEM_NOT_FOUND))
def StreamOpenReplyHandler(self, conn, stanza):
def IBBAllIqHandler(self, conn, stanza):
"""
Handle remote side reply about if it agree or not to receive our
datastream.
@ -905,7 +899,7 @@ class ConnectionIBBytestream(ConnectionBytestream):
is agreed upon.
"""
syn_id = stanza.getID()
log.debug('StreamOpenReplyHandler called syn_id->%s' % syn_id)
log.debug('IBBAllIqHandler called syn_id->%s' % syn_id)
for sid in self.files_props.keys():
file_props = self.files_props[sid]
if not 'direction' in file_props:
@ -921,10 +915,19 @@ class ConnectionIBBytestream(ConnectionBytestream):
elif stanza.getType() == 'result':
if file_props['direction'][0] == '|':
file_props['direction'] = file_props['direction'][1:]
conn.Event('IBB', 'STREAM COMMITTED', file_props)
self.SendHandler()
else:
conn.send(xmpp.Error(stanza,
xmpp.ERR_UNEXPECTED_REQUEST))
break
else:
if stanza.getTag('data'):
if self.IBBMessageHandler(conn, stanza):
reply = stanza.buildReply('result')
conn.send(reply)
raise xmpp.NodeProcessed
elif syn_id == self.last_sent_ibb_id:
self.SendHandler()
class ConnectionSocks5BytestreamZeroconf(ConnectionSocks5Bytestream):