summaryrefslogtreecommitdiff
path: root/src/roster.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/roster.py')
-rw-r--r--src/roster.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/roster.py b/src/roster.py
index b0f3cf65..5ddbdbb2 100644
--- a/src/roster.py
+++ b/src/roster.py
@@ -17,6 +17,7 @@ from contact import Contact
from roster_sorting import SORTING_METHODS, GROUP_SORTING_METHODS
from os import path as p
+from datetime import datetime
from common import safeJID
from sleekxmpp import JID
from sleekxmpp.exceptions import IqError, IqTimeout
@@ -43,6 +44,17 @@ class Roster(object):
self.groups = {}
self.contacts = {}
+ # Used for caching roster infos
+ self.last_built = datetime.now()
+ self.last_modified = datetime.now()
+
+ def modified(self):
+ self.last_modified = datetime.now()
+
+ @property
+ def needs_rebuild(self):
+ return self.last_modified >= self.last_built
+
def __getitem__(self, key):
"""Get a Contact from his bare JID"""
key = safeJID(key).bare