From: <an...@us...> - 2007-09-28 16:31:52
|
Revision: 959 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=959&view=rev Author: and-81 Date: 2007-09-28 09:31:49 -0700 (Fri, 28 Sep 2007) Log Message: ----------- Modified Paths: -------------- 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/IRServer.cs trunk/plugins/IR Server Suite/Applications/IR Server/Program.cs trunk/plugins/IR Server Suite/Applications/Translator/Forms/GetKeyCodeForm.cs trunk/plugins/IR Server Suite/Applications/Translator/Forms/MainForm.Designer.cs trunk/plugins/IR Server Suite/Applications/Translator/Forms/MainForm.cs trunk/plugins/IR Server Suite/Applications/Translator/Forms/MainForm.resx trunk/plugins/IR Server Suite/Applications/Translator/Program.cs trunk/plugins/IR Server Suite/Applications/Tray Launcher/GetKeyCodeForm.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 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/GenericPCQueue.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/IrssLog.cs trunk/plugins/IR Server Suite/Common/IrssUtils/SystemRegistry.cs trunk/plugins/IR Server Suite/Common/IrssUtils/Win32.cs trunk/plugins/IR Server Suite/Common/MPUtils/MPCommands.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/IRMan Receiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/IRTrans Transceiver/IRTransTransceiver.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/IrDecoder.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/NotifyWindow.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/RemoteDetectionData.cs trunk/plugins/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver/UirtTransceiver.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/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/MediaPortal Plugins/MP Blast Zone Plugin/Forms/MacroEditor.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/MacroEditor.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/TV2BlasterPlugin.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV3 Blaster Plugin/TV3BlasterPlugin.cs Modified: trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.cs 2007-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -173,7 +173,7 @@ if ((received.Flags & MessageFlags.Success) == MessageFlags.Success) { _registered = true; - _irServerInfo = IRServerInfo.FromBytes(received.DataAsBytes); + _irServerInfo = IRServerInfo.FromBytes(received.GetDataAsBytes()); comboBoxPort.Items.Clear(); comboBoxPort.Items.AddRange(_irServerInfo.Ports); comboBoxPort.SelectedIndex = 0; @@ -185,13 +185,13 @@ return; case MessageType.RemoteEvent: - RemoteHandlerCallback(received.DataAsString); + RemoteHandlerCallback(received.GetDataAsString()); return; case MessageType.LearnIR: if ((received.Flags & MessageFlags.Success) == MessageFlags.Success) { - byte[] dataBytes = received.DataAsBytes; + byte[] dataBytes = received.GetDataAsBytes(); using (FileStream file = File.Create(_learnIRFilename)) file.Write(dataBytes, 0, dataBytes.Length); @@ -206,7 +206,7 @@ case MessageType.Error: _learnIRFilename = null; - this.Invoke(_addStatusLine, new Object[] { received.DataAsString }); + this.Invoke(_addStatusLine, new Object[] { received.GetDataAsString() }); return; } } Modified: trunk/plugins/IR Server Suite/Applications/IR Blast/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/IR Blast/Program.cs 2007-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/Applications/IR Blast/Program.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -311,7 +311,7 @@ break; case MessageType.Error: - Warn(received.DataAsString); + Warn(received.GetDataAsString()); break; } } 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-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/Applications/IR Blast (No Window)/Program.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -275,7 +275,7 @@ break; case MessageType.Error: - IrssLog.Warn(received.DataAsString); + IrssLog.Warn(received.GetDataAsString()); break; } } Modified: trunk/plugins/IR Server Suite/Applications/IR Server/IRServer.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/IR Server/IRServer.cs 2007-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/Applications/IR Server/IRServer.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -43,7 +43,7 @@ #endregion Enumerations - internal class IRServer + internal class IRServer : IDisposable { #region Constants @@ -59,8 +59,8 @@ List<ClientManager> _registeredClients; List<ClientManager> _registeredRepeaters; - Server _server = null; - Client _client = null; + Server _server; + Client _client; IRServerMode _mode; string _hostComputer; @@ -77,7 +77,7 @@ #endregion Variables - #region Constructor + #region Constructor / Destructor public IRServer() { @@ -93,8 +93,38 @@ _notifyIcon.Text = "IR Server"; } - #endregion Constructor + /* + ~IRServer() + { + Dispose(false); + } + */ + #endregion Constructor / Destructor + + #region IDisposable + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposeManagedResources) + { + if (disposeManagedResources) + { + // Dispose managed resources ... + _notifyIcon.Dispose(); + _notifyIcon = null; + } + + // Free native resources ... + + } + + #endregion IDisposable + #region Implementation /// <summary> @@ -159,6 +189,7 @@ } } + // Mode select ... switch (_mode) { case IRServerMode.ServerMode: @@ -193,14 +224,17 @@ { if (plugin.Start()) { - if (plugin is IRemoteReceiver) - (plugin as IRemoteReceiver).RemoteCallback += new RemoteHandler(RemoteHandlerCallback); + IRemoteReceiver remoteReceiver = plugin as IRemoteReceiver; + if (remoteReceiver != null) + remoteReceiver.RemoteCallback += new RemoteHandler(RemoteHandlerCallback); - if (plugin is IKeyboardReceiver) - (plugin as IKeyboardReceiver).KeyboardCallback += new KeyboardHandler(KeyboardHandlerCallback); + IKeyboardReceiver keyboardReceiver = plugin as IKeyboardReceiver; + if (keyboardReceiver != null) + keyboardReceiver.KeyboardCallback += new KeyboardHandler(KeyboardHandlerCallback); - if (plugin is IMouseReceiver) - (plugin as IMouseReceiver).MouseCallback += new MouseHandler(MouseHandlerCallback); + IMouseReceiver mouseReceiver = plugin as IMouseReceiver; + if (mouseReceiver != null) + mouseReceiver.MouseCallback += new MouseHandler(MouseHandlerCallback); if (plugin.Name.Equals(_pluginTransmit.Name)) { @@ -274,7 +308,6 @@ } // Stop Plugin(s) ... - bool stoppedTransmit = false; if (_pluginReceive != null) @@ -283,14 +316,17 @@ { try { - if (plugin is IRemoteReceiver) - (plugin as IRemoteReceiver).RemoteCallback -= new RemoteHandler(RemoteHandlerCallback); + IRemoteReceiver remoteReceiver = plugin as IRemoteReceiver; + if (remoteReceiver != null) + remoteReceiver.RemoteCallback -= new RemoteHandler(RemoteHandlerCallback); - if (plugin is IKeyboardReceiver) - (plugin as IKeyboardReceiver).KeyboardCallback -= new KeyboardHandler(KeyboardHandlerCallback); + IKeyboardReceiver keyboardReceiver = plugin as IKeyboardReceiver; + if (keyboardReceiver != null) + keyboardReceiver.KeyboardCallback -= new KeyboardHandler(KeyboardHandlerCallback); - if (plugin is IMouseReceiver) - (plugin as IMouseReceiver).MouseCallback -= new MouseHandler(MouseHandlerCallback); + IMouseReceiver mouseReceiver = plugin as IMouseReceiver; + if (mouseReceiver != null) + mouseReceiver.MouseCallback -= new MouseHandler(MouseHandlerCallback); plugin.Stop(); @@ -406,17 +442,23 @@ } void StopServer() { - if (_server == null) - return; + if (_server != null) + { + _server.Dispose(); + _server = null; + } - _server.Dispose(); - _server = null; + if (_registeredClients != null) + { + _registeredClients.Clear(); + _registeredClients = null; + } - _registeredClients.Clear(); - _registeredClients = null; - - _registeredRepeaters.Clear(); - _registeredRepeaters = null; + if (_registeredRepeaters != null) + { + _registeredRepeaters.Clear(); + _registeredRepeaters = null; + } } void CommsFailure(object obj) @@ -473,11 +515,11 @@ } void StopClient() { - if (_client == null) - return; - - _client.Dispose(); - _client = null; + if (_client != null) + { + _client.Dispose(); + _client = null; + } } bool StartRelay() @@ -539,11 +581,16 @@ IrssMessage message = new IrssMessage(MessageType.UnregisterRepeater, MessageFlags.Request); _client.Send(message); } - + } + catch + { + throw; + } + finally + { StopServer(); StopClient(); } - catch { } } void RemoteHandlerCallback(string keyCode) @@ -939,12 +986,12 @@ case MessageType.ForwardRemoteEvent: if (_mode == IRServerMode.RelayMode) { - IrssMessage forward = new IrssMessage(MessageType.ForwardRemoteEvent, MessageFlags.Request, combo.Message.DataAsBytes); + IrssMessage forward = new IrssMessage(MessageType.ForwardRemoteEvent, MessageFlags.Request, combo.Message.GetDataAsBytes()); _client.Send(forward); } else { - IrssMessage forward = new IrssMessage(MessageType.RemoteEvent, MessageFlags.Notify, combo.Message.DataAsBytes); + IrssMessage forward = new IrssMessage(MessageType.RemoteEvent, MessageFlags.Notify, combo.Message.GetDataAsBytes()); SendToAllExcept(combo.Manager, forward); } break; @@ -952,12 +999,12 @@ case MessageType.ForwardKeyboardEvent: if (_mode == IRServerMode.RelayMode) { - IrssMessage forward = new IrssMessage(MessageType.ForwardKeyboardEvent, MessageFlags.Request, combo.Message.DataAsBytes); + IrssMessage forward = new IrssMessage(MessageType.ForwardKeyboardEvent, MessageFlags.Request, combo.Message.GetDataAsBytes()); _client.Send(forward); } else { - IrssMessage forward = new IrssMessage(MessageType.KeyboardEvent, MessageFlags.Notify, combo.Message.DataAsBytes); + IrssMessage forward = new IrssMessage(MessageType.KeyboardEvent, MessageFlags.Notify, combo.Message.GetDataAsBytes()); SendToAllExcept(combo.Manager, forward); } break; @@ -965,12 +1012,12 @@ case MessageType.ForwardMouseEvent: if (_mode == IRServerMode.RelayMode) { - IrssMessage forward = new IrssMessage(MessageType.ForwardMouseEvent, MessageFlags.Request, combo.Message.DataAsBytes); + IrssMessage forward = new IrssMessage(MessageType.ForwardMouseEvent, MessageFlags.Request, combo.Message.GetDataAsBytes()); _client.Send(forward); } else { - IrssMessage forward = new IrssMessage(MessageType.MouseEvent, MessageFlags.Notify, combo.Message.DataAsBytes); + IrssMessage forward = new IrssMessage(MessageType.MouseEvent, MessageFlags.Notify, combo.Message.GetDataAsBytes()); SendToAllExcept(combo.Manager, forward); } break; @@ -988,7 +1035,7 @@ if (_registeredRepeaters.Count > 0) SendToRepeaters(combo.Message); - if (BlastIR(combo.Message.DataAsBytes)) + if (BlastIR(combo.Message.GetDataAsBytes())) response.Flags |= MessageFlags.Success; else response.Flags |= MessageFlags.Failure; @@ -1018,7 +1065,7 @@ { case LearnStatus.Success: response.Flags |= MessageFlags.Success; - response.DataAsBytes = bytes; + response.SetDataAsBytes(bytes); break; case LearnStatus.Failure: @@ -1063,7 +1110,7 @@ irServerInfo.Ports = (_pluginTransmit as ITransmitIR).AvailablePorts; } - response.DataAsBytes = irServerInfo.ToBytes(); + response.SetDataAsBytes(irServerInfo.ToBytes()); response.Flags |= MessageFlags.Success; } else Modified: trunk/plugins/IR Server Suite/Applications/IR Server/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/IR Server/Program.cs 2007-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/Applications/IR Server/Program.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -26,11 +26,18 @@ if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length != 1) return; } +#if TRACE catch (Exception ex) { - Trace.WriteLine(ex.Message); + Trace.WriteLine(ex.ToString()); return; } +#else + catch + { + return; + } +#endif Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); @@ -42,10 +49,11 @@ Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); // Start Server - IRServer irServer = new IRServer(); - - if (irServer.Start()) - Application.Run(); + using (IRServer irServer = new IRServer()) + { + if (irServer.Start()) + Application.Run(); + } Application.ThreadException -= new ThreadExceptionEventHandler(Application_ThreadException); @@ -108,11 +116,18 @@ return plugins.ToArray(); } +#if TRACE catch (Exception ex) { Trace.WriteLine(ex.ToString()); return null; } +#else + catch + { + return null; + } +#endif } /// <summary> Modified: trunk/plugins/IR Server Suite/Applications/Translator/Forms/GetKeyCodeForm.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Translator/Forms/GetKeyCodeForm.cs 2007-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/Applications/Translator/Forms/GetKeyCodeForm.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -61,7 +61,7 @@ { if (received.Type == MessageType.RemoteEvent) { - _keyCode = received.DataAsString; + _keyCode = received.GetDataAsString(); this.Invoke(_keyCodeSet); } Modified: trunk/plugins/IR Server Suite/Applications/Translator/Forms/MainForm.Designer.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Translator/Forms/MainForm.Designer.cs 2007-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/Applications/Translator/Forms/MainForm.Designer.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -573,58 +573,58 @@ this.toolStripSeparator2, this.quitToolStripMenuItem}); this.configurationToolStripMenuItem.Name = "configurationToolStripMenuItem"; - this.configurationToolStripMenuItem.Size = new System.Drawing.Size(37, 20); + this.configurationToolStripMenuItem.Size = new System.Drawing.Size(35, 20); this.configurationToolStripMenuItem.Text = "&File"; // // newToolStripMenuItem // this.newToolStripMenuItem.Name = "newToolStripMenuItem"; - this.newToolStripMenuItem.Size = new System.Drawing.Size(122, 22); + this.newToolStripMenuItem.Size = new System.Drawing.Size(132, 22); this.newToolStripMenuItem.Text = "&New"; this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click); // // openToolStripMenuItem // this.openToolStripMenuItem.Name = "openToolStripMenuItem"; - this.openToolStripMenuItem.Size = new System.Drawing.Size(122, 22); + this.openToolStripMenuItem.Size = new System.Drawing.Size(132, 22); this.openToolStripMenuItem.Text = "&Open ..."; this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click); // // importToolStripMenuItem // this.importToolStripMenuItem.Name = "importToolStripMenuItem"; - this.importToolStripMenuItem.Size = new System.Drawing.Size(122, 22); + this.importToolStripMenuItem.Size = new System.Drawing.Size(132, 22); this.importToolStripMenuItem.Text = "&Import ..."; this.importToolStripMenuItem.Click += new System.EventHandler(this.importToolStripMenuItem_Click); // // exportToolStripMenuItem // this.exportToolStripMenuItem.Name = "exportToolStripMenuItem"; - this.exportToolStripMenuItem.Size = new System.Drawing.Size(122, 22); + this.exportToolStripMenuItem.Size = new System.Drawing.Size(132, 22); this.exportToolStripMenuItem.Text = "&Export ..."; this.exportToolStripMenuItem.Click += new System.EventHandler(this.exportToolStripMenuItem_Click); // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(119, 6); + this.toolStripSeparator1.Size = new System.Drawing.Size(129, 6); // // serverToolStripMenuItem // this.serverToolStripMenuItem.Name = "serverToolStripMenuItem"; - this.serverToolStripMenuItem.Size = new System.Drawing.Size(122, 22); + this.serverToolStripMenuItem.Size = new System.Drawing.Size(132, 22); this.serverToolStripMenuItem.Text = "&Server ..."; this.serverToolStripMenuItem.Click += new System.EventHandler(this.serverToolStripMenuItem_Click); // // toolStripSeparator2 // this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(119, 6); + this.toolStripSeparator2.Size = new System.Drawing.Size(129, 6); // // quitToolStripMenuItem // this.quitToolStripMenuItem.Name = "quitToolStripMenuItem"; - this.quitToolStripMenuItem.Size = new System.Drawing.Size(122, 22); + this.quitToolStripMenuItem.Size = new System.Drawing.Size(132, 22); this.quitToolStripMenuItem.Text = "&Quit"; this.quitToolStripMenuItem.Click += new System.EventHandler(this.quitToolStripMenuItem_Click); // @@ -634,20 +634,20 @@ this.translatorHelpToolStripMenuItem, this.aboutToolStripMenuItem}); this.helpToolStripMenuItem.Name = "helpToolStripMenuItem"; - this.helpToolStripMenuItem.Size = new System.Drawing.Size(44, 20); + this.helpToolStripMenuItem.Size = new System.Drawing.Size(40, 20); this.helpToolStripMenuItem.Text = "&Help"; // // translatorHelpToolStripMenuItem // this.translatorHelpToolStripMenuItem.Name = "translatorHelpToolStripMenuItem"; - this.translatorHelpToolStripMenuItem.Size = new System.Drawing.Size(122, 22); + this.translatorHelpToolStripMenuItem.Size = new System.Drawing.Size(129, 22); this.translatorHelpToolStripMenuItem.Text = "&Contents"; this.translatorHelpToolStripMenuItem.Click += new System.EventHandler(this.translatorHelpToolStripMenuItem_Click); // // aboutToolStripMenuItem // this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; - this.aboutToolStripMenuItem.Size = new System.Drawing.Size(122, 22); + this.aboutToolStripMenuItem.Size = new System.Drawing.Size(129, 22); this.aboutToolStripMenuItem.Text = "&About"; this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click); // @@ -679,6 +679,7 @@ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Translator"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing); + this.Load += new System.EventHandler(this.MainForm_Load); this.groupBoxProgram.ResumeLayout(false); this.tabControl.ResumeLayout(false); this.tabPagePrograms.ResumeLayout(false); Modified: trunk/plugins/IR Server Suite/Applications/Translator/Forms/MainForm.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Translator/Forms/MainForm.cs 2007-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/Applications/Translator/Forms/MainForm.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -86,7 +86,7 @@ #region Variables - IrssUtils.Forms.LearnIR _learnIR; + LearnIR _learnIR; #endregion Variables @@ -258,7 +258,7 @@ if (File.Exists(fileName)) { - _learnIR = new IrssUtils.Forms.LearnIR( + _learnIR = new LearnIR( new LearnIrDelegate(Program.LearnIR), new BlastIrDelegate(Program.BlastIR), Program.TransceiverInformation.Ports, @@ -317,13 +317,38 @@ } } + private void MainForm_Load(object sender, EventArgs e) + { + Program.HandleMessage += new ClientMessageSink(ReceivedMessage); + } private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { + Program.HandleMessage -= new ClientMessageSink(ReceivedMessage); + CommitEvents(); Configuration.Save(Program.Config, Program.ConfigFile); } + void ReceivedMessage(IrssMessage received) + { + if (_learnIR != null && received.Type == MessageType.LearnIR) + { + if ((received.Flags & MessageFlags.Success) == MessageFlags.Success) + { + _learnIR.LearnStatus("Learned IR successfully", true); + } + else if ((received.Flags & MessageFlags.Timeout) == MessageFlags.Timeout) + { + _learnIR.LearnStatus("Learn IR timed out", false); + } + else if ((received.Flags & MessageFlags.Failure) == MessageFlags.Failure) + { + _learnIR.LearnStatus("Learn IR failed", false); + } + } + } + protected override void WndProc(ref Message m) { try @@ -600,7 +625,7 @@ private void buttonNewIR_Click(object sender, EventArgs e) { - _learnIR = new IrssUtils.Forms.LearnIR( + _learnIR = new LearnIR( new LearnIrDelegate(Program.LearnIR), new BlastIrDelegate(Program.BlastIR), Program.TransceiverInformation.Ports); @@ -616,7 +641,7 @@ if (listBoxIR.SelectedIndex == -1) return; - _learnIR = new IrssUtils.Forms.LearnIR( + _learnIR = new LearnIR( new LearnIrDelegate(Program.LearnIR), new BlastIrDelegate(Program.BlastIR), Program.TransceiverInformation.Ports, Modified: trunk/plugins/IR Server Suite/Applications/Translator/Forms/MainForm.resx =================================================================== --- trunk/plugins/IR Server Suite/Applications/Translator/Forms/MainForm.resx 2007-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/Applications/Translator/Forms/MainForm.resx 2007-09-28 16:31:49 UTC (rev 959) @@ -120,9 +120,6 @@ <metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>17, 17</value> </metadata> - <metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> - <value>17, 17</value> - </metadata> <metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>102, 17</value> </metadata> Modified: trunk/plugins/IR Server Suite/Applications/Translator/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Translator/Program.cs 2007-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/Applications/Translator/Program.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -618,7 +618,7 @@ break; default: - throw new Exception("Unknown action: " + menuItem.Text); + throw new ArgumentException(String.Format("Unknown action: {0}", menuItem.Text), "sender"); } } catch (Exception ex) @@ -740,11 +740,11 @@ } internal static void StopClient() { - if (_client == null) - return; - - _client.Dispose(); - _client = null; + if (_client != null) + { + _client.Dispose(); + _client = null; + } } static void ReceivedMessage(IrssMessage received) @@ -756,24 +756,28 @@ switch (received.Type) { case MessageType.RemoteEvent: - RemoteHandlerCallback(received.DataAsString); + RemoteHandlerCallback(received.GetDataAsString()); break; case MessageType.KeyboardEvent: { - int vKey = BitConverter.ToInt32(received.DataAsBytes, 0); - bool keyUp = BitConverter.ToBoolean(received.DataAsBytes, 4); + byte[] dataBytes = received.GetDataAsBytes(); + int vKey = BitConverter.ToInt32(dataBytes, 0); + bool keyUp = BitConverter.ToBoolean(dataBytes, 4); + KeyboardHandlerCallback(vKey, keyUp); break; } case MessageType.MouseEvent: { - int deltaX = BitConverter.ToInt32(received.DataAsBytes, 0); - int deltaY = BitConverter.ToInt32(received.DataAsBytes, 4); - int buttons = BitConverter.ToInt32(received.DataAsBytes, 8); + byte[] dataBytes = received.GetDataAsBytes(); + int deltaX = BitConverter.ToInt32(dataBytes, 0); + int deltaY = BitConverter.ToInt32(dataBytes, 4); + int buttons = BitConverter.ToInt32(dataBytes, 8); + MouseHandlerCallback(deltaX, deltaY, buttons); break; } @@ -788,7 +792,7 @@ case MessageType.RegisterClient: if ((received.Flags & MessageFlags.Success) == MessageFlags.Success) { - _irServerInfo = IRServerInfo.FromBytes(received.DataAsBytes); + _irServerInfo = IRServerInfo.FromBytes(received.GetDataAsBytes()); _registered = true; IrssLog.Info("Registered to IR Server"); @@ -805,7 +809,7 @@ { IrssLog.Info("Learned IR Successfully"); - byte[] dataBytes = received.DataAsBytes; + byte[] dataBytes = received.GetDataAsBytes(); using (FileStream file = File.Create(_learnIRFilename)) file.Write(dataBytes, 0, dataBytes.Length); @@ -833,7 +837,7 @@ case MessageType.Error: _learnIRFilename = null; - IrssLog.Error("Received error: {0}", received.DataAsString); + IrssLog.Error("Received error: {0}", received.GetDataAsString()); break; } @@ -1027,7 +1031,7 @@ doc.Load(fileName); if (doc.DocumentElement.InnerText.Contains(Common.XmlTagBlast) && !_registered) - throw new Exception("Cannot process Macro with Blast commands when not registered to an active IR Server"); + throw new ApplicationException("Cannot process Macro with Blast commands when not registered to an active IR Server"); XmlNodeList commandSequence = doc.DocumentElement.SelectNodes("action"); string commandProperty; @@ -1171,7 +1175,7 @@ internal static void BlastIR(string fileName, string port) { if (!_registered) - throw new Exception("Cannot Blast, not registered to an active IR Server"); + throw new ApplicationException("Cannot Blast, not registered to an active IR Server"); using (FileStream file = File.OpenRead(fileName)) { Modified: trunk/plugins/IR Server Suite/Applications/Tray Launcher/GetKeyCodeForm.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Tray Launcher/GetKeyCodeForm.cs 2007-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/Applications/Tray Launcher/GetKeyCodeForm.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -60,7 +60,7 @@ { if (received.Type == MessageType.RemoteEvent) { - _keyCode = received.DataAsString; + _keyCode = received.GetDataAsString(); this.Invoke(_keyCodeSet); } Modified: trunk/plugins/IR Server Suite/Applications/Tray Launcher/Tray.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Tray Launcher/Tray.cs 2007-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/Applications/Tray Launcher/Tray.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -323,7 +323,7 @@ break; case MessageType.RemoteEvent: - RemoteHandlerCallback(received.DataAsString); + RemoteHandlerCallback(received.GetDataAsString()); break; case MessageType.ServerShutdown: @@ -332,7 +332,7 @@ break; case MessageType.Error: - IrssLog.Error("Received error: {0}", received.DataAsString); + IrssLog.Error("Received error: {0}", received.GetDataAsString()); break; } Modified: trunk/plugins/IR Server Suite/Applications/Virtual Remote/MainForm.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Virtual Remote/MainForm.cs 2007-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/Applications/Virtual Remote/MainForm.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -176,7 +176,7 @@ Program.RemoteSkin = skin; } else - throw new Exception(String.Format("Failed to load skin file not found \"{0}\"", xmlFile)); + throw new FileNotFoundException("Failed to load skin, file not found", xmlFile); } catch (Exception ex) { Modified: trunk/plugins/IR Server Suite/Applications/Virtual Remote/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Virtual Remote/Program.cs 2007-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/Applications/Virtual Remote/Program.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -354,7 +354,7 @@ break; case MessageType.Error: - IrssLog.Error(received.DataAsString); + IrssLog.Error(received.GetDataAsString()); break; } } 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-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/Applications/Virtual Remote Skin Editor/MainForm.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -581,7 +581,7 @@ { case MessageType.RemoteEvent: if (listViewButtons.SelectedItems.Count == 1) - listViewButtons.SelectedItems[0].SubItems[1].Text = received.DataAsString; + listViewButtons.SelectedItems[0].SubItems[1].Text = received.GetDataAsString(); return; case MessageType.RegisterClient: @@ -603,7 +603,7 @@ return; case MessageType.Error: - MessageBox.Show(this, received.DataAsString, "Virtual Remote Skin Editor Error from Server", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(this, received.GetDataAsString(), "Virtual Remote Skin Editor Error from Server", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } Modified: trunk/plugins/IR Server Suite/Common/IrssComms/Client.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssComms/Client.cs 2007-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/Common/IrssComms/Client.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -25,8 +25,8 @@ #region Variables - IPEndPoint _serverEndPoint; - Socket _serverSocket = null; + IPEndPoint _serverEndpoint; + Socket _serverSocket; volatile bool _processConnectionThread = false; volatile bool _connected = false; @@ -35,9 +35,9 @@ ClientMessageSink _messageSink; - WaitCallback _connectCallback = null; - WaitCallback _disconnectCallback = null; - WaitCallback _commsFailureCallback = null; + WaitCallback _connectCallback; + WaitCallback _disconnectCallback; + WaitCallback _commsFailureCallback; #endregion Variables @@ -88,7 +88,7 @@ /// <param name="serverEndPoint">IP Address and Port combination of Server.</param> public Client(IPEndPoint serverEndPoint, ClientMessageSink messageSink) { - _serverEndPoint = serverEndPoint; + _serverEndpoint = serverEndPoint; _messageSink = messageSink; @@ -105,13 +105,12 @@ GC.SuppressFinalize(this); } - protected virtual void Dispose(bool disposing) + protected virtual void Dispose(bool disposeManagedResources) { - if (disposing) + if (disposeManagedResources) { // Dispose managed resources ... - if (_processConnectionThread) - Stop(); + Stop(); _messageQueue.Dispose(); } @@ -238,7 +237,7 @@ { try { - _serverSocket.Connect(_serverEndPoint); + _serverSocket.Connect(_serverEndpoint); break; } catch (SocketException socketException) @@ -290,8 +289,8 @@ // Read data from socket ... while (_processConnectionThread) { - bytesRead = _serverSocket.Receive(buffer, 4, SocketFlags.None); - if (bytesRead == 0) + bytesRead = _serverSocket.Receive(buffer, buffer.Length, SocketFlags.None); + if (bytesRead != buffer.Length) break; int readSize = BitConverter.ToInt32(buffer, 0); @@ -299,12 +298,11 @@ byte[] packet = new byte[readSize]; - bytesRead = _serverSocket.Receive(packet, readSize, SocketFlags.None); - if (bytesRead == 0) + bytesRead = _serverSocket.Receive(packet, packet.Length, SocketFlags.None); + if (bytesRead != packet.Length) break; IrssMessage message = IrssMessage.FromBytes(packet); - _messageQueue.Enqueue(message); } Modified: trunk/plugins/IR Server Suite/Common/IrssComms/ClientManager.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssComms/ClientManager.cs 2007-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/Common/IrssComms/ClientManager.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -12,7 +12,7 @@ /// <summary> /// Manages Server socket connections. /// </summary> - public class ClientManager + public class ClientManager : IDisposable { #region Variables @@ -36,6 +36,28 @@ #endregion Constructor + #region IDisposable + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposeManagedResources) + { + if (disposeManagedResources) + { + // Dispose managed resources ... + Stop(); + } + + // Free native resources ... + + } + + #endregion IDisposable + #region Implementation internal void Start() @@ -59,6 +81,7 @@ _processReceiveThread = false; _connection.Close(); + _connection = null; //_receiveThread.Abort(); //_receiveThread.Join(); @@ -89,8 +112,8 @@ while (_processReceiveThread) { - bytesRead = _connection.Receive(buffer, 4, SocketFlags.None); - if (bytesRead == 0) + bytesRead = _connection.Receive(buffer, buffer.Length, SocketFlags.None); + if (bytesRead != buffer.Length) break; // TODO: Inform server to remove clientmanager from list? (Low) int readSize = BitConverter.ToInt32(buffer, 0); @@ -98,8 +121,8 @@ byte[] packet = new byte[readSize]; - bytesRead = _connection.Receive(packet, readSize, SocketFlags.None); - if (bytesRead == 0) + bytesRead = _connection.Receive(packet, packet.Length, SocketFlags.None); + if (bytesRead != packet.Length) break; IrssMessage message = IrssMessage.FromBytes(packet); @@ -107,10 +130,16 @@ _messageSink(combo); } } +#if TRACE catch (SocketException socketException) { Trace.WriteLine(socketException.ToString()); } +#else + catch (SocketException) + { + } +#endif } #endregion Implementation Modified: trunk/plugins/IR Server Suite/Common/IrssComms/GenericPCQueue.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssComms/GenericPCQueue.cs 2007-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/Common/IrssComms/GenericPCQueue.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -66,13 +66,12 @@ GC.SuppressFinalize(this); } - protected virtual void Dispose(bool disposing) + protected virtual void Dispose(bool disposeManagedResources) { - if (disposing) + if (disposeManagedResources) { // Dispose managed resources ... - if (_processQueue) - Stop(); + Stop(); _workerThread = null; @@ -82,6 +81,7 @@ _queueLock = null; _queueWaitHandle.Close(); + _queueWaitHandle = null; } // Free native resources ... @@ -142,9 +142,11 @@ throw new ArgumentNullException("obj"); lock (_queueLock) + { _queue.Enqueue(obj); - _queueWaitHandle.Set(); + _queueWaitHandle.Set(); + } } /// <summary> @@ -166,12 +168,10 @@ try { T obj = default(T); - bool didDequeue; + bool didDequeue = false; while (_processQueue) { - didDequeue = false; - lock (_queueLock) { if (_queue.Count > 0) @@ -182,15 +182,27 @@ } if (didDequeue) + { _sink(obj); + obj = default(T); + didDequeue = false; + } else + { _queueWaitHandle.WaitOne(); + } } } +#if TRACE catch (ThreadAbortException threadAbortException) { Trace.WriteLine(threadAbortException.ToString()); } +#else + catch (ThreadAbortException) + { + } +#endif } #endregion Implementation Modified: trunk/plugins/IR Server Suite/Common/IrssComms/IrssMessage.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssComms/IrssMessage.cs 2007-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/Common/IrssComms/IrssMessage.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -93,36 +93,6 @@ set { _flags = value; } } - /// <summary> - /// Message data as bytes. - /// </summary> - public byte[] DataAsBytes - { - get { return _data; } - set { _data = value; } - } - - /// <summary> - /// Message data as string. - /// </summary> - public string DataAsString - { - get - { - if (_data == null) - return String.Empty; - else - return Encoding.ASCII.GetString(_data); - } - set - { - if (String.IsNullOrEmpty(value)) - _data = null; - else - _data = Encoding.ASCII.GetBytes(value); - } - } - #endregion Properties #region Constructors @@ -144,13 +114,13 @@ public IrssMessage(MessageType type, MessageFlags flags, byte[] data) : this(type, flags) { - _data = data; + SetDataAsBytes(data); } public IrssMessage(MessageType type, MessageFlags flags, string data) : this(type, flags) { - _data = Encoding.ASCII.GetBytes(data); + SetDataAsString(data); } #endregion Constructors @@ -158,6 +128,47 @@ #region Implementation /// <summary> + /// Get message data as bytes. + /// </summary> + public byte[] GetDataAsBytes() + { + return _data; + } + + /// <summary> + /// Set message data as bytes. + /// </summary> + public void SetDataAsBytes(byte[] data) + { + if (data == null) + _data = null; + else + _data = (byte[])data.Clone(); + } + + /// <summary> + /// Get message data as string. + /// </summary> + public string GetDataAsString() + { + if (_data == null) + return String.Empty; + else + return Encoding.ASCII.GetString(_data); + } + + /// <summary> + /// Set message data as string. + /// </summary> + public void SetDataAsString(string data) + { + if (String.IsNullOrEmpty(data)) + _data = null; + else + _data = Encoding.ASCII.GetBytes(data); + } + + /// <summary> /// Turn this Message instance into a byte array. /// </summary> /// <returns>Byte array representation of this Message instance.</returns> Modified: trunk/plugins/IR Server Suite/Common/IrssComms/MessageManagerCombo.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssComms/MessageManagerCombo.cs 2007-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/Common/IrssComms/MessageManagerCombo.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -6,7 +6,7 @@ /// <summary> /// Encapsulates an IrssMessage and a ClientManager object instance for queueing. /// </summary> - public struct MessageManagerCombo : IEquatable<MessageManagerCombo> + public class MessageManagerCombo : IEquatable<MessageManagerCombo> { #region Variables @@ -53,6 +53,8 @@ #endregion Properties + #region IEquatable<MessageManagerCombo> Members + /// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> @@ -105,6 +107,8 @@ return _message.GetHashCode() + _manager.GetHashCode(); } + #endregion + } } Modified: trunk/plugins/IR Server Suite/Common/IrssComms/Server.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssComms/Server.cs 2007-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/Common/IrssComms/Server.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -81,13 +81,12 @@ GC.SuppressFinalize(this); } - protected virtual void Dispose(bool disposing) + protected virtual void Dispose(bool disposeManagedResources) { - if (disposing) + if (disposeManagedResources) { // Dispose managed resources ... - if (_processConnectionThread) - Stop(); + Stop(); _messageQueue.Dispose(); } @@ -177,7 +176,7 @@ lock (_clientManagers) { foreach (ClientManager manager in _clientManagers) - manager.Stop(); + manager.Dispose(); _clientManagers.Clear(); _clientManagers = null; @@ -239,10 +238,16 @@ manager.Start(); } } +#if TRACE catch (SocketException socketException) { - Trace.Write(socketException.ToString()); + Trace.WriteLine(socketException.ToString()); } +#else + catch (SocketException) + { + } +#endif } #endregion Implementation Modified: trunk/plugins/IR Server Suite/Common/IrssUtils/Common.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssUtils/Common.cs 2007-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/Common/IrssUtils/Common.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -193,6 +193,8 @@ #region Command Segments + public static readonly char[] SegmentSeparator = new char[] { '|' }; + public const int SegmentsBlastCommand = 2; public const int SegmentsRunCommand = 8; public const int SegmentsSerialCommand = 7; @@ -273,7 +275,7 @@ if (String.IsNullOrEmpty(command)) throw new ArgumentNullException("command"); - string[] commands = command.Split(new char[] { '|' }, StringSplitOptions.None); + string[] commands = command.Split(SegmentSeparator, StringSplitOptions.None); if (commands.Length != elements) throw new ArgumentException(String.Format("Command structure is invalid: {0}", command), "command"); @@ -291,6 +293,9 @@ /// <param name="command">An array of arguments for the method (the output of SplitRunCommand).</param> public static void ProcessRunCommand(string[] commands) { + if (commands == null) + throw new ArgumentNullException("commands"); + Process process = new Process(); process.StartInfo.FileName = commands[0]; process.StartInfo.WorkingDirectory = commands[1]; @@ -333,6 +338,9 @@ /// <param name="commands">An array of arguments for the method (the output of SplitSerialCommand).</param> public static void ProcessSerialCommand(string[] commands) { + if (commands == null) + throw new ArgumentNullException("commands"); + string command = Common.ReplaceEscapeCodes(commands[0]); string comPort = commands[1]; @@ -369,6 +377,9 @@ /// <param name="commands">An array of arguments for the method (the output of SplitWindowMessageCommand).</param> public static void ProcessWindowMessageCommand(string[] commands) { + if (commands == null) + throw new ArgumentNullException("commands"); + IntPtr windowHandle = IntPtr.Zero; string matchType = commands[0].ToLowerInvariant(); @@ -425,6 +436,9 @@ /// <param name="command">The keystrokes to send.</param> public static void ProcessKeyCommand(string command) { + if (String.IsNullOrEmpty(command)) + throw new ArgumentNullException("command"); + SendKeys.SendWait(command); } @@ -434,6 +448,9 @@ /// <param name="commands">An array of arguments for the method (the output of SplitTcpMessageCommand).</param> public static void ProcessTcpMessageCommand(string[] commands) { + if (commands == null) + throw new ArgumentNullException("commands"); + using (TcpClient tcpClient = new TcpClient()) { tcpClient.Connect(commands[0], int.Parse(commands[1])); @@ -457,6 +474,9 @@ /// <param name="command">The Mouse Command string.</param> public static void ProcessMouseCommand(string command) { + if (String.IsNullOrEmpty(command)) + throw new ArgumentNullException("command"); + switch (command) { case MouseClickLeft: @@ -503,6 +523,9 @@ /// <param name="command">The drive letter of the CD-ROM drive to eject the tray on.</param> public static void ProcessEjectCommand(string command) { + if (String.IsNullOrEmpty(command)) + throw new ArgumentNullException("command"); + if (CDRom.IsCDRom(command)) CDRom.Open(command); } Modified: trunk/plugins/IR Server Suite/Common/IrssUtils/IrssLog.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssUtils/IrssLog.cs 2007-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/Common/IrssUtils/IrssLog.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -70,10 +70,16 @@ File.Move(fileName, backup); } +#if TRACE catch (Exception ex) { - Trace.WriteLine(ex.Message); + Trace.WriteLine(ex.ToString()); } +#else + catch + { + } +#endif } try @@ -84,10 +90,16 @@ string message = DateTime.Now.ToString() + ":\tLog Opened"; _streamWriter.WriteLine(message); } +#if TRACE catch (Exception ex) { - Trace.WriteLine(ex.Message); + Trace.WriteLine(ex.ToString()); } +#else + catch + { + } +#endif } } @@ -109,12 +121,18 @@ File.Delete(backup); File.Move(fileName, backup); - } + } } +#if TRACE catch (Exception ex) { - Trace.WriteLine(ex.Message); + Trace.WriteLine(ex.ToString()); } +#else + catch + { + } +#endif try { @@ -124,10 +142,16 @@ string message = DateTime.Now.ToString() + ":\tLog Opened"; _streamWriter.WriteLine(message); } +#if TRACE catch (Exception ex) { - Trace.WriteLine(ex.Message); + Trace.WriteLine(ex.ToString()); } +#else + catch + { + } +#endif } } Modified: trunk/plugins/IR Server Suite/Common/IrssUtils/SystemRegistry.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssUtils/SystemRegistry.cs 2007-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/Common/IrssUtils/SystemRegistry.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -17,6 +17,8 @@ #endregion Constants + #region Methods + /// <summary> /// Get the install folder for IR Server Suite. /// </summary> @@ -37,6 +39,9 @@ /// <returns>If key of name exists return true else return false.</returns> public static bool GetAutoRun(string name) { + if (String.IsNullOrEmpty(name)) + throw new ArgumentNullException("name"); + RegistryKey key = Registry.CurrentUser.CreateSubKey(AutoRunPath); bool autoRun = (key.GetValue(name, null) != null); key.Close(); @@ -51,6 +56,12 @@ /// <param name="executablePath">Executable Path for program.</param> public static void SetAutoRun(string name, string executablePath) { + if (String.IsNullOrEmpty(name)) + throw new ArgumentNullException("name"); + + if (String.IsNullOrEmpty(executablePath)) + throw new ArgumentNullException("executablePath"); + RegistryKey key = Registry.CurrentUser.CreateSubKey(AutoRunPath); key.SetValue(name, executablePath, RegistryValueKind.String); key.Close(); @@ -62,11 +73,16 @@ /// <param name="name">Auto-run program name.</param> public static void RemoveAutoRun(string name) { + if (String.IsNullOrEmpty(name)) + throw new ArgumentNullException("name"); + RegistryKey key = Registry.CurrentUser.CreateSubKey(AutoRunPath); key.DeleteValue(name, false); key.Close(); } - + + #endregion Methods + } } Modified: trunk/plugins/IR Server Suite/Common/IrssUtils/Win32.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssUtils/Win32.cs 2007-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/Common/IrssUtils/Win32.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -364,6 +364,12 @@ #region Delegates + /// <summary> + /// Delegate for enumerating open Windows with EnumWindows method. + /// </summary> + /// <param name="hWnd">Window Handle.</param> + /// <param name="lParam">lParam.</param> + /// <returns>Success.</returns> public delegate bool EnumWindowsProc(IntPtr hWnd, int lParam); #endregion Delegates @@ -640,9 +646,9 @@ /// </summary> /// <param name="o">Object to get pointer for.</param> /// <returns>Pointer to object.</returns> - public static IntPtr VarPtr(object o) + public static IntPtr VarPtr(object obj) { - GCHandle handle = GCHandle.Alloc(o, GCHandleType.Pinned); + GCHandle handle = GCHandle.Alloc(obj, GCHandleType.Pinned); IntPtr ptr = handle.AddrOfPinnedObject(); handle.Free(); return ptr; Modified: trunk/plugins/IR Server Suite/Common/MPUtils/MPCommands.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/MPUtils/MPCommands.cs 2007-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/Common/MPUtils/MPCommands.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -27,7 +27,7 @@ { GUIDialogNotify dlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); if (dlgNotify == null) - throw new Exception("Failed to create GUIDialogNotify"); + throw new ApplicationException("Failed to create GUIDialogNotify"); dlgNotify.Reset(); dlgNotify.ClearAll(); @@ -44,6 +44,9 @@ /// <param name="useBasicHome">Use the basic home screen when home is requested.</param> public static void ProcessGoTo(string screen, bool useBasicHome) { + if (String.IsNullOrEmpty(screen)) + throw new ArgumentNullException("screen"); + int window = (int)GUIWindow.Window.WINDOW_INVALID; try @@ -66,7 +69,7 @@ } if (window == (int)GUIWindow.Window.WINDOW_INVALID) - throw new Exception(String.Format("Failed to parse Goto command window id \"{0}\"", screen)); + throw new ArgumentException(String.Format("Failed to parse Goto command window id \"{0}\"", screen), "screen"); if (window == (int)GUIWindow.Window.WINDOW_HOME && useBasicHome) window = (int)GUIWindow.Window.WINDOW_SECOND_HOME; Modified: trunk/plugins/IR Server Suite/IR Server Plugins/FusionRemote Receiver/FusionRemoteReceiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/FusionRemote Receiver/FusionRemoteReceiver.cs 2007-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/IR Server Plugins/FusionRemote Receiver/FusionRemoteReceiver.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -214,11 +214,18 @@ return true; } +#if TRACE catch (Exception ex) { - Trace.WriteLine(ex.Message); + Trace.WriteLine(ex.ToString()); return false; } +#else + catch + { + return false; + } +#endif } public override void Suspend() { @@ -261,7 +268,7 @@ string devicePath = FindDevice(hidGuid, DeviceID); if (devicePath == null) - throw new Exception("No device detected"); + throw new ApplicationException("No device detected"); SafeFileHandle deviceHandle = CreateFile(devicePath, GENERIC_READ, EFileShares.Read | EFileShares.Write, IntPtr.Zero, ECreationDisposition.OpenExisting, EFileAttributes.Overlapped, IntPtr.Zero); int lastError = Marshal.GetLastWin32Error(); @@ -381,10 +388,16 @@ if (_deviceStream != null) _deviceStream.BeginRead(_deviceBuffer, 0, _deviceBuffer.Length, new AsyncCallback(OnReadComplete), null); } +#if TRACE catch (Exception ex) { Trace.WriteLine(ex.ToString()); } +#else + catch + { + } +#endif } #endregion Implementation Modified: trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IRServerPluginInterface.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IRServerPluginInterface.cs 2007-09-28 15:23:09 UTC (rev 958) +++ trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IRServerPluginInterface.cs 2007-09-28 16:31:49 UTC (rev 959) @@ -50,6 +50,9 @@ #endregion Enumerations + /// <summary> + /// Base cla... [truncated message content] |