summaryrefslogtreecommitdiff
path: root/sleekxmpp
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2013-02-10 11:27:23 -0800
committerLance Stout <lancestout@gmail.com>2013-02-10 11:27:23 -0800
commitb0fed5a48dc6543a1eedf3ff2cc96f671fbfef0c (patch)
treed93eafed1aac539288eaf07921d01aa6826e0f02 /sleekxmpp
parent9165cbf7f6839ee8ba2a4514b297f27fb019098a (diff)
parent43132dab8525299bc9277a46a21f16ddb0ad3793 (diff)
downloadslixmpp-b0fed5a48dc6543a1eedf3ff2cc96f671fbfef0c.tar.gz
slixmpp-b0fed5a48dc6543a1eedf3ff2cc96f671fbfef0c.tar.bz2
slixmpp-b0fed5a48dc6543a1eedf3ff2cc96f671fbfef0c.tar.xz
slixmpp-b0fed5a48dc6543a1eedf3ff2cc96f671fbfef0c.zip
Merge pull request #221 from Roger/fix_gmail_notify_check
fixed gmail new mail notification check
Diffstat (limited to 'sleekxmpp')
-rw-r--r--sleekxmpp/plugins/gmail/notifications.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/sleekxmpp/plugins/gmail/notifications.py b/sleekxmpp/plugins/gmail/notifications.py
index dbc68162..9cc67f04 100644
--- a/sleekxmpp/plugins/gmail/notifications.py
+++ b/sleekxmpp/plugins/gmail/notifications.py
@@ -46,6 +46,7 @@ class Gmail(BasePlugin):
self._handle_new_mail))
self._last_result_time = None
+ self._last_result_tid = None
def plugin_end(self):
self.xmpp.remove_handler('Gmail New Mail')
@@ -57,13 +58,23 @@ class Gmail(BasePlugin):
def check(self, block=True, timeout=None, callback=None):
last_time = self._last_result_time
- self._last_result_time = str(int(time.time() * 1000))
- return self.search(newer=last_time,
+ last_tid = self._last_result_tid
+
+ def check_callback(data):
+ self._last_result_time = data["gmail_messages"]["result_time"]
+ if data["gmail_messages"]["threads"]:
+ self._last_result_tid = \
+ data["gmail_messages"]["threads"][0]["tid"]
+ if callback:
+ callback(data)
+
+ return self.search(newer_time=last_time,
+ newer_tid=last_tid,
block=block,
timeout=timeout,
- callback=callback)
+ callback=check_callback)
- def search(self, query=None, newer=None, block=True,
+ def search(self, query=None, newer_time=None, newer_tid=None, block=True,
timeout=None, callback=None):
if not query:
log.info('Gmail: Checking for new email')
@@ -73,5 +84,6 @@ class Gmail(BasePlugin):
iq['type'] = 'get'
iq['to'] = self.xmpp.boundjid.bare
iq['gmail']['search'] = query
- iq['gmail']['newer_than_time'] = newer
+ iq['gmail']['newer_than_time'] = newer_time
+ iq['gmail']['newer_than_tid'] = newer_tid
return iq.send(block=block, timeout=timeout, callback=callback)