diff --git a/amsn2/core/amsn.py b/amsn2/core/amsn.py index ca47e8c1..51ee88fe 100644 --- a/amsn2/core/amsn.py +++ b/amsn2/core/amsn.py @@ -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): diff --git a/amsn2/core/userinterface_manager.py b/amsn2/core/userinterface_manager.py index f5f083cd..c7e8f0c1 100644 --- a/amsn2/core/userinterface_manager.py +++ b/amsn2/core/userinterface_manager.py @@ -55,9 +55,6 @@ 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 @@ -65,7 +62,14 @@ def loadLogin(self, accounts): 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): diff --git a/amsn2/ui/base/login.py b/amsn2/ui/base/login.py index c12300ed..28d63b4b 100644 --- a/amsn2/ui/base/login.py +++ b/amsn2/ui/base/login.py @@ -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): diff --git a/amsn2/ui/front_ends/gtk/login.py b/amsn2/ui/front_ends/gtk/login.py index 89d90708..a2f0226c 100644 --- a/amsn2/ui/front_ends/gtk/login.py +++ b/amsn2/ui/front_ends/gtk/login.py @@ -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() == "": @@ -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() @@ -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)