From b161ec6f4e9166c357db6cd488ac135718824dca Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Tue, 20 Sep 2016 00:26:15 -0500 Subject: [PATCH] Fix double connection test Remote old preference dialog. Update token revoked behavior. --- resources/lib/connectmanager.py | 19 ++- resources/lib/dialogs/loginmanual.py | 7 +- resources/lib/userclient.py | 8 +- .../script-emby-kodi-UserPreferences.xml | 129 ------------------ 4 files changed, 20 insertions(+), 143 deletions(-) delete mode 100644 resources/skins/default/1080i/script-emby-kodi-UserPreferences.xml diff --git a/resources/lib/connectmanager.py b/resources/lib/connectmanager.py index 1d8cf0a8..08936af5 100644 --- a/resources/lib/connectmanager.py +++ b/resources/lib/connectmanager.py @@ -153,15 +153,18 @@ class ConnectManager(object): dialog.doModal() if dialog.is_user_selected(): + user = dialog.get_user() + username = user['Name'] + if user['HasPassword']: log.debug("User has password, present manual login") try: - return self.login_manual(server_address, user) + return self.login_manual(server_address, username) except RuntimeError: return self.login(server) else: - user = self.emby.loginUser(server_address, user['Name']) + user = self.emby.loginUser(server_address, username) self._connect.onAuthenticated(user) return user @@ -188,5 +191,13 @@ class ConnectManager(object): raise RuntimeError("User is not authenticated") def update_token(self, servers, server): - self._connect.credentialProvider.addOrUpdateServer(servers, server) - self.update_state() + + credentials = self._connect.credentialProvider.getCredentials() + updated_server = self._connect.credentialProvider.addOrUpdateServer(servers, server) + + for server in self.get_state()['Servers']: + if server['Id'] == updated_server['Id']: + # Update token saved in current state + server.update(updated_server) + # Update the token in data.txt + self._connect.credentialProvider.getCredentials(credentials) diff --git a/resources/lib/dialogs/loginmanual.py b/resources/lib/dialogs/loginmanual.py index aa34986b..7db1adcf 100644 --- a/resources/lib/dialogs/loginmanual.py +++ b/resources/lib/dialogs/loginmanual.py @@ -35,6 +35,7 @@ class LoginManual(xbmcgui.WindowXMLDialog): _user = None error = None + username = None def __init__(self, *args, **kwargs): @@ -49,7 +50,7 @@ class LoginManual(xbmcgui.WindowXMLDialog): self.server = server def set_user(self, user): - self.user = user or {} + self.username = user or {} def get_user(self): return self._user @@ -63,8 +64,8 @@ class LoginManual(xbmcgui.WindowXMLDialog): self.user_field = self._add_editcontrol(725, 400, 40, 500) self.password_field = self._add_editcontrol(725, 475, 40, 500, password=1) - if "Name" in self.user: - self.user_field.setText(self.user['Name']) + if self.username: + self.user_field.setText(self.username) self.setFocus(self.password_field) else: self.setFocus(self.user_field) diff --git a/resources/lib/userclient.py b/resources/lib/userclient.py index f2f44c96..d43a4f55 100644 --- a/resources/lib/userclient.py +++ b/resources/lib/userclient.py @@ -173,15 +173,9 @@ class UserClient(threading.Thread): ##### AUTHENTICATE USER ##### server = self.get_server() username = self.get_username().decode('utf-8') - users = self.emby.getUsers(server) - user_found = None - for user in users: - if username == user['Name']: - user_found = user - break try: - user = self.connectmanager.login_manual(server, user_found) + user = self.connectmanager.login_manual(server, username) except RuntimeError: window('emby_serverStatus', value="stop") self._auth = False diff --git a/resources/skins/default/1080i/script-emby-kodi-UserPreferences.xml b/resources/skins/default/1080i/script-emby-kodi-UserPreferences.xml deleted file mode 100644 index 329fd9a4..00000000 --- a/resources/skins/default/1080i/script-emby-kodi-UserPreferences.xml +++ /dev/null @@ -1,129 +0,0 @@ - - - 8011 - 0 - - - 560 - 140 - 800 - 800 - - - box.png - 100 - - - box.png - 100 - 700 - - - user image - 80 - 100 - - - 90 - 30 - 40 - 20% - left - font16 - ffeeeeee - - - - 320 - 30 - left - 40 - 100% - font16 - ffeeeeee - - - - separator - -10 - 103 - 101% - 1 - separator.png - - - 50 - 600 - vertical - left - 20 - - - 8 - 8012 - 8012 - 100 - 785 - left - 70 - radio-on.png - radio-off.png - white.png - 750 - 32 - 32 - 30 - B3dddddd - - - - - - - separator - 70 - -10 - 101% - 1 - separator.png - - - Save - 150 - 20 - 230 - 8011 - 8013 - 8013 - font14 - - FFededed - B3dddddd - FF000000 - 40 - ff333333 - box.png - box.png - - - Cancel - 430 - 20 - 230 - 8011 - 8012 - 8012 - font14 - - FFededed - B3dddddd - FF000000 - 40 - ff333333 - box.png - box.png - - - - - \ No newline at end of file