From: <che...@us...> - 2009-07-11 16:41:58
|
Revision: 3004 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=3004&view=rev Author: chemelli_sf Date: 2009-07-11 16:41:50 +0000 (Sat, 11 Jul 2009) Log Message: ----------- - Added 3 return status for Detect(): DevicePresent, DeviceNotFound, DeviceException - Handled well known exception where driver is not installed - Removed unused x86 compile platform - Handled x64 plugin load Modified Paths: -------------- trunk/plugins/IR Server Suite/IR Server Suite/Applications/IR Server/Config.cs trunk/plugins/IR Server Suite/IR Server Suite/Applications/IR Server/Program.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Ads Tech PTV-335 Receiver/Ads Tech PTV-335 Receiver.csproj trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Ads Tech PTV-335 Receiver/AdsTechPTV335Receiver.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/CoolCommand Receiver/CoolCommandReceiver.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Direct Input Receiver/Direct Input Receiver.csproj trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Direct Input Receiver/DirectInputReceiver.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FusionRemote Receiver/FusionREMOTE Receiver.csproj trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FusionRemote Receiver/FusionRemoteReceiver.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/PluginBase.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR501 Receiver/IR501 Receiver.csproj trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR501 Receiver/IR501Receiver.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR507 Receiver/IR507 Receiver.csproj trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR507 Receiver/IR507Receiver.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IRTrans Transceiver/IRTrans Transceiver.csproj trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IRTrans Transceiver/IRTransTransceiver.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IgorPlug Receiver/IgorPlug Receiver.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IgorPlug Receiver/IgorPlug Receiver.csproj trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Imon USB Receivers/PluginBaseInterfaces.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/LiveDrive Receiver/LiveDriveReceiver.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/MacMini Receiver/MacMini Receiver.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/MacMini Receiver/MacMini Receiver.csproj trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Microsoft MCE Transceiver.csproj trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/MicrosoftMceTransceiver.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/RC102 Receiver/RC102 Receiver.csproj trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/RC102 Receiver/RC102Receiver.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Technotrend Receiver/Technotrend Receiver.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Technotrend Receiver/Technotrend Receiver.csproj trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver/USB-UIRT Transceiver.csproj trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver/UirtTransceiver.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Wii Remote Receiver/Wii Remote Receiver.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/WinLirc Transceiver/WinLirc Transceiver.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/WinLirc Transceiver/WinLirc Transceiver.csproj trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Windows Message Receiver/Windows Message Receiver.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/X10 Transceiver/X10 Transceiver.csproj trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/X10 Transceiver/X10Transceiver.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/XBCDRC Receiver/XBCDRC Receiver.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/XBCDRC Receiver/XBCDRC Receiver.csproj trunk/plugins/IR Server Suite/IR Server Suite/IR Server Suite.sln trunk/plugins/IR Server Suite/IR Server Suite/Input Service/Input Service/Program.cs trunk/plugins/IR Server Suite/IR Server Suite/Input Service/Input Service Configuration/Config.cs trunk/plugins/IR Server Suite/IR Server Suite/Input Service/Input Service Configuration/Program.cs Modified: trunk/plugins/IR Server Suite/IR Server Suite/Applications/IR Server/Config.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/Applications/IR Server/Config.cs 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/Applications/IR Server/Config.cs 2009-07-11 16:41:50 UTC (rev 3004) @@ -29,9 +29,9 @@ using SourceGrid; using SourceGrid.Cells; using SourceGrid.Cells.Controllers; -using Button=SourceGrid.Cells.Button; -using CheckBox=SourceGrid.Cells.CheckBox; -using ColumnHeader=SourceGrid.Cells.ColumnHeader; +using Button = SourceGrid.Cells.Button; +using CheckBox = SourceGrid.Cells.CheckBox; +using ColumnHeader = SourceGrid.Cells.ColumnHeader; namespace IRServer { @@ -217,8 +217,8 @@ private void buttonClickEvent_Executed(object sender, EventArgs e) { - CellContext context = (CellContext) sender; - Button cell = (Button) context.Cell; + CellContext context = (CellContext)sender; + Button cell = (Button)context.Cell; try { @@ -236,8 +236,8 @@ private void TransmitChanged(object sender, EventArgs e) { - CellContext context = (CellContext) sender; - CheckBox cell = (CheckBox) context.Cell; + CellContext context = (CellContext)sender; + CheckBox cell = (CheckBox)context.Cell; if (cell.Checked != true) return; @@ -256,8 +256,8 @@ private void PluginDoubleClick(object sender, EventArgs e) { - CellContext context = (CellContext) sender; - Cell cell = (Cell) context.Cell; + CellContext context = (CellContext)sender; + Cell cell = (Cell)context.Cell; CheckBox checkBoxReceive = gridPlugins[cell.Row.Index, ColReceive] as CheckBox; if (checkBoxReceive != null) @@ -406,31 +406,46 @@ CheckBox checkBox; for (int row = 1; row < gridPlugins.RowsCount; row++) { + PluginBase plugin = gridPlugins.Rows[row].Tag as PluginBase; + try { - PluginBase plugin = gridPlugins.Rows[row].Tag as PluginBase; + if (plugin == null) + throw new InvalidOperationException(String.Format("Invalid grid data, row {0} contains no plugin in tag", + row)); - IrssLog.Info("Checking: {0}", plugin.Name); - bool detected = plugin.Detect(); + PluginBase.DetectionResult detected = plugin.Detect(); - if (detected) - IrssLog.Info("Found: {0}", plugin.Name); + if (detected == PluginBase.DetectionResult.DevicePresent) + { + IrssLog.Info("Plugin {0}: detected", plugin.Name); + } + if (detected == PluginBase.DetectionResult.DeviceException) + { + IrssLog.Warn("Plugin {0}: exception during Detect()", plugin.Name); + } // Receive checkBox = gridPlugins[row, ColReceive] as CheckBox; if (checkBox != null) - checkBox.Checked = detected; + checkBox.Checked = (detected == PluginBase.DetectionResult.DevicePresent ? true : false); // Transmit checkBox = gridPlugins[row, ColTransmit] as CheckBox; if (checkBox != null) - checkBox.Checked = detected; + checkBox.Checked = (detected == PluginBase.DetectionResult.DevicePresent ? true : false); } + catch (BadImageFormatException) + { + IrssLog.Warn("Plugin {0}: not available on current OS architecture ({1})", plugin.Name, IntPtr.Size == 8 ? "x64" : "x86"); + } catch (Exception ex) { IrssLog.Error(ex); } } + + IrssLog.Info("Input Plugins detection completed..."); } private void Advanced() Modified: trunk/plugins/IR Server Suite/IR Server Suite/Applications/IR Server/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/Applications/IR Server/Program.cs 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/Applications/IR Server/Program.cs 2009-07-11 16:41:50 UTC (rev 3004) @@ -187,7 +187,7 @@ { try { - if ((plugin is IRemoteReceiver || plugin is IKeyboardReceiver || plugin is IMouseReceiver) && plugin.Detect()) + if ((plugin is IRemoteReceiver || plugin is IKeyboardReceiver || plugin is IMouseReceiver) && plugin.Detect() == PluginBase.DetectionResult.DevicePresent) receivers.Add(plugin.Name); } catch (Exception ex) @@ -220,7 +220,7 @@ { try { - if (plugin is ITransmitIR && plugin.Detect()) + if (plugin is ITransmitIR && plugin.Detect() == PluginBase.DetectionResult.DevicePresent) blasters.Add(plugin.Name); } catch (Exception ex) Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Ads Tech PTV-335 Receiver/Ads Tech PTV-335 Receiver.csproj =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Ads Tech PTV-335 Receiver/Ads Tech PTV-335 Receiver.csproj 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Ads Tech PTV-335 Receiver/Ads Tech PTV-335 Receiver.csproj 2009-07-11 16:41:50 UTC (rev 3004) @@ -2,7 +2,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>8.0.50727</ProductVersion> + <ProductVersion>9.0.30729</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{E146C2D8-6842-46C5-B2A9-AFA9D6F1A3BB}</ProjectGuid> <OutputType>Library</OutputType> @@ -52,6 +52,10 @@ </Compile> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\Common\IrssUtils\IrssUtils.csproj"> + <Project>{CA15769C-232E-4CA7-94FD-206A06CA3ABB}</Project> + <Name>IrssUtils</Name> + </ProjectReference> <ProjectReference Include="..\IR Server Plugin Interface\IR Server Plugin Interface.csproj"> <Project>{D8B3D28F-62CE-4CA7-86CE-B7EAD614A94C}</Project> <Name>IR Server Plugin Interface</Name> Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Ads Tech PTV-335 Receiver/AdsTechPTV335Receiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Ads Tech PTV-335 Receiver/AdsTechPTV335Receiver.cs 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Ads Tech PTV-335 Receiver/AdsTechPTV335Receiver.cs 2009-07-11 16:41:50 UTC (rev 3004) @@ -25,6 +25,7 @@ using System.Runtime.InteropServices; using System.Threading; using InputService.Plugin.Properties; +using IrssUtils; namespace InputService.Plugin { @@ -125,21 +126,28 @@ #endregion /// <summary> - /// Detect the presence of this device. Devices that cannot be detected will always return false. + /// Detect the presence of this device. /// </summary> - /// <returns> - /// <c>true</c> if the device is present, otherwise <c>false</c>. - /// </returns> - public override bool Detect() + public override DetectionResult Detect() { try { - return (Init() != 0); + if (Init() != 0) + { + return DetectionResult.DevicePresent; + } } - catch + catch (DllNotFoundException) { - return false; + return DetectionResult.DeviceNotFound; } + catch (Exception ex) + { + IrssLog.Error("{0} exception: {1} type: {2}", Name, ex.Message, ex.GetType()); + return DetectionResult.DeviceException; + } + + return DetectionResult.DeviceNotFound; } /// <summary> Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/CoolCommand Receiver/CoolCommandReceiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/CoolCommand Receiver/CoolCommandReceiver.cs 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/CoolCommand Receiver/CoolCommandReceiver.cs 2009-07-11 16:41:50 UTC (rev 3004) @@ -106,22 +106,12 @@ } /// <summary> - /// Detect the presence of this device. Devices that cannot be detected will always return false. + /// Detect the presence of this device. /// </summary> - /// <returns> - /// <c>true</c> if the device is present, otherwise <c>false</c>. - /// </returns> - public override bool Detect() + public override DetectionResult Detect() { // TODO: Add CoolCommand detection - try - { - return false; - } - catch - { - return false; - } + return DetectionResult.DeviceNotFound; } /// <summary> Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Direct Input Receiver/Direct Input Receiver.csproj =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Direct Input Receiver/Direct Input Receiver.csproj 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Direct Input Receiver/Direct Input Receiver.csproj 2009-07-11 16:41:50 UTC (rev 3004) @@ -2,7 +2,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>8.0.50727</ProductVersion> + <ProductVersion>9.0.30729</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{732CDF64-D047-4D3C-91DA-E2FF27D84179}</ProjectGuid> <OutputType>Library</OutputType> @@ -75,6 +75,10 @@ </Compile> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\Common\IrssUtils\IrssUtils.csproj"> + <Project>{CA15769C-232E-4CA7-94FD-206A06CA3ABB}</Project> + <Name>IrssUtils</Name> + </ProjectReference> <ProjectReference Include="..\IR Server Plugin Interface\IR Server Plugin Interface.csproj"> <Project>{D8B3D28F-62CE-4CA7-86CE-B7EAD614A94C}</Project> <Name>IR Server Plugin Interface</Name> Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Direct Input Receiver/DirectInputReceiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Direct Input Receiver/DirectInputReceiver.cs 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Direct Input Receiver/DirectInputReceiver.cs 2009-07-11 16:41:50 UTC (rev 3004) @@ -27,6 +27,7 @@ using System.Windows.Forms; using System.Xml; using InputService.Plugin.Properties; +using IrssUtils; using Microsoft.DirectX.DirectInput; namespace InputService.Plugin @@ -231,23 +232,26 @@ #endregion /// <summary> - /// Detect the presence of this device. Devices that cannot be detected will always return false. + /// Detect the presence of this device. /// </summary> - /// <returns> - /// true if the device is present, otherwise false. - /// </returns> - public override bool Detect() + public override DetectionResult Detect() { try { InitDeviceList(); - return (_deviceList.Count != 0); + if (_deviceList.Count != 0) + { + return DetectionResult.DevicePresent; + } } - catch + catch (Exception ex) { - return false; + IrssLog.Error("{0} exception: {1}", Name, ex.Message); + return DetectionResult.DeviceException; } + + return DetectionResult.DeviceNotFound; } /// <summary> Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FusionRemote Receiver/FusionREMOTE Receiver.csproj =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FusionRemote Receiver/FusionREMOTE Receiver.csproj 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FusionRemote Receiver/FusionREMOTE Receiver.csproj 2009-07-11 16:41:50 UTC (rev 3004) @@ -2,7 +2,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>8.0.50727</ProductVersion> + <ProductVersion>9.0.30729</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{9FDD649E-0502-4FED-9AC1-AA0346394375}</ProjectGuid> <OutputType>Library</OutputType> @@ -58,6 +58,10 @@ </Compile> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\Common\IrssUtils\IrssUtils.csproj"> + <Project>{CA15769C-232E-4CA7-94FD-206A06CA3ABB}</Project> + <Name>IrssUtils</Name> + </ProjectReference> <ProjectReference Include="..\IR Server Plugin Interface\IR Server Plugin Interface.csproj"> <Project>{D8B3D28F-62CE-4CA7-86CE-B7EAD614A94C}</Project> <Name>IR Server Plugin Interface</Name> Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FusionRemote Receiver/FusionRemoteReceiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FusionRemote Receiver/FusionRemoteReceiver.cs 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FusionRemote Receiver/FusionRemoteReceiver.cs 2009-07-11 16:41:50 UTC (rev 3004) @@ -26,6 +26,7 @@ using System.IO; using System.Runtime.InteropServices; using InputService.Plugin.Properties; +using IrssUtils; using Microsoft.Win32.SafeHandles; namespace InputService.Plugin @@ -289,12 +290,9 @@ } /// <summary> - /// Detect the presence of this device. Devices that cannot be detected will always return false. + /// Detect the presence of this device. /// </summary> - /// <returns> - /// <c>true</c> if the device is present, otherwise <c>false</c>. - /// </returns> - public override bool Detect() + public override DetectionResult Detect() { try { @@ -303,12 +301,18 @@ string devicePath = FindDevice(hidGuid, DeviceID); - return (devicePath != null); + if (devicePath != null) + { + return DetectionResult.DevicePresent; + } } - catch + catch (Exception ex) { - return false; + IrssLog.Error("{0} exception: {1}", Name, ex.Message); + return DetectionResult.DeviceException; } + + return DetectionResult.DeviceNotFound; } /// <summary> Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/PluginBase.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/PluginBase.cs 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/PluginBase.cs 2009-07-11 16:41:50 UTC (rev 3004) @@ -79,16 +79,35 @@ #endregion Properties + #region Enums + ///<summary> + /// Store the result of Detect() in PluginBase + ///</summary> + public enum DetectionResult + { + ///<summary> + /// Device is not installed + ///</summary> + DeviceNotFound, + ///<summary> + /// Device is working + ///</summary> + DevicePresent, + ///<summary> + /// Init call fails + ///</summary> + DeviceException + } + #endregion + #region Methods /// <summary> - /// Detect the presence of this device. Devices that cannot be detected will always return false. - /// This method should not throw exceptions. + /// Detect the presence of this device. /// </summary> - /// <returns><c>true</c> if the device is present, otherwise <c>false</c>.</returns> - public virtual bool Detect() + public virtual DetectionResult Detect() { - return false; + return DetectionResult.DeviceNotFound; } /// <summary> Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR501 Receiver/IR501 Receiver.csproj =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR501 Receiver/IR501 Receiver.csproj 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR501 Receiver/IR501 Receiver.csproj 2009-07-11 16:41:50 UTC (rev 3004) @@ -2,7 +2,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>8.0.50727</ProductVersion> + <ProductVersion>9.0.30729</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{C7BF555E-638F-4E1B-9D5A-D2D226C77676}</ProjectGuid> <OutputType>Library</OutputType> @@ -52,6 +52,10 @@ </Compile> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\Common\IrssUtils\IrssUtils.csproj"> + <Project>{CA15769C-232E-4CA7-94FD-206A06CA3ABB}</Project> + <Name>IrssUtils</Name> + </ProjectReference> <ProjectReference Include="..\IR Server Plugin Interface\IR Server Plugin Interface.csproj"> <Project>{D8B3D28F-62CE-4CA7-86CE-B7EAD614A94C}</Project> <Name>IR Server Plugin Interface</Name> Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR501 Receiver/IR501Receiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR501 Receiver/IR501Receiver.cs 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR501 Receiver/IR501Receiver.cs 2009-07-11 16:41:50 UTC (rev 3004) @@ -26,6 +26,7 @@ using System.IO; using System.Runtime.InteropServices; using InputService.Plugin.Properties; +using IrssUtils; using Microsoft.Win32.SafeHandles; namespace InputService.Plugin @@ -249,12 +250,9 @@ } /// <summary> - /// Detect the presence of this device. Devices that cannot be detected will always return false. + /// Detect the presence of this device. /// </summary> - /// <returns> - /// <c>true</c> if the device is present, otherwise <c>false</c>. - /// </returns> - public override bool Detect() + public override DetectionResult Detect() { try { @@ -263,12 +261,22 @@ string devicePath = FindDevice(guid); - return (devicePath != null); + if (devicePath != null) + { + return DetectionResult.DevicePresent; + } } - catch + catch (FileNotFoundException) { - return false; + //No error if driver is not installed. Handled using default return "DeviceNotFound" } + catch (Exception ex) + { + IrssLog.Error("{0} exception: {1}", Name, ex.Message); + return DetectionResult.DeviceException; + } + + return DetectionResult.DeviceNotFound; } /// <summary> Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR507 Receiver/IR507 Receiver.csproj =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR507 Receiver/IR507 Receiver.csproj 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR507 Receiver/IR507 Receiver.csproj 2009-07-11 16:41:50 UTC (rev 3004) @@ -2,7 +2,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>8.0.50727</ProductVersion> + <ProductVersion>9.0.30729</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{1DD4B652-DBF4-47E2-B46C-C810EEE3B7C3}</ProjectGuid> <OutputType>Library</OutputType> @@ -57,6 +57,10 @@ <Compile Include="ReceiverWindow.cs" /> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\Common\IrssUtils\IrssUtils.csproj"> + <Project>{CA15769C-232E-4CA7-94FD-206A06CA3ABB}</Project> + <Name>IrssUtils</Name> + </ProjectReference> <ProjectReference Include="..\IR Server Plugin Interface\IR Server Plugin Interface.csproj"> <Project>{D8B3D28F-62CE-4CA7-86CE-B7EAD614A94C}</Project> <Name>IR Server Plugin Interface</Name> Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR507 Receiver/IR507Receiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR507 Receiver/IR507Receiver.cs 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR507 Receiver/IR507Receiver.cs 2009-07-11 16:41:50 UTC (rev 3004) @@ -26,6 +26,7 @@ using System.Runtime.InteropServices; using System.Windows.Forms; using InputService.Plugin.Properties; +using IrssUtils; namespace InputService.Plugin { @@ -120,7 +121,8 @@ private struct DeviceInterfaceDetailData { public int Size; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string DevicePath; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + public string DevicePath; } #endregion @@ -203,12 +205,9 @@ } /// <summary> - /// Detect the presence of this device. Devices that cannot be detected will always return false. + /// Detect the presence of this device. /// </summary> - /// <returns> - /// <c>true</c> if the device is present, otherwise <c>false</c>. - /// </returns> - public override bool Detect() + public override DetectionResult Detect() { try { @@ -217,12 +216,26 @@ string devicePath = FindDevice(guid); - return (devicePath != null); + if (devicePath != null) + { + return DetectionResult.DevicePresent; + } } - catch + catch (Win32Exception ex) { - return false; + if (ex.NativeErrorCode != 2) + { + IrssLog.Error("{0} exception: {1}", Name, ex.NativeErrorCode); + return DetectionResult.DeviceException; + } } + catch (Exception ex) + { + IrssLog.Error("{0} exception: {1} type: {2}", Name, ex.Message, ex.GetType()); + return DetectionResult.DeviceException; + } + + return DetectionResult.DeviceNotFound; } /// <summary> @@ -281,7 +294,7 @@ private bool RegisterForRawInput(RawInput.RAWINPUTDEVICE[] devices) { - return RawInput.RegisterRawInputDevices(devices, (uint) devices.Length, (uint) Marshal.SizeOf(devices[0])); + return RawInput.RegisterRawInputDevices(devices, (uint)devices.Length, (uint)Marshal.SizeOf(devices[0])); } private void ProcMessage(ref Message m) @@ -292,9 +305,9 @@ uint dwSize = 0; RawInput.GetRawInputData(m.LParam, RawInput.RawInputCommand.Input, IntPtr.Zero, ref dwSize, - (uint) Marshal.SizeOf(typeof (RawInput.RAWINPUTHEADER))); + (uint)Marshal.SizeOf(typeof(RawInput.RAWINPUTHEADER))); - IntPtr buffer = Marshal.AllocHGlobal((int) dwSize); + IntPtr buffer = Marshal.AllocHGlobal((int)dwSize); try { if (buffer == IntPtr.Zero) @@ -302,14 +315,14 @@ if ( RawInput.GetRawInputData(m.LParam, RawInput.RawInputCommand.Input, buffer, ref dwSize, - (uint) Marshal.SizeOf(typeof (RawInput.RAWINPUTHEADER))) != dwSize) + (uint)Marshal.SizeOf(typeof(RawInput.RAWINPUTHEADER))) != dwSize) return; - RawInput.RAWINPUT raw = (RawInput.RAWINPUT) Marshal.PtrToStructure(buffer, typeof (RawInput.RAWINPUT)); + RawInput.RAWINPUT raw = (RawInput.RAWINPUT)Marshal.PtrToStructure(buffer, typeof(RawInput.RAWINPUT)); if (raw.header.dwType == RawInput.RawInputType.HID) { - int offset = Marshal.SizeOf(typeof (RawInput.RAWINPUTHEADER)) + Marshal.SizeOf(typeof (RawInput.RAWHID)); + int offset = Marshal.SizeOf(typeof(RawInput.RAWINPUTHEADER)) + Marshal.SizeOf(typeof(RawInput.RAWHID)); byte[] bRawData = new byte[offset + raw.hid.dwSizeHid]; Marshal.Copy(buffer, bRawData, 0, bRawData.Length); @@ -351,7 +364,7 @@ string devicePath = null; - for (int deviceIndex = 0;; deviceIndex++) + for (int deviceIndex = 0; ; deviceIndex++) { DeviceInfoData deviceInfoData = new DeviceInfoData(); deviceInfoData.Size = Marshal.SizeOf(deviceInfoData); Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IRTrans Transceiver/IRTrans Transceiver.csproj =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IRTrans Transceiver/IRTrans Transceiver.csproj 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IRTrans Transceiver/IRTrans Transceiver.csproj 2009-07-11 16:41:50 UTC (rev 3004) @@ -2,7 +2,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>8.0.50727</ProductVersion> + <ProductVersion>9.0.30729</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{883913F6-F4A7-4DE2-846A-C2102FAF499E}</ProjectGuid> <OutputType>Library</OutputType> @@ -76,6 +76,10 @@ </EmbeddedResource> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\Common\IrssUtils\IrssUtils.csproj"> + <Project>{CA15769C-232E-4CA7-94FD-206A06CA3ABB}</Project> + <Name>IrssUtils</Name> + </ProjectReference> <ProjectReference Include="..\IR Server Plugin Interface\IR Server Plugin Interface.csproj"> <Project>{D8B3D28F-62CE-4CA7-86CE-B7EAD614A94C}</Project> <Name>IR Server Plugin Interface</Name> Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IRTrans Transceiver/IRTransTransceiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IRTrans Transceiver/IRTransTransceiver.cs 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IRTrans Transceiver/IRTransTransceiver.cs 2009-07-11 16:41:50 UTC (rev 3004) @@ -29,6 +29,7 @@ using System.Windows.Forms; using System.Xml; using InputService.Plugin.Properties; +using IrssUtils; namespace InputService.Plugin { @@ -308,12 +309,9 @@ #endregion /// <summary> - /// Detect the presence of this device. Devices that cannot be detected will always return false. + /// Detect the presence of this device. /// </summary> - /// <returns> - /// <c>true</c> if the device is present, otherwise <c>false</c>. - /// </returns> - public override bool Detect() + public override DetectionResult Detect() { try { @@ -322,14 +320,16 @@ if (Connect(_irTransServerAddress, _irTransServerPort)) { _socket.Close(); - return true; + return DetectionResult.DevicePresent; } } - catch + catch (Exception ex) { + IrssLog.Error("{0} exception: {1}", Name, ex.Message); + return DetectionResult.DeviceException; } - return false; + return DetectionResult.DeviceNotFound; } /// <summary> Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IgorPlug Receiver/IgorPlug Receiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IgorPlug Receiver/IgorPlug Receiver.cs 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IgorPlug Receiver/IgorPlug Receiver.cs 2009-07-11 16:41:50 UTC (rev 3004) @@ -28,6 +28,7 @@ using System.Runtime.InteropServices; using System.Threading; using InputService.Plugin.Properties; +using IrssUtils; using Microsoft.Win32.SafeHandles; namespace InputService.Plugin @@ -226,11 +227,9 @@ } /// <summary> - /// Detect the presence of this device. Devices that cannot be detected will always return false. - /// This method should not throw exceptions. + /// Detect the presence of this device. /// </summary> - /// <returns><c>true</c> if the device is present, otherwise <c>false</c>.</returns> - public override bool Detect() + public override DetectionResult Detect() { try { @@ -241,17 +240,19 @@ IntPtr.Zero); int lastError = Marshal.GetLastWin32Error(); - if (deviceHandle.IsInvalid) - throw new Win32Exception(lastError, "Failed to open device"); - - deviceHandle.Dispose(); - - return true; + if (!deviceHandle.IsInvalid) + { + deviceHandle.Dispose(); + return DetectionResult.DevicePresent; + } } - catch + catch (Exception ex) { - return false; + IrssLog.Error("{0} exception: {1}", Name, ex.Message); + return DetectionResult.DeviceException; } + + return DetectionResult.DeviceNotFound; } /// <summary> @@ -262,7 +263,7 @@ DebugOpen("IgorPlug Receiver.log"); DebugWriteLine("Start()"); - if (!Detect()) + if (Detect() != DetectionResult.DevicePresent) throw new InvalidOperationException("IgorPlug not found"); _readThread = new Thread(ReadThread); @@ -415,7 +416,7 @@ foreach (byte dataByte in data) { - timingData.Add((int) Math.Round(dataByte * TimeCodeMultiplier * multiplier)); + timingData.Add((int)Math.Round(dataByte * TimeCodeMultiplier * multiplier)); multiplier *= -1; } @@ -651,9 +652,9 @@ { foreach (object item in array) { - if (item is byte) DebugWrite("{0:X2}", (byte) item); - else if (item is ushort) DebugWrite("{0:X4}", (ushort) item); - else if (item is int) DebugWrite("{1}{0}", (int) item, (int) item > 0 ? "+" : String.Empty); + if (item is byte) DebugWrite("{0:X2}", (byte)item); + else if (item is ushort) DebugWrite("{0:X4}", (ushort)item); + else if (item is int) DebugWrite("{1}{0}", (int)item, (int)item > 0 ? "+" : String.Empty); else DebugWrite("{0}", item); DebugWrite(", "); Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IgorPlug Receiver/IgorPlug Receiver.csproj =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IgorPlug Receiver/IgorPlug Receiver.csproj 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IgorPlug Receiver/IgorPlug Receiver.csproj 2009-07-11 16:41:50 UTC (rev 3004) @@ -2,7 +2,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>8.0.50727</ProductVersion> + <ProductVersion>9.0.30729</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{A4023992-CCD6-461E-8E14-219A496734C5}</ProjectGuid> <OutputType>Library</OutputType> @@ -61,6 +61,10 @@ <Compile Include="RemoteDetectionData.cs" /> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\Common\IrssUtils\IrssUtils.csproj"> + <Project>{CA15769C-232E-4CA7-94FD-206A06CA3ABB}</Project> + <Name>IrssUtils</Name> + </ProjectReference> <ProjectReference Include="..\IR Server Plugin Interface\IR Server Plugin Interface.csproj"> <Project>{D8B3D28F-62CE-4CA7-86CE-B7EAD614A94C}</Project> <Name>IR Server Plugin Interface</Name> Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Imon USB Receivers/PluginBaseInterfaces.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Imon USB Receivers/PluginBaseInterfaces.cs 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Imon USB Receivers/PluginBaseInterfaces.cs 2009-07-11 16:41:50 UTC (rev 3004) @@ -57,12 +57,9 @@ } /// <summary> - /// Detect the presence of iMon devices. Devices that cannot be detected will always return false. + /// Detect the presence of iMon devices. /// </summary> - /// <returns> - /// <c>true</c> if a DOS or HID device is present, otherwise <c>false</c>. - /// </returns> - public override bool Detect() + public override DetectionResult Detect() { DebugWriteLine("Detect()"); bool HasDOS = Detect_DOS(); @@ -70,18 +67,18 @@ { _DriverMode = DeviceType.DOS; DebugWriteLine("Detect(): completed - found DOS device"); - return true; + return DetectionResult.DevicePresent; } bool HasHID = Detect_HID(); if (HasHID) { _DriverMode = DeviceType.HID; DebugWriteLine("Detect(): completed - found HID device"); - return true; + return DetectionResult.DevicePresent; } _DriverMode = DeviceType.None; DebugWriteLine("Detect(): completed - device not found"); - return false; + return DetectionResult.DeviceNotFound; } /// <summary> Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/LiveDrive Receiver/LiveDriveReceiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/LiveDrive Receiver/LiveDriveReceiver.cs 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/LiveDrive Receiver/LiveDriveReceiver.cs 2009-07-11 16:41:50 UTC (rev 3004) @@ -238,14 +238,13 @@ #endregion /// <summary> - /// Detect the presence of this device. Devices that cannot be detected will always return false. + /// Detect the presence of this device. /// </summary> - /// <returns> - /// <c>true</c> if the device is present, otherwise <c>false</c>. - /// </returns> - public override bool Detect() + public override DetectionResult Detect() { - return false; + // TODO: Add LiveDrive detection + + return DetectionResult.DeviceNotFound; } /// <summary> Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/MacMini Receiver/MacMini Receiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/MacMini Receiver/MacMini Receiver.cs 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/MacMini Receiver/MacMini Receiver.cs 2009-07-11 16:41:50 UTC (rev 3004) @@ -26,6 +26,7 @@ using System.IO; using System.Runtime.InteropServices; using InputService.Plugin.Properties; +using IrssUtils; using Microsoft.Win32.SafeHandles; namespace InputService.Plugin @@ -41,9 +42,9 @@ private const string DevicePathVidPid = "vid_045e&pid_0284"; //const string DeviceGuid = "{9DE464EB-5DAC-4498-88BC-5010CFD2F724}"; - private static readonly byte[] FlatCode = new byte[] {0x25, 0x87, 0xE0}; - private static readonly byte[] KeyCodeTemplate = new byte[] {0x25, 0x87, 0xEE, 0xFF, 0xFF}; - private static readonly byte[] RepeatCode = new byte[] {0x26, 0x00, 0x00, 0x00, 0x00}; + private static readonly byte[] FlatCode = new byte[] { 0x25, 0x87, 0xE0 }; + private static readonly byte[] KeyCodeTemplate = new byte[] { 0x25, 0x87, 0xEE, 0xFF, 0xFF }; + private static readonly byte[] RepeatCode = new byte[] { 0x26, 0x00, 0x00, 0x00, 0x00 }; #endregion Constants @@ -154,7 +155,8 @@ private struct DeviceInterfaceDetailData { public int Size; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string DevicePath; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + public string DevicePath; } #endregion @@ -304,12 +306,9 @@ } /// <summary> - /// Detect the presence of this device. Devices that cannot be detected will always return false. + /// Detect the presence of this device. /// </summary> - /// <returns> - /// <c>true</c> if the device is present, otherwise <c>false</c>. - /// </returns> - public override bool Detect() + public override DetectionResult Detect() { try { @@ -318,12 +317,26 @@ string devicePath = FindDevice(guid); - return (devicePath != null); + if (devicePath != null) + { + return DetectionResult.DevicePresent; + } } - catch + catch (Win32Exception ex) { - return false; + if (ex.NativeErrorCode != 13) + { + IrssLog.Error("{0} exception: {1}", Name, ex.NativeErrorCode); + return DetectionResult.DeviceException; + } } + catch (Exception ex) + { + IrssLog.Error("{0} exception: {1} type: {2}", Name, ex.Message, ex.GetType()); + return DetectionResult.DeviceException; + } + + return DetectionResult.DeviceNotFound; } /// <summary> @@ -410,7 +423,7 @@ string devicePath = null; - for (int deviceIndex = 0;; deviceIndex++) + for (int deviceIndex = 0; ; deviceIndex++) { DeviceInfoData deviceInfoData = new DeviceInfoData(); deviceInfoData.Size = Marshal.SizeOf(deviceInfoData); Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/MacMini Receiver/MacMini Receiver.csproj =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/MacMini Receiver/MacMini Receiver.csproj 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/MacMini Receiver/MacMini Receiver.csproj 2009-07-11 16:41:50 UTC (rev 3004) @@ -2,7 +2,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>8.0.50727</ProductVersion> + <ProductVersion>9.0.30729</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{FCE5308F-C451-4113-B7F2-BB6212EA7FAD}</ProjectGuid> <OutputType>Library</OutputType> @@ -52,6 +52,10 @@ </Compile> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\Common\IrssUtils\IrssUtils.csproj"> + <Project>{CA15769C-232E-4CA7-94FD-206A06CA3ABB}</Project> + <Name>IrssUtils</Name> + </ProjectReference> <ProjectReference Include="..\IR Server Plugin Interface\IR Server Plugin Interface.csproj"> <Project>{D8B3D28F-62CE-4CA7-86CE-B7EAD614A94C}</Project> <Name>IR Server Plugin Interface</Name> Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Microsoft MCE Transceiver.csproj =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Microsoft MCE Transceiver.csproj 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Microsoft MCE Transceiver.csproj 2009-07-11 16:41:50 UTC (rev 3004) @@ -2,7 +2,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>8.0.50727</ProductVersion> + <ProductVersion>9.0.30729</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{BABC30EB-7D0F-4398-9FCB-E517EA8D2AA9}</ProjectGuid> <OutputType>Library</OutputType> @@ -90,6 +90,10 @@ </EmbeddedResource> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\Common\IrssUtils\IrssUtils.csproj"> + <Project>{CA15769C-232E-4CA7-94FD-206A06CA3ABB}</Project> + <Name>IrssUtils</Name> + </ProjectReference> <ProjectReference Include="..\IR Server Plugin Interface\IR Server Plugin Interface.csproj"> <Project>{D8B3D28F-62CE-4CA7-86CE-B7EAD614A94C}</Project> <Name>IR Server Plugin Interface</Name> Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/MicrosoftMceTransceiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/MicrosoftMceTransceiver.cs 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/MicrosoftMceTransceiver.cs 2009-07-11 16:41:50 UTC (rev 3004) @@ -30,6 +30,7 @@ using System.Windows.Forms; using System.Xml; using InputService.Plugin.Properties; +using IrssUtils; using Microsoft.Win32; namespace InputService.Plugin @@ -341,24 +342,27 @@ #endregion /// <summary> - /// Detect the presence of this device. Devices that cannot be detected will always return false. + /// Detect the presence of this device. /// </summary> - /// <returns> - /// <c>true</c> if the device is present, otherwise <c>false</c>. - /// </returns> - public override bool Detect() + public override DetectionResult Detect() { try { Guid deviceGuid; string devicePath; - return FindDevice(out deviceGuid, out devicePath); + if (FindDevice(out deviceGuid, out devicePath)) + { + return DetectionResult.DevicePresent; + } } - catch + catch(Exception ex) { - return false; + IrssLog.Error("{0} exception: {1}", Name, ex.Message); + return DetectionResult.DeviceException; } + + return DetectionResult.DeviceNotFound; } /// <summary> Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/RC102 Receiver/RC102 Receiver.csproj =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/RC102 Receiver/RC102 Receiver.csproj 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/RC102 Receiver/RC102 Receiver.csproj 2009-07-11 16:41:50 UTC (rev 3004) @@ -2,7 +2,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>8.0.50727</ProductVersion> + <ProductVersion>9.0.30729</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{A2702ACF-C59E-4564-8A4A-5CBFF21C1E66}</ProjectGuid> <OutputType>Library</OutputType> @@ -52,6 +52,10 @@ <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\Common\IrssUtils\IrssUtils.csproj"> + <Project>{CA15769C-232E-4CA7-94FD-206A06CA3ABB}</Project> + <Name>IrssUtils</Name> + </ProjectReference> <ProjectReference Include="..\IR Server Plugin Interface\IR Server Plugin Interface.csproj"> <Project>{D8B3D28F-62CE-4CA7-86CE-B7EAD614A94C}</Project> <Name>IR Server Plugin Interface</Name> Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/RC102 Receiver/RC102Receiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/RC102 Receiver/RC102Receiver.cs 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/RC102 Receiver/RC102Receiver.cs 2009-07-11 16:41:50 UTC (rev 3004) @@ -26,6 +26,7 @@ using System.IO; using System.Runtime.InteropServices; using InputService.Plugin.Properties; +using IrssUtils; using Microsoft.Win32.SafeHandles; namespace InputService.Plugin @@ -252,12 +253,9 @@ } /// <summary> - /// Detect the presence of this device. Devices that cannot be detected will always return false. + /// Detect the presence of this device. /// </summary> - /// <returns> - /// <c>true</c> if the device is present, otherwise <c>false</c>. - /// </returns> - public override bool Detect() + public override DetectionResult Detect() { try { @@ -266,12 +264,18 @@ string devicePath = FindDevice(guid); - return (devicePath != null); + if (devicePath != null) + { + return DetectionResult.DevicePresent; + } } - catch + catch (Exception ex) { - return false; + IrssLog.Error("{0} exception: {1}", Name, ex.Message); + return DetectionResult.DeviceException; } + + return DetectionResult.DeviceNotFound; } /// <summary> Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Technotrend Receiver/Technotrend Receiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Technotrend Receiver/Technotrend Receiver.cs 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Technotrend Receiver/Technotrend Receiver.cs 2009-07-11 16:41:50 UTC (rev 3004) @@ -25,6 +25,7 @@ using System.Drawing; using System.Runtime.InteropServices; using InputService.Plugin.Properties; +using IrssUtils; namespace InputService.Plugin { @@ -303,10 +304,9 @@ } /// <summary> - /// Detect the presence of this device. Devices that cannot be detected will always return false. + /// Detect the presence of this device. /// </summary> - /// <returns><c>true</c> if the device is present, otherwise <c>false</c>.</returns> - public override bool Detect() + public override DetectionResult Detect() { IntPtr handle; TYPE_RET_VAL error; @@ -327,7 +327,7 @@ bdaapiClose(handle); if (error == TYPE_RET_VAL.RET_SUCCESS) - return true; + return DetectionResult.DevicePresent; } } catch @@ -337,11 +337,13 @@ } } } - catch + catch (Exception ex) { + IrssLog.Error("{0} exception: {1}", Name, ex.Message); + return DetectionResult.DeviceException; } - return false; + return DetectionResult.DeviceNotFound; } /// <summary> Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Technotrend Receiver/Technotrend Receiver.csproj =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Technotrend Receiver/Technotrend Receiver.csproj 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Technotrend Receiver/Technotrend Receiver.csproj 2009-07-11 16:41:50 UTC (rev 3004) @@ -2,7 +2,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>8.0.50727</ProductVersion> + <ProductVersion>9.0.30729</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{E83E5C73-5F70-4B52-B6BD-E906BAE90DF6}</ProjectGuid> <OutputType>Library</OutputType> @@ -59,6 +59,10 @@ <Compile Include="Technotrend Receiver.cs" /> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\Common\IrssUtils\IrssUtils.csproj"> + <Project>{CA15769C-232E-4CA7-94FD-206A06CA3ABB}</Project> + <Name>IrssUtils</Name> + </ProjectReference> <ProjectReference Include="..\IR Server Plugin Interface\IR Server Plugin Interface.csproj"> <Project>{D8B3D28F-62CE-4CA7-86CE-B7EAD614A94C}</Project> <Name>IR Server Plugin Interface</Name> Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver/USB-UIRT Transceiver.csproj =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver/USB-UIRT Transceiver.csproj 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver/USB-UIRT Transceiver.csproj 2009-07-11 16:41:50 UTC (rev 3004) @@ -2,7 +2,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>8.0.50727</ProductVersion> + <ProductVersion>9.0.30729</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{99B5CA78-3E0B-477F-A7D3-EE1B65E85DE4}</ProjectGuid> <OutputType>Library</OutputType> @@ -74,6 +74,10 @@ </EmbeddedResource> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\Common\IrssUtils\IrssUtils.csproj"> + <Project>{CA15769C-232E-4CA7-94FD-206A06CA3ABB}</Project> + <Name>IrssUtils</Name> + </ProjectReference> <ProjectReference Include="..\IR Server Plugin Interface\IR Server Plugin Interface.csproj"> <Project>{D8B3D28F-62CE-4CA7-86CE-B7EAD614A94C}</Project> <Name>IR Server Plugin Interface</Name> Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver/UirtTransceiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver/UirtTransceiver.cs 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver/UirtTransceiver.cs 2009-07-11 16:41:50 UTC (rev 3004) @@ -21,6 +21,7 @@ #endregion using System; +using System.ComponentModel; using System.Drawing; using System.IO; using System.Runtime.InteropServices; @@ -28,6 +29,7 @@ using System.Windows.Forms; using System.Xml; using InputService.Plugin.Properties; +using IrssUtils; namespace InputService.Plugin { @@ -49,7 +51,7 @@ private const int UUIRTDRV_IRFMT_UUIRT = 0x0000; private static readonly string ConfigurationFile = Path.Combine(ConfigurationPath, "USB-UIRT Transceiver.xml"); - private static readonly string[] Ports = new string[] {"Default", "Port 1", "Port 2", "Port 3"}; + private static readonly string[] Ports = new string[] { "Default", "Port 1", "Port 2", "Port 3" }; #endregion Constants @@ -288,7 +290,7 @@ try { - _abortLearn = Marshal.AllocHGlobal(Marshal.SizeOf(typeof (Int32))); + _abortLearn = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Int32))); Marshal.WriteInt32(_abortLearn, AllowLearn); result = UUIRTLearnIR( @@ -396,12 +398,9 @@ #endregion /// <summary> - /// Detect the presence of this device. Devices that cannot be detected will always return false. + /// Detect the presence of this device. /// </summary> - /// <returns> - /// <c>true</c> if the device is present, otherwise <c>false</c>. - /// </returns> - public override bool Detect() + public override DetectionResult Detect() { try { @@ -410,14 +409,20 @@ if (handle != new IntPtr(-1) && handle != IntPtr.Zero) { UUIRTClose(handle); - return true; + return DetectionResult.DevicePresent; } } - catch + catch (DllNotFoundException) { + return DetectionResult.DeviceNotFound; } + catch (Exception ex) + { + IrssLog.Error("{0} exception: {1} type: {2}", Name, ex.Message, ex.GetType()); + return DetectionResult.DeviceException; + } - return false; + return DetectionResult.DeviceNotFound; } /// <summary> @@ -513,7 +518,7 @@ { writer.Formatting = Formatting.Indented; writer.Indentation = 1; - writer.IndentChar = (char) 9; + writer.IndentChar = (char)9; writer.WriteStartDocument(true); writer.WriteStartElement("settings"); // <settings> @@ -586,7 +591,7 @@ _learnTimedOut = true; - ((Timer) sender).Stop(); + ((Timer)sender).Stop(); } #endregion Implementation Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Wii Remote Receiver/Wii Remote Receiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Wii Remote Receiver/Wii Remote Receiver.cs 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Wii Remote Receiver/Wii Remote Receiver.cs 2009-07-11 16:41:50 UTC (rev 3004) @@ -174,14 +174,13 @@ #endregion /// <summary> - /// Detect the presence of this device. Devices that cannot be detected will always return false. + /// Detect the presence of this device. /// </summary> - /// <returns> - /// <c>true</c> if the device is present, otherwise <c>false</c>. - /// </returns> - public override bool Detect() + public override DetectionResult Detect() { - return false; + // TODO: Add Wii Remote detection + + return DetectionResult.DeviceNotFound; } /// <summary> Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/WinLirc Transceiver/WinLirc Transceiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/WinLirc Transceiver/WinLirc Transceiver.cs 2009-07-11 10:56:05 UTC (rev 3003) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/WinLirc Transceiver/WinLirc Transceiver.cs 2009-07-11 16:41:50 UTC (rev 3004) @@ -28,6 +28,7 @@ using System.Windows.Forms; using System.Xml; using InputService.Plugin.Properties; +using IrssUtils; namespace InputService.Plugin { @@ -190,21 +191,24 @@ #endregion /// <summary> - /// Detect the presence of this device. Devices that cannot be detected will always return false. + /... [truncated message content] |