diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-10-26 19:52:15 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-10-26 19:52:15 +0000 |
commit | b5326ead7bdb119632c3dd2420a94a5da9d56b1d (patch) | |
tree | f3e939b8c28ed3e4cb4155efe81abe6607a564f0 | |
parent | Tidy up and alias glibmm and libxml++ refs (diff) | |
parent | Enable hidden visibility and LTO (diff) | |
download | p2pvr-0.1.3.tar.bz2 p2pvr-0.1.3.tar.xz p2pvr-0.1.3.zip |
Merge branch 'p2pvr-slicer'p2pvr-0.1.3
55 files changed, 199 insertions, 347 deletions
diff --git a/p2pvr/carddaemon/Jamfile.jam b/p2pvr/carddaemon/Jamfile.jam index 7088966..afa055f 100644 --- a/p2pvr/carddaemon/Jamfile.jam +++ b/p2pvr/carddaemon/Jamfile.jam @@ -5,4 +5,6 @@ lib p2pvrcarddaemon : <library>../ice//p2pvrice <library>../devices//p2pvrdevices <library>../daemonbase//p2pvrdaemonbase + <cflags>-fvisibility=hidden + <variant>release:<cflags>-flto ; diff --git a/p2pvr/daemon/Jamfile.jam b/p2pvr/daemon/Jamfile.jam index c565234..05b0e9b 100644 --- a/p2pvr/daemon/Jamfile.jam +++ b/p2pvr/daemon/Jamfile.jam @@ -1,4 +1,5 @@ lib slicer : : <name>slicer : : <include>/usr/include/slicer ; +lib slicer-db : : <name>slicer-db : : <include>/usr/include/slicer ; cpp-pch pch : pch.hpp : <library>../ice//p2pvrice @@ -22,8 +23,11 @@ lib p2pvrdaemon : <library>../devices//p2pvrdevices <library>../daemonbase//p2pvrdaemonbase <library>..//adhocutil + <cflags>-fvisibility=hidden + <variant>release:<cflags>-flto <implicit-dependency>../../libtmdb//tmdb <library>slicer + <library>slicer-db <slicer>yes <include>. : : diff --git a/p2pvr/daemon/dbClient.h b/p2pvr/daemon/dbClient.h index cd846e5..1fc12e8 100644 --- a/p2pvr/daemon/dbClient.h +++ b/p2pvr/daemon/dbClient.h @@ -11,6 +11,7 @@ #include <sqlVariableBinder.h> #include <sqlHandleAsVariableType.h> #include "p2Helpers.h" +#include <slicer/slicer.h> class SqlMergeTask; @@ -40,6 +41,13 @@ class DatabaseClient : public virtual CommonObjects { return {db, cmd}; } + template <typename SerializerType, typename Obj, typename ... ExtraArgs> + void Store(const Obj & o, const ExtraArgs & ... ea) const + { + auto db = dataSource<RdbmsDataSource>("postgres")->getWritable(); + Slicer::SerializeAny<SerializerType>(o, db.get(), ea...); + } + template <typename... Args> std::pair<RdbmsDataSource::ConnectionRef, SelectPtr> Select(const std::string & sql, const Args & ... args) const { diff --git a/p2pvr/daemon/globalDevices.h b/p2pvr/daemon/globalDevices.h index 33f6231..86d80c5 100644 --- a/p2pvr/daemon/globalDevices.h +++ b/p2pvr/daemon/globalDevices.h @@ -6,8 +6,9 @@ #include <dvb.h> #include <options.h> +#include <visibility.h> -class GlobalDevices : public P2PVR::Devices { +class DLL_PUBLIC GlobalDevices : public P2PVR::Devices { public: P2PVR::TunerPrx GetTunerSpecific(const DVBSI::DeliveryPtr &, const Ice::Current &); P2PVR::TunerPrx GetTunerAny(const DVBSI::DeliveryPtr &, const Ice::Current &); diff --git a/p2pvr/daemon/maintenance.h b/p2pvr/daemon/maintenance.h index 7ec0541..7c3e9b3 100644 --- a/p2pvr/daemon/maintenance.h +++ b/p2pvr/daemon/maintenance.h @@ -2,9 +2,11 @@ #define P2PVR_MAINTENANCE_H #include <p2pvr.h> +#include <IceUtil/Timer.h> #include "dbClient.h" +#include <visibility.h> -class Maintenance : public P2PVR::Maintenance, public DatabaseClient { +class DLL_PUBLIC Maintenance : public P2PVR::Maintenance, public DatabaseClient { public: Maintenance(Ice::ObjectAdapterPtr, IceUtil::TimerPtr); @@ -17,7 +19,7 @@ class Maintenance : public P2PVR::Maintenance, public DatabaseClient { INITOPTIONS; private: - void ScheduledUpdate(); + DLL_PRIVATE void ScheduledUpdate(); Ice::ObjectAdapterPtr adapter; IceUtil::TimerPtr timer; diff --git a/p2pvr/daemon/recorder.h b/p2pvr/daemon/recorder.h index bef331b..6a6940e 100644 --- a/p2pvr/daemon/recorder.h +++ b/p2pvr/daemon/recorder.h @@ -7,8 +7,9 @@ #include <p2pvr.h> #include <mutex> #include "serviceStreamer.h" +#include <visibility.h> -class Recorder : public P2PVR::Recorder { +class DLL_PUBLIC Recorder : public P2PVR::Recorder { public: typedef std::vector<IceUtil::TimerTaskPtr> Pendings; @@ -32,8 +33,8 @@ class Recorder : public P2PVR::Recorder { INITOPTIONS; private: - void StartRecording(P2PVR::SchedulePtr schedule, DVBSI::ServicePtr service, P2PVR::EventPtr event); - void StopRecording(CurrentPtr); + DLL_PRIVATE void StartRecording(P2PVR::SchedulePtr schedule, DVBSI::ServicePtr service, P2PVR::EventPtr event); + DLL_PRIVATE void StopRecording(CurrentPtr); Ice::ObjectAdapterPtr adapter; IceUtil::TimerPtr timer; diff --git a/p2pvr/daemon/recordings.cpp b/p2pvr/daemon/recordings.cpp index 9b79d60..ac8f27a 100644 --- a/p2pvr/daemon/recordings.cpp +++ b/p2pvr/daemon/recordings.cpp @@ -4,22 +4,19 @@ #include <Ice/Ice.h> #include <logger.h> #include <slicer/slicer.h> -#include "sqlSelectDeserializer.h" +#include <slicer/db/sqlSelectDeserializer.h> +#include <slicer/db/sqlInsertSerializer.h> -ResourceString(Recording_Insert, sql_Recordings_insert); -ResourceString(Recording_InsertNewId, sql_Recordings_insertNewId); ResourceString(Recording_Delete, sql_Recordings_delete); ResourceString(Recording_GetStorage, sql_Recordings_getStorage); ResourceString(Recording_GetAll, sql_Recordings_getAll); -int +Ice::Int Recordings::NewRecording(const P2PVR::RecordingPtr & r, const Ice::Current &) { Logger()->messagebf(LOG_INFO, "%s: Creating new recording %s at %s", __PRETTY_FUNCTION__, r->Guid, r->StorageAddress); TxHelper tx(this); - auto insert = Modify(Recording_Insert, r->StorageAddress, r->Guid, r->ScheduleId, r->EventUid); - insert.second->execute(); - r->RecordingId = SelectScalar<int>(Recording_InsertNewId); + Store<Slicer::SqlFetchIdInsertSerializer>(r, "recordings"); Logger()->messagebf(LOG_INFO, "%s: Created recording Id: %d", __PRETTY_FUNCTION__, r->RecordingId); return r->RecordingId; } @@ -47,7 +44,7 @@ P2PVR::RecordingList Recordings::GetRecordings(const Ice::Current &) { Logger()->message(LOG_DEBUG, __PRETTY_FUNCTION__); - return Slicer::DeserializeAny<SqlSelectDeserializer, P2PVR::RecordingList>( + return Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, P2PVR::RecordingList>( *Select(Recording_GetAll).second); } diff --git a/p2pvr/daemon/recordings.h b/p2pvr/daemon/recordings.h index 0f18a36..482ce23 100644 --- a/p2pvr/daemon/recordings.h +++ b/p2pvr/daemon/recordings.h @@ -4,10 +4,11 @@ #include <p2pvr.h> #include <string> #include "dbClient.h" +#include <visibility.h> -class Recordings : public DatabaseClient, public P2PVR::Recordings { +class DLL_PUBLIC Recordings : public DatabaseClient, public P2PVR::Recordings { public: - int NewRecording(const P2PVR::RecordingPtr & rec, const Ice::Current &); + Ice::Int NewRecording(const P2PVR::RecordingPtr & rec, const Ice::Current &); void DeleteRecording(int recordingId, const Ice::Current &); P2PVR::RecordingList GetRecordings(const Ice::Current &); }; diff --git a/p2pvr/daemon/schedules.cpp b/p2pvr/daemon/schedules.cpp index 40d7863..90a42a9 100644 --- a/p2pvr/daemon/schedules.cpp +++ b/p2pvr/daemon/schedules.cpp @@ -11,15 +11,13 @@ #include "resources.h" #include <boost/date_time/posix_time/posix_time.hpp> #include <factory.impl.h> -#include "sqlSelectDeserializer.h" -#include <slicer/slicer.h> +#include <slicer/db/sqlSelectDeserializer.h> +#include <slicer/db/sqlInsertSerializer.h> +#include <slicer/db/sqlUpdateSerializer.h> #include <p2pvr-int.h> #include <privateExecContext.h> ResourceString(Schedules_getCandidates, sql_Schedules_getCandidates); -ResourceString(Schedules_insert, sql_Schedules_insert); -ResourceString(Schedules_insertNewId, sql_Schedules_insertNewId); -ResourceString(Schedules_update, sql_Schedules_update); ResourceString(Schedules_delete, sql_Schedules_delete); ResourceString(Schedules_selectAll, sql_Schedules_selectAll); ResourceString(Schedules_selectById, sql_Schedules_selectById); @@ -193,7 +191,7 @@ Schedules::DoReschedule(const Ice::Current & ice) unsigned int tunerCount = devs->TunerCount(); // Load list from database - auto episodes = Slicer::DeserializeAny<SqlSelectDeserializer, P2PVR::ScheduleCandidates>( + auto episodes = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, P2PVR::ScheduleCandidates>( *Select(Schedules_getCandidates).second); Episodes scheduleList; @@ -309,7 +307,7 @@ P2PVR::ScheduleList Schedules::GetSchedules(const Ice::Current &) { Logger()->message(LOG_DEBUG, __PRETTY_FUNCTION__); - return Slicer::DeserializeAny<SqlSelectDeserializer, P2PVR::ScheduleList>( + return Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, P2PVR::ScheduleList>( *Select(Schedules_selectAll).second); } @@ -317,7 +315,7 @@ P2PVR::SchedulePtr Schedules::GetSchedule(int id, const Ice::Current &) { Logger()->messagebf(LOG_DEBUG, "%s(%d)", __PRETTY_FUNCTION__, id); - auto schedules = Slicer::DeserializeAny<SqlSelectDeserializer, P2PVR::ScheduleList>( + auto schedules = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, P2PVR::ScheduleList>( *Select(Schedules_selectById, id).second); if (schedules.empty()) throw P2PVR::NotFound(); return schedules.front(); @@ -327,24 +325,26 @@ P2PVR::ScheduledToRecordList Schedules::GetScheduledToRecord(const Ice::Current &) { Logger()->message(LOG_DEBUG, __PRETTY_FUNCTION__); - return Slicer::DeserializeAny<SqlSelectDeserializer, P2PVR::ScheduledToRecordList>( + return Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, P2PVR::ScheduledToRecordList>( *Select(Schedules_scheduledToRecord).second); } -int -Schedules::UpdateSchedule(const P2PVR::SchedulePtr & s, const Ice::Current & ice) +Ice::Int +Schedules::NewSchedule(const P2PVR::SchedulePtr & s, const Ice::Current & ice) { TxHelper tx(this); - if (s->ScheduleId == 0) { - Modify(Schedules_insert, s->ServiceId, s->EventUid, s->Title, s->Search, s->Priority, s->Early, s->Late, s->Repeats).second->execute(); - s->ScheduleId = SelectScalar<int>(Schedules_insertNewId); - } - else { - Modify(Schedules_update, s->ServiceId, s->EventUid, s->Title, s->Search, s->Priority, s->Early, s->Late, s->Repeats, s->ScheduleId).second->execute(); - } + Store<Slicer::SqlFetchIdInsertSerializer>(s, "schedules"); DoReschedule(ice); return s->ScheduleId; } +void +Schedules::UpdateSchedule(const P2PVR::SchedulePtr & s, const Ice::Current & ice) +{ + TxHelper tx(this); + Store<Slicer::SqlUpdateSerializer>(s, "schedules"); + DoReschedule(ice); +} + INSTANTIATEFACTORY(EpisodeGroup, const Episodes &); diff --git a/p2pvr/daemon/schedules.h b/p2pvr/daemon/schedules.h index 07f2c23..122e214 100644 --- a/p2pvr/daemon/schedules.h +++ b/p2pvr/daemon/schedules.h @@ -5,6 +5,7 @@ #include <options.h> #include "dbClient.h" #include <factory.h> +#include <visibility.h> typedef boost::posix_time::ptime datetime; class Episode; @@ -61,18 +62,20 @@ class EpisodeGroup { Showings selected; }; -class Schedules : public P2PVR::Schedules, public DatabaseClient { +class DLL_PUBLIC Schedules : public P2PVR::Schedules, public DatabaseClient { public: void DeleteSchedule(int id, const Ice::Current &); P2PVR::SchedulePtr GetSchedule(int id, const Ice::Current &); P2PVR::ScheduleList GetSchedules(const Ice::Current &); P2PVR::ScheduledToRecordList GetScheduledToRecord(const Ice::Current &); - int UpdateSchedule(const P2PVR::SchedulePtr &, const Ice::Current &); + Ice::Int NewSchedule(const P2PVR::SchedulePtr &, const Ice::Current &); + void UpdateSchedule(const P2PVR::SchedulePtr &, const Ice::Current &); void DoReschedule(const Ice::Current &); INITOPTIONS; protected: static void GetEpisodeIntersects(Episodes &, Episodes &); + private: static std::string SchedulerAlgorithm; }; diff --git a/p2pvr/daemon/si.cpp b/p2pvr/daemon/si.cpp index 9164a62..d511c47 100644 --- a/p2pvr/daemon/si.cpp +++ b/p2pvr/daemon/si.cpp @@ -1,7 +1,8 @@ #include <pch.hpp> #include "si.h" #include "resources.h" -#include "sqlSelectDeserializer.h" +#include <slicer/db/sqlSelectDeserializer.h> +#include <slicer/db/exceptions.h> #include "commonHelpers.h" #include <slicer/slicer.h> #include <logger.h> @@ -25,7 +26,7 @@ DVBSI::Networks SI::GetNetworks(const Ice::Current &) { Logger()->message(LOG_DEBUG, __PRETTY_FUNCTION__); - return Slicer::DeserializeAny<SqlSelectDeserializer, DVBSI::Networks>( + return Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, DVBSI::Networks>( *Select(SI_allNetworks).second); } @@ -33,7 +34,7 @@ P2PVR::Deliveries SI::GetAllDeliveries(const Ice::Current &) { Logger()->message(LOG_DEBUG, __PRETTY_FUNCTION__); - auto rtn = Slicer::DeserializeAny<SqlSelectDeserializer, P2PVR::Deliveries>( + auto rtn = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, P2PVR::Deliveries>( *Select(SI_allDeliveries).second, "delivery_type"); Logger()->messagebf(LOG_DEBUG, "%s: Found %d delivery methods", __PRETTY_FUNCTION__, rtn.size()); return rtn; @@ -44,10 +45,10 @@ SI::GetDeliveryForTransport(int id, const Ice::Current&) { try { Logger()->messagef(LOG_DEBUG, "%s(%d)", __PRETTY_FUNCTION__, id); - return Slicer::DeserializeAny<SqlSelectDeserializer, DVBSI::DeliveryPtr>( + return Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, DVBSI::DeliveryPtr>( *Select(SI_deliveryForTransport, id).second, "delivery_type"); } - catch (const NoRowsReturned &) { + catch (const Slicer::NoRowsReturned &) { throw P2PVR::NotFound(); } } @@ -57,10 +58,10 @@ SI::GetDeliveryForSi(const Ice::Current&) { try { Logger()->message(LOG_DEBUG, __PRETTY_FUNCTION__); - return Slicer::DeserializeAny<SqlSelectDeserializer, DVBSI::DeliveryPtr>( + return Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, DVBSI::DeliveryPtr>( *Select(SI_serviceNextUsed).second, "delivery_type"); } - catch (const NoRowsReturned &) { + catch (const Slicer::NoRowsReturned &) { return NULL; } } @@ -70,10 +71,10 @@ SI::GetDeliveryForService(int id, const Ice::Current&) { try { Logger()->messagef(LOG_DEBUG, "%s(%d)", __PRETTY_FUNCTION__, id); - return Slicer::DeserializeAny<SqlSelectDeserializer, DVBSI::DeliveryPtr>( + return Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, DVBSI::DeliveryPtr>( *Select(SI_deliveryForService, id).second, "delivery_type"); } - catch (const NoRowsReturned &) { + catch (const Slicer::NoRowsReturned &) { throw P2PVR::NotFound(); } } @@ -82,7 +83,7 @@ DVBSI::ServiceList SI::GetServices(const Ice::Current&) { Logger()->message(LOG_DEBUG, __PRETTY_FUNCTION__); - return Slicer::DeserializeAny<SqlSelectDeserializer, DVBSI::ServiceList>( + return Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, DVBSI::ServiceList>( *Select(SI_servicesSelectAll).second); } @@ -90,7 +91,7 @@ DVBSI::ServicePtr SI::GetService(int id, const Ice::Current&) { Logger()->messagef(LOG_DEBUG, "%s(%d)", __PRETTY_FUNCTION__, id); - auto rtn = Slicer::DeserializeAny<SqlSelectDeserializer, DVBSI::ServiceList>( + auto rtn = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, DVBSI::ServiceList>( *Select(SI_servicesSelectById, id).second); if (rtn.empty()) throw P2PVR::NotFound(); return rtn.front(); @@ -102,7 +103,7 @@ SI::GetEvents(const P2PVR::IntSequence & eventUids, const Ice::Current &) Logger()->message(LOG_DEBUG, __PRETTY_FUNCTION__); P2PVR::Events rtn; for (const auto & uid : eventUids) { - auto list = Slicer::DeserializeAny<SqlSelectDeserializer, P2PVR::Events>( + auto list = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, P2PVR::Events>( *Select(SI_eventByUid, uid).second); std::copy(list.begin(), list.end(), std::back_inserter(rtn)); } @@ -114,7 +115,7 @@ P2PVR::EventPtr SI::GetEvent(int serviceId, int eventId, const Ice::Current &) { Logger()->messagef(LOG_DEBUG, "%s(s=%d, e=%d)", __PRETTY_FUNCTION__, serviceId, eventId); - auto rtn = Slicer::DeserializeAny<SqlSelectDeserializer, P2PVR::Events>( + auto rtn = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, P2PVR::Events>( *Select(SI_eventById, serviceId, eventId).second); if (rtn.empty()) throw P2PVR::NotFound(); return rtn.front(); @@ -124,7 +125,7 @@ P2PVR::Events SI::EventsOnNow(const Ice::Current &) { Logger()->message(LOG_DEBUG, __PRETTY_FUNCTION__); - return Slicer::DeserializeAny<SqlSelectDeserializer, P2PVR::Events>( + return Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, P2PVR::Events>( *Select(SI_eventsOnNow).second); } @@ -132,7 +133,7 @@ P2PVR::Events SI::EventsInRange(const Common::DateTime & from, const Common::DateTime & to, const Ice::Current &) { Logger()->messagebf(LOG_DEBUG, "%s([%s]-[%s])", from, to, __PRETTY_FUNCTION__); - return Slicer::DeserializeAny<SqlSelectDeserializer, P2PVR::Events>( + return Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, P2PVR::Events>( *Select(SI_eventsInRange, from, to).second); } @@ -141,7 +142,7 @@ SI::EventSearch(const IceUtil::Optional<std::string> & keywords, const IceUtil:: { Logger()->messagebf(LOG_DEBUG, "%s(keywords=%s,serviceId=%s,from=%s,to=%s)", keywords, serviceId, from, to, __PRETTY_FUNCTION__); - return Slicer::DeserializeAny<SqlSelectDeserializer, P2PVR::Events>( + return Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, P2PVR::Events>( *Select(SI_eventSearch, from, to, serviceId, serviceId, keywords, keywords, keywords, keywords).second); } @@ -149,7 +150,7 @@ P2PVR::Events SI::EventsInSchedules(const Ice::Current &) { Logger()->message(LOG_DEBUG, __PRETTY_FUNCTION__); - return Slicer::DeserializeAny<SqlSelectDeserializer, P2PVR::Events>( + return Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, P2PVR::Events>( *Select(SI_eventsInSchedules).second); } @@ -157,7 +158,7 @@ P2PVR::Events SI::EventsInSchedule(int scheduleId, const Ice::Current &) { Logger()->messagebf(LOG_DEBUG, "%s(%d)", scheduleId, __PRETTY_FUNCTION__); - return Slicer::DeserializeAny<SqlSelectDeserializer, P2PVR::Events>( + return Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, P2PVR::Events>( *Select(SI_eventsInSchedule, scheduleId).second); } diff --git a/p2pvr/daemon/si.h b/p2pvr/daemon/si.h index c57a018..0e388a1 100644 --- a/p2pvr/daemon/si.h +++ b/p2pvr/daemon/si.h @@ -3,8 +3,9 @@ #include <p2pvr.h> #include "dbClient.h" +#include <visibility.h> -class SI : public P2PVR::SI, public DatabaseClient { +class DLL_PUBLIC SI : public P2PVR::SI, public DatabaseClient { public: DVBSI::Networks GetNetworks(const Ice::Current &); P2PVR::Deliveries GetAllDeliveries(const Ice::Current &); diff --git a/p2pvr/daemon/sql/Recordings_insert.sql b/p2pvr/daemon/sql/Recordings_insert.sql deleted file mode 100644 index ba0b9e2..0000000 --- a/p2pvr/daemon/sql/Recordings_insert.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO recordings(storageAddress, guid, scheduleId, eventUid) -VALUES(?, ?, ?, ?) diff --git a/p2pvr/daemon/sql/Recordings_insertNewId.sql b/p2pvr/daemon/sql/Recordings_insertNewId.sql deleted file mode 100644 index 0583b49..0000000 --- a/p2pvr/daemon/sql/Recordings_insertNewId.sql +++ /dev/null @@ -1,2 +0,0 @@ -SELECT currval('recordings_recordingid_seq'); - diff --git a/p2pvr/daemon/sql/Schedules_insert.sql b/p2pvr/daemon/sql/Schedules_insert.sql deleted file mode 100644 index 70c95bd..0000000 --- a/p2pvr/daemon/sql/Schedules_insert.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO schedules(serviceId, eventUid, title, search, priority, early, late, repeats) -VALUES(?, ?, ?, ?, ?, ?, ?, ?) diff --git a/p2pvr/daemon/sql/Schedules_insertNewId.sql b/p2pvr/daemon/sql/Schedules_insertNewId.sql deleted file mode 100644 index f66acd5..0000000 --- a/p2pvr/daemon/sql/Schedules_insertNewId.sql +++ /dev/null @@ -1 +0,0 @@ -SELECT currval('schedules_scheduleid_seq'); diff --git a/p2pvr/daemon/sql/Schedules_update.sql b/p2pvr/daemon/sql/Schedules_update.sql deleted file mode 100644 index cf3ce49..0000000 --- a/p2pvr/daemon/sql/Schedules_update.sql +++ /dev/null @@ -1,10 +0,0 @@ -UPDATE schedules SET - serviceId = ?, - eventUid = ?, - title = ?, - search = ?, - priority = ?, - early = ?, - late = ?, - repeats = ? -WHERE scheduleId = ? diff --git a/p2pvr/daemon/sqlSelectDeserializer.cpp b/p2pvr/daemon/sqlSelectDeserializer.cpp deleted file mode 100644 index 5a59e3a..0000000 --- a/p2pvr/daemon/sqlSelectDeserializer.cpp +++ /dev/null @@ -1,176 +0,0 @@ -#include "sqlSelectDeserializer.h" -#include <sqlHandleAsVariableType.h> -#include <logger.h> -#include <boost/algorithm/string/predicate.hpp> -#include <stdexcept> - -VariableType -operator/(DB::SelectCommand & cmd, unsigned int col) -{ - HandleAsVariableType vt; - cmd[col].apply(vt); - return vt.variable; -} - -class SqlSource : public DB::HandleField, public Slicer::ValueSource, - public Slicer::TValueSource<boost::posix_time::time_duration>, - public Slicer::TValueSource<boost::posix_time::ptime> { - public: - bool isNull() const - { - return vt.isNull(); - } - - void interval(const boost::posix_time::time_duration & d) override - { - vt = d; - } - void null() override - { - vt = Null(); - } - void string(const char * s, size_t l) override - { - vt = std::string(s, l); - } - void integer(int64_t i) override - { - vt = i; - } - void floatingpoint(double fp) override - { - vt = fp; - } - void timestamp(const boost::posix_time::ptime & t) - { - vt = t; - } - void boolean(bool b) override - { - vt = b; - } -#define SET(Type) \ - void set(Type & b) const override { \ - b = vt.as<Type>(); \ - } -#define SETNCONV(Type, CType) \ - void set(Type & b) const override { \ - b = boost::numeric_cast<Type>(vt.as<CType>()); \ - } - SET(bool); - SET(std::string); - SETNCONV(Ice::Byte, int64_t); - SETNCONV(Ice::Short, int64_t); - SET(Ice::Int); - SET(Ice::Long); - SETNCONV(Ice::Float, double); - SET(Ice::Double); - SET(boost::posix_time::ptime); - SET(boost::posix_time::time_duration); - - private: - VariableType vt; -}; -typedef IceUtil::Handle<SqlSource> SqlSourcePtr; - -SqlSelectDeserializer::SqlSelectDeserializer(DB::SelectCommand & c, IceUtil::Optional<std::string> tc) : - cmd(c), - typeIdColName(tc) -{ -} - -void -SqlSelectDeserializer::Deserialize(Slicer::ModelPartPtr mp) -{ - cmd.execute(); - columnCount = cmd.columnCount(); - if (typeIdColName) { - typeIdColIdx = cmd.getOrdinal(*typeIdColName); - } - switch (mp->GetType()) { - case Slicer::mpt_Sequence: - DeserializeSequence(mp); - return; - case Slicer::mpt_Complex: - DeserializeObject(mp); - return; - case Slicer::mpt_Simple: - DeserializeSimple(mp); - return; - default: - throw std::invalid_argument("Unspported model type"); - } -} - -void -SqlSelectDeserializer::DeserializeSimple(Slicer::ModelPartPtr mp) -{ - auto fmp = mp->GetAnonChild(); - if (!cmd.fetch()) { - throw NoRowsReturned(); - } - SqlSourcePtr h = new SqlSource(); - const DB::Column & c = cmd[0]; - c.apply(*h); - if (!h->isNull()) { - fmp->Create(); - fmp->SetValue(h); - fmp->Complete(); - } - if (cmd.fetch()) { - throw std::invalid_argument("Too many rows returned"); - } -} - -void -SqlSelectDeserializer::DeserializeSequence(Slicer::ModelPartPtr mp) -{ - mp = mp->GetAnonChild(); - SqlSourcePtr h = new SqlSource(); - while (cmd.fetch()) { - DeserializeRow(mp); - } -} - -void -SqlSelectDeserializer::DeserializeObject(Slicer::ModelPartPtr mp) -{ - if (!cmd.fetch()) { - throw NoRowsReturned(); - } - DeserializeRow(mp); - if (cmd.fetch()) { - while (cmd.fetch()) ; - throw std::invalid_argument("Too many rows returned"); - } -} - -void -SqlSelectDeserializer::DeserializeRow(Slicer::ModelPartPtr mp) -{ - SqlSourcePtr h = new SqlSource(); - auto rmp = mp->GetAnonChild(); - if (rmp) { - if (typeIdColIdx) { - rmp = rmp->GetSubclassModelPart(cmd / *typeIdColIdx); - } - rmp->Create(); - for (auto col = 0u; col < columnCount; col += 1) { - const DB::Column & c = cmd[col]; - auto fmpr = rmp->GetAnonChildRef([&c](Slicer::HookCommonPtr h) { - return boost::iequals(c.name.raw(), h->PartName()); - }); - if (fmpr) { - auto fmp = fmpr->Child(); - c.apply(*h); - if (!h->isNull()) { - fmp->Create(); - fmp->SetValue(h); - fmp->Complete(); - } - } - } - rmp->Complete(); - } -} - diff --git a/p2pvr/daemon/sqlSelectDeserializer.h b/p2pvr/daemon/sqlSelectDeserializer.h deleted file mode 100644 index 0c32811..0000000 --- a/p2pvr/daemon/sqlSelectDeserializer.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef P2PVR_SQL_DESERIALIZER_H -#define P2PVR_SQL_DESERIALIZER_H - -#include <slicer/serializer.h> -#include <selectcommand.h> - -class NoRowsReturned : public std::exception { }; - -class SqlSelectDeserializer : public Slicer::Deserializer { - public: - SqlSelectDeserializer(DB::SelectCommand &, IceUtil::Optional<std::string> typeIdCol = IceUtil::Optional<std::string>()); - - virtual void Deserialize(Slicer::ModelPartPtr) override; - - protected: - void DeserializeSimple(Slicer::ModelPartPtr); - void DeserializeObject(Slicer::ModelPartPtr); - void DeserializeSequence(Slicer::ModelPartPtr); - void DeserializeRow(Slicer::ModelPartPtr); - - DB::SelectCommand & cmd; - unsigned int columnCount; - IceUtil::Optional<std::string> typeIdColName; - IceUtil::Optional<unsigned int> typeIdColIdx; -}; - -#endif - diff --git a/p2pvr/daemon/storage.h b/p2pvr/daemon/storage.h index 144d6bd..982c3fd 100644 --- a/p2pvr/daemon/storage.h +++ b/p2pvr/daemon/storage.h @@ -6,8 +6,9 @@ #include <string> #include <boost/filesystem/path.hpp> #include "temporaryIceAdapterObject.h" +#include <visibility.h> -class Storage : public P2PVR::Storage { +class DLL_PUBLIC Storage : public P2PVR::Storage { public: P2PVR::RawDataClientPrx OpenForWrite(const std::string &, const Ice::Current &) override; void Close(const P2PVR::RawDataClientPrx & file, const Ice::Current &) override; diff --git a/p2pvr/daemon/unittests/Jamfile.jam b/p2pvr/daemon/unittests/Jamfile.jam index 86bb906..6f0f0dd 100644 --- a/p2pvr/daemon/unittests/Jamfile.jam +++ b/p2pvr/daemon/unittests/Jamfile.jam @@ -237,6 +237,7 @@ run <library>Ice <library>../..//boost_utf <library>testCommon + <library>..//slicer-db <dependency>test-data <define>ROOT=\"$(me)\" : testSqlSelectDeserializer ; diff --git a/p2pvr/daemon/unittests/mockScheduler.cpp b/p2pvr/daemon/unittests/mockScheduler.cpp index 2677df7..193630d 100644 --- a/p2pvr/daemon/unittests/mockScheduler.cpp +++ b/p2pvr/daemon/unittests/mockScheduler.cpp @@ -29,8 +29,13 @@ MockScheduler::GetScheduledToRecord(const::Ice::Current &) } Ice::Int +MockScheduler::NewSchedule(const::P2PVR::SchedulePtr &, const::Ice::Current &) +{ + return 1; +} + +void MockScheduler::UpdateSchedule(const::P2PVR::SchedulePtr &, const::Ice::Current &) { - return 0; } diff --git a/p2pvr/daemon/unittests/mockScheduler.h b/p2pvr/daemon/unittests/mockScheduler.h index 9176bb6..e90567b 100644 --- a/p2pvr/daemon/unittests/mockScheduler.h +++ b/p2pvr/daemon/unittests/mockScheduler.h @@ -10,7 +10,8 @@ class MockScheduler : public P2PVR::Schedules { P2PVR::SchedulePtr GetSchedule(::Ice::Int, const ::Ice::Current&) override; P2PVR::ScheduleList GetSchedules(const ::Ice::Current&) override; P2PVR::ScheduledToRecordList GetScheduledToRecord(const ::Ice::Current&) override; - Ice::Int UpdateSchedule(const ::P2PVR::SchedulePtr&, const ::Ice::Current&) override; + Ice::Int NewSchedule(const ::P2PVR::SchedulePtr&, const ::Ice::Current&) override; + void UpdateSchedule(const ::P2PVR::SchedulePtr&, const ::Ice::Current&) override; }; #endif diff --git a/p2pvr/daemon/unittests/testMaint.cpp b/p2pvr/daemon/unittests/testMaint.cpp index 38c9478..9926c2b 100644 --- a/p2pvr/daemon/unittests/testMaint.cpp +++ b/p2pvr/daemon/unittests/testMaint.cpp @@ -13,7 +13,7 @@ #include <linux/dvb/frontend.h> #include <definedDirs.h> #include "mockDefs.h" -#include "sqlSelectDeserializer.h" +#include <slicer/db/sqlSelectDeserializer.h> #include "commonHelpers.h" #include <slicer/slicer.h> #include <testAppInstance.h> diff --git a/p2pvr/daemon/unittests/testRecording.cpp b/p2pvr/daemon/unittests/testRecording.cpp index d3ecee6..260bf82 100644 --- a/p2pvr/daemon/unittests/testRecording.cpp +++ b/p2pvr/daemon/unittests/testRecording.cpp @@ -13,7 +13,7 @@ #include <linux/dvb/frontend.h> #include <definedDirs.h> #include "mockDefs.h" -#include "sqlSelectDeserializer.h" +#include <slicer/db/sqlSelectDeserializer.h> #include "commonHelpers.h" #include "serviceStreamer.h" #include "temporaryIceAdapterObject.h" diff --git a/p2pvr/daemon/unittests/testRecordings.cpp b/p2pvr/daemon/unittests/testRecordings.cpp index ff8f676..7415cb1 100644 --- a/p2pvr/daemon/unittests/testRecordings.cpp +++ b/p2pvr/daemon/unittests/testRecordings.cpp @@ -68,9 +68,10 @@ BOOST_AUTO_TEST_CASE( recordings_addAndDelete ) auto guid = boost::lexical_cast<std::string>(boost::uuids::random_generator()()); auto rec = P2PVR::RecordingPtr(new P2PVR::Recording(0, "", guid, 0, event->EventUid)); - auto id = r->NewRecording(rec); + rec->RecordingId = r->NewRecording(rec); + BOOST_REQUIRE_EQUAL(218, rec->RecordingId); r->GetRecordings(); - r->DeleteRecording(id); + r->DeleteRecording(rec->RecordingId); } BOOST_AUTO_TEST_SUITE_END() diff --git a/p2pvr/daemon/unittests/testSched.cpp b/p2pvr/daemon/unittests/testSched.cpp index 9afdaad..45414aa 100644 --- a/p2pvr/daemon/unittests/testSched.cpp +++ b/p2pvr/daemon/unittests/testSched.cpp @@ -79,11 +79,10 @@ BOOST_AUTO_TEST_CASE( sc_crud ) P2PVR::SchedulePtr schedule = new P2PVR::Schedule(); schedule->Search = "Top Gear"; - auto id = sc->UpdateSchedule(schedule); - BOOST_REQUIRE(id > 0); - schedule->ScheduleId = id; + schedule->ScheduleId = sc->NewSchedule(schedule); + BOOST_REQUIRE_EQUAL(187, schedule->ScheduleId); - auto fetched = sc->GetSchedule(id); + auto fetched = sc->GetSchedule(schedule->ScheduleId); BOOST_REQUIRE_EQUAL(schedule->ScheduleId, fetched->ScheduleId); BOOST_REQUIRE_EQUAL(*schedule->Search, *fetched->Search); BOOST_REQUIRE_EQUAL(schedule->Priority, fetched->Priority); @@ -94,10 +93,9 @@ BOOST_AUTO_TEST_CASE( sc_crud ) schedule->Search = "Top Gear Special"; schedule->Early.Minutes = 5; schedule->Late.Minutes = 15; - auto updatedId = sc->UpdateSchedule(schedule); + sc->UpdateSchedule(schedule); - fetched = sc->GetSchedule(id); - BOOST_REQUIRE_EQUAL(updatedId, id); + fetched = sc->GetSchedule(schedule->ScheduleId); BOOST_REQUIRE_EQUAL(schedule->ScheduleId, fetched->ScheduleId); BOOST_REQUIRE_EQUAL(*schedule->Search, *fetched->Search); BOOST_REQUIRE_EQUAL(schedule->Priority, fetched->Priority); diff --git a/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp b/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp index 077486c..47d36c5 100644 --- a/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp +++ b/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp @@ -1,6 +1,6 @@ #define BOOST_TEST_MODULE SqlSelectDeserializer #include <boost/test/unit_test.hpp> -#include <sqlSelectDeserializer.h> +#include <slicer/db/sqlSelectDeserializer.h> #include <slicer/slicer.h> #include <connection.h> #include <p2pvr.h> @@ -33,7 +33,7 @@ BOOST_AUTO_TEST_CASE( listOfEvents ) { auto db = dataSource<RdbmsDataSource>("postgres")->getReadonly(); auto sel = SelectPtr(db->newSelectCommand("SELECT * FROM events ORDER BY serviceId, eventId LIMIT 100")); - auto res = Slicer::DeserializeAny<SqlSelectDeserializer, P2PVR::Events>(*sel); + auto res = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, P2PVR::Events>(*sel); BOOST_REQUIRE_EQUAL(res.size(), 100); BOOST_REQUIRE_EQUAL(res[0]->ServiceId, 4166); BOOST_REQUIRE_EQUAL(res[0]->EventId, 49741); @@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE( singleField ) { auto db = dataSource<RdbmsDataSource>("postgres")->getReadonly(); auto sel = SelectPtr(db->newSelectCommand("SELECT EventId FROM events ORDER BY serviceId, eventId LIMIT 1")); - auto res = Slicer::DeserializeAny<SqlSelectDeserializer, int>(*sel); + auto res = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, int>(*sel); BOOST_REQUIRE_EQUAL(res, 49741); } @@ -60,7 +60,7 @@ BOOST_AUTO_TEST_CASE( singleEvent ) { auto db = dataSource<RdbmsDataSource>("postgres")->getReadonly(); auto sel = SelectPtr(db->newSelectCommand("SELECT * FROM events ORDER BY serviceId, eventId LIMIT 1")); - auto res = Slicer::DeserializeAny<SqlSelectDeserializer, P2PVR::EventPtr>(*sel); + auto res = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, P2PVR::EventPtr>(*sel); BOOST_REQUIRE_EQUAL(res->ServiceId, 4166); BOOST_REQUIRE_EQUAL(res->EventId, 49741); BOOST_REQUIRE_EQUAL(res->Title, "Skiing Weatherview"); @@ -74,7 +74,7 @@ BOOST_AUTO_TEST_CASE( dynamicTypes ) { auto db = dataSource<RdbmsDataSource>("postgres")->getReadonly(); auto sel = SelectPtr(db->newSelectCommand("SELECT d.*, '::DVBSI::TerrestrialDelivery' \"typeid\" FROM delivery_dvbt d ORDER BY TransportStreamId")); - auto res = Slicer::DeserializeAny<SqlSelectDeserializer, P2PVR::Deliveries>(*sel, "typeid"); + auto res = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, P2PVR::Deliveries>(*sel, "typeid"); BOOST_REQUIRE_EQUAL(res.size(), 6); auto dvbt = DVBSI::TerrestrialDeliveryPtr::dynamicCast(res[0]); BOOST_REQUIRE_EQUAL(dvbt->Frequency, 682000000); diff --git a/p2pvr/daemon/unittests/testp2ice.cpp b/p2pvr/daemon/unittests/testp2ice.cpp index dc584b6..6eece19 100644 --- a/p2pvr/daemon/unittests/testp2ice.cpp +++ b/p2pvr/daemon/unittests/testp2ice.cpp @@ -27,9 +27,8 @@ void unloadTests() { BOOST_REQUIRE_THROW(RowSetFactory::get("P2PVR-SI-GetEvent"), AdHoc::NoSuchPluginException); - // Known issue, these *should* unload, but for some reason, don't. - BOOST_WARN_THROW(StreamFactory::get("p2pvrrecordingstream"), AdHoc::NoSuchPluginException); - BOOST_WARN_THROW(StreamFactory::get("p2pvrservicestream"), AdHoc::NoSuchPluginException); + BOOST_REQUIRE_THROW(StreamFactory::get("p2pvrrecordingstream"), AdHoc::NoSuchPluginException); + BOOST_REQUIRE_THROW(StreamFactory::get("p2pvrservicestream"), AdHoc::NoSuchPluginException); } BOOST_GLOBAL_FIXTURE( TestAppInstance ); diff --git a/p2pvr/daemonbase/Jamfile.jam b/p2pvr/daemonbase/Jamfile.jam index f02a172..2168986 100644 --- a/p2pvr/daemonbase/Jamfile.jam +++ b/p2pvr/daemonbase/Jamfile.jam @@ -15,6 +15,8 @@ lib p2pvrdaemonbase : <library>../lib//p2pvrlib <library>../ice//p2pvrice <library>..//adhocutil + <cflags>-fvisibility=hidden + <variant>release:<cflags>-flto <implicit-dependency>../ice//p2pvrice : : <implicit-dependency>../ice//p2pvrice diff --git a/p2pvr/daemonbase/daemonBase.h b/p2pvr/daemonbase/daemonBase.h index 3cf9b19..87e741b 100644 --- a/p2pvr/daemonbase/daemonBase.h +++ b/p2pvr/daemonbase/daemonBase.h @@ -5,8 +5,9 @@ #include <Ice/Initialize.h> #include <daemon.h> #include <options.h> +#include <visibility.h> -class DaemonBase : public Daemon { +class DLL_PUBLIC DaemonBase : public Daemon { public: DaemonBase(int argc, char ** argv); ~DaemonBase(); diff --git a/p2pvr/daemonbase/fileSink.h b/p2pvr/daemonbase/fileSink.h index 8c7594b..fbd469c 100644 --- a/p2pvr/daemonbase/fileSink.h +++ b/p2pvr/daemonbase/fileSink.h @@ -4,8 +4,9 @@ #include <boost/filesystem/path.hpp> #include <stdio.h> #include <dvb.h> +#include <visibility.h> -class FileSink : public P2PVR::RawDataClient { +class DLL_PUBLIC FileSink : public P2PVR::RawDataClient { public: FileSink(const boost::filesystem::path & path); FileSink(int fd); diff --git a/p2pvr/daemonbase/p2LoggerWrapper.h b/p2pvr/daemonbase/p2LoggerWrapper.h index e8de1e8..0d84683 100644 --- a/p2pvr/daemonbase/p2LoggerWrapper.h +++ b/p2pvr/daemonbase/p2LoggerWrapper.h @@ -2,8 +2,9 @@ #define P2LOGGERWRAPPER #include <Ice/Logger.h> +#include <visibility.h> -class P2LoggerWrapper : public Ice::Logger { +class DLL_PUBLIC P2LoggerWrapper : public Ice::Logger { public: P2LoggerWrapper(const std::string & prefix = std::string()); diff --git a/p2pvr/devices/Jamfile.jam b/p2pvr/devices/Jamfile.jam index f39256b..67c86fe 100644 --- a/p2pvr/devices/Jamfile.jam +++ b/p2pvr/devices/Jamfile.jam @@ -25,6 +25,8 @@ lib p2pvrdevices : <library>..//p2common <library>..//adhocutil <implicit-dependency>../ice//p2pvrice + <cflags>-fvisibility=hidden + <variant>release:<cflags>-flto : : <library>boost_filesystem <implicit-dependency>../ice//p2pvrice diff --git a/p2pvr/devices/localDevices.h b/p2pvr/devices/localDevices.h index 3c3d51b..1845256 100644 --- a/p2pvr/devices/localDevices.h +++ b/p2pvr/devices/localDevices.h @@ -7,8 +7,10 @@ #include <dvb.h> #include <options.h> #include <mutex> +#include <visibility.h> +#include <IceUtil/Timer.h> -class LocalDevices : public P2PVR::LocalDevices { +class DLL_PUBLIC LocalDevices : public P2PVR::LocalDevices { public: LocalDevices(Ice::ObjectAdapterPtr adapter, IceUtil::TimerPtr); ~LocalDevices(); @@ -30,9 +32,9 @@ class LocalDevices : public P2PVR::LocalDevices { IceUtil::TimerTaskPtr clientCheck; // Check that registered clients haven't silently gone away - void ClientCheck(Ice::ObjectAdapterPtr adapter); + DLL_PRIVATE void ClientCheck(Ice::ObjectAdapterPtr adapter); - class OpenTuner { + class DLL_PRIVATE OpenTuner { public: OpenTuner(DVBSI::DeliveryPtr, P2PVR::PrivateTunerPrx, bool); diff --git a/p2pvr/dvb/Jamfile.jam b/p2pvr/dvb/Jamfile.jam index e71093a..1e81a73 100644 --- a/p2pvr/dvb/Jamfile.jam +++ b/p2pvr/dvb/Jamfile.jam @@ -8,6 +8,8 @@ lib p2pvrdvb : : <library>../ice//p2pvrice <library>..//adhocutil + <cflags>-fvisibility=hidden + <variant>release:<cflags>-flto <implicit-dependency>../ice//p2pvrice : : <implicit-dependency>../ice//p2pvrice diff --git a/p2pvr/dvb/siParsers/event.h b/p2pvr/dvb/siParsers/event.h index d437c4e..5baadd4 100644 --- a/p2pvr/dvb/siParsers/event.h +++ b/p2pvr/dvb/siParsers/event.h @@ -3,6 +3,7 @@ #include "table.h" #include <dvbsi.h> +#include <visibility.h> struct EventInformation { SiTableHeader header; @@ -13,7 +14,7 @@ struct EventInformation { u_char data[]; } __attribute__((packed)); -class SiEpgParser : public SiTableParser<EventInformation, DVBSI::EitInformationPtr, int> { +class DLL_PUBLIC SiEpgParser : public SiTableParser<EventInformation, DVBSI::EitInformationPtr, int> { protected: bool CheckTableId(u_char tableId) const; int SectionNumberShift() const { return 3; } @@ -24,11 +25,11 @@ class SiEpgParser : public SiTableParser<EventInformation, DVBSI::EitInformation virtual bool HandleTable(DVBSI::EventPtr) = 0; private: - static void parseStartTimeAndDuration(DVBSI::EventPtr, const u_char * data); - static void parseDescriptor_ShortEvent(DVBSI::EventPtr, const u_char * data); - static void parseDescriptor_Component(DVBSI::EventPtr, const u_char * data); - static void parseDescriptor_Content(DVBSI::EventPtr, const u_char * data); - static void parseDescriptor_ParentalRating(DVBSI::EventPtr, const u_char * data); + DLL_PRIVATE static void parseStartTimeAndDuration(DVBSI::EventPtr, const u_char * data); + DLL_PRIVATE static void parseDescriptor_ShortEvent(DVBSI::EventPtr, const u_char * data); + DLL_PRIVATE static void parseDescriptor_Component(DVBSI::EventPtr, const u_char * data); + DLL_PRIVATE static void parseDescriptor_Content(DVBSI::EventPtr, const u_char * data); + DLL_PRIVATE static void parseDescriptor_ParentalRating(DVBSI::EventPtr, const u_char * data); }; #endif diff --git a/p2pvr/dvb/siParsers/network.h b/p2pvr/dvb/siParsers/network.h index 4f8e6e3..fef11d0 100644 --- a/p2pvr/dvb/siParsers/network.h +++ b/p2pvr/dvb/siParsers/network.h @@ -3,6 +3,7 @@ #include "table.h" #include <dvbsi.h> +#include <visibility.h> struct NetworkInformation { SiTableHeader header; @@ -17,17 +18,17 @@ struct NetworkInformation { u_char data[]; } __attribute__((packed)); -class SiNetworkInformationParser : public SiTableParser<NetworkInformation, DVBSI::NetworkPtr, u_char> { +class DLL_PUBLIC SiNetworkInformationParser : public SiTableParser<NetworkInformation, DVBSI::NetworkPtr, u_char> { protected: bool CheckTableId(u_char tableId) const; void ParseSiTable(const struct NetworkInformation * nit, DVBSI::NetworkPtr); private: - static void parseDescriptor_NetworkName(DVBSI::NetworkPtr, const u_char *data, size_t len); - static void parseDescriptor_ServiceList(DVBSI::NetworkTransportStreamPtr, const u_char *data, size_t len); - static void parseDescriptor_TerrestrialDelivery(DVBSI::NetworkTransportStreamPtr, const u_char *data, size_t len); - static void parseDescriptor_SatelliteDelivery(DVBSI::NetworkTransportStreamPtr, const u_char *data, size_t len); - static void parseDescriptor_CableDelivery(DVBSI::NetworkTransportStreamPtr, const u_char *data, size_t len); + DLL_PRIVATE static void parseDescriptor_NetworkName(DVBSI::NetworkPtr, const u_char *data, size_t len); + DLL_PRIVATE static void parseDescriptor_ServiceList(DVBSI::NetworkTransportStreamPtr, const u_char *data, size_t len); + DLL_PRIVATE static void parseDescriptor_TerrestrialDelivery(DVBSI::NetworkTransportStreamPtr, const u_char *data, size_t len); + DLL_PRIVATE static void parseDescriptor_SatelliteDelivery(DVBSI::NetworkTransportStreamPtr, const u_char *data, size_t len); + DLL_PRIVATE static void parseDescriptor_CableDelivery(DVBSI::NetworkTransportStreamPtr, const u_char *data, size_t len); }; #endif diff --git a/p2pvr/dvb/siParsers/programAssociation.h b/p2pvr/dvb/siParsers/programAssociation.h index 653be0c..3ef44f0 100644 --- a/p2pvr/dvb/siParsers/programAssociation.h +++ b/p2pvr/dvb/siParsers/programAssociation.h @@ -3,6 +3,7 @@ #include "table.h" #include <dvbsi.h> +#include <visibility.h> struct ProgramAssociationSection { SiTableHeader header; @@ -12,7 +13,7 @@ struct ProgramAssociationSection { typedef std::map<uint16_t, uint16_t> ProgramAssociationMap; typedef boost::shared_ptr<ProgramAssociationMap> ProgramAssociationMapPtr; -class SiProgramAssociationParser : public SiTableParser<ProgramAssociationSection, ProgramAssociationMapPtr, int> { +class DLL_PUBLIC SiProgramAssociationParser : public SiTableParser<ProgramAssociationSection, ProgramAssociationMapPtr, int> { protected: bool CheckTableId(u_char tableId) const; void ParseSiTable(const struct ProgramAssociationSection * pas, ProgramAssociationMapPtr); diff --git a/p2pvr/dvb/siParsers/programMap.h b/p2pvr/dvb/siParsers/programMap.h index 07821b5..14f0c8d 100644 --- a/p2pvr/dvb/siParsers/programMap.h +++ b/p2pvr/dvb/siParsers/programMap.h @@ -3,6 +3,7 @@ #include "table.h" #include <dvbsi.h> +#include <visibility.h> struct ProgramMap { SiTableHeader header; @@ -25,7 +26,7 @@ struct ProgramMap { u_char data[]; } __attribute__((packed)); -class SiProgramMapParser : public SiTableParser<ProgramMap, DVBSI::ProgramMapPtr, u_char> { +class DLL_PUBLIC SiProgramMapParser : public SiTableParser<ProgramMap, DVBSI::ProgramMapPtr, u_char> { protected: bool CheckTableId(u_char tableId) const; void ParseSiTable(const struct ProgramMap * nit, DVBSI::ProgramMapPtr); diff --git a/p2pvr/dvb/siParsers/service.h b/p2pvr/dvb/siParsers/service.h index 611eb90..64ec351 100644 --- a/p2pvr/dvb/siParsers/service.h +++ b/p2pvr/dvb/siParsers/service.h @@ -3,6 +3,7 @@ #include "table.h" #include <dvbsi.h> +#include <visibility.h> struct TransportStreamDescriptor { SiTableHeader header; @@ -11,14 +12,14 @@ struct TransportStreamDescriptor { u_char data[]; } __attribute__((packed)); -class SiServicesParser : public SiTableParser<TransportStreamDescriptor, DVBSI::TransportStreamPtr, int> { +class DLL_PUBLIC SiServicesParser : public SiTableParser<TransportStreamDescriptor, DVBSI::TransportStreamPtr, int> { protected: bool CheckTableId(u_char tableId) const; void ParseSiTable(const struct TransportStreamDescriptor * nit, DVBSI::TransportStreamPtr); private: - static void parseDescriptor_Service(DVBSI::ServicePtr, const u_char *data, size_t len); - static void parseDescriptor_DefaultAuthority(DVBSI::ServicePtr, const u_char *data, size_t len); + DLL_PRIVATE static void parseDescriptor_Service(DVBSI::ServicePtr, const u_char *data, size_t len); + DLL_PRIVATE static void parseDescriptor_DefaultAuthority(DVBSI::ServicePtr, const u_char *data, size_t len); }; #endif diff --git a/p2pvr/dvb/siParsers/table.h b/p2pvr/dvb/siParsers/table.h index c470159..6333a2a 100644 --- a/p2pvr/dvb/siParsers/table.h +++ b/p2pvr/dvb/siParsers/table.h @@ -10,6 +10,7 @@ #include <dvb.h> #include <logger.h> #include <mutex> +#include <visibility.h> typedef unsigned char u_char; @@ -19,9 +20,10 @@ typedef unsigned char u_char; #define HILO4(x) (x##4 << 24 | x##2 << 16 | x##3 << 8 | x##4) #define BcdCharToInt(x) (10*((x & 0xF0)>>4) + (x & 0xF)) -class SiTableParserBase : public P2PVR::RawDataClient { +class DLL_PUBLIC SiTableParserBase : public P2PVR::RawDataClient { public: const P2PVR::Data & CurrentRawData() const; + protected: SiTableParserBase(); virtual ~SiTableParserBase() = 0; @@ -35,11 +37,12 @@ class SiTableParserBase : public P2PVR::RawDataClient { static const std::string ISO10646; static const std::string EitEncoding; static const std::string UTF8; - protected: + virtual bool ParseInfoTable(const u_char * data, size_t len) = 0; time_t startTime; unsigned int incomplete; std::mutex lock; + private: const P2PVR::Data * currentRawData; }; diff --git a/p2pvr/ice/Jamfile.jam b/p2pvr/ice/Jamfile.jam index ca27324..98d6018 100644 --- a/p2pvr/ice/Jamfile.jam +++ b/p2pvr/ice/Jamfile.jam @@ -12,6 +12,7 @@ lib p2pvrice : <library>..//adhocutil <library>..//p2ice <library>slicer + <cflags>-fvisibility=hidden <slicer>yes : : <include>. diff --git a/p2pvr/ice/commonHelpers.h b/p2pvr/ice/commonHelpers.h index 3f7e57d..67e861c 100644 --- a/p2pvr/ice/commonHelpers.h +++ b/p2pvr/ice/commonHelpers.h @@ -5,6 +5,7 @@ #include <ostream> #include <iomanip> #include <boost/date_time/posix_time/posix_time_types.hpp> +#include <visibility.h> namespace Common { template<typename C, typename T> @@ -30,13 +31,13 @@ namespace Common { return o; } - boost::posix_time::ptime operator*(const Common::DateTime &); - boost::posix_time::time_duration operator*(const Common::Duration &); + DLL_PUBLIC boost::posix_time::ptime operator*(const Common::DateTime &); + DLL_PUBLIC boost::posix_time::time_duration operator*(const Common::Duration &); } namespace boost { namespace posix_time { - Common::DateTime operator*(const boost::posix_time::ptime &); - Common::Duration operator*(const boost::posix_time::time_duration &); + DLL_PUBLIC Common::DateTime operator*(const boost::posix_time::ptime &); + DLL_PUBLIC Common::Duration operator*(const boost::posix_time::time_duration &); } } diff --git a/p2pvr/ice/converters.cpp b/p2pvr/ice/converters.cpp index 2a6b3c2..2b5f653 100644 --- a/p2pvr/ice/converters.cpp +++ b/p2pvr/ice/converters.cpp @@ -5,53 +5,53 @@ template<> VariableType -IceConvert<Common::DateTime>::ToVariable(const Common::DateTime & dt) +DLL_PUBLIC IceConvert<Common::DateTime>::ToVariable(const Common::DateTime & dt) { return *dt; } template<> VariableType -IceConvert<Common::Duration>::ToVariable(const Common::Duration & d) +DLL_PUBLIC IceConvert<Common::Duration>::ToVariable(const Common::Duration & d) { return *d; } template<> Common::DateTime -IceConvert<Common::DateTime>::FromVariable(const VariableType & dt) +DLL_PUBLIC IceConvert<Common::DateTime>::FromVariable(const VariableType & dt) { return *dt.as<boost::posix_time::ptime>(); } template<> Common::Duration -IceConvert<Common::Duration>::FromVariable(const VariableType & d) +DLL_PUBLIC IceConvert<Common::Duration>::FromVariable(const VariableType & d) { return *d.as<boost::posix_time::time_duration>(); } - + namespace Slicer { Common::DateTime - ptimeToDateTime(boost::posix_time::ptime const & p) + DLL_PUBLIC ptimeToDateTime(boost::posix_time::ptime const & p) { return *p; } boost::posix_time::ptime - dateTimeToPTime(Common::DateTime const & c) + DLL_PUBLIC dateTimeToPTime(Common::DateTime const & c) { return *c; } Common::Duration - timedurationToDuration(const boost::posix_time::time_duration & td) + DLL_PUBLIC timedurationToDuration(const boost::posix_time::time_duration & td) { return *td; } boost::posix_time::time_duration - durationToTimeDuration(const Common::Duration & td) + DLL_PUBLIC durationToTimeDuration(const Common::Duration & td) { return *td; } diff --git a/p2pvr/ice/p2pvr.ice b/p2pvr/ice/p2pvr.ice index 8f746d1..0c9cce3 100644 --- a/p2pvr/ice/p2pvr.ice +++ b/p2pvr/ice/p2pvr.ice @@ -8,6 +8,7 @@ module P2PVR { ["project2:type"] class Event extends DVBSI::Event { + ["slicer:db:auto","slicer:db:pkey"] int EventUid; bool Current = true; }; @@ -19,6 +20,7 @@ module P2PVR { // Something that we have recorded. ["project2:type"] class Recording { + ["slicer:db:auto","slicer:db:pkey"] int RecordingId; string StorageAddress; string Guid; @@ -30,6 +32,7 @@ module P2PVR { // Something that defines what we would like to record. ["project2:type"] class Schedule { + ["slicer:db:auto","slicer:db:pkey"] int ScheduleId = 0; optional(1) int ServiceId; optional(2) int EventUid; @@ -96,7 +99,8 @@ module P2PVR { idempotent ScheduleList GetSchedules(); ["project2:rows"] idempotent ScheduledToRecordList GetScheduledToRecord(); - idempotent int UpdateSchedule(Schedule newSchedule); + idempotent int NewSchedule(Schedule newSchedule); + idempotent void UpdateSchedule(Schedule newSchedule); ["project2:task"] idempotent void DoReschedule(); }; diff --git a/p2pvr/lib/Jamfile.jam b/p2pvr/lib/Jamfile.jam index 31974b7..1cb0033 100644 --- a/p2pvr/lib/Jamfile.jam +++ b/p2pvr/lib/Jamfile.jam @@ -22,6 +22,8 @@ lib p2pvrlib : <library>..//adhocutil <implicit-dependency>../ice//p2pvrice <library>slicer + <cflags>-fvisibility=hidden + <variant>release:<cflags>-flto : : <library>boost_filesystem <implicit-dependency>../ice//p2pvrice diff --git a/p2pvr/lib/bindTimerTask.h b/p2pvr/lib/bindTimerTask.h index 8c82680..f420ee0 100644 --- a/p2pvr/lib/bindTimerTask.h +++ b/p2pvr/lib/bindTimerTask.h @@ -3,8 +3,9 @@ #include <boost/function.hpp> #include <IceUtil/Timer.h> +#include <visibility.h> -class BindTimerTask : public IceUtil::TimerTask { +class DLL_PUBLIC BindTimerTask : public IceUtil::TimerTask { public: typedef boost::function<void()> Event; BindTimerTask(const Event & event); diff --git a/p2pvr/lib/fileHandle.h b/p2pvr/lib/fileHandle.h index 3c8d45e..0a3b7fc 100644 --- a/p2pvr/lib/fileHandle.h +++ b/p2pvr/lib/fileHandle.h @@ -1,7 +1,9 @@ #ifndef FILEHANDLE_H #define FILEHANDLE_H -class FileHandle { +#include <visibility.h> + +class DLL_PUBLIC FileHandle { public: FileHandle(int fd); ~FileHandle(); diff --git a/p2pvr/lib/muxer.h b/p2pvr/lib/muxer.h index cf0db1c..f0563a4 100644 --- a/p2pvr/lib/muxer.h +++ b/p2pvr/lib/muxer.h @@ -5,8 +5,9 @@ #include <mutex> #include <boost/shared_ptr.hpp> #include <processPipes.h> +#include <visibility.h> -class Muxer : public P2PVR::RawDataClient { +class DLL_PUBLIC Muxer : public P2PVR::RawDataClient { public: Muxer(const P2PVR::RawDataClientPrx & target, const std::string & cmd); ~Muxer(); @@ -14,9 +15,9 @@ class Muxer : public P2PVR::RawDataClient { bool NewData(const P2PVR::Data &, const Ice::Current &); private: - bool ReadWaiting() const; - bool ReadAvailable() const; - bool ReadMuxerAndSend(int wait) const; + DLL_PRIVATE bool ReadWaiting() const; + DLL_PRIVATE bool ReadAvailable() const; + DLL_PRIVATE bool ReadMuxerAndSend(int wait) const; const P2PVR::RawDataClientPrx target; typedef boost::shared_ptr<AdHoc::System::ProcessPipes> ProcessPipesPtr; ProcessPipesPtr fds; diff --git a/p2pvr/lib/p2Helpers.h b/p2pvr/lib/p2Helpers.h index 3b73f1b..d94d161 100644 --- a/p2pvr/lib/p2Helpers.h +++ b/p2pvr/lib/p2Helpers.h @@ -3,8 +3,10 @@ #include <variableType.h> #include <common.h> +#include <visibility.h> template <typename T> +DLL_PUBLIC const VariableType & operator>>(const VariableType & vt, T & v) { @@ -13,14 +15,17 @@ operator>>(const VariableType & vt, T & v) } template <> +DLL_PUBLIC const VariableType & operator>><Common::Duration>(const VariableType & vt, Common::Duration & d); template <> +DLL_PUBLIC const VariableType & operator>><Common::DateTime>(const VariableType & vt, Common::DateTime & dt); template <typename T> +DLL_PUBLIC const VariableType & operator>>(const VariableType & vt, IceUtil::Optional<T> & v) { @@ -35,10 +40,12 @@ operator>>(const VariableType & vt, IceUtil::Optional<T> & v) } template <> +DLL_PUBLIC const VariableType & operator>>(const VariableType & vt, short int & v); template <typename T> +DLL_PUBLIC VariableType & operator<<(VariableType & vt, const T & v) { @@ -47,14 +54,17 @@ operator<<(VariableType & vt, const T & v) } template <> +DLL_PUBLIC VariableType & operator<<<Common::Duration>(VariableType & vt, const Common::Duration & d); template <> +DLL_PUBLIC VariableType & operator<<<Common::DateTime>(VariableType & vt, const Common::DateTime & dt); template <typename T> +DLL_PUBLIC VariableType & operator<<(VariableType & vt, const IceUtil::Optional<T> & v) { diff --git a/p2pvr/lib/serviceStreamer.h b/p2pvr/lib/serviceStreamer.h index bff14ec..c4aa93e 100644 --- a/p2pvr/lib/serviceStreamer.h +++ b/p2pvr/lib/serviceStreamer.h @@ -2,8 +2,9 @@ #define SERVICESTREAMER_H #include "serviceStreamerCore.h" +#include <visibility.h> -class ServiceStreamer : public ServiceStreamerCore { +class DLL_PUBLIC ServiceStreamer : public ServiceStreamerCore { public: ServiceStreamer(int sid, P2PVR::RawDataClientPrx, const Ice::CommunicatorPtr & ic, const Ice::ObjectAdapterPtr & a); ServiceStreamer(int sid, P2PVR::RawDataClientPrx, const P2PVR::DevicesPrx & d, const P2PVR::SIPrx & s, const Ice::ObjectAdapterPtr & a); diff --git a/p2pvr/lib/serviceStreamerCore.h b/p2pvr/lib/serviceStreamerCore.h index 4af422a..1db80f8 100644 --- a/p2pvr/lib/serviceStreamerCore.h +++ b/p2pvr/lib/serviceStreamerCore.h @@ -8,8 +8,9 @@ #include "temporaryIceAdapterObject.h" #include <p2pvr.h> #include <set> +#include <visibility.h> -class ServiceStreamerCore { +class DLL_PUBLIC ServiceStreamerCore { public: ServiceStreamerCore(int sid, P2PVR::RawDataClientPrx, P2PVR::RawDataClientPrx, P2PVR::RawDataClientPrx, P2PVR::DevicesPrx, Ice::ObjectAdapterPtr); diff --git a/p2pvr/lib/temporaryIceAdapterObject.h b/p2pvr/lib/temporaryIceAdapterObject.h index d7fc77d..0614066 100644 --- a/p2pvr/lib/temporaryIceAdapterObject.h +++ b/p2pvr/lib/temporaryIceAdapterObject.h @@ -2,9 +2,10 @@ #define TEMPORARYICEADAPTER_H #include <Ice/ObjectAdapter.h> +#include <visibility.h> template <typename Object> -class TemporaryIceAdapterObject { +class DLL_PUBLIC TemporaryIceAdapterObject { public: TemporaryIceAdapterObject(Ice::ObjectAdapterPtr a, IceUtil::Handle<Object> o) : adapter(a), diff --git a/p2pvr/p2comp/Jamfile.jam b/p2pvr/p2comp/Jamfile.jam index 10b7fea..6540d77 100644 --- a/p2pvr/p2comp/Jamfile.jam +++ b/p2pvr/p2comp/Jamfile.jam @@ -1,11 +1,13 @@ lib p2pvrp2comp : [ glob-tree *.cpp ] - : : + : <library>../ice//p2pvrice <library>../lib//p2pvrlib <library>..//p2streams <library>..//p2ice <library>..//p2cgi <library>..//adhocutil + <cflags>-fvisibility=hidden + <variant>release:<cflags>-flto <implicit-dependency>../ice//p2pvrice ; |