From: Lars Op den Kamp Date: Sun, 7 Oct 2012 19:02:02 +0000 (+0200) Subject: added new settings from xbmc to LibCecTray X-Git-Tag: upstream/2.2.0~1^2~17^2^2~14 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=1b09c8f6e10ccf58dd03b7a01b80b9fd887dfc12;p=deb_libcec.git added new settings from xbmc to LibCecTray --- diff --git a/src/LibCecTray/Properties/Resources.Designer.cs b/src/LibCecTray/Properties/Resources.Designer.cs index ecf2b61..0285bd3 100644 --- a/src/LibCecTray/Properties/Resources.Designer.cs +++ b/src/LibCecTray/Properties/Resources.Designer.cs @@ -312,6 +312,15 @@ namespace LibCECTray.Properties { } } + /// + /// Looks up a localized string similar to Pause playback when switching to another source. + /// + internal static string app_pause_playback_on_deactivate { + get { + return ResourceManager.GetString("app_pause_playback_on_deactivate", resourceCulture); + } + } + /// /// Looks up a localized string similar to Send inactive source message when stopping the application. /// diff --git a/src/LibCecTray/Properties/Resources.resx b/src/LibCecTray/Properties/Resources.resx index 31cab95..14f481e 100644 --- a/src/LibCecTray/Properties/Resources.resx +++ b/src/LibCecTray/Properties/Resources.resx @@ -591,4 +591,7 @@ Error + + Pause playback when switching to another source + \ No newline at end of file diff --git a/src/LibCecTray/controller/applications/internal/XBMCController.cs b/src/LibCecTray/controller/applications/internal/XBMCController.cs index fe15fd2..c269788 100644 --- a/src/LibCecTray/controller/applications/internal/XBMCController.cs +++ b/src/LibCecTray/controller/applications/internal/XBMCController.cs @@ -123,9 +123,9 @@ namespace LibCECTray.controller.applications.@internal break; case "connected_device": { - ushort iDevice; - if (ushort.TryParse(value, out iDevice)) - Settings.ConnectedDevice.Value = (CecLogicalAddress)iDevice; + int iDevice; + if (int.TryParse(value, out iDevice)) + Settings.ConnectedDevice.Value = iDevice == 36038 ? CecLogicalAddress.AudioSystem : CecLogicalAddress.Tv; } break; case "cec_power_on_startup": @@ -170,7 +170,29 @@ namespace LibCECTray.controller.applications.@internal Settings.TVVendor.Value = (CecVendorId)iVendor; } break; - case "wake_devices": + case "wake_device": + { + int iWakeDevices; + if (int.TryParse(value, out iWakeDevices)) + { + Settings.WakeDevices.Value.Clear(); + switch (iWakeDevices) + { + case 36037: + Settings.WakeDevices.Value.Set(CecLogicalAddress.Tv); + break; + case 36038: + Settings.WakeDevices.Value.Set(CecLogicalAddress.AudioSystem); + break; + case 36039: + Settings.WakeDevices.Value.Set(CecLogicalAddress.Tv); + Settings.WakeDevices.Value.Set(CecLogicalAddress.AudioSystem); + break; + } + } + } + break; + case "wake_devices_advanced": { Settings.WakeDevices.Value.Clear(); string[] split = value.Split(new[] { ' ' }); @@ -183,6 +205,28 @@ namespace LibCECTray.controller.applications.@internal } break; case "standby_devices": + { + int iStandbyDevices; + if (int.TryParse(value, out iStandbyDevices)) + { + Settings.PowerOffDevices.Value.Clear(); + switch (iStandbyDevices) + { + case 36037: + Settings.PowerOffDevices.Value.Set(CecLogicalAddress.Tv); + break; + case 36038: + Settings.PowerOffDevices.Value.Set(CecLogicalAddress.AudioSystem); + break; + case 36039: + Settings.PowerOffDevices.Value.Set(CecLogicalAddress.Tv); + Settings.PowerOffDevices.Value.Set(CecLogicalAddress.AudioSystem); + break; + } + } + } + break; + case "standby_devices_advanced": { Settings.PowerOffDevices.Value.Clear(); string[] split = value.Split(new[] { ' ' }); @@ -203,6 +247,10 @@ namespace LibCECTray.controller.applications.@internal case "send_inactive_source": SendInactiveSource.Value = value.Equals("1") || value.ToLower().Equals("true") || value.ToLower().Equals("yes"); break; + // 1.9.0+ settings + case "pause_playback_on_deactivate": + PausePlaybackOnDeactivate.Value = value.Equals("1") || value.ToLower().Equals("true") || value.ToLower().Equals("yes"); + break; } } break; @@ -212,6 +260,14 @@ namespace LibCECTray.controller.applications.@internal return gotConfig; } + static bool HasAdvancedDeviceIdSet(CecLogicalAddresses addresses) + { + foreach (var val in addresses.Addresses) + if (val != CecLogicalAddress.Tv && val != CecLogicalAddress.AudioSystem) + return true; + return false; + } + public void SaveXMLConfiguration() { Settings.Persist(); @@ -258,7 +314,7 @@ namespace LibCECTray.controller.applications.@internal StringBuilder output = new StringBuilder(); output.AppendLine(""); output.AppendLine(""); - output.AppendLine(""); + output.AppendLine(""); output.AppendLine(""); output.AppendLine(""); output.AppendLine(""); @@ -274,26 +330,55 @@ namespace LibCECTray.controller.applications.@internal output.AppendLine(""); output.AppendLine(""); - output.Append(""); + if (HasAdvancedDeviceIdSet(Settings.WakeDevices.Value)) + { + output.Append(""); + } + + if (Settings.WakeDevices.Value.IsSet(CecLogicalAddress.Tv) && + Settings.WakeDevices.Value.IsSet(CecLogicalAddress.AudioSystem)) + output.Append(""); + else if (Settings.WakeDevices.Value.IsSet(CecLogicalAddress.Tv)) + output.Append(""); + else if (Settings.WakeDevices.Value.IsSet(CecLogicalAddress.AudioSystem)) + output.Append(""); + else + output.Append(""); + + if (HasAdvancedDeviceIdSet(Settings.PowerOffDevices.Value)) + { + output.Append(""); + } - output.Append(""); + if (Settings.PowerOffDevices.Value.IsSet(CecLogicalAddress.Tv) && + Settings.PowerOffDevices.Value.IsSet(CecLogicalAddress.AudioSystem)) + output.Append(""); + else if (Settings.PowerOffDevices.Value.IsSet(CecLogicalAddress.Tv)) + output.Append(""); + else if (Settings.PowerOffDevices.Value.IsSet(CecLogicalAddress.AudioSystem)) + output.Append(""); + else + output.Append(""); // only supported by 1.5.1+ clients output.AppendLine(""); output.AppendLine(""); + // only supported by 1.9.0+ clients + output.AppendLine(""); + output.AppendLine(""); writer.Write(output.ToString()); writer.Close(); @@ -372,5 +457,19 @@ namespace LibCECTray.controller.applications.@internal return Settings[ProcessName + "_send_inactive_source"].AsSettingBool; } } + + public CECSettingBool PausePlaybackOnDeactivate + { + get + { + if (!Settings.ContainsKey(ProcessName + "_pause_playback_on_deactivate")) + { + CECSettingBool setting = new CECSettingBool(ProcessName + "_pause_playback_on_deactivate", Resources.app_pause_playback_on_deactivate, true, null); + Settings.Load(setting); + Settings[ProcessName + "_pause_playback_on_deactivate"] = setting; + } + return Settings[ProcessName + "_pause_playback_on_deactivate"].AsSettingBool; + } + } } } diff --git a/src/LibCecTray/controller/applications/internal/XBMCControllerUI.Designer.cs b/src/LibCecTray/controller/applications/internal/XBMCControllerUI.Designer.cs index e1b4b12..df02422 100644 --- a/src/LibCecTray/controller/applications/internal/XBMCControllerUI.Designer.cs +++ b/src/LibCecTray/controller/applications/internal/XBMCControllerUI.Designer.cs @@ -39,6 +39,7 @@ this.bSaveConfig = new System.Windows.Forms.Button(); this.cbStandbyTvStandby = new System.Windows.Forms.CheckBox(); this.cbInactiveSource = new System.Windows.Forms.CheckBox(); + this.cbPauseOnDeactivate = new System.Windows.Forms.CheckBox(); ((System.ComponentModel.ISupportInitialize)(this.buttonBindingSource)).BeginInit(); this.SuspendLayout(); // @@ -142,9 +143,21 @@ this.cbInactiveSource.Text = "app_send_inactive_source"; this.cbInactiveSource.UseVisualStyleBackColor = true; // + // cbPauseOnDeactivate + // + this.cbPauseOnDeactivate.AutoSize = true; + this.cbPauseOnDeactivate.Enabled = false; + this.cbPauseOnDeactivate.Location = new System.Drawing.Point(11, 135); + this.cbPauseOnDeactivate.Name = "cbPauseOnDeactivate"; + this.cbPauseOnDeactivate.Size = new System.Drawing.Size(202, 17); + this.cbPauseOnDeactivate.TabIndex = 59; + this.cbPauseOnDeactivate.Text = "app_pause_playback_on_deactivate"; + this.cbPauseOnDeactivate.UseVisualStyleBackColor = true; + // // XBMCControllerUI // this.ClientSize = new System.Drawing.Size(576, 306); + this.Controls.Add(this.cbPauseOnDeactivate); this.Controls.Add(this.cbInactiveSource); this.Controls.Add(this.cbStandbyTvStandby); this.Controls.Add(this.bSaveConfig); @@ -174,5 +187,6 @@ private System.Windows.Forms.Button bSaveConfig; private System.Windows.Forms.CheckBox cbStandbyTvStandby; private System.Windows.Forms.CheckBox cbInactiveSource; + private System.Windows.Forms.CheckBox cbPauseOnDeactivate; } } \ No newline at end of file diff --git a/src/LibCecTray/controller/applications/internal/XBMCControllerUI.cs b/src/LibCecTray/controller/applications/internal/XBMCControllerUI.cs index 9dc6e61..7c2226f 100644 --- a/src/LibCecTray/controller/applications/internal/XBMCControllerUI.cs +++ b/src/LibCecTray/controller/applications/internal/XBMCControllerUI.cs @@ -55,6 +55,7 @@ namespace LibCECTray.controller.applications.@internal _controller.StandbyScreensaver.ReplaceControls(this, Controls, cbStandbyScreensaver); _controller.PowerOffOnStandby.ReplaceControls(this, Controls, cbStandbyTvStandby); _controller.SendInactiveSource.ReplaceControls(this, Controls, cbInactiveSource); + _controller.PausePlaybackOnDeactivate.ReplaceControls(this, Controls, cbPauseOnDeactivate); SetEnabled(false); } @@ -77,6 +78,7 @@ namespace LibCECTray.controller.applications.@internal SetControlEnabled(bSaveConfig, val); SetControlEnabled(bLoadConfig, val); SetControlEnabled(bConfigure, _controller.CanConfigureProcess && val); + SetControlEnabled(_controller.PausePlaybackOnDeactivate.ValueControl, val); } public override void SetStartButtonEnabled(bool val)