From: <an...@us...> - 2008-04-06 09:44:42
|
Revision: 1608 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=1608&view=rev Author: and-81 Date: 2008-04-06 02:44:35 -0700 (Sun, 06 Apr 2008) Log Message: ----------- Modified Paths: -------------- 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/Tray Launcher/Tray.cs trunk/plugins/IR Server Suite/Common/IrssUtils/Common.cs trunk/plugins/IR Server Suite/Documentation/new.html trunk/plugins/IR Server Suite/IR Server Plugins/Imon Receiver/Configure.Designer.cs trunk/plugins/IR Server Suite/IR Server Plugins/Imon Receiver/Configure.cs trunk/plugins/IR Server Suite/IR Server Plugins/Imon Receiver/Imon Receiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/MicrosoftMceTransceiver.cs trunk/plugins/IR Server Suite/Input Service/Input Service/Program.cs trunk/plugins/IR Server Suite/Input Service/Input Service Configuration/Config.cs trunk/plugins/IR Server Suite/Input Service/Input Service Configuration/Program.cs trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/0.IR trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/1.IR trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/2.IR trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/3.IR trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/4.IR trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/5.IR trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/6.IR trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/7.IR trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/8.IR trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/9.IR Added Paths: ----------- trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/#.IR trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/Prechange.IR Modified: trunk/plugins/IR Server Suite/Applications/IR Server/IRServer.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/IR Server/IRServer.cs 2008-04-05 18:04:30 UTC (rev 1607) +++ trunk/plugins/IR Server Suite/Applications/IR Server/IRServer.cs 2008-04-06 09:44:35 UTC (rev 1608) @@ -1717,6 +1717,8 @@ } void SaveSettings() { + IrssLog.Info("Saving settings ..."); + try { using (XmlTextWriter writer = new XmlTextWriter(ConfigurationFile, Encoding.UTF8)) @@ -1759,6 +1761,7 @@ IrssLog.Error(ex); } } + void CreateDefaultSettings() { try @@ -1768,13 +1771,29 @@ _pluginNameTransmit = String.Empty; else _pluginNameTransmit = blasters[0]; + } + catch (Exception ex) + { + IrssLog.Error(ex); + _pluginNameTransmit = String.Empty; + } + try + { string[] receivers = Program.DetectReceivers(); if (receivers == null || receivers.Length == 0) _pluginNameReceive = null; else _pluginNameReceive = receivers; + } + catch (Exception ex) + { + IrssLog.Error(ex); + _pluginNameReceive = null; + } + try + { SaveSettings(); } catch (Exception ex) Modified: trunk/plugins/IR Server Suite/Applications/IR Server/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/IR Server/Program.cs 2008-04-05 18:04:30 UTC (rev 1607) +++ trunk/plugins/IR Server Suite/Applications/IR Server/Program.cs 2008-04-06 09:44:35 UTC (rev 1608) @@ -17,6 +17,9 @@ static class Program { + /// <summary> + /// The main entry point for the application. + /// </summary> [STAThread] static void Main() { @@ -83,6 +86,9 @@ string path = Path.Combine(installFolder, "IR Server Plugins"); string[] files = Directory.GetFiles(path, "*.dll", SearchOption.TopDirectoryOnly); + + // TODO: Return a Type[], don't instantiate unless required + foreach (string file in files) { try @@ -94,32 +100,15 @@ { if (type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(PluginBase))) { - try - { - PluginBase plugin = (PluginBase)assembly.CreateInstance(type.FullName); + PluginBase plugin = (PluginBase)assembly.CreateInstance(type.FullName); - if (plugin != null) - plugins.Add(plugin); - } - catch - { - // Ignore this plugin ... - } + if (plugin != null) + plugins.Add(plugin); } } } - catch (BadImageFormatException) - { - // 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"); - } + catch (BadImageFormatException) { } // Ignore Bad Image Format Exceptions, just keep checking for Input Service Plugins + catch (TypeLoadException) { } // Ignore Type Load Exceptions, just keep checking for Input Service Plugins } return plugins.ToArray(); @@ -152,6 +141,8 @@ /// <returns>String array of plugin names.</returns> internal static string[] DetectReceivers() { + IrssLog.Info("Detect Receivers ..."); + PluginBase[] plugins = AvailablePlugins(); if (plugins == null || plugins.Length == 0) return null; @@ -159,8 +150,17 @@ List<string> receivers = new List<string>(); foreach (PluginBase plugin in plugins) - if ((plugin is IRemoteReceiver || plugin is IKeyboardReceiver || plugin is IMouseReceiver) && plugin.Detect()) - receivers.Add(plugin.Name); + { + try + { + if ((plugin is IRemoteReceiver || plugin is IKeyboardReceiver || plugin is IMouseReceiver) && plugin.Detect()) + receivers.Add(plugin.Name); + } + catch (Exception ex) + { + IrssLog.Error(ex); + } + } if (receivers.Count > 0) return receivers.ToArray(); @@ -174,6 +174,8 @@ /// <returns>String array of plugin names.</returns> internal static string[] DetectBlasters() { + IrssLog.Info("Detect Blasters ..."); + PluginBase[] plugins = Program.AvailablePlugins(); if (plugins == null || plugins.Length == 0) return null; @@ -181,8 +183,17 @@ List<string> blasters = new List<string>(); foreach (PluginBase plugin in plugins) - if (plugin is ITransmitIR && plugin.Detect()) - blasters.Add(plugin.Name); + { + try + { + if (plugin is ITransmitIR && plugin.Detect()) + blasters.Add(plugin.Name); + } + catch (Exception ex) + { + IrssLog.Error(ex); + } + } if (blasters.Count > 0) return blasters.ToArray(); Modified: trunk/plugins/IR Server Suite/Applications/Tray Launcher/Tray.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Tray Launcher/Tray.cs 2008-04-05 18:04:30 UTC (rev 1607) +++ trunk/plugins/IR Server Suite/Applications/Tray Launcher/Tray.cs 2008-04-06 09:44:35 UTC (rev 1608) @@ -454,26 +454,18 @@ } } - // Launch program - using (Process launch = new Process()) - { - launch.StartInfo.FileName = _programFile; - launch.StartInfo.WindowStyle = ProcessWindowStyle.Normal; - launch.StartInfo.UseShellExecute = true; - launch.Start(); + string[] launchCommand = new string[] { + _programFile, + Path.GetDirectoryName(_programFile), + String.Empty, + Enum.GetName(typeof(ProcessWindowStyle), ProcessWindowStyle.Normal), + false.ToString(), + true.ToString(), + false.ToString(), + true.ToString() + }; - int attempt = 0; - while (!launch.HasExited && attempt++ < 50) - { - if (launch.MainWindowHandle != IntPtr.Zero) - { - Win32.SetForegroundWindow(launch.MainWindowHandle, true); - break; - } - - Thread.Sleep(500); - } - } + Common.ProcessRunCommand(launchCommand); } catch (Exception ex) { Modified: trunk/plugins/IR Server Suite/Common/IrssUtils/Common.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssUtils/Common.cs 2008-04-05 18:04:30 UTC (rev 1607) +++ trunk/plugins/IR Server Suite/Common/IrssUtils/Common.cs 2008-04-06 09:44:35 UTC (rev 1608) @@ -569,6 +569,8 @@ } Thread.Sleep(1500); + + title = process.MainWindowTitle; } } Modified: trunk/plugins/IR Server Suite/Documentation/new.html =================================================================== --- trunk/plugins/IR Server Suite/Documentation/new.html 2008-04-05 18:04:30 UTC (rev 1607) +++ trunk/plugins/IR Server Suite/Documentation/new.html 2008-04-06 09:44:35 UTC (rev 1608) @@ -69,6 +69,9 @@ <LI>Misc: Updated SourceGrid component to version 4.11</LI> <LI>New Input Plugin: Added experimental Imon support (thanks to Cybrmage for helping).</LI> <LI>Version Numbering: Changed version numbering scheme to use last digit as SVN version number. With zero for release builds. Now Version 1.0.4.2 becomes 1.4.2</LI> +<LI>Input Service: Fixed some small plugin loading issues.</LI> +<LI>Imon input plugin: Improved Imon plugin, now supports MCE and Imon PAD remote hardware.</LI> +<LI>Tray Launcher: Now uses the Common program launching code (includes new focus forcing code).</LI> </UL></P> <BR> Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Imon Receiver/Configure.Designer.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Imon Receiver/Configure.Designer.cs 2008-04-05 18:04:30 UTC (rev 1607) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Imon Receiver/Configure.Designer.cs 2008-04-06 09:44:35 UTC (rev 1608) @@ -47,8 +47,10 @@ this.checkBoxEnableMouse = new System.Windows.Forms.CheckBox(); this.checkBoxUseSystemRatesRemote = new System.Windows.Forms.CheckBox(); this.checkBoxUseSystemRatesKeyboard = new System.Windows.Forms.CheckBox(); + this.comboBoxHardwareMode = new System.Windows.Forms.ComboBox(); this.tabControl = new System.Windows.Forms.TabControl(); this.tabPageRemote = new System.Windows.Forms.TabPage(); + this.labelHardwareMode = new System.Windows.Forms.Label(); this.tabPageKeyboard = new System.Windows.Forms.TabPage(); this.groupBoxKeypressTiming = new System.Windows.Forms.GroupBox(); this.labelKeyRepeatDelay = new System.Windows.Forms.Label(); @@ -73,7 +75,7 @@ this.labelButtonRepeatDelay.Location = new System.Drawing.Point(8, 24); this.labelButtonRepeatDelay.Name = "labelButtonRepeatDelay"; this.labelButtonRepeatDelay.Size = new System.Drawing.Size(128, 20); - this.labelButtonRepeatDelay.TabIndex = 1; + this.labelButtonRepeatDelay.TabIndex = 0; this.labelButtonRepeatDelay.Text = "Button repeat delay:"; this.labelButtonRepeatDelay.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // @@ -82,7 +84,7 @@ this.labelButtonHeldDelay.Location = new System.Drawing.Point(8, 56); this.labelButtonHeldDelay.Name = "labelButtonHeldDelay"; this.labelButtonHeldDelay.Size = new System.Drawing.Size(128, 20); - this.labelButtonHeldDelay.TabIndex = 3; + this.labelButtonHeldDelay.TabIndex = 2; this.labelButtonHeldDelay.Text = "Button held delay:"; this.labelButtonHeldDelay.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // @@ -101,7 +103,7 @@ 0}); this.numericUpDownButtonRepeatDelay.Name = "numericUpDownButtonRepeatDelay"; this.numericUpDownButtonRepeatDelay.Size = new System.Drawing.Size(80, 20); - this.numericUpDownButtonRepeatDelay.TabIndex = 2; + this.numericUpDownButtonRepeatDelay.TabIndex = 1; this.numericUpDownButtonRepeatDelay.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; this.numericUpDownButtonRepeatDelay.ThousandsSeparator = true; this.toolTips.SetToolTip(this.numericUpDownButtonRepeatDelay, "When the button is held this is the time between the first press and the first re" + @@ -127,7 +129,7 @@ 0}); this.numericUpDownButtonHeldDelay.Name = "numericUpDownButtonHeldDelay"; this.numericUpDownButtonHeldDelay.Size = new System.Drawing.Size(80, 20); - this.numericUpDownButtonHeldDelay.TabIndex = 4; + this.numericUpDownButtonHeldDelay.TabIndex = 3; this.numericUpDownButtonHeldDelay.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; this.numericUpDownButtonHeldDelay.ThousandsSeparator = true; this.toolTips.SetToolTip(this.numericUpDownButtonHeldDelay, "When the button is held this is the time between repeats"); @@ -169,7 +171,7 @@ this.groupBoxRemoteTiming.Location = new System.Drawing.Point(8, 72); this.groupBoxRemoteTiming.Name = "groupBoxRemoteTiming"; this.groupBoxRemoteTiming.Size = new System.Drawing.Size(232, 88); - this.groupBoxRemoteTiming.TabIndex = 1; + this.groupBoxRemoteTiming.TabIndex = 2; this.groupBoxRemoteTiming.TabStop = false; this.groupBoxRemoteTiming.Text = "Remote button timing (in milliseconds)"; // @@ -324,7 +326,7 @@ this.checkBoxUseSystemRatesRemote.Location = new System.Drawing.Point(8, 40); this.checkBoxUseSystemRatesRemote.Name = "checkBoxUseSystemRatesRemote"; this.checkBoxUseSystemRatesRemote.Size = new System.Drawing.Size(187, 17); - this.checkBoxUseSystemRatesRemote.TabIndex = 0; + this.checkBoxUseSystemRatesRemote.TabIndex = 1; this.checkBoxUseSystemRatesRemote.Text = "Use system keyboard rate settings"; this.toolTips.SetToolTip(this.checkBoxUseSystemRatesRemote, "Use the system keyboard repeat rate settings for remote button timing"); this.checkBoxUseSystemRatesRemote.UseVisualStyleBackColor = true; @@ -342,6 +344,16 @@ this.checkBoxUseSystemRatesKeyboard.UseVisualStyleBackColor = true; this.checkBoxUseSystemRatesKeyboard.CheckedChanged += new System.EventHandler(this.checkBoxUseSystemRatesKeyboard_CheckedChanged); // + // comboBoxHardwareMode + // + this.comboBoxHardwareMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxHardwareMode.FormattingEnabled = true; + this.comboBoxHardwareMode.Location = new System.Drawing.Point(152, 168); + this.comboBoxHardwareMode.Name = "comboBoxHardwareMode"; + this.comboBoxHardwareMode.Size = new System.Drawing.Size(89, 21); + this.comboBoxHardwareMode.TabIndex = 4; + this.toolTips.SetToolTip(this.comboBoxHardwareMode, "Choose between MCE and Imon remote types"); + // // tabControl // this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -358,6 +370,8 @@ // // tabPageRemote // + this.tabPageRemote.Controls.Add(this.comboBoxHardwareMode); + this.tabPageRemote.Controls.Add(this.labelHardwareMode); this.tabPageRemote.Controls.Add(this.checkBoxUseSystemRatesRemote); this.tabPageRemote.Controls.Add(this.checkBoxEnableRemote); this.tabPageRemote.Controls.Add(this.groupBoxRemoteTiming); @@ -369,6 +383,15 @@ this.tabPageRemote.Text = "Remote"; this.tabPageRemote.UseVisualStyleBackColor = true; // + // labelHardwareMode + // + this.labelHardwareMode.Location = new System.Drawing.Point(8, 168); + this.labelHardwareMode.Name = "labelHardwareMode"; + this.labelHardwareMode.Size = new System.Drawing.Size(136, 21); + this.labelHardwareMode.TabIndex = 3; + this.labelHardwareMode.Text = "Hardware mode:"; + this.labelHardwareMode.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // // tabPageKeyboard // this.tabPageKeyboard.Controls.Add(this.checkBoxUseSystemRatesKeyboard); @@ -439,15 +462,17 @@ // // Configure // + this.AcceptButton = this.buttonOK; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(272, 273); + this.CancelButton = this.buttonCancel; + this.ClientSize = new System.Drawing.Size(272, 272); this.Controls.Add(this.tabControl); this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonOK); this.MaximizeBox = false; this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(288, 309); + this.MinimumSize = new System.Drawing.Size(280, 306); this.Name = "Configure"; this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; @@ -498,5 +523,7 @@ private System.Windows.Forms.CheckBox checkBoxEnableMouse; private System.Windows.Forms.CheckBox checkBoxUseSystemRatesRemote; private System.Windows.Forms.CheckBox checkBoxUseSystemRatesKeyboard; + private System.Windows.Forms.ComboBox comboBoxHardwareMode; + private System.Windows.Forms.Label labelHardwareMode; } } \ No newline at end of file Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Imon Receiver/Configure.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Imon Receiver/Configure.cs 2008-04-05 18:04:30 UTC (rev 1607) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Imon Receiver/Configure.cs 2008-04-06 09:44:35 UTC (rev 1608) @@ -13,6 +13,12 @@ #region Properties + public ImonReceiver.RcMode HardwareMode + { + get { return (ImonReceiver.RcMode)Enum.Parse(typeof(ImonReceiver.RcMode), comboBoxHardwareMode.SelectedItem as string); } + set { comboBoxHardwareMode.SelectedItem = Enum.GetName(typeof(ImonReceiver.RcMode), value); } + } + public bool EnableRemote { get { return checkBoxEnableRemote.Checked; } @@ -86,6 +92,8 @@ public Configure() { InitializeComponent(); + + comboBoxHardwareMode.Items.AddRange(Enum.GetNames(typeof(ImonReceiver.RcMode))); } #endregion Constructor Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Imon Receiver/Imon Receiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Imon Receiver/Imon Receiver.cs 2008-04-05 18:04:30 UTC (rev 1607) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Imon Receiver/Imon Receiver.cs 2008-04-06 09:44:35 UTC (rev 1608) @@ -96,10 +96,43 @@ const uint IMON_PAD_BUTTON = 1000; const uint IMON_MCE_BUTTON = 2000; + static readonly byte[][] SetModeMCE = new byte[][] { + new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00 }, + new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x02 }, + new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x04 }, + new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x06 }, + new byte[] { 0x20, 0x20, 0x20, 0x20, 0x01, 0x00, 0x00, 0x08 }, + new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0A } + }; + + static readonly byte[][] SetModeImon = new byte[][] { + new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00 }, + new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x02 }, + new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x04 }, + new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x06 }, + new byte[] { 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x08 }, + new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0A } + }; + #endregion Constants #region Enumerations + /// <summary> + /// Hardware mode (either MCE or Imon). + /// </summary> + internal enum RcMode + { + /// <summary> + /// Microsoft MCE Mode. + /// </summary> + Mce, + /// <summary> + /// Soundgraph Imon Mode. + /// </summary> + Imon, + } + [Flags] enum KeyModifiers { @@ -220,6 +253,8 @@ #region Configuration + RcMode _hardwareMode = RcMode.Mce; + bool _enableRemoteInput = true; bool _useSystemRatesRemote = false; int _remoteFirstRepeat = 400; @@ -353,6 +388,8 @@ Configure config = new Configure(); + config.HardwareMode = _hardwareMode; + config.EnableRemote = _enableRemoteInput; config.UseSystemRatesForRemote = _useSystemRatesRemote; config.RemoteRepeatDelay = _remoteFirstRepeat; @@ -370,6 +407,8 @@ if (config.ShowDialog(owner) == DialogResult.OK) { + _hardwareMode = config.HardwareMode; + _enableRemoteInput = config.EnableRemote; _useSystemRatesRemote = config.UseSystemRatesForRemote; _remoteFirstRepeat = config.RemoteRepeatDelay; @@ -433,6 +472,8 @@ if (_deviceHandle.IsInvalid) throw new Win32Exception(lastError, "Failed to open device"); + SetHardwareMode(_hardwareMode); + _processReceiveThread = true; _receiveThread = new Thread(new ThreadStart(ReceiveThread)); _receiveThread.Name = "Imon Receive Thread"; @@ -527,6 +568,8 @@ try { doc.Load(ConfigurationFile); } catch { return; } + try { _hardwareMode = (RcMode)Enum.Parse(typeof(RcMode), doc.DocumentElement.Attributes["HardwareMode"].Value); } catch { } + try { _enableRemoteInput = bool.Parse(doc.DocumentElement.Attributes["EnableRemoteInput"].Value); } catch {} try { _useSystemRatesRemote = bool.Parse(doc.DocumentElement.Attributes["UseSystemRatesRemote"].Value); } catch { } try { _remoteFirstRepeat = int.Parse(doc.DocumentElement.Attributes["RemoteFirstRepeat"].Value); } catch {} @@ -558,6 +601,8 @@ writer.WriteStartDocument(true); writer.WriteStartElement("settings"); // <settings> + writer.WriteAttributeString("HardwareMode", Enum.GetName(typeof(RcMode), _hardwareMode)); + writer.WriteAttributeString("EnableRemoteInput", _enableRemoteInput.ToString()); writer.WriteAttributeString("UseSystemRatesRemote", _useSystemRatesRemote.ToString()); writer.WriteAttributeString("RemoteFirstRepeat", _remoteFirstRepeat.ToString()); @@ -577,10 +622,10 @@ writer.WriteEndDocument(); } } -#if TRACE +#if DEBUG catch (Exception ex) { - Trace.WriteLine(ex.ToString()); + DebugWriteLine(ex.ToString()); } #else catch @@ -592,7 +637,7 @@ void ProcessInput(byte[] dataBytes) { #if DEBUG - DebugWrite("Data Received: "); + DebugWriteLine("Data Received:"); DebugDump(dataBytes); #endif @@ -751,6 +796,63 @@ } } + void SetHardwareMode(RcMode mode) + { +#if DEBUG + DebugWriteLine("SetHardwareMode({0})", Enum.GetName(typeof(RcMode), mode)); +#endif + + int bytesRead; + + IntPtr deviceBufferPtr = IntPtr.Zero; + + try + { + switch (mode) + { + case RcMode.Imon: + foreach (byte[] send in SetModeImon) + { + deviceBufferPtr = Marshal.AllocHGlobal(send.Length); + + Marshal.Copy(send, 0, deviceBufferPtr, send.Length); + IoControl(IOCTL_IMON_WRITE, deviceBufferPtr, send.Length, IntPtr.Zero, 0, out bytesRead); + + Marshal.FreeHGlobal(deviceBufferPtr); + } + break; + + case RcMode.Mce: + foreach (byte[] send in SetModeMCE) + { + deviceBufferPtr = Marshal.AllocHGlobal(send.Length); + + Marshal.Copy(send, 0, deviceBufferPtr, send.Length); + IoControl(IOCTL_IMON_WRITE, deviceBufferPtr, send.Length, IntPtr.Zero, 0, out bytesRead); + + Marshal.FreeHGlobal(deviceBufferPtr); + } + break; + } + } +#if DEBUG + catch (Exception ex) + { + DebugWriteLine(ex.ToString()); +#else + catch + { +#endif + if (_deviceHandle != null) + CancelIo(_deviceHandle); + } + finally + { + if (deviceBufferPtr != IntPtr.Zero) + Marshal.FreeHGlobal(deviceBufferPtr); + } + } + void RemoteEvent(uint keyCode, bool firstPress) { #if DEBUG @@ -774,16 +876,16 @@ if (!_remoteButtonRepeated && timeBetween.TotalMilliseconds < firstRepeat) { -#if TRACE - Trace.WriteLine("Skip First Repeat"); +#if DEBUG + DebugWriteLine("Skip, First Repeat"); #endif return; } if (_remoteButtonRepeated && timeBetween.TotalMilliseconds < heldRepeats) { -#if TRACE - Trace.WriteLine("Skip Held Repeat"); +#if DEBUG + DebugWriteLine("Skip, Held Repeat"); #endif return; } Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/MicrosoftMceTransceiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/MicrosoftMceTransceiver.cs 2008-04-05 18:04:30 UTC (rev 1607) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/MicrosoftMceTransceiver.cs 2008-04-06 09:44:35 UTC (rev 1608) @@ -688,7 +688,7 @@ if (!_remoteButtonRepeated && timeBetween.TotalMilliseconds < firstRepeat) { #if TRACE - Trace.WriteLine("Skip First Repeat"); + Trace.WriteLine("Skip, First Repeat"); #endif return; } @@ -696,7 +696,7 @@ if (_remoteButtonRepeated && timeBetween.TotalMilliseconds < heldRepeats) { #if TRACE - Trace.WriteLine("Skip Held Repeat"); + Trace.WriteLine("Skip, Held Repeat"); #endif return; } Modified: trunk/plugins/IR Server Suite/Input Service/Input Service/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/Input Service/Input Service/Program.cs 2008-04-05 18:04:30 UTC (rev 1607) +++ trunk/plugins/IR Server Suite/Input Service/Input Service/Program.cs 2008-04-06 09:44:35 UTC (rev 1608) @@ -102,6 +102,9 @@ string path = Path.Combine(installFolder, "IR Server Plugins"); string[] files = Directory.GetFiles(path, "*.dll", SearchOption.TopDirectoryOnly); + + // TODO: Return a Type[], don't instantiate unless required + foreach (string file in files) { try @@ -113,28 +116,15 @@ { if (type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(PluginBase))) { - try - { - PluginBase plugin = (PluginBase)assembly.CreateInstance(type.FullName); + PluginBase plugin = (PluginBase)assembly.CreateInstance(type.FullName); - if (plugin != null) - plugins.Add(plugin); - } - catch - { - // Ignore this plugin ... - } + if (plugin != null) + plugins.Add(plugin); } } } - catch (BadImageFormatException) - { - // Ignore Bad Image Format Exceptions, just keep checking for Input Service Plugins - } - catch (TypeLoadException) - { - // Ignore Type Load Exceptions, just keep checking for Input Service Plugins - } + catch (BadImageFormatException) { } // Ignore Bad Image Format Exceptions, just keep checking for Input Service Plugins + catch (TypeLoadException) { } // Ignore Type Load Exceptions, just keep checking for Input Service Plugins } return plugins.ToArray(); @@ -167,6 +157,8 @@ /// <returns>String array of plugin names.</returns> internal static string[] DetectReceivers() { + IrssLog.Info("Detect Receivers ..."); + PluginBase[] plugins = AvailablePlugins(); if (plugins == null || plugins.Length == 0) return null; @@ -174,8 +166,17 @@ List<string> receivers = new List<string>(); foreach (PluginBase plugin in plugins) - if ((plugin is IRemoteReceiver || plugin is IKeyboardReceiver || plugin is IMouseReceiver) && plugin.Detect()) - receivers.Add(plugin.Name); + { + try + { + if ((plugin is IRemoteReceiver || plugin is IKeyboardReceiver || plugin is IMouseReceiver) && plugin.Detect()) + receivers.Add(plugin.Name); + } + catch (Exception ex) + { + IrssLog.Error(ex); + } + } if (receivers.Count > 0) return receivers.ToArray(); @@ -189,6 +190,8 @@ /// <returns>String array of plugin names.</returns> internal static string[] DetectBlasters() { + IrssLog.Info("Detect Blasters ..."); + PluginBase[] plugins = Program.AvailablePlugins(); if (plugins == null || plugins.Length == 0) return null; @@ -196,8 +199,17 @@ List<string> blasters = new List<string>(); foreach (PluginBase plugin in plugins) - if (plugin is ITransmitIR && plugin.Detect()) - blasters.Add(plugin.Name); + { + try + { + if (plugin is ITransmitIR && plugin.Detect()) + blasters.Add(plugin.Name); + } + catch (Exception ex) + { + IrssLog.Error(ex); + } + } if (blasters.Count > 0) return blasters.ToArray(); Modified: trunk/plugins/IR Server Suite/Input Service/Input Service Configuration/Config.cs =================================================================== --- trunk/plugins/IR Server Suite/Input Service/Input Service Configuration/Config.cs 2008-04-05 18:04:30 UTC (rev 1607) +++ trunk/plugins/IR Server Suite/Input Service/Input Service Configuration/Config.cs 2008-04-06 09:44:35 UTC (rev 1608) @@ -148,8 +148,17 @@ { InitializeComponent(); - // Add transceivers to list ... - _transceivers = Program.AvailablePlugins(); + try + { + _transceivers = Program.AvailablePlugins(); + } + catch (Exception ex) + { + IrssLog.Error(ex); + + _transceivers = null; + } + if (_transceivers == null || _transceivers.Length == 0) MessageBox.Show(this, "No Input Service Plugins found!", "Input Service Configuration", MessageBoxButtons.OK, MessageBoxIcon.Error); else Modified: trunk/plugins/IR Server Suite/Input Service/Input Service Configuration/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/Input Service/Input Service Configuration/Program.cs 2008-04-05 18:04:30 UTC (rev 1607) +++ trunk/plugins/IR Server Suite/Input Service/Input Service Configuration/Program.cs 2008-04-06 09:44:35 UTC (rev 1608) @@ -76,9 +76,6 @@ } catch (Exception ex) { -#if TRACE - Trace.WriteLine(ex.ToString()); -#endif MessageBox.Show(ex.ToString(), "Error detecting duplicate processes", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } @@ -155,23 +152,20 @@ { doc.Load(ConfigurationFile); } + catch (DirectoryNotFoundException) + { + IrssLog.Error("No configuration file found ({0}), folder not found! Creating default configuration file", ConfigurationFile); + + Directory.CreateDirectory(Path.GetDirectoryName(ConfigurationFile)); + + CreateDefaultSettings(); + return; + } catch (FileNotFoundException) { IrssLog.Warn("No configuration file found ({0}), creating default configuration file", ConfigurationFile); - string[] blasters = DetectBlasters(); - if (blasters == null) - _pluginNameTransmit = String.Empty; - else - _pluginNameTransmit = blasters[0]; - - string[] receivers = DetectReceivers(); - if (receivers == null) - _pluginNameReceive = null; - else - _pluginNameReceive = receivers; - - SaveSettings(); + CreateDefaultSettings(); return; } catch (Exception ex) @@ -253,6 +247,46 @@ } } + static void CreateDefaultSettings() + { + try + { + string[] blasters = Program.DetectBlasters(); + if (blasters == null) + _pluginNameTransmit = String.Empty; + else + _pluginNameTransmit = blasters[0]; + } + catch (Exception ex) + { + IrssLog.Error(ex); + _pluginNameTransmit = String.Empty; + } + + try + { + string[] receivers = Program.DetectReceivers(); + if (receivers == null) + _pluginNameReceive = null; + else + _pluginNameReceive = receivers; + } + catch (Exception ex) + { + IrssLog.Error(ex); + _pluginNameReceive = null; + } + + try + { + SaveSettings(); + } + catch (Exception ex) + { + IrssLog.Error(ex); + } + } + static void RestartService(string serviceName) { IrssLog.Info("Restarting service ({0})", serviceName); @@ -292,57 +326,40 @@ /// <returns>Array of plugin instances.</returns> internal static PluginBase[] AvailablePlugins() { - try - { - List<PluginBase> plugins = new List<PluginBase>(); + List<PluginBase> plugins = new List<PluginBase>(); - string installFolder = SystemRegistry.GetInstallFolder(); - if (String.IsNullOrEmpty(installFolder)) - return null; + string installFolder = SystemRegistry.GetInstallFolder(); + if (String.IsNullOrEmpty(installFolder)) + return null; - string path = Path.Combine(installFolder, "IR Server Plugins"); - string[] files = Directory.GetFiles(path, "*.dll", SearchOption.TopDirectoryOnly); + string path = Path.Combine(installFolder, "IR Server Plugins"); + string[] files = Directory.GetFiles(path, "*.dll", SearchOption.TopDirectoryOnly); - foreach (string file in files) + // TODO: Return a Type[], don't instantiate unless required + + foreach (string file in files) + { + try { - try + Assembly assembly = Assembly.LoadFrom(file); + Type[] types = assembly.GetExportedTypes(); + + foreach (Type type in types) { - Assembly assembly = Assembly.LoadFrom(file); - Type[] types = assembly.GetExportedTypes(); - - foreach (Type type in types) + if (type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(PluginBase))) { - if (type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(PluginBase))) - { - PluginBase plugin = (PluginBase)assembly.CreateInstance(type.FullName); + PluginBase plugin = (PluginBase)assembly.CreateInstance(type.FullName); - if (plugin != null) - plugins.Add(plugin); - } + if (plugin != null) + plugins.Add(plugin); } } - catch (BadImageFormatException) - { - // Ignore Bad Image Format Exceptions, just keep checking for Input Service Plugins - } - catch (TypeLoadException) - { - // Ignore Type Load Exceptions, just keep checking for Input Service Plugins - } } + catch (BadImageFormatException) { } // Ignore Bad Image Format Exceptions, just keep checking for Input Service Plugins + catch (TypeLoadException) { } // Ignore Type Load Exceptions, just keep checking for Input Service Plugins + } - return plugins.ToArray(); - } -#if TRACE - catch (Exception ex) - { - Trace.WriteLine("Input Service Configuration: " + ex.ToString()); -#else - catch - { -#endif - return null; - } + return plugins.ToArray(); } /// <summary> @@ -353,30 +370,28 @@ { IrssLog.Info("Detect Receivers ..."); - try - { - PluginBase[] plugins = AvailablePlugins(); + PluginBase[] plugins = AvailablePlugins(); + if (plugins == null || plugins.Length == 0) + return null; - List<string> receivers = new List<string>(); + List<string> receivers = new List<string>(); - foreach (PluginBase plugin in plugins) + foreach (PluginBase plugin in plugins) + { + try + { if ((plugin is IRemoteReceiver || plugin is IKeyboardReceiver || plugin is IMouseReceiver) && plugin.Detect()) receivers.Add(plugin.Name); - - if (receivers.Count > 0) - return receivers.ToArray(); + } + catch (Exception ex) + { + IrssLog.Error(ex); + } } -#if TRACE - catch (Exception ex) - { - Trace.WriteLine("Input Service Configuration: " + ex.ToString()); - } -#else - catch - { - } -#endif + if (receivers.Count > 0) + return receivers.ToArray(); + return null; } @@ -388,30 +403,28 @@ { IrssLog.Info("Detect Blasters ..."); - try - { - PluginBase[] plugins = Program.AvailablePlugins(); + PluginBase[] plugins = Program.AvailablePlugins(); + if (plugins == null || plugins.Length == 0) + return null; - List<string> blasters = new List<string>(); + List<string> blasters = new List<string>(); - foreach (PluginBase plugin in plugins) + foreach (PluginBase plugin in plugins) + { + try + { if (plugin is ITransmitIR && plugin.Detect()) blasters.Add(plugin.Name); - - if (blasters.Count > 0) - return blasters.ToArray(); + } + catch (Exception ex) + { + IrssLog.Error(ex); + } } -#if TRACE - catch (Exception ex) - { - Trace.WriteLine("Input Service Configuration: " + ex.ToString()); - } -#else - catch - { - } -#endif + if (blasters.Count > 0) + return blasters.ToArray(); + return null; } Added: trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/#.IR =================================================================== --- trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/#.IR (rev 0) +++ trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/#.IR 2008-04-06 09:44:35 UTC (rev 1608) @@ -0,0 +1 @@ +0000 006F 000A 0000 0022 0020 0022 0020 0041 0041 0043 003F 0043 0020 0022 0041 0022 0020 0022 0020 0043 0020 0022 0D1D \ No newline at end of file Modified: trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/0.IR =================================================================== --- trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/0.IR 2008-04-05 18:04:30 UTC (rev 1607) +++ trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/0.IR 2008-04-06 09:44:35 UTC (rev 1608) @@ -1 +1 @@ -5000 0073 0000 0001 000A 0000 \ No newline at end of file +0000 006F 000B 0000 0020 0022 0020 0022 0041 0041 0041 0041 0043 0020 0022 0020 0022 0020 0022 0022 0020 0022 0020 0022 0020 0D1D \ No newline at end of file Modified: trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/1.IR =================================================================== --- trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/1.IR 2008-04-05 18:04:30 UTC (rev 1607) +++ trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/1.IR 2008-04-06 09:44:35 UTC (rev 1608) @@ -1 +1 @@ -5000 0073 0000 0001 000A 0001 \ No newline at end of file +0000 006F 000B 0000 0020 0020 0022 0020 0043 0041 0041 0041 0043 0020 0022 0020 0022 0020 0022 0020 0022 0020 0022 0041 0022 0CFD \ No newline at end of file Modified: trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/2.IR =================================================================== --- trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/2.IR 2008-04-05 18:04:30 UTC (rev 1607) +++ trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/2.IR 2008-04-06 09:44:35 UTC (rev 1608) @@ -1 +1 @@ -5000 0073 0000 0001 000A 0002 \ No newline at end of file +0000 006F 000A 0000 0020 0022 0041 0020 0022 0043 003F 0043 003F 0022 0022 0022 0020 0020 0022 0022 0020 0043 003F 0D21 \ No newline at end of file Modified: trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/3.IR =================================================================== --- trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/3.IR 2008-04-05 18:04:30 UTC (rev 1607) +++ trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/3.IR 2008-04-06 09:44:35 UTC (rev 1608) @@ -1 +1 @@ -5000 0073 0000 0001 000A 0003 \ No newline at end of file +0000 0070 000B 0000 001F 0021 0041 0021 001F 0041 0041 0043 0041 001F 0021 001F 0021 0021 001F 0021 001F 0041 0021 0021 001F 0CE0 \ No newline at end of file Modified: trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/4.IR =================================================================== --- trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/4.IR 2008-04-05 18:04:30 UTC (rev 1607) +++ trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/4.IR 2008-04-06 09:44:35 UTC (rev 1608) @@ -1 +1 @@ -5000 0073 0000 0001 000A 0004 \ No newline at end of file +0000 006F 000A 0000 0020 0022 0041 0022 0020 0043 0041 0041 0041 0022 0020 0022 0020 0022 0020 0043 0041 0020 0022 0D1D \ No newline at end of file Modified: trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/5.IR =================================================================== --- trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/5.IR 2008-04-05 18:04:30 UTC (rev 1607) +++ trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/5.IR 2008-04-06 09:44:35 UTC (rev 1608) @@ -1 +1 @@ -5000 0073 0000 0001 000A 0005 \ No newline at end of file +0000 006F 000A 0000 0020 0022 0041 0020 0022 0041 0041 0041 0043 0020 0022 0020 0022 0020 0022 0041 0041 0041 0022 0CFF \ No newline at end of file Modified: trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/6.IR =================================================================== --- trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/6.IR 2008-04-05 18:04:30 UTC (rev 1607) +++ trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/6.IR 2008-04-06 09:44:35 UTC (rev 1608) @@ -1 +1 @@ -5000 0073 0000 0001 000A 0006 \ No newline at end of file +0000 006F 000A 0000 0020 0022 0041 0022 0020 0041 0041 0043 0041 0020 0022 0020 0022 0020 0022 0041 0022 0020 0041 0D1F \ No newline at end of file Modified: trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/7.IR =================================================================== --- trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/7.IR 2008-04-05 18:04:30 UTC (rev 1607) +++ trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/7.IR 2008-04-06 09:44:35 UTC (rev 1608) @@ -1 +1 @@ -5000 0073 0000 0001 000A 0007 \ No newline at end of file +0000 006F 000B 0000 0020 0022 0041 0020 0022 0041 0041 0041 0041 0022 0022 0020 0022 0020 0022 0041 0022 0020 0022 0020 0022 0CFC \ No newline at end of file Modified: trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/8.IR =================================================================== --- trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/8.IR 2008-04-05 18:04:30 UTC (rev 1607) +++ trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/8.IR 2008-04-06 09:44:35 UTC (rev 1608) @@ -1 +1 @@ -5000 0073 0000 0001 000A 0008 \ No newline at end of file +0000 006E 000A 0000 0020 0020 0022 0022 0042 0042 0042 0044 0042 0020 0022 0020 0022 0042 0042 0022 0020 0022 0020 0EB8 \ No newline at end of file Modified: trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/9.IR =================================================================== --- trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/9.IR 2008-04-05 18:04:30 UTC (rev 1607) +++ trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/9.IR 2008-04-06 09:44:35 UTC (rev 1608) @@ -1 +1 @@ -5000 0073 0000 0001 000A 0009 \ No newline at end of file +0000 006F 000A 0000 0020 0022 0041 0020 0022 0041 0041 0041 0041 0022 0022 0020 0022 0041 0041 0022 0020 0041 0022 0CFF \ No newline at end of file Added: trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/Prechange.IR =================================================================== --- trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/Prechange.IR (rev 0) +++ trunk/plugins/IR Server Suite/Set Top Boxes/Pace 4100/Prechange.IR 2008-04-06 09:44:35 UTC (rev 1608) @@ -0,0 +1 @@ +0000 006F 0009 0000 0041 0020 0022 0020 0022 0041 0041 0043 0041 0041 0041 0041 0022 0020 0022 0020 0041 0D23 \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |