merge from trunk
This commit is contained in:
commit
092bde6389
5 changed files with 438 additions and 680 deletions
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
gajimversion="0.13.90.1"
|
gajimversion="0.13.90.1"
|
||||||
if [ -d ".hg" ]; then
|
if [ -d ".hg" ]; then
|
||||||
hgversion="-$(hexdump -n6 -e'6/1 "%02x"' .hg/dirstate)"
|
node=$(hg tip --template "{node}")
|
||||||
|
hgversion="-${node:0:12}"
|
||||||
else
|
else
|
||||||
hgversion=""
|
hgversion=""
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1084,6 +1084,14 @@ ConnectionJingle, ConnectionIBBytestream):
|
||||||
|
|
||||||
gajim.ged.register_event_handler('http-auth-received', ged.CORE,
|
gajim.ged.register_event_handler('http-auth-received', ged.CORE,
|
||||||
self._nec_http_auth_received)
|
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):
|
def build_http_auth_answer(self, iq_obj, answer):
|
||||||
if not self.connection or self.connected < 2:
|
if not self.connection or self.connected < 2:
|
||||||
|
@ -1262,7 +1270,14 @@ ConnectionJingle, ConnectionIBBytestream):
|
||||||
log.debug('VersionCB')
|
log.debug('VersionCB')
|
||||||
if not self.connection or self.connected < 2:
|
if not self.connection or self.connected < 2:
|
||||||
return
|
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 = iq_obj.getTag('query')
|
||||||
qp.setTagData('name', 'Gajim')
|
qp.setTagData('name', 'Gajim')
|
||||||
qp.setTagData('version', gajim.version)
|
qp.setTagData('version', gajim.version)
|
||||||
|
@ -1270,25 +1285,30 @@ ConnectionJingle, ConnectionIBBytestream):
|
||||||
if send_os:
|
if send_os:
|
||||||
qp.setTagData('os', helpers.get_os_info())
|
qp.setTagData('os', helpers.get_os_info())
|
||||||
self.connection.send(iq_obj)
|
self.connection.send(iq_obj)
|
||||||
raise common.xmpp.NodeProcessed
|
|
||||||
|
|
||||||
def _LastCB(self, con, iq_obj):
|
def _LastCB(self, con, iq_obj):
|
||||||
global HAS_IDLE
|
|
||||||
log.debug('LastCB')
|
log.debug('LastCB')
|
||||||
if not self.connection or self.connected < 2:
|
if not self.connection or self.connected < 2:
|
||||||
return
|
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,
|
if HAS_IDLE and gajim.config.get_per('accounts', self.name,
|
||||||
'send_idle_time'):
|
'send_idle_time'):
|
||||||
iq_obj = iq_obj.buildReply('result')
|
iq_obj = obj.iq_obj.buildReply('result')
|
||||||
qp = iq_obj.getTag('query')
|
qp = iq_obj.getTag('query')
|
||||||
qp.attrs['seconds'] = int(self.sleeper.getIdleSec())
|
qp.attrs['seconds'] = int(self.sleeper.getIdleSec())
|
||||||
else:
|
else:
|
||||||
iq_obj = iq_obj.buildReply('error')
|
iq_obj = obj.iq_obj.buildReply('error')
|
||||||
err = common.xmpp.ErrorNode(name=common.xmpp.NS_STANZAS+' service-unavailable')
|
err = common.xmpp.ErrorNode(name=common.xmpp.NS_STANZASi + \
|
||||||
|
' service-unavailable')
|
||||||
iq_obj.addChild(node=err)
|
iq_obj.addChild(node=err)
|
||||||
|
|
||||||
self.connection.send(iq_obj)
|
self.connection.send(iq_obj)
|
||||||
raise common.xmpp.NodeProcessed
|
|
||||||
|
|
||||||
def _VersionResultCB(self, con, iq_obj):
|
def _VersionResultCB(self, con, iq_obj):
|
||||||
log.debug('VersionResultCB')
|
log.debug('VersionResultCB')
|
||||||
|
@ -1299,29 +1319,40 @@ ConnectionJingle, ConnectionIBBytestream):
|
||||||
log.debug('TimeCB')
|
log.debug('TimeCB')
|
||||||
if not self.connection or self.connected < 2:
|
if not self.connection or self.connected < 2:
|
||||||
return
|
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 = iq_obj.getTag('query')
|
||||||
qp.setTagData('utc', strftime('%Y%m%dT%H:%M:%S', gmtime()))
|
qp.setTagData('utc', strftime('%Y%m%dT%H:%M:%S', gmtime()))
|
||||||
qp.setTagData('tz', helpers.decode_string(tzname[daylight]))
|
qp.setTagData('tz', helpers.decode_string(tzname[daylight]))
|
||||||
qp.setTagData('display', helpers.decode_string(strftime('%c',
|
qp.setTagData('display', helpers.decode_string(strftime('%c',
|
||||||
localtime())))
|
localtime())))
|
||||||
self.connection.send(iq_obj)
|
self.connection.send(iq_obj)
|
||||||
raise common.xmpp.NodeProcessed
|
|
||||||
|
|
||||||
def _TimeRevisedCB(self, con, iq_obj):
|
def _TimeRevisedCB(self, con, iq_obj):
|
||||||
log.debug('TimeRevisedCB')
|
log.debug('TimeRevisedCB')
|
||||||
if not self.connection or self.connected < 2:
|
if not self.connection or self.connected < 2:
|
||||||
return
|
return
|
||||||
iq_obj = iq_obj.buildReply('result')
|
gajim.nec.push_incoming_event(TimeRevisedRequestEvent(None,
|
||||||
qp = iq_obj.setTag('time',
|
conn=self, iq_obj=iq_obj))
|
||||||
namespace=common.xmpp.NS_TIME_REVISED)
|
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()))
|
qp.setTagData('utc', strftime('%Y-%m-%dT%H:%M:%SZ', gmtime()))
|
||||||
isdst = localtime().tm_isdst
|
isdst = localtime().tm_isdst
|
||||||
zone = -(timezone, altzone)[isdst] / 60
|
zone = -(timezone, altzone)[isdst] / 60
|
||||||
tzo = (zone / 60, abs(zone % 60))
|
tzo = (zone / 60, abs(zone % 60))
|
||||||
qp.setTagData('tzo', '%+03d:%02d' % (tzo))
|
qp.setTagData('tzo', '%+03d:%02d' % (tzo))
|
||||||
self.connection.send(iq_obj)
|
self.connection.send(iq_obj)
|
||||||
raise common.xmpp.NodeProcessed
|
|
||||||
|
|
||||||
def _TimeRevisedResultCB(self, con, iq_obj):
|
def _TimeRevisedResultCB(self, con, iq_obj):
|
||||||
log.debug('TimeRevisedResultCB')
|
log.debug('TimeRevisedResultCB')
|
||||||
|
@ -2355,7 +2386,7 @@ ConnectionJingle, ConnectionIBBytestream):
|
||||||
common.xmpp.NS_BYTESTREAM)
|
common.xmpp.NS_BYTESTREAM)
|
||||||
con.RegisterHandler('iq', self._bytestreamErrorCB, 'error',
|
con.RegisterHandler('iq', self._bytestreamErrorCB, 'error',
|
||||||
common.xmpp.NS_BYTESTREAM)
|
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('iq', self.IBBIqHandler, ns=common.xmpp.NS_IBB)
|
||||||
con.RegisterHandler('message', self.IBBMessageHandler,
|
con.RegisterHandler('message', self.IBBMessageHandler,
|
||||||
ns=common.xmpp.NS_IBB)
|
ns=common.xmpp.NS_IBB)
|
||||||
|
@ -2683,3 +2714,51 @@ class RosterItemExchangeEvent(nec.NetworkIncomingEvent, HelperEvent):
|
||||||
self.exchange_items_list[jid].append(groups)
|
self.exchange_items_list[jid].append(groups)
|
||||||
if exchange_items_list:
|
if exchange_items_list:
|
||||||
return True
|
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
|
|
@ -30,8 +30,9 @@ localedir = '../po'
|
||||||
version = '0.13.90.1'
|
version = '0.13.90.1'
|
||||||
import subprocess
|
import subprocess
|
||||||
try:
|
try:
|
||||||
hgversion = subprocess.Popen('hexdump -n6 -e\'6/1 "%02x"\' ../.hg/dirstate',
|
node = subprocess.Popen('hg tip --template {node}', shell=True,
|
||||||
shell=True, stdout=subprocess.PIPE).communicate()[0]
|
stdout=subprocess.PIPE).communicate()[0]
|
||||||
|
hgversion = node[:12]
|
||||||
version += '-' + hgversion
|
version += '-' + hgversion
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -121,7 +121,7 @@ class ConnectionBytestream:
|
||||||
feature.addChild(node=_feature)
|
feature.addChild(node=_feature)
|
||||||
field = _feature.setField('stream-method')
|
field = _feature.setField('stream-method')
|
||||||
field.setAttr('type', 'list-single')
|
field.setAttr('type', 'list-single')
|
||||||
field.addOption(xmpp.NS_BYTESTREAM)
|
#field.addOption(xmpp.NS_BYTESTREAM)
|
||||||
field.addOption(xmpp.NS_IBB)
|
field.addOption(xmpp.NS_IBB)
|
||||||
self.connection.send(iq)
|
self.connection.send(iq)
|
||||||
|
|
||||||
|
@ -688,7 +688,7 @@ class ConnectionIBBytestream(ConnectionBytestream):
|
||||||
'action': 'error'}), xmpp.Node('rule',
|
'action': 'error'}), xmpp.Node('rule',
|
||||||
{'condition': 'match-resource', 'value': 'exact',
|
{'condition': 'match-resource', 'value': 'exact',
|
||||||
'action':'error'})])
|
'action':'error'})])
|
||||||
self.timout_id = None
|
self.last_sent_ibb_id = None
|
||||||
|
|
||||||
def IBBIqHandler(self, conn, stanza):
|
def IBBIqHandler(self, conn, stanza):
|
||||||
"""
|
"""
|
||||||
|
@ -746,7 +746,7 @@ class ConnectionIBBytestream(ConnectionBytestream):
|
||||||
file_props['fp'] = open(file_props['file-name'], 'w')
|
file_props['fp'] = open(file_props['file-name'], 'w')
|
||||||
conn.send(rep)
|
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
|
Start new stream. You should provide stream id 'sid', the endpoind jid
|
||||||
'to', the file object containing info for send 'fp'. Also the desired
|
'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]['completed'] = False
|
||||||
self.files_props[sid]['disconnect_cb'] = None
|
self.files_props[sid]['disconnect_cb'] = None
|
||||||
self.files_props[sid]['continue_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 + \
|
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.connection.send(syn)
|
||||||
self.files_props[sid]['syn_id'] = syn.getID()
|
self.files_props[sid]['syn_id'] = syn.getID()
|
||||||
return self.files_props[sid]
|
return self.files_props[sid]
|
||||||
|
@ -785,8 +782,7 @@ class ConnectionIBBytestream(ConnectionBytestream):
|
||||||
"""
|
"""
|
||||||
log.debug('SendHandler called')
|
log.debug('SendHandler called')
|
||||||
if not self.files_props:
|
if not self.files_props:
|
||||||
self.timout_id = None
|
return
|
||||||
return False
|
|
||||||
for file_props in self.files_props.values():
|
for file_props in self.files_props.values():
|
||||||
if 'direction' not in file_props:
|
if 'direction' not in file_props:
|
||||||
# it's socks5 bytestream
|
# it's socks5 bytestream
|
||||||
|
@ -806,7 +802,7 @@ class ConnectionIBBytestream(ConnectionBytestream):
|
||||||
file_props['started'] = True
|
file_props['started'] = True
|
||||||
if file_props['seq'] == 65536:
|
if file_props['seq'] == 65536:
|
||||||
file_props['seq'] = 0
|
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,
|
file_props['direction'][1:], payload=[datanode,
|
||||||
self._ampnode]))
|
self._ampnode]))
|
||||||
current_time = time.time()
|
current_time = time.time()
|
||||||
|
@ -826,10 +822,6 @@ class ConnectionIBBytestream(ConnectionBytestream):
|
||||||
{'sid':sid})]))
|
{'sid':sid})]))
|
||||||
file_props['completed'] = True
|
file_props['completed'] = True
|
||||||
del self.files_props[sid]
|
del self.files_props[sid]
|
||||||
if not self.files_props:
|
|
||||||
self.timout_id = None
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
def IBBMessageHandler(self, conn, stanza):
|
def IBBMessageHandler(self, conn, stanza):
|
||||||
"""
|
"""
|
||||||
|
@ -874,6 +866,8 @@ class ConnectionIBBytestream(ConnectionBytestream):
|
||||||
conn.send(xmpp.Error(xmpp.Iq(to=stanza.getFrom(),
|
conn.send(xmpp.Error(xmpp.Iq(to=stanza.getFrom(),
|
||||||
frm=stanza.getTo(),
|
frm=stanza.getTo(),
|
||||||
payload=[xmpp.Node(xmpp.NS_IBB + ' close')]), err, reply=0))
|
payload=[xmpp.Node(xmpp.NS_IBB + ' close')]), err, reply=0))
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
def StreamCloseHandler(self, conn, stanza):
|
def StreamCloseHandler(self, conn, stanza):
|
||||||
"""
|
"""
|
||||||
|
@ -897,7 +891,7 @@ class ConnectionIBBytestream(ConnectionBytestream):
|
||||||
else:
|
else:
|
||||||
conn.send(xmpp.Error(stanza, xmpp.ERR_ITEM_NOT_FOUND))
|
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
|
Handle remote side reply about if it agree or not to receive our
|
||||||
datastream.
|
datastream.
|
||||||
|
@ -905,7 +899,7 @@ class ConnectionIBBytestream(ConnectionBytestream):
|
||||||
is agreed upon.
|
is agreed upon.
|
||||||
"""
|
"""
|
||||||
syn_id = stanza.getID()
|
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():
|
for sid in self.files_props.keys():
|
||||||
file_props = self.files_props[sid]
|
file_props = self.files_props[sid]
|
||||||
if not 'direction' in file_props:
|
if not 'direction' in file_props:
|
||||||
|
@ -921,10 +915,19 @@ class ConnectionIBBytestream(ConnectionBytestream):
|
||||||
elif stanza.getType() == 'result':
|
elif stanza.getType() == 'result':
|
||||||
if file_props['direction'][0] == '|':
|
if file_props['direction'][0] == '|':
|
||||||
file_props['direction'] = file_props['direction'][1:]
|
file_props['direction'] = file_props['direction'][1:]
|
||||||
conn.Event('IBB', 'STREAM COMMITTED', file_props)
|
self.SendHandler()
|
||||||
else:
|
else:
|
||||||
conn.send(xmpp.Error(stanza,
|
conn.send(xmpp.Error(stanza,
|
||||||
xmpp.ERR_UNEXPECTED_REQUEST))
|
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):
|
class ConnectionSocks5BytestreamZeroconf(ConnectionSocks5Bytestream):
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue