summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--p2pvr/Jamfile.jam4
-rw-r--r--p2pvr/ice/p2pvr.ice8
-rw-r--r--p2pvr/lib/si.cpp20
-rw-r--r--p2pvr/lib/si.h4
-rw-r--r--p2pvr/lib/sql/SI_eventsInRange.sql28
-rw-r--r--p2pvr/lib/sql/SI_eventsOnNow.sql27
-rw-r--r--p2pvr/p2/Jamfile.jam18
-rw-r--r--p2pvr/p2/config.cpp50
-rw-r--r--p2pvr/p2/config.h31
-rw-r--r--p2pvr/p2/pch.hpp25
-rw-r--r--p2pvr/p2/views/events.cpp60
-rw-r--r--p2pvr/p2/views/schedules.cpp29
-rw-r--r--p2pvr/p2/views/services.cpp28
-rw-r--r--p2pvr/util/dvbsiHelpers/event.cpp30
-rw-r--r--p2pvr/util/p2Helpers.cpp8
-rw-r--r--p2pvr/util/p2Helpers.h21
-rw-r--r--p2pvr/util/p2pvrHelpers/schedule.cpp50
17 files changed, 423 insertions, 18 deletions
diff --git a/p2pvr/Jamfile.jam b/p2pvr/Jamfile.jam
index a0948fc..8f82f35 100644
--- a/p2pvr/Jamfile.jam
+++ b/p2pvr/Jamfile.jam
@@ -24,8 +24,8 @@ alias p2daemonlib : glibmm : : :
build-project daemon ;
build-project carddaemon ;
-install debuginstall : lib//p2pvrlib util//p2pvrutil carddaemon daemon ice : <location>./testing ;
-package.install install : : : carddaemon daemon ;
+install debuginstall : lib//p2pvrlib util//p2pvrutil p2//p2pvrp2 carddaemon daemon ice : <location>./testing ;
+package.install install : : : carddaemon daemon p2//p2pvrp2 ;
import type ;
import generators ;
diff --git a/p2pvr/ice/p2pvr.ice b/p2pvr/ice/p2pvr.ice
index 2c827af..f6ed579 100644
--- a/p2pvr/ice/p2pvr.ice
+++ b/p2pvr/ice/p2pvr.ice
@@ -157,6 +157,7 @@ module DVBSI {
optional(17) short UserCategory;
optional(18) short Season;
};
+ sequence<Event> Events;
};
module P2PVR {
exception DeviceError {
@@ -282,13 +283,16 @@ module P2PVR {
sequence<DVBSI::Delivery> Deliveries;
interface SI {
- // Get any delivery suitable for SI reading
+ // Get delivery methods
idempotent Deliveries GetAllDeliveries(short type);
idempotent DVBSI::Delivery GetDeliveryForService(int id);
idempotent DVBSI::Delivery GetDeliveryForTransport(int id);
- // Get a list of services
+ // Get services
idempotent DVBSI::ServiceList GetServices();
idempotent DVBSI::Service GetService(int id);
+ // Get events
+ idempotent DVBSI::Events EventsOnNow();
+ idempotent DVBSI::Events EventsInRange(Common::DateTime from, Common::DateTime to);
};
};
diff --git a/p2pvr/lib/si.cpp b/p2pvr/lib/si.cpp
index ce55fbc..7c76ef4 100644
--- a/p2pvr/lib/si.cpp
+++ b/p2pvr/lib/si.cpp
@@ -8,6 +8,8 @@
ResourceString(SI_servicesSelectAll, lib_sql_SI_servicesSelectAll_sql);
ResourceString(SI_servicesSelectById, lib_sql_SI_servicesSelectById_sql);
+ResourceString(SI_eventsOnNow, lib_sql_SI_eventsOnNow_sql);
+ResourceString(SI_eventsInRange, lib_sql_SI_eventsInRange_sql);
P2PVR::Deliveries
SI::GetAllDeliveries(short type, const Ice::Current &)
@@ -83,3 +85,21 @@ SI::GetService(int id, const Ice::Current&)
return rtn.front();
}
+DVBSI::Events
+SI::EventsOnNow(const Ice::Current &)
+{
+ DVBSI::Events rtn;
+ SqlContainerCreator<DVBSI::Events, DVBSI::Event> cc(rtn);
+ cc.populate(Select(SI_eventsOnNow));
+ return rtn;
+}
+
+DVBSI::Events
+SI::EventsInRange(const Common::DateTime & from, const Common::DateTime & to, const Ice::Current &)
+{
+ DVBSI::Events rtn;
+ SqlContainerCreator<DVBSI::Events, DVBSI::Event> cc(rtn);
+ cc.populate(Select(SI_eventsInRange, from, to));
+ return rtn;
+}
+
diff --git a/p2pvr/lib/si.h b/p2pvr/lib/si.h
index 053ac77..ca8e5b4 100644
--- a/p2pvr/lib/si.h
+++ b/p2pvr/lib/si.h
@@ -9,8 +9,12 @@ class SI : public P2PVR::SI, public DatabaseClient {
P2PVR::Deliveries GetAllDeliveries(short type, const Ice::Current &);
DVBSI::DeliveryPtr GetDeliveryForService(int id, const Ice::Current &);
DVBSI::DeliveryPtr GetDeliveryForTransport(int id, const Ice::Current &);
+
DVBSI::ServiceList GetServices(const Ice::Current &);
DVBSI::ServicePtr GetService(int id, const Ice::Current &);
+
+ DVBSI::Events EventsOnNow(const Ice::Current &);
+ DVBSI::Events EventsInRange(const Common::DateTime &, const Common::DateTime &, const Ice::Current &);
};
#endif
diff --git a/p2pvr/lib/sql/SI_eventsInRange.sql b/p2pvr/lib/sql/SI_eventsInRange.sql
new file mode 100644
index 0000000..0a2d6de
--- /dev/null
+++ b/p2pvr/lib/sql/SI_eventsInRange.sql
@@ -0,0 +1,28 @@
+select e.serviceid,
+ e.eventid,
+ e.title,
+ e.titlelang,
+ e.subtitle,
+ e.description,
+ e.descriptionlang,
+ e.videoaspect,
+ e.videoframerate,
+ e.videohd,
+ e.audiochannels,
+ e.audiolanguage,
+ e.subtitlelanguage,
+ e.category,
+ e.subcategory,
+ e.usercategory,
+ e.dvbrating,
+ e.starttime,
+ e.stoptime,
+ e.episode,
+ e.episodes,
+ e.year,
+ e.flags,
+ e.season
+from events e
+where tsrange(?, ?, '[)') && tsrange(e.starttime, e.stoptime)
+order by e.serviceid, e.starttime
+
diff --git a/p2pvr/lib/sql/SI_eventsOnNow.sql b/p2pvr/lib/sql/SI_eventsOnNow.sql
new file mode 100644
index 0000000..36760b4
--- /dev/null
+++ b/p2pvr/lib/sql/SI_eventsOnNow.sql
@@ -0,0 +1,27 @@
+select e.serviceid,
+ e.eventid,
+ e.title,
+ e.titlelang,
+ e.subtitle,
+ e.description,
+ e.descriptionlang,
+ e.videoaspect,
+ e.videoframerate,
+ e.videohd,
+ e.audiochannels,
+ e.audiolanguage,
+ e.subtitlelanguage,
+ e.category,
+ e.subcategory,
+ e.usercategory,
+ e.dvbrating,
+ e.starttime,
+ e.stoptime,
+ e.episode,
+ e.episodes,
+ e.year,
+ e.flags,
+ e.season
+from events e
+where now()::timestamp without time zone <@ tsrange(e.starttime, e.stoptime)
+order by e.serviceid
diff --git a/p2pvr/p2/Jamfile.jam b/p2pvr/p2/Jamfile.jam
new file mode 100644
index 0000000..f81ee60
--- /dev/null
+++ b/p2pvr/p2/Jamfile.jam
@@ -0,0 +1,18 @@
+cpp-pch pch : pch.hpp :
+ <library>../ice//p2pvrice
+ <library>..//p2common
+ <library>..//p2lib
+ <implicit-dependency>../ice//p2pvrice
+;
+
+lib p2pvrp2 :
+ pch
+ [ glob-tree *.cpp ]
+ :
+ <library>../ice//p2pvrice
+ <library>../util//p2pvrutil
+ <library>..//p2common
+ <library>..//p2lib
+ <implicit-dependency>../ice//p2pvrice
+;
+
diff --git a/p2pvr/p2/config.cpp b/p2pvr/p2/config.cpp
new file mode 100644
index 0000000..49022b7
--- /dev/null
+++ b/p2pvr/p2/config.cpp
@@ -0,0 +1,50 @@
+#include "config.h"
+#include <logger.h>
+#include <Ice/Ice.h>
+
+std::string Config::DaemonAddress;
+std::string Config::CommunicatorArgs;
+Ice::CommunicatorPtr Config::ic;
+Ice::ObjectAdapterPtr Config::adapter;
+
+DECLARE_OPTIONS(Config, "P2PVR Client options")
+("p2pvr.client.daemonaddress", Options::value(&DaemonAddress),
+ "The ICE address of the P2PVR daemon")
+("p2pvr.client.communicatorargs", Options::value(&CommunicatorArgs),
+ "Arguments to pass to the client's ICE Communicator")
+END_OPTIONS(Config);
+
+
+DECLARE_COMPONENT("P2PVR Client Config", Config);
+
+void
+Config::onConfigLoad()
+{
+ if (ic) {
+ Logger()->messagef(LOG_DEBUG, "%s: Destroying existing ICE Communicator", __PRETTY_FUNCTION__);
+ ic->shutdown();
+ }
+ Logger()->messagef(LOG_DEBUG, "%s: Creating new ICE Communicator", __PRETTY_FUNCTION__);
+ int argc = 0;
+ char ** argv = {};
+ ic = Ice::initialize(argc, argv);
+ try {
+ if (!ic) {
+ Logger()->message(LOG_ERR, "Failed to initialize ICE Communicator");
+ throw std::runtime_error("Failed to initialize ICE Communicator");
+ }
+ Logger()->messagebf(LOG_DEBUG, "%s: Creating new default adapter for Communicator", __PRETTY_FUNCTION__);
+ adapter = ic->createObjectAdapterWithEndpoints("DefaultAdapter", "default -p 10002");
+ if (!adapter) {
+ Logger()->message(LOG_ERR, "Failed to create new adapter");
+ throw std::runtime_error("Failed to create new adapter");
+ }
+ Logger()->messagef(LOG_DEBUG, "%s: Activating", __PRETTY_FUNCTION__);
+ adapter->activate();
+ Logger()->messagef(LOG_DEBUG, "%s: Done", __PRETTY_FUNCTION__);
+ }
+ catch (const Ice::Exception & ie) {
+ Logger()->messagebf(LOG_DEBUG, "%s: ICE initialization failed (%s)", __PRETTY_FUNCTION__, ie);
+ }
+}
+
diff --git a/p2pvr/p2/config.h b/p2pvr/p2/config.h
new file mode 100644
index 0000000..56d8b53
--- /dev/null
+++ b/p2pvr/p2/config.h
@@ -0,0 +1,31 @@
+#ifndef P2PVRP2_CONFIG_H
+#define P2PVRP2_CONFIG_H
+
+#include <options.h>
+#include <componentLoader.h>
+#include <Ice/Communicator.h>
+#include <Ice/ObjectAdapter.h>
+
+class Config : public ComponentLoader {
+ public:
+ static Ice::ObjectAdapterPtr Adapter();
+ static Ice::CommunicatorPtr Communicator();
+ template <typename Proxy>
+ static Proxy GetProxy(const std::string & interface)
+ {
+ return Proxy::checkedCast(ic->stringToProxy(interface + ":" + DaemonAddress));
+ }
+
+ INITOPTIONS;
+ void onConfigLoad();
+
+ static std::string DaemonAddress;
+ static std::string CommunicatorArgs;
+
+ private:
+ static Ice::CommunicatorPtr ic;
+ static Ice::ObjectAdapterPtr adapter;
+};
+
+#endif
+
diff --git a/p2pvr/p2/pch.hpp b/p2pvr/p2/pch.hpp
new file mode 100644
index 0000000..5ba7bd7
--- /dev/null
+++ b/p2pvr/p2/pch.hpp
@@ -0,0 +1,25 @@
+#ifdef BOOST_BUILD_PCH_ENABLED
+#ifndef P2PVRP2_PCH
+#define P2PVRP2_PCH
+
+#include <Ice/Ice.h>
+#include <boost/bind.hpp>
+#include <boost/foreach.hpp>
+#include <boost/function.hpp>
+#include <boost/intrusive_ptr.hpp>
+#include <boost/shared_ptr.hpp>
+
+#include <list>
+#include <map>
+#include <set>
+#include <string>
+#include <vector>
+
+#include <variableType.h>
+
+#include <p2pvr.h>
+
+#endif
+#endif
+
+
diff --git a/p2pvr/p2/views/events.cpp b/p2pvr/p2/views/events.cpp
new file mode 100644
index 0000000..f435731
--- /dev/null
+++ b/p2pvr/p2/views/events.cpp
@@ -0,0 +1,60 @@
+#include <pch.hpp>
+#include <p2pvr.h>
+#include <p2Helpers.h>
+#include <logger.h>
+#include <rowSet.h>
+#include <genLoader.h>
+#include <execContext.h>
+#include <objectRowState.h>
+#include "../config.h"
+
+class EventsOnNow : public RowSet {
+ public:
+ EventsOnNow(ScriptNodePtr p) :
+ RowSet(p)
+ {
+ }
+
+ void execute(const Glib::ustring &, const RowProcessorCallback & rp, ExecContext *) const
+ {
+ auto proxy = Config::GetProxy<P2PVR::SIPrx>("SI");
+ auto services = proxy->EventsOnNow();
+ ObjectRowState<DVBSI::EventPtr> rs;
+ BOOST_FOREACH(const auto & s, services) {
+ BindColumns(rs, s);
+ rs.process(rp);
+ }
+ }
+};
+
+DECLARE_LOADER("eventsonnow", EventsOnNow);
+
+class EventsInRange : public RowSet {
+ public:
+ EventsInRange(ScriptNodePtr p) :
+ RowSet(p),
+ From(p, "from"),
+ To(p, "to")
+ {
+ }
+
+ void execute(const Glib::ustring &, const RowProcessorCallback & rp, ExecContext * ec) const
+ {
+ auto proxy = Config::GetProxy<P2PVR::SIPrx>("SI");
+ Common::DateTime from, to;
+ From(ec) >> from;
+ To(ec) >> to;
+ auto services = proxy->EventsInRange(from, to);
+ ObjectRowState<DVBSI::EventPtr> rs;
+ BOOST_FOREACH(const auto & s, services) {
+ BindColumns(rs, s);
+ rs.process(rp);
+ }
+ }
+ private:
+ const Variable From;
+ const Variable To;
+};
+
+DECLARE_LOADER("eventsinrange", EventsInRange);
+
diff --git a/p2pvr/p2/views/schedules.cpp b/p2pvr/p2/views/schedules.cpp
new file mode 100644
index 0000000..2c2d020
--- /dev/null
+++ b/p2pvr/p2/views/schedules.cpp
@@ -0,0 +1,29 @@
+#include <pch.hpp>
+#include <p2pvr.h>
+#include <logger.h>
+#include <rowSet.h>
+#include <genLoader.h>
+#include <objectRowState.h>
+#include "../config.h"
+
+class ScheduleList : public RowSet {
+ public:
+ ScheduleList(ScriptNodePtr p) :
+ RowSet(p)
+ {
+ }
+
+ void execute(const Glib::ustring &, const RowProcessorCallback & rp, ExecContext *) const
+ {
+ auto proxy = Config::GetProxy<P2PVR::SchedulesPrx>("Schedules");
+ auto schedules = proxy->GetSchedules();
+ ObjectRowState<P2PVR::SchedulePtr> rs;
+ BOOST_FOREACH(const auto & s, schedules) {
+ BindColumns(rs, s);
+ rs.process(rp);
+ }
+ }
+};
+
+DECLARE_LOADER("schedulelist", ScheduleList);
+
diff --git a/p2pvr/p2/views/services.cpp b/p2pvr/p2/views/services.cpp
new file mode 100644
index 0000000..2fb4c9d
--- /dev/null
+++ b/p2pvr/p2/views/services.cpp
@@ -0,0 +1,28 @@
+#include <pch.hpp>
+#include <p2pvr.h>
+#include <logger.h>
+#include <rowSet.h>
+#include <genLoader.h>
+#include <objectRowState.h>
+#include "../config.h"
+
+class ServiceList : public RowSet {
+ public:
+ ServiceList(ScriptNodePtr p) :
+ RowSet(p)
+ {
+ }
+
+ void execute(const Glib::ustring &, const RowProcessorCallback & rp, ExecContext *) const
+ {
+ auto proxy = Config::GetProxy<P2PVR::SIPrx>("SI");
+ auto services = proxy->GetServices();
+ ObjectRowState<DVBSI::ServicePtr> rs;
+ BOOST_FOREACH(const auto & s, services) {
+ BindColumns(rs, s);
+ rs.process(rp);
+ }
+ }
+};
+
+DECLARE_LOADER("servicelist", ServiceList);
diff --git a/p2pvr/util/dvbsiHelpers/event.cpp b/p2pvr/util/dvbsiHelpers/event.cpp
index decd2b9..ca072df 100644
--- a/p2pvr/util/dvbsiHelpers/event.cpp
+++ b/p2pvr/util/dvbsiHelpers/event.cpp
@@ -62,3 +62,33 @@ BindColumns(RowState & rs, const DVBSI::EventPtr & e)
rs.fields[23] << e->Season;
}
+template<>
+void
+UnbindColumns(RowState & rs, const DVBSI::EventPtr & e)
+{
+ rs.fields[0] >> e->ServiceId;
+ rs.fields[1] >> e->EventId;
+ rs.fields[2] >> e->Title;
+ rs.fields[3] >> e->TitleLang;
+ rs.fields[4] >> e->Subtitle;
+ rs.fields[5] >> e->Description;
+ rs.fields[6] >> e->DescriptionLang;
+ rs.fields[7] >> e->VideoAspect;
+ rs.fields[8] >> e->VideoFrameRate;
+ rs.fields[9] >> e->VideoHD;
+ rs.fields[10] >> e->AudioChannels;
+ rs.fields[11] >> e->AudioLanguage;
+ rs.fields[12] >> e->SubtitleLanguage;
+ rs.fields[13] >> e->Category;
+ rs.fields[14] >> e->SubCategory;
+ rs.fields[15] >> e->UserCategory;
+ rs.fields[16] >> e->DvbRating;
+ rs.fields[17] >> e->StartTime;
+ rs.fields[18] >> e->StopTime;
+ rs.fields[19] >> e->Episode;
+ rs.fields[20] >> e->Episodes;
+ rs.fields[21] >> e->Year;
+ rs.fields[22] >> e->Flags;
+ rs.fields[23] >> e->Season;
+}
+
diff --git a/p2pvr/util/p2Helpers.cpp b/p2pvr/util/p2Helpers.cpp
index 0c1fe37..081905d 100644
--- a/p2pvr/util/p2Helpers.cpp
+++ b/p2pvr/util/p2Helpers.cpp
@@ -11,8 +11,8 @@ operator<<<Common::DateTime>(VariableType & vt, const Common::DateTime & dt)
}
template <>
-VariableType &
-operator>><Common::DateTime>(VariableType & vt, Common::DateTime & dt)
+const VariableType &
+operator>><Common::DateTime>(const VariableType & vt, Common::DateTime & dt)
{
const boost::posix_time::ptime & date = vt;
dt.Year = date.date().year();
@@ -24,8 +24,8 @@ operator>><Common::DateTime>(VariableType & vt, Common::DateTime & dt)
}
template <>
-VariableType &
-operator>>(VariableType & vt, short int & v)
+const VariableType &
+operator>>(const VariableType & vt, short int & v)
{
v = (int)vt;
return vt;
diff --git a/p2pvr/util/p2Helpers.h b/p2pvr/util/p2Helpers.h
index 7ea56de..e843692 100644
--- a/p2pvr/util/p2Helpers.h
+++ b/p2pvr/util/p2Helpers.h
@@ -5,33 +5,34 @@
#include <p2pvr.h>
template <typename T>
-VariableType &
-operator>>(VariableType & vt, T & v)
+const VariableType &
+operator>>(const VariableType & vt, T & v)
{
v = vt.as<T>();
return vt;
}
template <>
-VariableType &
-operator>><Common::DateTime>(VariableType & vt, Common::DateTime & dt);
+const VariableType &
+operator>><Common::DateTime>(const VariableType & vt, Common::DateTime & dt);
template <typename T>
-VariableType &
-operator>>(VariableType & vt, IceUtil::Optional<T> & v)
+const VariableType &
+operator>>(const VariableType & vt, IceUtil::Optional<T> & v)
{
if (vt.isNull()) {
- v = NULL;
+ v = IceUtil::Optional<T>();
}
else {
- v = vt.as<T>();
+ v = T();
+ vt >> *v;
}
return vt;
}
template <>
-VariableType &
-operator>>(VariableType & vt, short int & v);
+const VariableType &
+operator>>(const VariableType & vt, short int & v);
template <typename T>
VariableType &
diff --git a/p2pvr/util/p2pvrHelpers/schedule.cpp b/p2pvr/util/p2pvrHelpers/schedule.cpp
new file mode 100644
index 0000000..264c132
--- /dev/null
+++ b/p2pvr/util/p2pvrHelpers/schedule.cpp
@@ -0,0 +1,50 @@
+#include <pch.hpp>
+#include "../dvbsiHelpers.h"
+#include "../p2Helpers.h"
+
+template<>
+void
+CreateColumns<P2PVR::SchedulePtr>(const ColumnCreator & cc)
+{
+ cc("scheduleid", true);
+ cc("serviceid", true);
+ cc("eventid", false);
+ cc("title", false);
+ cc("search", false);
+ cc("priority", false);
+ cc("early", false);
+ cc("late", false);
+ cc("repeats", false);
+}
+
+template<>
+void
+BindColumns(RowState & rs, const P2PVR::SchedulePtr & s)
+{
+ rs.fields[0] << s->ScheduleId;
+ rs.fields[1] << s->ServiceId;
+ rs.fields[2] << s->EventId;
+ rs.fields[3] << s->Title;
+ rs.fields[4] << s->Search;
+ rs.fields[5] << s->Priority;
+ rs.fields[6] << s->Early;
+ rs.fields[7] << s->Late;
+ rs.fields[8] << s->Repeats;
+}
+
+template<>
+void
+UnbindColumns(RowState & rs, P2PVR::SchedulePtr const & s)
+{
+ rs.fields[0] >> s->ScheduleId;
+ rs.fields[1] >> s->ServiceId;
+ rs.fields[2] >> s->EventId;
+ rs.fields[3] >> s->Title;
+ rs.fields[4] >> s->Search;
+ rs.fields[5] >> s->Priority;
+ rs.fields[6] >> s->Early;
+ rs.fields[7] >> s->Late;
+ rs.fields[8] >> s->Repeats;
+}
+
+