10 _moduleLogger = logging.getLogger("gvoice.session")
13 class Session(object):
15 def __init__(self, cookiePath):
16 self._cookiePath = cookiePath
20 self._addressbook = None
21 self._conversations = None
23 def login(self, username, password):
24 self._username = username
25 self._password = password
26 self._backend = backend.GVoiceBackend(self._cookiePath)
27 if not self._backend.is_authed():
28 self._backend.login(self._username, self._password)
34 self._addressbook = None
35 self._conversations = None
37 def is_logged_in(self):
38 if self._backend is None:
40 elif self._backend.is_authed():
44 loggedIn = self._backend.login(self._username, self._password)
56 Login enforcing backend
58 assert self.is_logged_in(), "User not logged in"
62 def addressbook(self):
64 Delay initialized addressbook
66 if self._addressbook is None:
67 _moduleLogger.info("Initializing addressbook")
68 self._addressbook = addressbook.Addressbook(self.backend)
69 return self._addressbook
72 def conversations(self):
74 Delay initialized addressbook
76 if self._conversations is None:
77 _moduleLogger.info("Initializing conversations")
78 self._conversations = conversations.Conversationst(self.backend)
79 return self._conversations