|
From: <an...@us...> - 2007-05-16 07:37:17
|
Revision: 403
http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=403&view=rev
Author: and-81
Date: 2007-05-16 00:37:02 -0700 (Wed, 16 May 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.cs
trunk/plugins/IR Server Suite/Applications/IR Server/Config.cs
trunk/plugins/IR Server Suite/Applications/IR Server/IR Server.csproj
trunk/plugins/IR Server Suite/Applications/IR Server/IRServer.cs
trunk/plugins/IR Server Suite/Applications/IR Server/Program.cs
trunk/plugins/IR Server Suite/Applications/Translator/Configuration.cs
trunk/plugins/IR Server Suite/Applications/Translator/Forms/MainForm.cs
trunk/plugins/IR Server Suite/Applications/Translator/Program.cs
trunk/plugins/IR Server Suite/Applications/Tray Launcher/Program.cs
trunk/plugins/IR Server Suite/Applications/Tray Launcher/Setup.cs
trunk/plugins/IR Server Suite/Applications/Tray Launcher/Tray.cs
trunk/plugins/IR Server Suite/Applications/Virtual Remote/MainForm.cs
trunk/plugins/IR Server Suite/Applications/Virtual Remote Skin Editor/MainForm.cs
trunk/plugins/IR Server Suite/Common/IrssUtils/IrssUtils.csproj
trunk/plugins/IR Server Suite/IPC/AppModule.InterProcessComm/AppModule.InterProcessComm.csproj
trunk/plugins/IR Server Suite/IPC/AppModule.NamedPipes/AppModule.NamedPipes.csproj
trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IR Server Plugin Interface.csproj
trunk/plugins/IR Server Suite/IR Server Suite.sln
trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Blast Zone Plugin/Forms/SetupForm.cs
trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Blast Zone Plugin/MPBlastZonePlugin.cs
trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Control Plugin/Forms/SetupForm.cs
trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Control Plugin/MPControlPlugin.cs
trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/Forms/SetupForm.cs
trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/Forms/StbSetup.cs
trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/TV2BlasterPlugin.cs
trunk/plugins/IR Server Suite/MediaPortal Plugins/TV3 Blaster Plugin/Forms/PluginSetup.cs
trunk/plugins/IR Server Suite/MediaPortal Plugins/TV3 Blaster Plugin/Forms/StbSetup.cs
trunk/plugins/IR Server Suite/MediaPortal Plugins/TV3 Blaster Plugin/TV3BlasterPlugin.cs
Added Paths:
-----------
trunk/plugins/IR Server Suite/Common/IrssUtils/SystemRegistry.cs
Modified: trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.cs
===================================================================
--- trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.cs 2007-05-15 06:15:21 UTC (rev 402)
+++ trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.cs 2007-05-16 07:37:02 UTC (rev 403)
@@ -10,8 +10,6 @@
using System.Text;
using System.Windows.Forms;
-using Microsoft.Win32;
-
using NamedPipes;
using IrssUtils;
@@ -97,7 +95,7 @@
#region Constants
- const string TempIRFile = "test.IR";
+ const string TempIRFile = "test.IR";
#endregion
@@ -190,10 +188,12 @@
{
_transceiverInfo = TransceiverInfo.FromBytes(received.Data);
- comboBoxPort.Items.Add(_transceiverInfo.Ports);
+ comboBoxPort.Items.Clear();
+ comboBoxPort.Items.AddRange(_transceiverInfo.Ports);
comboBoxPort.SelectedIndex = 0;
- comboBoxSpeed.Items.Add(_transceiverInfo.Speeds);
+ comboBoxSpeed.Items.Clear();
+ comboBoxSpeed.Items.AddRange(_transceiverInfo.Speeds);
comboBoxSpeed.SelectedIndex = 0;
return;
}
@@ -574,12 +574,15 @@
private void buttonHelp_Click(object sender, EventArgs e)
{
- RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("Software\\IR Server Suite\\");
- string installFolder = (string)registryKey.GetValue("Install_Dir", String.Empty);
- registryKey.Close();
-
- Help.ShowHelp(this, installFolder + "\\IR Server Suite.chm");
- // , HelpNavigator.Topic, "index.html"
+ try
+ {
+ Help.ShowHelp(this, SystemRegistry.GetInstallFolder() + "\\IR Server Suite.chm");
+ // , HelpNavigator.Topic, "index.html"
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(this, ex.Message, "Failed to load help", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
}
#endregion Controls
Modified: trunk/plugins/IR Server Suite/Applications/IR Server/Config.cs
===================================================================
--- trunk/plugins/IR Server Suite/Applications/IR Server/Config.cs 2007-05-15 06:15:21 UTC (rev 402)
+++ trunk/plugins/IR Server Suite/Applications/IR Server/Config.cs 2007-05-16 07:37:02 UTC (rev 403)
@@ -9,8 +9,6 @@
using System.Text;
using System.Windows.Forms;
-using Microsoft.Win32;
-
using IRServerPluginInterface;
using IrssUtils;
@@ -104,9 +102,7 @@
try
{
- RegistryKey key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
- checkBoxRunAtBoot.Checked = (key.GetValue("IR Server", null) != null);
- key.Close();
+ checkBoxRunAtBoot.Checked = SystemRegistry.GetAutoRun("IR Server");
}
catch
{
@@ -138,12 +134,10 @@
{
try
{
- RegistryKey key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
if (checkBoxRunAtBoot.Checked)
- key.SetValue("IR Server", Application.ExecutablePath);
+ SystemRegistry.SetAutoRun("IR Server", Application.ExecutablePath);
else
- key.DeleteValue("IR Server", false);
- key.Close();
+ SystemRegistry.RemoveAutoRun("IR Server");
}
catch (Exception ex)
{
@@ -181,12 +175,14 @@
private void buttonHelp_Click(object sender, EventArgs e)
{
- RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("Software\\IR Server Suite\\");
- string installFolder = (string)registryKey.GetValue("Install_Dir", String.Empty);
- registryKey.Close();
-
- Help.ShowHelp(this, installFolder + "\\IR Server Suite.chm");
- // , HelpNavigator.Topic, "index.html"
+ try
+ {
+ Help.ShowHelp(this, SystemRegistry.GetInstallFolder() + "\\IR Server Suite.chm", HelpNavigator.Topic, "IR Server");
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(this, ex.Message, "Failed to load help", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
}
#endregion Controls
Modified: trunk/plugins/IR Server Suite/Applications/IR Server/IR Server.csproj
===================================================================
--- trunk/plugins/IR Server Suite/Applications/IR Server/IR Server.csproj 2007-05-15 06:15:21 UTC (rev 402)
+++ trunk/plugins/IR Server Suite/Applications/IR Server/IR Server.csproj 2007-05-16 07:37:02 UTC (rev 403)
@@ -119,7 +119,6 @@
<ProjectReference Include="..\..\IR Server Plugins\IR Server Plugin Interface\IR Server Plugin Interface.csproj">
<Project>{D8B3D28F-62CE-4CA7-86CE-B7EAD614A94C}</Project>
<Name>IR Server Plugin Interface</Name>
- <Private>True</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Modified: trunk/plugins/IR Server Suite/Applications/IR Server/IRServer.cs
===================================================================
--- trunk/plugins/IR Server Suite/Applications/IR Server/IRServer.cs 2007-05-15 06:15:21 UTC (rev 402)
+++ trunk/plugins/IR Server Suite/Applications/IR Server/IRServer.cs 2007-05-16 07:37:02 UTC (rev 403)
@@ -6,6 +6,7 @@
using System.Text;
using System.Threading;
using System.Windows.Forms;
+using System.Xml;
using Microsoft.Win32;
using Microsoft.Win32.SafeHandles;
@@ -43,6 +44,12 @@
internal class IRServer
{
+ #region Constants
+
+ public static readonly string ConfigurationFile = Common.FolderAppData + "IR Server\\IR Server.xml";
+
+ #endregion Constants
+
#region Variables
NotifyIcon _notifyIcon;
@@ -64,31 +71,23 @@
string _pluginName = String.Empty;
IIRServerPlugin _plugin = null;
+ bool _inConfiguration = false;
+
#endregion Variables
#region Constructor
public IRServer()
{
- try
- {
- // Load settings
- RegistryKey key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\and-81\IRServer");
+ // Setup taskbar icon
+ _notifyIcon = new NotifyIcon();
+ _notifyIcon.ContextMenuStrip = new ContextMenuStrip();
+ _notifyIcon.ContextMenuStrip.Items.Add(new ToolStripMenuItem("&Setup", null, new EventHandler(ClickSetup)));
+ _notifyIcon.ContextMenuStrip.Items.Add(new ToolStripMenuItem("&Quit", null, new EventHandler(ClickQuit)));
+ _notifyIcon.Icon = Properties.Resources.Icon16;
+ _notifyIcon.Text = "IR Server";
- _mode = (IRServerMode)key.GetValue("Mode", (int)IRServerMode.ServerMode);
- _hostComputer = (string)key.GetValue("HostComputer", String.Empty);
- _pluginName = (string)key.GetValue("Plugin", String.Empty);
- key.Close();
- }
- catch (Exception ex)
- {
- IrssLog.Error(ex.Message);
-
- _mode = IRServerMode.ServerMode;
- _hostComputer = String.Empty;
- _pluginName = String.Empty;
- }
}
#endregion Constructor
@@ -103,66 +102,40 @@
{
try
{
- IrssLog.Debug("Starting IR Server");
+ IrssLog.Debug("Starting IR Server ...");
- if (String.IsNullOrEmpty(_pluginName))
+ LoadSettings();
+
+ // Try to load the IR Plugin, if it fails (for whatever reason) then run configuration.
+ _plugin = null;
+ while (_plugin == null)
{
- IrssLog.Error("No transceiver plugin specified, cannot start. Run Configuration.");
- return false;
- }
- else
- {
- IIRServerPlugin[] serverPlugins = Program.AvailablePlugins();
+ _plugin = Program.GetPlugin(_pluginName);
+ IrssLog.Warn("Failed to load plugin \"{0}\"", _pluginName);
- if (serverPlugins == null)
- {
- IrssLog.Error("No IR Server Plugins found, cannot start.");
- return false;
- }
-
- foreach (IIRServerPlugin plugin in serverPlugins)
- {
- if (plugin.Name == _pluginName)
- {
- _plugin = plugin;
- break;
- }
- }
-
if (_plugin == null)
{
- IrssLog.Error("Failed to start transceiver plugin \"{0}\", cannot start. Run Configuration.", _pluginName);
- return false;
+ if (Configure())
+ SaveSettings();
+ else
+ return false;
}
- else
- {
- IrssLog.Info("Loading transceiver plugin: \"{0}\"", _pluginName);
- }
}
- // Create a FIFO message queue
- _messageQueue = Queue.Synchronized(new Queue());
+ StartMessageQueue();
- // Start message queue handling thread
- _processMessageQueue = true;
- _messageHandlerThread = new Thread(new ThreadStart(MessageHandlerThread));
- _messageHandlerThread.IsBackground = true;
- _messageHandlerThread.Name = "IR Server Message Queue";
- _messageHandlerThread.Start();
-
- IrssLog.Debug("Message Queue thread started");
-
switch (_mode)
{
case IRServerMode.ServerMode:
{
- // Initialize registered clients list
+ // Initialize registered client lists ...
_registeredClients = new List<Client>();
+ _registeredRepeaters = new List<Client>();
// Start server pipe
PipeAccess.StartServer(Common.ServerPipeName, new PipeMessageHandler(QueueMessage));
- IrssLog.Debug("Server Mode: \\\\" + Environment.MachineName + "\\pipe\\" + Common.ServerPipeName);
+ IrssLog.Info("Server Mode: \\\\" + Environment.MachineName + "\\pipe\\" + Common.ServerPipeName);
break;
}
@@ -207,12 +180,6 @@
if (_plugin.CanReceive)
_plugin.RemoteButtonCallback += new RemoteButtonHandler(RemoteButtonPressed);
- // Setup taskbar icon
- _notifyIcon = new NotifyIcon();
- _notifyIcon.ContextMenu = new ContextMenu();
- _notifyIcon.ContextMenu.MenuItems.Add(new MenuItem("&Quit", ClickQuit));
- _notifyIcon.Icon = Properties.Resources.Icon16;
- _notifyIcon.Text = "IR Server";
_notifyIcon.Visible = true;
IrssLog.Info("IR Server started");
@@ -233,13 +200,12 @@
{
IrssLog.Info("Stopping IR Server ...");
- _processMessageQueue = false;
-
_notifyIcon.Visible = false;
if (_plugin.CanReceive)
_plugin.RemoteButtonCallback -= new RemoteButtonHandler(RemoteButtonPressed);
-
+
+ // Stop Plugin
try
{
_plugin.Stop();
@@ -249,8 +215,19 @@
IrssLog.Error(ex.ToString());
}
+ // Stop Message Queue
try
{
+ StopMessageQueue();
+ }
+ catch (Exception ex)
+ {
+ IrssLog.Error(ex.ToString());
+ }
+
+ // Stop Server
+ try
+ {
switch (_mode)
{
case IRServerMode.ServerMode:
@@ -271,10 +248,68 @@
{
IrssLog.Error(ex.ToString());
}
+ }
- Application.Exit();
+ bool Configure()
+ {
+ _inConfiguration = true;
+
+ try
+ {
+ Config config = new Config();
+ config.Mode = _mode;
+ config.HostComputer = _hostComputer;
+ config.Plugin = _pluginName;
+
+ if (config.ShowDialog() == DialogResult.OK)
+ {
+ _mode = config.Mode;
+ _hostComputer = config.HostComputer;
+ _pluginName = config.Plugin;
+
+ _inConfiguration = false;
+
+ return true;
+ }
+ }
+ catch (Exception ex)
+ {
+ IrssLog.Error(ex.ToString());
+ }
+
+ _inConfiguration = false;
+
+ return false;
}
+ void StartMessageQueue()
+ {
+ _processMessageQueue = true;
+
+ // Create a FIFO message queue
+ _messageQueue = Queue.Synchronized(new Queue());
+
+ // Start message queue handling thread
+ _messageHandlerThread = new Thread(new ThreadStart(MessageHandlerThread));
+ _messageHandlerThread.IsBackground = true;
+ _messageHandlerThread.Name = "IR Server Message Queue";
+ _messageHandlerThread.Start();
+ }
+ void StopMessageQueue()
+ {
+ _processMessageQueue = false;
+
+ try
+ {
+ if (_messageHandlerThread != null && _messageHandlerThread.IsAlive)
+ _messageHandlerThread.Abort();
+ }
+ catch { }
+
+ _messageQueue.Clear();
+ _messageQueue = null;
+ }
+
bool StartRelay()
{
bool retry = false;
@@ -344,8 +379,6 @@
bool StartRepeater()
{
- _registeredRepeaters = new List<Client>();
-
bool retry = false;
int pipeNumber = 1;
string localPipeTest;
@@ -530,7 +563,6 @@
UnregisterClient(pipe, server);
}
}
-
void SendToRepeaters(PipeMessage message)
{
IrssLog.Debug("SendToRepeaters({0})", message.ToString());
@@ -902,7 +934,9 @@
PipeMessage response = new PipeMessage(Common.ServerPipeName, Environment.MachineName, "Server Shutdown", null);
SendToAll(response);
}
+
Stop();
+ Application.Exit();
break;
}
@@ -1001,10 +1035,27 @@
catch { }
}
+ void ClickSetup(object sender, EventArgs e)
+ {
+ IrssLog.Info("Setup");
+
+ if (_inConfiguration)
+ return;
+
+ Stop();
+
+ if (Configure())
+ SaveSettings();
+
+ Start();
+ }
void ClickQuit(object sender, EventArgs e)
{
IrssLog.Info("Quit");
+ if (_inConfiguration)
+ return;
+
if (_mode == IRServerMode.ServerMode)
{
PipeMessage message = new PipeMessage(Common.ServerPipeName, Environment.MachineName, "Server Shutdown", null);
@@ -1012,8 +1063,54 @@
}
Stop();
+ Application.Exit();
}
+ void LoadSettings()
+ {
+ try
+ {
+ XmlDocument doc = new XmlDocument();
+ doc.Load(ConfigurationFile);
+
+ _mode = (IRServerMode)Enum.Parse(typeof(IRServerMode), doc.DocumentElement.Attributes["Mode"].Value);
+ _hostComputer = doc.DocumentElement.Attributes["HostComputer"].Value;
+ _pluginName = doc.DocumentElement.Attributes["Plugin"].Value;
+ }
+ catch (Exception ex)
+ {
+ IrssLog.Error(ex.ToString());
+
+ _mode = IRServerMode.ServerMode;
+ _hostComputer = String.Empty;
+ _pluginName = String.Empty;
+ }
+ }
+ void SaveSettings()
+ {
+ try
+ {
+ XmlTextWriter writer = new XmlTextWriter(ConfigurationFile, System.Text.Encoding.UTF8);
+ writer.Formatting = Formatting.Indented;
+ writer.Indentation = 1;
+ writer.IndentChar = (char)9;
+ writer.WriteStartDocument(true);
+ writer.WriteStartElement("settings"); // <settings>
+
+ writer.WriteAttributeString("Mode", Enum.GetName(typeof(IRServerMode), _mode));
+ writer.WriteAttributeString("HostComputer", _hostComputer);
+ writer.WriteAttributeString("Plugin", _pluginName);
+
+ writer.WriteEndElement(); // </settings>
+ writer.WriteEndDocument();
+ writer.Close();
+ }
+ catch (Exception ex)
+ {
+ IrssLog.Error(ex.ToString());
+ }
+ }
+
#endregion Implementation
}
Modified: trunk/plugins/IR Server Suite/Applications/IR Server/Program.cs
===================================================================
--- trunk/plugins/IR Server Suite/Applications/IR Server/Program.cs 2007-05-15 06:15:21 UTC (rev 402)
+++ trunk/plugins/IR Server Suite/Applications/IR Server/Program.cs 2007-05-16 07:37:02 UTC (rev 403)
@@ -16,86 +16,22 @@
static class Program
{
- enum ErrorCode : int
- {
- None = 0,
- InvalidCommandLine = 1,
- MultipleInstances = 2,
- FailedToStart = 3,
- Other = 127
- }
-
- /// <summary>
- /// Entry point for IR Server
- /// </summary>
- /// <param name="args">Command line arguments
- /// /c = configure the IR Server
- /// /k = kill the server
- /// /? = show command line parameters
- /// </param>
- /// <returns>Exit code to show what happened
- /// 0 = Successful
- /// 1 = Invalid command line arguments
- /// 2 = Multiple instances
- /// 3 = Failed to start
- /// 4 = Other failure
- /// </returns>
[STAThread]
static int Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
- // Process Command Line Arguments
- if (args.Length == 1)
- {
- switch(args[0])
- {
- case "--help":
- case "-help":
- case "/help":
- case "-?":
- case "/?":
- MessageBox.Show(
-@"Command Line Parameters:
-
-/c = configure the IR Server
-/k = kill the server
-/? = show command line parameters",
- "IR Server", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return (int)ErrorCode.None;
-
- case "-configure":
- case "/configure":
- case "-c":
- case "/c":
- return Configure();
-
- case "-kill":
- case "/kill":
- case "-k":
- case "/k":
- return Kill();
-
- default:
- return (int)ErrorCode.InvalidCommandLine;
- }
- }
- else if (args.Length > 1)
- {
- return (int)ErrorCode.InvalidCommandLine;
- }
-
// Check for multiple instances
try
{
- if (IsMultipleInstances())
- return (int)ErrorCode.MultipleInstances;
+ if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length != 1)
+ return 1;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
- return (int)ErrorCode.Other;
+ return 1;
}
// Open log file
@@ -109,103 +45,41 @@
catch (Exception ex)
{
Console.WriteLine(ex.Message);
- return (int)ErrorCode.Other;
+ return 1;
}
// Start Server
- IRServer transceiverServer = new IRServer();
+ IRServer irServer = new IRServer();
- if (transceiverServer.Start())
+ if (irServer.Start())
{
Application.Run();
IrssLog.Close();
- return (int)ErrorCode.None;
+ return 0;
}
else
{
MessageBox.Show("Failed to start IR Server, refer to log file for more details.", "IR Server", MessageBoxButtons.OK, MessageBoxIcon.Error);
IrssLog.Close();
- return (int)ErrorCode.FailedToStart;
+ return 1;
}
}
- static bool IsMultipleInstances()
- {
- return (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length != 1);
- }
-
- static int Configure()
- {
- RegistryKey key = null;
-
- try
- {
- key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\and-81\IRServer");
-
- Config config = new Config();
- config.Mode = (IRServerMode)key.GetValue("Mode", (int)IRServerMode.ServerMode);
- config.HostComputer = (string)key.GetValue("HostComputer", String.Empty);
- config.Plugin = (string)key.GetValue("Plugin", String.Empty);
-
- if (config.ShowDialog() == DialogResult.OK)
- {
- key.SetValue("Mode", (int)config.Mode);
- key.SetValue("HostComputer", config.HostComputer);
- key.SetValue("Plugin", config.Plugin);
-
- if (IsMultipleInstances())
- MessageBox.Show("You must restart the IR Server for any settings changes to take effect.", "IR Server", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
-
- key.Close();
- }
- catch (Exception ex)
- {
- if (key != null)
- key.Close();
-
- MessageBox.Show(ex.Message, "IR Server - Configuration Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return (int)ErrorCode.Other;
- }
-
- return (int)ErrorCode.None;
- }
- static int Kill()
- {
- try
- {
- Process[] processes = Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName);
- foreach (Process proc in processes)
- if (proc.Id != Process.GetCurrentProcess().Id)
- proc.Kill();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "IR Server Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return (int)ErrorCode.Other;
- }
-
- return (int)ErrorCode.None;
- }
-
/// <summary>
- /// Retreives a list of available IR Server plugins
+ /// Retreives a list of available IR Server plugins.
/// </summary>
- /// <returns>Array of plugin instances</returns>
+ /// <returns>Array of plugin instances.</returns>
internal static IIRServerPlugin[] AvailablePlugins()
{
try
{
List<IIRServerPlugin> plugins = new List<IIRServerPlugin>();
- RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("Software\\IR Server Suite\\");
- string installFolder = (string)registryKey.GetValue("Install_Dir", String.Empty);
- registryKey.Close();
-
- if (string.IsNullOrEmpty(installFolder))
+ string installFolder = SystemRegistry.GetInstallFolder();
+ if (String.IsNullOrEmpty(installFolder))
return null;
string[] files = Directory.GetFiles(installFolder + "\\IR Server Plugins\\", "*.dll", SearchOption.TopDirectoryOnly);
@@ -239,7 +113,7 @@
MessageBox.Show(ex.ToString(), "IR Server Unexpected Error");
}
}
-
+
return plugins.ToArray();
}
catch (Exception ex)
@@ -249,6 +123,31 @@
}
}
+ /// <summary>
+ /// Retreives a plugin instance given the plugin name.
+ /// </summary>
+ /// <param name="pluginName">Name of plugin to instantiate.</param>
+ /// <returns>Plugin instance.</returns>
+ internal static IIRServerPlugin GetPlugin(string pluginName)
+ {
+ if (String.IsNullOrEmpty(pluginName))
+ return null;
+
+ IIRServerPlugin[] serverPlugins = AvailablePlugins();
+ if (serverPlugins == null)
+ return null;
+
+ foreach (IIRServerPlugin plugin in serverPlugins)
+ {
+ if (plugin.Name == pluginName)
+ {
+ return plugin;
+ }
+ }
+
+ return null;
+ }
+
}
}
Modified: trunk/plugins/IR Server Suite/Applications/Translator/Configuration.cs
===================================================================
--- trunk/plugins/IR Server Suite/Applications/Translator/Configuration.cs 2007-05-15 06:15:21 UTC (rev 402)
+++ trunk/plugins/IR Server Suite/Applications/Translator/Configuration.cs 2007-05-16 07:37:02 UTC (rev 403)
@@ -16,6 +16,8 @@
#region Variables
+ string _serverHost;
+
List<ButtonMapping> _systemWideMappings;
List<ProgramSettings> _programSettings;
List<MappedEvent> _mappedEvents;
@@ -24,6 +26,13 @@
#region Properties
+ [XmlElement]
+ public string ServerHost
+ {
+ get { return _serverHost; }
+ set { _serverHost = value; }
+ }
+
[XmlArray]
public List<ButtonMapping> SystemWideMappings
{
@@ -51,6 +60,8 @@
public Configuration()
{
+ _serverHost = String.Empty;
+
_systemWideMappings = new List<ButtonMapping>();
_programSettings = new List<ProgramSettings>();
_mappedEvents = new List<MappedEvent>();
@@ -78,7 +89,7 @@
}
catch (Exception ex)
{
- IrssLog.Error(ex.Message);
+ IrssLog.Error(ex.ToString());
return false;
}
}
@@ -98,7 +109,7 @@
}
catch (Exception ex)
{
- IrssLog.Error(ex.Message);
+ IrssLog.Error(ex.ToString());
return null;
}
}
Modified: trunk/plugins/IR Server Suite/Applications/Translator/Forms/MainForm.cs
===================================================================
--- trunk/plugins/IR Server Suite/Applications/Translator/Forms/MainForm.cs 2007-05-15 06:15:21 UTC (rev 402)
+++ trunk/plugins/IR Server Suite/Applications/Translator/Forms/MainForm.cs 2007-05-16 07:37:02 UTC (rev 403)
@@ -8,8 +8,6 @@
using System.Text;
using System.Windows.Forms;
-using Microsoft.Win32;
-
using IrssUtils;
using IrssUtils.Forms;
@@ -99,9 +97,7 @@
try
{
- RegistryKey key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
- checkBoxAutoRun.Checked = (key.GetValue("Translator", null) != null);
- key.Close();
+ checkBoxAutoRun.Checked = SystemRegistry.GetAutoRun("Translator");
}
catch { }
}
@@ -652,12 +648,10 @@
private void checkBoxAutoRun_CheckedChanged(object sender, EventArgs e)
{
- RegistryKey key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
if (checkBoxAutoRun.Checked)
- key.SetValue("Translator", Application.ExecutablePath);
- else if (key.GetValue("Translator", null) != null)
- key.DeleteValue("Translator");
- key.Close();
+ SystemRegistry.SetAutoRun("Translator", Application.ExecutablePath);
+ else
+ SystemRegistry.RemoveAutoRun("Translator");
}
private void buttonAddEvent_Click(object sender, EventArgs e)
@@ -862,14 +856,12 @@
}
private void serverToolStripMenuItem_Click(object sender, EventArgs e)
{
- IrssUtils.Forms.ServerAddress serverAddress = new IrssUtils.Forms.ServerAddress(Program.ServerHost);
+ IrssUtils.Forms.ServerAddress serverAddress = new IrssUtils.Forms.ServerAddress(Program.Config.ServerHost);
if (serverAddress.ShowDialog(this) == DialogResult.OK)
{
- RegistryKey key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\and-81\Translator");
- key.SetValue("ServerHost", serverAddress.ServerHost);
- key.Close();
-
- MessageBox.Show(this, "Changes to the Server Host will not take effect until the program is restarted", "Note", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ Program.StopComms();
+ Program.Config.ServerHost = serverAddress.ServerHost;
+ Program.StartComms();
}
}
private void quitToolStripMenuItem_Click(object sender, EventArgs e)
@@ -878,12 +870,14 @@
}
private void translatorHelpToolStripMenuItem_Click(object sender, EventArgs e)
{
- RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("Software\\IR Server Suite\\");
- string installFolder = (string)registryKey.GetValue("Install_Dir", String.Empty);
- registryKey.Close();
-
- Help.ShowHelp(this, installFolder + "\\IR Server Suite.chm");
- // , HelpNavigator.Topic, "index.html"
+ try
+ {
+ Help.ShowHelp(this, SystemRegistry.GetInstallFolder() + "\\IR Server Suite.chm", HelpNavigator.Topic, "Translator");
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(this, ex.Message, "Failed to load help", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
Modified: trunk/plugins/IR Server Suite/Applications/Translator/Program.cs
===================================================================
--- trunk/plugins/IR Server Suite/Applications/Translator/Program.cs 2007-05-15 06:15:21 UTC (rev 402)
+++ trunk/plugins/IR Server Suite/Applications/Translator/Program.cs 2007-05-16 07:37:02 UTC (rev 403)
@@ -97,7 +97,6 @@
static Configuration _config;
- static string _serverHost = String.Empty;
static string _localPipeName = String.Empty;
static string _learnIRFilename = null;
@@ -116,12 +115,6 @@
#region Properties
- internal static string ServerHost
- {
- get { return _serverHost; }
- set { _serverHost = value; }
- }
-
internal static Configuration Config
{
get { return _config; }
@@ -165,25 +158,21 @@
IrssLog.Debug("Platform is {0}", (IntPtr.Size == 4 ? "32-bit" : "64-bit"));
- RegistryKey key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\and-81\Translator");
- _serverHost = (string)key.GetValue("ServerHost", String.Empty);
- key.Close();
+ _config = Configuration.Load(ConfigFile);
+ if (_config == null)
+ _config = new Configuration();
- if (String.IsNullOrEmpty(_serverHost))
+ if (String.IsNullOrEmpty(_config.ServerHost))
{
- IrssUtils.Forms.ServerAddress serverAddress = new IrssUtils.Forms.ServerAddress(_serverHost);
+ IrssUtils.Forms.ServerAddress serverAddress = new IrssUtils.Forms.ServerAddress(_config.ServerHost);
if (serverAddress.ShowDialog() == DialogResult.OK)
{
- _serverHost = serverAddress.ServerHost;
- SaveOptions();
+ _config.ServerHost = serverAddress.ServerHost;
+ Configuration.Save(_config, ConfigFile);
}
}
- _config = Configuration.Load(ConfigFile);
- if (_config == null)
- _config = new Configuration();
-
// Setup notify icon ...
_notifyIcon = new NotifyIcon();
_notifyIcon.ContextMenuStrip = new ContextMenuStrip();
@@ -249,13 +238,6 @@
}
- internal static void SaveOptions()
- {
- RegistryKey key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\and-81\Translator");
- key.SetValue("ServerHost", _serverHost);
- key.Close();
- }
-
internal static void UpdateNotifyMenu()
{
_notifyIcon.ContextMenuStrip.Items.Clear();
@@ -333,7 +315,7 @@
Application.Exit();
}
- static bool StartComms()
+ internal static bool StartComms()
{
try
{
@@ -354,7 +336,7 @@
return false;
}
- static void StopComms()
+ internal static void StopComms()
{
_notifyIcon.Visible = false;
@@ -362,7 +344,7 @@
try
{
- if (_keepAliveThread != null)
+ if (_keepAliveThread != null && _keepAliveThread.IsAlive)
_keepAliveThread.Abort();
}
catch { }
@@ -374,7 +356,7 @@
_registered = false;
PipeMessage message = new PipeMessage(_localPipeName, Environment.MachineName, "Unregister", null);
- PipeAccess.SendMessage(Common.ServerPipeName, _serverHost, message.ToString());
+ PipeAccess.SendMessage(Common.ServerPipeName, _config.ServerHost, message.ToString());
}
}
catch { }
@@ -430,7 +412,7 @@
try
{
PipeMessage message = new PipeMessage(_localPipeName, Environment.MachineName, "Register", null);
- PipeAccess.SendMessage(Common.ServerPipeName, _serverHost, message.ToString());
+ PipeAccess.SendMessage(Common.ServerPipeName, _config.ServerHost, message.ToString());
return true;
}
catch (AppModule.NamedPipes.NamedPipeIOException)
@@ -462,7 +444,7 @@
#region Connect to server
- IrssLog.Info("Connecting ({0}) ...", _serverHost);
+ IrssLog.Info("Connecting ({0}) ...", _config.ServerHost);
attempt = 0;
while (_keepAlive && reconnect)
{
@@ -511,7 +493,7 @@
if (_keepAlive && _registered && !reconnect)
{
- IrssLog.Info("Connected ({0})", _serverHost);
+ IrssLog.Info("Connected ({0})", _config.ServerHost);
_notifyIcon.Icon = Properties.Resources.Icon16;
_notifyIcon.Text = "Translator";
@@ -529,7 +511,7 @@
while (_keepAlive && _registered && !reconnect)
{
- IrssLog.Info("Ping ({0})", _serverHost);
+ IrssLog.Info("Ping ({0})", _config.ServerHost);
int pingID = random.Next();
long pingTime = DateTime.Now.Ticks;
@@ -537,7 +519,7 @@
try
{
PipeMessage message = new PipeMessage(_localPipeName, Environment.MachineName, "Ping", BitConverter.GetBytes(pingID));
- PipeAccess.SendMessage(Common.ServerPipeName, _serverHost, message.ToString());
+ PipeAccess.SendMessage(Common.ServerPipeName, _config.ServerHost, message.ToString());
}
catch
{
@@ -910,7 +892,7 @@
_learnIRFilename = fileName;
PipeMessage message = new PipeMessage(_localPipeName, Environment.MachineName, "Learn", null);
- PipeAccess.SendMessage(Common.ServerPipeName, _serverHost, message.ToString());
+ PipeAccess.SendMessage(Common.ServerPipeName, _config.ServerHost, message.ToString());
}
catch (Exception ex)
{
@@ -948,7 +930,7 @@
file.Close();
PipeMessage message = new PipeMessage(_localPipeName, Environment.MachineName, "Blast", outData);
- PipeAccess.SendMessage(Common.ServerPipeName, ServerHost, message.ToString());
+ PipeAccess.SendMessage(Common.ServerPipeName, _config.ServerHost, message.ToString());
}
/// <summary>
Modified: trunk/plugins/IR Server Suite/Applications/Tray Launcher/Program.cs
===================================================================
--- trunk/plugins/IR Server Suite/Applications/Tray Launcher/Program.cs 2007-05-15 06:15:21 UTC (rev 402)
+++ trunk/plugins/IR Server Suite/Applications/Tray Launcher/Program.cs 2007-05-16 07:37:02 UTC (rev 403)
@@ -2,8 +2,6 @@
using System.Diagnostics;
using System.Windows.Forms;
-using Microsoft.Win32;
-
using IrssUtils;
namespace TrayLauncher
Modified: trunk/plugins/IR Server Suite/Applications/Tray Launcher/Setup.cs
===================================================================
--- trunk/plugins/IR Server Suite/Applications/Tray Launcher/Setup.cs 2007-05-15 06:15:21 UTC (rev 402)
+++ trunk/plugins/IR Server Suite/Applications/Tray Launcher/Setup.cs 2007-05-16 07:37:02 UTC (rev 403)
@@ -19,7 +19,7 @@
#region Variables
OpenFileDialog openFileDialog;
- string _launchButton;
+ string _launchKeyCode;
#endregion Variables
@@ -45,10 +45,10 @@
get { return checkBoxLaunchOnLoad.Checked; }
set { checkBoxLaunchOnLoad.Checked = value; }
}
- public string LaunchButton
+ public string LaunchKeyCode
{
- get { return _launchButton; }
- set { _launchButton = value; }
+ get { return _launchKeyCode; }
+ set { _launchKeyCode = value; }
}
#endregion Properties
@@ -108,7 +108,7 @@
if (String.IsNullOrEmpty(keyCode))
return;
- _launchButton = keyCode;
+ _launchKeyCode = keyCode;
}
}
Modified: trunk/plugins/IR Server Suite/Applications/Tray Launcher/Tray.cs
===================================================================
--- trunk/plugins/IR Server Suite/Applications/Tray Launcher/Tray.cs 2007-05-15 06:15:21 UTC (rev 402)
+++ trunk/plugins/IR Server Suite/Applications/Tray Launcher/Tray.cs 2007-05-16 07:37:02 UTC (rev 403)
@@ -7,9 +7,8 @@
using System.Text;
using System.Threading;
using System.Windows.Forms;
+using System.Xml;
-using Microsoft.Win32;
-
using NamedPipes;
using IrssUtils;
@@ -19,16 +18,14 @@
public class Tray : Form
{
- #region Properties
+ #region Constants
- internal static Common.MessageHandler HandleMessage
- {
- get { return _handleMessage; }
- set { _handleMessage = value; }
- }
+ const string DefaultKeyCode = "31730";
- #endregion Properties
-
+ public static readonly string ConfigurationFile = Common.FolderAppData + "Tray Launcher\\Tray Launcher.xml";
+
+ #endregion Constants
+
#region Variables
static Common.MessageHandler _handleMessage = null;
@@ -49,24 +46,28 @@
NotifyIcon _notifyIcon;
#endregion Variables
-
- #region Constants
- const string DefaultKeyCode = "31730";
+ #region Properties
- #endregion Constants
+ internal static Common.MessageHandler HandleMessage
+ {
+ get { return _handleMessage; }
+ set { _handleMessage = value; }
+ }
+ #endregion Properties
+
#region Constructor
public Tray()
{
- ContextMenu contextMenu = new ContextMenu();
- contextMenu.MenuItems.Add(new MenuItem("Launch", ClickLaunch));
- contextMenu.MenuItems.Add(new MenuItem("Setup", ClickSetup));
- contextMenu.MenuItems.Add(new MenuItem("Quit", ClickQuit));
+ ContextMenuStrip contextMenu = new ContextMenuStrip();
+ contextMenu.Items.Add(new ToolStripMenuItem("&Launch", null, new EventHandler(ClickLaunch)));
+ contextMenu.Items.Add(new ToolStripMenuItem("&Setup", null, new EventHandler(ClickSetup)));
+ contextMenu.Items.Add(new ToolStripMenuItem("&Quit", null, new EventHandler(ClickQuit)));
_notifyIcon = new NotifyIcon();
- _notifyIcon.ContextMenu = contextMenu;
+ _notifyIcon.ContextMenuStrip = contextMenu;
_notifyIcon.Icon = Properties.Resources.Icon16Connecting;
_notifyIcon.Text = "Tray Launcher - Connecting ...";
_notifyIcon.DoubleClick += new EventHandler(ClickSetup);
@@ -80,7 +81,7 @@
{
try
{
- LoadSetup();
+ LoadSettings();
bool didSetup = false;
if (String.IsNullOrEmpty(_programFile) || String.IsNullOrEmpty(_serverHost))
@@ -118,7 +119,7 @@
try
{
- if (_keepAliveThread != null)
+ if (_keepAliveThread != null && _keepAliveThread.IsAlive)
_keepAliveThread.Abort();
}
catch { }
@@ -143,51 +144,70 @@
catch { }
}
- void LoadSetup()
+ void LoadSettings()
{
- IrssLog.Info("Load Setup");
+ try
+ {
+ _autoRun = SystemRegistry.GetAutoRun("Tray Launcher");
+ }
+ catch (Exception ex)
+ {
+ IrssLog.Error(ex.ToString());
+ _autoRun = false;
+ }
+
try
{
- RegistryKey key;
+ XmlDocument doc = new XmlDocument();
+ doc.Load(ConfigurationFile);
- key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
- _autoRun = (key.GetValue("Tray Launcher", null) != null);
- key.Close();
-
- key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\and-81\TrayLauncher");
- _serverHost = (string)key.GetValue("ServerHost", String.Empty);
- _programFile = (string)key.GetValue("Launch", String.Empty);
- _launchOnLoad = bool.Parse((string)key.GetValue("LaunchOnLoad", "False"));
- _launchKeyCode = (string)key.GetValue("LaunchButton", DefaultKeyCode);
- key.Close();
+ _serverHost = doc.DocumentElement.Attributes["ServerHost"].Value;
+ _programFile = doc.DocumentElement.Attributes["ProgramFile"].Value;
+ _launchOnLoad = bool.Parse(doc.DocumentElement.Attributes["LaunchOnLoad"].Value);
+ _launchKeyCode = doc.DocumentElement.Attributes["LaunchKeyCode"].Value;
}
catch (Exception ex)
{
IrssLog.Error(ex.ToString());
+
+ _serverHost = String.Empty;
+ _programFile = String.Empty;
+ _launchOnLoad = false;
+ _launchKeyCode = DefaultKeyCode;
}
}
- void SaveSetup()
+ void SaveSettings()
{
- IrssLog.Info("Save Setup");
+ try
+ {
+ if (_autoRun)
+ SystemRegistry.SetAutoRun("Tray Launcher", Application.ExecutablePath);
+ else
+ SystemRegistry.RemoveAutoRun("Tray Launcher");
+ }
+ catch (Exception ex)
+ {
+ IrssLog.Error(ex.ToString());
+ }
try
{
- RegistryKey key;
+ XmlTextWriter writer = new XmlTextWriter(ConfigurationFile, System.Text.Encoding.UTF8);
+ writer.Formatting = Formatting.Indented;
+ writer.Indentation = 1;
+ writer.IndentChar = (char)9;
+ writer.WriteStartDocument(true);
+ writer.WriteStartElement("settings"); // <settings>
- key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
- if (_autoRun)
- key.SetValue("Tray Launcher", Application.ExecutablePath);
- else if (key.GetValue("Tray Launcher", null) != null)
- key.DeleteValue("Tray Launcher");
- key.Close();
+ writer.WriteAttributeString("ServerHost", _serverHost);
+ writer.WriteAttributeString("ProgramFile", _programFile);
+ writer.WriteAttributeString("LaunchOnLoad", _launchOnLoad.ToString());
+ writer.WriteAttributeString("LaunchKeyCode", _launchKeyCode);
- key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\and-81\TrayLauncher");
- key.SetValue("ServerHost", _serverHost);
- key.SetValue("Launch", _programFile);
- key.SetValue("LaunchOnLoad", _launchOnLoad.ToString());
- key.SetValue("LaunchButton", _launchKeyCode);
- key.Close();
+ writer.WriteEndElement(); // </settings>
+ writer.WriteEndDocument();
+ writer.Close();
}
catch (Exception ex)
{
@@ -195,7 +215,6 @@
}
}
-
bool OpenLocalPipe()
{
try
@@ -388,7 +407,6 @@
}
-
void ReceivedMessage(string message)
{
PipeMessage received = PipeMessage.FromString(message);
@@ -457,7 +475,6 @@
}
}
-
void RemoteButtonPressed(string keyCode)
{
IrssLog.Info("Remote Button: {0}", keyCode);
@@ -471,24 +488,25 @@
IrssLog.Info("Setup");
Setup setup = new Setup();
- setup.ServerHost = _serverHost;
- setup.ProgramFile = _programFile;
- setup.AutoRun = _autoRun;
- setup.LaunchOnLoad = _launchOnLoad;
- setup.LaunchButton = _launchKeyCode;
+ setup.AutoRun = _autoRun;
+ setup.ServerHost = _serverHost;
+ setup.ProgramFile = _programFile;
+ setup.LaunchOnLoad = _launchOnLoad;
+ setup.LaunchKeyCode = _launchKeyCode;
+
if (setup.ShowDialog() == DialogResult.OK)
{
if (PipeAccess.ServerRunning && _serverHost != setup.ServerHost)
MessageBox.Show(this, "Changes to the server host address may not take effect until you restart Tray Launcher", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- _serverHost = setup.ServerHost;
- _programFile = setup.ProgramFile;
- _autoRun = setup.AutoRun;
- _launchOnLoad = setup.LaunchOnLoad;
- _launchKeyCode = setup.LaunchButton;
+ _autoRun = setup.AutoRun;
+ _serverHost = setup.ServerHost;
+ _programFile = setup.ProgramFile;
+ _launchOnLoad = setup.LaunchOnLoad;
+ _launchKeyCode = setup.LaunchKeyCode;
- SaveSetup();
+ SaveSettings();
}
}
void ClickLaunch(object sender, EventArgs e)
Modified: trunk/plugins/IR Server Suite/Applications/Virtual Remote/MainForm.cs
===================================================================
--- trunk/plugins/IR Server Suite/Applications/Virtual Remote/MainForm.cs 2007-05-15 06:15:21 UTC (rev 402)
+++ trunk/plugins/IR Server Suite/Applications/Virtual Remote/MainForm.cs 2007-05-16 07:37:02 UTC (rev 403)
@@ -10,8 +10,6 @@
using System.Windows.Forms;
using System.Xml;
-using Microsoft.Win32;
-
using NamedPipes;
using IrssUtils;
@@ -21,76 +19,12 @@
public partial class MainForm : Form
{
- #region Enumerations
-
- /// <summary>
- /// A list of MCE remote buttons
- /// </summary>
- public enum MceButton
- {
- Custom = -1,
- None = 0,
- TV_Power = 0x7b9a,
- Blue = 0x7ba1,
- Yellow = 0x7ba2,
- Green = 0x7ba3,
- Red = 0x7ba4,
- Teletext = 0x7ba5,
- Radio = 0x7baf,
- Print = 0x7bb1,
- Videos = 0x7bb5,
- Pictures = 0x7bb6,
- Recorded_TV = 0x7bb7,
- Music = 0x7bb8,
- TV = 0x7bb9,
- Guide = 0x7bd9,
- Live_TV = 0x7bda,
- DVD_Menu = 0x7bdb,
- Back = 0x7bdc,
- OK = 0x7bdd,
- Right = 0x7bde,
- Left = 0x7bdf,
- Down = 0x7be0,
- Up = 0x7be1,
- Star = 0x7be2,
- Hash = 0x7be3,
- Replay = 0x7be4,
- Skip = 0x7be5,
- Stop = 0x7be6,
- Pause = 0x7be7,
- Record = 0x7be8,
- Play = 0x7be9,
- Rewind = 0x7bea,
- Forward = 0x7beb,
- Channel_Down = 0x7bec,
- Channel_Up = 0x7bed,
- Volume_Down = 0x7bee,
- Volume_Up = 0x7bef,
- Info = 0x7bf0,
- Mute = 0x7bf1,
- Start = 0x7bf2,
- PC_Power = 0x7bf3,
- Enter = 0x7bf4,
- Escape = 0x7bf5,
- Number_9 = 0x7bf6,
- Number_8 = 0x7bf7,
- Number_7 = 0x7bf8,
- Number_6 = 0x7bf9,
- Number_5 = 0x7bfa,
- Number_4 = 0x7bfb,
- Number_3 = 0x7bfc,
- Number_2 = 0x7bfd,
- Number_1 = 0x7bfe,
- Number_0 = 0x7bff,
- }
-
- #endregion Enumerations
-
#region Constants
const string DefaultSkin = "MCE";
- const string DefaultIntallFolder = ".";
+ public static readonly string ConfigurationFile = Common.FolderAppData + "Virtual Remote\\Virtual Remote.xml";
+
#endregion Constants
#region Variables
@@ -197,34 +131,52 @@
{
try
{
- RegistryKey key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\and-81\VirtualRemote");
- _remoteSkin = (string)key.GetValue("Skin", DefaultSkin);
- _serverHost = (string)key.GetValue("ServerHost", String.Empty);
- key.Close();
+ _installFolder = SystemRegistry.GetInstallFolder();
+ if (String.IsNullOrEmpty(_installFolder))
+ _installFolder = ".";
+ else
+ _installFolder += "\\Virtual Remote";
+ }
+ catch (Exception ex)
+ {
+ IrssLog.Error(ex.ToString());
- key = Registry.LocalMachine.OpenSubKey("Software\\IR Server Suite\\");
- _installFolder = (string)key.GetValue("Install_Dir", DefaultIntallFolder);
- key.Close();
+ _installFolder = ".";
+ }
- if (_installFolder != DefaultIntallFolder)
- _installFolder += "\\Virtual Remote";
+ try
+ {
+ XmlDocument doc = new XmlDocument();
+ doc.Load(ConfigurationFile);
+
+ _serverHost = doc.DocumentElement.Attributes["ServerHost"].Value;
+ _remoteSkin = doc.DocumentElement.Attributes["RemoteSkin"].Value;
}
catch (Exception ex)
{
IrssLog.Error(ex.ToString());
- _remoteSkin = DefaultSkin;
- _serverHost = String.Empty;
- _installFolder = DefaultIntallFolder;
+
+ _serverHost = String.Empty;
+ _remoteSkin = DefaultSkin;
}
}
void SaveSettings()
{
try
{
- RegistryKey key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\and-81\VirtualRemote");
- key.SetValue("Skin", _remoteSkin);
- key.SetValue("ServerHost", _serverHost);
- key.Close();
+ XmlTextWriter writer = new XmlTextWriter(ConfigurationFile, System.Text.Encoding.UTF8);
+ writer.Formatting = Formatting.Indented;
+ writer.Indentation = 1;
+ writer.IndentChar = (char)9;
+ writer.WriteStartDocument(true);
+ writer.WriteStartElement("settings"); // <settings>
+
+ writer.WriteAttributeString("ServerHost", _serverHost);
+ writer.WriteAttributeString("Skin", _remoteSkin);
+
+ writer.WriteEndElement(); // </settings>
+ writer.WriteEndDocument();
+ writer.Close();
}
catch (Exception ex)
{
@@ -250,14 +202,13 @@
return false;
}
-
void StopComms()
{
_keepAlive = false;
try
{
- if (_keepAliveThread != null)
+ if (_keepAliveThread != null && _keepAliveThread.IsAlive)
_keepAliveThread.Abort();
}
catch { }
Modified: trunk/plugins/IR Server Suite/Applications/Virtual Remote Skin Editor/MainForm.cs
===================================================================
--- trunk/plugins/IR Server Suite/Applications/Virtual Remote Skin Editor/MainForm.cs 2007-05-15 06:15:21 UTC (rev 402)
+++ trunk/plugins/IR Server Suite/Applications/Virtual Remote Skin Editor/MainForm.cs 2007-05-16 07:37:02 UTC (rev 403)
@@ -8,8 +8,6 @@
using System.Windows.Forms;
using System.Xml;
-using Microsoft.Win32;
-
using NamedPipes;
using IrssUtils;
@@ -19,6 +17,12 @@
public partial class MainForm : Form
{
+ #region Constants
+
+ public static readonly string ConfigurationFile = Common.FolderAppData + "Virtual Remote Skin Editor\\Virtual Remote Skin Editor.xml";
+
+ #endregion Constants
+
#region Variables
//static bool _keepAlive = true;
@@ -238,13 +242,15 @@
{
try
{
- RegistryKey key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\and-81\VirtualRemoteSkinEditor");
- _serverHost = (string)key.GetValue("ServerHost", String.Empty);
- key.Close();
+ XmlDocument doc = new XmlDocument();
+ doc.Load(ConfigurationFile);
+
+ _serverHost = doc.DocumentElement.Attributes["ServerHost"].Value;
}
catch (Exception ex)
{
IrssLog.Error(ex.ToString());
+
_serverHost = String.Empty;
}
}
@@ -252,13 +258,22 @@
{
try
{
- RegistryKey key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\and-81\VirtualRemoteSkinEditor");
- key.SetValue("ServerHost", _serverHost);
- key.Close();
+ XmlTextWriter writer = new XmlTextWriter(ConfigurationFile, System.Text.Encoding.UTF8);
+ writer.Formatting = Formatting.Indented;
+ writer.Indentation = 1;
+ writer.IndentChar = (char)9;
+ writer.WriteStartDocument(true);
+ writer.WriteStartElement("settings"); // <settings>
+
+ writer.WriteAttributeString("ServerHost", _serverHost);
+
+ writer.WriteEndElement(); // </settings>
+ writer.WriteEndDocument();
+ writer.Close();
}
catch (Exception ex)
{
- IrssLog.Error(ex.Message);
+ IrssLog.Error(ex.ToString());
}
}
Modified: trunk/plugins/IR Server Suite/Common/IrssUtils/IrssUtils.csproj
===================================================================
--- trunk/plugins/IR Server Suite/Common/IrssUtils/IrssUtils.csproj 2007-05-15 06:15:21 UTC (rev 402)
+++ trunk/plugins/IR Server Suite/Common/IrssUtils/IrssUtils.csproj 2007-05-16 07:37:02 UTC (rev 403)
@@ -86,6 +86,7 @@
</Compile>
<Compile Include="IrssLog.cs" />
<Compile Include="Mouse.cs" />
+ <Compile Include="SystemRegistry.cs" />
<Compile Include="TransceiverInfo.cs" />
<Compile Include="Win32.cs" />
<Compile Include="XML.cs" />
Added: trunk/plugins/IR Server Suite/Common/IrssUtils/SystemRegistry.cs
===================================================================
--- trunk/plugins/IR Server Suite/Common/IrssUtils/SystemRegistry.cs (rev 0)
+++ trunk/plugins/IR Server Suite/Common/IrssUtils/SystemRegistry.cs 2007-05-16 07:37:02 UTC (rev 403)
@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using Microsoft.Win32;
+
+namespace IrssUtils
+{
+
+ public static class SystemRegistry
+ {
+
+ const string AutoRunPath = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Run";
+
+ /// <summary>
+ /// Get the install folder for IR Server Suite.
+ /// </summary>
+ /// <returns>String containing the Install Folder (no trailing slash).</returns>
+ public static string GetInstallFolder()
+ {
+ RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("Software\\IR Server Suite\\");
+ string installFolder = registryKey.GetValue("Install_Dir", null) as string;
+ registryKey.Close();
+
+ return installFolder;
+ }
+
+ /// <summary>
+ /// Returns a boolean value indicating if there is an auto-run in place for the specified name.
+ /// </summary>
+ /// <param name="name">Auto-run program name.</param>
+ /// <returns>If key of name exists return true else return false.</returns>
+ public static bool GetAutoRun(string name)
+ {
+ RegistryKey key = Registry.CurrentUser.CreateSubKey(AutoRunPath);
+ bool autoRun = (key.GetValue(name, null) != null);
+ key.Close();
+
+ return autoRun;
+ }
+
+ /// <summary>
+ /// Setup an auto-run in the system registry.
+ /// </summary>
+ /// <param name="name">Auto-run program name.</param>
+ /// <param name="executablePath">Executable Path for program.</param>
+ public static void SetAutoRun(string name, string executablePath)
+ {
+ RegistryKey key = Registry.CurrentUser.CreateSubKey(AutoRunPath);
+ key.SetValue(name, executablePath, RegistryValueKind.String);
+ key.Close();
+ }
+
+ /// <summary>
+ /// Remove an auto-run from the system registry.
+ /// </summary>
+ /// <param name="name">Auto-run program name.</param>
+ public static void RemoveAutoRun(string name)
+ {
+ RegistryKey key = Registry.CurrentUser.CreateSubKey(AutoRunPath);
+ key.DeleteValue(name, false);
+ key.Close();
+ }
+
+ }
+
+}
Modified: trunk/plugins/IR Server Suite/IPC/AppModule.InterProcessComm/AppModule.InterProcessComm.csproj
===================================================================
--- trunk/plugins/IR Server Suite/IPC/AppModule.InterProcessComm/AppModule.InterProcessComm.csproj 2007-05-15 06:15:21 UTC (rev 402)
+++ trunk/plugins/IR Server Suite/IPC/AppModule.InterProcessComm/AppModule.InterProcessComm.csproj 2007-05-16 07:37:02 UTC (rev 403)
@@ -35,7 +35,8 @@
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>DEBUG</DefineConstants>
- <DocumentationFile>AppModule.InterProcessComm.xml</DocumentationFile>
+ <DocumentationFile>
+ </DocumentationFile>
<DebugSymbols>false</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<NoStdLib>false</NoStdLib>
Modified: trunk/plugins/IR Server Suite/IPC/AppModule.NamedPipes/AppModule.NamedPipes.csproj
===================================================================
--- trunk/plugins/IR Server Suite/IPC/AppModule.NamedPipes/AppModule.NamedPipes.csproj 2007-05-15 06:15:21 UTC (rev 402)
+++ trunk/plugins/IR Server Suite/IPC/AppModule.NamedPipes/AppModule.NamedPipes.csproj 2007-05-16 07:37:02 UTC (rev 403)
@@ -35,7 +35,8 @@
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>DEBUG</DefineConstants>
- <DocumentationFile>AppModule.NamedPipes.xml</DocumentationFile>
+ <DocumentationFile>
+ </DocumentationFile>
<DebugSymbols>false</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<NoStdLib>false</NoStdLib>
Modified: trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IR Server Plugin Interface.csproj
===================================================================
--- trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IR Server Plugin Interface.csproj 2007-05-15 06:15:21 UTC (rev 402)
+++ trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IR Server Plugin Interface.csproj 2007-05-16 07:37:02 UTC (rev 403)
@@ -32,7 +32,8 @@
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<UseVSHostingProcess>false</UseVSHostingProcess>
- <DocumentationFile>bin\Release\IRServerPluginInterface.xml</DocumentationFile>
+ <DocumentationFile>
+ </DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Modified: trunk/plugins/IR Server Suite/IR Server Suite.sln
===================================================================
--- trunk/plugins/IR Server Suite/IR Server Suite.sln 2007-05-15 06:15:21 UTC (rev 402)
+++ trunk/plugins/IR Server Suite/IR Server Suite.sln 2007-05-16 07:37:02 UTC (rev 403)
@@ -33,8 +33,6 @@
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TV3 Blaster Plugin", "MediaPortal Plugins\TV3 Blaster Plugin\TV3 Blaster Plugin.csproj", "{CD395FC2-70E2-42C4-8A20-5469A0C5EB50}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IR Server Plugin Interface", "IR Server Plugins\IR Server Plugin Interface\IR Server Plugin Interface.csproj", "{D8B3D28F-62CE-4CA7-86CE-B7EAD614A94C}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IgorPlug USB Receiver", "IR Server Plugins\IgorPlug USB Receiver\IgorPlug USB Receiver.csproj", "{A4023992-CCD6-461E-8E14-219A496734C5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IRMan Receiver", "IR Server Plugins\IRMan Receiver\IRMan Receiver.csproj", "{7C686499-7517-4338-8837-7E8617549D9A}"
@@ -65,6 +63,8 @@
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MPUtils", "Common\MPUtils\MPUtils.csproj", "{08F57DD7-2C6E-484E-9CC5-835F70C5BC64}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IR Server Plugin Interface", "IR Server Plugins\IR Server Plugin Interface\IR Server Plugin Interface.csproj", "{D8B3D28F-62CE-4CA7-86CE-B7EAD614A94C}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -119,10 +119,6 @@
{CD395FC2-70E2-42C4-8A20-5469A0C5EB50}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CD395FC2-70E2-42C4-8A20-5469A0C5EB50}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CD395FC2-70E2-42C4-8A20-5469A0C5EB50}.Release|Any CPU.Build.0 = Release|Any CPU
...
[truncated message content] |