From: <do...@us...> - 2009-05-26 08:32:27
|
Revision: 2869 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=2869&view=rev Author: dot-i Date: 2009-05-26 08:32:13 +0000 (Tue, 26 May 2009) Log Message: ----------- Updated to For The Record 1.4 plugin source code. Modified Paths: -------------- trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Channels/ChannelLink.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Channels/ChannelLinks.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/CreateChannelLinkForm.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/ForTheRecord.RecorderTuners.MediaPortalTvServer.csproj trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/MediaPortalRecorderTunerService.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/RecordingThread.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SettingName.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SetupForm.Designer.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SetupForm.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SetupForm.resx trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/TvServerPlugin.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Utility.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/ActiveRecordings.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/ChannelNavigator.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/ForTheRecord.UI.MediaPortal.csproj trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TVZapOSD.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TextId.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvFullScreen.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvGuide.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvGuideDialog.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvGuideSearch.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvOSD.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvProgramInfo.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvRecorded.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvRecordingOverlay.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/UpcomingPrograms.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/Utility.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/WindowId.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/language/fortherecord_da.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/language/fortherecord_de.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/language/fortherecord_en.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/language/fortherecord_nl.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/language/fortherecord_sv.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Aeon wide/4TR_Home.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Blue3/4TR_Home.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Blue3/4TR_RecordedTv.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Blue3wide/4TR_Home.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Blue3wide/4TR_RecordedTv.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Indigo/4TR_Home.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Indigo/4TR_RecordedTv.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Monochrome/4TR_Home.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Monochrome/4TR_RecordedTv.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/CurrentAndNextProgramView.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/EditSchedule/EditScheduleController.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/EditSchedule/EditScheduleModel.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/ForTheRecord.UI.Process.csproj trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/KeepUntilControlUtility.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/ProcessUtility.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/Recordings/RecordingsController.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/Recordings/RecordingsModel.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/ScheduleNamesCache.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/SearchGuide/SearchGuideController.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/SearchGuide/SearchGuideModel.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/UpcomingGuideProgramsDictionary.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/UpcomingOrActiveProgramView.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/UpcomingOrActiveProgramsList.cs trunk/plugins/ForTheRecord/ReferencedAssemblies/Core.dll trunk/plugins/ForTheRecord/ReferencedAssemblies/Databases.dll trunk/plugins/ForTheRecord/ReferencedAssemblies/Dialogs.dll trunk/plugins/ForTheRecord/ReferencedAssemblies/ForTheRecord.Entities.dll trunk/plugins/ForTheRecord/ReferencedAssemblies/ForTheRecord.RecorderTuners.Common.dll trunk/plugins/ForTheRecord/ReferencedAssemblies/ForTheRecord.ServiceAgents.dll trunk/plugins/ForTheRecord/ReferencedAssemblies/ForTheRecord.ServiceContracts.dll trunk/plugins/ForTheRecord/ReferencedAssemblies/Gentle.Common.dll trunk/plugins/ForTheRecord/ReferencedAssemblies/Gentle.Framework.dll trunk/plugins/ForTheRecord/ReferencedAssemblies/PluginBase.dll trunk/plugins/ForTheRecord/ReferencedAssemblies/SetupControls.dll trunk/plugins/ForTheRecord/ReferencedAssemblies/TVDatabase.dll trunk/plugins/ForTheRecord/ReferencedAssemblies/TvBusinessLayer.dll trunk/plugins/ForTheRecord/ReferencedAssemblies/TvControl.dll trunk/plugins/ForTheRecord/ReferencedAssemblies/TvLibrary.Interfaces.dll trunk/plugins/ForTheRecord/ReferencedAssemblies/Utils.dll Added Paths: ----------- trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/DvbEpgThread.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Properties/Resources.Designer.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Properties/Resources.resx trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Resources/ trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Resources/WizardHeader.bmp trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/ThreeStateTreeView.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Wizards/ trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Wizards/ImportChannels/ trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Wizards/ImportChannels/FinishPage.Designer.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Wizards/ImportChannels/FinishPage.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Wizards/ImportChannels/FinishPage.resx trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Wizards/ImportChannels/ImportChannelsContext.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Wizards/ImportChannels/ImportChannelsPage.Designer.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Wizards/ImportChannels/ImportChannelsPage.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Wizards/ImportChannels/ImportChannelsPage.resx trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Wizards/ImportChannels/ImportChannelsPageBase.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Wizards/ImportChannels/ImportChannelsWizard.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Wizards/WizardForm.Designer.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Wizards/WizardForm.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Wizards/WizardForm.resx trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Wizards/WizardPage.Designer.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Wizards/WizardPage.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Wizards/WizardPage.resx trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/ForTheRecordMain.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/GuideBase.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/GuideSearchBase.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/Hamming.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/HomeBase.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/MiniGuide.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/RadioGuide.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/RadioGuideSearch.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/RadioHome.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/RadioRecorded.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/RecordedBase.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TeletextPageRenderer.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvFullscreenTeletext.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvHome.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvTeletext.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvTeletextBase.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/language/fortherecord_pl.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Aeon wide/4TR_RadioGuide.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Aeon wide/4TR_RadioGuideSearch.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Aeon wide/4TR_RadioHome.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Aeon wide/4TR_RecordedRadio.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Aeon wide/4TR_TvGuide.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Blue3/4TR_RadioGuide.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Blue3/4TR_RadioGuideSearch.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Blue3/4TR_RadioHome.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Blue3/4TR_RecordedRadio.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Blue3/4TR_TvGuide.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Blue3wide/4TR_RadioGuide.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Blue3wide/4TR_RadioGuideSearch.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Blue3wide/4TR_RadioHome.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Blue3wide/4TR_RecordedRadio.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Blue3wide/4TR_TvGuide.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Indigo/4TR_RadioGuide.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Indigo/4TR_RadioGuideSearch.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Indigo/4TR_RadioHome.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Indigo/4TR_RecordedRadio.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Indigo/4TR_TvGuide.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Monochrome/4TR_RadioGuide.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Monochrome/4TR_RadioGuideSearch.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Monochrome/4TR_RadioHome.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Monochrome/4TR_RecordedRadio.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/Monochrome/4TR_TvGuide.xml trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/ChannelProgramView.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/ChannelProgramsList.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/Guide/ trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/Guide/ChannelPrograms.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/Guide/GuideController.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/Guide/GuideModel.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/Guide/GuideUpcomingProgram.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/LiveStreamView.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/LiveStreamsList.cs trunk/plugins/ForTheRecord/ReferencedAssemblies/ForTheRecord.Client.Common.dll Removed Paths: ------------- trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SyncEpgThread.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/ForTheRecordHome.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvGuideBase.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvMiniGuide.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/BlueTwo/ trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/BlueTwo wide/ trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/TvChannelProgramView.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/TvChannelProgramsList.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/TvGuide/ Modified: trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Channels/ChannelLink.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Channels/ChannelLink.cs 2009-05-22 21:00:13 UTC (rev 2868) +++ trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Channels/ChannelLink.cs 2009-05-26 08:32:13 UTC (rev 2869) @@ -23,15 +23,17 @@ using System.Text; using System.Xml.XPath; using System.Xml; +using ForTheRecord.Entities; namespace ForTheRecord.RecorderTuners.MediaPortalTvServer.Channels { internal class ChannelLink { - public ChannelLink(Guid tvChannelId, string tvChannelName, int mpChannelId, string mpChannelName) + public ChannelLink(ChannelType channelType, Guid channelId, string channelName, int mpChannelId, string mpChannelName) { - this.TvChannelId = tvChannelId; - this.TvChannelName = tvChannelName; + this.ChannelType = channelType; + this.ChannelId = channelId; + this.ChannelName = channelName; this.MPChannelId = mpChannelId; this.MPChannelName = mpChannelName; } @@ -39,11 +41,11 @@ public static ChannelLink Parse(XPathNavigator navigator) { ChannelLink result = null; - Guid tvChannelId = Guid.Empty; + Guid channelId = Guid.Empty; string id = navigator.GetAttribute("id", String.Empty); if (!String.IsNullOrEmpty(id)) { - tvChannelId = new Guid(id); + channelId = new Guid(id); } int mpChannelId = -1; string mpId = navigator.GetAttribute("mpId", String.Empty); @@ -51,12 +53,22 @@ { mpChannelId = Int32.Parse(mpId); } - if (tvChannelId != Guid.Empty + if (channelId != Guid.Empty && mpChannelId >= 0) { - string tvChannelName = navigator.GetAttribute("name", String.Empty); + string channelName = navigator.GetAttribute("name", String.Empty); + ChannelType channelType; + string type = navigator.GetAttribute("type", String.Empty); + if (String.IsNullOrEmpty(type)) + { + channelType = ChannelType.Television; + } + else + { + channelType = (ChannelType)Enum.Parse(typeof(ChannelType), type); + } string mpChannelName = navigator.GetAttribute("mpName", String.Empty); - result = new ChannelLink(tvChannelId, tvChannelName, mpChannelId, mpChannelName); + result = new ChannelLink(channelType, channelId, channelName, mpChannelId, mpChannelName); } return result; } @@ -64,17 +76,20 @@ public void WriteToXml(XmlTextWriter xmlWriter) { xmlWriter.WriteStartElement("link"); - xmlWriter.WriteAttributeString("id", this.TvChannelId.ToString()); - xmlWriter.WriteAttributeString("name", this.TvChannelName.ToString()); + xmlWriter.WriteAttributeString("id", this.ChannelId.ToString()); + xmlWriter.WriteAttributeString("name", this.ChannelName.ToString()); + xmlWriter.WriteAttributeString("type", this.ChannelType.ToString()); xmlWriter.WriteAttributeString("mpId", this.MPChannelId.ToString()); xmlWriter.WriteAttributeString("mpName", this.MPChannelName.ToString()); xmlWriter.WriteEndElement(); } - public Guid TvChannelId { get; set; } + public ChannelType ChannelType { get; set; } - public string TvChannelName { get; set; } + public Guid ChannelId { get; set; } + public string ChannelName { get; set; } + public int MPChannelId { get; set; } public string MPChannelName { get; set; } Modified: trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Channels/ChannelLinks.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Channels/ChannelLinks.cs 2009-05-22 21:00:13 UTC (rev 2868) +++ trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Channels/ChannelLinks.cs 2009-05-26 08:32:13 UTC (rev 2869) @@ -26,94 +26,102 @@ using System.Collections; using System.Text; -using TvDatabase; +using System.Threading; -using ForTheRecord.Entities; using Gentle.Framework; +using ForTheRecord.Entities; + namespace ForTheRecord.RecorderTuners.MediaPortalTvServer.Channels { internal class ChannelLinks { + private ReaderWriterLock _readerWriterLock = new ReaderWriterLock(); + private Dictionary<Guid, ChannelLink> _linksById = new Dictionary<Guid, ChannelLink>(); + private Dictionary<int, bool> _autoLinkedMPChannels = new Dictionary<int, bool>(); private ChannelLinks() { - Load(); + LoadChannelLinks(true); } - public static ChannelLinks LoadChannelLinks() + #region Singleton + + private static ChannelLinks Instance { - return new ChannelLinks(); + get + { + return Nested.instance; + } } - public LinkedMediaPortalChannel GetLinkedMediaPortalChannel(TvChannel tvChannel) + private class Nested { + // Explicit static constructor to tell C# compiler + // not to mark type as beforefieldinit + static Nested() + { + } + + internal static readonly ChannelLinks instance = new ChannelLinks(); + } + + #endregion + + public static LinkedMediaPortalChannel GetLinkedMediaPortalChannel(Channel channel) + { bool isAutoLinked; bool duplicateChannelsFound; - return GetLinkedMediaPortalChannel(tvChannel, out isAutoLinked, out duplicateChannelsFound); + return GetLinkedMediaPortalChannel(channel, out isAutoLinked, out duplicateChannelsFound); } - public LinkedMediaPortalChannel GetLinkedMediaPortalChannel(Guid tvChannelId, string displayName) + public static LinkedMediaPortalChannel GetLinkedMediaPortalChannel(ChannelType channelType, Guid channelId, string displayName) { bool isAutoLinked; bool duplicateChannelsFound; - return GetLinkedMediaPortalChannel(tvChannelId, displayName, out isAutoLinked, out duplicateChannelsFound); + return GetLinkedMediaPortalChannel(channelType, channelId, displayName, out isAutoLinked, out duplicateChannelsFound); } - public LinkedMediaPortalChannel GetLinkedMediaPortalChannel(TvChannel tvChannel, out bool isAutoLinked, out bool duplicateChannelsFound) + public static LinkedMediaPortalChannel GetLinkedMediaPortalChannel(Channel channel, out bool isAutoLinked, out bool duplicateChannelsFound) { - return GetLinkedMediaPortalChannel(tvChannel.TvChannelId, tvChannel.DisplayName, out isAutoLinked, out duplicateChannelsFound); + return GetLinkedMediaPortalChannel(channel.ChannelType, channel.ChannelId, channel.DisplayName, out isAutoLinked, out duplicateChannelsFound); } - public LinkedMediaPortalChannel GetLinkedMediaPortalChannel(Guid tvChannelId, string displayName, out bool isAutoLinked, out bool duplicateChannelsFound) + public static LinkedMediaPortalChannel GetLinkedMediaPortalChannel(ChannelType channelType, Guid channelId, string displayName, + out bool isAutoLinked, out bool duplicateChannelsFound) { - isAutoLinked = false; - duplicateChannelsFound = false; + return Instance.GetLinkedMediaPortalChannelInternal(channelType, channelId, displayName, out isAutoLinked, out duplicateChannelsFound); + } - if (_linksById.ContainsKey(tvChannelId)) - { - ChannelLink link = _linksById[tvChannelId]; - return new LinkedMediaPortalChannel(link.MPChannelId, link.MPChannelName, link.MPChannelDisplayName); - } + public static bool IsAutoLinked(TvDatabase.Channel mpChannel) + { + return Instance.IsAutoLinkedInternal(mpChannel); + } - Channel channel = GetChannelByDisplayName(displayName, out duplicateChannelsFound); - if (channel != null) - { - isAutoLinked = true; - return new LinkedMediaPortalChannel(channel.IdChannel, channel.Name, channel.DisplayName); - } + public static void SetLinkedMediaPortalChannel(Channel channel, TvDatabase.Channel mpChannel) + { + Instance.SetLinkedMediaPortalChannelInternal(channel, mpChannel); + } - return null; + public static void ClearLinkedMediaPortalChannel(Channel channel) + { + Instance.ClearLinkedMediaPortalChannelInternal(channel); } - public void SetLinkedMediaPortalChannel(TvChannel tvChannel, Channel mpChannel) + public static ChannelLink GetChannelLinkForMediaPortalChannel(TvDatabase.Channel channel) { - ClearLinkedMediaPortalChannel(tvChannel); - ChannelLink link = new ChannelLink(tvChannel.TvChannelId, tvChannel.DisplayName, mpChannel.IdChannel, mpChannel.Name); - link.MPChannelDisplayName = mpChannel.DisplayName; - _linksById.Add(link.TvChannelId, link); + return Instance.GetChannelLinkForMediaPortalChannelInternal(channel); } - public void ClearLinkedMediaPortalChannel(TvChannel tvChannel) + public static void RemoveObsoleteLinks(ChannelType channelType, List<Channel> channels) { - if (_linksById.ContainsKey(tvChannel.TvChannelId)) - { - _linksById.Remove(tvChannel.TvChannelId); - } + Instance.RemoveObsoleteLinksInternal(channelType, channels); } - public ChannelLink GetChannelLinkForMediaPortalChannel(Channel channel) + public static void Save() { - foreach (ChannelLink link in _linksById.Values) - { - if (link.MPChannelId == channel.IdChannel - && link.MPChannelName == channel.Name) - { - return link; - } - } - return null; + Instance.SaveChannelLinks(); } #region Serialization @@ -128,97 +136,294 @@ } } - private void Load() + private DateTime _lastFileWriteTimeUtc = DateTime.MinValue; + + private void EnsureLoaded() { - _linksById.Clear(); + LoadChannelLinks(false); + } + + private void LoadChannelLinks(bool forceLoad) + { string settingsFileName = this.SettingsFileName; - if (File.Exists(settingsFileName)) + if (!File.Exists(settingsFileName)) { - using (StreamReader reader = new StreamReader(settingsFileName, Encoding.UTF8)) + _readerWriterLock.AcquireWriterLock(Timeout.Infinite); + try { - XPathDocument xpathDocument = new XPathDocument(reader); - XPathNavigator navigator = xpathDocument.CreateNavigator(); - XPathNodeIterator iterator = navigator.Select("/links/link"); - while (iterator.MoveNext()) + _linksById.Clear(); + _autoLinkedMPChannels.Clear(); + return; + } + finally + { + _readerWriterLock.ReleaseWriterLock(); + } + } + + DateTime lastWriteTimeUtc = File.GetLastWriteTimeUtc(settingsFileName); + if (forceLoad + || lastWriteTimeUtc != _lastFileWriteTimeUtc) + { + _readerWriterLock.AcquireWriterLock(Timeout.Infinite); + try + { + _lastFileWriteTimeUtc = lastWriteTimeUtc; + _linksById.Clear(); + _autoLinkedMPChannels.Clear(); + using (StreamReader reader = new StreamReader(settingsFileName, Encoding.UTF8)) { - ChannelLink link = ChannelLink.Parse(iterator.Current); - if (link != null) + XPathDocument xpathDocument = new XPathDocument(reader); + XPathNavigator navigator = xpathDocument.CreateNavigator(); + XPathNodeIterator iterator = navigator.Select("/links/link"); + while (iterator.MoveNext()) { - Channel channel = GetChannelById(link.MPChannelId); - if (channel == null - || channel.Name != link.MPChannelName) + ChannelLink link = ChannelLink.Parse(iterator.Current); + if (link != null) { - channel = GetChannelByName(link.MPChannelName); + TvDatabase.Channel mpChannel = GetChannelById(link.ChannelType, link.MPChannelId); + if (mpChannel == null + || mpChannel.Name != link.MPChannelName) + { + mpChannel = GetChannelByName(link.ChannelType, link.MPChannelName); + } + if (mpChannel != null) + { + link.MPChannelDisplayName = mpChannel.DisplayName; + _linksById.Add(link.ChannelId, link); + } } - if (channel != null) - { - link.MPChannelDisplayName = channel.DisplayName; - _linksById.Add(link.TvChannelId, link); - } } } } + finally + { + _readerWriterLock.ReleaseWriterLock(); + } } } - public void Save() + private void SaveChannelLinks() { - string settingsFileName = this.SettingsFileName; - string settingsDirName = Path.GetDirectoryName(settingsFileName); - if (!Directory.Exists(settingsDirName)) + _readerWriterLock.AcquireReaderLock(Timeout.Infinite); + try { - Directory.CreateDirectory(settingsDirName); + string settingsFileName = this.SettingsFileName; + string settingsDirName = Path.GetDirectoryName(settingsFileName); + if (!Directory.Exists(settingsDirName)) + { + Directory.CreateDirectory(settingsDirName); + } + using (XmlTextWriter xmlWriter = new XmlTextWriter(this.SettingsFileName, Encoding.UTF8)) + { + xmlWriter.Formatting = Formatting.Indented; + xmlWriter.WriteStartDocument(); + xmlWriter.WriteStartElement("links"); + foreach (ChannelLink link in _linksById.Values) + { + link.WriteToXml(xmlWriter); + } + xmlWriter.WriteEndElement(); + } + _lastFileWriteTimeUtc = File.GetLastWriteTimeUtc(settingsFileName); } - using (XmlTextWriter xmlWriter = new XmlTextWriter(this.SettingsFileName, Encoding.UTF8)) + finally { - xmlWriter.Formatting = Formatting.Indented; - xmlWriter.WriteStartDocument(); - xmlWriter.WriteStartElement("links"); + _readerWriterLock.ReleaseReaderLock(); + } + } + + #endregion + + #region Private Methods + + private LinkedMediaPortalChannel GetLinkedMediaPortalChannelInternal(ChannelType channelType, Guid channelId, string displayName, out bool isAutoLinked, out bool duplicateChannelsFound) + { + EnsureLoaded(); + + _readerWriterLock.AcquireReaderLock(Timeout.Infinite); + try + { + isAutoLinked = false; + duplicateChannelsFound = false; + + if (_linksById.ContainsKey(channelId)) + { + ChannelLink link = _linksById[channelId]; + return new LinkedMediaPortalChannel(link.MPChannelId, link.MPChannelName, link.MPChannelDisplayName); + } + + TvDatabase.Channel channel = GetChannelByDisplayName(channelType, displayName, + out duplicateChannelsFound); + if (channel != null) + { + isAutoLinked = true; + _autoLinkedMPChannels[channel.IdChannel] = true; + return new LinkedMediaPortalChannel(channel.IdChannel, channel.Name, channel.DisplayName); + } + + return null; + } + finally + { + _readerWriterLock.ReleaseReaderLock(); + } + } + + private ChannelLink GetChannelLinkForMediaPortalChannelInternal(TvDatabase.Channel channel) + { + EnsureLoaded(); + + _readerWriterLock.AcquireReaderLock(Timeout.Infinite); + try + { foreach (ChannelLink link in _linksById.Values) { - link.WriteToXml(xmlWriter); + if (link.MPChannelId == channel.IdChannel + && link.MPChannelName == channel.Name) + { + return link; + } } - xmlWriter.WriteEndElement(); + return null; } + finally + { + _readerWriterLock.ReleaseReaderLock(); + } } - #endregion + public bool IsAutoLinkedInternal(TvDatabase.Channel mpChannel) + { + EnsureLoaded(); - #region Private Methods + _readerWriterLock.AcquireReaderLock(Timeout.Infinite); + try + { + return _autoLinkedMPChannels.ContainsKey(mpChannel.IdChannel); + } + finally + { + _readerWriterLock.ReleaseReaderLock(); + } + } - private Channel GetChannelByDisplayName(string displayName, out bool duplicateChannelsFound) + public void SetLinkedMediaPortalChannelInternal(Channel channel, TvDatabase.Channel mpChannel) { - return InternalGetChannelBy("displayName", displayName, out duplicateChannelsFound); + EnsureLoaded(); + + _readerWriterLock.AcquireWriterLock(Timeout.Infinite); + try + { + ClearLinkedMediaPortalChannel(channel); + ChannelLink link = new ChannelLink(channel.ChannelType, channel.ChannelId, channel.DisplayName, mpChannel.IdChannel, mpChannel.Name); + link.MPChannelDisplayName = mpChannel.DisplayName; + _linksById.Add(link.ChannelId, link); + } + finally + { + _readerWriterLock.ReleaseWriterLock(); + } } - private Channel GetChannelById(int id) + public void ClearLinkedMediaPortalChannelInternal(Channel channel) { + EnsureLoaded(); + + _readerWriterLock.AcquireWriterLock(Timeout.Infinite); + try + { + if (_linksById.ContainsKey(channel.ChannelId)) + { + _linksById.Remove(channel.ChannelId); + } + } + finally + { + _readerWriterLock.ReleaseWriterLock(); + } + } + + private void RemoveObsoleteLinksInternal(ChannelType channelType, List<Channel> channels) + { + EnsureLoaded(); + + _readerWriterLock.AcquireWriterLock(Timeout.Infinite); + try + { + List<Guid> obsoleteLinks = new List<Guid>(); + foreach (Guid channelId in _linksById.Keys) + { + if (_linksById[channelId].ChannelType == channelType + && !ChannelListContains(channels, channelId)) + { + obsoleteLinks.Add(channelId); + } + } + foreach (Guid channelId in obsoleteLinks) + { + _linksById.Remove(channelId); + } + } + finally + { + _readerWriterLock.ReleaseWriterLock(); + } + } + + private TvDatabase.Channel GetChannelByDisplayName(ChannelType channelType, string displayName, out bool duplicateChannelsFound) + { + return InternalGetChannelBy(channelType, "displayName", displayName, out duplicateChannelsFound); + } + + private TvDatabase.Channel GetChannelById(ChannelType channelType, int id) + { bool duplicateChannelsFound; - return InternalGetChannelBy("idChannel", id, out duplicateChannelsFound); + return InternalGetChannelBy(channelType, "idChannel", id, out duplicateChannelsFound); } - private Channel GetChannelByName(string name) + private TvDatabase.Channel GetChannelByName(ChannelType channelType, string name) { bool duplicateChannelsFound; - return InternalGetChannelBy("name", name, out duplicateChannelsFound); + return InternalGetChannelBy(channelType, "name", name, out duplicateChannelsFound); } - private Channel InternalGetChannelBy(string columnName, object value, out bool duplicateChannelsFound) + private TvDatabase.Channel InternalGetChannelBy(ChannelType channelType, string columnName, object value, out bool duplicateChannelsFound) { - SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof(Channel)); + SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof(TvDatabase.Channel)); sb.AddConstraint(Operator.Equals, columnName, value); sb.AddConstraint(Operator.Equals, "visibleInGuide", true); + if (channelType == ChannelType.Television) + { + sb.AddConstraint(Operator.Equals, "isTv", true); + } + else + { + sb.AddConstraint(Operator.Equals, "isRadio", true); + } SqlResult result = Broker.Execute(sb.GetStatement()); if (result.Rows.Count == 1) { duplicateChannelsFound = false; - IList channels = ObjectFactory.GetCollection(typeof(Channel), result); - return channels[0] as Channel; + IList channels = ObjectFactory.GetCollection(typeof(TvDatabase.Channel), result); + return channels[0] as TvDatabase.Channel; } duplicateChannelsFound = (result.Rows.Count > 0); return null; } + private static bool ChannelListContains(List<Channel> channels, Guid channelId) + { + foreach (Channel channel in channels) + { + if (channel.ChannelId == channelId) + { + return true; + } + } + return false; + } + #endregion } } Modified: trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/CreateChannelLinkForm.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/CreateChannelLinkForm.cs 2009-05-22 21:00:13 UTC (rev 2868) +++ trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/CreateChannelLinkForm.cs 2009-05-26 08:32:13 UTC (rev 2869) @@ -5,7 +5,6 @@ using System.Text; using System.Windows.Forms; -using TvDatabase; using Gentle.Framework; using ForTheRecord.Entities; @@ -20,29 +19,27 @@ InitializeComponent(); } - internal ChannelLinks ChannelLinks { set; get; } + internal Channel Channel { set; get; } - internal TvChannel TvChannel { set; get; } - private void CreateShareForm_Load(object sender, EventArgs e) { - _channelNameLabel.Text = this.TvChannel.DisplayName; + _channelNameLabel.Text = this.Channel.DisplayName; LoadGroups(); - LinkedMediaPortalChannel linkedChannel = this.ChannelLinks.GetLinkedMediaPortalChannel(this.TvChannel); + LinkedMediaPortalChannel linkedChannel = ChannelLinks.GetLinkedMediaPortalChannel(this.Channel); if (linkedChannel != null) { - SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof(GroupMap)); + SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof(TvDatabase.GroupMap)); sb.AddConstraint(Operator.Equals, "idChannel", linkedChannel.Id); SqlResult result = Broker.Execute(sb.GetStatement()); - List<GroupMap> groupMaps = (List<GroupMap>) - ObjectFactory.GetCollection(typeof(GroupMap), result, new List<GroupMap>()); + List<TvDatabase.GroupMap> groupMaps = (List<TvDatabase.GroupMap>) + ObjectFactory.GetCollection(typeof(TvDatabase.GroupMap), result, new List<TvDatabase.GroupMap>()); if (groupMaps.Count > 0) { foreach (ListViewItem item in _groupsListView.Items) { - ChannelGroup channelGroup = item.Tag as ChannelGroup; - if (channelGroup.IdGroup == groupMaps[0].IdGroup) + if (item.Tag is int + && (int)item.Tag == groupMaps[0].IdGroup) { item.Selected = true; _groupsListView.EnsureVisible(item.Index); @@ -74,21 +71,44 @@ private void LoadGroups() { - SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof(ChannelGroup)); - sb.AddOrderByField("groupName"); - SqlResult result = Broker.Execute(sb.GetStatement()); - List<ChannelGroup> channelGroups = (List<ChannelGroup>) - ObjectFactory.GetCollection(typeof(ChannelGroup), result, new List<ChannelGroup>()); - _groupsListView.Items.Clear(); - foreach (ChannelGroup channelGroup in channelGroups) + if (this.Channel.ChannelType == ChannelType.Television) { - ListViewItem item = new ListViewItem(channelGroup.GroupName); - item.Tag = channelGroup; - _groupsListView.Items.Add(item); + List<TvDatabase.ChannelGroup> groups = Utility.GetAllGroups<TvDatabase.ChannelGroup>(); + foreach (TvDatabase.ChannelGroup group in groups) + { + if (group.GroupName.Equals("All Channels", StringComparison.CurrentCultureIgnoreCase)) + { + groups.Remove(group); + break; + } + } + groups.Add(new TvDatabase.ChannelGroup(-1, "All Channels")); + foreach (TvDatabase.ChannelGroup group in groups) + { + ListViewItem item = new ListViewItem(group.GroupName); + item.Tag = group.IdGroup; + _groupsListView.Items.Add(item); + } } - ListViewItem allItem = new ListViewItem("All Channels"); - allItem.Tag = null; - _groupsListView.Items.Add(allItem); + else + { + List<TvDatabase.RadioChannelGroup> groups = Utility.GetAllGroups<TvDatabase.RadioChannelGroup>(); + foreach (TvDatabase.RadioChannelGroup group in groups) + { + if (group.GroupName.Equals("All Channels", StringComparison.CurrentCultureIgnoreCase)) + { + groups.Remove(group); + break; + } + } + groups.Add(new TvDatabase.RadioChannelGroup(-1, "All Channels")); + foreach (TvDatabase.RadioChannelGroup group in groups) + { + ListViewItem item = new ListViewItem(group.GroupName); + item.Tag = group.IdGroup; + _groupsListView.Items.Add(item); + } + } } private void _okButton_Click(object sender, EventArgs e) @@ -96,11 +116,11 @@ if (_channelsListView.SelectedItems.Count > 0) { ChannelItem channelItem = _channelsListView.SelectedItems[0].Tag as ChannelItem; - this.ChannelLinks.SetLinkedMediaPortalChannel(this.TvChannel, channelItem.Channel); + ChannelLinks.SetLinkedMediaPortalChannel(this.Channel, channelItem.Channel); } else { - this.ChannelLinks.ClearLinkedMediaPortalChannel(this.TvChannel); + ChannelLinks.ClearLinkedMediaPortalChannel(this.Channel); } this.DialogResult = DialogResult.OK; this.Close(); @@ -108,7 +128,7 @@ private void _clearLinkButton_Click(object sender, EventArgs e) { - this.ChannelLinks.ClearLinkedMediaPortalChannel(this.TvChannel); + ChannelLinks.ClearLinkedMediaPortalChannel(this.Channel); this.DialogResult = DialogResult.OK; this.Close(); } @@ -125,37 +145,16 @@ { if (_groupsListView.SelectedItems.Count > 0) { - ChannelGroup group = _groupsListView.SelectedItems[0].Tag as ChannelGroup; + int groupId = (int)_groupsListView.SelectedItems[0].Tag; List<ChannelItem> channelItems = new List<ChannelItem>(); - if (group == null) + List<TvDatabase.Channel> channels = + Utility.GetAllChannelsInGroup(this.Channel.ChannelType, groupId); + foreach (TvDatabase.Channel channel in channels) { - SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof(Channel)); - sb.AddConstraint(Operator.Equals, "visibleInGuide", true); - sb.AddOrderByField("displayName"); - SqlResult result = Broker.Execute(sb.GetStatement()); - List<Channel> channels = (List<Channel>)ObjectFactory.GetCollection(typeof(Channel), result, new List<Channel>()); - foreach(Channel channel in channels) - { - channelItems.Add(new ChannelItem(channel)); - } + channelItems.Add(new ChannelItem(channel)); } - else - { - SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof(GroupMap)); - sb.AddConstraint(Operator.Equals, "idGroup", group.IdGroup); - SqlResult result = Broker.Execute(sb.GetStatement()); - List<GroupMap> groupMaps = (List<GroupMap>) - ObjectFactory.GetCollection(typeof(GroupMap), result, new List<GroupMap>()); - foreach (GroupMap groupMap in groupMaps) - { - channelItems.Add(new ChannelItem(groupMap.ReferencedChannel())); - } - channelItems.Sort( - delegate(ChannelItem c1, ChannelItem c2) { return c1.Channel.DisplayName.CompareTo(c2.Channel.DisplayName); }); - } - _channelsListView.Items.Clear(); foreach (ChannelItem channelItem in channelItems) { @@ -172,14 +171,14 @@ private class ChannelItem { - private Channel _channel; + private TvDatabase.Channel _channel; - public ChannelItem(Channel channel) + public ChannelItem(TvDatabase.Channel channel) { _channel = channel; } - public Channel Channel + public TvDatabase.Channel Channel { get { return _channel; } } Added: trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/DvbEpgThread.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/DvbEpgThread.cs (rev 0) +++ trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/DvbEpgThread.cs 2009-05-26 08:32:13 UTC (rev 2869) @@ -0,0 +1,145 @@ +/* + * Copyright (C) 2007-2009 ForTheRecord + * http://www.4therecord.eu + * + * 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 + * + */ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Text; +using System.Threading; + +using TvLibrary.Interfaces; +using TvEngine.Events; +using TvLibrary.Log; +using Gentle.Framework; + +using ForTheRecord.ServiceAgents; +using ForTheRecord.Entities; +using ForTheRecord.RecorderTuners.Common; +using ForTheRecord.RecorderTuners.MediaPortalTvServer.Channels; + +namespace ForTheRecord.RecorderTuners.MediaPortalTvServer +{ + internal class DvbEpgThread : WorkerThread + { + private List<List<GuideProgram>> _guideProgramsToImport = new List<List<GuideProgram>>(); + private AutoResetEvent _newProgramsToImportEvent; + private object _guideProgramsToImportLock = new object(); + + public DvbEpgThread() + : base("ForTheRecordDvbEpg") + { + } + + public void ImportProgramsAsync(List<GuideProgram> guidePrograms) + { + if (guidePrograms != null + && guidePrograms.Count > 0) + { + lock (_guideProgramsToImportLock) + { + _guideProgramsToImport.Add(guidePrograms); + if (_newProgramsToImportEvent != null) + { + _newProgramsToImportEvent.Set(); + } + } + } + } + + private List<GuideProgram> GetProgramsToImport() + { + lock (_guideProgramsToImportLock) + { + List<GuideProgram> result; + if (_guideProgramsToImport.Count > 0) + { + result = _guideProgramsToImport[0]; + _guideProgramsToImport.RemoveAt(0); + } + else + { + result = new List<GuideProgram>(); + } + return result; + } + } + + protected override void Run() + { + Thread.Sleep(5 * 1000); + + lock (_guideProgramsToImportLock) + { + _newProgramsToImportEvent = new AutoResetEvent(false); + } + try + { + int interval = 1 * 60 * 1000; +#if DEBUG + interval = 5000; +#endif + + bool aborted = false; + while (!aborted) + { + try + { + List<GuideProgram> guidePrograms = GetProgramsToImport(); + if (guidePrograms.Count > 0) + { + using (TvGuideServiceAgent tvGuideAgent = new TvGuideServiceAgent()) + { + Log.Debug("ForTheRecord.RecorderTuners.MediaPortalTvServer: ForTheRecordDvbEpg: importing {0} programs into For The Record", guidePrograms.Count); + foreach (GuideProgram guideProgram in guidePrograms) + { + tvGuideAgent.ImportProgram(guideProgram, GuideSource.DvbEpg); + aborted = this.StopThreadEvent.WaitOne(0, false); + if (aborted) + { + break; + } + } + } + } + if (!aborted) + { + aborted = (0 == WaitHandle.WaitAny(new WaitHandle[] { this.StopThreadEvent, _newProgramsToImportEvent }, interval, false)); + } + } + catch (Exception ex) + { + Log.Error("ForTheRecordDvbEpg error: {0}", ex.Message); + // Delay for a short while and then restart. + aborted = this.StopThreadEvent.WaitOne(30 * 1000, false); + } + } + } + finally + { + lock (_guideProgramsToImportLock) + { + _newProgramsToImportEvent.Close(); + _newProgramsToImportEvent = null; + } + } + } + } +} Modified: trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/ForTheRecord.RecorderTuners.MediaPortalTvServer.csproj =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/ForTheRecord.RecorderTuners.MediaPortalTvServer.csproj 2009-05-22 21:00:13 UTC (rev 2868) +++ trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/ForTheRecord.RecorderTuners.MediaPortalTvServer.csproj 2009-05-26 08:32:13 UTC (rev 2869) @@ -18,7 +18,7 @@ <OldToolsVersion>2.0</OldToolsVersion> <UpgradeBackupLocation> </UpgradeBackupLocation> - <TargetFrameworkVersion>v3.0</TargetFrameworkVersion> + <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> @@ -38,19 +38,19 @@ <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> - <Reference Include="ForTheRecord.Entities, Version=1.3.1.0, Culture=neutral, PublicKeyToken=a9a5dfc20b8d6175, processorArchitecture=MSIL"> + <Reference Include="ForTheRecord.Entities, Version=1.4.0.0, Culture=neutral, PublicKeyToken=a9a5dfc20b8d6175, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\ReferencedAssemblies\ForTheRecord.Entities.dll</HintPath> </Reference> - <Reference Include="ForTheRecord.RecorderTuners.Common, Version=1.3.1.0, Culture=neutral, PublicKeyToken=a9a5dfc20b8d6175, processorArchitecture=MSIL"> + <Reference Include="ForTheRecord.RecorderTuners.Common, Version=1.4.0.0, Culture=neutral, PublicKeyToken=a9a5dfc20b8d6175, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\ReferencedAssemblies\ForTheRecord.RecorderTuners.Common.dll</HintPath> </Reference> - <Reference Include="ForTheRecord.ServiceAgents, Version=1.3.1.0, Culture=neutral, PublicKeyToken=a9a5dfc20b8d6175, processorArchitecture=MSIL"> + <Reference Include="ForTheRecord.ServiceAgents, Version=1.4.0.0, Culture=neutral, PublicKeyToken=a9a5dfc20b8d6175, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\ReferencedAssemblies\ForTheRecord.ServiceAgents.dll</HintPath> </Reference> - <Reference Include="ForTheRecord.ServiceContracts, Version=1.3.1.0, Culture=neutral, PublicKeyToken=a9a5dfc20b8d6175, processorArchitecture=MSIL"> + <Reference Include="ForTheRecord.ServiceContracts, Version=1.4.0.0, Culture=neutral, PublicKeyToken=a9a5dfc20b8d6175, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\ReferencedAssemblies\ForTheRecord.ServiceContracts.dll</HintPath> </Reference> @@ -71,6 +71,9 @@ <HintPath>..\ForTheRecord.ReferencedAssemblies\MediaPortalAssemblies\SetupControls.dll</HintPath> </Reference> <Reference Include="System" /> + <Reference Include="System.Core"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> <Reference Include="System.Data" /> <Reference Include="System.Drawing" /> <Reference Include="System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL" /> @@ -107,6 +110,11 @@ <DependentUpon>CreateShareForm.cs</DependentUpon> </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="RecordingThread.cs" /> <Compile Include="SettingName.cs" /> <Compile Include="Channels\ChannelLink.cs" /> @@ -119,9 +127,43 @@ <DependentUpon>SetupForm.cs</DependentUpon> </Compile> <Compile Include="MediaPortalRecorderTunerService.cs" /> + <Compile Include="ThreeStateTreeView.cs"> + <SubType>Component</SubType> + </Compile> <Compile Include="TvServerPlugin.cs" /> - <Compile Include="SyncEpgThread.cs" /> + <Compile Include="DvbEpgThread.cs" /> <Compile Include="Utility.cs" /> + <Compile Include="Wizards\ImportChannels\ImportChannelsContext.cs" /> + <Compile Include="Wizards\ImportChannels\ImportChannelsPage.cs"> + <SubType>UserControl</SubType> + </Compile> + <Compile Include="Wizards\ImportChannels\ImportChannelsPage.Designer.cs"> + <DependentUpon>ImportChannelsPage.cs</DependentUpon> + </Compile> + <Compile Include="Wizards\ImportChannels\ImportChannelsPageBase.cs"> + <SubType>UserControl</SubType> + </Compile> + <Compile Include="Wizards\ImportChannels\ImportChannelsWizard.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Wizards\ImportChannels\FinishPage.cs"> + <SubType>UserControl</SubType> + </Compile> + <Compile Include="Wizards\ImportChannels\FinishPage.Designer.cs"> + <DependentUpon>FinishPage.cs</DependentUpon> + </Compile> + <Compile Include="Wizards\WizardForm.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Wizards\WizardForm.Designer.cs"> + <DependentUpon>WizardForm.cs</DependentUpon> + </Compile> + <Compile Include="Wizards\WizardPage.cs"> + <SubType>UserControl</SubType> + </Compile> + <Compile Include="Wizards\WizardPage.Designer.cs"> + <DependentUpon>WizardPage.cs</DependentUpon> + </Compile> </ItemGroup> <ItemGroup> <EmbeddedResource Include="CreateChannelLinkForm.resx"> @@ -132,14 +174,33 @@ <DependentUpon>CreateShareForm.cs</DependentUpon> <SubType>Designer</SubType> </EmbeddedResource> + <EmbeddedResource Include="Properties\Resources.resx"> + <Generator>ResXFileCodeGenerator</Generator> + <LastGenOutput>Resources.Designer.cs</LastGenOutput> + </EmbeddedResource> <EmbeddedResource Include="SetupForm.resx"> <DependentUpon>SetupForm.cs</DependentUpon> <SubType>Designer</SubType> </EmbeddedResource> + <EmbeddedResource Include="Wizards\ImportChannels\ImportChannelsPage.resx"> + <DependentUpon>ImportChannelsPage.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Wizards\ImportChannels\FinishPage.resx"> + <DependentUpon>FinishPage.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Wizards\WizardForm.resx"> + <DependentUpon>WizardForm.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Wizards\WizardPage.resx"> + <DependentUpon>WizardPage.cs</DependentUpon> + </EmbeddedResource> </ItemGroup> <ItemGroup> <None Include="PostBuild.cmd" /> </ItemGroup> + <ItemGroup> + <None Include="Resources\WizardHeader.bmp" /> + </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/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/MediaPortalRecorderTunerService.cs ========================... [truncated message content] |