public void SetValue(string key, string value, bool encrypt = false)
 {
     using (Settings settings = new MPSettings())
     {
         if (encrypt) value = EncryptionUtils.SymEncryptLocalPC(value);
         if (string.IsNullOrWhiteSpace(value))
             settings.RemoveEntry(PluginConfiguration.CFG_SECTION, key);
         else
             settings.SetValue(PluginConfiguration.CFG_SECTION, key, value);
     }
 }
    private void SaveSettings()
    {
      using (Settings xmlwriter = new MPSettings())
      {
        xmlwriter.SetValueAsBool("general", "autochangerefreshrate", btnEnableDynamicRefreshRate.Selected);
        xmlwriter.SetValueAsBool("general", "notify_on_refreshrate", btnNotify.Selected);
        xmlwriter.SetValueAsBool("general", "use_default_hz", btnUseDefaultRefreshRate.Selected);
        xmlwriter.SetValueAsBool("general", "devicereset", btnUseDeviceReset.Selected);
        xmlwriter.SetValueAsBool("general", "force_refresh_rate", btnForceRefreshRateChange.Selected);
        
        if (_defaultHzIndex >= 0)
        {
          string rate = RefreshRateData(lcRefreshRatesList.ListItems[_defaultHzIndex]).Refreshrate;
          xmlwriter.SetValue("general", "default_hz", rate);
        }
        else
        {
          xmlwriter.SetValue("general", "default_hz", string.Empty);
        }

        //delete all refreshrate entries, then re-add them.
        Settings xmlreader = new MPSettings();
        for (int i = 1; i < 100; i++)
        {
          string name = xmlreader.GetValueAsString("general", "refreshrate0" + Convert.ToString(i) + "_name", "");

          if (string.IsNullOrEmpty(name))
          {
            continue;
          }

          xmlwriter.RemoveEntry("general", name + "_fps");
          xmlwriter.RemoveEntry("general", name + "_hz");
          xmlwriter.RemoveEntry("general", "refreshrate0" + Convert.ToString(i) + "_ext");
          xmlwriter.RemoveEntry("general", "refreshrate0" + Convert.ToString(i) + "_name");
        }

        int j = 1;
        foreach (GUIListItem item in lcRefreshRatesList.ListItems)
        {
          string name = RefreshRateData(item).Name;
          string fps = RefreshRateData(item).FrameRate;
          string hz = RefreshRateData(item).Refreshrate;
          string extCmd = RefreshRateData(item).Action;

          xmlwriter.SetValue("general", name + "_fps", fps);
          xmlwriter.SetValue("general", name + "_hz", hz);
          xmlwriter.SetValue("general", "refreshrate0" + Convert.ToString(j) + "_ext", extCmd);
          xmlwriter.SetValue("general", "refreshrate0" + Convert.ToString(j) + "_name", name);
          j++;
        }
      }
    }
Beispiel #3
0
    public static void SetDefaultGrabber()
    {
      GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);

      if (dlg == null)
      {
        return;
      }

      dlg.Reset();
      dlg.SetHeading(1263); // menu

      // read index file
      if (!File.Exists(_grabberIndexFile))
      {
        GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
        dlgOk.SetHeading(257);
        dlgOk.SetLine(1, GUILocalizeStrings.Get(1261)); // No grabber index found
        dlgOk.DoModal(GUIWindowManager.ActiveWindow);
        return;
      }

      _grabberList = new Dictionary<string, ComboBoxItemDatabase>();

      Directory.CreateDirectory(IMDB.ScriptDirectory);
      DirectoryInfo di = new DirectoryInfo(IMDB.ScriptDirectory);

      FileInfo[] fileList = di.GetFiles("*.csscript", SearchOption.AllDirectories);
      GUIWaitCursor.Show();

      foreach (FileInfo f in fileList)
      {
        try
        {
          CSScript.GlobalSettings.AddSearchDir(AppDomain.CurrentDomain.BaseDirectory);

          using (AsmHelper script = new AsmHelper(CSScript.Compile(f.FullName), "Temp", true))
          {
            script.ProbingDirs = CSScript.GlobalSettings.SearchDirs.Split(';');
            IIMDBScriptGrabber grabber = (IIMDBScriptGrabber) script.CreateObject("Grabber");

            ComboBoxItemDatabase item = new ComboBoxItemDatabase();
            item.Database = Path.GetFileNameWithoutExtension(f.FullName);
            item.Language = grabber.GetLanguage();
            item.Limit = IMDB.DEFAULT_SEARCH_LIMIT.ToString();
            item.Name = grabber.GetName();
            _grabberList.Add(item.Database, item);
          }
        }
        catch (Exception ex)
        {
          Log.Error("Script grabber error file: {0}, message : {1}", f.FullName, ex.Message);
        }
      }

      string defaultDatabase = string.Empty;
      int defaultIndex = 0;
      int dbNumber;

      using (Profile.Settings xmlreader = new MPSettings())
      {
        defaultDatabase = xmlreader.GetValueAsString("moviedatabase", "database" + 0, "IMDB");
        dbNumber = xmlreader.GetValueAsInt("moviedatabase", "number", 0);
      }

      foreach (KeyValuePair<string, ComboBoxItemDatabase> grabber in _grabberList)
      {
        dlg.Add(grabber.Value.Name + " - " + grabber.Value.Language);

        if (defaultDatabase == grabber.Key)
        {
          dlg.SelectedLabel = defaultIndex;
        }
        else
        {
          defaultIndex++;
        }
      }

      GUIWaitCursor.Hide();

      dlg.DoModal(GUIWindowManager.ActiveWindow);

      if (dlg.SelectedId == -1)
      {
        return;
      }

      using (Profile.Settings xmlwriter = new MPSettings())
      {
        KeyValuePair<string, ComboBoxItemDatabase> grabber = _grabberList.ElementAt(dlg.SelectedLabel);


        if (grabber.Key != "IMDB")
        {
          if (dbNumber == 0)
          {
            dbNumber = 1;
          }
          xmlwriter.SetValue("moviedatabase", "number", dbNumber);
          xmlwriter.SetValue("moviedatabase", "database" + 0, grabber.Key);
          xmlwriter.SetValue("moviedatabase", "title" + 0, grabber.Value.Name);
          xmlwriter.SetValue("moviedatabase", "language" + 0, grabber.Value.Language);
          xmlwriter.SetValue("moviedatabase", "limit" + 0, 25);
        }
        else
        {
          for (int i = 0; i < 4; i++)
          {
            xmlwriter.SetValue("moviedatabase", "number", 0);
            xmlwriter.RemoveEntry("moviedatabase", "database" + i);
            xmlwriter.RemoveEntry("moviedatabase", "title" + i);
            xmlwriter.RemoveEntry("moviedatabase", "language" + i);
            xmlwriter.RemoveEntry("moviedatabase", "limit" + i);
          }
        }
      }

      IMDB.MovieInfoDatabase.ResetGrabber();
    }
    /// <summary>
    /// Loads the standby configuration
    /// </summary>
    private void LoadSettings()
    {
      bool changed = false;
      bool boolSetting;
      int intSetting;
      string stringSetting;
      PowerSetting powerSetting;

      Log.Debug("PS: LoadSettings()");

      // Load initial settings only once
      if (_settings == null)
      {
        using (Settings reader = new MPSettings())
        {

          // Check if update of old PS settings is necessary
          if (reader.GetValue("psclientplugin", "ExpertMode") == "")
          {
            // Initialise list of old and new settings names to update
            List<String[]> settingNames = new List<String[]>();
            settingNames.Add(new String[] { "homeonly", "HomeOnly" });
            settingNames.Add(new String[] { "idletimeout", "IdleTimeout" });
            settingNames.Add(new String[] { "shutdownenabled", "ShutdownEnabled" });
            settingNames.Add(new String[] { "shutdownmode", "ShutdownMode" });

            // Update settings names
            foreach (String[] settingName in settingNames)
            {
              String settingValue = reader.GetValue("psclientplugin", settingName[0]);
              if (settingValue != "")
              {
                reader.RemoveEntry("psclientplugin", settingName[0]);
                reader.SetValue("psclientplugin", settingName[1], settingValue);
              }
            }
          }

          _settings = new PowerSettings();
          changed = true;

          // Set constant values (needed for backward compatibility)
          _settings.ForceShutdown = false;
          _settings.ExtensiveLogging = false;
          _settings.PreNoShutdownTime = 300;
          _settings.CheckInterval = 15;

          // Check if we only should suspend in MP's home window
          boolSetting = reader.GetValueAsBool("psclientplugin", "HomeOnly", false);
          powerSetting = _settings.GetSetting("HomeOnly");
          powerSetting.Set<bool>(boolSetting);
          Log.Debug("PS: Only allow standby when on home window: {0}", boolSetting);

          // Get external command
          stringSetting = reader.GetValueAsString("psclientplugin", "Command", String.Empty);
          powerSetting = _settings.GetSetting("Command");
          powerSetting.Set<string>(stringSetting);
          Log.Debug("PS: Run command on power state change: {0}", stringSetting);

          // Check if we should unmute the master volume
          boolSetting = reader.GetValueAsBool("psclientplugin", "UnmuteMasterVolume", true);
          powerSetting = _settings.GetSetting("UnmuteMasterVolume");
          powerSetting.Set<bool>(boolSetting);
          Log.Debug("PS: Unmute master volume: {0}", boolSetting);

          // Detect single-seat
          string tvPluginDll = Config.GetSubFolder(Config.Dir.Plugins, "windows") + @"\" + "TvPlugin.dll";
          if (File.Exists(tvPluginDll))
          {
            string hostName = reader.GetValueAsString("tvservice", "hostname", String.Empty);
            if (hostName != String.Empty && PowerManager.IsLocal(hostName))
            {
              _singleSeat = true;
              Log.Info("PS: Detected single-seat setup - TV-Server on local system");
            }
            else if (hostName == String.Empty)
            {
              _singleSeat = false;
              Log.Info("PS: Detected standalone client setup - no TV-Server configured");
            }
            else
            {
              _singleSeat = false;
              Log.Info("PS: Detected remote client setup - TV-Server on \"{0}\"", hostName);

              RemotePowerControl.HostName = hostName;
              Log.Debug("PS: Set RemotePowerControl.HostName: {0}", hostName);
            }
          }
          else
          {
            _singleSeat = false;
            Log.Info("PS: Detected standalone client setup - no TV-Plugin installed");
          }

          // Standalone client has local standby / wakeup settings
          if (!_singleSeat)
          {
            // Check if PowerScheduler should actively put the system into standby
            boolSetting = reader.GetValueAsBool("psclientplugin", "ShutdownEnabled", false);
            _settings.ShutdownEnabled = boolSetting;
            Log.Debug("PS: PowerScheduler forces system to go to standby when idle: {0}", boolSetting);

            if (_settings.ShutdownEnabled)
            {
              // Check configured shutdown mode
              intSetting = reader.GetValueAsInt("psclientplugin", "ShutdownMode", 0);
              _settings.ShutdownMode = (ShutdownMode)intSetting;
              Log.Debug("PS: Shutdown mode: {0}", _settings.ShutdownMode.ToString());
            }

            // Get idle timeout
            if (_settings.ShutdownEnabled)
            {
              intSetting = reader.GetValueAsInt("psclientplugin", "IdleTimeout", 30);
              _settings.IdleTimeout = intSetting;
              Log.Debug("PS: Standby after: {0} minutes", intSetting);
            }

            // Check configured pre-wakeup time (can only be configured by editing MediaPortal.xml)
            intSetting = reader.GetValueAsInt("psclientplugin", "PreWakeupTime", 60);
            _settings.PreWakeupTime = intSetting;
            Log.Debug("PS: Pre-wakeup time: {0} seconds", intSetting);

            // Check configured pre-no-standby time (can only be configured by editing MediaPortal.xml)
            intSetting = reader.GetValueAsInt("psclientplugin", "PreNoStandbyTime", 300);
            _settings.PreNoShutdownTime = intSetting;
            Log.Debug("PS: Pre-no-standby time: {0} seconds", intSetting);

            // Check if PowerScheduler should wakeup the system automatically
            intSetting = reader.GetValueAsInt("psclientplugin", "Profile", 0);
            if (intSetting == 2)
              boolSetting = false;  // Notebook
            else
              boolSetting = true;   // HTPC, Desktop
            _settings.WakeupEnabled = boolSetting;
            Log.Debug("PS: Wakeup system for various events: {0}", boolSetting);
          }
        }
      }

      // (Re-)Load settings every check interval
      if (_singleSeat)
      {
        // Connect to local tvservice (RemotePowerControl)
        if (RemotePowerControl.Instance != null && RemotePowerControl.Isconnected)
        {
          // Check if PowerScheduler should actively put the system into standby
          boolSetting = RemotePowerControl.Instance.PowerSettings.ShutdownEnabled;
          if (_settings.ShutdownEnabled != boolSetting)
          {
            _settings.ShutdownEnabled = boolSetting;
            Log.Debug("PS: Server plugin setting - PowerScheduler forces system to go to standby when idle: {0}", boolSetting);
            changed = true;
          }

          if (_settings.ShutdownEnabled)
          {
            // Get configured shutdown mode from local tvservice
            intSetting = (int)RemotePowerControl.Instance.PowerSettings.ShutdownMode;
            if ((int)_settings.ShutdownMode != intSetting)
            {
              _settings.ShutdownMode = (ShutdownMode)intSetting;
              Log.Debug("PS: Server plugin setting - Shutdown mode: {0}", _settings.ShutdownMode.ToString());
              changed = true;
            }
          }

          // Get idle timeout from local tvservice
          intSetting = RemotePowerControl.Instance.PowerSettings.IdleTimeout;
          if (_settings.IdleTimeout != intSetting)
          {
            _settings.IdleTimeout = intSetting;
            Log.Debug("PS: Server plugin setting - {0}: {1} minutes", (_settings.ShutdownEnabled ? "Standby after" : "System idle timeout"), intSetting);
            changed = true;
          }

          // Get configured pre-wakeup time from local tvservice
          intSetting = RemotePowerControl.Instance.PowerSettings.PreWakeupTime;
          if (_settings.PreWakeupTime != intSetting)
          {
            _settings.PreWakeupTime = intSetting;
            Log.Debug("PS: Pre-wakeup time: {0} seconds", intSetting);
            changed = true;
          }

          // Check if PowerScheduler should wakeup the system automatically
          boolSetting = RemotePowerControl.Instance.PowerSettings.WakeupEnabled;
          if (_settings.WakeupEnabled != boolSetting)
          {
            _settings.WakeupEnabled = boolSetting;
            Log.Debug("PS: Server plugin setting - Wakeup system for various events: {0}", boolSetting);
            changed = true;
          }
        }
        else
        {
          Log.Error("PS: Cannot connect to local tvservice to load settings");
        }
      }
      else
      {
        // Get active idle timeout for standalone client if standby is handled by Windows
        if (!_settings.ShutdownEnabled)
        {
          intSetting = (int)PowerManager.GetActivePowerSetting(PowerManager.SystemPowerSettingType.STANDBYIDLE) / 60;
          if (_settings.IdleTimeout != intSetting)
          {
            _settings.IdleTimeout = intSetting;
            Log.Debug("PS: System idle timeout: {0} minutes", intSetting);
            changed = true;
          }
        }
      }

      // Send message in case any setting has changed
      if (changed)
      {
        PowerSchedulerEventArgs args = new PowerSchedulerEventArgs(PowerSchedulerEventType.SettingsChanged);
        args.SetData<PowerSettings>(_settings.Clone());
        SendPowerSchedulerEvent(args);
      }
    }
