From ad621debc7d58ef84d0c07c064aae11c635087fd Mon Sep 17 00:00:00 2001 From: randomdan Date: Tue, 11 Mar 2014 20:15:29 +0000 Subject: Add the p2pvr Ice <-> Project2 type converters Add the beginnings of the web frontend Remove the deprecated p2 client code, now superceeded by the Project2 slice compiler --- p2pvr/Jamfile.jam | 8 ++++-- p2pvr/ice/Jamfile.jam | 2 ++ p2pvr/ice/converters.cpp | 33 +++++++++++++++++++++ p2pvr/ice/dvbsi.ice | 2 ++ p2pvr/ice/p2pvr.ice | 8 ++++++ p2pvr/p2/Jamfile.jam | 18 ------------ p2pvr/p2/config.cpp | 50 -------------------------------- p2pvr/p2/config.h | 31 -------------------- p2pvr/p2/pch.hpp | 25 ---------------- p2pvr/p2/views/events.cpp | 60 --------------------------------------- p2pvr/p2/views/schedules.cpp | 29 ------------------- p2pvr/p2/views/services.cpp | 28 ------------------ p2pvr/webfe/.p2config | 6 ++++ p2pvr/webfe/datasources/p2pvr.xml | 4 +++ p2pvr/webfe/present/iceTask.xml | 7 +++++ p2pvr/webfe/present/iceView.xml | 10 +++++++ 16 files changed, 78 insertions(+), 243 deletions(-) create mode 100644 p2pvr/ice/converters.cpp delete mode 100644 p2pvr/p2/Jamfile.jam delete mode 100644 p2pvr/p2/config.cpp delete mode 100644 p2pvr/p2/config.h delete mode 100644 p2pvr/p2/pch.hpp delete mode 100644 p2pvr/p2/views/events.cpp delete mode 100644 p2pvr/p2/views/schedules.cpp delete mode 100644 p2pvr/p2/views/services.cpp create mode 100644 p2pvr/webfe/.p2config create mode 100644 p2pvr/webfe/datasources/p2pvr.xml create mode 100644 p2pvr/webfe/present/iceTask.xml create mode 100644 p2pvr/webfe/present/iceView.xml diff --git a/p2pvr/Jamfile.jam b/p2pvr/Jamfile.jam index 3fe2894..565da4e 100644 --- a/p2pvr/Jamfile.jam +++ b/p2pvr/Jamfile.jam @@ -17,6 +17,10 @@ alias p2lib : glibmm : : : /usr/include/project2/lib "-lp2lib" ; +alias p2ice : glibmm : : : + /usr/include/project2/ice + "-lp2ice" +; alias p2daemonlib : glibmm : : : "-I /usr/include/project2/daemon/lib" "-lp2daemonlib" @@ -25,8 +29,8 @@ build-project streamer ; build-project daemon ; build-project carddaemon ; -install debuginstall : lib//p2pvrlib util//p2pvrutil p2//p2pvrp2 carddaemon daemon ice streamer//streamer : ./testing ; -package.install install : : : carddaemon daemon p2//p2pvrp2 ; +install debuginstall : lib//p2pvrlib util//p2pvrutil carddaemon daemon ice streamer//streamer : ./testing ; +package.install install : : : carddaemon daemon ; import type ; import generators ; diff --git a/p2pvr/ice/Jamfile.jam b/p2pvr/ice/Jamfile.jam index c5031bd..cc97614 100644 --- a/p2pvr/ice/Jamfile.jam +++ b/p2pvr/ice/Jamfile.jam @@ -8,7 +8,9 @@ lib p2pvrice : Ice IceUtil pthread + ..//p2common ..//p2lib + ..//p2ice : : . Ice diff --git a/p2pvr/ice/converters.cpp b/p2pvr/ice/converters.cpp new file mode 100644 index 0000000..94f2353 --- /dev/null +++ b/p2pvr/ice/converters.cpp @@ -0,0 +1,33 @@ +#include +#include +#include +#include "commonHelpers.h" + +template<> +VariableType +IceConvert::ToVariable(const Common::DateTime & dt) +{ + return *dt; +} + +template<> +VariableType +IceConvert::ToVariable(const Common::Duration & d) +{ + return *d; +} + +template<> +Common::DateTime +IceConvert::FromVariable(const VariableType & dt) +{ + return *dt.as(); +} + +template<> +Common::Duration +IceConvert::FromVariable(const VariableType & d) +{ + return *d.as(); +} + diff --git a/p2pvr/ice/dvbsi.ice b/p2pvr/ice/dvbsi.ice index 8cf6527..7978d3f 100644 --- a/p2pvr/ice/dvbsi.ice +++ b/p2pvr/ice/dvbsi.ice @@ -83,6 +83,7 @@ module DVBSI { BouquetTransportStreamList Streams; }; + ["project2:type"] class Service { int ServiceId; int TransportStreamId; @@ -121,6 +122,7 @@ module DVBSI { int OriginalNetworkId; }; + ["project2:type"] class Event { int ServiceId; int EventId; diff --git a/p2pvr/ice/p2pvr.ice b/p2pvr/ice/p2pvr.ice index 75bfbf8..61c0e32 100644 --- a/p2pvr/ice/p2pvr.ice +++ b/p2pvr/ice/p2pvr.ice @@ -65,16 +65,19 @@ module P2PVR { interface Recordings { idempotent int NewRecording(Recording rec); + ["project2:task"] idempotent void DeleteRecording(int recordingId); idempotent RecordingList GetRecordings(); }; interface Schedules { + ["project2:task"] idempotent void DeleteSchedule(int scheduleId); idempotent Schedule GetSchedule(int scheduleId); idempotent ScheduleList GetSchedules(); idempotent ScheduledToRecordList GetScheduledToRecord(); idempotent int UpdateSchedule(Schedule newSchedule); + ["project2:task"] idempotent void DoReschedule(); }; @@ -86,11 +89,16 @@ module P2PVR { idempotent DVBSI::Delivery GetDeliveryForTransport(int id); idempotent DVBSI::Delivery GetDeliveryForSi(); // Get services + ["project2:rows"] idempotent DVBSI::ServiceList GetServices(); + ["project2:rows"] idempotent DVBSI::Service GetService(int id); // Get events + ["project2:rows"] idempotent DVBSI::Event GetEvent(int serviceId, int eventId); + ["project2:rows"] idempotent DVBSI::Events EventsOnNow(); + ["project2:rows"] idempotent DVBSI::Events EventsInRange(Common::DateTime from, Common::DateTime to); }; diff --git a/p2pvr/p2/Jamfile.jam b/p2pvr/p2/Jamfile.jam deleted file mode 100644 index f81ee60..0000000 --- a/p2pvr/p2/Jamfile.jam +++ /dev/null @@ -1,18 +0,0 @@ -cpp-pch pch : pch.hpp : - ../ice//p2pvrice - ..//p2common - ..//p2lib - ../ice//p2pvrice -; - -lib p2pvrp2 : - pch - [ glob-tree *.cpp ] - : - ../ice//p2pvrice - ../util//p2pvrutil - ..//p2common - ..//p2lib - ../ice//p2pvrice -; - diff --git a/p2pvr/p2/config.cpp b/p2pvr/p2/config.cpp deleted file mode 100644 index 49022b7..0000000 --- a/p2pvr/p2/config.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include "config.h" -#include -#include - -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 deleted file mode 100644 index 56d8b53..0000000 --- a/p2pvr/p2/config.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef P2PVRP2_CONFIG_H -#define P2PVRP2_CONFIG_H - -#include -#include -#include -#include - -class Config : public ComponentLoader { - public: - static Ice::ObjectAdapterPtr Adapter(); - static Ice::CommunicatorPtr Communicator(); - template - 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 deleted file mode 100644 index 5ba7bd7..0000000 --- a/p2pvr/p2/pch.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#ifdef BOOST_BUILD_PCH_ENABLED -#ifndef P2PVRP2_PCH -#define P2PVRP2_PCH - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include - -#endif -#endif - - diff --git a/p2pvr/p2/views/events.cpp b/p2pvr/p2/views/events.cpp deleted file mode 100644 index f435731..0000000 --- a/p2pvr/p2/views/events.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#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("SI"); - auto services = proxy->EventsOnNow(); - ObjectRowState 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("SI"); - Common::DateTime from, to; - From(ec) >> from; - To(ec) >> to; - auto services = proxy->EventsInRange(from, to); - ObjectRowState 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 deleted file mode 100644 index 2c2d020..0000000 --- a/p2pvr/p2/views/schedules.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include -#include -#include -#include -#include -#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("Schedules"); - auto schedules = proxy->GetSchedules(); - ObjectRowState 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 deleted file mode 100644 index 2fb4c9d..0000000 --- a/p2pvr/p2/views/services.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include -#include -#include -#include -#include -#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("SI"); - auto services = proxy->GetServices(); - ObjectRowState rs; - BOOST_FOREACH(const auto & s, services) { - BindColumns(rs, s); - rs.process(rp); - } - } -}; - -DECLARE_LOADER("servicelist", ServiceList); diff --git a/p2pvr/webfe/.p2config b/p2pvr/webfe/.p2config new file mode 100644 index 0000000..f5ea06f --- /dev/null +++ b/p2pvr/webfe/.p2config @@ -0,0 +1,6 @@ +ice.client.sliceclient = ice/common.ice +library = libp2pvrice.so +ice.client.sliceclient = ice/dvbsi.ice +ice.client.sliceclient = ice/dvb.ice +ice.client.sliceclient = ice/p2pvr.ice + diff --git a/p2pvr/webfe/datasources/p2pvr.xml b/p2pvr/webfe/datasources/p2pvr.xml new file mode 100644 index 0000000..ce98566 --- /dev/null +++ b/p2pvr/webfe/datasources/p2pvr.xml @@ -0,0 +1,4 @@ + + + tcp -p 10000 -h randomdan.homeip.net -t 5000 + diff --git a/p2pvr/webfe/present/iceTask.xml b/p2pvr/webfe/present/iceTask.xml new file mode 100644 index 0000000..ca3e582 --- /dev/null +++ b/p2pvr/webfe/present/iceTask.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/p2pvr/webfe/present/iceView.xml b/p2pvr/webfe/present/iceView.xml new file mode 100644 index 0000000..8874d83 --- /dev/null +++ b/p2pvr/webfe/present/iceView.xml @@ -0,0 +1,10 @@ + + + + + + + + + + -- cgit v1.2.3