JEP 0091 support: timestamp in presences. Fixes #1675
This commit is contained in:
parent
81d3d38455
commit
90e5561860
|
@ -1299,6 +1299,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco)
|
||||||
if ptype == 'available':
|
if ptype == 'available':
|
||||||
ptype = None
|
ptype = None
|
||||||
gajim.log.debug('PresenceCB: %s' % ptype)
|
gajim.log.debug('PresenceCB: %s' % ptype)
|
||||||
|
timestamp = None
|
||||||
is_gc = False # is it a GC presence ?
|
is_gc = False # is it a GC presence ?
|
||||||
sigTag = None
|
sigTag = None
|
||||||
avatar_sha = None
|
avatar_sha = None
|
||||||
|
@ -1310,6 +1311,11 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco)
|
||||||
sigTag = x
|
sigTag = x
|
||||||
if x.getNamespace() == common.xmpp.NS_VCARD_UPDATE:
|
if x.getNamespace() == common.xmpp.NS_VCARD_UPDATE:
|
||||||
avatar_sha = x.getTagData('photo')
|
avatar_sha = x.getTagData('photo')
|
||||||
|
if x.getNamespace() == common.xmpp.NS_DELAY:
|
||||||
|
# JEP-0091
|
||||||
|
tim = prs.getTimestamp()
|
||||||
|
tim = time.strptime(tim, '%Y%m%dT%H:%M:%S')
|
||||||
|
timstamp = time.localtime(timegm(tim))
|
||||||
|
|
||||||
who = helpers.get_full_jid_from_iq(prs)
|
who = helpers.get_full_jid_from_iq(prs)
|
||||||
jid_stripped, resource = gajim.get_room_and_nick_from_fjid(who)
|
jid_stripped, resource = gajim.get_room_and_nick_from_fjid(who)
|
||||||
|
@ -1340,7 +1346,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco)
|
||||||
errcode = prs.getErrorCode()
|
errcode = prs.getErrorCode()
|
||||||
if errcode == '502': # Internal Timeout:
|
if errcode == '502': # Internal Timeout:
|
||||||
self.dispatch('NOTIFY', (jid_stripped, 'error', errmsg, resource,
|
self.dispatch('NOTIFY', (jid_stripped, 'error', errmsg, resource,
|
||||||
prio, keyID))
|
prio, keyID, timestamp))
|
||||||
elif errcode == '401': # password required to join
|
elif errcode == '401': # password required to join
|
||||||
self.dispatch('ERROR', (_('Unable to join room'),
|
self.dispatch('ERROR', (_('Unable to join room'),
|
||||||
_('A password is required to join this room.')))
|
_('A password is required to join this room.')))
|
||||||
|
@ -1389,8 +1395,8 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco)
|
||||||
p = self.add_sha(p)
|
p = self.add_sha(p)
|
||||||
self.connection.send(p)
|
self.connection.send(p)
|
||||||
if who.find("@") <= 0:
|
if who.find("@") <= 0:
|
||||||
self.dispatch('NOTIFY',
|
self.dispatch('NOTIFY', (jid_stripped, 'offline', 'offline',
|
||||||
(jid_stripped, 'offline', 'offline', resource, prio, keyID))
|
resource, prio, keyID, timestamp))
|
||||||
else:
|
else:
|
||||||
if not status:
|
if not status:
|
||||||
status = _('I would like to add you to my roster.')
|
status = _('I would like to add you to my roster.')
|
||||||
|
@ -1409,7 +1415,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco)
|
||||||
errcode = prs.getErrorCode()
|
errcode = prs.getErrorCode()
|
||||||
if errcode == '502': # Internal Timeout:
|
if errcode == '502': # Internal Timeout:
|
||||||
self.dispatch('NOTIFY', (jid_stripped, 'error', errmsg, resource,
|
self.dispatch('NOTIFY', (jid_stripped, 'error', errmsg, resource,
|
||||||
prio, keyID))
|
prio, keyID, timestamp))
|
||||||
else: # print in the window the error
|
else: # print in the window the error
|
||||||
self.dispatch('ERROR_ANSWER', ('', jid_stripped,
|
self.dispatch('ERROR_ANSWER', ('', jid_stripped,
|
||||||
errmsg, errcode))
|
errmsg, errcode))
|
||||||
|
@ -1426,7 +1432,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco)
|
||||||
not in no_log_for and jid_stripped not in no_log_for:
|
not in no_log_for and jid_stripped not in no_log_for:
|
||||||
gajim.logger.write('status', jid_stripped, status, show)
|
gajim.logger.write('status', jid_stripped, status, show)
|
||||||
self.dispatch('NOTIFY', (jid_stripped, show, status, resource, prio,
|
self.dispatch('NOTIFY', (jid_stripped, show, status, resource, prio,
|
||||||
keyID))
|
keyID, timestamp))
|
||||||
# END presenceCB
|
# END presenceCB
|
||||||
def _StanzaArrivedCB(self, con, obj):
|
def _StanzaArrivedCB(self, con, obj):
|
||||||
self.last_io = gajim.idlequeue.current_time()
|
self.last_io = gajim.idlequeue.current_time()
|
||||||
|
|
|
@ -302,7 +302,7 @@ class Interface:
|
||||||
|
|
||||||
def handle_event_notify(self, account, array):
|
def handle_event_notify(self, account, array):
|
||||||
# 'NOTIFY' (account, (jid, status, status message, resource, priority,
|
# 'NOTIFY' (account, (jid, status, status message, resource, priority,
|
||||||
# keyID))
|
# keyID, timestamp))
|
||||||
# if we're here it means contact changed show
|
# if we're here it means contact changed show
|
||||||
statuss = ['offline', 'error', 'online', 'chat', 'away', 'xa', 'dnd',
|
statuss = ['offline', 'error', 'online', 'chat', 'away', 'xa', 'dnd',
|
||||||
'invisible']
|
'invisible']
|
||||||
|
@ -374,7 +374,11 @@ class Interface:
|
||||||
contact1.status = status_message
|
contact1.status = status_message
|
||||||
contact1.priority = priority
|
contact1.priority = priority
|
||||||
contact1.keyID = keyID
|
contact1.keyID = keyID
|
||||||
if contact1.jid not in gajim.newly_added[account]:
|
timestamp = array[6]
|
||||||
|
if timestamp:
|
||||||
|
contact1.last_status_time = timestamp
|
||||||
|
elif not gajim.block_signed_in_notifications[account]:
|
||||||
|
# We're connected since more that 30 seconds
|
||||||
contact1.last_status_time = time.localtime()
|
contact1.last_status_time = time.localtime()
|
||||||
if gajim.jid_is_transport(jid):
|
if gajim.jid_is_transport(jid):
|
||||||
# It must be an agent
|
# It must be an agent
|
||||||
|
|
Loading…
Reference in New Issue