From: <an...@us...> - 2008-04-06 14:58:27
|
Revision: 1610 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=1610&view=rev Author: and-81 Date: 2008-04-06 07:58:21 -0700 (Sun, 06 Apr 2008) Log Message: ----------- Modified Paths: -------------- trunk/plugins/IR Server Suite/setup/setup.nsi trunk/plugins/TelnetInterface/TelnetInterface.cs Added Paths: ----------- trunk/plugins/TelnetCommand/ trunk/plugins/TelnetCommand/Program.cs trunk/plugins/TelnetCommand/Properties/ trunk/plugins/TelnetCommand/Properties/AssemblyInfo.cs trunk/plugins/TelnetCommand/TelnetCommand.csproj Modified: trunk/plugins/IR Server Suite/setup/setup.nsi =================================================================== --- trunk/plugins/IR Server Suite/setup/setup.nsi 2008-04-06 14:38:26 UTC (rev 1609) +++ trunk/plugins/IR Server Suite/setup/setup.nsi 2008-04-06 14:58:21 UTC (rev 1610) @@ -290,6 +290,7 @@ ExecWait '"taskkill" /F /IM IRFileTool.exe' ExecWait '"taskkill" /F /IM DebugClient.exe' ExecWait '"taskkill" /F /IM KeyboardInputRelay.exe' + ExecWait '"taskkill" /F /IM "Input Service Configuration.exe"' IfFileExists "$DIR_INSTALL\Input Service\Input Service.exe" StopInputService SkipStopInputService Property changes on: trunk/plugins/TelnetCommand ___________________________________________________________________ Name: svn:ignore + bin obj Added: trunk/plugins/TelnetCommand/Program.cs =================================================================== --- trunk/plugins/TelnetCommand/Program.cs (rev 0) +++ trunk/plugins/TelnetCommand/Program.cs 2008-04-06 14:58:21 UTC (rev 1610) @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using System.Net; +using System.Net.Sockets; +using System.Text; + +namespace TelnetCommand +{ + + class Program + { + + const int ServerPort = 2381; + + static void Main(string[] args) + { + if (args.Length == 0 || args.Length == 1) + { + ShowHelp(); + return; + } + else + { + try + { + string hostAddress = args[0]; + + StringBuilder commandString = new StringBuilder(); + for (int index = 1; index < args.Length; index++) + { + commandString.Append(args[index]); + if (index < args.Length - 1) + commandString.Append(' '); + } + + string command = commandString.ToString() + '\r'; + + IPAddress serverIP = GetIPFromName(hostAddress); + IPEndPoint endPoint = new IPEndPoint(serverIP, ServerPort); + + Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + socket.Connect(endPoint); + + byte[] textBytes = Encoding.ASCII.GetBytes(command); + socket.Send(textBytes); + + byte[] received = new byte[4096]; + + socket.ReceiveTimeout = 500; + + try + { + while (true) + { + int bytesRead = socket.Receive(received); + if (bytesRead == 0) + break; + + string reply = Encoding.ASCII.GetString(received, 0, bytesRead); + + Console.Write(reply); + } + } + catch (SocketException) { } + + socket.Close(); + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + } + } + } + + static void ShowHelp() + { + Console.WriteLine(); + Console.WriteLine("MediaPortal Telnet Interface Command Line Tool"); + Console.WriteLine("by and-81"); + Console.WriteLine(); + Console.WriteLine("Usage:"); + Console.WriteLine(); + Console.WriteLine("TelnetCommand.exe <host address> <command> [command parameters]"); + Console.WriteLine(); + Console.WriteLine("Available Commands:"); + Console.WriteLine(""); + Console.WriteLine("GET ACTIONS, GET SCREENS, GOTO <Screen>, PLAY <File>, ACTION <Action>, EXIT, BYE"); + Console.WriteLine(); + Console.WriteLine("GET ACTIONS - Returns a list of MediaPortal actions the ACTION command can trigger"); + Console.WriteLine("GET SCREENS - Returns a list of MediaPortal screens the GOTO command can use"); + Console.WriteLine("GOTO <Screen> - Make MediaPortal move to another screen, can be the screen name from the GET SCREENS command, or the screen ID from it's XML file"); + Console.WriteLine("PLAY <File> - Play the music/video file specified"); + Console.WriteLine("ACTION <Action> - Trigger a MediaPortal action, this must be one of the actions from the GET ACTIONS command"); + Console.WriteLine("EXIT - Quit MediaPortal"); + Console.WriteLine(); + } + + static IPAddress GetIPFromName(string name) + { + // Automatically convert localhost to loopback address, avoiding lookup calls for systems that aren't on a network. + if (name.Equals("localhost", StringComparison.OrdinalIgnoreCase)) + return IPAddress.Loopback; + + IPAddress[] addresses = Dns.GetHostAddresses(name); + foreach (IPAddress address in addresses) + if (address.AddressFamily == AddressFamily.InterNetwork) + return address; + + return null; + } + + } + +} Added: trunk/plugins/TelnetCommand/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/TelnetCommand/Properties/AssemblyInfo.cs (rev 0) +++ trunk/plugins/TelnetCommand/Properties/AssemblyInfo.cs 2008-04-06 14:58:21 UTC (rev 1610) @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("TelnetCommand")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("TelnetCommand")] +[assembly: AssemblyCopyright("Copyright © 2008")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("9f4d1069-258a-421d-980e-b0149e21b410")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.4.2.0")] +[assembly: AssemblyFileVersion("1.4.2.0")] Added: trunk/plugins/TelnetCommand/TelnetCommand.csproj =================================================================== --- trunk/plugins/TelnetCommand/TelnetCommand.csproj (rev 0) +++ trunk/plugins/TelnetCommand/TelnetCommand.csproj 2008-04-06 14:58:21 UTC (rev 1610) @@ -0,0 +1,52 @@ +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>8.0.50727</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{906BCFAC-8475-412E-951C-588BB9FC8DCD}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>TelnetCommand</RootNamespace> + <AssemblyName>TelnetCommand</AssemblyName> + <StartupObject>TelnetCommand.Program</StartupObject> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <TreatWarningsAsErrors>true</TreatWarningsAsErrors> + <DocumentationFile> + </DocumentationFile> + <UseVSHostingProcess>false</UseVSHostingProcess> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </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. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file Modified: trunk/plugins/TelnetInterface/TelnetInterface.cs =================================================================== --- trunk/plugins/TelnetInterface/TelnetInterface.cs 2008-04-06 14:38:26 UTC (rev 1609) +++ trunk/plugins/TelnetInterface/TelnetInterface.cs 2008-04-06 14:58:21 UTC (rev 1610) @@ -21,6 +21,7 @@ #region Constant const int SocketBacklog = 10; + const int ServerPort = 2381; #endregion Constant @@ -46,7 +47,7 @@ /// </summary> public void Start() { - _serverPort = 2381; + _serverPort = ServerPort; _processConnectionThread = true; GUIWindowManager.Receivers += new SendMessageHandler(GUIWindowManager_Receivers); @@ -94,7 +95,6 @@ foreach (Socket socket in _activeSockets) socket.Close(); - if (_serverSocket != null) _serverSocket.Close(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |