private void btnAuthoriseApplication_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(TraktSettings.UserAccessToken))
            {
                var AuthDialog = new AuthorizationPopup();

                AuthDialog.ShowDialog(this);
                if (AuthDialog.DialogResult == DialogResult.OK)
                {
                    lblAuthorizeApplication.Visible = false;
                    btnAuthoriseApplication.Text    = "Revoke Access";
                    TraktSettings.SaveSettings(false);
                }
                else
                {
                    btnAuthoriseApplication.Text = "Authorize Application...";
                    ClearAuthorisationProperties();
                }
            }
            else
            {
                TraktLogger.Info("Revoking application access to trakt.tv account");

                TraktAPI.TraktAPI.RevokeToken();
                ClearAuthorisationProperties();

                TraktLogger.Info("Application access has now been revoked from using trakt.tv account");
            }
        }
示例#2
0
        public Configuration()
        {
            InitializeComponent();
            this.Text = "Trakt Configuration v" + TraktSettings.Version;

            TraktSettings.PerformMaintenance();
            TraktSettings.LoadSettings();

            #region load settings
            tbUsername.Text = TraktSettings.Username;
            // since password is Sha1, just show a dummy password
            tbPassword.Text = string.IsNullOrEmpty(TraktSettings.Password) ? string.Empty : TraktSettings.Password.Substring(0, 10);

            List <KeyValuePair <int, string> > items = new List <KeyValuePair <int, string> >();
            items.Add(new KeyValuePair <int, string>(TraktSettings.MovingPictures, "Moving Pictures"));
            items.Add(new KeyValuePair <int, string>(TraktSettings.TVSeries, "MP-TVSeries"));
            items.Add(new KeyValuePair <int, string>(TraktSettings.MyVideos, "My Videos"));
            items.Add(new KeyValuePair <int, string>(TraktSettings.MyFilms, "My Films"));
            items.Add(new KeyValuePair <int, string>(TraktSettings.OnlineVideos, "OnlineVideos"));
            items.Add(new KeyValuePair <int, string>(TraktSettings.MyAnime, "My Anime"));
            items.Add(new KeyValuePair <int, string>(TraktSettings.MyTVRecordings, "My TV Recordings"));
            items.Add(new KeyValuePair <int, string>(TraktSettings.MyTVLive, "My TV Live"));
            items.Add(new KeyValuePair <int, string>(TraktSettings.ForTheRecordRecordings, "4TR TV Recordings"));
            items.Add(new KeyValuePair <int, string>(TraktSettings.ForTheRecordTVLive, "4TR TV Live"));
            items.Add(new KeyValuePair <int, string>(TraktSettings.ArgusRecordings, "Argus TV Recordings"));
            items.Add(new KeyValuePair <int, string>(TraktSettings.ArgusTVLive, "Argus TV Live"));

            // add enabled ones to top of list, sort by priority
            foreach (var item in items.Where(p => p.Key >= 0).OrderBy(p => p.Key))
            {
                clbPlugins.Items.Add(item.Value, true);
            }
            // add disabled ones last, sort by name
            foreach (var item in items.Where(p => p.Key < 0).OrderBy(p => p.Value))
            {
                clbPlugins.Items.Add(item.Value, false);
            }

            cbTraktSyncLength.SelectedItem     = (TraktSettings.SyncTimerLength / 3600000).ToString();
            cbMovingPicturesCategories.Checked = TraktSettings.MovingPicturesCategories;
            cbMovingPicturesFilters.Checked    = TraktSettings.MovingPicturesFilters;
            cbMyFilmsCategories.Checked        = TraktSettings.MyFilmsCategories;
            cbKeepInSync.Checked  = TraktSettings.KeepTraktLibraryClean;
            cbSyncLibrary.Checked = TraktSettings.SyncLibrary;
            cbSyncRatings.Checked = TraktSettings.SyncRatings;

            // disable controls if not applicable
            if (!TraktSettings.SyncLibrary)
            {
                cbKeepInSync.Enabled  = false;
                cbSyncRatings.Enabled = false;
            }

            #endregion

            // handle events now that we have populated default settings
            clbPlugins.ItemCheck   += new ItemCheckEventHandler(this.clbPlugins_ItemCheck);
            tbPassword.TextChanged += new EventHandler(this.tbPassword_TextChanged);
        }
 private void ClearAuthorisationProperties()
 {
     lblAuthorizeApplication.Visible     = true;
     btnAuthoriseApplication.Text        = "Authorize Application...";
     TraktSettings.Username              = string.Empty;
     TraktSettings.UserAccessToken       = string.Empty;
     TraktSettings.UserAccessTokenExpiry = string.Empty;
     TraktSettings.UserRefreshToken      = string.Empty;
     TraktSettings.SaveSettings(false);
 }
