diff --git a/ColorControl/ColorControl.csproj b/ColorControl/ColorControl.csproj index a45f8fe..b3bcf38 100644 --- a/ColorControl/ColorControl.csproj +++ b/ColorControl/ColorControl.csproj @@ -27,7 +27,7 @@ ColorControl Maassoft 0 - 4.3.0.0 + 4.4.0.0 false true true diff --git a/ColorControl/LgDevice.cs b/ColorControl/LgDevice.cs index dba70d1..29a81d6 100644 --- a/ColorControl/LgDevice.cs +++ b/ColorControl/LgDevice.cs @@ -289,7 +289,8 @@ namespace ColorControl _lgTvApi = null; } } - public async Task ExecutePreset(LgPreset preset, bool reconnect = false) + + public async Task ExecutePreset(LgPreset preset, bool reconnect, LgServiceConfig config) { var hasApp = !string.IsNullOrEmpty(preset.appId); @@ -315,7 +316,12 @@ namespace ColorControl { try { - await _lgTvApi.LaunchApp(preset.appId); + dynamic @params = null; + if (config.AllowFirmwareDowngrade && preset.appId.Equals("com.webos.app.softwareupdate")) + { + @params = new { mode = "user", flagUpdate = true }; + } + await _lgTvApi.LaunchApp(preset.appId, @params); } catch (Exception ex) { diff --git a/ColorControl/LgService.cs b/ColorControl/LgService.cs index 6ce70bb..cb7e8c1 100644 --- a/ColorControl/LgService.cs +++ b/ColorControl/LgService.cs @@ -350,7 +350,7 @@ namespace ColorControl return false; } - var result = await device.ExecutePreset(preset, reconnect); + var result = await device.ExecutePreset(preset, reconnect, Config); _lastAppliedPreset = preset; diff --git a/ColorControl/LgServiceConfig.cs b/ColorControl/LgServiceConfig.cs index 9773eec..070e131 100644 --- a/ColorControl/LgServiceConfig.cs +++ b/ColorControl/LgServiceConfig.cs @@ -20,6 +20,8 @@ namespace ColorControl public bool ShowRemoteControl { get; set; } + public bool AllowFirmwareDowngrade { get; set; } + public LgServiceConfig() { PowerOnDelayAfterResume = 5000; diff --git a/ColorControl/MainForm.Designer.cs b/ColorControl/MainForm.Designer.cs index 2f1bbd9..ffed692 100644 --- a/ColorControl/MainForm.Designer.cs +++ b/ColorControl/MainForm.Designer.cs @@ -178,6 +178,7 @@ this.edtDelayDisplaySettings = new System.Windows.Forms.NumericUpDown(); this.label6 = new System.Windows.Forms.Label(); this.grpGeneralOptions = new System.Windows.Forms.GroupBox(); + this.chkCheckForUpdates = new System.Windows.Forms.CheckBox(); this.chkMinimizeToSystemTray = new System.Windows.Forms.CheckBox(); this.chkMinimizeOnClose = new System.Windows.Forms.CheckBox(); this.chkStartMinimized = new System.Windows.Forms.CheckBox(); @@ -193,7 +194,7 @@ this.lbPlugins = new System.Windows.Forms.ListBox(); this.label7 = new System.Windows.Forms.Label(); this.lblInfo = new System.Windows.Forms.Label(); - this.chkCheckForUpdates = new System.Windows.Forms.CheckBox(); + this.chkLgAllowDowngrade = new System.Windows.Forms.CheckBox(); this.tcMain.SuspendLayout(); this.tabNVIDIA.SuspendLayout(); this.mnuNvPresets.SuspendLayout(); @@ -1610,7 +1611,7 @@ this.grpMiscellaneousOptions.Controls.Add(this.edtBlankScreenSaverShortcut); this.grpMiscellaneousOptions.Controls.Add(this.lblFixChromeFontsDescription); this.grpMiscellaneousOptions.Controls.Add(this.chkFixChromeFonts); - this.grpMiscellaneousOptions.Location = new System.Drawing.Point(6, 309); + this.grpMiscellaneousOptions.Location = new System.Drawing.Point(6, 253); this.grpMiscellaneousOptions.Name = "grpMiscellaneousOptions"; this.grpMiscellaneousOptions.Size = new System.Drawing.Size(400, 130); this.grpMiscellaneousOptions.TabIndex = 5; @@ -1668,14 +1669,15 @@ // // grpLGOptions // + this.grpLGOptions.Controls.Add(this.chkLgAllowDowngrade); this.grpLGOptions.Controls.Add(this.chkLgOldWolMechanism); this.grpLGOptions.Controls.Add(this.btnLGTestPower); this.grpLGOptions.Controls.Add(this.lblLgMaxPowerOnRetriesDescription); this.grpLGOptions.Controls.Add(this.edtLgMaxPowerOnRetries); this.grpLGOptions.Controls.Add(this.lblLgMaxPowerOnRetries); - this.grpLGOptions.Location = new System.Drawing.Point(6, 196); + this.grpLGOptions.Location = new System.Drawing.Point(6, 118); this.grpLGOptions.Name = "grpLGOptions"; - this.grpLGOptions.Size = new System.Drawing.Size(403, 107); + this.grpLGOptions.Size = new System.Drawing.Size(403, 129); this.grpLGOptions.TabIndex = 4; this.grpLGOptions.TabStop = false; this.grpLGOptions.Text = "LG controller"; @@ -1739,12 +1741,13 @@ // this.grpHDROptions.Controls.Add(this.edtDelayDisplaySettings); this.grpHDROptions.Controls.Add(this.label6); - this.grpHDROptions.Location = new System.Drawing.Point(6, 118); + this.grpHDROptions.Location = new System.Drawing.Point(412, 316); this.grpHDROptions.Name = "grpHDROptions"; this.grpHDROptions.Size = new System.Drawing.Size(400, 72); this.grpHDROptions.TabIndex = 3; this.grpHDROptions.TabStop = false; this.grpHDROptions.Text = "HDR"; + this.grpHDROptions.Visible = false; // // edtDelayDisplaySettings // @@ -1789,6 +1792,17 @@ this.grpGeneralOptions.TabStop = false; this.grpGeneralOptions.Text = "General"; // + // chkCheckForUpdates + // + this.chkCheckForUpdates.AutoSize = true; + this.chkCheckForUpdates.Location = new System.Drawing.Point(204, 42); + this.chkCheckForUpdates.Name = "chkCheckForUpdates"; + this.chkCheckForUpdates.Size = new System.Drawing.Size(177, 17); + this.chkCheckForUpdates.TabIndex = 6; + this.chkCheckForUpdates.Text = "Automatically check for updates"; + this.chkCheckForUpdates.UseVisualStyleBackColor = true; + this.chkCheckForUpdates.CheckedChanged += new System.EventHandler(this.chkCheckForUpdates_CheckedChanged); + // // chkMinimizeToSystemTray // this.chkMinimizeToSystemTray.AutoSize = true; @@ -1954,16 +1968,16 @@ this.lblInfo.TabIndex = 1; this.lblInfo.Text = "Info"; // - // chkCheckForUpdates + // chkLgAllowDowngrade // - this.chkCheckForUpdates.AutoSize = true; - this.chkCheckForUpdates.Location = new System.Drawing.Point(204, 42); - this.chkCheckForUpdates.Name = "chkCheckForUpdates"; - this.chkCheckForUpdates.Size = new System.Drawing.Size(177, 17); - this.chkCheckForUpdates.TabIndex = 6; - this.chkCheckForUpdates.Text = "Automatically check for updates"; - this.chkCheckForUpdates.UseVisualStyleBackColor = true; - this.chkCheckForUpdates.CheckedChanged += new System.EventHandler(this.chkCheckForUpdates_CheckedChanged); + this.chkLgAllowDowngrade.AutoSize = true; + this.chkLgAllowDowngrade.Location = new System.Drawing.Point(9, 97); + this.chkLgAllowDowngrade.Name = "chkLgAllowDowngrade"; + this.chkLgAllowDowngrade.Size = new System.Drawing.Size(275, 17); + this.chkLgAllowDowngrade.TabIndex = 8; + this.chkLgAllowDowngrade.Text = "Allow firmware downgrade with Software Update-app"; + this.chkLgAllowDowngrade.UseVisualStyleBackColor = true; + this.chkLgAllowDowngrade.CheckedChanged += new System.EventHandler(this.chkLgAllowDowngrade_CheckedChanged); // // MainForm // @@ -2186,6 +2200,7 @@ private System.Windows.Forms.Button btnLgPresetEditTriggerConditions; private System.Windows.Forms.TextBox edtLgPresetTriggerConditions; private System.Windows.Forms.CheckBox chkCheckForUpdates; + private System.Windows.Forms.CheckBox chkLgAllowDowngrade; } } diff --git a/ColorControl/MainForm.cs b/ColorControl/MainForm.cs index b820d8c..58539ed 100644 --- a/ColorControl/MainForm.cs +++ b/ColorControl/MainForm.cs @@ -178,6 +178,7 @@ namespace ColorControl edtLgMaxPowerOnRetries.Value = _lgService.Config.PowerOnRetries; edtLgDeviceFilter.Text = _lgService.Config.DeviceSearchKey; chkLgOldWolMechanism.Checked = _lgService.Config.UseOldNpcapWol; + chkLgAllowDowngrade.Checked = _lgService.Config.AllowFirmwareDowngrade; var values = Enum.GetValues(typeof(ButtonType)); foreach (var button in values) @@ -2816,5 +2817,32 @@ Do you want to continue?" _config.CheckForUpdates = chkCheckForUpdates.Checked; } } + + private void chkLgAllowDowngrade_CheckedChanged(object sender, EventArgs e) + { + if (!_initialized) + { + return; + } + + if (chkLgAllowDowngrade.Checked) + { + if (MessageForms.QuestionYesNo( +@"Are you sure you want to enable firmware downgrade functionality with the Software Update-app? +This may cause irreversible damage to your tv and will void your warranty. +This app and its creator are in no way accountable for any damages it may cause to your tv." + ) != DialogResult.Yes) + { + chkLgAllowDowngrade.Checked = false; + return; + } + MessageForms.InfoOk( +@"Firmware downgrade functionality activated. +In order to use it, you must create and execute a preset on the LG controller tab that starts the app Software Update (com.webos.app.softwareupdate)." + ); + } + + _lgService.Config.AllowFirmwareDowngrade = chkLgAllowDowngrade.Checked; + } } } \ No newline at end of file diff --git a/ColorControl/MessageForms.cs b/ColorControl/MessageForms.cs index c4153a0..915d916 100644 --- a/ColorControl/MessageForms.cs +++ b/ColorControl/MessageForms.cs @@ -40,7 +40,14 @@ namespace ColorControl public static void InfoOk(string text, string title = null, string url = null) { - MessageBox.Show(text, title ?? MainForm?.Text, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, 0, url); + if (url != null) + { + MessageBox.Show(text, title ?? MainForm?.Text, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, 0, url); + } + else + { + MessageBox.Show(text, title ?? MainForm?.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); + } } public static DialogResult QuestionYesNo(string text) diff --git a/ColorControl/Properties/AssemblyInfo.cs b/ColorControl/Properties/AssemblyInfo.cs index ef59674..8da5b59 100644 --- a/ColorControl/Properties/AssemblyInfo.cs +++ b/ColorControl/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("4.3.0.0")] -[assembly: AssemblyFileVersion("4.3.0.0")] +[assembly: AssemblyVersion("4.4.0.0")] +[assembly: AssemblyFileVersion("4.4.0.0")] diff --git a/ColorControl/lgtv/LgTvApi.cs b/ColorControl/lgtv/LgTvApi.cs index 4a4b273..1ce7ce6 100644 --- a/ColorControl/lgtv/LgTvApi.cs +++ b/ColorControl/lgtv/LgTvApi.cs @@ -447,9 +447,19 @@ namespace LgTv return appList.OrderBy(e => e.title); } - public async Task LaunchApp(string appId) + public async Task LaunchApp(string appId, dynamic @params = null) { - var requestMessage = new RequestMessage("ssap://system.launcher/launch", new { id = appId }); + dynamic payload; + if (@params != null) + { + payload = new { id = appId, @params = @params }; + } + else + { + payload = new { id = appId }; + } + + var requestMessage = new RequestMessage("ssap://system.launcher/launch", payload); var response = await _connection.SendCommandAsync(requestMessage); return (string)response.sessionId; }