Skip to content

Commit

Permalink
EPG past days!
Browse files Browse the repository at this point in the history
  • Loading branch information
aassif committed Jan 9, 2021
1 parent 0f4a743 commit 798837f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pvr.freebox/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.freebox"
version="6.1.0"
version="6.1.1"
name="PVR Freebox TV"
provider-name="aassif">
<requires>@ADDON_DEPENDS@</requires>
Expand Down
32 changes: 23 additions & 9 deletions src/Freebox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,8 @@ Freebox::Freebox () :
m_tv_prefs_quality (),
m_epg_queries (),
m_epg_cache (),
m_epg_days (0),
m_epg_days_past (0),
m_epg_days_future (0),
m_epg_last (0),
m_recordings (),
m_unique_id (1),
Expand Down Expand Up @@ -979,10 +980,16 @@ void Freebox::SetProtocol (Protocol p)
m_tv_protocol = p;
}

void Freebox::SetDays (int d)
void Freebox::SetPastDays (int d)
{
lock_guard<recursive_mutex> lock (m_mutex);
m_epg_days = d != EPG_TIMEFRAME_UNLIMITED ? min (d, 7) : 7;
m_epg_days_past = d != EPG_TIMEFRAME_UNLIMITED ? min (d, 7) : 7;
}

void Freebox::SetFutureDays (int d)
{
lock_guard<recursive_mutex> lock (m_mutex);
m_epg_days_future = d != EPG_TIMEFRAME_UNLIMITED ? min (d, 7) : 7;
}

void Freebox::SetExtended (bool e)
Expand Down Expand Up @@ -1142,10 +1149,10 @@ void Freebox::Process ()
{
m_mutex.lock ();
int delay = m_delay;
int days = m_epg_days;
time_t now = time (NULL);
time_t end = now + days * 24 * 60 * 60;
time_t last = max (now, m_epg_last);
time_t begin = now - m_epg_days_past * 24 * 3600;
time_t end = now + m_epg_days_future * 24 * 3600;
time_t last = max (begin, m_epg_last);
m_mutex.unlock ();

if (StartSession ())
Expand Down Expand Up @@ -1229,7 +1236,8 @@ ADDON_STATUS Freebox::Create ()
AddMenuHook (h);

kodi::QueueNotification (QUEUE_INFO, "", PVR_FREEBOX_VERSION);
SetDays (EpgMaxFutureDays ());
SetPastDays (EpgMaxPastDays ());
SetFutureDays (EpgMaxFutureDays ());
ProcessChannels ();
CreateThread ();

Expand Down Expand Up @@ -1332,9 +1340,15 @@ PVR_ERROR Freebox::GetConnectionString (string & connection)
// E P G ///////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

PVR_ERROR Freebox::SetEPGMaxFutureDays (int futureDays)
PVR_ERROR Freebox::SetEPGMaxPastDays (int days)
{
SetPastDays (days);
return PVR_ERROR_NO_ERROR;
}

PVR_ERROR Freebox::SetEPGMaxFutureDays (int days)
{
SetDays (futureDays);
SetFutureDays (days);
return PVR_ERROR_NO_ERROR;
}

Expand Down
10 changes: 7 additions & 3 deletions src/Freebox.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ class ATTRIBUTE_HIDDEN Freebox :
PVR_ERROR GetConnectionString (std::string &) override;

// E P G ///////////////////////////////////////////////////////////////////
PVR_ERROR SetEPGMaxPastDays(int) override;
PVR_ERROR SetEPGMaxFutureDays(int) override;
PVR_ERROR GetEPGForChannel(int, time_t, time_t, kodi::addon::PVREPGTagsResultSet &) override;

Expand Down Expand Up @@ -392,8 +393,10 @@ class ATTRIBUTE_HIDDEN Freebox :
void SetQuality (Quality);
// Streaming protocol.
void SetProtocol (Protocol);
// MaxDays setting.
void SetDays (int);
// Maximum past days.
void SetPastDays (int);
// Maximum future days.
void SetFutureDays (int);
// Extended EPG.
void SetExtended (bool);
// Colored Categories.
Expand Down Expand Up @@ -487,7 +490,8 @@ class ATTRIBUTE_HIDDEN Freebox :
// EPG /////////////////////////////////////////////////////////////////////
std::queue<Query> m_epg_queries;
std::set<std::string> m_epg_cache;
int m_epg_days;
int m_epg_days_past;
int m_epg_days_future;
time_t m_epg_last;
bool m_epg_extended = PVR_FREEBOX_DEFAULT_EXTENDED;
bool m_epg_colors = PVR_FREEBOX_DEFAULT_COLORS;
Expand Down

0 comments on commit 798837f

Please sign in to comment.