Beispiel #5
0
    public override void SaveSettings()
    {
      LoadAll();

      using (Settings xmlwriter = new MPSettings())
      {
        foreach (ListViewItem item in listViewPlugins.Items)
        {
          ItemTag itemTag = (ItemTag) item.Tag;

          bool isEnabled = itemTag.IsEnabled;
          bool isHome = itemTag.IsHome;
          bool isPlugins = itemTag.IsPlugins;

          if (itemTag.IsIncompatible)
          {
            continue;
          }

          xmlwriter.SetValueAsBool("plugins", itemTag.SetupForm.PluginName(), isEnabled);
          xmlwriter.SetValueAsBool("pluginsdlls", itemTag.DllName, isEnabled);

          if ((isEnabled) && (!isHome && !isPlugins))
          {
            isHome = true;
          }

          if (itemTag.IsWindow)
          {
            xmlwriter.SetValueAsBool("home", itemTag.SetupForm.PluginName(), isHome);
            xmlwriter.SetValueAsBool("myplugins", itemTag.SetupForm.PluginName(), isPlugins);
            xmlwriter.SetValueAsBool("pluginswindows", itemTag.Type, isEnabled);
          }
        }

        // Remove PS++ entries
        xmlwriter.RemoveEntry("plugins", "PowerScheduler++");
        xmlwriter.RemoveEntry("home", "PowerScheduler++");
        xmlwriter.RemoveEntry("myplugins", "PowerScheduler++");
        xmlwriter.RemoveEntry("pluginswindows", "PowerScheduler++");
      }
    }
    public override void SaveSettings()
    {
      using (Settings xmlwriter = new MPSettings())
      {
        xmlwriter.SetValueAsBool("general", "autochangerefreshrate", chkEnableDynamicRR.Checked);
        xmlwriter.SetValueAsBool("general", "notify_on_refreshrate", chkNotifyOnRR.Checked);
        xmlwriter.SetValueAsBool("general", "use_default_hz", chkUseDefaultRR.Checked);
        xmlwriter.SetValueAsBool("general", "devicereset", chkUseDeviceReset.Checked);
        xmlwriter.SetValueAsBool("general", "force_refresh_rate", chkForceRR.Checked);
        xmlwriter.SetValue("general", "default_hz", sDefaultHz);

        /*
        // example
        <entry name="refreshrate01_ext">C:\\Program Files\\displaychanger\\dc.exe -refreshrate=60 -apply -quiet</entry>
        <entry name="refreshrate01_name">NTSC</entry>
        <entry name="ntsc_fps">29.97;30</entry>
        <entry name="ntsc_hz">60</entry>
        */

        //delete all refreshrate entries, then re-add them.
        Settings xmlreader = new MPSettings();
        for (int i = 1; i < 100; i++)
        {
          string name = xmlreader.GetValueAsString("general", "refreshrate0" + Convert.ToString(i) + "_name", "");

          if (string.IsNullOrEmpty(name))
          {
            continue;
          }

          xmlwriter.RemoveEntry("general", name + "_fps");
          xmlwriter.RemoveEntry("general", name + "_hz");
          xmlwriter.RemoveEntry("general", "refreshrate0" + Convert.ToString(i) + "_ext");
          xmlwriter.RemoveEntry("general", "refreshrate0" + Convert.ToString(i) + "_name");
        }

        int j = 1;
        foreach (DataGridViewRow row in dataGridViewRR.Rows)
        {
          string name = (string)row.Cells[0].Value;
          string fps = (string)row.Cells[1].Value;
          string hz = (string)row.Cells[2].Value;
          string extCmd = (string)row.Cells[3].Value;

          xmlwriter.SetValue("general", name + "_fps", fps);
          xmlwriter.SetValue("general", name + "_hz", hz);
          xmlwriter.SetValue("general", "refreshrate0" + Convert.ToString(j) + "_ext", extCmd);
          xmlwriter.SetValue("general", "refreshrate0" + Convert.ToString(j) + "_name", name);
          j++;
        }
      }
    }
