Exemple #1
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            using (MediaPortal.Profile.Settings xmlWriter = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MQTTPlugin.xml")))
            {
                xmlWriter.SetValueAsBool(MQTTPlugin.PLUGIN_NAME, "WindowChange", WindowChange_checkBox.Checked);
                xmlWriter.SetValue(MQTTPlugin.PLUGIN_NAME, "SetLevelForMediaDuration", Convert.ToInt32(mediaDuration_textBox.Text));

                xmlWriter.SetValue(MQTTPlugin.BROKER, "Host", host_textBox.Text);
                xmlWriter.SetValue(MQTTPlugin.BROKER, "Port", port_textBox.Text);
                xmlWriter.SetValue(MQTTPlugin.BROKER, "User", user_textBox.Text);
                xmlWriter.SetValue(MQTTPlugin.BROKER, "Password", DPAPI.EncryptString(password_textBox.Text));

                xmlWriter.SetValueAsBool(MQTTPlugin.PLUGIN_NAME, "DebugMode", debug_checkBox.Checked);
            }
        }
Exemple #2
0
        private void displayDeviceSettings()
        {
            using (var xmlReader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MQTTPlugin.xml")))
            {
                WindowChange_checkBox.Checked = xmlReader.GetValueAsBool(MQTTPlugin.PLUGIN_NAME, "WindowChange", true);
                mediaDuration_textBox.Text    = (xmlReader.GetValueAsInt(MQTTPlugin.PLUGIN_NAME, "SetLevelForMediaDuration", 10)).ToString();

                host_textBox.Text     = xmlReader.GetValueAsString(MQTTPlugin.BROKER, "Host", string.Empty);
                port_textBox.Text     = xmlReader.GetValueAsString(MQTTPlugin.BROKER, "Port", "1883");
                user_textBox.Text     = xmlReader.GetValueAsString(MQTTPlugin.BROKER, "User", string.Empty);
                password_textBox.Text = DPAPI.DecryptString(xmlReader.GetValueAsString(MQTTPlugin.BROKER, "Password", string.Empty));

                debug_checkBox.Checked = xmlReader.GetValueAsBool(MQTTPlugin.PLUGIN_NAME, "DebugMode", false);
            }
        }
Exemple #3
0
        public static string DecryptString(string text)
        {
            try
            {
                string entropy = null;
                string description;

                string decrypted = DPAPI.Decrypt(text, entropy, out description);
                return(decrypted);
            }
            catch (Exception ex)
            {
                while (ex != null)
                {
                    Logger.Error(ex.Message);
                    ex = ex.InnerException;
                }
                return(null);
            }
        }
Exemple #4
0
        public static string EncryptString(string text)
        {
            try
            {
                string entropy = null;

                // Call DPAPI to encrypt data with user-specific key.
                string encrypted = DPAPI.Encrypt(DPAPI.KeyType.UserKey, text, entropy, "string");
                return(encrypted);
            }
            catch (Exception ex)
            {
                while (ex != null)
                {
                    Logger.Error(ex.Message);
                    ex = ex.InnerException;
                }
                return(null);
            }
        }
Exemple #5
0
        public MQTTPlugin()
        {
            SystemStandby = false;
            PublishedId   = 0;
            using (Settings xmlReader = new Settings(Config.GetFile(Config.Dir.Config, "MQTTPlugin.xml")))
            {
                WindowChange = xmlReader.GetValueAsBool(PLUGIN_NAME, "WindowChange", false);

                Host     = xmlReader.GetValueAsString(BROKER, "Host", string.Empty);
                Port     = xmlReader.GetValueAsString(BROKER, "Port", "1883");
                User     = xmlReader.GetValueAsString(BROKER, "User", string.Empty);
                Password = DPAPI.DecryptString(xmlReader.GetValueAsString(BROKER, "Password", string.Empty));

                setLevelForMediaDuration = xmlReader.GetValueAsInt(PLUGIN_NAME, "SetLevelForMediaDuration", 10);

                DebugMode = xmlReader.GetValueAsBool(PLUGIN_NAME, "DebugMode", false);
            }
            HostName       = Dns.GetHostName();
            BaseTopic      = "Mediaportal/" + HostName + "/";
            Utils.Language = Utils.GetLang().ToLowerInvariant();
            DialogBusy     = false;
        }