示例#4
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (TraktSettings.KeepTraktLibraryClean && (TraktSettings.MoviePluginCount > 1 || TraktSettings.TvShowPluginCount > 1))
     {
         // warn and disable clean library
         string message = "You can not have 'Clean Library' option enabled with more than one movie or show plugin enabled. Option will be disabled.";
         MessageBox.Show(message, "trakt", MessageBoxButtons.OK, MessageBoxIcon.Information);
         TraktSettings.KeepTraktLibraryClean = false;
     }
     TraktSettings.SaveSettings();
     this.Close();
 }
        private void Extensions_OnSettingsChanged(string guid)
        {
            // settings change occured
            if (guid == TraktSettings.cGuid)
            {
                TraktLogger.Info("Settings updated externally");

                // re-load settings
                TraktSettings.loadSettings();

                // re-initialize sync Interval
                TraktPlugin.ChangeSyncTimer(TraktSettings.SyncTimerLength, TraktSettings.SyncTimerLength);

                // update any internal plugin settings required
                TraktSettings.UpdateInternalPluginSettings();
            }
        }
        private void CloseConfig()
        {
            if (TraktSettings.KeepTraktLibraryClean && (TraktSettings.MoviePluginCount > 1 || TraktSettings.TvShowPluginCount > 1))
            {
                // warn and disable clean library
                string message = "You can not have 'Clean Library' option enabled with more than one movie or show plugin enabled. Option will be disabled.";
                MessageBox.Show(message, "trakt", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TraktSettings.KeepTraktLibraryClean = false;
            }

            // disable parental controls if not pin code not entered
            if (txtPinCode.TextLength < 4)
            {
                TraktSettings.ParentalControlsEnabled = false;
            }

            TraktSettings.SaveSettings(false);

            TraktLogger.Info("Exiting Configuration");
            this.Close();
        }
        public Configuration(string[] args)
        {
            TraktLogger.OnLogReceived += new TraktLogger.OnLogReceivedDelegate(OnLogMessage);

            InitializeComponent();
            this.Text = "Trakt Configuration v" + TraktSettings.Version;

            ParseCommandLine(args);

            TraktSettings.PerformMaintenance();
            TraktSettings.LoadSettings(false);

            #region Load Settings
            tbUsername.Text = TraktSettings.Username;
            tbPassword.Text = TraktSettings.Password;

            List <KeyValuePair <int, string> > items = new List <KeyValuePair <int, string> >();
            items.Add(new KeyValuePair <int, string>(TraktSettings.MovingPictures, "Moving Pictures"));
            items.Add(new KeyValuePair <int, string>(TraktSettings.TVSeries, "MP-TVSeries"));
            items.Add(new KeyValuePair <int, string>(TraktSettings.MyVideos, "My Videos"));
            items.Add(new KeyValuePair <int, string>(TraktSettings.MyFilms, "My Films"));
            items.Add(new KeyValuePair <int, string>(TraktSettings.OnlineVideos, "OnlineVideos"));
            items.Add(new KeyValuePair <int, string>(TraktSettings.MyTVRecordings, "My TV Recordings"));
            items.Add(new KeyValuePair <int, string>(TraktSettings.MyTVLive, "My TV Live"));
            items.Add(new KeyValuePair <int, string>(TraktSettings.ArgusRecordings, "Argus TV Recordings"));
            items.Add(new KeyValuePair <int, string>(TraktSettings.ArgusTVLive, "Argus TV Live"));

            // add enabled ones to top of list, sort by priority
            foreach (var item in items.Where(p => p.Key >= 0).OrderBy(p => p.Key))
            {
                clbPlugins.Items.Add(item.Value, true);
            }
            // add disabled ones last, sort by name
            foreach (var item in items.Where(p => p.Key < 0).OrderBy(p => p.Value))
            {
                clbPlugins.Items.Add(item.Value, false);
            }

            cbMovingPicturesCategories.Checked = TraktSettings.MovingPicturesCategories;
            cbMovingPicturesFilters.Checked    = TraktSettings.MovingPicturesFilters;
            cbMyFilmsCategories.Checked        = TraktSettings.MyFilmsCategories;
            cbKeepInSync.Checked   = TraktSettings.KeepTraktLibraryClean;
            cbSyncLibrary.Checked  = TraktSettings.SyncLibrary;
            cbSyncRatings.Checked  = TraktSettings.SyncRatings;
            cbSyncPlayback.Checked = TraktSettings.SyncPlayback;
            cbSyncPlaybackOnEnterPlugin.Checked = TraktSettings.SyncPlaybackOnEnterPlugin;

            numSyncInterval.Value    = TraktSettings.SyncTimerLength;
            numSyncResumeDelta.Value = TraktSettings.SyncResumeDelta;

            cbParentControls.Checked = TraktSettings.ParentalControlsEnabled;
            txtPinCode.Text          = TraktSettings.ParentalControlsPinCode;
            txtPinCode.Enabled       = TraktSettings.ParentalControlsEnabled == true;

            cbParentalControlsTime.Checked = TraktSettings.ParentalIgnoreAfterEnabled;
            dtParentalControlsTime.Text    = TraktSettings.ParentalIgnoreAfterTime;
            dtParentalControlsTime.Enabled = TraktSettings.ParentalIgnoreAfterEnabled;

            cbParentalIgnoreMovieCertifications.Checked = TraktSettings.ParentalIgnoreMovieRatingEnabled;
            cboMovieCertifications.Text    = TraktSettings.ParentalIgnoreMovieRating;
            cboMovieCertifications.Enabled = TraktSettings.ParentalIgnoreMovieRatingEnabled;

            cbParentalIgnoreShowCertifications.Checked = TraktSettings.ParentalIgnoreShowRatingEnabled;
            cboTVCertifications.Text    = TraktSettings.ParentalIgnoreShowRating;
            cboTVCertifications.Enabled = TraktSettings.ParentalIgnoreShowRatingEnabled;

            // disable controls if not applicable
            if (!TraktSettings.SyncLibrary)
            {
                cbKeepInSync.Enabled  = false;
                cbSyncRatings.Enabled = false;
            }

            if (!TraktSettings.SyncPlayback)
            {
                numSyncResumeDelta.Enabled          = false;
                lblSyncResumeDelta.Enabled          = false;
                cbSyncPlaybackOnEnterPlugin.Enabled = false;
            }

            int selectedItem = 0;
            int i            = 0;
            foreach (var language in TraktSettings.ImageLanguages)
            {
                cboPreferredImageLanguage.Items.Add(language);

                if (language.TwoLetterCode == TraktSettings.TmdbPreferredImageLanguage)
                {
                    selectedItem = i;
                }

                i++;
            }
            cboPreferredImageLanguage.SelectedIndex = selectedItem;

            #endregion

            // handle events now that we have populated default settings
            clbPlugins.ItemCheck   += new ItemCheckEventHandler(this.clbPlugins_ItemCheck);
            tbPassword.TextChanged += new EventHandler(this.tbPassword_TextChanged);
        }