Skip to content

Commit

Permalink
[core, gtk] Implement autologin.
Browse files Browse the repository at this point in the history
-> API changed <-
The meaning of the signin() and signout() methods changed, now the switch between the initial window and the "login in progress" (if present) is managed by the core. The login/logout button on the login window only has to call the related core methods.
  • Loading branch information
luckyluke committed Dec 17, 2009
1 parent c58b93b commit 16a6ea3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
2 changes: 2 additions & 0 deletions amsn2/core/amsn.py
Expand Up @@ -138,10 +138,12 @@ def signinToAccount(self, login_window, accountview):
print "Signing in to account %s" % (accountview.email)
self._account = self._account_manager.signinToAccount(accountview)
self._account.login = login_window
self._account.login.signin()
self._account.client = protocol.Client(self, self._account)
self._account.client.connect(accountview.email, accountview.password)

def signOutOfAccount(self):
self._account.login.signout()
self._account.client.logout()

def connectionStateChanged(self, account, state):
Expand Down
10 changes: 7 additions & 3 deletions amsn2/core/userinterface_manager.py
Expand Up @@ -55,17 +55,21 @@ def loadSplash(self):
return self._splash

def loadLogin(self, accounts):
self._login = self._ui.aMSNLoginWindow(self._core, self._main)
self._login.setAccounts(accounts)

if self._splash:
self._splash.hide()
self._splash = None

if self._contactlist:
self.unloadContactList()

if not self._login:
self._login = self._ui.aMSNLoginWindow(self._core, self._main)
self._login.setAccounts(accounts)
if accounts[0].autologin:
self._core.signinToAccount(self._login, accounts[0])

self._main.setTitle("aMSN 2 - Login")

self._login.show()

def unloadLogin(self):
Expand Down
8 changes: 7 additions & 1 deletion amsn2/ui/base/login.py
Expand Up @@ -23,7 +23,13 @@ def setAccounts(self, accountviews):
raise NotImplementedError

def signin(self):
""" This method will be called when the core needs the login window to start the signin process """
""" This method will be called when the core needs the login window to start the signin process.
This is intended only to change the look of the login window. """
raise NotImplementedError

def signout(self):
""" This method will be called when the core needs the login window to stop the signin process.
This is intended only to change the look of the login window. """
raise NotImplementedError

def onConnecting(self, progress, message):
Expand Down
10 changes: 2 additions & 8 deletions amsn2/ui/front_ends/gtk/login.py
Expand Up @@ -208,10 +208,10 @@ def __animation(self):

def __login_clicked(self, *args):
if self.login:
self.signout()
self._amsn_core.signOutOfAccount()
else:
self.accountview = self.__get_account()
self.signin()
self._amsn_core.signinToAccount(self, self.accountview)

def show(self):
if self.user.get_active_text() == "":
Expand Down Expand Up @@ -286,14 +286,9 @@ def setAccounts(self, accountviews):
# first in the list, default
self.__switch_to_account(self._account_views[0].email)

if self.accountview.autologin:
self.signin()

def signout(self):
self.__show_boxes(False)

self._amsn_core.signOutOfAccount()

def __get_account(self):
if self.user.get_active_text() == "":
self.user.grab_focus()
Expand Down Expand Up @@ -322,7 +317,6 @@ def __get_account(self):

def signin(self):
self.__show_boxes(True)
self._amsn_core.signinToAccount(self, self.accountview)

def onConnecting(self, progress, message):
self.status.set_text(message)
Expand Down

0 comments on commit 16a6ea3

Please sign in to comment.