Permalink
Browse files

intial commit of patch #0.3

  • Loading branch information...
2 parents 7a0483b + e14e7c7 commit a660d8bbc9fa1edaa80ed03f659c20ea7f2812b1 @gibman gibman committed Aug 26, 2011
@@ -0,0 +1,6 @@
+USE %TvLibrary%;
+
+ALTER TABLE "Recording"
+ ADD COLUMN "mediaType" int(1) NOT NULL;
+
+UPDATE Version SET versionNumber=60;
@@ -0,0 +1,9 @@
+use %TvLibrary%
+GO
+
+ALTER TABLE Recording
+ ADD mediaType int NOT NULL DEFAULT ((1))
+GO
+
+UPDATE Version SET versionNumber=60
+GO
@@ -983,7 +983,8 @@ private static Recording BuildRecordingFromTag(string aFileName, MatroskaTagInfo
aTag.episodeName,
aTag.seriesNum,
aTag.episodeNum,
- aTag.episodePart
+ aTag.episodePart,
+ Convert.ToInt32(aTag.mediaType)
);
}
catch (Exception ex)
@@ -663,6 +663,8 @@
<EmbeddedResource Include="40_upgrade_sqlserver_database.sql" />
</ItemGroup>
<ItemGroup>
+ <EmbeddedResource Include="59_upgrade_mysql_database.sql" />
+ <EmbeddedResource Include="59_upgrade_sqlserver_database.sql" />
<Content Include="images\animation.SatDish.gif" />
<Content Include="images\icon.card.gif" />
<Content Include="images\icon.computer.gif" />
@@ -735,8 +737,8 @@
<EmbeddedResource Include="57_upgrade_sqlserver_database.sql" />
<EmbeddedResource Include="58_upgrade_mysql_database.sql" />
<EmbeddedResource Include="58_upgrade_sqlserver_database.sql" />
- <EmbeddedResource Include="59_upgrade_mysql_database.sql" />
- <EmbeddedResource Include="59_upgrade_sqlserver_database.sql" />
+ <EmbeddedResource Include="60_upgrade_mysql_database.sql" />
+ <EmbeddedResource Include="60_upgrade_sqlserver_database.sql" />
<None Include="images\icon.down.png" />
<Content Include="images\icon.mpConfig.ico" />
<Content Include="images\icon.radio_fta.png" />
@@ -0,0 +1,29 @@
+#region Copyright (C) 2005-2010 Team MediaPortal
+
+// Copyright (C) 2005-2010 Team MediaPortal
+// http://www.team-mediaportal.com
+//
+// MediaPortal 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 of the License, or
+// (at your option) any later version.
+//
+// MediaPortal 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 MediaPortal. If not, see <http://www.gnu.org/licenses/>.
+
+#endregion
+
+namespace TvDatabase
+{
+ public enum MediaTypeEnum
+ {
+ TV,
+ Radio
+ }
+
+}
@@ -37,6 +37,9 @@ public class Recording : Persistent
[TableColumn("idRecording", NotNull = true), PrimaryKey(AutoGenerated = true)] private int idRecording;
[TableColumn("idChannel", NotNull = true), ForeignKey("Channel", "idChannel")] private int idChannel;
[TableColumn("idSchedule", NotNull = true), ForeignKey("Schedule", "idSchedule")] private int idSchedule;
+
+ [TableColumn("mediaType", NotNull = true)] private int mediaType;
+
[TableColumn("isRecording", NotNull = false)] private bool isRecording;
[TableColumn("startTime", NotNull = true)] private DateTime startTime;
[TableColumn("endTime", NotNull = true)] private DateTime endTime;
@@ -66,6 +69,37 @@ public class Recording : Persistent
string description, string genre,
string fileName, int keepUntil, DateTime keepUntilDate, int timesWatched, int idServer,
string episodeName,
+ string seriesNum, string episodeNum, string episodePart, int mediaType)
+ {
+ this.mediaType = mediaType;
+ isChanged = true;
+ this.idChannel = idChannel;
+ this.isRecording = isRecording;
+ this.idSchedule = idSchedule;
+ this.startTime = startTime;
+ this.endTime = endTime;
+ this.title = title;
+ this.description = description;
+ this.genre = genre;
+ this.fileName = fileName;
+ this.keepUntil = keepUntil;
+ this.keepUntilDate = keepUntilDate;
+ this.timesWatched = timesWatched;
+ this.idServer = idServer;
+ stopTime = 0;
+ this.episodeName = episodeName;
+ this.seriesNum = seriesNum;
+ this.episodeNum = episodeNum;
+ this.episodePart = episodePart;
+ }
+
+ /// <summary>
+ /// Create a new object by specifying all fields (except the auto-generated primary key field).
+ /// </summary>
+ public Recording(int idChannel, int idSchedule, bool isRecording, DateTime startTime, DateTime endTime, string title,
+ string description, string genre,
+ string fileName, int keepUntil, DateTime keepUntilDate, int timesWatched, int idServer,
+ string episodeName,
string seriesNum, string episodeNum, string episodePart)
{
isChanged = true;
@@ -124,6 +158,22 @@ public class Recording : Persistent
#region Public Properties
+ public bool IsTV
+ {
+ get
+ {
+ return (mediaType == (int)MediaTypeEnum.TV);
+ }
+ }
+
+ public bool IsRadio
+ {
+ get
+ {
+ return (mediaType == (int)MediaTypeEnum.Radio);
+ }
+ }
+
/// <summary>
/// Is recording a manual one
/// </summary>
@@ -385,7 +435,7 @@ public bool IsRecording
{
get
{
- this.Refresh();
+ //this.Refresh(); //slow
return isRecording;
}
set
@@ -398,6 +448,19 @@ public bool IsRecording
#endregion
#region Storage and Retrieval
+ /// <summary>
+ /// Static method to retrieve all instances that are stored in the database in one call
+ /// </summary>
+ public static IList<Recording> ListAllRadio()
+ {
+ SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof(Recording));
+ sb.AddConstraint(Operator.Equals, "mediaType", (int)MediaTypeEnum.Radio);
+
+ SqlStatement stmt = sb.GetStatement(true);
+
+ // execute the statement/query and create a collection of User instances from the result set
+ return ObjectFactory.GetCollection<Recording>(stmt.Execute());
+ }
/// <summary>
/// Static method to retrieve all instances that are stored in the database in one call
@@ -410,6 +473,21 @@ public static IList<Recording> ListAll()
/// <summary>
/// Static method to retrieve all instances that are stored in the database in one call
/// </summary>
+ public static IList<Recording> ListAllTv()
+ {
+ SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof(Recording));
+ sb.AddConstraint(Operator.Equals, "mediaType", (int)MediaTypeEnum.TV);
+
+ SqlStatement stmt = sb.GetStatement(true);
+
+ // execute the statement/query and create a collection of User instances from the result set
+ return ObjectFactory.GetCollection<Recording>(stmt.Execute());
+
+ }
+
+ /// <summary>
+ /// Static method to retrieve all instances that are stored in the database in one call
+ /// </summary>
public static void ResetActiveRecordings()
{
/*SqlBuilder sb = new SqlBuilder(StatementType.Update, typeof(Recording));
@@ -559,6 +637,8 @@ public override void Persist()
{
try
{
+ PersistMediaType();
+
base.Persist();
}
catch (Exception ex)
@@ -570,6 +650,19 @@ public override void Persist()
}
}
+ private void PersistMediaType()
+ {
+ Channel refChannel = ReferencedChannel();
+ if (refChannel.IsRadio)
+ {
+ mediaType = (int)MediaTypeEnum.Radio;
+ }
+ else if (refChannel.IsTv)
+ {
+ mediaType = (int)MediaTypeEnum.TV;
+ }
+ }
+
#endregion
#region Relations
@@ -616,6 +709,11 @@ public bool ShouldBeDeleted
}
}
+ public int MediaType
+ {
+ get { return mediaType; }
+ }
+
public void Delete()
{
Remove();
@@ -82,6 +82,7 @@
<Compile Include="ChannelLinkageMap.cs" />
<Compile Include="ChannelMap.cs" />
<Compile Include="Conflict.cs" />
+ <Compile Include="Enums\MediaType.cs" />
<Compile Include="PendingDeletion.cs" />
<Compile Include="EpisodeFormatter.cs" />
<Compile Include="SoftwareEncoder.cs" />
@@ -39,6 +39,7 @@ public class MatroskaTagInfo
public string episodePart = "";
public DateTime startTime = SqlDateTime.MinValue.Value;
public DateTime endTime = SqlDateTime.MinValue.Value;
+ public string mediaType = "1";
}
/// <summary>
@@ -162,6 +163,9 @@ public static MatroskaTagInfo ReadTag(string filename)
string tagName = simpleTag.ChildNodes[0].InnerText;
switch (tagName)
{
+ case "MEDIATYPE":
+ info.mediaType = simpleTag.ChildNodes[1].InnerText;
+ break;
case "TITLE":
info.title = simpleTag.ChildNodes[1].InnerText;
break;
@@ -228,6 +232,7 @@ public static void WriteTag(string filename, MatroskaTagInfo taginfo)
XmlNode tagsNode = doc.CreateElement("tags");
XmlNode tagNode = doc.CreateElement("tag");
tagNode.AppendChild(AddSimpleTag("TITLE", taginfo.title, doc));
+ tagNode.AppendChild(AddSimpleTag("MEDIATYPE", taginfo.mediaType, doc));
tagNode.AppendChild(AddSimpleTag("COMMENT", taginfo.description, doc));
tagNode.AppendChild(AddSimpleTag("GENRE", taginfo.genre, doc));
tagNode.AppendChild(AddSimpleTag("CHANNEL_NAME", taginfo.channelName, doc));
@@ -215,12 +215,7 @@ public interface IController
/// </summary>
/// <param name="idRecording">The id recording.</param>
bool DeleteRecording(int idRecording);
-
- /// <summary>
- /// Checks if the files of a recording still exist
- /// </summary>
- /// <param name="idRecording">The id of the recording</param>
- bool IsRecordingValid(int idRecording);
+
/// <summary>
/// Deletes invalid recordings from database. A recording is invalid if the corresponding file no longer exists.
@@ -100,23 +100,7 @@ public bool DeleteRecording(int idRecording)
HandleFailure();
}
return false;
- }
-
- /// <summary>
- /// Checks if the files of a recording still exist
- /// </summary>
- /// <param name="idRecording">The id of the recording</param>
- public bool IsRecordingValid(int idRecording)
- {
- try
- {
- return RemoteControl.Instance.IsRecordingValid(idRecording);
- }
- catch (Exception)
- {
- return true;
- }
- }
+ }
/// <summary>
/// Gets the user for card.
@@ -117,7 +117,6 @@ Global
{59C2EBC8-0FEA-4B2E-B5D1-476347332331}.Release|x86.ActiveCfg = Release|x86
{59C2EBC8-0FEA-4B2E-B5D1-476347332331}.Release|x86.Build.0 = Release|x86
{E9D3F443-A654-4D94-BBAA-080362D25D7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {E9D3F443-A654-4D94-BBAA-080362D25D7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E9D3F443-A654-4D94-BBAA-080362D25D7C}.Debug|x86.ActiveCfg = Debug|x86
{E9D3F443-A654-4D94-BBAA-080362D25D7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E9D3F443-A654-4D94-BBAA-080362D25D7C}.Release|Any CPU.Build.0 = Release|Any CPU
@@ -637,27 +637,15 @@ private void LoadDirectory()
List<GUIListItem> itemlist = new List<GUIListItem>();
try
{
- GUIControl.ClearControl(GetID, facadeLayout.GetID);
-
- IList<RadioGroupMap> radiogroups = RadioGroupMap.ListAll();
- IList<Recording> recordings = Recording.ListAll();
+ GUIControl.ClearControl(GetID, facadeLayout.GetID);
+ IList<Recording> recordings = Recording.ListAllRadio();
if (_currentLabel == string.Empty)
{
foreach (Recording rec in recordings)
{
// catch exceptions here so MP will go on and list further recs
try
- {
- bool isRadioChannel = false;
- foreach (RadioGroupMap radiogroup in radiogroups)
- {
- if (rec.IdChannel == radiogroup.IdChannel)
- {
- isRadioChannel = true;
- break;
- }
- }
- if (isRadioChannel == false) continue; // only RadioChannels are allowed
+ {
bool add = true;
// combine recordings with the same name to a folder located on top
@@ -1023,7 +1011,7 @@ private bool OnSelectedRecording(int iItem)
GUIPropertyManager.SetProperty("#Play.Current.Thumb", pItem.ThumbnailImage);
Recording rec = (Recording)pItem.TVTag;
- IList<Recording> itemlist = Recording.ListAll();
+ IList<Recording> itemlist = Recording.ListAllRadio();
_oActiveRecording = rec;
_bIsLiveRecording = false;
@@ -3234,8 +3234,8 @@ private static bool PreTuneChecks(Channel channel, out bool doContinue)
ChannelState CurrentChanState = TvServer.GetChannelState(channel.IdChannel, Card.User);
if (CurrentChanState == ChannelState.nottunable)
{
- ChannelTuneFailedNotifyUser(TvResult.AllCardsBusy, false, channel);
- return false;
+ //ChannelTuneFailedNotifyUser(TvResult.AllCardsBusy, false, channel);
+ //return false;
}
//BAV: fixing mantis bug 1263: TV starts with no video if Radio is previously ON & channel selected from TV guide
Oops, something went wrong.

0 comments on commit a660d8b

Please sign in to comment.