コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
        }