Skip to content
This repository has been archived by the owner on Apr 15, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
[MediaPortal] Update TVServer enums and put them in the TvDatabase na…
…mespace
  • Loading branch information
margro committed Nov 18, 2013
1 parent 8c73964 commit d6f410f
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 42 deletions.
10 changes: 5 additions & 5 deletions addons/pvr.mediaportal.tvserver/src/recordings.cpp
Expand Up @@ -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);
Expand All @@ -241,7 +241,7 @@ int cRecording::Lifetime(void) const
}
}
break;
case Forever: //forever
case TvDatabase::Always: //forever
return MAXLIFETIME;
default:
return MAXLIFETIME;
Expand Down
56 changes: 28 additions & 28 deletions addons/pvr.mediaportal.tvserver/src/timers.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -119,7 +119,7 @@ cTimer::cTimer(const PVR_TIMER& timerinfo)
}
else
{
m_schedtype = Once;
m_schedtype = TvDatabase::Once;
m_series = false;
}

Expand Down Expand Up @@ -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]);
Expand All @@ -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)
Expand All @@ -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;
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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);
Expand All @@ -566,7 +566,7 @@ int cTimer::GetLifetime(void)
}
}
break;
case Forever: //forever
case TvDatabase::Always: //forever
return 99;
default:
return 0;
Expand Down
25 changes: 16 additions & 9 deletions 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
Expand Down Expand Up @@ -38,6 +38,9 @@ enum eTimerFlags { tfNone = 0x0000,
};
*/

namespace TvDatabase
{

// From MediaPortal: TvDatabase.ScheduleRecordingType
enum ScheduleRecordingType
{
Expand All @@ -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
Expand All @@ -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
Expand All @@ -103,15 +110,15 @@ 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
// skipped: maxAirings field
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
Expand Down

0 comments on commit d6f410f

Please sign in to comment.