From 43132dab8525299bc9277a46a21f16ddb0ad3793 Mon Sep 17 00:00:00 2001 From: roger Date: Sat, 9 Feb 2013 12:31:13 -0300 Subject: fix not blocking gmail notification check --- sleekxmpp/plugins/gmail/notifications.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'sleekxmpp/plugins') diff --git a/sleekxmpp/plugins/gmail/notifications.py b/sleekxmpp/plugins/gmail/notifications.py index 53ad2f3f..9cc67f04 100644 --- a/sleekxmpp/plugins/gmail/notifications.py +++ b/sleekxmpp/plugins/gmail/notifications.py @@ -59,16 +59,20 @@ class Gmail(BasePlugin): def check(self, block=True, timeout=None, callback=None): last_time = self._last_result_time last_tid = self._last_result_tid - data = self.search(newer_time=last_time, + + 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) - - self._last_result_time = data["gmail_messages"]["result_time"] - if data["gmail_messages"]["threads"]: - self._last_result_tid = data["gmail_messages"]["threads"][0]["tid"] - return data + callback=check_callback) def search(self, query=None, newer_time=None, newer_tid=None, block=True, timeout=None, callback=None): -- cgit v1.2.3