From: Lars Op den Kamp Date: Sat, 6 Oct 2012 12:12:45 +0000 (+0200) Subject: load and save the 2548:1002 config for XBMC too. try to create the profile directory... X-Git-Tag: upstream/2.2.0~1^2~17^2^2~28 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=496897540ebcc6fc13b346aa5e08f2148a2770c7;p=deb_libcec.git load and save the 2548:1002 config for XBMC too. try to create the profile directory if the tray tool was started before starting XBMC for the first time --- diff --git a/src/LibCecTray/Properties/Resources.Designer.cs b/src/LibCecTray/Properties/Resources.Designer.cs index 817b21e..ecf2b61 100644 --- a/src/LibCecTray/Properties/Resources.Designer.cs +++ b/src/LibCecTray/Properties/Resources.Designer.cs @@ -465,6 +465,15 @@ namespace LibCECTray.Properties { } } + /// + /// Looks up a localized string similar to Couldn't create directory '{0}'. + /// + internal static string could_not_create_directory { + get { + return ResourceManager.GetString("could_not_create_directory", resourceCulture); + } + } + /// /// Looks up a localized string similar to AVR. /// @@ -546,6 +555,15 @@ namespace LibCECTray.Properties { } } + /// + /// Looks up a localized string similar to Error. + /// + internal static string error { + get { + return ResourceManager.GetString("error", resourceCulture); + } + } + /// /// Looks up a localized string similar to Executables (*.exe)|*.exe|All files (*.*)|*.*. /// diff --git a/src/LibCecTray/Properties/Resources.resx b/src/LibCecTray/Properties/Resources.resx index 8ff31f6..31cab95 100644 --- a/src/LibCecTray/Properties/Resources.resx +++ b/src/LibCecTray/Properties/Resources.resx @@ -585,4 +585,10 @@ Put devices in standby mode when activating screensaver + + Couldn't create directory '{0}' + + + Error + \ No newline at end of file diff --git a/src/LibCecTray/controller/CECController.cs b/src/LibCecTray/controller/CECController.cs index f7a3a04..13d7520 100644 --- a/src/LibCecTray/controller/CECController.cs +++ b/src/LibCecTray/controller/CECController.cs @@ -490,6 +490,20 @@ namespace LibCECTray.controller get { return Lib.ToString(Config.ClientVersion); } } + /// + /// Get the usb vid:prod descriptor + /// + public string USBDescriptor + { + get + { + DateTime checkDate = new DateTime(1970, 1, 1, 0, 0, 0, 0); + checkDate = checkDate.AddSeconds(0x5045dbf5); + + return string.Format("2548:100{0}", ((DateTime)Config.FirmwareBuildDate >= checkDate ? "2" : "1")); + } + } + /// /// libCEC /// diff --git a/src/LibCecTray/controller/applications/internal/XBMCController.cs b/src/LibCecTray/controller/applications/internal/XBMCController.cs index 9e4fb3a..5ffe8f9 100644 --- a/src/LibCecTray/controller/applications/internal/XBMCController.cs +++ b/src/LibCecTray/controller/applications/internal/XBMCController.cs @@ -70,16 +70,16 @@ 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 + @"\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 +203,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}.xml", Program.Instance.Controller.USBDescriptor.Replace(':', '_')), Filter = Resources.xml_file_filter, FilterIndex = 1 }; diff --git a/src/LibCecTray/ui/CECTray.cs b/src/LibCecTray/ui/CECTray.cs index a44cd8a..e8dd66b 100644 --- a/src/LibCecTray/ui/CECTray.cs +++ b/src/LibCecTray/ui/CECTray.cs @@ -491,6 +491,10 @@ namespace LibCECTray.ui private ConfigTab _selectedTab = ConfigTab.Configuration; private string _log = string.Empty; private readonly CECController _controller; + public CECController Controller + { + get { return _controller; } + } public Control.ControlCollection TabControls { get { return tabPanel.Controls; }