Beispiel #7
0
        public void SaveSettings(string section)
        {
            if (AddOpticalDiskDrives)
            {
                AddStaticShares(DriveType.DVD, "DVD");
            }

            using (Profile.Settings xmlwriter = new MPSettings())
            {
                string defaultShare = string.Empty;

                for (int index = 0; index < 128; index++)
                {
                    string shareName       = String.Format("sharename{0}", index);
                    string sharePath       = String.Format("sharepath{0}", index);
                    string sharePin        = String.Format("pincode{0}", index);
                    string shareType       = String.Format("sharetype{0}", index);
                    string shareServer     = String.Format("shareserver{0}", index);
                    string shareLogin      = String.Format("sharelogin{0}", index);
                    string sharePwd        = String.Format("sharepassword{0}", index);
                    string sharePort       = String.Format("shareport{0}", index);
                    string shareRemotePath = String.Format("shareremotepath{0}", index);
                    string shareViewPath   = String.Format("shareview{0}", index);

                    xmlwriter.RemoveEntry(section, shareName);
                    xmlwriter.RemoveEntry(section, sharePath);
                    xmlwriter.RemoveEntry(section, sharePin);
                    xmlwriter.RemoveEntry(section, shareType);
                    xmlwriter.RemoveEntry(section, shareServer);
                    xmlwriter.RemoveEntry(section, shareLogin);
                    xmlwriter.RemoveEntry(section, sharePwd);
                    xmlwriter.RemoveEntry(section, sharePort);
                    xmlwriter.RemoveEntry(section, shareRemotePath);
                    xmlwriter.RemoveEntry(section, shareViewPath);

                    if (section == "music" || section == "movies")
                    {
                        string shareScan = String.Format("sharescan{0}", index);
                        xmlwriter.RemoveEntry(section, shareScan);
                    }

                    if (section == "movies")
                    {
                        string thumbs = String.Format("videothumbscreate{0}", index);
                        xmlwriter.RemoveEntry(section, thumbs);

                        string movieFolder = String.Format("eachfolderismovie{0}", index);
                        xmlwriter.RemoveEntry(section, movieFolder);
                    }

                    string shareNameData       = string.Empty;
                    string sharePathData       = string.Empty;
                    string sharePinData        = string.Empty;
                    bool   shareTypeData       = false;
                    string shareServerData     = string.Empty;
                    string shareLoginData      = string.Empty;
                    string sharePwdData        = string.Empty;
                    int    sharePortData       = 21;
                    string shareRemotePathData = string.Empty;
                    int    shareLayout         = (int)MediaPortal.GUI.Library.GUIFacadeControl.Layout.List;
                    bool   shareScanData       = false;
                    //ThumbsCreate (default true)
                    bool thumbsCreate  = true;
                    bool folderIsMovie = false;

                    if (_shareListControl != null && _shareListControl.Count > index)
                    {
                        ShareData shareData = _shareListControl[index].AlbumInfoTag as ShareData;

                        if (shareData != null && !String.IsNullOrEmpty(shareData.Name))
                        {
                            shareNameData       = shareData.Name;
                            sharePathData       = shareData.Folder;
                            sharePinData        = shareData.PinCode;
                            shareTypeData       = shareData.IsRemote;
                            shareServerData     = shareData.Server;
                            shareLoginData      = shareData.LoginName;
                            sharePwdData        = shareData.PassWord;
                            sharePortData       = shareData.Port;
                            shareRemotePathData = shareData.RemoteFolder;
                            shareLayout         = (int)shareData.DefaultLayout;
                            shareScanData       = shareData.ScanShare;
                            // ThumbsCreate
                            thumbsCreate  = shareData.CreateThumbs;
                            folderIsMovie = shareData.EachFolderIsMovie;

                            if (shareNameData == _defaultShare)
                            {
                                defaultShare = shareNameData;
                            }

                            xmlwriter.SetValue(section, shareName, shareNameData);
                            xmlwriter.SetValue(section, sharePath, sharePathData);
                            xmlwriter.SetValue(section, sharePin, Util.Utils.EncryptPassword(sharePinData));
                            xmlwriter.SetValueAsBool(section, shareType, shareTypeData);
                            xmlwriter.SetValue(section, shareServer, shareServerData);
                            xmlwriter.SetValue(section, shareLogin, shareLoginData);
                            xmlwriter.SetValue(section, sharePwd, Util.Utils.EncryptPassword(sharePwdData));
                            xmlwriter.SetValue(section, sharePort, sharePortData.ToString());
                            xmlwriter.SetValue(section, shareRemotePath, shareRemotePathData);
                            xmlwriter.SetValue(section, shareViewPath, shareLayout);

                            if (section == "music" || section == "movies")
                            {
                                string shareScan = String.Format("sharescan{0}", index);
                                xmlwriter.SetValueAsBool(section, shareScan, shareScanData);
                            }

                            if (section == "movies")
                            {
                                string thumbs = String.Format("videothumbscreate{0}", index);
                                xmlwriter.SetValueAsBool(section, thumbs, thumbsCreate);

                                string folderMovie = String.Format("eachfolderismovie{0}", index);
                                xmlwriter.SetValueAsBool(section, folderMovie, folderIsMovie);
                            }
                        }
                    }
                }
                xmlwriter.SetValue(section, "default", defaultShare);
                xmlwriter.SetValueAsBool(section, "rememberlastfolder", RememberLastFolder);
                xmlwriter.SetValueAsBool(section, "AddOpticalDiskDrives", AddOpticalDiskDrives);
                xmlwriter.SetValueAsBool(section, "SwitchRemovableDrives", SwitchRemovableDrives);
            }
            // Set new shares for internal plugins
            switch (section)
            {
            case "movies":
                GUIVideoFiles.ResetShares();
                break;

            case "music":
                GUIMusicFiles.ResetShares();
                break;

            case "pictures":
                Pictures.GUIPictures.ResetShares();
                break;
            }
        }
    public void SaveSettings(string section)
    {
      if (AddOpticalDiskDrives)
      {
        AddStaticShares(DriveType.DVD, "DVD");
      }

      using (Profile.Settings xmlwriter = new MPSettings())
      {
        string defaultShare = string.Empty;

        for (int index = 0; index < 128; index++)
        {
          string shareName = String.Format("sharename{0}", index);
          string sharePath = String.Format("sharepath{0}", index);
          string sharePin = String.Format("pincode{0}", index);
          string shareType = String.Format("sharetype{0}", index);
          string shareServer = String.Format("shareserver{0}", index);
          string shareLogin = String.Format("sharelogin{0}", index);
          string sharePwd = String.Format("sharepassword{0}", index);
          string sharePort = String.Format("shareport{0}", index);
          string shareRemotePath = String.Format("shareremotepath{0}", index);
          string shareViewPath = String.Format("shareview{0}", index);

          xmlwriter.RemoveEntry(section, shareName);
          xmlwriter.RemoveEntry(section, sharePath);
          xmlwriter.RemoveEntry(section, sharePin);
          xmlwriter.RemoveEntry(section, shareType);
          xmlwriter.RemoveEntry(section, shareServer);
          xmlwriter.RemoveEntry(section, shareLogin);
          xmlwriter.RemoveEntry(section, sharePwd);
          xmlwriter.RemoveEntry(section, sharePort);
          xmlwriter.RemoveEntry(section, shareRemotePath);
          xmlwriter.RemoveEntry(section, shareViewPath);

          if (section == "music" || section == "movies")
          {
            string shareScan = String.Format("sharescan{0}", index);
            xmlwriter.RemoveEntry(section, shareScan);
          }

          if (section == "movies")
          {
            string thumbs = String.Format("videothumbscreate{0}", index);
            xmlwriter.RemoveEntry(section, thumbs);

            string movieFolder = String.Format("eachfolderismovie{0}", index);
            xmlwriter.RemoveEntry(section, movieFolder);
          }

          string shareNameData = string.Empty;
          string sharePathData = string.Empty;
          string sharePinData = string.Empty;
          bool shareTypeData = false;
          string shareServerData = string.Empty;
          string shareLoginData = string.Empty;
          string sharePwdData = string.Empty;
          int sharePortData = 21;
          string shareRemotePathData = string.Empty;
          int shareLayout = (int)MediaPortal.GUI.Library.GUIFacadeControl.Layout.List;
          bool shareScanData = false;
          //ThumbsCreate (default true)
          bool thumbsCreate = true;
          bool folderIsMovie = false;

          if (_shareListControl != null && _shareListControl.Count > index)
          {
            ShareData shareData = _shareListControl[index].AlbumInfoTag as ShareData;

            if (shareData != null && !String.IsNullOrEmpty(shareData.Name))
            {
              shareNameData = shareData.Name;
              sharePathData = shareData.Folder;
              sharePinData = shareData.PinCode;
              shareTypeData = shareData.IsRemote;
              shareServerData = shareData.Server;
              shareLoginData = shareData.LoginName;
              sharePwdData = shareData.PassWord;
              sharePortData = shareData.Port;
              shareRemotePathData = shareData.RemoteFolder;
              shareLayout = (int)shareData.DefaultLayout;
              shareScanData = shareData.ScanShare;
              // ThumbsCreate
              thumbsCreate = shareData.CreateThumbs;
              folderIsMovie = shareData.EachFolderIsMovie;

              if (shareNameData == _defaultShare)
              {
                defaultShare = shareNameData;
              }

              xmlwriter.SetValue(section, shareName, shareNameData);
              xmlwriter.SetValue(section, sharePath, sharePathData);
              xmlwriter.SetValue(section, sharePin, Util.Utils.EncryptPassword(sharePinData));
              xmlwriter.SetValueAsBool(section, shareType, shareTypeData);
              xmlwriter.SetValue(section, shareServer, shareServerData);
              xmlwriter.SetValue(section, shareLogin, shareLoginData);
              xmlwriter.SetValue(section, sharePwd, Util.Utils.EncryptPassword(sharePwdData));
              xmlwriter.SetValue(section, sharePort, sharePortData.ToString());
              xmlwriter.SetValue(section, shareRemotePath, shareRemotePathData);
              xmlwriter.SetValue(section, shareViewPath, shareLayout);

              if (section == "music" || section == "movies")
              {
                string shareScan = String.Format("sharescan{0}", index);
                xmlwriter.SetValueAsBool(section, shareScan, shareScanData);
              }
              
              if (section == "movies")
              {
                string thumbs = String.Format("videothumbscreate{0}", index);
                xmlwriter.SetValueAsBool(section, thumbs, thumbsCreate);

                string folderMovie = String.Format("eachfolderismovie{0}", index);
                xmlwriter.SetValueAsBool(section, folderMovie, folderIsMovie);
              }
            }
          }
        }
        xmlwriter.SetValue(section, "default", defaultShare);
        xmlwriter.SetValueAsBool(section, "rememberlastfolder", RememberLastFolder);
        xmlwriter.SetValueAsBool(section, "AddOpticalDiskDrives", AddOpticalDiskDrives);
        xmlwriter.SetValueAsBool(section, "SwitchRemovableDrives", SwitchRemovableDrives);
      }
      // Set new shares for internal plugins
      switch (section)
      {
        case "movies":
          GUIVideoFiles.ResetShares();
          break;
        case "music":
          GUIMusicFiles.ResetShares();
          break;
        case "pictures":
          Pictures.GUIPictures.ResetShares();
          break;
      }
    }
    public void SetDefaultDrives(string section, bool addOpticalDrives)
    {
      using (Profile.Settings xmlwriter = new MPSettings())
      {
        for (int index = 0; index < 128; index++)
        {
          string shareName = String.Format("sharename{0}", index);
          string sharePath = String.Format("sharepath{0}", index);
          string sharePin = String.Format("pincode{0}", index);
          string shareType = String.Format("sharetype{0}", index);
          string shareServer = String.Format("shareserver{0}", index);
          string shareLogin = String.Format("sharelogin{0}", index);
          string sharePwd = String.Format("sharepassword{0}", index);
          string sharePort = String.Format("shareport{0}", index);
          string shareRemotePath = String.Format("shareremotepath{0}", index);
          string shareViewPath = String.Format("shareview{0}", index);

          xmlwriter.RemoveEntry(section, shareName);
          xmlwriter.RemoveEntry(section, sharePath);
          xmlwriter.RemoveEntry(section, sharePin);
          xmlwriter.RemoveEntry(section, shareType);
          xmlwriter.RemoveEntry(section, shareServer);
          xmlwriter.RemoveEntry(section, shareLogin);
          xmlwriter.RemoveEntry(section, sharePwd);
          xmlwriter.RemoveEntry(section, sharePort);
          xmlwriter.RemoveEntry(section, shareRemotePath);
          xmlwriter.RemoveEntry(section, shareViewPath);
        }
      }

      switch (section)
      {
        case "movies":
          VirtualDirectory.SetInitialDefaultShares(false, false, false, true);
          break;
        case "music":
          VirtualDirectory.SetInitialDefaultShares(false, true, false, false);
          break;
        case "pictures":
          VirtualDirectory.SetInitialDefaultShares(false, false, true, false);
          break;
      }
    }
        public void Save(bool saveOnlyRuntimeModifyable)
        {
            OnlineVideos.OnlineVideoSettings ovsconf = OnlineVideos.OnlineVideoSettings.Instance;
            try
            {
                using (Settings settings = new MPSettings())
                {
                    settings.SetValue(CFG_SECTION, CFG_GROUPVIEW_MODE, (int)currentGroupView);
                    settings.SetValue(CFG_SECTION, CFG_SITEVIEW_MODE, (int)currentSiteView);
                    settings.SetValue(CFG_SECTION, CFG_SITEVIEW_ORDER, (int)siteOrder);
                    settings.SetValue(CFG_SECTION, CFG_VIDEOVIEW_MODE, (int)currentVideoView);
                    settings.SetValue(CFG_SECTION, CFG_CATEGORYVIEW_MODE, (int)currentCategoryView);
                    if (lastFirstRun != default(DateTime))
                    {
                        settings.SetValue(CFG_SECTION, CFG_LAST_FIRSTRUN, lastFirstRun.ToString("s"));
                    }
                    try
                    {
                        MemoryStream           xmlMem = new MemoryStream();
                        DataContractSerializer dcs    = new DataContractSerializer(typeof(Dictionary <string, List <string> >));
                        dcs.WriteObject(xmlMem, searchHistory);
                        xmlMem.Position = 0;
                        XmlDocument xmlDoc = new XmlDocument();
                        xmlDoc.Load(xmlMem);
                        settings.SetValue(CFG_SECTION, CFG_SEARCHHISTORY, xmlDoc.InnerXml);
                    }
                    catch (Exception e)
                    {
                        Log.Instance.Warn("Error saving search history to configuration: {0}:{1}! Will be reset on next load...", e.GetType(), e.Message);
                        searchHistory = null;
                        settings.SetValue(CFG_SECTION, CFG_SEARCHHISTORY, "");
                    }

                    if (!saveOnlyRuntimeModifyable)
                    {
                        settings.SetValue(CFG_SECTION, CFG_BASICHOMESCREEN_NAME, BasicHomeScreenName);
                        settings.SetValue(CFG_SECTION, CFG_THUMBNAIL_DIR, ovsconf.ThumbsDir);
                        settings.SetValue(CFG_SECTION, CFG_THUMBNAIL_AGE, ThumbsAge);
                        settings.SetValueAsBool(CFG_SECTION, CFG_USE_AGECONFIRMATION, ovsconf.UseAgeConfirmation);
                        settings.SetValue(CFG_SECTION, CFG_PIN_AGECONFIRMATION, pinAgeConfirmation);
                        settings.SetValueAsBool(CFG_SECTION, CFG_USE_QUICKSELECT, useQuickSelect);
                        settings.SetValue(CFG_SECTION, CFG_CACHE_TIMEOUT, ovsconf.CacheTimeout);
                        settings.SetValue(CFG_SECTION, CFG_UTIL_TIMEOUT, ovsconf.UtilTimeout);
                        settings.SetValue(CFG_SECTION, CFG_CATEGORYDISCOVERED_TIMEOUT, ovsconf.DynamicCategoryTimeout);
                        settings.SetValue(CFG_SECTION, CFG_WMP_BUFFER, wmpbuffer);
                        settings.SetValue(CFG_SECTION, CFG_PLAY_BUFFER, playbuffer);
                        settings.SetValue(CFG_SECTION, CFG_UPDATEPERIOD, updatePeriod);
                        if (FilterArray != null && FilterArray.Length > 0)
                        {
                            settings.SetValue(CFG_SECTION, CFG_FILTER, string.Join(",", FilterArray));
                        }
                        if (!string.IsNullOrEmpty(ovsconf.DownloadDir))
                        {
                            settings.SetValue(CFG_SECTION, CFG_DOWNLOAD_DIR, ovsconf.DownloadDir);
                        }
                        if (!string.IsNullOrEmpty(email))
                        {
                            settings.SetValue(CFG_SECTION, CFG_EMAIL, email);
                        }
                        if (!string.IsNullOrEmpty(password))
                        {
                            settings.SetValue(CFG_SECTION, CFG_PASSWORD, password);
                        }
                        if (updateOnStart == null)
                        {
                            settings.RemoveEntry(CFG_SECTION, CFG_UPDATEONSTART);
                        }
                        else
                        {
                            settings.SetValueAsBool(CFG_SECTION, CFG_UPDATEONSTART, updateOnStart.Value);
                        }
                        settings.SetValue(CFG_SECTION, CFG_SEARCHHISTORY_NUM, searchHistoryNum);
                        settings.SetValue(CFG_SECTION, CFG_SEARCHHISTORYTYPE, (int)searchHistoryType);
                        settings.SetValueAsBool(CFG_SECTION, CFG_AUTO_LANG_GROUPS, autoGroupByLang);
                        settings.SetValueAsBool(CFG_SECTION, CFG_FAVORITES_FIRST, ovsconf.FavoritesFirst);
                        settings.SetValueAsBool(CFG_SECTION, CFG_LATESTVIDEOS_RANDOMIZE, LatestVideosRandomize);
                        settings.SetValue(CFG_SECTION, CFG_LATESTVIDEOS_MAXITEMS, LatestVideosMaxItems);
                        settings.SetValue(CFG_SECTION, CFG_LATESTVIDEOS_ONLINEDATA_REFRESH, LatestVideosOnlineDataRefresh);
                        settings.SetValue(CFG_SECTION, CFG_LATESTVIDEOS_GUIDATA_REFRESH, LatestVideosGuiDataRefresh);
                        settings.SetValueAsBool(CFG_SECTION, CFG_ALLOW_REFRESHRATE_CHANGE, AllowRefreshRateChange);
                        settings.SetValueAsBool(CFG_SECTION, CFG_STORE_LAYOUT_PER_CATEGORY, StoreLayoutPerCategory);
                        SaveSitesGroups();
                        ovsconf.SaveSites();

                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_HTTP_PREFERRED_NETWORK_INTERFACE, ovsconf.HttpPreferredNetworkInterface);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_HTTP_OPEN_CONNECTION_TIMEOUT, ovsconf.HttpOpenConnectionTimeout);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_HTTP_OPEN_CONNECTION_SLEEP_TIME, ovsconf.HttpOpenConnectionSleepTime);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_HTTP_TOTAL_REOPEN_CONNECTION_TIMEOUT, ovsconf.HttpTotalReopenConnectionTimeout);

                        settings.SetValueAsBool(CFG_SECTION, CFG_FILTER_V2_HTTP_SERVER_AUTHENTICATE, ovsconf.HttpServerAuthenticate);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_HTTP_SERVER_USER_NAME, ovsconf.HttpServerUserName);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_HTTP_SERVER_PASSWORD, ovsconf.HttpServerPassword);

                        settings.SetValueAsBool(CFG_SECTION, CFG_FILTER_V2_HTTP_PROXY_SERVER_AUTHENTICATE, ovsconf.HttpProxyServerAuthenticate);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_HTTP_PROXY_SERVER, ovsconf.HttpProxyServer);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_HTTP_PROXY_SERVER_PORT, ovsconf.HttpProxyServerPort);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_HTTP_PROXY_SERVER_USER_NAME, ovsconf.HttpProxyServerUserName);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_HTTP_PROXY_SERVER_PASSWORD, ovsconf.HttpProxyServerPassword);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_HTTP_PROXY_SERVER_TYPE, (int)ovsconf.HttpProxyServerType);

                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_RTMP_PREFERRED_NETWORK_INTERFACE, ovsconf.RtmpPreferredNetworkInterface);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_RTMP_OPEN_CONNECTION_TIMEOUT, ovsconf.RtmpOpenConnectionTimeout);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_RTMP_OPEN_CONNECTION_SLEEP_TIME, ovsconf.RtmpOpenConnectionSleepTime);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_RTMP_TOTAL_REOPEN_CONNECTION_TIMEOUT, ovsconf.RtmpTotalReopenConnectionTimeout);

                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_RTSP_PREFERRED_NETWORK_INTERFACE, ovsconf.RtspPreferredNetworkInterface);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_RTSP_OPEN_CONNECTION_TIMEOUT, ovsconf.RtspOpenConnectionTimeout);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_RTSP_OPEN_CONNECTION_SLEEP_TIME, ovsconf.RtspOpenConnectionSleepTime);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_RTSP_TOTAL_REOPEN_CONNECTION_TIMEOUT, ovsconf.RtspTotalReopenConnectionTimeout);

                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_RTSP_CLIENT_PORT_MIN, ovsconf.RtspClientPortMin);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_RTSP_CLIENT_PORT_MAX, ovsconf.RtspClientPortMax);

                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_UDPRTP_PREFERRED_NETWORK_INTERFACE, ovsconf.UdpRtpPreferredNetworkInterface);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_UDPRTP_OPEN_CONNECTION_TIMEOUT, ovsconf.UdpRtpOpenConnectionTimeout);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_UDPRTP_OPEN_CONNECTION_SLEEP_TIME, ovsconf.UdpRtpOpenConnectionSleepTime);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_UDPRTP_TOTAL_REOPEN_CONNECTION_TIMEOUT, ovsconf.UdpRtpTotalReopenConnectionTimeout);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_UDPRTP_RECEIVE_DATA_CHECK_INTERVAL, ovsconf.UdpRtpReceiveDataCheckInterval);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Instance.Error(ex);
            }
        }
        /// <summary>
        /// Perform any maintenance tasks on the settings
        /// </summary>
        internal static void PerformMaintenance()
        {
            TraktLogger.Info("Performing maintenance tasks");

            using (Settings xmlreader = new MPSettings())
            {
                int currentSettingsVersion = xmlreader.GetValueAsInt(cTrakt, cSettingsVersion, SettingsVersion);

                // check if any maintenance task is required
                if (currentSettingsVersion >= SettingsVersion) return;

                // upgrade settings for each version
                while (currentSettingsVersion < SettingsVersion)
                {
                    switch (currentSettingsVersion)
                    {
                        case 0:
                            xmlreader.RemoveEntry(cTrakt, cLastActivityLoad);
                            xmlreader.RemoveEntry(cTrakt, cLastTrendingMovies);
                            xmlreader.RemoveEntry(cTrakt, cLastTrendingShows);
                            xmlreader.RemoveEntry(cTrakt, cLastStatistics);
                            currentSettingsVersion++;
                            break;

                        case 1:
                            // trailers plugin now supports tvshows, seasons and episodes.
                            xmlreader.SetValueAsBool(cTrakt, "UseTrailersPlugin", true);
                            currentSettingsVersion++;
                            break;

                        case 2:
                            // Only use Trailers plugin now for Trailers functionality.
                            xmlreader.RemoveEntry(cTrakt, "UseTrailersPlugin");
                            xmlreader.RemoveEntry(cTrakt, "DefaultTVShowTrailerSite");
                            xmlreader.RemoveEntry(cTrakt, "DefaultMovieTrailerSite");

                            // Remove old activity settings
                            xmlreader.RemoveEntry(cTrakt, "ShowCommunityActivity");
                            xmlreader.RemoveEntry(cTrakt, "IncludeMeInFriendsActivity");

                            // Remove old category/filter node ids for MovingPictures (not needed)
                            xmlreader.RemoveEntry(cTrakt, "MovingPicturesCategoryId");
                            xmlreader.RemoveEntry(cTrakt, "MovingPicturesFilterId");

                            currentSettingsVersion++;
                            break;

                        case 3:
                            // Remove 4TR / My Anime plugin handlers (plugins no longer developed or superceded)
                            xmlreader.RemoveEntry(cTrakt, "ForTheRecordRecordings");
                            xmlreader.RemoveEntry(cTrakt, "ForTheRecordTVLive");
                            xmlreader.RemoveEntry(cTrakt, "MyAnime");

                            // Clear existing passwords as they're no longer hashed in new API v2
                            xmlreader.RemoveEntry(cTrakt, cPassword);
                            xmlreader.RemoveEntry(cTrakt, cUserLogins);

                            // Remove Advanced Rating setting, there is only one now
                            xmlreader.RemoveEntry(cTrakt, "ShowAdvancedRatingsDialog");

                            // Remove SkippedMovies and AlreadyExistMovies as data structures changed
                            xmlreader.RemoveEntry(cTrakt, "SkippedMovies");
                            xmlreader.RemoveEntry(cTrakt, "AlreadyExistMovies");

                            // Remove old show collection cache
                            xmlreader.RemoveEntry(cTrakt, "ShowsInCollection");

                            // Reset some defaults
                            xmlreader.RemoveEntry(cTrakt, cSyncRatings);
                            xmlreader.RemoveEntry(cTrakt, cDashboardActivityPollInterval);
                            xmlreader.RemoveEntry(cTrakt, cDashboardTrendingPollInterval);
                            xmlreader.RemoveEntry(cTrakt, cDashboardLoadDelay);
                            xmlreader.RemoveEntry(cTrakt, cShowRateDlgForPlaylists);
                            xmlreader.RemoveEntry(cTrakt, cSearchTypes);

                            // Remove any persisted data that has changed with with new API v2
                            try
                            {
                                if (File.Exists(cLastActivityFileCache)) File.Delete(cLastActivityFileCache);
                                if (File.Exists(cLastTrendingShowFileCache)) File.Delete(cLastTrendingShowFileCache);
                                if (File.Exists(cLastTrendingMovieFileCache)) File.Delete(cLastTrendingMovieFileCache);
                                if (File.Exists(cLastStatisticsFileCache)) File.Delete(cLastStatisticsFileCache);

                                // Remove old artwork - filenames have changed
                                string imagePath = Config.GetFolder(Config.Dir.Thumbs) + "\\Trakt";
                                if (Directory.Exists(imagePath))
                                {
                                    Directory.Delete(imagePath, true);
                                }
                            }
                            catch (Exception e)
                            {
                                TraktLogger.Error("Failed to remove v1 API persisted data from disk, Reason = '{0}'", e.Message);
                            }

                            currentSettingsVersion++;
                            break;

                        case 4:
                            try
                            {
                                // Fix bad upgrade from previous release
                                string dashboardPersistence = Config.GetFolder(Config.Dir.Config) + "\\Trakt\\Dashboard";
                                if (Directory.Exists(dashboardPersistence))
                                {
                                    Directory.Delete(dashboardPersistence, true);
                                }
                            }
                            catch (Exception e)
                            {
                                TraktLogger.Error("Failed to remove v1 API persisted data from disk, Reason = '{0}'", e.Message);
                            }
                            currentSettingsVersion++;
                            break;

                        case 5:
                            // Clear existing passwords, change of encryption/decryption technique
                            xmlreader.RemoveEntry(cTrakt, cPassword);
                            xmlreader.RemoveEntry(cTrakt, cUserLogins);
                            currentSettingsVersion++;
                            break;

                        case 6:
                            // Save Sync Interval in Hours from Milliseconds
                            int syncTimerLength = xmlreader.GetValueAsInt(cTrakt, cSyncTimerLength, 24);
                            if (syncTimerLength > 24)
                            {
                                // requires upgrade
                                xmlreader.SetValue(cTrakt, cSyncTimerLength, syncTimerLength / 3600000);
                            }
                            currentSettingsVersion++;
                            break;

                        case 7:
                            // upgrade last activity view
                            xmlreader.RemoveEntry(cTrakt, cActivityStreamView);

                            // remove last paused item processed - stored in last activities
                            xmlreader.RemoveEntry(cTrakt, "LastPausedItemProcessed");

                            currentSettingsVersion++;
                            break;

                        case 8:
                            // cleanup cached likes, API changed to include a user object for lists
                            // i.e. the user that owns the list
                            try
                            {
                                var folderName = Path.Combine(Config.GetFolder(Config.Dir.Config), @"Trakt");

                                var matches = Directory.GetFiles(folderName, "Liked.json", SearchOption.AllDirectories);
                                foreach (string file in matches)
                                {
                                    File.Delete(file);
                                }
                            }
                            catch (Exception e)
                            {
                                TraktLogger.Error("Failed to remove previously cached likes from disk, Reason = '{0}'", e.Message);
                            }
                            currentSettingsVersion++;
                            break;

                        case 9:
                            // remove old thumbs folder
                            try
                            {
                                DirectoryInfo di = new DirectoryInfo(Path.Combine(Config.GetFolder(Config.Dir.Thumbs), @"Trakt"));

                                foreach (FileInfo file in di.GetFiles())
                                {
                                    file.Delete();
                                }
                                foreach (DirectoryInfo dir in di.GetDirectories())
                                {
                                    dir.Delete(true);
                                }
                            }
                            catch (Exception e)
                            {
                                TraktLogger.Error("Failed to remove previously cached thumbs from disk, Reason = '{0}'", e.Message);
                            }

                            // update default sizes for requests so we dont hit any limits from TMDb by default
                            xmlreader.SetValue(cTrakt, cMaxAnticipatedMoviesRequest, 40);
                            xmlreader.SetValue(cTrakt, cMaxAnticipatedShowsRequest, 40);
                            xmlreader.SetValue(cTrakt, cMaxPopularMoviesRequest, 40);
                            xmlreader.SetValue(cTrakt, cMaxPopularShowsRequest, 40);
                            xmlreader.SetValue(cTrakt, cMaxRelatedMoviesUnWatchedRequest, 40);
                            xmlreader.SetValue(cTrakt, cMaxRelatedShowsUnWatchedRequest, 40);
                            xmlreader.SetValue(cTrakt, cMaxTrendingMoviesRequest, 40);
                            xmlreader.SetValue(cTrakt, cMaxTrendingShowsRequest, 40);
                            xmlreader.SetValue(cTrakt, cMaxUserWatchedEpisodesRequest, 40);
                            xmlreader.SetValue(cTrakt, cMaxUserWatchedMoviesRequest, 40);
                            xmlreader.SetValue(cTrakt, cMaxUserCommentsRequest, 40);

                            currentSettingsVersion++;
                            break;
                    }
                }
            }
            Settings.SaveCache();
        }
    private void OnSetDefaultGrabber()
    {
      // read index file
      if (!File.Exists(_grabberIndexFile))
      {
        GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
        dlgOk.SetHeading(257);
        dlgOk.SetLine(1, GUILocalizeStrings.Get(300033)); // No grabber index found
        dlgOk.DoModal(GetID);
        return;
      }

      GUIWaitCursor.Show();
      GetGrabbers();

      string defaultDatabase = string.Empty;
      int defaultIndex = 0;
      int dbNumber;

      using (MediaPortal.Profile.Settings xmlreader = new MPSettings())
      {
        defaultDatabase = xmlreader.GetValueAsString("moviedatabase", "database" + 0, "IMDB");
        dbNumber = xmlreader.GetValueAsInt("moviedatabase", "number", 0);
      }

      // Dialog menu with grabbers
      GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
      if (dlg == null)
      {
        return;
      }
      dlg.Reset();
      dlg.SetHeading(300036); // Set default Grabber script

      foreach (KeyValuePair<string, IIMDBScriptGrabber> grabber in _grabberList)
      {
        dlg.Add(grabber.Value.GetName() + " - " + grabber.Value.GetLanguage());

        if (defaultDatabase == grabber.Key)
        {
          dlg.SelectedLabel = defaultIndex;
        }
        else
        {
          defaultIndex++;
        }
      }

      GUIWaitCursor.Hide();

      dlg.DoModal(GetID);

      if (dlg.SelectedId == -1)
      {
        return;
      }

      using (MediaPortal.Profile.Settings xmlwriter = new MPSettings())
      {
        KeyValuePair<string, IIMDBScriptGrabber> grabber = _grabberList.ElementAt(dlg.SelectedLabel);


        if (grabber.Key != "IMDB")
        {
          if (dbNumber == 0)
          {
            dbNumber = 1;
          }
          xmlwriter.SetValue("moviedatabase", "number", dbNumber);
          xmlwriter.SetValue("moviedatabase", "database" + 0, grabber.Key);
          xmlwriter.SetValue("moviedatabase", "title" + 0, grabber.Value.GetName());
          xmlwriter.SetValue("moviedatabase", "language" + 0, grabber.Value.GetLanguage());
          xmlwriter.SetValue("moviedatabase", "limit" + 0, 25);
        }
        else
        {
          for (int i = 0; i < 4; i++)
          {
            xmlwriter.SetValue("moviedatabase", "number", 0);
            xmlwriter.RemoveEntry("moviedatabase", "database" + i);
            xmlwriter.RemoveEntry("moviedatabase", "title" + i);
            xmlwriter.RemoveEntry("moviedatabase", "language" + i);
            xmlwriter.RemoveEntry("moviedatabase", "limit" + i);
          }
        }
      }
    }
