From: <che...@us...> - 2009-10-11 14:47:44
|
Revision: 3117 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=3117&view=rev Author: chemelli_sf Date: 2009-10-11 14:47:37 +0000 (Sun, 11 Oct 2009) Log Message: ----------- - Custom HID plugin is available only is disabled in service mode - IRSS install path is taken from the application path instead of registry lookup - Minor cleanup Modified Paths: -------------- trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server/IR Server.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server/IR Server.csproj trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server/Program.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server Configuration/Config.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server Configuration/Program.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Custom HID Receiver/Custom HID Receiver.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Custom HID Receiver/Custom HID Receiver.csproj trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IR Server Plugin Interface.csproj trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/PluginBase.cs Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server/IR Server.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server/IR Server.cs 2009-10-11 11:02:31 UTC (rev 3116) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server/IR Server.cs 2009-10-11 14:47:37 UTC (rev 3117) @@ -1472,7 +1472,7 @@ { IrssMessage response = new IrssMessage(MessageType.AvailableBlasters, MessageFlags.Response); - PluginBase[] plugins = Program.AvailablePlugins(); + PluginBase[] plugins = BasicFunctions.AvailablePlugins(); StringBuilder blasters = new StringBuilder(); for (int index = 0; index < plugins.Length; index++) @@ -1508,7 +1508,7 @@ { IrssMessage response = new IrssMessage(MessageType.AvailableReceivers, MessageFlags.Response); - PluginBase[] plugins = Program.AvailablePlugins(); + PluginBase[] plugins = BasicFunctions.AvailablePlugins(); StringBuilder receivers = new StringBuilder(); for (int index = 0; index < plugins.Length; index++) Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server/IR Server.csproj =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server/IR Server.csproj 2009-10-11 11:02:31 UTC (rev 3116) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server/IR Server.csproj 2009-10-11 14:47:37 UTC (rev 3117) @@ -2,7 +2,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>9.0.21022</ProductVersion> + <ProductVersion>9.0.30729</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{46F1DB42-F082-4200-B939-6E4B72A8117C}</ProjectGuid> <OutputType>WinExe</OutputType> @@ -19,6 +19,21 @@ <OldToolsVersion>2.0</OldToolsVersion> <UpgradeBackupLocation> </UpgradeBackupLocation> + <PublishUrl>publish\</PublishUrl> + <Install>true</Install> + <InstallFrom>Disk</InstallFrom> + <UpdateEnabled>false</UpdateEnabled> + <UpdateMode>Foreground</UpdateMode> + <UpdateInterval>7</UpdateInterval> + <UpdateIntervalUnits>Days</UpdateIntervalUnits> + <UpdatePeriodically>false</UpdatePeriodically> + <UpdateRequired>false</UpdateRequired> + <MapFileExtensions>true</MapFileExtensions> + <ApplicationRevision>0</ApplicationRevision> + <ApplicationVersion>1.0.0.%2a</ApplicationVersion> + <IsWebBootstrapper>false</IsWebBootstrapper> + <UseApplicationTrust>false</UseApplicationTrust> + <BootstrapperEnabled>true</BootstrapperEnabled> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> @@ -155,6 +170,33 @@ <SubType>Designer</SubType> </EmbeddedResource> </ItemGroup> + <ItemGroup> + <BootstrapperPackage Include="Microsoft.Net.Client.3.5"> + <Visible>False</Visible> + <ProductName>.NET Framework Client Profile</ProductName> + <Install>false</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Net.Framework.2.0"> + <Visible>False</Visible> + <ProductName>.NET Framework 2.0 %28x86%29</ProductName> + <Install>true</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Net.Framework.3.0"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.0 %28x86%29</ProductName> + <Install>false</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Net.Framework.3.5"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.5</ProductName> + <Install>false</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.5 SP1</ProductName> + <Install>false</Install> + </BootstrapperPackage> + </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server/Program.cs 2009-10-11 11:02:31 UTC (rev 3116) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server/Program.cs 2009-10-11 14:47:37 UTC (rev 3117) @@ -30,6 +30,7 @@ using IRServer.Plugin; using IrssUtils; using System.Windows.Forms; +using IRServer.Plugin; namespace IRServer { @@ -58,106 +59,106 @@ try { - IrssLog.Open("IR Server.log"); + IrssLog.Open("IR Server.log"); - if (args.Length == 0) + if (args.Length == 0) + { + IRServer = new IRServer(); + if (IRServer.DoStart()) { - IRServer = new IRServer(); - if (IRServer.DoStart()) - { - ReceiverWindow receiverWindow = new ReceiverWindow(ServerWindowName); - Application.Run(); - receiverWindow.DestroyHandle(); - receiverWindow = null; - IRServer.DoStop(); - } + ReceiverWindow receiverWindow = new ReceiverWindow(ServerWindowName); + Application.Run(); + receiverWindow.DestroyHandle(); + receiverWindow = null; + IRServer.DoStop(); } - else + } + else + { + foreach (string parameter in args) { - foreach (string parameter in args) - { - switch (parameter.ToUpperInvariant().Replace("-", "/")) + switch (parameter.ToUpperInvariant().Replace("-", "/")) + { + case "/INSTALL": + IrssLog.Info("Installing IR Server ..."); + using (TransactedInstaller transactedInstaller = new TransactedInstaller()) + { + using (IRServerInstaller IRServerInstaller = new IRServerInstaller()) { - case "/INSTALL": - IrssLog.Info("Installing IR Server ..."); - using (TransactedInstaller transactedInstaller = new TransactedInstaller()) - { - using (IRServerInstaller IRServerInstaller = new IRServerInstaller()) - { - transactedInstaller.Installers.Add(IRServerInstaller); + transactedInstaller.Installers.Add(IRServerInstaller); - string path = "/assemblypath=" + Assembly.GetExecutingAssembly().Location; - string[] cmdline = { path }; + string path = "/assemblypath=" + Assembly.GetExecutingAssembly().Location; + string[] cmdline = { path }; - InstallContext installContext = new InstallContext(String.Empty, cmdline); - transactedInstaller.Context = installContext; + InstallContext installContext = new InstallContext(String.Empty, cmdline); + transactedInstaller.Context = installContext; - transactedInstaller.Install(new Hashtable()); - } - } - break; + transactedInstaller.Install(new Hashtable()); + } + } + break; - case "/UNINSTALL": - IrssLog.Info("Uninstalling IR Server ..."); - using (TransactedInstaller transactedInstaller = new TransactedInstaller()) - { - using (IRServerInstaller IRServerInstaller = new IRServerInstaller()) - { - transactedInstaller.Installers.Add(IRServerInstaller); + case "/UNINSTALL": + IrssLog.Info("Uninstalling IR Server ..."); + using (TransactedInstaller transactedInstaller = new TransactedInstaller()) + { + using (IRServerInstaller IRServerInstaller = new IRServerInstaller()) + { + transactedInstaller.Installers.Add(IRServerInstaller); - string path = "/assemblypath=" + Assembly.GetExecutingAssembly().Location; - string[] cmdline = { path }; + string path = "/assemblypath=" + Assembly.GetExecutingAssembly().Location; + string[] cmdline = { path }; - InstallContext installContext = new InstallContext(String.Empty, cmdline); - transactedInstaller.Context = installContext; + InstallContext installContext = new InstallContext(String.Empty, cmdline); + transactedInstaller.Context = installContext; - transactedInstaller.Uninstall(null); - } - } - break; + transactedInstaller.Uninstall(null); + } + } + break; - case "/START": - IrssLog.Info("Starting IR Server ..."); - using (ServiceController serviceController = new ServiceController(ServiceName)) - if (serviceController.Status == ServiceControllerStatus.Stopped) - serviceController.Start(); - break; + case "/START": + IrssLog.Info("Starting IR Server ..."); + using (ServiceController serviceController = new ServiceController(ServiceName)) + if (serviceController.Status == ServiceControllerStatus.Stopped) + serviceController.Start(); + break; - case "/STOP": - IrssLog.Info("Stopping IR Server ..."); - using (ServiceController serviceController = new ServiceController(ServiceName)) - if (serviceController.Status == ServiceControllerStatus.Running) - serviceController.Stop(); - break; + case "/STOP": + IrssLog.Info("Stopping IR Server ..."); + using (ServiceController serviceController = new ServiceController(ServiceName)) + if (serviceController.Status == ServiceControllerStatus.Running) + serviceController.Stop(); + break; - case "/RESTART": - IrssLog.Info("Restarting IR Server ..."); - using (ServiceController serviceController = new ServiceController(ServiceName)) - { - if (serviceController.Status == ServiceControllerStatus.Running) - serviceController.Stop(); + case "/RESTART": + IrssLog.Info("Restarting IR Server ..."); + using (ServiceController serviceController = new ServiceController(ServiceName)) + { + if (serviceController.Status == ServiceControllerStatus.Running) + serviceController.Stop(); - serviceController.WaitForStatus(ServiceControllerStatus.Stopped, new TimeSpan(0, 0, 30)); + serviceController.WaitForStatus(ServiceControllerStatus.Stopped, new TimeSpan(0, 0, 30)); - if (serviceController.Status == ServiceControllerStatus.Stopped) - serviceController.Start(); - } - break; + if (serviceController.Status == ServiceControllerStatus.Stopped) + serviceController.Start(); + } + break; - case "/SERVICE": - { - IRServer IRServer = new IRServer(); - ServiceBase.Run(IRServer); - } - break; + case "/SERVICE": + { + IRServer IRServer = new IRServer(); + ServiceBase.Run(IRServer); + } + break; - default: - throw new InvalidOperationException(String.Format("Unknown command line parameter \"{0}\"", parameter)); - } - } - - IrssLog.Info("Done."); + default: + throw new InvalidOperationException(String.Format("Unknown command line parameter \"{0}\"", parameter)); + } } + + IrssLog.Info("Done."); + } } catch (Exception ex) { @@ -169,56 +170,8 @@ } } + /// <summary> - /// Retreives a list of available IR Server plugins. - /// </summary> - /// <returns>Array of plugin instances.</returns> - internal static PluginBase[] AvailablePlugins() - { - List<PluginBase> plugins = new List<PluginBase>(); - - 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); - - // TODO: Return a Type[], don't instantiate unless required - - foreach (string file in files) - { - try - { - Assembly assembly = Assembly.LoadFrom(file); - Type[] types = assembly.GetExportedTypes(); - - foreach (Type type in types) - { - if (type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof (PluginBase))) - { - PluginBase plugin = (PluginBase) assembly.CreateInstance(type.FullName); - - 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 (FileNotFoundException) - { - } // Ignore File Not Found Exceptions, just keep checking for IR Server Plugins - } - - return plugins.ToArray(); - } - - /// <summary> /// Retreives a plugin instance given the plugin name. /// </summary> /// <param name="pluginName">Name of plugin to instantiate.</param> @@ -228,7 +181,7 @@ if (String.IsNullOrEmpty(pluginName)) throw new ArgumentNullException("pluginName"); - PluginBase[] serverPlugins = AvailablePlugins(); + PluginBase[] serverPlugins = BasicFunctions.AvailablePlugins(); if (serverPlugins == null) throw new FileNotFoundException("No available plugins found"); @@ -247,7 +200,7 @@ { IrssLog.Info("Detect Receivers ..."); - PluginBase[] plugins = AvailablePlugins(); + PluginBase[] plugins = BasicFunctions.AvailablePlugins(); if (plugins == null || plugins.Length == 0) return null; @@ -280,7 +233,7 @@ { IrssLog.Info("Detect Blasters ..."); - PluginBase[] plugins = AvailablePlugins(); + PluginBase[] plugins = BasicFunctions.AvailablePlugins(); if (plugins == null || plugins.Length == 0) return null; Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server Configuration/Config.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server Configuration/Config.cs 2009-10-11 11:02:31 UTC (rev 3116) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server Configuration/Config.cs 2009-10-11 14:47:37 UTC (rev 3117) @@ -432,7 +432,7 @@ try { - _transceivers = Program.AvailablePlugins(); + _transceivers = BasicFunctions.AvailablePlugins(); } catch (Exception ex) { Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server Configuration/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server Configuration/Program.cs 2009-10-11 11:02:31 UTC (rev 3116) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server Configuration/Program.cs 2009-10-11 14:47:37 UTC (rev 3117) @@ -486,7 +486,7 @@ if (exitCode != 0) { IrssLog.Error("RunAdminHelper exitcode = " + exitCode); - MessageBox.Show("There occured an issue when trying to run AdminHelper." + Environment.NewLine + + MessageBox.Show("There occured an issue when trying to run AdminHelper." + Environment.NewLine + "Do you have administration rights?" + Environment.NewLine + "Did you accept the request for Administration rights?" + Environment.NewLine + Environment.NewLine + "If you think you did everything right, please report the issue to the devlopers.", @@ -592,56 +592,6 @@ } /// <summary> - /// Retreives a list of available IR Server plugins. - /// </summary> - /// <returns>Array of plugin instances.</returns> - internal static PluginBase[] AvailablePlugins() - { - List<PluginBase> plugins = new List<PluginBase>(); - - 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); - - // TODO: Return a Type[], don't instantiate unless required - - foreach (string file in files) - { - try - { - Assembly assembly = Assembly.LoadFrom(file); - - Type[] types = assembly.GetExportedTypes(); - - foreach (Type type in types) - { - if (type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(PluginBase))) - { - PluginBase plugin = (PluginBase)assembly.CreateInstance(type.FullName); - - if (plugin != null && plugin.Detect() != PluginBase.DetectionResult.DeviceDisabled) - 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 (FileNotFoundException) - { - } // Ignore File Not Found Exceptions, just keep checking for IR Server Plugins - } - - return plugins.ToArray(); - } - - /// <summary> /// Retreives a list of detected Receiver plugins. /// </summary> /// <returns>String array of plugin names.</returns> @@ -649,7 +599,7 @@ { IrssLog.Info("Detect Receivers ..."); - PluginBase[] plugins = AvailablePlugins(); + PluginBase[] plugins = BasicFunctions.AvailablePlugins(); if (plugins == null || plugins.Length == 0) return null; @@ -682,7 +632,7 @@ { IrssLog.Info("Detect Blasters ..."); - PluginBase[] plugins = AvailablePlugins(); + PluginBase[] plugins = BasicFunctions.AvailablePlugins(); if (plugins == null || plugins.Length == 0) return null; Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Custom HID Receiver/Custom HID Receiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Custom HID Receiver/Custom HID Receiver.cs 2009-10-11 11:02:31 UTC (rev 3116) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Custom HID Receiver/Custom HID Receiver.cs 2009-10-11 14:47:37 UTC (rev 3117) @@ -28,6 +28,7 @@ using System.Windows.Forms; using System.Xml; using IRServer.Plugin.Properties; +using IrssUtils; namespace IRServer.Plugin { @@ -234,6 +235,16 @@ #endregion + public override DetectionResult Detect() + { + if (Environment.UserInteractive) + { + IrssLog.Error("{0,15}: not available on \"service\" installation mode", Name); + return DetectionResult.DeviceDisabled; + } + return DetectionResult.DevicePresent; + } + /// <summary> /// Start the IR Server plugin. /// </summary> Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Custom HID Receiver/Custom HID Receiver.csproj =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Custom HID Receiver/Custom HID Receiver.csproj 2009-10-11 11:02:31 UTC (rev 3116) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Custom HID Receiver/Custom HID Receiver.csproj 2009-10-11 14:47:37 UTC (rev 3117) @@ -83,6 +83,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/IR Server Plugin Interface/IR Server Plugin Interface.csproj =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IR Server Plugin Interface.csproj 2009-10-11 11:02:31 UTC (rev 3116) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IR Server Plugin Interface.csproj 2009-10-11 14:47:37 UTC (rev 3117) @@ -69,6 +69,12 @@ <Compile Include="ITransmitIR.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\Common\IrssUtils\IrssUtils.csproj"> + <Project>{CA15769C-232E-4CA7-94FD-206A06CA3ABB}</Project> + <Name>IrssUtils</Name> + </ProjectReference> + </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. 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-10-11 11:02:31 UTC (rev 3116) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/PluginBase.cs 2009-10-11 14:47:37 UTC (rev 3117) @@ -21,8 +21,12 @@ #endregion using System; +using System.Collections.Generic; using System.Drawing; using System.IO; +using System.Reflection; +using System.Windows.Forms; +using IrssUtils; namespace IRServer.Plugin { @@ -140,4 +144,56 @@ #endregion Methods } + + public class BasicFunctions + { + /// <summary> + /// Retreives a list of available IR Server plugins. + /// </summary> + /// <returns>Array of plugin instances.</returns> + public static PluginBase[] AvailablePlugins() + { + List<PluginBase> plugins = new List<PluginBase>(); + + string path = Path.Combine(Application.StartupPath, "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 + { + Assembly assembly = Assembly.LoadFrom(file); + + Type[] types = assembly.GetExportedTypes(); + + foreach (Type type in types) + { + if (type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(PluginBase))) + { + + PluginBase plugin = (PluginBase)assembly.CreateInstance(type.FullName); + + if (plugin != null && plugin.Detect() != PluginBase.DetectionResult.DeviceDisabled) + { + 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 (FileNotFoundException) + { + } // Ignore File Not Found Exceptions, just keep checking for IR Server Plugins + } + + return plugins.ToArray(); + } + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |