summaryrefslogtreecommitdiff
path: root/p2pvr/daemon
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-06-14 03:20:20 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2015-06-14 03:20:20 +0100
commit1eaa6683947f4ebe74c29b4844b47efb352f9a3b (patch)
treea887a65f8699e7dbf46e8d50c25b575e50d498b2 /p2pvr/daemon
parentSwitch to using project2's own DB mocking framework (diff)
downloadp2pvr-1eaa6683947f4ebe74c29b4844b47efb352f9a3b.tar.bz2
p2pvr-1eaa6683947f4ebe74c29b4844b47efb352f9a3b.tar.xz
p2pvr-1eaa6683947f4ebe74c29b4844b47efb352f9a3b.zip
Compatibility with AppInstance and ExecContext changes
Diffstat (limited to 'p2pvr/daemon')
-rw-r--r--p2pvr/daemon/containerIterator.h2
-rw-r--r--p2pvr/daemon/maintenance/events.cpp16
-rw-r--r--p2pvr/daemon/maintenance/network.cpp11
-rw-r--r--p2pvr/daemon/maintenance/services.cpp5
-rw-r--r--p2pvr/daemon/privateExecContext.cpp14
-rw-r--r--p2pvr/daemon/privateExecContext.h13
-rw-r--r--p2pvr/daemon/schedules.cpp4
-rw-r--r--p2pvr/daemon/unittests/testErrorHandling.cpp3
-rw-r--r--p2pvr/daemon/unittests/testMaint.cpp3
-rw-r--r--p2pvr/daemon/unittests/testRecording.cpp4
-rw-r--r--p2pvr/daemon/unittests/testRecordings.cpp3
-rw-r--r--p2pvr/daemon/unittests/testSched.cpp3
-rw-r--r--p2pvr/daemon/unittests/testSi.cpp3
-rw-r--r--p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp3
-rw-r--r--p2pvr/daemon/unittests/testStorage.cpp3
-rw-r--r--p2pvr/daemon/unittests/testp2ice.cpp3
16 files changed, 70 insertions, 23 deletions
diff --git a/p2pvr/daemon/containerIterator.h b/p2pvr/daemon/containerIterator.h
index 14c339d..88976af 100644
--- a/p2pvr/daemon/containerIterator.h
+++ b/p2pvr/daemon/containerIterator.h
@@ -20,7 +20,7 @@ class ContainerIterator : public IHaveSubTasks {
ObjectRowStateTmpl<typename T::value_type> rs;
for (const auto & i : *container) {
binder(rs, i);
- rs.process(boost::bind(&ContainerIterator::executeChildren, this, ec));
+ rs.process(ec, boost::bind(&ContainerIterator::executeChildren, this, ec));
}
}
diff --git a/p2pvr/daemon/maintenance/events.cpp b/p2pvr/daemon/maintenance/events.cpp
index 9a22cd9..7029398 100644
--- a/p2pvr/daemon/maintenance/events.cpp
+++ b/p2pvr/daemon/maintenance/events.cpp
@@ -8,21 +8,25 @@
#include <temporaryIceAdapterObject.h>
#include <commonHelpers.h>
#include <resources.h>
+#include <privateExecContext.h>
ResourceString(Maint_pruneEvents, sql_Maint_pruneEvents);
class SiEventsHandler : public SiEpgParser {
public:
- SiEventsHandler(const RowProcessorCallback & cb, const SelectedColumns & sc) :
+ SiEventsHandler(const RowProcessorCallback & cb, ExecContext * e, const SelectedColumns & sc) :
ecs(sc),
- callBack(cb) {}
+ callBack(cb),
+ ec(e)
+ {
+ }
bool HandleTable(DVBSI::EventPtr e)
{
Logger()->messagebf(LOG_DEBUG, "Service Id: %d Program Id: %d Title: %s Time: %s - %s",
e->ServiceId, e->EventId, e->Title, e->StartTime, e->StopTime);
BindColumns<DVBSI::EventPtr>(rowState, ecs, e);
- rowState.process(callBack);
+ rowState.process(ec, callBack);
return false;
}
@@ -30,6 +34,7 @@ class SiEventsHandler : public SiEpgParser {
ObjectRowStateTmpl<DVBSI::EventPtr> rowState;
const SelectedColumns & ecs;
const RowProcessorCallback callBack;
+ ExecContext * ec;
};
class SiEventsMerger : public IHaveSubTasks {
@@ -51,7 +56,7 @@ class SiEventsMerger : public IHaveSubTasks {
}
TemporaryIceAdapterObject<P2PVR::RawDataClient> parser(ice.adapter,
- new SiEventsHandler(boost::bind(&SiEventsMerger::executeChildren, this, ec), ecs));
+ new SiEventsHandler(boost::bind(&SiEventsMerger::executeChildren, this, ec), ec, ecs));
auto delivery = si->GetDeliveryForSi();
if (!delivery) {
@@ -81,13 +86,14 @@ void
Maintenance::UpdateEvents(const Ice::Current & ice)
{
TxHelper tx(this);
+ PrivateExecContext ec;
SqlMergeTask mergeEvents("postgres", "events");
auto ecs = CreateColumns<DVBSI::EventPtr>(boost::bind(SqlMergeColumnsInserter, &mergeEvents, _1, _2));
mergeEvents.sources.insert(new SiEventsMerger(ice, ecs));
mergeEvents.insteadOfDelete = new DynamicSql::SqlText("SET current = false");
mergeEvents.updateWhere = new DynamicSql::SqlText("a.current");
mergeEvents.loadComplete(this);
- mergeEvents.execute(NULL);
+ mergeEvents.execute(&ec);
Modify(Maint_pruneEvents).second->execute();
tx.Commit();
Logger()->messagebf(LOG_INFO, "%s: Updated events", __PRETTY_FUNCTION__);
diff --git a/p2pvr/daemon/maintenance/network.cpp b/p2pvr/daemon/maintenance/network.cpp
index 0152a29..fdf2c8e 100644
--- a/p2pvr/daemon/maintenance/network.cpp
+++ b/p2pvr/daemon/maintenance/network.cpp
@@ -6,8 +6,9 @@
#include <p2Helpers.h>
#include <containerIterator.h>
#include <temporaryIceAdapterObject.h>
+#include <privateExecContext.h>
-class SiNetworkInformationMerger : public SiNetworkInformationParser {
+class SiNetworkInformationMerger : public SiNetworkInformationParser, public PrivateExecContext {
public:
SiNetworkInformationMerger(DatabaseClient * co) : commonObjects(co) { }
@@ -30,13 +31,13 @@ class SiNetworkInformationMerger : public SiNetworkInformationParser {
std::vector<DVBSI::NetworkPtr> networks = { n };
mergeNetwork.sources.insert(new ContainerIterator<std::vector<DVBSI::NetworkPtr>>(&networks, ncs));
mergeNetwork.loadComplete(commonObjects);
- mergeNetwork.execute(NULL);
+ mergeNetwork.execute(this);
SqlMergeTask mergeTransports("postgres", "transportstreams");
auto tscs = CreateColumns<DVBSI::NetworkTransportStreamPtr>(boost::bind(&DatabaseClient::SqlMergeColumnsInserter, &mergeTransports, _1, _2));
mergeTransports.sources.insert(new ContainerIterator<DVBSI::NetworkTransportStreams>(&n->TransportStreams, tscs));
mergeTransports.loadComplete(commonObjects);
- mergeTransports.execute(NULL);
+ mergeTransports.execute(this);
mergeDelivery<DVBSI::TerrestrialDeliveryPtr, &DVBSI::NetworkTransportStream::Terrestrial>("delivery_dvbt", n);
mergeDelivery<DVBSI::SatelliteDeliveryPtr, &DVBSI::NetworkTransportStream::Satellite>("delivery_dvbs", n);
@@ -48,7 +49,7 @@ class SiNetworkInformationMerger : public SiNetworkInformationParser {
mergeServices.sources.insert(new ContainerIterator<DVBSI::NetworkServiceList>(&s->Services, scs));
}
mergeServices.loadComplete(commonObjects);
- mergeServices.execute(NULL);
+ mergeServices.execute(this);
return false;
}
private:
@@ -65,7 +66,7 @@ class SiNetworkInformationMerger : public SiNetworkInformationParser {
}
merge.sources.insert(new ContainerIterator<decltype(dels)>(&dels, dcs));
merge.loadComplete(commonObjects);
- merge.execute(NULL);
+ merge.execute(this);
}
DatabaseClient * commonObjects;
};
diff --git a/p2pvr/daemon/maintenance/services.cpp b/p2pvr/daemon/maintenance/services.cpp
index 6619d42..e5edbc5 100644
--- a/p2pvr/daemon/maintenance/services.cpp
+++ b/p2pvr/daemon/maintenance/services.cpp
@@ -6,8 +6,9 @@
#include <p2Helpers.h>
#include <containerIterator.h>
#include <temporaryIceAdapterObject.h>
+#include <privateExecContext.h>
-class SiServicesMerger : public SiServicesParser {
+class SiServicesMerger : public SiServicesParser, public PrivateExecContext {
public:
SiServicesMerger(DatabaseClient * co) : commonObjects(co) { }
@@ -29,7 +30,7 @@ class SiServicesMerger : public SiServicesParser {
mergeServices.doInsert = VariableType(false);
mergeServices.sources.insert(new ContainerIterator<DVBSI::ServiceList>(&ts->Services, scs));
mergeServices.loadComplete(commonObjects);
- mergeServices.execute(NULL);
+ mergeServices.execute(this);
return false;
}
diff --git a/p2pvr/daemon/privateExecContext.cpp b/p2pvr/daemon/privateExecContext.cpp
new file mode 100644
index 0000000..47c5773
--- /dev/null
+++ b/p2pvr/daemon/privateExecContext.cpp
@@ -0,0 +1,14 @@
+#include "privateExecContext.h"
+
+VariableType
+PrivateExecContext::getParameter(const VariableType &) const
+{
+ throw NotSupported(__PRETTY_FUNCTION__);
+}
+
+SessionPtr
+PrivateExecContext::getSession() const
+{
+ throw NotSupported(__PRETTY_FUNCTION__);
+}
+
diff --git a/p2pvr/daemon/privateExecContext.h b/p2pvr/daemon/privateExecContext.h
new file mode 100644
index 0000000..1d336b0
--- /dev/null
+++ b/p2pvr/daemon/privateExecContext.h
@@ -0,0 +1,13 @@
+#ifndef PRIVATEEXECCONTENT_H
+#define PRIVATEEXECCONTENT_H
+
+#include <execContext.h>
+
+class PrivateExecContext : public ExecContext {
+ public:
+ VariableType getParameter(const VariableType & key) const;
+ SessionPtr getSession() const;
+};
+
+#endif
+
diff --git a/p2pvr/daemon/schedules.cpp b/p2pvr/daemon/schedules.cpp
index 674dd87..5e3881d 100644
--- a/p2pvr/daemon/schedules.cpp
+++ b/p2pvr/daemon/schedules.cpp
@@ -14,6 +14,7 @@
#include "sqlSelectDeserializer.h"
#include <slicer/slicer.h>
#include <p2pvr-int.h>
+#include <privateExecContext.h>
ResourceString(Schedules_getCandidates, sql_Schedules_getCandidates);
ResourceString(Schedules_insert, sql_Schedules_insert);
@@ -284,11 +285,12 @@ Schedules::DoReschedule(const Ice::Current & ice)
}
TxHelper tx(this);
+ PrivateExecContext ec;
SqlMergeTask mergeRecords("postgres", "record");
auto rcs = CreateColumns<P2PVR::ScheduledToRecordPtr>(boost::bind(&DatabaseClient::SqlMergeColumnsInserter, &mergeRecords, _1, _2));
mergeRecords.sources.insert(new ContainerIterator<P2PVR::ScheduledToRecordList>(&records, rcs));
mergeRecords.loadComplete(this);
- mergeRecords.execute(NULL);
+ mergeRecords.execute(&ec);
tx.Commit();
auto recorder = P2PVR::RecorderPrx::checkedCast(ice.adapter->createProxy(ice.adapter->getCommunicator()->stringToIdentity("Recorder")));
diff --git a/p2pvr/daemon/unittests/testErrorHandling.cpp b/p2pvr/daemon/unittests/testErrorHandling.cpp
index ca5bd63..9c720a2 100644
--- a/p2pvr/daemon/unittests/testErrorHandling.cpp
+++ b/p2pvr/daemon/unittests/testErrorHandling.cpp
@@ -16,8 +16,9 @@
#include <siParsers/network.h>
#include <temporaryIceAdapterObject.h>
#include "mockDefs.h"
+#include <testAppInstance.h>
-class Core {
+class Core : public TestAppInstance {
public:
Core()
{
diff --git a/p2pvr/daemon/unittests/testMaint.cpp b/p2pvr/daemon/unittests/testMaint.cpp
index f8340af..0d7d5a0 100644
--- a/p2pvr/daemon/unittests/testMaint.cpp
+++ b/p2pvr/daemon/unittests/testMaint.cpp
@@ -17,8 +17,9 @@
#include "sqlSelectDeserializer.h"
#include "commonHelpers.h"
#include <slicer/slicer.h>
+#include <testAppInstance.h>
-class Core : public CommonObjects {
+class Core : public CommonObjects, public TestAppInstance {
public:
Core()
{
diff --git a/p2pvr/daemon/unittests/testRecording.cpp b/p2pvr/daemon/unittests/testRecording.cpp
index 4e49916..720b868 100644
--- a/p2pvr/daemon/unittests/testRecording.cpp
+++ b/p2pvr/daemon/unittests/testRecording.cpp
@@ -19,9 +19,9 @@
#include "serviceStreamer.h"
#include "temporaryIceAdapterObject.h"
#include <slicer/slicer.h>
+#include <testAppInstance.h>
-
-class Core : public CommonObjects {
+class Core : public CommonObjects, public TestAppInstance {
public:
Core()
{
diff --git a/p2pvr/daemon/unittests/testRecordings.cpp b/p2pvr/daemon/unittests/testRecordings.cpp
index c0496d3..eb3d5db 100644
--- a/p2pvr/daemon/unittests/testRecordings.cpp
+++ b/p2pvr/daemon/unittests/testRecordings.cpp
@@ -15,8 +15,9 @@
#include <boost/uuid/uuid_io.hpp>
#include <boost/lexical_cast.hpp>
#include "mockDefs.h"
+#include <testAppInstance.h>
-class Core {
+class Core : public TestAppInstance {
public:
Core()
{
diff --git a/p2pvr/daemon/unittests/testSched.cpp b/p2pvr/daemon/unittests/testSched.cpp
index bfa8567..3a513d0 100644
--- a/p2pvr/daemon/unittests/testSched.cpp
+++ b/p2pvr/daemon/unittests/testSched.cpp
@@ -16,8 +16,9 @@
#include <boost/lexical_cast.hpp>
#include <commonHelpers.h>
#include "mockDefs.h"
+#include <testAppInstance.h>
-class Core {
+class Core : public TestAppInstance {
public:
Core()
{
diff --git a/p2pvr/daemon/unittests/testSi.cpp b/p2pvr/daemon/unittests/testSi.cpp
index c0f3fdf..6cc810b 100644
--- a/p2pvr/daemon/unittests/testSi.cpp
+++ b/p2pvr/daemon/unittests/testSi.cpp
@@ -13,8 +13,9 @@
#include <boost/uuid/uuid_io.hpp>
#include <boost/lexical_cast.hpp>
#include "mockDefs.h"
+#include <testAppInstance.h>
-class Core {
+class Core : public TestAppInstance {
public:
Core()
{
diff --git a/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp b/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp
index b109c04..2608fd8 100644
--- a/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp
+++ b/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp
@@ -11,10 +11,11 @@
#include <definedDirs.h>
#include <commonHelpers.h>
#include "mockDefs.h"
+#include <testAppInstance.h>
typedef boost::shared_ptr<DB::SelectCommand> SelectPtr;
-class TestCommonObjects : public CommonObjects {
+class TestCommonObjects : public CommonObjects, public TestAppInstance {
public:
TestCommonObjects()
{
diff --git a/p2pvr/daemon/unittests/testStorage.cpp b/p2pvr/daemon/unittests/testStorage.cpp
index 5480566..973e93b 100644
--- a/p2pvr/daemon/unittests/testStorage.cpp
+++ b/p2pvr/daemon/unittests/testStorage.cpp
@@ -10,9 +10,10 @@
#include <storage.h>
#include <boost/lexical_cast.hpp>
#include <commonHelpers.h>
+#include <testAppInstance.h>
const boost::filesystem::path rootDir = "/tmp/ut/p2pvr/recordings";
-class Core {
+class Core : public TestAppInstance {
public:
Core()
{
diff --git a/p2pvr/daemon/unittests/testp2ice.cpp b/p2pvr/daemon/unittests/testp2ice.cpp
index 23fcbdc..4d29cc9 100644
--- a/p2pvr/daemon/unittests/testp2ice.cpp
+++ b/p2pvr/daemon/unittests/testp2ice.cpp
@@ -4,6 +4,7 @@
#include <testOptionsSource.h>
#include <definedDirs.h>
#include <sourceObject.h>
+#include <testAppInstance.h>
const boost::filesystem::path variant = BinDir.leaf();
const boost::filesystem::path compiler = BinDir.parent_path().leaf();
@@ -29,6 +30,8 @@ unloadTests()
BOOST_WARN_THROW(ElementLoader::getFor("p2pvrservicestream"), NotSupported);
}
+BOOST_GLOBAL_FIXTURE( TestAppInstance );
+
BOOST_AUTO_TEST_CASE( compile_client_clientOnly )
{
TestOptionsSource::LoadTestOptions({ });