Beispiel #13
0
    protected void SaveSettings(string section)
    {
      if (AddOpticalDiskDrives)
      {
        AddStaticShares(DriveType.DVD, "DVD");
      }

      using (Settings xmlwriter = new MPSettings())
      {
        string defaultShare = string.Empty;

        for (int index = 0; index < MaximumShares; index++)
        {
          string shareName = String.Format("sharename{0}", index);
          string sharePath = String.Format("sharepath{0}", index);
          string sharePin = String.Format("pincode{0}", index);
          string shareType = String.Format("sharetype{0}", index);
          string shareServer = String.Format("shareserver{0}", index);
          string shareLogin = String.Format("sharelogin{0}", index);
          string sharePwd = String.Format("sharepassword{0}", index);
          string sharePort = String.Format("shareport{0}", index);
          string shareRemotePath = String.Format("shareremotepath{0}", index);
          string shareViewPath = String.Format("shareview{0}", index);
          string sharewakeonlan = String.Format("sharewakeonlan{0}", index);
          string sharedonotfolderjpgifpin = String.Format("sharedonotfolderjpgifpin{0}", index);
          
          xmlwriter.RemoveEntry(section, shareName);
          xmlwriter.RemoveEntry(section, sharePath);
          xmlwriter.RemoveEntry(section, sharePin);
          xmlwriter.RemoveEntry(section, shareType);
          xmlwriter.RemoveEntry(section, shareServer);
          xmlwriter.RemoveEntry(section, shareLogin);
          xmlwriter.RemoveEntry(section, sharePwd);
          xmlwriter.RemoveEntry(section, sharePort);
          xmlwriter.RemoveEntry(section, shareRemotePath);
          xmlwriter.RemoveEntry(section, shareViewPath);
          xmlwriter.RemoveEntry(section, sharewakeonlan);
          xmlwriter.RemoveEntry(section, sharedonotfolderjpgifpin);
          
          if (section == "music" || section == "movies")
          {
            string shareScan = String.Format("sharescan{0}", index);
            xmlwriter.RemoveEntry(section, shareScan);
          }

          if (section == "movies")
          {
            string thumbs = String.Format("videothumbscreate{0}", index);
            xmlwriter.RemoveEntry(section, thumbs);

            string movieFolder = String.Format("eachfolderismovie{0}", index);
            xmlwriter.RemoveEntry(section, movieFolder);
          }
          
          string shareNameData = string.Empty;
          string sharePathData = string.Empty;
          string sharePinData = string.Empty;
          bool shareTypeData = false;
          string shareServerData = string.Empty;
          string shareLoginData = string.Empty;
          string sharePwdData = string.Empty;
          int sharePortData = 21;
          string shareRemotePathData = string.Empty;
          int shareLayout = (int)MediaPortal.GUI.Library.GUIFacadeControl.Layout.List;
          bool shareScanData = false;
          //ThumbsCreate (default true)
          bool thumbsCreate = true;
          bool folderIsMovie = false;
          bool shareWakeOnLan = false;
          bool sharedonotFolderJpgIfPin = true;

          if (CurrentShares != null && CurrentShares.Count > index)
          {
            ShareData shareData = CurrentShares[index].Tag as ShareData;

            if (shareData != null && !String.IsNullOrEmpty(shareData.Name))
            {
              shareNameData = shareData.Name;
              sharePathData = shareData.Folder;
              sharePinData = shareData.PinCode;
              shareTypeData = shareData.IsRemote;
              shareServerData = shareData.Server;
              shareLoginData = shareData.LoginName;
              sharePwdData = shareData.PassWord;
              sharePortData = shareData.Port;
              shareRemotePathData = shareData.RemoteFolder;
              shareLayout = (int)shareData.DefaultLayout;
              shareScanData = shareData.ScanShare;
              // ThumbsCreate
              thumbsCreate = shareData.CreateThumbs;
              folderIsMovie = shareData.EachFolderIsMovie;
              shareWakeOnLan = shareData.EnableWakeOnLan;
              sharedonotFolderJpgIfPin = shareData.DonotFolderJpgIfPin;

              if (CurrentShares[index] == DefaultShare)
              {
                defaultShare = shareNameData;
              }

              xmlwriter.SetValue(section, shareName, shareNameData);
              xmlwriter.SetValue(section, sharePath, sharePathData);
              xmlwriter.SetValue(section, sharePin, Util.Utils.EncryptPassword(sharePinData));
              xmlwriter.SetValueAsBool(section, shareType, shareTypeData);
              xmlwriter.SetValue(section, shareServer, shareServerData);
              xmlwriter.SetValue(section, shareLogin, shareLoginData);
              xmlwriter.SetValue(section, sharePwd, Util.Utils.EncryptPassword(sharePwdData));
              xmlwriter.SetValue(section, sharePort, sharePortData.ToString());
              xmlwriter.SetValue(section, shareRemotePath, shareRemotePathData);
              xmlwriter.SetValue(section, shareViewPath, shareLayout);
              xmlwriter.SetValueAsBool(section, sharewakeonlan, shareWakeOnLan);
              xmlwriter.SetValueAsBool(section, sharedonotfolderjpgifpin, sharedonotFolderJpgIfPin);

              if (section == "music" || section == "movies")
              {
                string shareScan = String.Format("sharescan{0}", index);
                xmlwriter.SetValueAsBool(section, shareScan, shareScanData);
              }
              //ThumbsCreate
              if (section == "movies")
              {
                string thumbs = String.Format("videothumbscreate{0}", index);
                xmlwriter.SetValueAsBool(section, thumbs, thumbsCreate);

                string folderMovie = String.Format("eachfolderismovie{0}", index);
                xmlwriter.SetValueAsBool(section, folderMovie, folderIsMovie);
              }
            }
          }
        }
        xmlwriter.SetValue(section, "default", defaultShare);
        xmlwriter.SetValueAsBool(section, "rememberlastfolder", RememberLastFolder);
        xmlwriter.SetValueAsBool(section, "AddOpticalDiskDrives", AddOpticalDiskDrives);
        xmlwriter.SetValueAsBool(section, "SwitchRemovableDrives", SwitchRemovableDrives);
      }
    }
        protected void SaveSettings(string section)
        {
            if (AddOpticalDiskDrives)
            {
                AddStaticShares(DriveType.DVD, "DVD");
            }

            using (Settings xmlwriter = new MPSettings())
            {
                string defaultShare = string.Empty;

                for (int index = 0; index < MaximumShares; index++)
                {
                    string shareName                = String.Format("sharename{0}", index);
                    string sharePath                = String.Format("sharepath{0}", index);
                    string sharePin                 = String.Format("pincode{0}", index);
                    string shareType                = String.Format("sharetype{0}", index);
                    string shareServer              = String.Format("shareserver{0}", index);
                    string shareLogin               = String.Format("sharelogin{0}", index);
                    string sharePwd                 = String.Format("sharepassword{0}", index);
                    string sharePort                = String.Format("shareport{0}", index);
                    string shareRemotePath          = String.Format("shareremotepath{0}", index);
                    string shareViewPath            = String.Format("shareview{0}", index);
                    string sharewakeonlan           = String.Format("sharewakeonlan{0}", index);
                    string sharedonotfolderjpgifpin = String.Format("sharedonotfolderjpgifpin{0}", index);

                    xmlwriter.RemoveEntry(section, shareName);
                    xmlwriter.RemoveEntry(section, sharePath);
                    xmlwriter.RemoveEntry(section, sharePin);
                    xmlwriter.RemoveEntry(section, shareType);
                    xmlwriter.RemoveEntry(section, shareServer);
                    xmlwriter.RemoveEntry(section, shareLogin);
                    xmlwriter.RemoveEntry(section, sharePwd);
                    xmlwriter.RemoveEntry(section, sharePort);
                    xmlwriter.RemoveEntry(section, shareRemotePath);
                    xmlwriter.RemoveEntry(section, shareViewPath);
                    xmlwriter.RemoveEntry(section, sharewakeonlan);
                    xmlwriter.RemoveEntry(section, sharedonotfolderjpgifpin);

                    if (section == "music" || section == "movies")
                    {
                        string shareScan = String.Format("sharescan{0}", index);
                        xmlwriter.RemoveEntry(section, shareScan);
                    }

                    if (section == "movies")
                    {
                        string thumbs = String.Format("videothumbscreate{0}", index);
                        xmlwriter.RemoveEntry(section, thumbs);

                        string movieFolder = String.Format("eachfolderismovie{0}", index);
                        xmlwriter.RemoveEntry(section, movieFolder);
                    }

                    string shareNameData       = string.Empty;
                    string sharePathData       = string.Empty;
                    string sharePinData        = string.Empty;
                    bool   shareTypeData       = false;
                    string shareServerData     = string.Empty;
                    string shareLoginData      = string.Empty;
                    string sharePwdData        = string.Empty;
                    int    sharePortData       = 21;
                    string shareRemotePathData = string.Empty;
                    int    shareLayout         = (int)MediaPortal.GUI.Library.GUIFacadeControl.Layout.List;
                    bool   shareScanData       = false;
                    //ThumbsCreate (default true)
                    bool thumbsCreate             = true;
                    bool folderIsMovie            = false;
                    bool shareWakeOnLan           = false;
                    bool sharedonotFolderJpgIfPin = true;

                    if (CurrentShares != null && CurrentShares.Count > index)
                    {
                        ShareData shareData = CurrentShares[index].Tag as ShareData;

                        if (shareData != null && !String.IsNullOrEmpty(shareData.Name))
                        {
                            shareNameData       = shareData.Name;
                            sharePathData       = shareData.Folder;
                            sharePinData        = shareData.PinCode;
                            shareTypeData       = shareData.IsRemote;
                            shareServerData     = shareData.Server;
                            shareLoginData      = shareData.LoginName;
                            sharePwdData        = shareData.PassWord;
                            sharePortData       = shareData.Port;
                            shareRemotePathData = shareData.RemoteFolder;
                            shareLayout         = (int)shareData.DefaultLayout;
                            shareScanData       = shareData.ScanShare;
                            // ThumbsCreate
                            thumbsCreate             = shareData.CreateThumbs;
                            folderIsMovie            = shareData.EachFolderIsMovie;
                            shareWakeOnLan           = shareData.EnableWakeOnLan;
                            sharedonotFolderJpgIfPin = shareData.DonotFolderJpgIfPin;

                            if (CurrentShares[index] == DefaultShare)
                            {
                                defaultShare = shareNameData;
                            }

                            xmlwriter.SetValue(section, shareName, shareNameData);
                            xmlwriter.SetValue(section, sharePath, sharePathData);
                            xmlwriter.SetValue(section, sharePin, Util.Utils.EncryptPassword(sharePinData));
                            xmlwriter.SetValueAsBool(section, shareType, shareTypeData);
                            xmlwriter.SetValue(section, shareServer, shareServerData);
                            xmlwriter.SetValue(section, shareLogin, shareLoginData);
                            xmlwriter.SetValue(section, sharePwd, Util.Utils.EncryptPassword(sharePwdData));
                            xmlwriter.SetValue(section, sharePort, sharePortData.ToString());
                            xmlwriter.SetValue(section, shareRemotePath, shareRemotePathData);
                            xmlwriter.SetValue(section, shareViewPath, shareLayout);
                            xmlwriter.SetValueAsBool(section, sharewakeonlan, shareWakeOnLan);
                            xmlwriter.SetValueAsBool(section, sharedonotfolderjpgifpin, sharedonotFolderJpgIfPin);

                            if (section == "music" || section == "movies")
                            {
                                string shareScan = String.Format("sharescan{0}", index);
                                xmlwriter.SetValueAsBool(section, shareScan, shareScanData);
                            }
                            //ThumbsCreate
                            if (section == "movies")
                            {
                                string thumbs = String.Format("videothumbscreate{0}", index);
                                xmlwriter.SetValueAsBool(section, thumbs, thumbsCreate);

                                string folderMovie = String.Format("eachfolderismovie{0}", index);
                                xmlwriter.SetValueAsBool(section, folderMovie, folderIsMovie);
                            }
                        }
                    }
                }
                xmlwriter.SetValue(section, "default", defaultShare);
                xmlwriter.SetValueAsBool(section, "rememberlastfolder", RememberLastFolder);
                xmlwriter.SetValueAsBool(section, "AddOpticalDiskDrives", AddOpticalDiskDrives);
                xmlwriter.SetValueAsBool(section, "SwitchRemovableDrives", SwitchRemovableDrives);
            }
        }
        public void Save(bool saveOnlyRuntimeModifyable)
        {
            OnlineVideos.OnlineVideoSettings ovsconf = OnlineVideos.OnlineVideoSettings.Instance;
            try
            {
                using (Settings settings = new MPSettings())
                {
                    settings.SetValue(CFG_SECTION, CFG_GROUPVIEW_MODE, (int)currentGroupView);
                    settings.SetValue(CFG_SECTION, CFG_SITEVIEW_MODE, (int)currentSiteView);
                    settings.SetValue(CFG_SECTION, CFG_SITEVIEW_ORDER, (int)siteOrder);
                    settings.SetValue(CFG_SECTION, CFG_VIDEOVIEW_MODE, (int)currentVideoView);
                    settings.SetValue(CFG_SECTION, CFG_CATEGORYVIEW_MODE, (int)currentCategoryView);
                    if (lastFirstRun != default(DateTime)) settings.SetValue(CFG_SECTION, CFG_LAST_FIRSTRUN, lastFirstRun.ToString("s"));
                    try
                    {
                        MemoryStream xmlMem = new MemoryStream();
                        DataContractSerializer dcs = new DataContractSerializer(typeof(Dictionary<string, List<string>>));
                        dcs.WriteObject(xmlMem, searchHistory);
                        xmlMem.Position = 0;
                        XmlDocument xmlDoc = new XmlDocument();
                        xmlDoc.Load(xmlMem);
                        settings.SetValue(CFG_SECTION, CFG_SEARCHHISTORY, xmlDoc.InnerXml);
                    }
                    catch (Exception e)
                    {
                        Log.Instance.Warn("Error saving search history to configuration: {0}:{1}! Will be reset on next load...", e.GetType(), e.Message);
                        searchHistory = null;
                        settings.SetValue(CFG_SECTION, CFG_SEARCHHISTORY, "");
                    }

                    if (!saveOnlyRuntimeModifyable)
                    {
                        settings.SetValue(CFG_SECTION, CFG_BASICHOMESCREEN_NAME, BasicHomeScreenName);
                        settings.SetValue(CFG_SECTION, CFG_THUMBNAIL_DIR, ovsconf.ThumbsDir);
                        settings.SetValue(CFG_SECTION, CFG_THUMBNAIL_AGE, ThumbsAge);
                        settings.SetValueAsBool(CFG_SECTION, CFG_USE_AGECONFIRMATION, ovsconf.UseAgeConfirmation);
                        settings.SetValue(CFG_SECTION, CFG_PIN_AGECONFIRMATION, pinAgeConfirmation);
                        settings.SetValueAsBool(CFG_SECTION, CFG_USE_QUICKSELECT, useQuickSelect);
                        settings.SetValue(CFG_SECTION, CFG_CACHE_TIMEOUT, ovsconf.CacheTimeout);
                        settings.SetValue(CFG_SECTION, CFG_UTIL_TIMEOUT, ovsconf.UtilTimeout);
						settings.SetValue(CFG_SECTION, CFG_CATEGORYDISCOVERED_TIMEOUT, ovsconf.DynamicCategoryTimeout);
                        settings.SetValue(CFG_SECTION, CFG_WMP_BUFFER, wmpbuffer);
                        settings.SetValue(CFG_SECTION, CFG_PLAY_BUFFER, playbuffer);
                        settings.SetValue(CFG_SECTION, CFG_UPDATEPERIOD, updatePeriod);
                        if (FilterArray != null && FilterArray.Length > 0) settings.SetValue(CFG_SECTION, CFG_FILTER, string.Join(",", FilterArray));
                        if (!string.IsNullOrEmpty(ovsconf.DownloadDir)) settings.SetValue(CFG_SECTION, CFG_DOWNLOAD_DIR, ovsconf.DownloadDir);
                        if (!string.IsNullOrEmpty(email)) settings.SetValue(CFG_SECTION, CFG_EMAIL, email);
                        if (!string.IsNullOrEmpty(password)) settings.SetValue(CFG_SECTION, CFG_PASSWORD, password);
                        if (updateOnStart == null) settings.RemoveEntry(CFG_SECTION, CFG_UPDATEONSTART);
                        else settings.SetValueAsBool(CFG_SECTION, CFG_UPDATEONSTART, updateOnStart.Value);
                        settings.SetValue(CFG_SECTION, CFG_SEARCHHISTORY_NUM, searchHistoryNum);
                        settings.SetValue(CFG_SECTION, CFG_SEARCHHISTORYTYPE, (int)searchHistoryType);
                        settings.SetValueAsBool(CFG_SECTION, CFG_AUTO_LANG_GROUPS, autoGroupByLang);
                        settings.SetValueAsBool(CFG_SECTION, CFG_FAVORITES_FIRST, ovsconf.FavoritesFirst);
						settings.SetValueAsBool(CFG_SECTION, CFG_LATESTVIDEOS_RANDOMIZE, LatestVideosRandomize);
						settings.SetValue(CFG_SECTION, CFG_LATESTVIDEOS_MAXITEMS, LatestVideosMaxItems);
						settings.SetValue(CFG_SECTION, CFG_LATESTVIDEOS_ONLINEDATA_REFRESH, LatestVideosOnlineDataRefresh);
						settings.SetValue(CFG_SECTION, CFG_LATESTVIDEOS_GUIDATA_REFRESH, LatestVideosGuiDataRefresh);
						settings.SetValueAsBool(CFG_SECTION, CFG_ALLOW_REFRESHRATE_CHANGE, AllowRefreshRateChange);
						settings.SetValueAsBool(CFG_SECTION, CFG_STORE_LAYOUT_PER_CATEGORY, StoreLayoutPerCategory);
                        SaveSitesGroups();
                        ovsconf.SaveSites();

                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_HTTP_PREFERRED_NETWORK_INTERFACE, ovsconf.HttpPreferredNetworkInterface);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_HTTP_OPEN_CONNECTION_TIMEOUT, ovsconf.HttpOpenConnectionTimeout);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_HTTP_OPEN_CONNECTION_SLEEP_TIME, ovsconf.HttpOpenConnectionSleepTime);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_HTTP_TOTAL_REOPEN_CONNECTION_TIMEOUT, ovsconf.HttpTotalReopenConnectionTimeout);

                        settings.SetValueAsBool(CFG_SECTION, CFG_FILTER_V2_HTTP_SERVER_AUTHENTICATE, ovsconf.HttpServerAuthenticate);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_HTTP_SERVER_USER_NAME, ovsconf.HttpServerUserName);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_HTTP_SERVER_PASSWORD, ovsconf.HttpServerPassword);

                        settings.SetValueAsBool(CFG_SECTION, CFG_FILTER_V2_HTTP_PROXY_SERVER_AUTHENTICATE, ovsconf.HttpProxyServerAuthenticate);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_HTTP_PROXY_SERVER, ovsconf.HttpProxyServer);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_HTTP_PROXY_SERVER_PORT, ovsconf.HttpProxyServerPort);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_HTTP_PROXY_SERVER_USER_NAME, ovsconf.HttpProxyServerUserName);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_HTTP_PROXY_SERVER_PASSWORD, ovsconf.HttpProxyServerPassword);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_HTTP_PROXY_SERVER_TYPE, (int)ovsconf.HttpProxyServerType);

                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_RTMP_PREFERRED_NETWORK_INTERFACE, ovsconf.RtmpPreferredNetworkInterface);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_RTMP_OPEN_CONNECTION_TIMEOUT, ovsconf.RtmpOpenConnectionTimeout);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_RTMP_OPEN_CONNECTION_SLEEP_TIME, ovsconf.RtmpOpenConnectionSleepTime);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_RTMP_TOTAL_REOPEN_CONNECTION_TIMEOUT, ovsconf.RtmpTotalReopenConnectionTimeout);

                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_RTSP_PREFERRED_NETWORK_INTERFACE, ovsconf.RtspPreferredNetworkInterface);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_RTSP_OPEN_CONNECTION_TIMEOUT, ovsconf.RtspOpenConnectionTimeout);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_RTSP_OPEN_CONNECTION_SLEEP_TIME, ovsconf.RtspOpenConnectionSleepTime);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_RTSP_TOTAL_REOPEN_CONNECTION_TIMEOUT, ovsconf.RtspTotalReopenConnectionTimeout);

                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_RTSP_CLIENT_PORT_MIN, ovsconf.RtspClientPortMin);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_RTSP_CLIENT_PORT_MAX, ovsconf.RtspClientPortMax);

                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_UDPRTP_PREFERRED_NETWORK_INTERFACE, ovsconf.UdpRtpPreferredNetworkInterface);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_UDPRTP_OPEN_CONNECTION_TIMEOUT, ovsconf.UdpRtpOpenConnectionTimeout);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_UDPRTP_OPEN_CONNECTION_SLEEP_TIME, ovsconf.UdpRtpOpenConnectionSleepTime);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_UDPRTP_TOTAL_REOPEN_CONNECTION_TIMEOUT, ovsconf.UdpRtpTotalReopenConnectionTimeout);
                        settings.SetValue(CFG_SECTION, CFG_FILTER_V2_UDPRTP_RECEIVE_DATA_CHECK_INTERVAL, ovsconf.UdpRtpReceiveDataCheckInterval);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Instance.Error(ex);
            }
        }