private bool TestAccount(TraktAuthenticationToken token) { // test account by requesting the user settings var response = TraktAPI.TraktAPI.GetUserSettings(); if (response == null || response.User == null) { GUIUtils.ShowNotifyDialog(Translation.Error, Translation.FailedOnlineSettings); return(false); } else { // Save New Account Settings TraktSettings.Username = response.User.Username; TraktSettings.OnlineSettings = response; TraktSettings.AccountStatus = ConnectionState.Connected; InitProperties(); // clear caches // watchlists are stored by user so dont need clearing. GUINetwork.ClearCache(); GUICalendarTV.ClearCache(); GUIRecommendationsMovies.ClearCache(); GUIRecommendationsShows.ClearCache(); // clear any stored user data TraktCache.ClearSyncCache(); // persist settings TraktSettings.SaveSettings(false); return(true); } }
private void DisconnectAccount() { TraktLogger.Info("Disconnecting Account: {0}", TraktSettings.Username); // clear account settings TraktSettings.Username = string.Empty; TraktSettings.Password = string.Empty; TraktSettings.AccountStatus = ConnectionState.Disconnected; InitProperties(); // clear caches // watchlists are stored by user so dont need clearing. GUINetwork.ClearCache(); GUICalendar.ClearCache(); GUIRecommendationsMovies.ClearCache(); GUIRecommendationsShows.ClearCache(); // clear any stored user data TraktCache.ClearSyncCache(); }
private void DisconnectAccount() { TraktLogger.Info("Revoking application access to trakt.tv account"); GUIBackgroundTask.Instance.ExecuteInBackgroundAndCallback(() => { TraktAPI.TraktAPI.RevokeToken(); return(true); }, delegate(bool success, object result) { if (success) { // clear account settings TraktSettings.Username = string.Empty; TraktSettings.UserAccessToken = string.Empty; TraktSettings.UserAccessTokenExpiry = string.Empty; TraktSettings.UserRefreshToken = string.Empty; TraktSettings.AccountStatus = ConnectionState.Disconnected; InitProperties(); // clear caches // watchlists are stored by user so dont need clearing. GUINetwork.ClearCache(); GUICalendarTV.ClearCache(); GUIRecommendationsMovies.ClearCache(); GUIRecommendationsShows.ClearCache(); // clear any stored user data TraktCache.ClearSyncCache(); // persist settings TraktSettings.SaveSettings(false); } }, Translation.AuthorizingApplication, false); }
private void TestAccount(TraktAuthentication account) { TraktUserToken response = null; if (NewAccount) { // No longer supported with v2 API. //if (lblTestConnect != null) // GUIControl.SetControlLabel(GetID, lblTestConnect.GetID, Translation.CreatingAccount); //GUIWindowManager.Process(); //response = TraktAPI.v1.TraktAPI.CreateAccount(account); } else { if (lblTestConnect != null) { GUIControl.SetControlLabel(GetID, lblTestConnect.GetID, Translation.SigningIntoAccount); } GUIWindowManager.Process(); response = TraktAPI.TraktAPI.Login(account.ToJSON()); } if (response == null || string.IsNullOrEmpty(response.Token)) { GUIUtils.ShowNotifyDialog(Translation.Error, Translation.FailedLogin); if (lblTestConnect != null) { GUIControl.SetControlLabel(GetID, lblTestConnect.GetID, string.Empty); } } else { // Save User Token TraktAPI.TraktAPI.UserToken = response.Token; // Save New Account Settings TraktSettings.Username = account.Username; TraktSettings.Password = account.Password; if (!TraktSettings.UserLogins.Exists(u => u.Username == TraktSettings.Username)) { TraktSettings.UserLogins.Add(new TraktAuthentication { Username = TraktSettings.Username, Password = TraktSettings.Password }); } TraktSettings.AccountStatus = ConnectionState.Connected; HideAccountControls(); InitProperties(); // clear caches // watchlists are stored by user so dont need clearing. GUINetwork.ClearCache(); GUICalendar.ClearCache(); GUIRecommendationsMovies.ClearCache(); GUIRecommendationsShows.ClearCache(); // clear any stored user data TraktCache.ClearSyncCache(); } }