From: <an...@us...> - 2007-09-26 07:34:30
|
Revision: 956 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=956&view=rev Author: and-81 Date: 2007-09-26 00:34:18 -0700 (Wed, 26 Sep 2007) Log Message: ----------- Modified Paths: -------------- trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.Designer.cs trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.cs trunk/plugins/IR Server Suite/Applications/IR Blast/Program.cs trunk/plugins/IR Server Suite/Applications/IR Blast (No Window)/Program.cs trunk/plugins/IR Server Suite/Applications/IR Server/Config.cs 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/EventSchedule.cs trunk/plugins/IR Server Suite/Applications/Translator/Forms/ButtonMappingForm.Designer.cs trunk/plugins/IR Server Suite/Applications/Translator/Forms/ButtonMappingForm.cs trunk/plugins/IR Server Suite/Applications/Translator/Forms/EditProgramForm.cs trunk/plugins/IR Server Suite/Applications/Translator/Forms/GetKeyCodeForm.cs trunk/plugins/IR Server Suite/Applications/Translator/Forms/MacroEditor.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/Translator/Translator.csproj trunk/plugins/IR Server Suite/Applications/Tray Launcher/GetKeyCodeForm.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/Program.cs trunk/plugins/IR Server Suite/Applications/Virtual Remote/RemoteButton.cs trunk/plugins/IR Server Suite/Applications/Virtual Remote Skin Editor/MainForm.cs trunk/plugins/IR Server Suite/Common/IrssComms/Client.cs trunk/plugins/IR Server Suite/Common/IrssComms/ClientManager.cs trunk/plugins/IR Server Suite/Common/IrssComms/IrssMessage.cs trunk/plugins/IR Server Suite/Common/IrssComms/MessageManagerCombo.cs trunk/plugins/IR Server Suite/Common/IrssComms/Server.cs trunk/plugins/IR Server Suite/Common/IrssUtils/Common.cs trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/ServerAddress.Designer.cs trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/ServerAddress.cs trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/ServerAddress.resx trunk/plugins/IR Server Suite/Common/IrssUtils/IrssLog.cs trunk/plugins/IR Server Suite/Common/IrssUtils/IrssUtils.csproj trunk/plugins/IR Server Suite/Common/IrssUtils/Win32.cs trunk/plugins/IR Server Suite/Common/MPUtils/ExternalChannelConfig.cs trunk/plugins/IR Server Suite/IR Server Plugins/FusionRemote Receiver/FusionRemoteReceiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IRServerPluginInterface.cs trunk/plugins/IR Server Suite/IR Server Plugins/IRMan Receiver/Configure.cs trunk/plugins/IR Server Suite/IR Server Plugins/IRMan Receiver/IRMan Receiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/IRTrans Transceiver/CSocketPacket.cs trunk/plugins/IR Server Suite/IR Server Plugins/IRTrans Transceiver/Configure.cs trunk/plugins/IR Server Suite/IR Server Plugins/IRTrans Transceiver/IRTransTransceiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Advanced.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Configure.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Driver.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DriverReplacement.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DriverVista.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DriverXP.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/IrCode.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/IrDecoder.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Keyboard.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/MceDetectionData.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/MicrosoftMceTransceiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Mouse.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/NotifyWindow.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Pronto.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/RemoteDetectionData.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Win32ErrorCodes.cs trunk/plugins/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver/Configure.cs trunk/plugins/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver/UirtTransceiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/Configure.cs trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/CreateIRFile.cs trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/WinLirc Transceiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/WinLircServer.cs trunk/plugins/IR Server Suite/IR Server Plugins/Windows Message Receiver/Configure.cs trunk/plugins/IR Server Suite/IR Server Plugins/Windows Message Receiver/ReceiverWindow.cs trunk/plugins/IR Server Suite/IR Server Plugins/Windows Message Receiver/Windows Message Receiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/X10 Transceiver/X10Transceiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/XBCDRC Receiver/XBCDRC Receiver.cs trunk/plugins/IR Server Suite/IR Server Suite.sln trunk/plugins/IR Server Suite/Input Service/InputService.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Blast Zone Plugin/Forms/MacroEditor.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Blast Zone Plugin/Forms/SetupForm.Designer.cs 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/MP Blast Zone Plugin.csproj trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Blast Zone Plugin/MPBlastZonePlugin.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Blast Zone Plugin/Menu.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Control Plugin/Forms/MacroEditor.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Control Plugin/Forms/MultiMapNameBox.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Control Plugin/Forms/SetupForm.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Control Plugin/InputMapper/InputHandler.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Control Plugin/InputMapper/InputMappingForm.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Control Plugin/MP Control Plugin.csproj trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Control Plugin/MPControlPlugin.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Control Plugin/MappedEvent.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/Forms/ExternalChannels.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/Forms/MacroEditor.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/Forms/SetupForm.Designer.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/SetupForm.resx trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/Forms/StbSetup.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/TV2 Blaster Plugin.csproj trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/TV2BlasterPlugin.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV3 Blaster Plugin/Forms/ExternalChannels.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV3 Blaster Plugin/Forms/MacroEditor.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV3 Blaster Plugin/Forms/PluginSetup.Designer.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/TV3 Blaster Plugin.csproj trunk/plugins/IR Server Suite/MediaPortal Plugins/TV3 Blaster Plugin/TV3BlasterPlugin.cs Removed Paths: ------------- trunk/plugins/IR Server Suite/Applications/Translator/Forms/BlastCommand.Designer.cs trunk/plugins/IR Server Suite/Applications/Translator/Forms/BlastCommand.cs trunk/plugins/IR Server Suite/Applications/Translator/Forms/BlastCommand.resx trunk/plugins/IR Server Suite/Applications/Translator/Forms/LearnIR.Designer.cs trunk/plugins/IR Server Suite/Applications/Translator/Forms/LearnIR.cs trunk/plugins/IR Server Suite/Applications/Translator/Forms/LearnIR.resx trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Blast Zone Plugin/Forms/BlastCommand.Designer.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Blast Zone Plugin/Forms/BlastCommand.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Blast Zone Plugin/Forms/BlastCommand.resx trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Blast Zone Plugin/Forms/LearnIR.Designer.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Blast Zone Plugin/Forms/LearnIR.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Blast Zone Plugin/Forms/LearnIR.resx trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Control Plugin/Forms/BlastCommand.Designer.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Control Plugin/Forms/BlastCommand.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Control Plugin/Forms/BlastCommand.resx trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Control Plugin/Forms/LearnIR.Designer.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Control Plugin/Forms/LearnIR.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Control Plugin/Forms/LearnIR.resx trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/Forms/BlastCommand.Designer.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/Forms/BlastCommand.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/Forms/BlastCommand.resx trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/Forms/LearnIR.Designer.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/Forms/LearnIR.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/Forms/LearnIR.resx trunk/plugins/IR Server Suite/MediaPortal Plugins/TV3 Blaster Plugin/Forms/BlastCommand.Designer.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV3 Blaster Plugin/Forms/BlastCommand.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV3 Blaster Plugin/Forms/BlastCommand.resx trunk/plugins/IR Server Suite/MediaPortal Plugins/TV3 Blaster Plugin/Forms/LearnIR.Designer.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV3 Blaster Plugin/Forms/LearnIR.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV3 Blaster Plugin/Forms/LearnIR.resx Modified: trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.Designer.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.Designer.cs 2007-09-24 19:20:56 UTC (rev 955) +++ trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.Designer.cs 2007-09-26 07:34:18 UTC (rev 956) @@ -37,7 +37,6 @@ this.buttonDisconnect = new System.Windows.Forms.Button(); this.buttonShutdownServer = new System.Windows.Forms.Button(); this.listBoxStatus = new System.Windows.Forms.ListBox(); - this.buttonPing = new System.Windows.Forms.Button(); this.groupBoxStatus = new System.Windows.Forms.GroupBox(); this.groupBoxRemoteButton = new System.Windows.Forms.GroupBox(); this.labelCustomButton = new System.Windows.Forms.Label(); @@ -141,18 +140,6 @@ this.listBoxStatus.TabIndex = 0; this.toolTips.SetToolTip(this.listBoxStatus, "Status messages"); // - // buttonPing - // - this.buttonPing.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonPing.Location = new System.Drawing.Point(296, 16); - this.buttonPing.Name = "buttonPing"; - this.buttonPing.Size = new System.Drawing.Size(64, 24); - this.buttonPing.TabIndex = 3; - this.buttonPing.Text = "Ping"; - this.toolTips.SetToolTip(this.buttonPing, "Ping the server"); - this.buttonPing.UseVisualStyleBackColor = true; - this.buttonPing.Click += new System.EventHandler(this.buttonPing_Click); - // // groupBoxStatus // this.groupBoxStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -266,7 +253,6 @@ this.groupBoxCommands.Controls.Add(this.buttonBlast); this.groupBoxCommands.Controls.Add(this.buttonLearnIR); this.groupBoxCommands.Controls.Add(this.buttonShutdownServer); - this.groupBoxCommands.Controls.Add(this.buttonPing); this.groupBoxCommands.Location = new System.Drawing.Point(8, 80); this.groupBoxCommands.Name = "groupBoxCommands"; this.groupBoxCommands.Size = new System.Drawing.Size(440, 48); @@ -343,7 +329,6 @@ private System.Windows.Forms.Button buttonDisconnect; private System.Windows.Forms.Button buttonShutdownServer; private System.Windows.Forms.ListBox listBoxStatus; - private System.Windows.Forms.Button buttonPing; private System.Windows.Forms.GroupBox groupBoxStatus; private System.Windows.Forms.GroupBox groupBoxRemoteButton; private System.Windows.Forms.NumericUpDown numericUpDownButton; Modified: trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.cs 2007-09-24 19:20:56 UTC (rev 955) +++ trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.cs 2007-09-26 07:34:18 UTC (rev 956) @@ -20,7 +20,7 @@ namespace DebugClient { - public partial class MainForm : Form + partial class MainForm : Form { #region Enumerations @@ -107,11 +107,10 @@ Client _client = null; - string _serverHost = Environment.MachineName; + string _serverHost = "localhost"; string _learnIRFilename = null; bool _registered = false; - int _echoID = -1; IRServerInfo _irServerInfo = new IRServerInfo(); @@ -143,12 +142,14 @@ comboBoxPort.Items.Add("None"); comboBoxPort.SelectedIndex = 0; + comboBoxComputer.Items.Clear(); + comboBoxComputer.Items.Add("localhost"); + ArrayList networkPCs = IrssUtils.Win32.GetNetworkComputers(); if (networkPCs != null) - { comboBoxComputer.Items.AddRange(networkPCs.ToArray()); - comboBoxComputer.Text = _serverHost; - } + + comboBoxComputer.Text = _serverHost; } private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { @@ -192,9 +193,8 @@ { byte[] dataBytes = received.DataAsBytes; - FileStream file = new FileStream(_learnIRFilename, FileMode.Create); - file.Write(dataBytes, 0, dataBytes.Length); - file.Close(); + using (FileStream file = File.Create(_learnIRFilename)) + file.Write(dataBytes, 0, dataBytes.Length); } _learnIRFilename = null; @@ -204,10 +204,6 @@ _registered = false; return; - case MessageType.Echo: - _echoID = BitConverter.ToInt32(received.DataAsBytes, 0); - return; - case MessageType.Error: _learnIRFilename = null; this.Invoke(_addStatusLine, new Object[] { received.DataAsString }); @@ -247,21 +243,21 @@ { try { - if (!File.Exists(fileName)) - return false; + using (FileStream file = File.OpenRead(fileName)) + { + if (file.Length == 0) + throw new IOException(String.Format("Cannot Blast. IR file \"{0}\" has no data, possible IR learn failure", fileName)); - FileStream file = new FileStream(fileName, FileMode.Open); + byte[] outData = new byte[4 + port.Length + file.Length]; - byte[] outData = new byte[4 + port.Length + file.Length]; + BitConverter.GetBytes(port.Length).CopyTo(outData, 0); + Encoding.ASCII.GetBytes(port).CopyTo(outData, 4); - BitConverter.GetBytes(port.Length).CopyTo(outData, 0); - Encoding.ASCII.GetBytes(port).CopyTo(outData, 4); + file.Read(outData, 4 + port.Length, (int)file.Length); - file.Read(outData, 4 + port.Length, (int)file.Length); - file.Close(); - - IrssMessage message = new IrssMessage(MessageType.BlastIR, MessageFlags.Request, outData); - _client.Send(message); + IrssMessage message = new IrssMessage(MessageType.BlastIR, MessageFlags.Request, outData); + _client.Send(message); + } } catch (Exception ex) { @@ -303,16 +299,14 @@ Thread.Sleep(1000); } - bool StartClient() + bool StartClient(IPEndPoint endPoint) { if (_client != null) return false; ClientMessageSink sink = new ClientMessageSink(ReceivedMessage); - IPAddress serverAddress = Client.GetIPFromName(_serverHost); - - _client = new Client(serverAddress, 24000, sink); + _client = new Client(endPoint, sink); _client.CommsFailureCallback = new WaitCallback(CommsFailure); _client.ConnectCallback = new WaitCallback(Connected); _client.DisconnectCallback = new WaitCallback(Disconnected); @@ -332,7 +326,7 @@ if (_client == null) return; - _client.Stop(); + _client.Dispose(); _client = null; } @@ -353,7 +347,10 @@ _serverHost = comboBoxComputer.Text; - StartClient(); + IPAddress serverIP = Client.GetIPFromName(_serverHost); + IPEndPoint endPoint = new IPEndPoint(serverIP, IrssComms.Server.DefaultPort); + + StartClient(endPoint); } catch (Exception ex) { @@ -465,33 +462,7 @@ AddStatusLine(ex.Message); } } - private void buttonPing_Click(object sender, EventArgs e) - { - AddStatusLine("Ping Server"); - if (_client == null) - { - AddStatusLine(" - Not connected"); - return; - } - - if (!_client.Connected) - { - AddStatusLine(" - Connecting..."); - return; - } - - try - { - IrssMessage message = new IrssMessage(MessageType.Ping, MessageFlags.Request, BitConverter.GetBytes(24)); - _client.Send(message); - } - catch (Exception ex) - { - AddStatusLine(ex.Message); - } - } - private void comboBoxRemoteButtons_SelectedIndexChanged(object sender, EventArgs e) { if (comboBoxRemoteButtons.SelectedItem.ToString() == "Custom") Modified: trunk/plugins/IR Server Suite/Applications/IR Blast/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/IR Blast/Program.cs 2007-09-24 19:20:56 UTC (rev 955) +++ trunk/plugins/IR Server Suite/Applications/IR Blast/Program.cs 2007-09-26 07:34:18 UTC (rev 956) @@ -24,7 +24,6 @@ static Client _client = null; static bool _registered = false; - static int _echoID = -1; static string _serverHost = null; @@ -87,70 +86,76 @@ ShowHelp(); } - else if (StartClient()) + else { - Thread.Sleep(250); + IPAddress serverIP = Client.GetIPFromName(_serverHost); - // Wait for registered ... Give up after 10 seconds ... - int attempt = 0; - while (!_registered) + IPEndPoint endPoint = new IPEndPoint(serverIP, IrssComms.Server.DefaultPort); + + if (StartClient(endPoint)) { - if (++attempt >= 10) - break; - else - Thread.Sleep(1000); - } + Thread.Sleep(250); - if (_registered) - { - string fileName; - foreach (String command in irCommands) + // Wait for registered ... Give up after 10 seconds ... + int attempt = 0; + while (!_registered) { - if (_treatAsChannelNumber) + if (++attempt >= 10) + break; + else + Thread.Sleep(1000); + } + + if (_registered) + { + string fileName; + foreach (String command in irCommands) { - Info("Processing channel: {0}", command); - - StringBuilder channelNumber = new StringBuilder(command); - - if (_padChannelNumber > 0) + if (_treatAsChannelNumber) { - for (int index = 0; index < _padChannelNumber - command.Length; index++) - channelNumber.Insert(0, '0'); + Info("Processing channel: {0}", command); - Info("Padding channel number: {0} becomes {1}", command, channelNumber.ToString()); - } + StringBuilder channelNumber = new StringBuilder(command); - foreach (char digit in channelNumber.ToString()) - { - if (digit.Equals('~')) + if (_padChannelNumber > 0) { - Thread.Sleep(500); + for (int index = 0; index < _padChannelNumber - command.Length; index++) + channelNumber.Insert(0, '0'); + + Info("Padding channel number: {0} becomes {1}", command, channelNumber.ToString()); } - else + + foreach (char digit in channelNumber.ToString()) { - fileName = Common.FolderIRCommands + digit + Common.FileExtensionIR; - BlastIR(fileName, _blastPort); + if (digit.Equals('~')) + { + Thread.Sleep(500); + } + else + { + fileName = Common.FolderIRCommands + digit + Common.FileExtensionIR; + BlastIR(fileName, _blastPort); + } } } + else if (command.StartsWith("~")) + { + Thread.Sleep(command.Length * 500); + } + else + { + fileName = Common.FolderIRCommands + command; + BlastIR(fileName, _blastPort); + } } - else if (command.StartsWith("~")) - { - Thread.Sleep(command.Length * 500); - } - else - { - fileName = Common.FolderIRCommands + command; - BlastIR(fileName, _blastPort); - } + + Thread.Sleep(500); } - - Thread.Sleep(500); + else + { + Warn("Failed to register with server host \"{0}\", blasting not sent", _serverHost); + } } - else - { - Warn("Failed to register with server host \"{0}\", blasting not sent", _serverHost); - } - } } else // Give help ... @@ -240,16 +245,14 @@ Thread.Sleep(1000); } - static bool StartClient() + static bool StartClient(IPEndPoint endPoint) { if (_client != null) return false; ClientMessageSink sink = new ClientMessageSink(ReceivedMessage); - IPAddress serverAddress = Client.GetIPFromName(_serverHost); - - _client = new Client(serverAddress, 24000, sink); + _client = new Client(endPoint, sink); _client.CommsFailureCallback = new WaitCallback(CommsFailure); _client.ConnectCallback = new WaitCallback(Connected); _client.DisconnectCallback = new WaitCallback(Disconnected); @@ -269,7 +272,7 @@ if (_client == null) return; - _client.Stop(); + _client.Dispose(); _client = null; } @@ -307,10 +310,6 @@ Warn("IR Server Shutdown - Blasting disabled until IR Server returns"); break; - case MessageType.Echo: - _echoID = BitConverter.ToInt32(received.DataAsBytes, 0); - break; - case MessageType.Error: Warn(received.DataAsString); break; @@ -324,18 +323,21 @@ static void BlastIR(string fileName, string port) { - FileStream file = new FileStream(fileName, FileMode.Open); + using (FileStream file = File.OpenRead(fileName)) + { + if (file.Length == 0) + throw new IOException(String.Format("Cannot Blast. IR file \"{0}\" has no data, possible IR learn failure", fileName)); - byte[] outData = new byte[4 + port.Length + file.Length]; + byte[] outData = new byte[4 + port.Length + file.Length]; - BitConverter.GetBytes(port.Length).CopyTo(outData, 0); - Encoding.ASCII.GetBytes(port).CopyTo(outData, 4); + BitConverter.GetBytes(port.Length).CopyTo(outData, 0); + Encoding.ASCII.GetBytes(port).CopyTo(outData, 4); - file.Read(outData, 4 + port.Length, (int)file.Length); - file.Close(); + file.Read(outData, 4 + port.Length, (int)file.Length); - IrssMessage message = new IrssMessage(MessageType.BlastIR, MessageFlags.Request | MessageFlags.ForceNotRespond, outData); - _client.Send(message); + IrssMessage message = new IrssMessage(MessageType.BlastIR, MessageFlags.Request | MessageFlags.ForceNotRespond, outData); + _client.Send(message); + } } #region Log Commands Modified: trunk/plugins/IR Server Suite/Applications/IR Blast (No Window)/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/IR Blast (No Window)/Program.cs 2007-09-24 19:20:56 UTC (rev 955) +++ trunk/plugins/IR Server Suite/Applications/IR Blast (No Window)/Program.cs 2007-09-26 07:34:18 UTC (rev 956) @@ -25,7 +25,6 @@ static Client _client = null; static bool _registered = false; - static int _echoID = -1; static string _serverHost = null; @@ -86,69 +85,77 @@ ShowHelp(); } - else if (StartClient()) + else { - Thread.Sleep(250); + IPAddress serverIP = Client.GetIPFromName(_serverHost); - // Wait for registered ... Give up after 10 seconds ... - int attempt = 0; - while (!_registered) + IPEndPoint endPoint = new IPEndPoint(serverIP, IrssComms.Server.DefaultPort); + + if (StartClient(endPoint)) { - if (++attempt >= 10) - break; - else - Thread.Sleep(1000); - } + Thread.Sleep(250); - if (_registered) - { - string fileName; - foreach (String command in irCommands) + // Wait for registered ... Give up after 10 seconds ... + int attempt = 0; + while (!_registered) { - if (_treatAsChannelNumber) + if (++attempt >= 10) + break; + else + Thread.Sleep(1000); + } + + if (_registered) + { + string fileName; + foreach (String command in irCommands) { - IrssLog.Info("Processing channel: {0}", command); - - StringBuilder channelNumber = new StringBuilder(command); - - if (_padChannelNumber > 0) + if (_treatAsChannelNumber) { - for (int index = 0; index < _padChannelNumber - command.Length; index++) - channelNumber.Insert(0, '0'); + IrssLog.Info("Processing channel: {0}", command); - IrssLog.Info("Padding channel number: {0} becomes {1}", command, channelNumber.ToString()); - } + StringBuilder channelNumber = new StringBuilder(command); - foreach (char digit in channelNumber.ToString()) - { - if (digit.Equals('~')) + if (_padChannelNumber > 0) { - Thread.Sleep(500); + for (int index = 0; index < _padChannelNumber - command.Length; index++) + channelNumber.Insert(0, '0'); + + IrssLog.Info("Padding channel number: {0} becomes {1}", command, channelNumber.ToString()); } - else + + foreach (char digit in channelNumber.ToString()) { - fileName = Common.FolderIRCommands + digit + Common.FileExtensionIR; - BlastIR(fileName, _blastPort); + if (digit.Equals('~')) + { + Thread.Sleep(500); + } + else + { + fileName = Common.FolderIRCommands + digit + Common.FileExtensionIR; + BlastIR(fileName, _blastPort); + } } } + else if (command.StartsWith("~")) + { + Thread.Sleep(command.Length * 500); + } + else + { + fileName = Common.FolderIRCommands + command; + BlastIR(fileName, _blastPort); + } } - else if (command.StartsWith("~")) - { - Thread.Sleep(command.Length * 500); - } - else - { - fileName = Common.FolderIRCommands + command; - BlastIR(fileName, _blastPort); - } + + Thread.Sleep(500); } + else + { + IrssLog.Warn("Failed to register with server host \"{0}\", blasting not sent", _serverHost); + } - Thread.Sleep(500); } - else - { - IrssLog.Warn("Failed to register with server host \"{0}\", blasting not sent", _serverHost); - } } } @@ -202,16 +209,14 @@ Thread.Sleep(1000); } - static bool StartClient() + static bool StartClient(IPEndPoint endPoint) { if (_client != null) return false; ClientMessageSink sink = new ClientMessageSink(ReceivedMessage); - IPAddress serverAddress = Client.GetIPFromName(_serverHost); - - _client = new Client(serverAddress, 24000, sink); + _client = new Client(endPoint, sink); _client.CommsFailureCallback = new WaitCallback(CommsFailure); _client.ConnectCallback = new WaitCallback(Connected); _client.DisconnectCallback = new WaitCallback(Disconnected); @@ -231,7 +236,7 @@ if (_client == null) return; - _client.Stop(); + _client.Dispose(); _client = null; } @@ -269,10 +274,6 @@ IrssLog.Warn("IR Server Shutdown - Blasting disabled until IR Server returns"); break; - case MessageType.Echo: - _echoID = BitConverter.ToInt32(received.DataAsBytes, 0); - break; - case MessageType.Error: IrssLog.Warn(received.DataAsString); break; @@ -286,18 +287,21 @@ static void BlastIR(string fileName, string port) { - FileStream file = new FileStream(fileName, FileMode.Open); + using (FileStream file = File.OpenRead(fileName)) + { + if (file.Length == 0) + throw new IOException(String.Format("Cannot Blast. IR file \"{0}\" has no data, possible IR learn failure", fileName)); - byte[] outData = new byte[4 + port.Length + file.Length]; + byte[] outData = new byte[4 + port.Length + file.Length]; - BitConverter.GetBytes(port.Length).CopyTo(outData, 0); - Encoding.ASCII.GetBytes(port).CopyTo(outData, 4); + BitConverter.GetBytes(port.Length).CopyTo(outData, 0); + Encoding.ASCII.GetBytes(port).CopyTo(outData, 4); - file.Read(outData, 4 + port.Length, (int)file.Length); - file.Close(); + file.Read(outData, 4 + port.Length, (int)file.Length); - IrssMessage message = new IrssMessage(MessageType.BlastIR, MessageFlags.Request | MessageFlags.ForceNotRespond, outData); - _client.Send(message); + IrssMessage message = new IrssMessage(MessageType.BlastIR, MessageFlags.Request | MessageFlags.ForceNotRespond, outData); + _client.Send(message); + } } } Modified: trunk/plugins/IR Server Suite/Applications/IR Server/Config.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/IR Server/Config.cs 2007-09-24 19:20:56 UTC (rev 955) +++ trunk/plugins/IR Server Suite/Applications/IR Server/Config.cs 2007-09-26 07:34:18 UTC (rev 956) @@ -15,7 +15,7 @@ namespace IRServer { - public partial class Config : Form + partial class Config : Form { #region Variables @@ -40,19 +40,24 @@ set { _hostComputer = value; } } - public string PluginReceive + public string[] PluginReceive { get { + List<string> receivers = new List<string>(); + SourceGrid.Cells.CheckBox checkBox; for (int row = 1; row < gridPlugins.RowsCount; row++) { checkBox = gridPlugins[row, 1] as SourceGrid.Cells.CheckBox; if (checkBox != null && checkBox.Checked) - return gridPlugins[row, 0].DisplayText; + receivers.Add(gridPlugins[row, 0].DisplayText); } - return String.Empty; + if (receivers.Count == 0) + return null; + else + return receivers.ToArray(); } set { @@ -63,7 +68,9 @@ if (checkBox == null) continue; - if (gridPlugins[row, 0].DisplayText.Equals(value, StringComparison.InvariantCultureIgnoreCase)) + if (value == null) + checkBox.Checked = false; + else if (Array.IndexOf<string>(value, gridPlugins[row, 0].DisplayText) != -1) checkBox.Checked = true; else checkBox.Checked = false; @@ -173,13 +180,13 @@ gridPlugins[row, 0] = nameCell; - if (transceiver is IRemoteReceiver) + if (transceiver is IRemoteReceiver || transceiver is IMouseReceiver || transceiver is IKeyboardReceiver) { SourceGrid.Cells.CheckBox checkbox = new SourceGrid.Cells.CheckBox(); - SourceGrid.Cells.Controllers.CustomEvents checkboxcontroller = new SourceGrid.Cells.Controllers.CustomEvents(); - checkboxcontroller.ValueChanged += new EventHandler(ReceiveChanged); - checkbox.Controller.AddController(checkboxcontroller); + //SourceGrid.Cells.Controllers.CustomEvents checkboxcontroller = new SourceGrid.Cells.Controllers.CustomEvents(); + //checkboxcontroller.ValueChanged += new EventHandler(ReceiveChanged); + //checkbox.Controller.AddController(checkboxcontroller); gridPlugins[row, 1] = checkbox; } @@ -259,7 +266,7 @@ if (transceiver.Name == plugin) (transceiver as IConfigure).Configure(); } - + /* private void ReceiveChanged(object sender, EventArgs e) { SourceGrid.CellContext context = (SourceGrid.CellContext)sender; @@ -277,6 +284,7 @@ checkBox.Checked = false; } } + */ private void TransmitChanged(object sender, EventArgs e) { SourceGrid.CellContext context = (SourceGrid.CellContext)sender; Modified: trunk/plugins/IR Server Suite/Applications/IR Server/IRServer.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/IR Server/IRServer.cs 2007-09-24 19:20:56 UTC (rev 955) +++ trunk/plugins/IR Server Suite/Applications/IR Server/IRServer.cs 2007-09-26 07:34:18 UTC (rev 956) @@ -62,18 +62,16 @@ Server _server = null; Client _client = null; - int _serverPort = 24000; - IRServerMode _mode; string _hostComputer; bool _registered = false; // Used for relay and repeater modes. - string _pluginNameReceive = String.Empty; - IRServerPlugin _pluginReceive = null; + string[] _pluginNameReceive; + IRServerPlugin[] _pluginReceive; - string _pluginNameTransmit = String.Empty; - IRServerPlugin _pluginTransmit = null; + string _pluginNameTransmit; + IRServerPlugin _pluginTransmit; bool _inConfiguration = false; @@ -115,111 +113,132 @@ _pluginReceive = null; _pluginTransmit = null; - if (String.IsNullOrEmpty(_pluginNameReceive) && String.IsNullOrEmpty(_pluginNameTransmit)) + if (_pluginNameReceive == null && String.IsNullOrEmpty(_pluginNameTransmit)) { - IrssLog.Warn("No transmit or receive plugin loaded"); + IrssLog.Warn("No transmit or receive plugins loaded"); } else { - if (String.IsNullOrEmpty(_pluginNameReceive)) + if (_pluginNameReceive == null) { - IrssLog.Warn("No receiver plugin loaded"); + IrssLog.Warn("No receiver plugins loaded"); } else { - _pluginReceive = Program.GetPlugin(_pluginNameReceive); + List<IRServerPlugin> plugins = new List<IRServerPlugin>(_pluginNameReceive.Length); + + for (int index = 0; index < _pluginNameReceive.Length; index++) + { + string pluginName = _pluginNameReceive[index]; + + IRServerPlugin plugin = Program.GetPlugin(pluginName); + + if (plugin == null) + { + IrssLog.Warn("Receiver plugin not found: {0}", pluginName); + } + else + { + plugins.Add(plugin); + + if (!String.IsNullOrEmpty(_pluginNameTransmit) && plugin.Name.Equals(_pluginNameTransmit)) + _pluginTransmit = plugin; + } + } + + _pluginReceive = plugins.ToArray(); } - if (_pluginNameTransmit.Equals(_pluginNameReceive, StringComparison.InvariantCultureIgnoreCase)) + if (String.IsNullOrEmpty(_pluginNameTransmit)) { - _pluginTransmit = _pluginReceive; - IrssLog.Info("Using the same plugin for transmit and receive"); - } - else if (String.IsNullOrEmpty(_pluginNameTransmit)) - { IrssLog.Warn("No transmit plugin loaded"); } - else + else if (_pluginTransmit != null) { _pluginTransmit = Program.GetPlugin(_pluginNameTransmit); - } + } } switch (_mode) { case IRServerMode.ServerMode: - { - StartServer(); + StartServer(); + IrssLog.Info("Started in Server Mode"); + break; - IrssLog.Info("Started in Server Mode"); - break; - } - case IRServerMode.RelayMode: - { - if (StartRelay()) - IrssLog.Info("Started in Relay Mode"); - else - IrssLog.Error("Failed to start in Relay Mode"); - break; - } + if (StartRelay()) + IrssLog.Info("Started in Relay Mode"); + else + IrssLog.Error("Failed to start in Relay Mode"); + break; case IRServerMode.RepeaterMode: - { - if (StartRepeater()) - IrssLog.Info("Started in Repeater Mode"); - else - IrssLog.Error("Failed to start in Repeater Mode"); - break; - } + if (StartRepeater()) + IrssLog.Info("Started in Repeater Mode"); + else + IrssLog.Error("Failed to start in Repeater Mode"); + break; } // Start plugin(s) ... + + bool startedTransmit = false; + if (_pluginReceive != null) { - try + foreach (IRServerPlugin plugin in _pluginReceive) { - if (_pluginReceive.Start()) - IrssLog.Info("Receiver plugin started: \"{0}\"", _pluginNameReceive); - else - IrssLog.Error("Failed to start receive plugin: \"{0}\"", _pluginNameReceive); - } - catch (Exception ex) - { - IrssLog.Error("Failed to start receive plugin: \"{0}\"", _pluginNameReceive); - IrssLog.Error(ex.ToString()); - } - } - - if (!_pluginNameTransmit.Equals(_pluginNameReceive, StringComparison.InvariantCultureIgnoreCase)) - { - if (_pluginTransmit != null) - { try { - if (_pluginTransmit.Start()) - IrssLog.Info("Transmit plugin started: \"{0}\"", _pluginNameTransmit); + if (plugin.Start()) + { + if (plugin is IRemoteReceiver) + (plugin as IRemoteReceiver).RemoteCallback += new RemoteHandler(RemoteHandlerCallback); + + if (plugin is IKeyboardReceiver) + (plugin as IKeyboardReceiver).KeyboardCallback += new KeyboardHandler(KeyboardHandlerCallback); + + if (plugin is IMouseReceiver) + (plugin as IMouseReceiver).MouseCallback += new MouseHandler(MouseHandlerCallback); + + if (plugin.Name.Equals(_pluginTransmit.Name)) + { + startedTransmit = true; + IrssLog.Info("Transmit and Receive plugin started: \"{0}\"", plugin.Name); + } + else + { + IrssLog.Info("Receiver plugin started: \"{0}\"", plugin.Name); + } + } else - IrssLog.Error("Failed to start transmit plugin: \"{0}\"", _pluginNameTransmit); + { + IrssLog.Error("Failed to start receive plugin: \"{0}\"", plugin.Name); + } } catch (Exception ex) { - IrssLog.Error("Failed to start transmit plugin: \"{0}\"", _pluginNameTransmit); + IrssLog.Error("Failed to start receive plugin: \"{0}\"", plugin.Name); IrssLog.Error(ex.ToString()); } } } - - if (_pluginReceive != null) + + if (_pluginTransmit != null && !startedTransmit) { - if (_pluginReceive is IRemoteReceiver) - (_pluginReceive as IRemoteReceiver).RemoteCallback += new RemoteHandler(RemoteHandlerCallback); - - if (_pluginReceive is IKeyboardReceiver) - (_pluginReceive as IKeyboardReceiver).KeyboardCallback += new KeyboardHandler(KeyboardHandlerCallback); - - if (_pluginReceive is IMouseReceiver) - (_pluginReceive as IMouseReceiver).MouseCallback += new MouseHandler(MouseHandlerCallback); + try + { + if (_pluginTransmit.Start()) + IrssLog.Info("Transmit plugin started: \"{0}\"", _pluginNameTransmit); + else + IrssLog.Error("Failed to start transmit plugin: \"{0}\"", _pluginNameTransmit); + } + catch (Exception ex) + { + IrssLog.Error("Failed to start transmit plugin: \"{0}\"", _pluginNameTransmit); + IrssLog.Error(ex.ToString()); + } } _notifyIcon.Visible = true; @@ -254,32 +273,52 @@ SendToAll(message); } + // Stop Plugin(s) ... + + bool stoppedTransmit = false; + if (_pluginReceive != null) { - if (_pluginReceive is IRemoteReceiver) - (_pluginReceive as IRemoteReceiver).RemoteCallback -= new RemoteHandler(RemoteHandlerCallback); - - if (_pluginReceive is IKeyboardReceiver) - (_pluginReceive as IKeyboardReceiver).KeyboardCallback -= new KeyboardHandler(KeyboardHandlerCallback); - - if (_pluginReceive is IMouseReceiver) - (_pluginReceive as IMouseReceiver).MouseCallback -= new MouseHandler(MouseHandlerCallback); + foreach (IRServerPlugin plugin in _pluginReceive) + { + try + { + if (plugin is IRemoteReceiver) + (plugin as IRemoteReceiver).RemoteCallback -= new RemoteHandler(RemoteHandlerCallback); + + if (plugin is IKeyboardReceiver) + (plugin as IKeyboardReceiver).KeyboardCallback -= new KeyboardHandler(KeyboardHandlerCallback); + + if (plugin is IMouseReceiver) + (plugin as IMouseReceiver).MouseCallback -= new MouseHandler(MouseHandlerCallback); + + plugin.Stop(); + + if (plugin == _pluginTransmit) + { + stoppedTransmit = true; + IrssLog.Info("Transmit and Receive plugin stopped: \"{0}\"", plugin.Name); + } + else + { + IrssLog.Info("Receiver plugin stopped: \"{0}\"", plugin.Name); + } + } + catch (Exception ex) + { + IrssLog.Error(ex.ToString()); + } + } + + _pluginReceive = null; } - - // Stop Plugin(s) + try { - if (_pluginReceive != null) - _pluginReceive.Stop(); - } - catch (Exception ex) - { - IrssLog.Error(ex.ToString()); - } - try - { - if (_pluginTransmit != null && _pluginTransmit != _pluginReceive) + if (_pluginTransmit != null && !stoppedTransmit) _pluginTransmit.Stop(); + + _pluginTransmit = null; } catch (Exception ex) { @@ -337,7 +376,7 @@ _pluginNameReceive = config.PluginReceive; _pluginNameTransmit = config.PluginTransmit; - SaveSettings(); // Save Settings + SaveSettings(); Start(); // Restart communications } @@ -361,7 +400,7 @@ _registeredRepeaters = new List<ClientManager>(); ServerMessageSink sink = new ServerMessageSink(ServerReceivedMessage); - _server = new Server(_serverPort, sink); + _server = new Server(Server.DefaultPort, sink); _server.Start(); } @@ -370,7 +409,7 @@ if (_server == null) return; - _server.Stop(); + _server.Dispose(); _server = null; _registeredClients.Clear(); @@ -410,16 +449,14 @@ Thread.Sleep(1000); } - bool StartClient() + bool StartClient(IPEndPoint endPoint) { if (_client != null) return false; ClientMessageSink sink = new ClientMessageSink(ClientReceivedMessage); - IPAddress serverAddress = Client.GetIPFromName(_hostComputer); - - _client = new Client(serverAddress, 24000, sink); + _client = new Client(endPoint, sink); _client.CommsFailureCallback = new WaitCallback(CommsFailure); _client.ConnectCallback = new WaitCallback(Connected); _client.DisconnectCallback = new WaitCallback(Disconnected); @@ -439,17 +476,21 @@ if (_client == null) return; - _client.Stop(); + _client.Dispose(); _client = null; } - + bool StartRelay() { try { StartServer(); - StartClient(); + IPAddress serverIP = Client.GetIPFromName(_hostComputer); + IPEndPoint endPoint = new IPEndPoint(serverIP, IrssComms.Server.DefaultPort); + + StartClient(endPoint); + return true; } catch (Exception ex) @@ -473,8 +514,12 @@ try { StartServer(); - StartClient(); + IPAddress serverIP = Client.GetIPFromName(_hostComputer); + IPEndPoint endPoint = new IPEndPoint(serverIP, IrssComms.Server.DefaultPort); + + StartClient(endPoint); + return true; } catch (Exception ex) @@ -604,30 +649,55 @@ { IrssLog.Info("Resume from standby ..."); + bool resumedTransmit = false; + if (_pluginReceive != null) - _pluginReceive.Resume(); + { + foreach (IRServerPlugin plugin in _pluginReceive) + { + if (_pluginTransmit == plugin) + resumedTransmit = true; - if (_pluginTransmit != null && _pluginTransmit != _pluginReceive) + plugin.Resume(); + } + } + + if (_pluginTransmit != null && !resumedTransmit) _pluginTransmit.Resume(); - // TODO: Inform clients ? + // Inform clients ... + if (_mode == IRServerMode.ServerMode) + { + IrssMessage message = new IrssMessage(MessageType.ServerResume, MessageFlags.Notify); + SendToAll(message); + } break; } case PowerModes.Suspend: { - IrssLog.Info("Enter low-power standby ..."); + IrssLog.Info("Enter standby ..."); + bool suspendedTransmit = false; + if (_pluginReceive != null) - _pluginReceive.Suspend(); + { + foreach (IRServerPlugin plugin in _pluginReceive) + { + if (_pluginTransmit == plugin) + suspendedTransmit = true; - if (_pluginTransmit != null && _pluginTransmit != _pluginReceive) + plugin.Suspend(); + } + } + + if (_pluginTransmit != null && !suspendedTransmit) _pluginTransmit.Suspend(); // Inform clients ... if (_mode == IRServerMode.ServerMode) { - IrssMessage message = new IrssMessage(MessageType.ServerShutdown, MessageFlags.Notify); + IrssMessage message = new IrssMessage(MessageType.ServerSuspend, MessageFlags.Notify); SendToAll(message); } break; @@ -975,13 +1045,6 @@ break; - case MessageType.Ping: - { - IrssMessage response = new IrssMessage(MessageType.Echo, MessageFlags.Response, combo.Message.DataAsBytes); - SendTo(combo.Manager, response); - break; - } - case MessageType.RegisterClient: { IrssMessage response = new IrssMessage(MessageType.RegisterClient, MessageFlags.Response); @@ -1104,45 +1167,85 @@ void LoadSettings() { + _mode = IRServerMode.ServerMode; + _hostComputer = String.Empty; + _pluginNameReceive = null; + _pluginNameTransmit = String.Empty; + + XmlDocument doc = new XmlDocument(); + try { - XmlDocument doc = new XmlDocument(); doc.Load(ConfigurationFile); - - _mode = (IRServerMode)Enum.Parse(typeof(IRServerMode), doc.DocumentElement.Attributes["Mode"].Value, true); - _hostComputer = doc.DocumentElement.Attributes["HostComputer"].Value; - _pluginNameReceive = doc.DocumentElement.Attributes["PluginReceive"].Value; - _pluginNameTransmit = doc.DocumentElement.Attributes["PluginTransmit"].Value; } + catch (FileNotFoundException) + { + IrssLog.Warn("No configuration file found ({0}), creating default configuration file", ConfigurationFile); + SaveSettings(); + return; + } catch (Exception ex) { IrssLog.Error(ex.ToString()); + return; + } - _mode = IRServerMode.ServerMode; - _hostComputer = String.Empty; - _pluginNameReceive = String.Empty; - _pluginNameTransmit = String.Empty; + try { _mode = (IRServerMode)Enum.Parse(typeof(IRServerMode), doc.DocumentElement.Attributes["Mode"].Value, true); } + catch (Exception ex) { IrssLog.Warn(ex.ToString()); } + + try { _hostComputer = doc.DocumentElement.Attributes["HostComputer"].Value; } + catch (Exception ex) { IrssLog.Warn(ex.ToString()); } + + try { _pluginNameTransmit = doc.DocumentElement.Attributes["PluginTransmit"].Value; } + catch (Exception ex) { IrssLog.Warn(ex.ToString()); } + + try + { + string receivers = doc.DocumentElement.Attributes["PluginReceive"].Value; + if (!String.IsNullOrEmpty(receivers)) + _pluginNameReceive = receivers.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } + catch (Exception ex) + { + IrssLog.Warn(ex.ToString()); + } } 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> + using (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("PluginReceive", _pluginNameReceive); - writer.WriteAttributeString("PluginTransmit", _pluginNameTransmit); + writer.WriteAttributeString("Mode", Enum.GetName(typeof(IRServerMode), _mode)); + writer.WriteAttributeString("HostComputer", _hostComputer); + writer.WriteAttributeString("PluginTransmit", _pluginNameTransmit); - writer.WriteEndElement(); // </settings> - writer.WriteEndDocument(); - writer.Close(); + if (_pluginNameReceive != null) + { + StringBuilder receivers = new StringBuilder(); + for (int index = 0; index < _pluginNameReceive.Length; index++) + { + receivers.Append(_pluginNameReceive[index]); + + if (index < _pluginNameReceive.Length - 1) + receivers.Append(','); + } + writer.WriteAttributeString("PluginReceive", receivers.ToString()); + } + else + { + writer.WriteAttributeString("PluginReceive", String.Empty); + } + + writer.WriteEndElement(); // </settings> + writer.WriteEndDocument(); + } } catch (Exception ex) { Modified: trunk/plugins/IR Server Suite/Applications/IR Server/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/IR Server/Program.cs 2007-09-24 19:20:56 UTC (rev 955) +++ trunk/plugins/IR Server Suite/Applications/IR Server/Program.cs 2007-09-26 07:34:18 UTC (rev 956) @@ -83,18 +83,16 @@ try { Assembly assembly = Assembly.LoadFrom(file); - Type[] types = assembly.GetExportedTypes(); foreach (Type type in types) { if (type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(IRServerPlugin))) { - IRServerPlugin plugin = (IRServerPlugin)Activator.CreateInstance(type); - if (plugin == null) - continue; - - plugins.Add(plugin); + IRServerPlugin plugin = (IRServerPlugin)assembly.CreateInstance(type.FullName); + + if (plugin != null) + plugins.Add(plugin); } } } Modified: trunk/plugins/IR Server Suite/Applications/Translator/Configuration.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Translator/Configuration.cs 2007-09-24 19:20:56 UTC (rev 955) +++ trunk/plugins/IR Server Suite/Applications/Translator/Configuration.cs 2007-09-26 07:34:18 UTC (rev 956) @@ -75,7 +75,7 @@ public Configuration() { - _serverHost = String.Empty; + _serverHost = "localhost"; _systemWideMappings = new List<ButtonMapping>(); _programSettings = new List<ProgramSettings>(); @@ -122,6 +122,11 @@ using (StreamReader file = new StreamReader(fileName)) return (Configuration)reader.Deserialize(file); } + catch (FileNotFoundException) + { + IrssLog.Warn("No configuration file found ({0}), using default configuration", fileName); + return new Configuration(); + } catch (Exception ex) { IrssLog.Error(ex.ToString()); Modified: trunk/plugins/IR Server Suite/Applications/Translator/EventSchedule.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Translator/EventSchedule.cs 2007-09-24 19:20:56 UTC (rev 955) +++ trunk/plugins/IR Server Suite/Applications/Translator/EventSchedule.cs 2007-09-26 07:34:18 UTC (rev 956) @@ -51,7 +51,7 @@ #endregion Enumerations - public class EventSchedule + class EventSchedule { //DateTime _start; Deleted: trunk/plugins/IR Server Suite/Applications/Translator/Forms/BlastCommand.Designer.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Translator/Forms/BlastCommand.Designer.cs 2007-09-24 19:20:56 UTC (rev 955) +++ trunk/plugins/IR Server Suite/Applications/Translator/Forms/BlastCommand.Designer.cs 2007-09-26 07:34:18 UTC (rev 956) @@ -1,150 +0,0 @@ -namespace Translator -{ - partial class BlastCommand - { - /// <summary> - /// Required designer variable. - /// </summary> - private System.ComponentModel.IContainer components = null; - - /// <summary> - /// Clean up any resources being used. - /// </summary> - /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disp... [truncated message content] |