use nec to handle last requests
This commit is contained in:
parent
f66baccf3b
commit
372c4e8d76
|
@ -1082,6 +1082,8 @@ ConnectionJingle, ConnectionIBBytestream):
|
||||||
self._nec_http_auth_received)
|
self._nec_http_auth_received)
|
||||||
gajim.ged.register_event_handler('version-request-received', ged.CORE,
|
gajim.ged.register_event_handler('version-request-received', ged.CORE,
|
||||||
self._nec_version_request_received)
|
self._nec_version_request_received)
|
||||||
|
gajim.ged.register_event_handler('last-request-received', ged.CORE,
|
||||||
|
self._nec_last_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:
|
||||||
|
@ -1277,22 +1279,28 @@ ConnectionJingle, ConnectionIBBytestream):
|
||||||
self.connection.send(iq_obj)
|
self.connection.send(iq_obj)
|
||||||
|
|
||||||
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')
|
||||||
|
@ -2685,3 +2693,15 @@ class VersionRequestEvent(nec.NetworkIncomingEvent):
|
||||||
self.iq_obj = self.base_event.xmpp_iq
|
self.iq_obj = self.base_event.xmpp_iq
|
||||||
|
|
||||||
return True
|
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
|
Loading…
Reference in New Issue