X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2FLibCecTray%2Fcontroller%2Fapplications%2Finternal%2FXBMCController.cs;h=fe15fd25edc18d3b62c2442ab9d3ce17b2433d4d;hb=f4729954da8ed049a6bc5ea6bbd72e30f158ddc9;hp=9e4fb3a1973d717351d04993bb8cc145a4d4b212;hpb=8768aecabf8219cdf0ceb28a8b9ca4ef6756b612;p=deb_libcec.git diff --git a/src/LibCecTray/controller/applications/internal/XBMCController.cs b/src/LibCecTray/controller/applications/internal/XBMCController.cs index 9e4fb3a..fe15fd2 100644 --- a/src/LibCecTray/controller/applications/internal/XBMCController.cs +++ b/src/LibCecTray/controller/applications/internal/XBMCController.cs @@ -56,6 +56,17 @@ namespace LibCECTray.controller.applications.@internal ControlApplication.Value = false; LoadXMLConfiguration(); + + ApplicationRunningChanged += RunningChanged; + } + + static void RunningChanged(bool running) + { + if (running) + { + // XBMC is running, close the application, or we'll block communication + Application.Exit(); + } } public override ApplicationAction DefaultValue(CecKeypress key) @@ -70,16 +81,18 @@ namespace LibCECTray.controller.applications.@internal public bool LoadXMLConfiguration() { - bool gotConfig = false; - string xbmcDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\XBMC\userdata\peripheral_data"; - string defaultDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); - string file = defaultDir + @"\usb_2548_1001.xml"; - if (File.Exists(xbmcDir + @"\usb_2548_1001.xml")) - file = xbmcDir + @"\usb_2548_1001.xml"; + var xbmcDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\XBMC\userdata\peripheral_data"; + return LoadXMLConfiguration(xbmcDir + string.Format(@"\usb_{0:X}_{1:X}.xml", Program.Instance.Controller.AdapterVendorId, Program.Instance.Controller.AdapterProductId)) || + LoadXMLConfiguration(xbmcDir + @"\usb_2548_1001.xml") || + LoadXMLConfiguration(xbmcDir + @"\usb_2548_1002.xml"); + } - if (File.Exists(file)) + public bool LoadXMLConfiguration(string filename) + { + bool gotConfig = false; + if (File.Exists(filename)) { - XmlTextReader reader = new XmlTextReader(file); + XmlTextReader reader = new XmlTextReader(filename); while (reader.Read()) { gotConfig = true; @@ -203,14 +216,23 @@ namespace LibCECTray.controller.applications.@internal { Settings.Persist(); - string xbmcDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\XBMC\userdata\peripheral_data"; - string defaultDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); + var xbmcDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\XBMC\userdata\peripheral_data"; + if (!Directory.Exists(xbmcDir)) + Directory.CreateDirectory(xbmcDir); + + if (!Directory.Exists(xbmcDir)) + { + // couldn't create directory + MessageBox.Show(string.Format(Resources.could_not_create_directory, xbmcDir), Resources.error, + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } SaveFileDialog dialog = new SaveFileDialog - { + { Title = Resources.store_settings_where, - InitialDirectory = Directory.Exists(xbmcDir) ? xbmcDir : defaultDir, - FileName = "usb_2548_1001.xml", + InitialDirectory = xbmcDir, + FileName = string.Format("usb_{0:X}_{1:X}.xml", Program.Instance.Controller.AdapterVendorId, Program.Instance.Controller.AdapterProductId), Filter = Resources.xml_file_filter, FilterIndex = 1 }; @@ -270,8 +292,7 @@ namespace LibCECTray.controller.applications.@internal // only supported by 1.5.1+ clients output.AppendLine(""); - //TODO - //output.AppendLine(""); + output.AppendLine(""); output.AppendLine(""); writer.Write(output.ToString());