Exemplo n.º 1
0
        private void btnRemoveView_Click(object sender, EventArgs e) {
            if (availViews.Count == 0)
                return;
            
            // Get Selected View from list
            selectedView = Helper.getElementFromList<logicalView, string>((string)_availViews.SelectedItem, "Name", 0, availViews);
            
            // Confirm Delete
            string message = string.Format("Are you sure you want to delete view \"{0}\"?",selectedView.prettyName);
            DialogResult result = MessageBox.Show(message, "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

			if (result == DialogResult.No)
				return;

            // if view is a tagged view, remove series attached to view
            if (selectedView.IsTaggedView)
            {
                // Get list of series in view
                SQLCondition conditions = new SQLCondition();
                conditions.Add(new DBOnlineSeries(), DBOnlineSeries.cViewTags, selectedView.Name, SQLConditionType.Like);
                List<DBSeries> series = DBSeries.Get(conditions);

                foreach (DBSeries s in series)
                {
                    s[DBOnlineSeries.cViewTags] = Helper.GetSeriesViewTags(s, false, selectedView.Name);
                    s.Commit();

                    // Remove from online database
                    if (selectedView.Name == DBView.cTranslateTokenOnlineFavourite)
                        Online_Parsing_Classes.OnlineAPI.ConfigureFavourites(false, DBOption.GetOptions(DBOption.cOnlineUserID), s[DBOnlineSeries.cID]);                    
                }
            }

            // Get All current Views
            DBView[] views = DBView.getAll(true);

            // Remove all Rows from Database
            DBView.ClearAll();

            int index = 0;

            // Add Rows back excluding deleted one
            foreach (DBView view in views) {
                if (view[DBView.cIndex] != int.Parse(selectedView.m_uniqueID)) {
                    DBView newView = new DBView();

                    newView[DBView.cIndex] = index;
                    newView[DBView.cEnabled] = view[DBView.cEnabled];
                    newView[DBView.cSort] = view[DBView.cSort];
                    newView[DBView.cTransToken] = view[DBView.cTransToken];
                    newView[DBView.cPrettyName] = view[DBView.cPrettyName];
                    newView[DBView.cViewConfig] = view[DBView.cViewConfig];
                    newView[DBView.cTaggedView] = view[DBView.cTaggedView];
					newView[DBView.cParentalControl] = view[DBView.cParentalControl];
                    newView.Commit();
                    index++;
                }
            }
            
            // Reload List and available Views
            LoadViews();
            
			// Select First Item in list
			if (_availViews.Items.Count > 0)
				_availViews.SelectedIndex = 0;
        }
Exemplo n.º 2
0
 private void viewChanged()
 {
     if (!pauseViewConfigSave)
     {
         selectedView = Helper.getElementFromList<logicalView, string>((string)_availViews.SelectedItem, "Name", 0, availViews);
         if (selectedView != null)
         {
             selectedView.prettyName = view_selectedName.Text;
             selectedView.m_Enabled = checkCurViewEnabled.Checked;
             selectedView.ParentalControl = checkBoxParentalControl.Checked;
             selectedView.saveToDB();
             LoadViews();
             for (int i = 0; i < availViews.Count; i++) {
                 if (availViews[i].m_uniqueID == selectedView.m_uniqueID) {
                     pauseViewConfigSave = true;
                     _availViews.SelectedIndex = i;
                     pauseViewConfigSave = false;
                     break;
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
        private bool switchView(logicalView view)
        {
            // Handle if view has been removed
            if (view == null) view = m_allViews[0];

            // Check if View has Parental Control enabled
            if (!CheckParentalControls(view))
            {
                // We can't show a dialog on top when there is no main window
                if (!m_bPluginLoaded && m_bShowLastActiveModule && (m_iLastActiveModule == GetID))
                {
                    MPTVSeriesLog.Write("Unable to Show PinCode Dialog, MediaPortal not ready, returning to Home screen");
                    m_bPluginLoaded = true;
                    return false;
                }

                // Prompt to choose UnProtected View
                return showViewSwitchDialog();
            }

            MPTVSeriesLog.Write("Switching view to " + view.Name);
            m_CurrLView = view;

            if (fanartSet) DisableFanart();

            m_CurrViewStep = 0; // we always start out at step 0
            m_stepSelection = null;
            m_stepSelections = new List<string[]>();
            m_stepSelections.Add(new string[] { null });
            setNewListLevelOfCurrView(0);

            // set the skin labels
            m_stepSelectionPretty.Clear();
            setViewLabels();

            DBOption.SetOptions("lastView", view.Name); // to remember next time the plugin is entered
            return true;
        }
Exemplo n.º 4
0
        private void _availViews_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!pauseViewConfigSave)
            {
                logicalView.s_cachePrettyName = false;
                pauseViewConfigSave = true;
                view_selectedName.Text = string.Empty;
                view_selStepsList.Items.Clear();

                selectedView = Helper.getElementFromList<logicalView, string>((string)_availViews.SelectedItem, "Name", 0, availViews);
                view_selectedName.Text = selectedView.prettyName;
                checkCurViewEnabled.Checked = selectedView.m_Enabled;
                checkBoxParentalControl.Checked = selectedView.ParentalControl;             

                foreach (string step in Helper.getPropertyListFromList<logicalViewStep, String>("Name", selectedView.m_steps))
                    view_selStepsList.Items.Add(step);
                
                pauseViewConfigSave = false;

                // Enable 'Edit' button for Simple Views
                // TODO: allow editing of advanced views when conditional GUI is complete
                if (selectedView.IsTaggedView) {
                    buttonEditView.Enabled = true;
                } else {
                    buttonEditView.Enabled = false;
                }
            }
        }
Exemplo n.º 5
0
        private bool CheckParentalControls(logicalView view)
        {
            bool pinInCorrect = true;

            if (view.ParentalControl && logicalView.IsLocked)
            {
                // We can't show a dialog on top when there is no main window
                if (!m_bPluginLoaded && m_bShowLastActiveModule && (m_iLastActiveModule == GetID))
                {
                    return false;
                }

                // Update Ugly Current View Property if not yet set
                if (TVSeriesPlugin.getGUIProperty(guiProperty.CurrentView.ToString()).Length == 0)
                {
                    setGUIProperty(guiProperty.CurrentView, Translation.ViewIsLocked);
                    setGUIProperty(guiProperty.SimpleCurrentView, Translation.ViewIsLocked);
                }

                MPTVSeriesLog.Write(string.Format("View: {0} is locked, prompting for PinCode", view.prettyName));

                // Check if Graphical PinCode dialog exists

                if (System.IO.File.Exists(GUIGraphicsContext.Skin + @"\TVSeries.PinCodeDialog.xml"))
                {
                    try
                    {
                        GUIPinCode pinCodeDlg = (GUIPinCode)GUIWindowManager.GetWindow(GUIPinCode.ID);
                        pinCodeDlg.Reset();

                        // Initialize Dialog
                        pinCodeDlg.MasterCode = DBOption.GetOptions(DBOption.cParentalControlPinCode);
                        pinCodeDlg.EnteredPinCode = string.Empty;
                        pinCodeDlg.SetHeading(Translation.PinCode);
                        pinCodeDlg.SetLine(1, string.Format(Translation.PinCodeDlgLabel1, view.prettyName));
                        pinCodeDlg.SetLine(2, Translation.PinCodeDlgLabel2);
                        pinCodeDlg.Message = Translation.PinCodeMessageIncorrect;
                        pinCodeDlg.DoModal(pinCodeDlg.GetID); //should this be (GUIWindowManager.ActiveWindow)?
                        if (!pinCodeDlg.IsCorrect)
                        {
                            // Prompt to choose UnProtected View
                            MPTVSeriesLog.Write("PinCode entered was incorrect, showing Views Menu");
                            return false;
                        }
                        else
                        {
                            // reset timer
                            ResetParentalControlTimer();
                            logicalView.IsLocked = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        MPTVSeriesLog.Write(string.Format("An Error occurred in the PinCode Dialog: {0}", ex.Message));
                        return false;
                    }
                }
                else
                {
                    // Use Virtual Keyboard if skin doesnt exist
                    while (pinInCorrect)
                    {
                        GetStringFromUserDescriptor Keyboard = new GetStringFromUserDescriptor();
                        Keyboard.Text = string.Empty;
                        Keyboard.IsPassword = true;
                        string enteredPinCode = string.Empty;
                        string pinMasterCode = DBOption.GetOptions(DBOption.cParentalControlPinCode);
                        if (pinMasterCode.Length == 0) break;

                        if (this.GetStringFromUser(Keyboard, out enteredPinCode) == ReturnCode.OK)
                        {
                            // Convert SMS Input to Numbers
                            string smsCode = string.Empty;
                            if (enteredPinCode.Length == 4)
                            {
                                for (int i = 0; i < 4; i++)
                                {
                                    smsCode += Helper.ConvertSMSInputToPinCode(enteredPinCode[i].ToString());
                                }
                            }
                            // Check if PinCode is correct
                            if (smsCode != pinMasterCode)
                            {
                                ShowPinCodeIncorrectMessage();
                                pinInCorrect = true;
                            }
                            else
                            {
                                // Cease to prompt for PinCode for remainder of session
                                logicalView.IsLocked = false;
                                pinInCorrect = false;

                                // reset timer
                                ResetParentalControlTimer();
                            }
                        }
                        else
                        {
                            return false;
                        }
                    }
                }
            }
            return true;
        }