From: <an...@us...> - 2007-10-02 05:45:10
|
Revision: 967 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=967&view=rev Author: and-81 Date: 2007-10-01 22:45:04 -0700 (Mon, 01 Oct 2007) Log Message: ----------- Modified Paths: -------------- trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.cs trunk/plugins/IR Server Suite/Applications/IR Server/Config.Designer.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/Forms/ButtonMappingForm.cs trunk/plugins/IR Server Suite/Applications/Translator/Forms/EditProgramForm.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/Tray Launcher/Tray.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/Server.cs trunk/plugins/IR Server Suite/Common/IrssUtils/IrssLog.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/IR Server Plugin Interface.csproj 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/Configure.Designer.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/MicrosoftMceTransceiver.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/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/MediaPortal Plugins/MP Blast Zone Plugin/Forms/MacroEditor.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Blast Zone Plugin/Forms/SetupForm.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/MP Control Plugin/MappedEvent.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.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/Forms/StbSetup.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.cs trunk/plugins/MCEReplacement/Forms/MacroEditor.cs trunk/plugins/MCEReplacement/Forms/MultiMapNameBox.cs trunk/plugins/MCEReplacement/Forms/SetupForm.cs trunk/plugins/MCEReplacement/Forms/StbSetup.cs trunk/plugins/MCEReplacement/MCEReplacement.cs trunk/plugins/MCEReplacement/MappedEvent.cs Added Paths: ----------- trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IConfigure.cs trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IKeyboardReceiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/ILearnIR.cs trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IMouseReceiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IRServerPluginBase.cs trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IRemoteReceiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/ITransmitIR.cs Removed Paths: ------------- trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IRServerPluginInterface.cs Modified: trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.cs 2007-10-01 13:08:52 UTC (rev 966) +++ trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.cs 2007-10-02 05:45:04 UTC (rev 967) @@ -177,6 +177,9 @@ comboBoxPort.Items.Clear(); comboBoxPort.Items.AddRange(_irServerInfo.Ports); comboBoxPort.SelectedIndex = 0; + + _client.Send(new IrssMessage(MessageType.ActiveReceivers, MessageFlags.Request)); + _client.Send(new IrssMessage(MessageType.ActiveBlasters, MessageFlags.Request)); } else if ((received.Flags & MessageFlags.Failure) == MessageFlags.Failure) { @@ -184,6 +187,14 @@ } return; + case MessageType.ActiveBlasters: + this.Invoke(_addStatusLine, new Object[] { received.GetDataAsString() }); + break; + + case MessageType.ActiveReceivers: + this.Invoke(_addStatusLine, new Object[] { received.GetDataAsString() }); + break; + case MessageType.RemoteEvent: RemoteHandlerCallback(received.GetDataAsString()); return; @@ -521,6 +532,7 @@ private void buttonAutoTest_Click(object sender, EventArgs e) { AutoTest = new Thread(new ThreadStart(AutoTestThread)); + AutoTest.Name = "DebugClient.AutoTest"; AutoTest.IsBackground = true; AutoTest.Start(); } Modified: trunk/plugins/IR Server Suite/Applications/IR Server/Config.Designer.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/IR Server/Config.Designer.cs 2007-10-01 13:08:52 UTC (rev 966) +++ trunk/plugins/IR Server Suite/Applications/IR Server/Config.Designer.cs 2007-10-02 05:45:04 UTC (rev 967) @@ -34,20 +34,21 @@ this.buttonCancel = new System.Windows.Forms.Button(); this.toolTips = new System.Windows.Forms.ToolTip(this.components); this.checkBoxRunAtBoot = new System.Windows.Forms.CheckBox(); + this.buttonAdvanced = new System.Windows.Forms.Button(); + this.buttonDetect = new System.Windows.Forms.Button(); this.groupBoxTransceiver = new System.Windows.Forms.GroupBox(); this.gridPlugins = new SourceGrid.Grid(); this.buttonHelp = new System.Windows.Forms.Button(); - this.buttonAdvanced = new System.Windows.Forms.Button(); this.groupBoxTransceiver.SuspendLayout(); this.SuspendLayout(); // // buttonOK // this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.Location = new System.Drawing.Point(352, 280); + this.buttonOK.Location = new System.Drawing.Point(352, 304); this.buttonOK.Name = "buttonOK"; this.buttonOK.Size = new System.Drawing.Size(64, 24); - this.buttonOK.TabIndex = 4; + this.buttonOK.TabIndex = 5; this.buttonOK.Text = "OK"; this.buttonOK.UseVisualStyleBackColor = true; this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); @@ -56,26 +57,50 @@ // this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(424, 280); + this.buttonCancel.Location = new System.Drawing.Point(424, 304); this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Size = new System.Drawing.Size(64, 24); - this.buttonCancel.TabIndex = 5; + this.buttonCancel.TabIndex = 6; this.buttonCancel.Text = "Cancel"; this.buttonCancel.UseVisualStyleBackColor = true; this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); // // checkBoxRunAtBoot // - this.checkBoxRunAtBoot.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.checkBoxRunAtBoot.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.checkBoxRunAtBoot.AutoSize = true; - this.checkBoxRunAtBoot.Location = new System.Drawing.Point(168, 288); + this.checkBoxRunAtBoot.Location = new System.Drawing.Point(8, 272); this.checkBoxRunAtBoot.Name = "checkBoxRunAtBoot"; this.checkBoxRunAtBoot.Size = new System.Drawing.Size(165, 17); - this.checkBoxRunAtBoot.TabIndex = 3; + this.checkBoxRunAtBoot.TabIndex = 1; this.checkBoxRunAtBoot.Text = "&Start IR Server with Windows"; this.toolTips.SetToolTip(this.checkBoxRunAtBoot, "Run IR Server when windows boots up?"); this.checkBoxRunAtBoot.UseVisualStyleBackColor = true; // + // buttonAdvanced + // + this.buttonAdvanced.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonAdvanced.Location = new System.Drawing.Point(80, 304); + this.buttonAdvanced.Name = "buttonAdvanced"; + this.buttonAdvanced.Size = new System.Drawing.Size(64, 24); + this.buttonAdvanced.TabIndex = 3; + this.buttonAdvanced.Text = "Advanced"; + this.toolTips.SetToolTip(this.buttonAdvanced, "Click here for advanced options"); + this.buttonAdvanced.UseVisualStyleBackColor = true; + this.buttonAdvanced.Click += new System.EventHandler(this.buttonAdvanced_Click); + // + // buttonDetect + // + this.buttonDetect.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.buttonDetect.Location = new System.Drawing.Point(216, 304); + this.buttonDetect.Name = "buttonDetect"; + this.buttonDetect.Size = new System.Drawing.Size(80, 24); + this.buttonDetect.TabIndex = 4; + this.buttonDetect.Text = "Auto-Detect"; + this.toolTips.SetToolTip(this.buttonDetect, "Click here to automatically detect attached devices"); + this.buttonDetect.UseVisualStyleBackColor = true; + this.buttonDetect.Click += new System.EventHandler(this.buttonDetect_Click); + // // groupBoxTransceiver // this.groupBoxTransceiver.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -108,31 +133,20 @@ // buttonHelp // this.buttonHelp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonHelp.Location = new System.Drawing.Point(8, 280); + this.buttonHelp.Location = new System.Drawing.Point(8, 304); this.buttonHelp.Name = "buttonHelp"; this.buttonHelp.Size = new System.Drawing.Size(64, 24); - this.buttonHelp.TabIndex = 1; + this.buttonHelp.TabIndex = 2; this.buttonHelp.Text = "Help"; this.buttonHelp.UseVisualStyleBackColor = true; this.buttonHelp.Click += new System.EventHandler(this.buttonHelp_Click); // - // buttonAdvanced - // - this.buttonAdvanced.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonAdvanced.Location = new System.Drawing.Point(80, 280); - this.buttonAdvanced.Name = "buttonAdvanced"; - this.buttonAdvanced.Size = new System.Drawing.Size(64, 24); - this.buttonAdvanced.TabIndex = 2; - this.buttonAdvanced.Text = "Advanced"; - this.toolTips.SetToolTip(this.buttonAdvanced, "Click here for advanced options"); - this.buttonAdvanced.UseVisualStyleBackColor = true; - this.buttonAdvanced.Click += new System.EventHandler(this.buttonAdvanced_Click); - // // Config // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(496, 319); + this.ClientSize = new System.Drawing.Size(496, 343); + this.Controls.Add(this.buttonDetect); this.Controls.Add(this.buttonAdvanced); this.Controls.Add(this.buttonHelp); this.Controls.Add(this.checkBoxRunAtBoot); @@ -140,7 +154,7 @@ this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonOK); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MinimumSize = new System.Drawing.Size(504, 346); + this.MinimumSize = new System.Drawing.Size(504, 370); this.Name = "Config"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "IR Server - Configuration"; @@ -160,5 +174,6 @@ private System.Windows.Forms.Button buttonHelp; private SourceGrid.Grid gridPlugins; private System.Windows.Forms.Button buttonAdvanced; + private System.Windows.Forms.Button buttonDetect; } } \ No newline at end of file Modified: trunk/plugins/IR Server Suite/Applications/IR Server/Config.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/IR Server/Config.cs 2007-10-01 13:08:52 UTC (rev 966) +++ trunk/plugins/IR Server Suite/Applications/IR Server/Config.cs 2007-10-02 05:45:04 UTC (rev 967) @@ -20,7 +20,7 @@ #region Variables - IRServerPlugin[] _transceivers; + IRServerPluginBase[] _transceivers; IRServerMode _mode = IRServerMode.ServerMode; string _hostComputer = String.Empty; @@ -165,7 +165,7 @@ row++; - foreach (IRServerPlugin transceiver in _transceivers) + foreach (IRServerPluginBase transceiver in _transceivers) { gridPlugins.Rows.Insert(row); @@ -262,7 +262,7 @@ string plugin = gridPlugins[cell.Row.Index, 0].DisplayText; - foreach (IRServerPlugin transceiver in _transceivers) + foreach (IRServerPluginBase transceiver in _transceivers) if (transceiver.Name == plugin) (transceiver as IConfigure).Configure(); } @@ -344,6 +344,29 @@ #endregion Controls + private void buttonDetect_Click(object sender, EventArgs e) + { + SourceGrid.Cells.CheckBox checkBox; + for (int row = 1; row < gridPlugins.RowsCount; row++) + { + string name = gridPlugins[row, 0].DisplayText; + + IRServerPluginBase plugin = Program.GetPlugin(name); + + bool detected = plugin.Detect(); + + // Receive + checkBox = gridPlugins[row, 1] as SourceGrid.Cells.CheckBox; + if (checkBox != null) + checkBox.Checked = detected; + + // Transmit + checkBox = gridPlugins[row, 2] as SourceGrid.Cells.CheckBox; + if (checkBox != null) + checkBox.Checked = detected; + } + } + } } Modified: trunk/plugins/IR Server Suite/Applications/IR Server/IRServer.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/IR Server/IRServer.cs 2007-10-01 13:08:52 UTC (rev 966) +++ trunk/plugins/IR Server Suite/Applications/IR Server/IRServer.cs 2007-10-02 05:45:04 UTC (rev 967) @@ -68,10 +68,10 @@ bool _registered = false; // Used for relay and repeater modes. string[] _pluginNameReceive; - IRServerPlugin[] _pluginReceive; + IRServerPluginBase[] _pluginReceive; string _pluginNameTransmit; - IRServerPlugin _pluginTransmit; + IRServerPluginBase _pluginTransmit; bool _inConfiguration = false; @@ -159,13 +159,13 @@ } else { - List<IRServerPlugin> plugins = new List<IRServerPlugin>(_pluginNameReceive.Length); + List<IRServerPluginBase> plugins = new List<IRServerPluginBase>(_pluginNameReceive.Length); for (int index = 0; index < _pluginNameReceive.Length; index++) { string pluginName = _pluginNameReceive[index]; - IRServerPlugin plugin = Program.GetPlugin(pluginName); + IRServerPluginBase plugin = Program.GetPlugin(pluginName); if (plugin == null) { @@ -222,7 +222,7 @@ if (_pluginReceive != null) { - foreach (IRServerPlugin plugin in _pluginReceive) + foreach (IRServerPluginBase plugin in _pluginReceive) { try { @@ -316,7 +316,7 @@ if (_pluginReceive != null) { - foreach (IRServerPlugin plugin in _pluginReceive) + foreach (IRServerPluginBase plugin in _pluginReceive) { try { @@ -441,6 +441,7 @@ ServerMessageSink sink = new ServerMessageSink(ServerReceivedMessage); _server = new Server(Server.DefaultPort, sink); + _server.ClientDisconnectCallback = new WaitCallback(ClientDisconnect); _server.Start(); } @@ -495,6 +496,17 @@ Thread.Sleep(1000); } + void ClientDisconnect(object obj) + { + ClientManager clientManager = obj as ClientManager; + + if (clientManager != null) + { + UnregisterClient(clientManager); + UnregisterRepeater(clientManager); + } + } + bool StartClient(IPEndPoint endPoint) { if (_client != null) @@ -704,7 +716,7 @@ if (_pluginReceive != null) { - foreach (IRServerPlugin plugin in _pluginReceive) + foreach (IRServerPluginBase plugin in _pluginReceive) { if (_pluginTransmit == plugin) resumedTransmit = true; @@ -733,7 +745,7 @@ if (_pluginReceive != null) { - foreach (IRServerPlugin plugin in _pluginReceive) + foreach (IRServerPluginBase plugin in _pluginReceive) { if (_pluginTransmit == plugin) suspendedTransmit = true; @@ -987,6 +999,8 @@ { switch (combo.Message.Type) { + + #region ForwardRemoteEvent case MessageType.ForwardRemoteEvent: if (_mode == IRServerMode.RelayMode) { @@ -999,7 +1013,9 @@ SendToAllExcept(combo.Manager, forward); } break; + #endregion ForwardRemoteEvent + #region ForwardKeyboardEvent case MessageType.ForwardKeyboardEvent: if (_mode == IRServerMode.RelayMode) { @@ -1012,7 +1028,9 @@ SendToAllExcept(combo.Manager, forward); } break; + #endregion ForwardKeyboardEvent + #region ForwardMouseEvent case MessageType.ForwardMouseEvent: if (_mode == IRServerMode.RelayMode) { @@ -1025,7 +1043,9 @@ SendToAllExcept(combo.Manager, forward); } break; + #endregion ForwardMouseEvent + #region BlastIR case MessageType.BlastIR: { IrssMessage response = new IrssMessage(MessageType.BlastIR, MessageFlags.Response); @@ -1050,7 +1070,9 @@ break; } + #endregion BlastIR + #region LearnIR case MessageType.LearnIR: { IrssMessage response = new IrssMessage(MessageType.LearnIR, MessageFlags.Response); @@ -1085,7 +1107,9 @@ SendTo(combo.Manager, response); break; } + #endregion LearnIR + #region ServerShutdown case MessageType.ServerShutdown: if ((combo.Message.Flags & MessageFlags.Request) == MessageFlags.Request) { @@ -1093,9 +1117,10 @@ Stop(); Application.Exit(); } - break; + #endregion ServerShutdown + #region RegisterClient case MessageType.RegisterClient: { IrssMessage response = new IrssMessage(MessageType.RegisterClient, MessageFlags.Response); @@ -1125,11 +1150,15 @@ SendTo(combo.Manager, response); break; } + #endregion RegisterClient + #region UnregisterClient case MessageType.UnregisterClient: UnregisterClient(combo.Manager); break; + #endregion UnregisterClient + #region RegisterRepeater case MessageType.RegisterRepeater: { IrssMessage response = new IrssMessage(MessageType.RegisterRepeater, MessageFlags.Response); @@ -1142,10 +1171,179 @@ SendTo(combo.Manager, response); break; } + #endregion RegisterRepeater + #region UnregisterRepeater case MessageType.UnregisterRepeater: UnregisterRepeater(combo.Manager); break; + #endregion UnregisterRepeater + + #region ActiveBlasters + case MessageType.ActiveBlasters: + { + IrssMessage response = new IrssMessage(MessageType.ActiveBlasters, MessageFlags.Response); + response.SetDataAsString(_pluginNameTransmit); + + SendTo(combo.Manager, response); + break; + } + #endregion ActiveBlasters + + #region ActiveReceivers + case MessageType.ActiveReceivers: + { + IrssMessage response = new IrssMessage(MessageType.ActiveReceivers, MessageFlags.Response); + + 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(','); + } + + response.SetDataAsString(receivers.ToString()); + } + else + { + response.SetDataAsString(null); + } + + SendTo(combo.Manager, response); + break; + } + #endregion ActiveReceivers + + #region AvailableBlasters + case MessageType.AvailableBlasters: + { + IrssMessage response = new IrssMessage(MessageType.AvailableBlasters, MessageFlags.Response); + + IRServerPluginBase[] plugins = Program.AvailablePlugins(); + StringBuilder blasters = new StringBuilder(); + + for (int index = 0; index < plugins.Length; index++) + { + IRServerPluginBase plugin = plugins[index]; + + if (plugin is ITransmitIR) + { + blasters.Append(plugin.Name); + blasters.Append(','); + } + } + + if (blasters.Length == 0) + { + response.SetDataAsString(null); + } + else + { + blasters.Remove(blasters.Length - 1, 1); + response.SetDataAsString(blasters.ToString()); + } + + SendTo(combo.Manager, response); + break; + } + #endregion AvailableBlasters + + #region AvailableReceivers + case MessageType.AvailableReceivers: + { + IrssMessage response = new IrssMessage(MessageType.AvailableReceivers, MessageFlags.Response); + + IRServerPluginBase[] plugins = Program.AvailablePlugins(); + StringBuilder receivers = new StringBuilder(); + + for (int index = 0; index < plugins.Length; index++) + { + IRServerPluginBase plugin = plugins[index]; + + if (plugin is IRemoteReceiver || plugin is IKeyboardReceiver || plugin is IMouseReceiver) + { + receivers.Append(plugin.Name); + receivers.Append(','); + } + } + + if (receivers.Length == 0) + { + response.SetDataAsString(null); + } + else + { + receivers.Remove(receivers.Length - 1, 1); + response.SetDataAsString(receivers.ToString()); + } + + SendTo(combo.Manager, response); + break; + } + #endregion AvailableReceivers + + #region DetectedBlasters + case MessageType.DetectedBlasters: + { + IrssMessage response = new IrssMessage(MessageType.DetectedBlasters, MessageFlags.Response); + string[] detectedBlasters = Program.DetectBlasters(); + + if (detectedBlasters != null) + { + StringBuilder blasters = new StringBuilder(); + for (int index = 0; index < detectedBlasters.Length; index++) + { + blasters.Append(detectedBlasters[index]); + + if (index < detectedBlasters.Length - 1) + blasters.Append(','); + } + + response.SetDataAsString(blasters.ToString()); + } + else + { + response.SetDataAsString(null); + } + + SendTo(combo.Manager, response); + break; + } + #endregion DetectedBlasters + + #region DetectedReceivers + case MessageType.DetectedReceivers: + { + IrssMessage response = new IrssMessage(MessageType.DetectedReceivers, MessageFlags.Response); + string[] detectedReceivers = Program.DetectReceivers(); + + if (detectedReceivers != null) + { + StringBuilder receivers = new StringBuilder(); + for (int index = 0; index < detectedReceivers.Length; index++) + { + receivers.Append(detectedReceivers[index]); + + if (index < detectedReceivers.Length - 1) + receivers.Append(','); + } + + response.SetDataAsString(receivers.ToString()); + } + else + { + response.SetDataAsString(null); + } + + SendTo(combo.Manager, response); + break; + } + #endregion DetectedReceivers + } } catch (Exception ex) @@ -1232,6 +1430,19 @@ catch (FileNotFoundException) { IrssLog.Warn("No configuration file found ({0}), creating default configuration file", ConfigurationFile); + + string[] blasters = Program.DetectBlasters(); + if (blasters == null) + _pluginNameTransmit = String.Empty; + else + _pluginNameTransmit = blasters[0]; + + string[] receivers = Program.DetectReceivers(); + if (receivers == null) + _pluginNameReceive = null; + else + _pluginNameReceive = receivers; + SaveSettings(); return; } Modified: trunk/plugins/IR Server Suite/Applications/IR Server/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/IR Server/Program.cs 2007-10-01 13:08:52 UTC (rev 966) +++ trunk/plugins/IR Server Suite/Applications/IR Server/Program.cs 2007-10-02 05:45:04 UTC (rev 967) @@ -30,14 +30,12 @@ catch (Exception ex) { Trace.WriteLine(ex.ToString()); - return; - } #else catch { +#endif return; } -#endif Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); @@ -74,11 +72,11 @@ /// Retreives a list of available IR Server plugins. /// </summary> /// <returns>Array of plugin instances.</returns> - internal static IRServerPlugin[] AvailablePlugins() + internal static IRServerPluginBase[] AvailablePlugins() { try { - List<IRServerPlugin> plugins = new List<IRServerPlugin>(); + List<IRServerPluginBase> plugins = new List<IRServerPluginBase>(); string installFolder = SystemRegistry.GetInstallFolder(); if (String.IsNullOrEmpty(installFolder)) @@ -95,10 +93,10 @@ foreach (Type type in types) { - if (type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(IRServerPlugin))) + if (type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(IRServerPluginBase))) { - IRServerPlugin plugin = (IRServerPlugin)assembly.CreateInstance(type.FullName); - + IRServerPluginBase plugin = (IRServerPluginBase)assembly.CreateInstance(type.FullName); + if (plugin != null) plugins.Add(plugin); } @@ -108,6 +106,10 @@ { // Ignore Bad Image Format Exceptions, just keep checking for IR Server Plugins } + catch (TypeLoadException) + { + // Ignore Type Load Exceptions, just keep checking for IR Server Plugins + } catch (Exception ex) { MessageBox.Show(ex.ToString(), "IR Server Plugin Error"); @@ -119,15 +121,13 @@ #if TRACE catch (Exception ex) { - Trace.WriteLine(ex.ToString()); - return null; - } + Trace.WriteLine("IRServer: " + ex.ToString()); #else catch { +#endif return null; } -#endif } /// <summary> @@ -135,22 +135,88 @@ /// </summary> /// <param name="pluginName">Name of plugin to instantiate.</param> /// <returns>Plugin instance.</returns> - internal static IRServerPlugin GetPlugin(string pluginName) + internal static IRServerPluginBase GetPlugin(string pluginName) { if (String.IsNullOrEmpty(pluginName)) throw new ArgumentNullException("pluginName"); - IRServerPlugin[] serverPlugins = AvailablePlugins(); + IRServerPluginBase[] serverPlugins = AvailablePlugins(); if (serverPlugins == null) throw new FileNotFoundException("No available plugins found"); - foreach (IRServerPlugin plugin in serverPlugins) + foreach (IRServerPluginBase plugin in serverPlugins) if (plugin.Name.Equals(pluginName, StringComparison.InvariantCultureIgnoreCase)) return plugin; return null; } + /// <summary> + /// Retreives a list of detected Receiver plugins. + /// </summary> + /// <returns>String array of plugin names.</returns> + internal static string[] DetectReceivers() + { + try + { + IRServerPluginBase[] plugins = AvailablePlugins(); + + List<string> receivers = new List<string>(); + + foreach (IRServerPluginBase plugin in plugins) + if ((plugin is IRemoteReceiver || plugin is IKeyboardReceiver || plugin is IMouseReceiver) && plugin.Detect()) + receivers.Add(plugin.Name); + + if (receivers.Count > 0) + return receivers.ToArray(); + } +#if TRACE + catch (Exception ex) + { + Trace.WriteLine("IRServer: " + ex.ToString()); + } +#else + catch + { + } +#endif + + return null; + } + + /// <summary> + /// Retreives a list of detected Blaster plugins. + /// </summary> + /// <returns>String array of plugin names.</returns> + internal static string[] DetectBlasters() + { + try + { + IRServerPluginBase[] plugins = Program.AvailablePlugins(); + + List<string> blasters = new List<string>(); + + foreach (IRServerPluginBase plugin in plugins) + if (plugin is ITransmitIR && plugin.Detect()) + blasters.Add(plugin.Name); + + if (blasters.Count > 0) + return blasters.ToArray(); + } +#if TRACE + catch (Exception ex) + { + Trace.WriteLine("IRServer: " + ex.ToString()); + } +#else + catch + { + } +#endif + + return null; + } + } } Modified: trunk/plugins/IR Server Suite/Applications/Translator/Forms/ButtonMappingForm.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Translator/Forms/ButtonMappingForm.cs 2007-10-01 13:08:52 UTC (rev 966) +++ trunk/plugins/IR Server Suite/Applications/Translator/Forms/ButtonMappingForm.cs 2007-10-02 05:45:04 UTC (rev 967) @@ -580,7 +580,7 @@ private void buttonNewMacro_Click(object sender, EventArgs e) { - MacroEditor macroEditor = new MacroEditor(true, String.Empty); + MacroEditor macroEditor = new MacroEditor(); macroEditor.ShowDialog(this); SetupMacroList(); Modified: trunk/plugins/IR Server Suite/Applications/Translator/Forms/EditProgramForm.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Translator/Forms/EditProgramForm.cs 2007-10-01 13:08:52 UTC (rev 966) +++ trunk/plugins/IR Server Suite/Applications/Translator/Forms/EditProgramForm.cs 2007-10-02 05:45:04 UTC (rev 967) @@ -150,7 +150,7 @@ } catch (Exception ex) { - IrssLog.Error("Test Application: {0}", ex.Message); + IrssLog.Error("Test Application: {0}", ex.ToString()); } } Modified: trunk/plugins/IR Server Suite/Applications/Translator/Forms/MacroEditor.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Translator/Forms/MacroEditor.cs 2007-10-01 13:08:52 UTC (rev 966) +++ trunk/plugins/IR Server Suite/Applications/Translator/Forms/MacroEditor.cs 2007-10-02 05:45:04 UTC (rev 967) @@ -20,22 +20,38 @@ #region Constructor - public MacroEditor(bool newMacro, string name) + /// <summary> + /// Creates a Macro Editor windows form. + /// </summary> + public MacroEditor() { InitializeComponent(); + + textBoxName.Text = "New"; + textBoxName.Enabled = true; + } - textBoxName.Text = name; - textBoxName.Enabled = newMacro; + /// <summary> + /// Creates a Macro Editor windows form. + /// </summary> + /// <param name="name">The name of an existing macro.</param> + public MacroEditor(string name) + : this() + { + if (String.IsNullOrEmpty(name)) + throw new ArgumentNullException("name"); - if (!newMacro) - { - string fileName = Program.FolderMacros + name + Common.FileExtensionMacro; - ReadFromFile(fileName); - } + textBoxName.Text = name; + textBoxName.Enabled = false; + + string fileName = Program.FolderMacros + name + Common.FileExtensionMacro; + ReadFromFile(fileName); } #endregion Constructor + #region Implementation + void RefreshCommandList() { comboBoxCommands.Items.Clear(); @@ -57,6 +73,10 @@ comboBoxCommands.Items.AddRange(irList); } + /// <summary> + /// Write the macro in the listBox to a macro name provided. + /// </summary> + /// <param name="fileName">Name of Macro to write (macro name, not file path).</param> void WriteToFile(string fileName) { try @@ -150,6 +170,11 @@ IrssLog.Error(ex.ToString()); } } + + /// <summary> + /// Read a macro into the listBox from the macro name provided. + /// </summary> + /// <param name="fileName">Name of Macro to read (macro name, not file path).</param> void ReadFromFile(string fileName) { try @@ -157,6 +182,8 @@ XmlDocument doc = new XmlDocument(); doc.Load(fileName); + listBoxMacro.Items.Clear(); + XmlNodeList commandSequence = doc.DocumentElement.SelectNodes("action"); string commandProperty; @@ -237,36 +264,26 @@ if (selected == Common.UITextRun) { ExternalProgram externalProgram = new ExternalProgram(false); - - if (externalProgram.ShowDialog(this) == DialogResult.Cancel) - return; - - listBoxMacro.Items.Add(Common.CmdPrefixRun + externalProgram.CommandString); + if (externalProgram.ShowDialog(this) == DialogResult.OK) + listBoxMacro.Items.Add(Common.CmdPrefixRun + externalProgram.CommandString); } else if (selected == Common.UITextPause) { - IrssUtils.Forms.PauseTime pauseTime = new IrssUtils.Forms.PauseTime(); - - if (pauseTime.ShowDialog(this) == DialogResult.Cancel) - return; - - listBoxMacro.Items.Add(Common.CmdPrefixPause + pauseTime.Time.ToString()); + PauseTime pauseTime = new PauseTime(); + if (pauseTime.ShowDialog(this) == DialogResult.OK) + listBoxMacro.Items.Add(Common.CmdPrefixPause + pauseTime.Time.ToString()); } else if (selected == Common.UITextSerial) { SerialCommand serialCommand = new SerialCommand(); - if (serialCommand.ShowDialog(this) == DialogResult.Cancel) - return; - - listBoxMacro.Items.Add(Common.CmdPrefixSerial + serialCommand.CommandString); + if (serialCommand.ShowDialog(this) == DialogResult.OK) + listBoxMacro.Items.Add(Common.CmdPrefixSerial + serialCommand.CommandString); } else if (selected == Common.UITextWindowMsg) { MessageCommand messageCommand = new MessageCommand(); - if (messageCommand.ShowDialog(this) == DialogResult.Cancel) - return; - - listBoxMacro.Items.Add(Common.CmdPrefixWindowMsg + messageCommand.CommandString); + if (messageCommand.ShowDialog(this) == DialogResult.OK) + listBoxMacro.Items.Add(Common.CmdPrefixWindowMsg + messageCommand.CommandString); } else if (selected == Common.UITextTcpMsg) { @@ -279,18 +296,14 @@ else if (selected == Common.UITextKeys) { KeysCommand keysCommand = new KeysCommand(); - if (keysCommand.ShowDialog(this) == DialogResult.Cancel) - return; - - listBoxMacro.Items.Add(Common.CmdPrefixKeys + keysCommand.CommandString); + if (keysCommand.ShowDialog(this) == DialogResult.OK) + listBoxMacro.Items.Add(Common.CmdPrefixKeys + keysCommand.CommandString); } else if (selected == Common.UITextEject) { EjectCommand ejectCommand = new EjectCommand(); - if (ejectCommand.ShowDialog(this) == DialogResult.Cancel) - return; - - listBoxMacro.Items.Add(Common.CmdPrefixEject + ejectCommand.CommandString); + if (ejectCommand.ShowDialog(this) == DialogResult.OK) + listBoxMacro.Items.Add(Common.CmdPrefixEject + ejectCommand.CommandString); } else if (selected == Common.UITextStandby) { @@ -308,7 +321,7 @@ { listBoxMacro.Items.Add(Common.CmdPrefixShutdown); } - else + else if (selected.StartsWith(Common.CmdPrefixBlast)) { BlastCommand blastCommand = new BlastCommand( new BlastIrDelegate(Program.BlastIR), @@ -316,11 +329,13 @@ Program.TransceiverInformation.Ports, selected.Substring(Common.CmdPrefixBlast.Length)); - if (blastCommand.ShowDialog(this) == DialogResult.Cancel) - return; - - listBoxMacro.Items.Add(Common.CmdPrefixBlast + blastCommand.CommandString); + if (blastCommand.ShowDialog(this) == DialogResult.OK) + listBoxMacro.Items.Add(Common.CmdPrefixBlast + blastCommand.CommandString); } + else + { + throw new ApplicationException(String.Format("Unknown command in macro command list \"{0}\"", selected)); + } } private void buttonMoveUp_Click(object sender, EventArgs e) @@ -409,8 +424,7 @@ if (selected.StartsWith(Common.CmdPrefixPause)) { - IrssUtils.Forms.PauseTime pauseTime = new IrssUtils.Forms.PauseTime(int.Parse(selected.Substring(Common.CmdPrefixPause.Length))); - + PauseTime pauseTime = new PauseTime(int.Parse(selected.Substring(Common.CmdPrefixPause.Length))); if (pauseTime.ShowDialog(this) == DialogResult.Cancel) return; @@ -422,6 +436,7 @@ else if (selected.StartsWith(Common.CmdPrefixRun)) { string[] commands = Common.SplitRunCommand(selected.Substring(Common.CmdPrefixRun.Length)); + ExternalProgram executeProgram = new ExternalProgram(commands, false); if (executeProgram.ShowDialog(this) == DialogResult.Cancel) return; @@ -434,6 +449,7 @@ else if (selected.StartsWith(Common.CmdPrefixSerial)) { string[] commands = Common.SplitSerialCommand(selected.Substring(Common.CmdPrefixSerial.Length)); + SerialCommand serialCommand = new SerialCommand(commands); if (serialCommand.ShowDialog(this) == DialogResult.Cancel) return; @@ -446,6 +462,7 @@ else if (selected.StartsWith(Common.CmdPrefixWindowMsg)) { string[] commands = Common.SplitWindowMessageCommand(selected.Substring(Common.CmdPrefixWindowMsg.Length)); + MessageCommand messageCommand = new MessageCommand(commands); if (messageCommand.ShowDialog(this) == DialogResult.Cancel) return; @@ -509,6 +526,8 @@ } } + #endregion Implementation + } } Modified: trunk/plugins/IR Server Suite/Applications/Translator/Forms/MainForm.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Translator/Forms/MainForm.cs 2007-10-01 13:08:52 UTC (rev 966) +++ trunk/plugins/IR Server Suite/Applications/Translator/Forms/MainForm.cs 2007-10-02 05:45:04 UTC (rev 967) @@ -270,7 +270,7 @@ } else { - MessageBox.Show(this, "File not found: " + command + Common.FileExtensionIR, "File missing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + MessageBox.Show(this, "File not found: " + fileName, "IR file missing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); RefreshIRList(); } } @@ -284,12 +284,12 @@ if (File.Exists(fileName)) { - MacroEditor macroEditor = new MacroEditor(false, command); + MacroEditor macroEditor = new MacroEditor(command); macroEditor.ShowDialog(this); } else { - MessageBox.Show(this, "File not found: " + command + Common.FileExtensionMacro, "File missing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + MessageBox.Show(this, "File not found: " + fileName, "Macro file missing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); RefreshMacroList(); } } @@ -668,13 +668,13 @@ } else { - MessageBox.Show(this, "File not found: " + fileName, "File missing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + MessageBox.Show(this, "File not found: " + fileName, "IR file missing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } private void buttonNewMacro_Click(object sender, EventArgs e) { - MacroEditor macroEditor = new MacroEditor(true, String.Empty); + MacroEditor macroEditor = new MacroEditor(); macroEditor.ShowDialog(this); RefreshMacroList(); @@ -700,7 +700,7 @@ } else { - MessageBox.Show(this, "File not found: " + fileName, "File missing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + MessageBox.Show(this, "File not found: " + fileName, "Macro file missing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } private void buttonTestMacro_Click(object sender, EventArgs e) Modified: trunk/plugins/IR Server Suite/Applications/Translator/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Translator/Program.cs 2007-10-01 13:08:52 UTC (rev 966) +++ trunk/plugins/IR Server Suite/Applications/Translator/Program.cs 2007-10-02 05:45:04 UTC (rev 967) @@ -847,7 +847,7 @@ catch (Exception ex) { _learnIRFilename = null; - IrssLog.Error(ex.Message); + IrssLog.Error(ex.ToString()); } } @@ -1160,7 +1160,7 @@ catch (Exception ex) { _learnIRFilename = null; - IrssLog.Error(ex.Message); + IrssLog.Error(ex.ToString()); return false; } Modified: trunk/plugins/IR Server Suite/Applications/Tray Launcher/Tray.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Tray Launcher/Tray.cs 2007-10-01 13:08:52 UTC (rev 966) +++ trunk/plugins/IR Server Suite/Applications/Tray Launcher/Tray.cs 2007-10-02 05:45:04 UTC (rev 967) @@ -44,6 +44,8 @@ NotifyIcon _notifyIcon; + bool _inConfiguration = false; + #endregion Variables #region Properties @@ -109,12 +111,12 @@ } bool clientStarted = false; - - IPAddress serverIP = Client.GetIPFromName(_serverHost); - IPEndPoint endPoint = new IPEndPoint(serverIP, IrssComms.Server.DefaultPort); try { + IPAddress serverIP = Client.GetIPFromName(_serverHost); + IPEndPoint endPoint = new IPEndPoint(serverIP, IrssComms.Server.DefaultPort); + clientStarted = StartClient(endPoint); } catch (Exception ex) @@ -336,7 +338,6 @@ break; } - // If another module of the program has registered to receive messages too ... if (_handleMessage != null) _handleMessage(received); } @@ -384,17 +385,27 @@ { IrssLog.Info("Setup"); + _inConfiguration = true; + if (Configure()) { Stop(); Thread.Sleep(500); Start(); } + + _inConfiguration = false; } void ClickLaunch(object sender, EventArgs e) { IrssLog.Info("Launch"); + if (_inConfiguration) + { + IrssLog.Info("In Configuration"); + return; + } + try { // Check for multiple instances @@ -411,18 +422,23 @@ return; } } - catch { } + catch (Exception ex) + { + IrssLog.Error(ex.ToString()); + } } // Launch program Process launch = new Process(); launch.StartInfo.FileName = _programFile; launch.StartInfo.UseShellExecute = false; + launch.StartInfo.WindowStyle = ProcessWindowStyle.Normal; + launch.StartInfo.UseShellExecute = true; launch.Start(); } catch (Exception ex) { - IrssLog.Error(ex.Message); + IrssLog.Error(ex.ToString()); MessageBox.Show(ex.Message, "Tray Launcher", MessageBoxButtons.OK, MessageBoxIcon.Error); } } @@ -430,6 +446,12 @@ { IrssLog.Info("Quit"); + if (_inConfiguration) + { + IrssLog.Info("In Configuration"); + return; + } + Stop(); Application.Exit(); Modified: trunk/plugins/IR Server Suite/Common/IrssComms/ClientManager.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssComms/ClientManager.cs 2007-10-01 13:08:52 UTC (rev 966) +++ trunk/plugins/IR Server Suite/Common/IrssComms/ClientManager.cs 2007-10-02 05:45:04 UTC (rev 967) @@ -24,8 +24,23 @@ Socket _connection; + WaitCallback _disconnectCallback; + #endregion Variables + #region Properties + + /// <summary> + /// Gets or Sets the Disconnect callback. + /// </summary> + public WaitCallback DisconnectCallback + { + get { return _disconnectCallback; } + set { _disconnectCallback = value; } + } + + #endregion Properties + #region Constructor internal ClientManager(Socket connection, ServerMessageSink sink) @@ -80,9 +95,14 @@ _processReceiveThread = false; - _connection.Close(); - _connection = null; + if (_connection != null) + { + _connection.Close(100); + _connection = null; + } + _messageSink = null; + //_receiveThread.Abort(); //_receiveThread.Join(); _receiveThread = null; @@ -114,7 +134,7 @@ { bytesRead = _connection.Receive(buffer, buffer.Length, SocketFlags.None); if (bytesRead != buffer.Length) - break; // TODO: Inform server to remove clientmanager from list? (Low) + break; int readSize = BitConverter.ToInt32(buffer, 0); readSize = IPAddress.NetworkToHostOrder(readSize); @@ -127,7 +147,9 @@ IrssMessage message = IrssMessage.FromBytes(packet); MessageManagerCombo combo = new MessageManagerCombo(message, this); - _messageSink(combo); + + if (_messageSink != null) + _messageSink(combo); } } #if TRACE @@ -140,6 +162,16 @@ { } #endif + finally + { + if (_connection != null) + { + _connection.Close(100); + _connection = null; + } + + _disconnectCallback(this); + } } #endregion Implementation Modified: trunk/plugins/IR Server Suite/Common/IrssComms/GenericPCQueue.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssComms/GenericPCQueue.cs 2007-10-01 13:08:52 UTC (rev 966) +++ trunk/plugins/IR Server Suite/Common/IrssComms/GenericPCQueue.cs 2007-10-02 05:45:04 UTC (rev 967) @@ -104,8 +104,8 @@ // Create the worker thread ... _workerThread = new Thread(new ThreadStart(WorkerThread)); + _workerThread.Name = "IrssComms.GenericPCQueue"; _workerThread.IsBackground = true; - _workerThread.Name = "IrssComms.GenericPCQueue"; _workerThread.Start(); } Modified: trunk/plugins/IR Server Suite/Common/IrssComms/IrssMessage.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssComms/IrssMessage.cs 2007-10-01 13:08:52 UTC (rev 966) +++ trunk/plugins/IR Server Suite/Common/IrssComms/IrssMessage.cs 2007-10-02 05:45:04 UTC (rev 967) @@ -33,6 +33,13 @@ ForwardRemoteEvent, ForwardKeyboardEvent, ForwardMouseEvent, + + AvailableReceivers, + AvailableBlasters, + ActiveReceivers, + ActiveBlasters, + DetectedReceivers, + DetectedBlasters, } [Flags] Modified: trunk/plugins/IR Server Suite/Common/IrssComms/Server.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssComms/Server.cs 2007-10-01 13:08:52 UTC (rev 966) +++ trunk/plugins/IR Server Suite/Common/IrssComms/Server.cs 2007-10-02 05:45:04 UTC (rev 967) @@ -53,8 +53,23 @@ GenericPCQueue<MessageManagerCombo> _messageQueue; + WaitCallback _clientDisconnectCallback; + #endregion Variables + #region Properties + + /// <summary> + /// Gets or Sets the Client Disconnect callback. + /// </summary> + public WaitCallback ClientDisconnectCallback + { + get { return _clientDisconnectCallback; } + set { _clientDisconnectCallback = value; } + } + + #endregion Properties + #region Constructor /// <summary> @@ -148,8 +163,8 @@ catch { _processConnectionThread = false; - _serverSocket = null; - _clientManagers = null; + _serverSocket = null; + _clientManagers = null; _connectionThread = null; throw; @@ -205,7 +220,7 @@ } catch (SocketException) { - _clientManagers.Remove(sendTo); + ClientDisconnect(sendTo); return false; } } @@ -220,6 +235,25 @@ _messageSink(combo); } + void ClientDisconnect(object obj) + { + ClientManager clientManager = obj as ClientManager; + + if (clientManager != null) + { + lock (_clientManagers) + { + if (_clientManagers.Contains(clientManager)) + _clientManagers.Remove(clientManager); + } + + if (_clientDisconnectCallback != null) + _clientDisconnectCallback(clientManager); + + clientManager.Dispose(); + } + } + void ConnectionThread() { try @@ -231,6 +265,7 @@ Socket socket = _serverSocket.Accept(); ClientManager manager = new ClientManager(socket, clientManagerMessageSink); + manager.DisconnectCallback = new WaitCallback(ClientDisconnect); lock (_clientManagers) _clientManagers.Add(manager); Modified: trunk/plugins/IR Server Suite/Common/IrssUtils/IrssLog.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssUtils/IrssLog.cs 2007-10-01 13:08:52 UTC (rev 966) +++ trunk/plugins/IR Server Suite/Common/IrssUtils/IrssLog.cs 2007-10-02 05:45:04 UTC (rev 967) @@ -195,6 +195,9 @@ { string message = DateTime.Now.ToString() + " - Error:\t" + String.Format(format, args); _streamWriter.WriteLine(message); +#if TRACE + Trace.WriteLine(message); +#endif } } @@ -209,6 +212,9 @@ { string message = DateTime.Now.ToString() + " - Warn: \t" + String.Format(format, args); _streamWriter.WriteLine(message); +#if TRACE + Trace.WriteLine(message); +#endif } } @@ -223,6 +229,9 @@ { string message = DateTime.Now.ToString() + " - Info: \t" + String.Format(format, args); _streamWriter.WriteLine(message); +#if TRACE + Trace.WriteLine(message); +#endif } } @@ -237,6 +246,9 @@ { string message = DateTime.Now.ToString() + " - Debug:\t" + String.Format(format, args); _streamWriter.WriteLine(message); +#if TRACE + Trace.WriteLine(message); +#endif } } 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-10-01 13:08:52 UTC (rev 966) +++ trunk/plugins/IR Server Suite/IR Server Plugins/FusionRemote Receiver/FusionRemoteReceiver.cs 2007-10-02 05:45:04 UTC (rev 967) @@ -17,7 +17,7 @@ namespace FusionRemoteReceiver { - public class FusionRemoteReceiver : IRServerPlugin, IRemoteReceiver + public class FusionRemoteReceiver : IRServerPluginBase, IRemoteReceiver { #region Constants @@ -202,6 +202,16 @@ public override string Author { get { return "and-81"; } } public override string Description { get { return "DViCO FusionREMOTE Receiver"; } } + public override bool Detect() + { + Guid hidGuid = new Guid(); + HidD_GetHidGuid(ref hidGuid); + + string devicePath = FindDevice(hidGuid, DeviceID); + + return (devicePath != null); + } + public override bool Start() { try @@ -217,15 +227,13 @@ #if TRACE catch (Exception ex) { - Trace.WriteLine(ex.ToString()); - return false; - } + Trace.WriteLine("FusionRemoteReceiver: " + ex.ToString()); #else catch { +#endif return false; } -#endif } public override void Suspend() { Added: trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IConfigure.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IConfigure.cs (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IConfigure.cs 2007-10-02 05:45:04 UTC (rev 967) @@ -0,0 +1,19 @@ +using System; + +namespace IRServerPluginInterface +{ + + /// <summary> + /// Plugins that implement this interface are configurable. + /// </summary> + public interface IConfigure + { + + /// <summary> + /// Configure the IR Server plugin. + /// </summary> + void Configure(); + + } + +} Added: trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IKeyboardReceiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IKeyboardReceiver.cs (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IKeyboardReceiver.cs 2007-10-02 05:45:04 UTC (rev 967) @@ -0,0 +1,30 @@ +using System; + +namespace IRServerPluginInterface +{ + + #region Delegates + + /// <summary> + /// IR Server callback for keyboard key press handling. + /// </summary> + /// <param name="vKey">Virtual key code.</param> + /// <param name="keyUp">.</param> + public delegate void KeyboardHandler(int vKey, bool keyUp); + + #endregion Delegates + + /// <summary> + /// Plugins that implement this interface can receive keyboard button presses. + /// </summary> + public interface IKeyboardReceiver + { + + /// <summary> + /// Callback for keyboard presses. + /// </summary> + KeyboardHandler KeyboardCallback { get; set; } + + } + +} Added: trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/ILearnIR.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/ILearnIR.cs (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/ILearnIR.cs 2007-10-02 05:45:04 UTC (rev 967) @@ -0,0 +1,44 @@ +using System; + +namespace IRServerPluginInterface +{ + + #region Enumerations + + /// <summary> + /// Provides information about the status of learning an infrared command. + /// </summary> + public enum LearnStatus + { + /// <summary> + /// Failed to learn infrared command. + /// </summary> + Failure, + /// <summary> + /// Succeeded in learning infrared command. + /// </summary> + Success, + /// <summary> + /// Infrared command learning timed out. + /// </summary> + Timeout, + } + + #endregion Enumerations + + /// <summary> + /// Plugins that implement this interface can learn IR commands. + /// </summary> + public interface ILearnIR + { + + /// <summary> + /// Learn an infrared command. + /// </summary> + /// <param name="data">New infrared command.</param> + /// <returns>Tells the calling code if the learn was Successful, Failed or Timed Out.</returns> + LearnStatus Learn(out byte[] data); + + } + +} Added: trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IMouseReceiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IMouseReceiver.cs (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Plugin... [truncated message content] |