From: <mis...@us...> - 2009-08-09 20:13:38
|
Revision: 3048 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=3048&view=rev Author: misterd_sf Date: 2009-08-09 20:13:30 +0000 (Sun, 09 Aug 2009) Log Message: ----------- Initial version of FireDTV receiver plugin - Still WiP Modified Paths: -------------- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Suite.sln Added Paths: ----------- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/Configure.Designer.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/Configure.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/Configure.resx trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/FireDTV Receiver.csproj trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/FireDTV interfaces/ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/FireDTV interfaces/FireSATControl.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/FireDTV interfaces/FireSATDefines.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/FireDTV interfaces/FireSATSourceFilterInfo.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/FireDTVReceiver.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/Icon.ico trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/Properties/ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/Properties/AssemblyInfo.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/Properties/Resources.Designer.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/Properties/Resources.resx trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/ReceiverWindow.cs Property changes on: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver ___________________________________________________________________ Added: svn:ignore + [Bb]in obj [Dd]ebug [Rr]elease *.user *.aps *.eto Copied: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/Configure.Designer.cs (from rev 3043, trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/X10 Transceiver/Configure.Designer.cs) =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/Configure.Designer.cs (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/Configure.Designer.cs 2009-08-09 20:13:30 UTC (rev 3048) @@ -0,0 +1,124 @@ +namespace IRServer.Plugin +{ + partial class Configure + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.toolTips = new System.Windows.Forms.ToolTip(this.components); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.labelDevice = new System.Windows.Forms.Label(); + this.comboBoxDevice = new System.Windows.Forms.ComboBox(); + this.labelFireDTV = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.Location = new System.Drawing.Point(137, 134); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(64, 24); + this.buttonOK.TabIndex = 4; + this.buttonOK.Text = "OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(209, 134); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(64, 24); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // labelDevice + // + this.labelDevice.Location = new System.Drawing.Point(12, 9); + this.labelDevice.Name = "labelDevice"; + this.labelDevice.Size = new System.Drawing.Size(134, 20); + this.labelDevice.TabIndex = 6; + this.labelDevice.Text = "Please select the device:"; + this.labelDevice.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // comboBoxDevice + // + this.comboBoxDevice.FormattingEnabled = true; + this.comboBoxDevice.Location = new System.Drawing.Point(15, 35); + this.comboBoxDevice.Name = "comboBoxDevice"; + this.comboBoxDevice.Size = new System.Drawing.Size(258, 21); + this.comboBoxDevice.TabIndex = 9; + this.comboBoxDevice.SelectedIndexChanged += new System.EventHandler(this.comboBoxDevice_SelectedIndexChanged); + // + // labelFireDTV + // + this.labelFireDTV.AutoSize = true; + this.labelFireDTV.Location = new System.Drawing.Point(12, 91); + this.labelFireDTV.Name = "labelFireDTV"; + this.labelFireDTV.Size = new System.Drawing.Size(134, 13); + this.labelFireDTV.TabIndex = 10; + this.labelFireDTV.Text = "FireDTV API Version: 1.1.1"; + // + // Configure + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(281, 167); + this.Controls.Add(this.labelFireDTV); + this.Controls.Add(this.comboBoxDevice); + this.Controls.Add(this.labelDevice); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(256, 164); + this.Name = "Configure"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "FireDTV Configuration"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.ToolTip toolTips; + private System.Windows.Forms.Timer timer1; + private System.Windows.Forms.Label labelDevice; + private System.Windows.Forms.ComboBox comboBoxDevice; + private System.Windows.Forms.Label labelFireDTV; + } +} \ No newline at end of file Copied: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/Configure.cs (from rev 3043, trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/X10 Transceiver/Configure.cs) =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/Configure.cs (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/Configure.cs 2009-08-09 20:13:30 UTC (rev 3048) @@ -0,0 +1,116 @@ +#region Copyright (C) 2005-2009 Team MediaPortal + +// Copyright (C) 2005-2009 Team MediaPortal +// http://www.team-mediaportal.com +// +// This Program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// This Program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with GNU Make; see the file COPYING. If not, write to +// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +// http://www.gnu.org/copyleft/gpl.html + +#endregion + +using System; +using System.Windows.Forms; + +namespace IRServer.Plugin +{ + /// <summary> + /// Configure the FireDTV receiver + /// </summary> + internal partial class Configure : Form + { + #region variables + + private FireDTVControl fireDTV; + private string _deviceName; + #endregion variables + + #region Properties + + /// <summary> + /// Gets or sets the device name + /// </summary> + /// <value>Use channel control</value> + public string DeviceName + { + get { return _deviceName; } + set + { + _deviceName = value; + } + } + + #endregion Properties + + #region Constructor + + /// <summary> + /// Initializes a new instance of the <see cref="Configure"/> class. + /// </summary> + public Configure() + { + InitializeComponent(); + try + { + fireDTV = new FireDTVControl((IntPtr)0); + labelFireDTV.Text = "FireDTV API Version:"+fireDTV.APIVersion; + if (fireDTV.OpenDrivers()) + { + comboBoxDevice.DataSource = fireDTV.SourceFilters; + comboBoxDevice.DisplayMember = "FriendlyName"; + comboBoxDevice.ValueMember = "Name"; + } + if (!string.IsNullOrEmpty(_deviceName)) + { + comboBoxDevice.SelectedValue = _deviceName; + } + comboBoxDevice.Enabled = true; + buttonOK.Enabled = true; + labelFireDTV.Visible = true; + } + catch (Exception e) + { + MessageBox.Show(e.ToString()); + labelFireDTV.Visible = false; + comboBoxDevice.Enabled = false; + buttonOK.Enabled = false; + } + + } + + #endregion Constructor + + #region Buttons + + private void buttonOK_Click(object sender, EventArgs e) + { + if (comboBoxDevice.SelectedValue != null) + { + _deviceName = comboBoxDevice.SelectedValue.ToString(); + } + DialogResult = DialogResult.OK; + Close(); + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + + #endregion Buttons + + } +} \ No newline at end of file Copied: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/Configure.resx (from rev 3043, trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/X10 Transceiver/Configure.resx) =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/Configure.resx (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/Configure.resx 2009-08-09 20:13:30 UTC (rev 3048) @@ -0,0 +1,126 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <metadata name="toolTips.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>17, 17</value> + </metadata> + <metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>107, 17</value> + </metadata> +</root> \ No newline at end of file Added: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/FireDTV Receiver.csproj =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/FireDTV Receiver.csproj (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/FireDTV Receiver.csproj 2009-08-09 20:13:30 UTC (rev 3048) @@ -0,0 +1,97 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>9.0.30729</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{D88EDBC1-D583-4149-9873-8239FA63F4FE}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>IRServer.Plugin</RootNamespace> + <AssemblyName>FireDTV Receiver</AssemblyName> + <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <TargetFrameworkSubset> + </TargetFrameworkSubset> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <DocumentationFile>bin\Debug\FireDTV Receiver.XML</DocumentationFile> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants> + </DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <DocumentationFile>bin\Release\FireDTV Receiver.XML</DocumentationFile> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Data" /> + <Reference Include="System.Drawing" /> + <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Configure.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Configure.Designer.cs"> + <DependentUpon>Configure.cs</DependentUpon> + </Compile> + <Compile Include="FireDTV interfaces\FireSATControl.cs" /> + <Compile Include="FireDTV interfaces\FireSATDefines.cs" /> + <Compile Include="FireDTV interfaces\FireSATSourceFilterInfo.cs" /> + <Compile Include="FireDTVReceiver.cs"> + <SubType>Code</SubType> + </Compile> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="Properties\Resources.Designer.cs"> + <AutoGen>True</AutoGen> + <DesignTime>True</DesignTime> + <DependentUpon>Resources.resx</DependentUpon> + </Compile> + <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> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="Configure.resx"> + <DependentUpon>Configure.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Properties\Resources.resx"> + <Generator>ResXFileCodeGenerator</Generator> + <LastGenOutput>Resources.Designer.cs</LastGenOutput> + </EmbeddedResource> + </ItemGroup> + <ItemGroup> + <Content Include="Icon.ico" /> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\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 Added: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/FireDTV interfaces/FireSATControl.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/FireDTV interfaces/FireSATControl.cs (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/FireDTV interfaces/FireSATControl.cs 2009-08-09 20:13:30 UTC (rev 3048) @@ -0,0 +1,352 @@ +#region Copyright (C) 2005-2009 Team MediaPortal + +/* + * Copyright (C) 2005-2009 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#endregion + +#region Usings + +using System; +using System.Diagnostics; +using System.IO; +using System.Runtime.InteropServices; + +#endregion + +namespace IRServer.Plugin +{ + /// <summary> + /// Summary description for FireDTVControl. + /// </summary> + public class FireDTVControl + { + /// <summary> + /// The SetDllDirectory function adds a directory to the search path used to locate DLLs for the application. + /// http://msdn.microsoft.com/library/en-us/dllproc/base/setdlldirectory.asp + /// </summary> + /// <param name="pathName">Pointer to a null-terminated string that specifies the directory to be added to the search path.</param> + /// <returns></returns> + [DllImport("kernel32.dll")] + private static extern bool SetDllDirectory( + string pathName); + + #region Constructor / Destructor + + /// <summary> + /// Try to locate the FireDTV API library and initialise the library. + /// </summary> + /// <param name="windowHandle"></param> + public FireDTVControl(IntPtr windowHandle) + { + try + { + string prgPath = Environment.GetEnvironmentVariable("ProgramW6432"); + if (string.IsNullOrEmpty(prgPath)) + { + prgPath = Environment.GetEnvironmentVariable("ProgramFiles"); + } + + // Look for Digital Everywhere's software which uses a hardcoded path + string fullDllPath = Path.Combine(prgPath, @"FireDTV\Tools\FiresatApi.dll"); + if (!File.Exists(fullDllPath)) + { + throw new FileNotFoundException("Could not FireSATApi.dll"); + } + + try + { + SetDllDirectory(Path.GetDirectoryName(fullDllPath)); + } + catch (Exception) + { + throw new FileNotFoundException("FireDTV: Trying to enable FireDTV remote but failed to set its path."); + } + } + catch (Exception) + { + throw new FileNotFoundException("FireDTV: Trying to enable FireDTV remote but failed"); + } + + _windowHandle = windowHandle; + + // initialise the library + InitializeLibrary(); + RegisterGeneralNotifications(); + } + + /// <summary> + /// Default contructer should not be called. + /// </summary> + private FireDTVControl() + { + } + + + ~FireDTVControl() + { + CloseDrivers(); + } + + #endregion + + #region Private Methods + + #region Initialization + + [DebuggerStepThrough] + internal void InitializeLibrary() + { + if (!LibrayInitialized) + { + try + { + uint returnCode = FireDTVAPI.FS_Initialize(); + if ((FireDTVConstants.FireDTVStatusCodes)returnCode != FireDTVConstants.FireDTVStatusCodes.Success) + { + throw new FireDTVInitializationException("Initilization Failure (" + returnCode.ToString() + ")"); + } + LibrayInitialized = true; + } + catch (Exception e) + { + throw new InvalidOperationException("FireDTV: error initializing "+ e.Message); + } + } + } + + #endregion + + #region FireDTV Open/Close Device + + internal uint OpenWDMDevice(int deviceIndex) + { + uint DeviceHandle; + uint returnCode = FireDTVAPI.FS_OpenWDMDeviceHandle((uint)deviceIndex, out DeviceHandle); + if ((FireDTVConstants.FireDTVStatusCodes)returnCode != FireDTVConstants.FireDTVStatusCodes.Success) + { + throw new FireDTVDeviceOpenException((FireDTVConstants.FireDTVStatusCodes)returnCode, "Open WDM Device Error!"); + } + return DeviceHandle; + } + + internal uint OpenBDADevice(int deviceIndex) + { + uint DeviceHandle; + uint returnCode = FireDTVAPI.FS_OpenBDADeviceHandle((uint)deviceIndex, out DeviceHandle); + if ((FireDTVConstants.FireDTVStatusCodes)returnCode != FireDTVConstants.FireDTVStatusCodes.Success) + { + throw new FireDTVDeviceOpenException((FireDTVConstants.FireDTVStatusCodes)returnCode, "Open BDA Device Error!"); + } + return DeviceHandle; + } + + internal void CloseFireDTVHandle(FireDTVSourceFilterInfo currentSourceFilter) + { + try + { + uint returnCode = FireDTVAPI.FS_CloseDeviceHandle(currentSourceFilter.Handle); + if ((FireDTVConstants.FireDTVStatusCodes)returnCode != FireDTVConstants.FireDTVStatusCodes.Success) + { + throw new FireDTVException((FireDTVConstants.FireDTVStatusCodes)returnCode, "Device Close Failure"); + } + } + catch (Exception) + { + } + } + + internal int getWDMCount() + { + try + { + uint WDMCount; + uint returnCode = FireDTVAPI.FS_GetNumberOfWDMDevices(out WDMCount); + if ((FireDTVConstants.FireDTVStatusCodes)returnCode != FireDTVConstants.FireDTVStatusCodes.Success) + { + throw new FireDTVException((FireDTVConstants.FireDTVStatusCodes)returnCode, "Unable to WDM Driver Count"); + } + return (int)WDMCount; + } + catch (Exception ex) + { + throw new InvalidOperationException("FireSATControl: Error getting WDM Devices "+ ex.Message); + } + } + + internal int getBDACount() + { + try + { + uint BDACount; + uint returnCode = FireDTVAPI.FS_GetNumberOfBDADevices(out BDACount); + if ((FireDTVConstants.FireDTVStatusCodes)returnCode != FireDTVConstants.FireDTVStatusCodes.Success) + { + throw new FireDTVException((FireDTVConstants.FireDTVStatusCodes)returnCode, "Unable to BDA Driver Count"); + } + return (int)BDACount; + } + catch (Exception ex) + { + throw new InvalidOperationException("FireSATControl: Error getting BDA Devices " + ex.Message); + } + } + + #endregion + + #region FireDTV Register Notifications + + internal void UnRegisterNotifications(uint widowHandle) + { + if (NotificationsRegistered) + { + uint returnCode = FireDTVAPI.FS_UnregisterNotifications(widowHandle); + if ((FireDTVConstants.FireDTVStatusCodes)returnCode != FireDTVConstants.FireDTVStatusCodes.Success) + { + throw new FireDTVException((FireDTVConstants.FireDTVStatusCodes)returnCode, + "Unable to unRegister Notifiations"); + } + NotificationsRegistered = false; + } + } + + [DebuggerStepThrough] + internal void RegisterGeneralNotifications() + { + if (!NotificationsRegistered) + { + try + { + uint returnCode = FireDTVAPI.FS_RegisterGeneralNotifications((int)WindowsHandle); + if ((FireDTVConstants.FireDTVStatusCodes)returnCode != FireDTVConstants.FireDTVStatusCodes.Success) + { + throw new FireDTVException((FireDTVConstants.FireDTVStatusCodes)returnCode, + "Unable to Register General Notifiations"); + } + NotificationsRegistered = true; + } + catch (Exception) + { + } + } + } + + #endregion + + #endregion + + #region Private Variables + + private bool LibrayInitialized = false; + private bool NotificationsRegistered = false; + private IntPtr _windowHandle = (IntPtr)0; + private SourceFilterCollection _sourceFilterCollection = new SourceFilterCollection(); + + #endregion + + #region Properties + + public SourceFilterCollection SourceFilters + { + get { return _sourceFilterCollection; } + set { _sourceFilterCollection = value; } + } + + /// <summary> + /// Get the API version of the FireDTV libary + /// </summary> + public string APIVersion + { + get { return Marshal.PtrToStringAnsi(FireDTVAPI.FS_GetApiVersion()); } + } + + public IntPtr WindowsHandle + { + get + { + if (_windowHandle == (IntPtr)0) + { + return (IntPtr)FireDTVAPI.GetActiveWindow(); + } + else + { + return _windowHandle; + } + } + } + + #endregion + + #region Public Methods + + /// <summary> + /// Open the communication channels with the FireDTV's. + /// </summary> + /// <returns>true if success</returns> + public bool OpenDrivers() + { + if (!LibrayInitialized) + { + return false; + } + + int BDADriverCount = getBDACount(); + int WDMDriverCount = getWDMCount(); + + for (int BDACount = 0; BDACount < BDADriverCount; BDACount++) + { + FireDTVSourceFilterInfo bdaSourceFilter = new FireDTVSourceFilterInfo(OpenBDADevice(BDACount), _windowHandle); + _sourceFilterCollection.Add(bdaSourceFilter); + } + + for (int WDMCount = 0; WDMCount < WDMDriverCount; WDMCount++) + { + FireDTVSourceFilterInfo wdmSourceFilter = new FireDTVSourceFilterInfo(OpenWDMDevice(WDMCount), _windowHandle); + _sourceFilterCollection.Add(wdmSourceFilter); + } + return true; + } + + public void CloseDrivers() + { + for (int DeviceCount = 0; DeviceCount < SourceFilters.Count; DeviceCount++) + { + FireDTVSourceFilterInfo SourceFilter = SourceFilters.Item(DeviceCount); + _sourceFilterCollection.RemoveAt(DeviceCount); + } + } + + public bool StopRemoteControlSupport() + { + foreach (FireDTVSourceFilterInfo SourceFilter in _sourceFilterCollection) + { + if (SourceFilter.RemoteRunning) + { + SourceFilter.StopFireDTVRemoteControlSupport(); + return SourceFilter.RemoteRunning; + } + } + return false; + } + + #endregion + } +} \ No newline at end of file Added: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/FireDTV interfaces/FireSATDefines.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/FireDTV interfaces/FireSATDefines.cs (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/FireDTV interfaces/FireSATDefines.cs 2009-08-09 20:13:30 UTC (rev 3048) @@ -0,0 +1,390 @@ +#region Copyright (C) 2005-2009 Team MediaPortal + +/* + * Copyright (C) 2005-2009 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#endregion + +using System; +using System.Runtime.InteropServices; +using System.Runtime.Serialization; +using System.Text; + +namespace IRServer.Plugin +{ + public class FireDTVConstants + { + #region Constants + + public const int WM_USER = 0x0400; + + #endregion + + #region FireDTV Enumeration + + public enum FireDTVWindowMessages + { + DeviceAttached = WM_USER + 1, + DeviceDetached = WM_USER + 2, + DeviceChanged = WM_USER + 3, + CIModuleInserted = WM_USER + 4, + CIModuleReady = WM_USER + 5, + CIModuleRemoved = WM_USER + 6, + CIMMI = WM_USER + 7, + CIDateTime = WM_USER + 8, + CIPMTReply = WM_USER + 9, + RemoteControlEvent = WM_USER + 10 + } + + public enum FireDTVStatusCodes + { + Success = 0, + Error = 1, + InvalidDeviceHandle = 2, + InvalidValue = 3, + AlreadyInUse = 4, + NotSuppotedByTuner = 5, + } ; + + #endregion + + #region Structs + + public struct FireDTV_DRIVER_VERSION + { + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] public byte[] DriverVersion; + } + + [StructLayout(LayoutKind.Sequential)] + public struct FireDTV_FIRMWARE_VERSION + { + public byte uHWMajor; + public byte uHWMiddle; + public byte uHWMinor; + public byte uSWMajor; + public byte uSWMiddle; + public byte uSWMinor; + public byte uBuildNrMSB; + public byte uBuildNrLSB; + } + + [StructLayout(LayoutKind.Sequential)] + public struct FireDTV_SYSTEM_INFO + { + public byte uNrAntennas; //0-3 + public byte uAntennaInfo; //ANTENNA_FIX, ANTENNA_MOVABLE, ANTENNA_MOBIL + public byte uSystem; // + public byte uTransport; //TRANSPORT_SATELLITE, TRANSPORT_CABLE, TRANSPORT_TERRESTRIAL + public bool bLists; + } + + #endregion + } + + #region FireDTV Exception Class + + public class FireDTVException : Exception + { + public FireDTVException() + { + } + + public FireDTVException(string message) + : base(message) + { + } + + public FireDTVException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + + public FireDTVException(FireDTVConstants.FireDTVStatusCodes status, string message) + { + friendlyMessage = message; + statusCode = status; + } + + + private FireDTVConstants.FireDTVStatusCodes statusCode; + private string friendlyMessage; + + public FireDTVConstants.FireDTVStatusCodes StatusCode + { + get { return statusCode; } + } + + public override string Message + { + get + { + if (friendlyMessage != string.Empty) + { + return friendlyMessage; + } + else + { + switch (statusCode) + { + case FireDTVConstants.FireDTVStatusCodes.AlreadyInUse: + return "DEVICE ALREADY IN USE!"; + + + case FireDTVConstants.FireDTVStatusCodes.Error: + return "STATUS ERROR!"; + + + case FireDTVConstants.FireDTVStatusCodes.InvalidDeviceHandle: + return "INVALID DEVICE HANDLE!"; + + + case FireDTVConstants.FireDTVStatusCodes.InvalidValue: + return "INVALID VALUE!"; + + + case FireDTVConstants.FireDTVStatusCodes.NotSuppotedByTuner: + return "NOT SUPPORTED BY TUNER!"; + + + default: + return base.Message; + } + } + } + } + } + + public class FireDTVInitializationException : FireDTVException + { + public FireDTVInitializationException() + { + } + + public FireDTVInitializationException(string message) + : base(message) + { + } + + public FireDTVInitializationException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } + + public class FireDTVDeviceOpenException : FireDTVException + { + public FireDTVDeviceOpenException() + { + } + + public FireDTVDeviceOpenException(string message) + : base(message) + { + } + + public FireDTVDeviceOpenException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + + public FireDTVDeviceOpenException(FireDTVConstants.FireDTVStatusCodes status, string message) + : base(status, message) + { + } + } + + #endregion + + /// <summary> + /// Summary description for FireDTVDefines. + /// </summary> + public class FireDTVAPI + { + #region FireDTV API Imports + + [DllImport("FireSATApi.dll", + EntryPoint = "?FS_Initialize@@YAKXZ", + PreserveSig = false, + CallingConvention = CallingConvention.StdCall)] + public static extern uint FS_Initialize(); + + [DllImport("FireSATApi.dll", + EntryPoint = "?FS_RegisterGeneralNotifications@@YAKPAUHWND__@@@Z", + SetLastError = true, + CharSet = CharSet.Unicode, + ExactSpelling = true, + PreserveSig = false, + CallingConvention = CallingConvention.StdCall)] + public static extern uint FS_RegisterGeneralNotifications(int hWnd); + + [DllImport("FireSATApi.dll", + EntryPoint = "?FS_GetNumberOfWDMDevices@@YAKPAK@Z", + SetLastError = true, + CharSet = CharSet.Unicode, + ExactSpelling = true, + PreserveSig = false, + CallingConvention = CallingConvention.StdCall)] + public static extern uint FS_GetNumberOfWDMDevices(out uint puNumberOfWDMDevices); + + [DllImport("FireSATApi.dll", + EntryPoint = "?FS_GetNumberOfBDADevices@@YAKPAK@Z", + SetLastError = true, + CharSet = CharSet.Unicode, + ExactSpelling = true, + PreserveSig = false, + CallingConvention = CallingConvention.StdCall)] + public static extern uint FS_GetNumberOfBDADevices(out uint puNumberOfWDMDevices); + + [DllImport("FireSATApi.dll", + EntryPoint = "?FS_OpenWDMDeviceHandle@@YAKKPAK@Z", + SetLastError = true, + CharSet = CharSet.Ansi, + ExactSpelling = true, + PreserveSig = false, + CallingConvention = CallingConvention.StdCall)] + public static extern uint FS_OpenWDMDeviceHandle(uint uWDMDeviceNumber, out uint pDeviceHandle); + + [DllImport("FireSATApi.dll", + EntryPoint = "?FS_OpenBDADeviceHandle@@YAKKPAK@Z", + SetLastError = true, + CharSet = CharSet.Ansi, + ExactSpelling = true, + PreserveSig = false, + CallingConvention = CallingConvention.StdCall)] + public static extern uint FS_OpenBDADeviceHandle(uint uBDADeviceNumber, out uint DeviceHandle); + + [DllImport("FireSATApi.dll", + EntryPoint = "?FS_CloseDeviceHandle@@YAKK@Z", + SetLastError = true, + CharSet = CharSet.Ansi, + ExactSpelling = true, + PreserveSig = false, + CallingConvention = CallingConvention.StdCall)] + public static extern uint FS_CloseDeviceHandle(uint DeviceHandle); + + [DllImport("FireSATApi.dll", + EntryPoint = "?FS_RegisterNotifications@@YAKKPAUHWND__@@@Z", + SetLastError = true, + CharSet = CharSet.Ansi, + ExactSpelling = true, + PreserveSig = false, + CallingConvention = CallingConvention.StdCall)] + public static extern uint FS_RegisterNotifications(uint DeviceHandle, int hWnd); + + [DllImport("FireSATApi.dll", + EntryPoint = "?FS_UnregisterNotifications@@YAKK@Z", + SetLastError = true, + CharSet = CharSet.Ansi, + ExactSpelling = true, + PreserveSig = false, + CallingConvention = CallingConvention.StdCall)] + public static extern uint FS_UnregisterNotifications(uint DeviceHandle); + + [DllImport("FireSATApi.dll", + EntryPoint = "?FS_GetApiVersion@@YAPADXZ", + SetLastError = true, + CharSet = CharSet.Ansi, + ExactSpelling = true, + PreserveSig = true, + CallingConvention = CallingConvention.StdCall)] + public static extern IntPtr FS_GetApiVersion(); + + [DllImport("FireSATApi.dll", + EntryPoint = "?FS_GetFriendlyString@@YAKKPAPAD@Z", + SetLastError = true, + CharSet = CharSet.Ansi, + ExactSpelling = true, + PreserveSig = true, + CallingConvention = CallingConvention.StdCall)] + public static extern uint FS_GetFriendlyString(uint deviceHandle, out string friendlyName); + + [DllImport("FireSATApi.dll", + EntryPoint = "?FS_GetDisplayString@@YAKKPAD@Z", + SetLastError = true, + CharSet = CharSet.Ansi, + ExactSpelling = true, + PreserveSig = true, + CallingConvention = CallingConvention.StdCall)] + public static extern uint FS_GetDisplayString(uint DeviceHandle, StringBuilder strDisplayName); + + [DllImport("FireSATApi.dll", + EntryPoint = "?FS_GetGUIDString@@YAKKPAD@Z", + SetLastError = true, + CharSet = CharSet.Ansi, + ExactSpelling = true, + PreserveSig = false, + CallingConvention = CallingConvention.StdCall)] + public static extern uint FS_GetGUIDString(uint DeviceHandle, StringBuilder strGUIDName); + + [DllImport("FiresatApi.dll", + EntryPoint = "?FS_GetDriverVersion@@YAKKPAU_FIRESAT_DRIVER_VERSION@@@Z", + SetLastError = true, + CharSet = CharSet.Ansi, + ExactSpelling = true, + CallingConvention = CallingConvention.StdCall)] + public static extern uint FS_GetDriverVersion(uint DeviceHandle, + ref FireDTVConstants.FireDTV_DRIVER_VERSION pDriverVersion); + + [DllImport("FireSATApi.dll", + EntryPoint = "?FS_GetFirmwareVersion@@YAKKPAU_FIRESAT_FIRMWARE_VERSION@@@Z", + SetLastError = true, + CharSet = CharSet.Ansi, + ExactSpelling = true, + CallingConvention = CallingConvention.StdCall)] + public static extern uint FS_GetFirmwareVersion(uint DeviceHandle, + ref FireDTVConstants.FireDTV_FIRMWARE_VERSION Version); + + [DllImport("FiresatApi.dll", + EntryPoint = "?FS_GetSystemInfo@@YAKKPAU_FIRESAT_SYSTEM_INFO@@@Z", + SetLastError = true, + CharSet = CharSet.Ansi, + ExactSpelling = true, + CallingConvention = CallingConvention.StdCall)] + public static extern uint FS_GetSystemInfo(uint DeviceHandle, ref FireDTVConstants.FireDTV_SYSTEM_INFO pSystemInfo); + + [DllImport("FireSATApi.dll", + EntryPoint = "?FS_RemoteControl_Start@@YAKK@Z", + SetLastError = true, + CharSet = CharSet.Ansi, + ExactSpelling = true, + PreserveSig = false, + CallingConvention = CallingConvention.StdCall)] + public static extern uint FS_RemoteControl_Start(uint DeviceHandle); + + [DllImport("FireSATApi.dll", + EntryPoint = "?FS_RemoteControl_Stop@@YAKK@Z", + SetLastError = true, + CharSet = CharSet.Ansi, + ExactSpelling = true, + PreserveSig = false, + CallingConvention = CallingConvention.StdCall)] + public static extern uint FS_RemoteControl_Stop(uint DeviceHandle); + + #endregion + + #region Win32 API Imports + + [DllImport("user32.dll", CharSet = CharSet.Ansi)] + public static extern int GetActiveWindow(); + + #endregion + } ; +} \ No newline at end of file Added: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/FireDTV interfaces/FireSATSourceFilterInfo.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/FireDTV interfaces/FireSATSourceFilterInfo.cs (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/FireDTV interfaces/FireSATSourceFilterInfo.cs 2009-08-09 20:13:30 UTC (rev 3048) @@ -0,0 +1,364 @@ +#region Copyright (C) 2005-2009 Team MediaPortal + +/* + * Copyright (C) 2005-2009 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#endregion + +#region Usings + +using System; +using System.Collections; +using System.Text; + +#endregion + +namespace IRServer.Plugin +{ + public class FireDTVSourceFilterInfo + { + public FireDTVSourceFilterInfo(uint deviceHandle, IntPtr activeWindow) + { + _windowHandle = activeWindow; + _handle = deviceHandle; + + StringBuilder displayName = new StringBuilder(256); + uint returnCode = FireDTVAPI.FS_GetDisplayString(Handle, displayName); + if ((FireDTVConstants.FireDTVStatusCodes) returnCode != FireDTVConstants.FireDTVStatusCodes.Success) + { + throw new FireDTVException((FireDTVConstants.FireDTVStatusCodes) returnCode, + "Unable to get Device Display Name!"); + } + _name = displayName.ToString(); + + StringBuilder GuidString = new StringBuilder(256); + returnCode = FireDTVAPI.FS_GetGUIDString(Handle, GuidString); + if ((FireDTVConstants.FireDTVStatusCodes) returnCode != FireDTVConstants.FireDTVStatusCodes.Success) + { + throw new FireDTVException((FireDTVConstants.FireDTVStatusCodes) returnCode, "Unable to get GUID String!"); + } + _GUID = GuidString.ToString(); + + string DriverFriend; + returnCode = FireDTVAPI.FS_GetFriendlyString(Handle, out DriverFriend); + if ((FireDTVConstants.FireDTVStatusCodes) returnCode != FireDTVConstants.FireDTVStatusCodes.Success) + { + throw new FireDTVException((FireDTVConstants.FireDTVStatusCodes) returnCode, + "Unable to get Device Friendly Name!"); + } + _friendlyName = DriverFriend; + + FireDTVConstants.FireDTV_DRIVER_VERSION version = new FireDTVConstants.FireDTV_DRIVER_VERSION(); + returnCode = FireDTVAPI.FS_GetDriverVersion(Handle, ref version); + if ((FireDTVConstants.FireDTVStatusCodes) returnCode != FireDTVConstants.FireDTVStatusCodes.Success) + { + throw new FireDTVException((FireDTVConstants.FireDTVStatusCodes) returnCode, "Unable to get Driver Version!"); + } + _driverVersion = Encoding.ASCII.GetString(version.DriverVersion); + + returnCode = FireDTVAPI.FS_GetFirmwareVersion(Handle, ref _firmwareVersion); + if ((FireDTVConstants.FireDTVStatusCodes) returnCode != FireDTVConstants.FireDTVStatusCodes.Success) + { + throw new FireDTVException((FireDTVConstants.FireDTVStatusCodes) returnCode, + "Unable to get Firmware Hardware Version!"); + } + + returnCode = FireDTVAPI.FS_GetSystemInfo(Handle, ref _systemInfo); + if ((FireDTVConstants.FireDTVStatusCodes) returnCode != FireDTVConstants.FireDTVStatusCodes.Success) + { + throw new FireDTVException((FireDTVConstants.FireDTVStatusCodes) returnCode, "Unable to get System Information!"); + } + + + RegisterNotifications(); + } + + ~FireDTVSourceFilterInfo() + { + Close(); + } + + public void Close() + { + if (_handle != 0) + { + if (_remoteRunning) + { + StopFireDTVRemoteControlSupport(); + } + + if (_notificationRegistered) + { + UnRegisterNotifications(); + } + + CloseFireDTVHandle(); + } + } + + #region Private variables + + private uint _handle; + private string _name; + private string _friendlyName; + private string _GUID; + private string _driverVersion; + private IntPtr _windowHandle = (IntPtr) 0; + private bool _remoteRunning = false; + private bool _notificationRegistered = false; + + private FireDTVConstants.FireDTV_FIRMWARE_VERSION _firmwareVersion = new FireDTVConstants.FireDTV_FIRMWARE_VERSION(); + private FireDTVConstants.FireDTV_SYSTEM_INFO _systemInfo = new FireDTVConstants.FireDTV_SYSTEM_INFO(); + //IBaseFilter *pFilter; + + #endregion + + #region Properties + + public string Name + { + get { return _name; } + } + + public string GUID + { + get { return _GUID; } + } + + public uint Handle + { + get { return _handle; } + set { _handle = value; } + } + + public string FriendlyName + { + get { return _friendlyName; } + } + + public bool RemoteRunning + { + get { return _remoteRunning; } + } + + public IntPtr WindowHandle + { + get + { + if (_windowHandle == (IntPtr) 0) + { + return (IntPtr) FireDTVAPI.GetActiveWindow(); + } + else + { + return _windowHandle; + } + } + } + + #endregion + + /// <summary> + /// ToString() for debugging and logging. + /// </summary> + /// <returns></returns> + public override String ToString() + { + return String.Format("SourceFilter: handle[{0}],name[{1}],friendly[{2}],GUID[{3}],version[{4}]", + _handle, _name, _friendlyName, _GUID, _driverVersion); + } + + #region FireDTV Close Device + + internal void CloseFireDTVHandle() + { + uint returnCode = FireDTVAPI.FS_CloseDeviceHandle(Handle); + if ((FireDTVConstants.FireDTVStatusCodes) returnCode != FireDTVConstants.FireDTVStatusCodes.Success) + { + throw new FireDTVException((FireDTVConstants.FireDTVStatusCodes) returnCode, "Device Close Failure"); + } + _handle = 0; + } + + #endregion + + #region FireDTV Register Notifications + + public void RegisterNotifications() + { + uint returnCode = FireDTVAPI.FS_RegisterNotifications(Handle, (int) this.WindowHandle); + if ((FireDTVConstants.FireDTVStatusCodes) returnCode != FireDTVConstants.FireDTVStatusCodes.Success) + { + throw new FireDTVException((FireDTVConstants.FireDTVStatusCodes) returnCode, "Unable to Register Notifiations"); + } + _notificationRegistered = true; + } + + public void UnRegisterNotifications() + { + uint returnCode = FireDTVAPI.FS_UnregisterNotifications(Handle); + if ((FireDTVConstants.FireDTVStatusCodes) returnCode != FireDTVConstants.FireDTVStatusCodes.Success) + { + throw new FireDTVException((FireDTVConstants.FireDTVStatusCodes) returnCode, "Unable to unRegister Notifiations"); + } + _notificationRegistered = false; + } + + #endregion + + #region Remote Control Management + + public void StartFireDTVRemoteControlSupport() + { + uint returnCode = FireDTVAPI.FS_RemoteControl_Start(Handle); + if ((FireDTVConstants.FireDTVStatusCodes) returnCode != FireDTVConstants.FireDTVStatusCodes.Success) + { + throw new FireDTVException((FireDTVConstants.FireDTVStatusCodes) returnCode, "Unable to Start RC Support"); + } + _remoteRunning = true; + } + + public void StopFireDTVRemoteControlSupport() + { + uint returnCode = FireDTVAPI.FS_RemoteControl_Stop(Handle); + if ((FireDTVConstants.FireDTVStatusCodes) returnCode != FireDTVConstants.FireDTVStatusCodes.Success) + { + throw new FireDTVException((FireDTVConstants.FireDTVStatusCodes) returnCode, "Unable to Stop RC Support"); + } + _remoteRunning = true; + } + + #endregion + } + + /// <summary> + /// Strongly typed collection of FireDTVSourceFilters + /// </summary> + public class SourceFilterCollection : CollectionBase + { + public void Add(FireDTVSourceFilterInfo sourceFilter) + { + foreach (FireDTVSourceFilterInfo srcFilter in List) + { + if (srcFilter.Name == sourceFilter.Name) + { + sourceFilter.Close(); + return; + } + } + List.Add(sourceFilter); + } + + /// <summary> + /// Remove a FilterSource but first close it. + /// </summary> + /// <param name="index">index of the filter</param> + public new void RemoveAt(int index) + { + if (index > List.Count - 1 || index < 0) + { + throw new IndexOutOfRangeException("Source Filter Index out of Bounds"); + } + else + { + ((FireDTVSourceFilterInfo) List[index]).Close(); + List.RemoveAt(index); + } + } + + /// <summary> + /// Remove a FilterSource, but first close it. + /// </summary> + /// <param name="index">index of the filter</param> + public void RemoveByHandle(uint deviceHandle) + { + foreach (FireDTVSourceFilterInfo sourceFilter in List) + { + if (sourceFilter.Handle == deviceHandle) + { + List.Remove(sourceFilter); + } + } + // TODO <THROW ERROR> + } + + public FireDTVSourceFilterInfo Item(int index) + { + if (index > List.Count - 1 || index < 0) + { + throw new IndexOutOfRangeException("Source Filter Index out of Bounds"); + } + else + { + return (FireDTVSourceFilterInfo) List[index]; + } + } + + public FireDTVSourceFilterInfo ItemByHandle(uint deviceHandle) + { + foreach (FireDTVSourceFilterInfo sourceFilter in List) + { + if (sourceFilter.Handle == deviceHandle) + { + return sourceFilter; + } + } + return null; + } + + public FireDTVSourceFilterInfo ItemByName(string displayString) + { + foreach (FireDTVSourceFilterInfo SourceFilter in List) + { + if (SourceFilter.Name == displayString) + { + return SourceFilter; + } + } + return null; + } + + public FireDTVSourceFilterInfo ItemByGUID(string guidString) + { + foreach (FireDTVSourceFilterInfo SourceFilter in List) + { + if (SourceFilter.GUID == guidString) + { + return SourceFilter; + } + } + return null; + } + + public int IndexByHandle(uint deviceHandle) + { + for (int iIndex = 0; iIndex < List.Count; iIndex++) + { + FireDTVSourceFilterInfo SourceFilter = Item(iIndex); + if (SourceFilter.Handle == deviceHandle) + { + return iIndex; + } + } + return -1; + } + } +} \ No newline at end of file Added: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/FireDTVReceiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/FireDTVReceiver.cs (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/FireDTVReceiver.cs 2009-08-09 20:13:30 UTC (rev 3048) @@ -0,0 +1,300 @@ +#region Copyright (C) 2005-2009 Team MediaPortal + +// Copyright (C) 2005-2009 Team MediaPortal +// http://www.team-mediaportal.com +// +// This Program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// This Program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with GNU Make; see the file COPYING. If not, write to +// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +// http://www.gnu.org/copyleft/gpl.html + +#endregion + +using System; +using System.Drawing; +using System.IO; +using System.Text; +using System.Windows.Forms; +using System.Xml; +using IRServer.Plugin.Properties; +using IrssUtils; + +namespace IRServer.Plugin +{ + /// <summary> + /// IR Server Plugin for X10 Transceiver devices. + /// </summary> + public class FireDTVReceiver : PluginBase, IRemoteReceiver, IConfigure + { + #region Constants + + private static readonly string ConfigurationFile = Path.Combine(ConfigurationPath, "FireDTV Receiver.xml"); + + #endregion Constants + + #region Variables + + private static RemoteHandler _remoteButtonHandler; + private string _deviceName; + private FireDTVControl _fireDTV = null; + private ReceiverWindow _receiverWindow; + + #endregion Variables + + /// <summary> + /// Name of the IR Server plugin. + /// </summary> + /// <value>The name.</value> + public override string Name + { + get { return "... [truncated message content] |