From d6f410f01337b998fc5a97f1c1947e1819a02ff1 Mon Sep 17 00:00:00 2001 From: Marcel Groothuis Date: Sun, 1 Sep 2013 19:40:16 +0200 Subject: [PATCH] [MediaPortal] Update TVServer enums and put them in the TvDatabase namespace --- .../src/recordings.cpp | 10 ++-- .../pvr.mediaportal.tvserver/src/timers.cpp | 56 +++++++++---------- addons/pvr.mediaportal.tvserver/src/timers.h | 25 ++++++--- 3 files changed, 49 insertions(+), 42 deletions(-) diff --git a/addons/pvr.mediaportal.tvserver/src/recordings.cpp b/addons/pvr.mediaportal.tvserver/src/recordings.cpp index caf09b091..41a170fab 100644 --- a/addons/pvr.mediaportal.tvserver/src/recordings.cpp +++ b/addons/pvr.mediaportal.tvserver/src/recordings.cpp @@ -217,15 +217,15 @@ int cRecording::Lifetime(void) const // automatically deleted in favour of a new recording, until the // given number of days since the start time of the recording has // passed by - KeepMethodType m_keepmethod = (KeepMethodType) m_keepUntil; + TvDatabase::KeepMethodType m_keepmethod = (TvDatabase::KeepMethodType) m_keepUntil; switch (m_keepmethod) { - case UntilSpaceNeeded: //until space needed - case UntilWatched: //until watched + case TvDatabase::UntilSpaceNeeded: //until space needed + case TvDatabase::UntilWatched: //until watched return 0; break; - case UntilKeepDate: //until keepdate + case TvDatabase::TillDate: //until keepdate { double diffseconds = difftime(m_keepUntilDate, m_StartTime); int daysremaining = (int)(diffseconds / cSecsInDay); @@ -241,7 +241,7 @@ int cRecording::Lifetime(void) const } } break; - case Forever: //forever + case TvDatabase::Always: //forever return MAXLIFETIME; default: return MAXLIFETIME; diff --git a/addons/pvr.mediaportal.tvserver/src/timers.cpp b/addons/pvr.mediaportal.tvserver/src/timers.cpp index 44bce13bb..1fddfcc76 100644 --- a/addons/pvr.mediaportal.tvserver/src/timers.cpp +++ b/addons/pvr.mediaportal.tvserver/src/timers.cpp @@ -35,11 +35,11 @@ cTimer::cTimer() m_index = -1; m_active = true; m_channel = 0; - m_schedtype = Once; + m_schedtype = TvDatabase::Once; m_starttime = 0; m_endtime = 0; m_priority = 0; - m_keepmethod = UntilSpaceNeeded; + m_keepmethod = TvDatabase::UntilSpaceNeeded; m_keepdate = cUndefinedDate; m_prerecordinterval = -1; // Use MediaPortal setting instead m_postrecordinterval = -1; // Use MediaPortal setting instead @@ -119,7 +119,7 @@ cTimer::cTimer(const PVR_TIMER& timerinfo) } else { - m_schedtype = Once; + m_schedtype = TvDatabase::Once; m_series = false; } @@ -241,7 +241,7 @@ bool cTimer::ParseLine(const char *s) m_channel = atoi(schedulefields[3].c_str()); m_title = schedulefields[5]; - m_schedtype = (ScheduleRecordingType) atoi(schedulefields[6].c_str()); + m_schedtype = (TvDatabase::ScheduleRecordingType) atoi(schedulefields[6].c_str()); m_priority = atoi(schedulefields[7].c_str()); m_done = stringtobool(schedulefields[8]); @@ -251,7 +251,7 @@ bool cTimer::ParseLine(const char *s) if(schedulefields.size() >= 18) { //TVServerXBMC build >= 100 - m_keepmethod = (KeepMethodType) atoi(schedulefields[11].c_str()); + m_keepmethod = (TvDatabase::KeepMethodType) atoi(schedulefields[11].c_str()); m_keepdate = DateTimeToTimeT(schedulefields[12]); if( m_keepdate < 0) @@ -278,7 +278,7 @@ bool cTimer::ParseLine(const char *s) } else { - m_keepmethod = UntilSpaceNeeded; + m_keepmethod = TvDatabase::UntilSpaceNeeded; m_keepdate = cUndefinedDate; m_prerecordinterval = -1; m_postrecordinterval = -1; @@ -298,7 +298,7 @@ bool cTimer::ParseLine(const char *s) return false; } -int cTimer::SchedRecType2RepeatFlags(ScheduleRecordingType schedtype) +int cTimer::SchedRecType2RepeatFlags(TvDatabase::ScheduleRecordingType schedtype) { // margro: the meaning of the XBMC-PVR Weekdays field is undocumented. // Assuming that VDR is the source for this field: @@ -313,13 +313,13 @@ int cTimer::SchedRecType2RepeatFlags(ScheduleRecordingType schedtype) switch (schedtype) { - case Once: + case TvDatabase::Once: weekdays = 0; break; - case Daily: + case TvDatabase::Daily: weekdays = 127; // 0111 1111 break; - case Weekly: + case TvDatabase::Weekly: { // Not sure what to do with this MediaPortal option... // Assumption: record once a week, on the same day and time @@ -338,16 +338,16 @@ int cTimer::SchedRecType2RepeatFlags(ScheduleRecordingType schedtype) weekdays = 1 << weekday; break; } - case EveryTimeOnThisChannel: + case TvDatabase::EveryTimeOnThisChannel: // Don't know what to do with this MediaPortal option? break; - case EveryTimeOnEveryChannel: + case TvDatabase::EveryTimeOnEveryChannel: // Don't know what to do with this MediaPortal option? break; - case Weekends: + case TvDatabase::Weekends: weekdays = 96; // 0110 0000 break; - case WorkingDays: + case TvDatabase::WorkingDays: weekdays = 31; // 0001 1111 break; default: @@ -357,7 +357,7 @@ int cTimer::SchedRecType2RepeatFlags(ScheduleRecordingType schedtype) return weekdays; } -ScheduleRecordingType cTimer::RepeatFlags2SchedRecType(int repeatflags) +TvDatabase::ScheduleRecordingType cTimer::RepeatFlags2SchedRecType(int repeatflags) { // margro: the meaning of the XBMC-PVR Weekdays field is undocumented. // Assuming that VDR is the source for this field: @@ -371,7 +371,7 @@ ScheduleRecordingType cTimer::RepeatFlags2SchedRecType(int repeatflags) switch (repeatflags) { case 0: - return Once; + return TvDatabase::Once; break; case 1: //Monday case 2: //Tuesday @@ -380,21 +380,21 @@ ScheduleRecordingType cTimer::RepeatFlags2SchedRecType(int repeatflags) case 16: //Friday case 32: //Saturday case 64: //Sunday - return Weekly; + return TvDatabase::Weekly; break; case 31: // 0001 1111 - return WorkingDays; + return TvDatabase::WorkingDays; case 96: // 0110 0000 - return Weekends; + return TvDatabase::Weekends; break; case 127: // 0111 1111 - return Daily; + return TvDatabase::Daily; break; default: break; } - return Once; + return TvDatabase::Once; } std::string cTimer::AddScheduleCommand() @@ -517,17 +517,17 @@ void cTimer::SetKeepMethod(int lifetime) // 99 means that this recording will never be automatically deleted if (lifetime == 0) { - m_keepmethod = UntilSpaceNeeded; + m_keepmethod = TvDatabase::UntilSpaceNeeded; m_keepdate = cUndefinedDate; } else if (lifetime == 99) { - m_keepmethod = Forever; + m_keepmethod = TvDatabase::Always; m_keepdate = cUndefinedDate; } else { - m_keepmethod = UntilKeepDate; + m_keepmethod = TvDatabase::TillDate; m_keepdate = m_starttime + (lifetime * cSecsInDay); } } @@ -546,11 +546,11 @@ int cTimer::GetLifetime(void) // passed by switch (m_keepmethod) { - case UntilSpaceNeeded: //until space needed - case UntilWatched: //until watched + case TvDatabase::UntilSpaceNeeded: //until space needed + case TvDatabase::UntilWatched: //until watched return 0; break; - case UntilKeepDate: //until keepdate + case TvDatabase::TillDate: //until keepdate { double diffseconds = difftime(m_keepdate, m_starttime); int daysremaining = (int)(diffseconds / cSecsInDay); @@ -566,7 +566,7 @@ int cTimer::GetLifetime(void) } } break; - case Forever: //forever + case TvDatabase::Always: //forever return 99; default: return 0; diff --git a/addons/pvr.mediaportal.tvserver/src/timers.h b/addons/pvr.mediaportal.tvserver/src/timers.h index 923c7eb02..3dd006ef1 100644 --- a/addons/pvr.mediaportal.tvserver/src/timers.h +++ b/addons/pvr.mediaportal.tvserver/src/timers.h @@ -1,6 +1,6 @@ #pragma once /* - * Copyright (C) 2005-2011 Team XBMC + * Copyright (C) 2005-2013 Team XBMC * http://www.xbmc.org * * This Program is free software; you can redistribute it and/or modify @@ -38,6 +38,9 @@ enum eTimerFlags { tfNone = 0x0000, }; */ +namespace TvDatabase +{ + // From MediaPortal: TvDatabase.ScheduleRecordingType enum ScheduleRecordingType { @@ -47,15 +50,19 @@ enum ScheduleRecordingType EveryTimeOnThisChannel = 3, EveryTimeOnEveryChannel = 4, Weekends = 5, - WorkingDays = 6 + WorkingDays = 6, + WeeklyEveryTimeOnThisChannel = 7 }; +// From MediaPortal: TvDatabase.KeepMethodType enum KeepMethodType { UntilSpaceNeeded = 0, UntilWatched = 1, - UntilKeepDate = 2, - Forever = 3 + TillDate = 2, + Always = 3 +}; + }; class cTimer @@ -77,17 +84,17 @@ class cTimer int PreRecordInterval(void) const { return m_prerecordinterval; } int PostRecordInterval(void) const { return m_postrecordinterval; } int RepeatFlags() { return SchedRecType2RepeatFlags(m_schedtype); }; - bool Repeat() const { return (m_schedtype == Once ? false : true); }; + bool Repeat() const { return (m_schedtype == TvDatabase::Once ? false : true); }; bool Done() const { return m_done; }; bool IsManual() const { return m_ismanual; }; bool IsActive() const { return !m_canceled; }; bool IsRecording() const { return m_isrecording; }; - ScheduleRecordingType RepeatFlags2SchedRecType(int repeatflags); + TvDatabase::ScheduleRecordingType RepeatFlags2SchedRecType(int repeatflags); std::string AddScheduleCommand(); std::string UpdateScheduleCommand(); private: - int SchedRecType2RepeatFlags(ScheduleRecordingType schedtype); + int SchedRecType2RepeatFlags(TvDatabase::ScheduleRecordingType schedtype); /** * @brief Convert a XBMC Lifetime value to MediaPortals keepMethod+keepDate settings @@ -103,7 +110,7 @@ class cTimer // MediaPortal database fields: int m_index; ///> MediaPortal id_Schedule int m_channel; ///> MediaPortal idChannel - ScheduleRecordingType m_schedtype; ///> MediaPortal scheduleType + TvDatabase::ScheduleRecordingType m_schedtype; ///> MediaPortal scheduleType std::string m_title; ///> MediaPortal programName time_t m_starttime; ///> MediaPortal startTime time_t m_endtime; ///> MediaPortal endTime @@ -111,7 +118,7 @@ class cTimer int m_priority; ///> MediaPortal priority (not the XBMC one!!!) std::string m_directory; ///> MediaPortal directory // skipped: quality field - KeepMethodType m_keepmethod; ///> MediaPortal keepMethod + TvDatabase::KeepMethodType m_keepmethod; ///> MediaPortal keepMethod time_t m_keepdate; ///> MediaPortal keepDate int m_prerecordinterval; ///> MediaPortal preRecordInterval int m_postrecordinterval; ///> MediaPortal postRecordInterval