From: <an...@us...> - 2008-03-19 14:57:19
|
Revision: 1484 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=1484&view=rev Author: and-81 Date: 2008-03-19 07:54:17 -0700 (Wed, 19 Mar 2008) Log Message: ----------- Modified Paths: -------------- trunk/plugins/IR Server Suite/Applications/Translator/Forms/ButtonMappingForm.cs trunk/plugins/IR Server Suite/Documentation/new.html 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/NotifyWindow.cs trunk/plugins/IR Server Suite/Input Service/Input Service/InputService.cs Modified: trunk/plugins/IR Server Suite/Applications/Translator/Forms/ButtonMappingForm.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Translator/Forms/ButtonMappingForm.cs 2008-03-19 06:36:43 UTC (rev 1483) +++ trunk/plugins/IR Server Suite/Applications/Translator/Forms/ButtonMappingForm.cs 2008-03-19 14:54:17 UTC (rev 1484) @@ -197,12 +197,12 @@ string[] commands = Common.SplitRunCommand(suffix); tabControl.SelectTab(tabPageProgram); - textBoxApp.Text = commands[0]; - textBoxAppStartFolder.Text = commands[1]; + textBoxApp.Text = commands[0]; + textBoxAppStartFolder.Text = commands[1]; textBoxApplicationParameters.Text = commands[2]; - comboBoxWindowStyle.SelectedItem = commands[3]; - checkBoxNoWindow.Checked = bool.Parse(commands[4]); - checkBoxShellExecute.Checked = bool.Parse(commands[5]); + comboBoxWindowStyle.SelectedItem = commands[3]; + checkBoxNoWindow.Checked = bool.Parse(commands[4]); + checkBoxShellExecute.Checked = bool.Parse(commands[5]); break; } @@ -211,12 +211,12 @@ string[] commands = Common.SplitSerialCommand(suffix); tabControl.SelectTab(tabPageSerial); - textBoxSerialCommand.Text = commands[0]; - comboBoxComPort.SelectedItem = commands[1]; - numericUpDownBaudRate.Value = decimal.Parse(commands[2]); - comboBoxParity.SelectedItem = commands[3]; - numericUpDownDataBits.Value = decimal.Parse(commands[4]); - comboBoxStopBits.SelectedItem = commands[5]; + textBoxSerialCommand.Text = commands[0]; + comboBoxComPort.SelectedItem = commands[1]; + numericUpDownBaudRate.Value = decimal.Parse(commands[2]); + comboBoxParity.SelectedItem = commands[3]; + numericUpDownDataBits.Value = decimal.Parse(commands[4]); + comboBoxStopBits.SelectedItem = commands[5]; checkBoxWaitForResponse.Checked = bool.Parse(commands[6]); break; @@ -479,14 +479,29 @@ textBoxCommand.Text = _command = Common.CmdPrefixSmsKB; break; - //comboBoxMiscCommand.Items.Add(Common.UITextTcpMsg); - //comboBoxMiscCommand.Items.Add(Common.UITextHttpMsg); + case Common.UITextTcpMsg: + TcpMessageCommand tcpMessageCommand = new TcpMessageCommand(); + if (tcpMessageCommand.ShowDialog(this) == DialogResult.OK) + textBoxCommand.Text = Common.CmdPrefixTcpMsg + tcpMessageCommand.CommandString; + break; + case Common.UITextHttpMsg: + HttpMessageCommand httpMessageCommand = new HttpMessageCommand(); + if (httpMessageCommand.ShowDialog(this) == DialogResult.OK) + textBoxCommand.Text = Common.CmdPrefixHttpMsg + httpMessageCommand.CommandString; + break; + case Common.UITextEject: - textBoxCommand.Text = _command = Common.CmdPrefixEject; + EjectCommand ejectCommand = new EjectCommand(); + if (ejectCommand.ShowDialog(this) == DialogResult.OK) + textBoxCommand.Text = Common.CmdPrefixEject + ejectCommand.CommandString; break; - //comboBoxMiscCommand.Items.Add(Common.UITextPopup); + case Common.UITextPopup: + PopupMessage popupMessage = new PopupMessage(); + if (popupMessage.ShowDialog(this) == DialogResult.OK) + textBoxCommand.Text = Common.CmdPrefixPopup + popupMessage.CommandString; + break; case Common.UITextStandby: textBoxCommand.Text = _command = Common.CmdPrefixStandby; @@ -504,8 +519,20 @@ textBoxCommand.Text = _command = Common.CmdPrefixShutdown; break; - //comboBoxMiscCommand.Items.Add(Common.UITextBeep); - //comboBoxMiscCommand.Items.Add(Common.UITextSound); + case Common.UITextBeep: + BeepCommand beepCommand = new BeepCommand(); + if (beepCommand.ShowDialog(this) == DialogResult.OK) + textBoxCommand.Text = Common.CmdPrefixBeep + beepCommand.CommandString; + break; + + case Common.UITextSound: + OpenFileDialog openFileDialog = new OpenFileDialog(); + openFileDialog.Filter = "Wave Files|*.wav"; + openFileDialog.Multiselect = false; + + if (openFileDialog.ShowDialog(this) == DialogResult.OK) + textBoxCommand.Text = Common.CmdPrefixSound + openFileDialog.FileName; + break; } break; Modified: trunk/plugins/IR Server Suite/Documentation/new.html =================================================================== --- trunk/plugins/IR Server Suite/Documentation/new.html 2008-03-19 06:36:43 UTC (rev 1483) +++ trunk/plugins/IR Server Suite/Documentation/new.html 2008-03-19 14:54:17 UTC (rev 1484) @@ -58,6 +58,9 @@ <LI>Translator: Added process priority adjustment (under the new Advanced configuration menu item).</LI> <LI>WinLirc Plugin: Changed suspend/resume behaviour to fix a bug with repeated buttons after resume from standby.</LI> <LI>MCE Remote Receiver: Fixed an SMK brand receiver issue that was preventing some from receiving remote buttons.</LI> +<LI>Translator: Fixed broken misc command types on the button mapping form.</LI> +<LI>Translator: Added option to hide the tray icon in Advanced configuration. To reveal the icon just run the Translator application again.</LI> +<LI>Input Service Configuration: Added Start and Stop buttons to the toolbar.</LI> </UL></P> <BR> Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DriverReplacement.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DriverReplacement.cs 2008-03-19 06:36:43 UTC (rev 1483) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DriverReplacement.cs 2008-03-19 14:54:17 UTC (rev 1484) @@ -236,6 +236,7 @@ #endif finally { + _notifyWindow.UnregisterDeviceArrival(); _notifyWindow.Dispose(); _notifyWindow = null; @@ -257,7 +258,12 @@ try { if (_readHandle == null) - throw new InvalidOperationException("Cannot suspend, device is not active"); + { +#if DEBUG + DebugWriteLine("Warning: Device is not active"); +#endif + return; + } WriteSync(StopPacket); @@ -290,11 +296,18 @@ try { if (String.IsNullOrEmpty(Driver.Find(_deviceGuid))) - throw new InvalidOperationException("Device not available"); + { +#if DEBUG + DebugWriteLine("Device not found"); +#endif + return; + } if (_readHandle != null) - throw new InvalidOperationException("Cannot resume, device is active"); + throw new InvalidOperationException("Cannot resume, device is already active"); + //_notifyWindow.RegisterDeviceArrival(); + OpenDevice(); StartReadThread(); InitializeDevice(); @@ -382,7 +395,7 @@ public override void Send(IrCode code, int port) { #if DEBUG - DebugWriteLine("Send()"); + DebugWrite("Send(): "); DebugDump(code.TimingData); #endif @@ -414,6 +427,10 @@ /// </summary> void InitializeDevice() { +#if DEBUG + DebugWriteLine("InitializeDevice()"); +#endif + WriteSync(ResetPacket); // Added 18-March-2008 to see what SMK devices think of it... WriteSync(StartPacket); @@ -651,7 +668,7 @@ } /// <summary> - /// Opens the device. + /// Opens the device handles and registers for device removal notification. /// </summary> void OpenDevice() { @@ -687,13 +704,20 @@ throw new Win32Exception(lastError); } - _notifyWindow.RegisterDeviceRemoval(_readHandle.DangerousGetHandle()); + bool success = false; + _readHandle.DangerousAddRef(ref success); + if (success) + _notifyWindow.RegisterDeviceRemoval(_readHandle.DangerousGetHandle()); +#if DEBUG + else + DebugWriteLine("Warning: Failed to initialize device removal notification"); +#endif _deviceAvailable = true; } /// <summary> - /// Close all handles to the device. + /// Close all handles to the device and unregisters device removal notification. /// </summary> void CloseDevice() { @@ -715,6 +739,8 @@ { _notifyWindow.UnregisterDeviceRemoval(); + _readHandle.DangerousRelease(); + CloseHandle(_readHandle); _readHandle.Dispose(); @@ -730,6 +756,9 @@ } } + /// <summary> + /// Called when device arrival is notified. + /// </summary> void OnDeviceArrival() { #if DEBUG @@ -740,6 +769,9 @@ StartReadThread(); InitializeDevice(); } + /// <summary> + /// Called when device removal is notified. + /// </summary> void OnDeviceRemoval() { #if DEBUG @@ -763,15 +795,15 @@ SafeHandle safeWaitHandle = waitHandle.SafeWaitHandle; WaitHandle[] waitHandles = new WaitHandle[] { waitHandle, _stopReadThread }; - IntPtr deviceBufferPtr = IntPtr.Zero; + IntPtr deviceBufferPtr = IntPtr.Zero; + bool success = false; + safeWaitHandle.DangerousAddRef(ref success); + if (!success) + throw new InvalidOperationException("Failed to initialize safe wait handle"); + try { - bool success = false; - safeWaitHandle.DangerousAddRef(ref success); - if (!success) - throw new InvalidOperationException("Failed to initialize safe wait handle"); - IntPtr dangerousWaitHandle = safeWaitHandle.DangerousGetHandle(); DeviceIoOverlapped overlapped = new DeviceIoOverlapped(); @@ -819,7 +851,7 @@ Marshal.Copy(deviceBufferPtr, packetBytes, 0, bytesRead); #if DEBUG - DebugWriteLine("Received data:"); + DebugWrite("Received bytes ({0}): ", bytesRead); DebugDump(packetBytes); #endif @@ -975,7 +1007,7 @@ void WriteSync(byte[] data) { #if DEBUG - DebugWriteLine("WriteSync({0} bytes)", data.Length); + DebugWrite("WriteSync({0}): ", data.Length); DebugDump(data); #endif @@ -1045,8 +1077,6 @@ int[] GetTimingDataFromPacket(byte[] packet) { #if DEBUG - DebugWriteLine("GetTimingDataFromPacket()"); - // TODO: Remove this try/catch block once the IndexOutOfRangeException is corrected... try #endif @@ -1117,7 +1147,7 @@ timingData.Add(len * TimingResolution); #if DEBUG - DebugWriteLine("Received:"); + DebugWrite("Received timing: "); DebugDump(timingData.ToArray()); #endif @@ -1127,7 +1157,7 @@ catch (Exception ex) { DebugWriteLine(ex.ToString()); - DebugWriteLine("Method Input:"); + DebugWrite("Method Input: "); DebugDump(packet); return null; Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DriverVista.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DriverVista.cs 2008-03-19 06:36:43 UTC (rev 1483) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DriverVista.cs 2008-03-19 14:54:17 UTC (rev 1484) @@ -13,7 +13,7 @@ { /// <summary> - /// Driver class for Windows Vista eHome driver. + /// Driver class for the Windows Vista eHome driver. /// </summary> class DriverVista : Driver { @@ -622,14 +622,17 @@ catch (Exception ex) { DebugWriteLine(ex.ToString()); + throw; + } #else catch { -#endif throw; } +#endif finally { + _notifyWindow.UnregisterDeviceArrival(); _notifyWindow.Dispose(); _notifyWindow = null; @@ -666,7 +669,7 @@ if (String.IsNullOrEmpty(Driver.Find(_deviceGuid))) { #if DEBUG - DebugWriteLine("Device not available"); + DebugWriteLine("Device not found"); #endif return; } @@ -681,6 +684,7 @@ catch (Exception ex) { DebugWriteLine(ex.ToString()); + throw; } #else catch @@ -763,7 +767,7 @@ public override void Send(IrCode code, int port) { #if DEBUG - DebugWriteLine("Send()"); + DebugWrite("Send(): "); DebugDump(code.TimingData); #endif @@ -789,6 +793,10 @@ /// </summary> void InitializeDevice() { +#if DEBUG + DebugWriteLine("InitializeDevice()"); +#endif + GetDeviceCapabilities(); GetBlasters(); } @@ -876,7 +884,7 @@ } /// <summary> - /// Opens the device. + /// Opens the device handles and registers for device removal notification. /// </summary> void OpenDevice() { @@ -892,15 +900,24 @@ return; } + int lastError; + _eHomeHandle = CreateFile(_devicePath, CreateFileAccessTypes.GenericRead | CreateFileAccessTypes.GenericWrite, CreateFileShares.None, IntPtr.Zero, CreateFileDisposition.OpenExisting, CreateFileAttributes.Overlapped, IntPtr.Zero); - int lastError = Marshal.GetLastWin32Error(); + lastError = Marshal.GetLastWin32Error(); if (_eHomeHandle.IsInvalid) { _eHomeHandle = null; throw new Win32Exception(lastError); } - _notifyWindow.RegisterDeviceRemoval(_eHomeHandle.DangerousGetHandle()); + bool success = false; + _eHomeHandle.DangerousAddRef(ref success); + if (success) + _notifyWindow.RegisterDeviceRemoval(_eHomeHandle.DangerousGetHandle()); +#if DEBUG + else + DebugWriteLine("Warning: Failed to initialize device removal notification"); +#endif Thread.Sleep(PacketTimeout); // Hopefully improves compatibility with Zalman remote which times out retrieving device capabilities. (2008-01-01) @@ -908,7 +925,7 @@ } /// <summary> - /// Close all handles to the device. + /// Close all handles to the device and unregisters device removal notification. /// </summary> void CloseDevice() { @@ -928,12 +945,17 @@ _notifyWindow.UnregisterDeviceRemoval(); + _eHomeHandle.DangerousRelease(); + CloseHandle(_eHomeHandle); _eHomeHandle.Dispose(); _eHomeHandle = null; } + /// <summary> + /// Called when device arrival is notified. + /// </summary> void OnDeviceArrival() { #if DEBUG @@ -946,6 +968,9 @@ StartReceive(_receivePort, PacketTimeout); StartReadThread(ReadThreadMode.Receiving); } + /// <summary> + /// Called when device removal is notified. + /// </summary> void OnDeviceRemoval() { #if DEBUG @@ -996,7 +1021,7 @@ int[] timingData = GetTimingDataFromPacket(packetBytes); #if DEBUG - DebugWriteLine("Received:"); + DebugWrite("Received timing: "); DebugDump(timingData); #endif Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DriverXP.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DriverXP.cs 2008-03-19 06:36:43 UTC (rev 1483) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DriverXP.cs 2008-03-19 14:54:17 UTC (rev 1484) @@ -235,6 +235,7 @@ #endif finally { + _notifyWindow.UnregisterDeviceArrival(); _notifyWindow.Dispose(); _notifyWindow = null; @@ -256,7 +257,12 @@ try { if (_eHomeHandle == null) - throw new InvalidOperationException("Cannot suspend, device is not active"); + { +#if DEBUG + DebugWriteLine("Warning: Device is not active"); +#endif + return; + } WriteSync(StopPacket); @@ -289,11 +295,18 @@ try { if (String.IsNullOrEmpty(Driver.Find(_deviceGuid))) - throw new InvalidOperationException("Device not available"); + { +#if DEBUG + DebugWriteLine("Device not found"); +#endif + return; + } if (_eHomeHandle != null) - throw new InvalidOperationException("Cannot resume, device is active"); + throw new InvalidOperationException("Cannot resume, device is already active"); + //_notifyWindow.RegisterDeviceArrival(); + OpenDevice(); StartReadThread(); InitializeDevice(); @@ -381,7 +394,7 @@ public override void Send(IrCode code, int port) { #if DEBUG - DebugWriteLine("Send()"); + DebugWrite("Send(): "); DebugDump(code.TimingData); #endif @@ -413,6 +426,10 @@ /// </summary> void InitializeDevice() { +#if DEBUG + DebugWriteLine("InitializeDevice()"); +#endif + WriteSync(ResetPacket); // Added 18-March-2008 to see what SMK devices think of it... WriteSync(StartPacket); @@ -650,7 +667,7 @@ } /// <summary> - /// Opens the device. + /// Opens the device handles and registers for device removal notification. /// </summary> void OpenDevice() { @@ -676,13 +693,20 @@ throw new Win32Exception(lastError); } - _notifyWindow.RegisterDeviceRemoval(_eHomeHandle.DangerousGetHandle()); + bool success = false; + _eHomeHandle.DangerousAddRef(ref success); + if (success) + _notifyWindow.RegisterDeviceRemoval(_eHomeHandle.DangerousGetHandle()); +#if DEBUG + else + DebugWriteLine("Warning: Failed to initialize device removal notification"); +#endif _deviceAvailable = true; } /// <summary> - /// Close all handles to the device. + /// Close all handles to the device and unregisters device removal notification. /// </summary> void CloseDevice() { @@ -702,12 +726,17 @@ _notifyWindow.UnregisterDeviceRemoval(); + _eHomeHandle.DangerousRelease(); + CloseHandle(_eHomeHandle); _eHomeHandle.Dispose(); _eHomeHandle = null; } + /// <summary> + /// Called when device arrival is notified. + /// </summary> void OnDeviceArrival() { #if DEBUG @@ -718,6 +747,9 @@ StartReadThread(); InitializeDevice(); } + /// <summary> + /// Called when device removal is notified. + /// </summary> void OnDeviceRemoval() { #if DEBUG @@ -741,15 +773,15 @@ SafeHandle safeWaitHandle = waitHandle.SafeWaitHandle; WaitHandle[] waitHandles = new WaitHandle[] { waitHandle, _stopReadThread }; - IntPtr deviceBufferPtr = IntPtr.Zero; + IntPtr deviceBufferPtr = IntPtr.Zero; + bool success = false; + safeWaitHandle.DangerousAddRef(ref success); + if (!success) + throw new InvalidOperationException("Failed to initialize safe wait handle"); + try { - bool success = false; - safeWaitHandle.DangerousAddRef(ref success); - if (!success) - throw new InvalidOperationException("Failed to initialize safe wait handle"); - IntPtr dangerousWaitHandle = safeWaitHandle.DangerousGetHandle(); DeviceIoOverlapped overlapped = new DeviceIoOverlapped(); @@ -797,7 +829,7 @@ Marshal.Copy(deviceBufferPtr, packetBytes, 0, bytesRead); #if DEBUG - DebugWriteLine("Received data:"); + DebugWrite("Received bytes ({0}): ", bytesRead); DebugDump(packetBytes); #endif @@ -953,7 +985,7 @@ void WriteSync(byte[] data) { #if DEBUG - DebugWriteLine("WriteSync({0} bytes)", data.Length); + DebugWrite("WriteSync({0}): ", data.Length); DebugDump(data); #endif @@ -1023,8 +1055,6 @@ int[] GetTimingDataFromPacket(byte[] packet) { #if DEBUG - DebugWriteLine("GetTimingDataFromPacket()"); - // TODO: Remove this try/catch block once the IndexOutOfRangeException is corrected... try #endif @@ -1095,7 +1125,7 @@ timingData.Add(len * TimingResolution); #if DEBUG - DebugWriteLine("Received:"); + DebugWrite("Received timing: "); DebugDump(timingData.ToArray()); #endif @@ -1105,7 +1135,7 @@ catch (Exception ex) { DebugWriteLine(ex.ToString()); - DebugWriteLine("Method Input:"); + DebugWrite("Method Input: "); DebugDump(packet); return null; Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/NotifyWindow.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/NotifyWindow.cs 2008-03-19 06:36:43 UTC (rev 1483) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/NotifyWindow.cs 2008-03-19 14:54:17 UTC (rev 1484) @@ -118,7 +118,10 @@ #endregion IDisposable Members #region Methods - + + /// <summary> + /// Creates the window handle. + /// </summary> internal void Create() { if (Handle != IntPtr.Zero) @@ -130,6 +133,9 @@ CreateHandle(Params); } + /// <summary> + /// Destroys the window handle. + /// </summary> void Destroy() { if (Handle == IntPtr.Zero) Modified: trunk/plugins/IR Server Suite/Input Service/Input Service/InputService.cs =================================================================== --- trunk/plugins/IR Server Suite/Input Service/Input Service/InputService.cs 2008-03-19 06:36:43 UTC (rev 1483) +++ trunk/plugins/IR Server Suite/Input Service/Input Service/InputService.cs 2008-03-19 14:54:17 UTC (rev 1484) @@ -539,8 +539,8 @@ #region Resume case PowerBroadcastStatus.ResumeAutomatic: - case PowerBroadcastStatus.ResumeCritical: - case PowerBroadcastStatus.ResumeSuspend: + //case PowerBroadcastStatus.ResumeCritical: + //case PowerBroadcastStatus.ResumeSuspend: IrssLog.Info("Resume from standby ..."); bool resumedTransmit = false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |