summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSascha Volkenandt <sascha (at) akv-soft (dot) de>2007-01-04 15:02:00 +0000
committerSascha Volkenandt <sascha (at) akv-soft (dot) de>2007-01-04 15:02:00 +0000
commit64eaee28c243214e654c60b06a27212e8dcb5c02 (patch)
tree21b264c07166720513b65638feeb8fc3344530ec
parent4bfb50c7a53074fa7e4673ffdd16502c1bf72fcb (diff)
downloadvdr-plugin-live-64eaee28c243214e654c60b06a27212e8dcb5c02.tar.gz
vdr-plugin-live-64eaee28c243214e654c60b06a27212e8dcb5c02.tar.bz2
- optimized interface to access plugin objects from website
- moved website code to pagelib subdirectory - introduced TimerManager that will help working on timers from a background thread
-rw-r--r--Makefile16
-rw-r--r--live.cpp9
-rw-r--r--live.h9
-rw-r--r--pagelib/Makefile33
-rw-r--r--pagelib/sortedtimers.cpp28
-rw-r--r--pagelib/sortedtimers.h26
-rw-r--r--pagelib/tools.cpp (renamed from tools.cpp)0
-rw-r--r--pagelib/tools.h (renamed from tools.h)2
-rw-r--r--pages/Makefile3
-rw-r--r--pages/channels.ecpp1
-rw-r--r--pages/timers.ecpp2
-rw-r--r--setup.h3
-rw-r--r--timers.cpp11
-rw-r--r--timers.h24
14 files changed, 132 insertions, 35 deletions
diff --git a/Makefile b/Makefile
index 97b4b87..7bfe495 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
#
# Makefile for a Video Disk Recorder plugin
#
-# $Id: Makefile,v 1.20 2007/01/03 23:06:10 lordjaxom Exp $
+# $Id: Makefile,v 1.21 2007/01/04 15:02:00 lordjaxom Exp $
# The official name of this plugin.
# This name will be used in the '-P...' option of VDR to load the plugin.
@@ -54,16 +54,14 @@ export DEFINES
LIBS += httpd/libhttpd.a
-SUBDIRS = httpd pages css images
+SUBDIRS = httpd pages css images pagelib
### The object files (add further files here):
-PLUGINOBJS = $(PLUGIN).o thread.o tntconfig.o setup.o i18n.o
+PLUGINOBJS = $(PLUGIN).o thread.o tntconfig.o setup.o i18n.o timers.o
+
+WEBLIBS = pages/libpages.a css/libcss.a images/libimages.a pagelib/libpagelib.a
-WEBOBJS = tools.o timers.o
-WEBLIBS = pages/libpages.a \
- css/libcss.a \
- images/libimages.a
### Default rules:
@@ -96,7 +94,7 @@ libvdr-$(PLUGIN).so: $(PLUGINOBJS) $(LIBS)
$(CXX) $(LDFLAGS) -shared -o $@ $^ $(LIBS)
@cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
-libtnt-$(PLUGIN).so: $(WEBOBJS) $(WEBLIBS)
+libtnt-$(PLUGIN).so: $(WEBLIBS)
$(CXX) $(LDFLAGS) -Wl,--whole-archive -shared -o $@ $^
@cp --remove-destination $@ $(LIBDIR)/$@
@@ -109,7 +107,7 @@ dist: clean
@echo Distribution package created as $(PACKAGE).tgz
clean:
- @-rm -f $(PLUGINOBJS) $(WEBOBJS) $(DEPFILE) *.so *.tgz core* *~
+ @-rm -f $(PLUGINOBJS) $(DEPFILE) *.so *.tgz core* *~
@for dir in $(SUBDIRS); do \
make -C $$dir clean ; \
done
diff --git a/live.cpp b/live.cpp
index 0000186..88f4718 100644
--- a/live.cpp
+++ b/live.cpp
@@ -3,7 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
- * $Id: live.cpp,v 1.5 2007/01/03 21:43:21 lordjaxom Exp $
+ * $Id: live.cpp,v 1.6 2007/01/04 15:02:00 lordjaxom Exp $
*/
#include <vdr/plugin.h>
@@ -11,6 +11,7 @@
#include "live.h"
#include "setup.h"
#include "thread.h"
+#include "timers.h"
namespace vdrlive {
@@ -71,6 +72,12 @@ Setup& Plugin::GetLiveSetup()
return instance;
}
+TimerManager& Plugin::GetLiveTimerManager()
+{
+ static TimerManager instance;
+ return instance;
+}
+
} // namespace vdrlive
VDRPLUGINCREATOR(vdrlive::Plugin); // Don't touch this!
diff --git a/live.h b/live.h
index f5d9e18..ac1188b 100644
--- a/live.h
+++ b/live.h
@@ -8,13 +8,21 @@
namespace vdrlive {
class Setup;
+class TimerManager;
class PluginBase : public cPlugin
{
public:
virtual Setup& GetLiveSetup() = 0;
+ virtual TimerManager& GetLiveTimerManager() = 0;
};
+inline PluginBase& LivePlugin()
+{
+ static PluginBase& plugin = *static_cast< PluginBase* >( cPluginManager::GetPlugin( PLUGIN_NAME_I18N ) );
+ return plugin;
+}
+
class Plugin : public PluginBase {
public:
Plugin(void);
@@ -30,6 +38,7 @@ public:
virtual bool SetupParse(const char *Name, const char *Value);
virtual Setup& GetLiveSetup();
+ virtual TimerManager& GetLiveTimerManager();
private:
static const char *VERSION;
diff --git a/pagelib/Makefile b/pagelib/Makefile
new file mode 100644
index 0000000..6c91953
--- /dev/null
+++ b/pagelib/Makefile
@@ -0,0 +1,33 @@
+CXX ?= g++
+AR ?= ar
+
+CXXFLAGS ?= -O2 -Woverloaded-virtual -Wall -fPIC
+
+INCLUDES += -I.. -I$(VDRDIR)/include
+
+### The directory environment:
+
+VDRDIR ?= ../../../..
+
+### The object files (add further files here):
+
+OBJS = sortedtimers.o tools.o
+
+### Default rules:
+
+.PHONY: all clean
+
+all: libpagelib.a
+
+### Implicit rules:
+
+%.o: %.cpp
+ $(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $<
+
+### Targets:
+
+libpagelib.a: $(OBJS)
+ $(AR) r $@ $^
+
+clean:
+ @rm -f *~ *.o core* libpagelib.a
diff --git a/pagelib/sortedtimers.cpp b/pagelib/sortedtimers.cpp
new file mode 100644
index 0000000..547c482
--- /dev/null
+++ b/pagelib/sortedtimers.cpp
@@ -0,0 +1,28 @@
+#include "sortedtimers.h"
+
+static bool operator<( cTimer const& left, cTimer const& right )
+{
+ return left.Compare( right ) < 0;
+}
+
+/*
+static bool operator==( cTimer const& left, cTimer const& right )
+{
+ return left.Channel() == right.Channel() &&
+ (left.WeekDays() && left.WeekDays() == right.WeekDays() || !left.WeekDays() && left.Day() == right.Day()) &&
+ left.Start() == right.Start() &&
+ left.Stop() == right.Stop();
+}
+*/
+
+namespace vdrlive {
+
+SortedTimers::SortedTimers()
+{
+ for ( cTimer* timer = Timers.First(); timer != 0; timer = Timers.Next( timer ) ) {
+ m_timers.push_back( *timer );
+ }
+ m_timers.sort();
+}
+
+} // namespace vdrlive
diff --git a/pagelib/sortedtimers.h b/pagelib/sortedtimers.h
new file mode 100644
index 0000000..ffe9150
--- /dev/null
+++ b/pagelib/sortedtimers.h
@@ -0,0 +1,26 @@
+#ifndef VDR_LIVE_SORTEDTIMERS_H
+#define VDR_LIVE_SORTEDTIMERS_H
+
+#include <list>
+#include <vdr/timers.h>
+
+namespace vdrlive {
+
+class SortedTimers
+{
+public:
+ typedef std::list< cTimer > List;
+ typedef List::iterator iterator;
+
+ SortedTimers();
+
+ iterator begin() { return m_timers.begin(); }
+ iterator end() { return m_timers.end(); }
+
+private:
+ List m_timers;
+};
+
+} // namespace vdrlive
+
+#endif // VDR_LIVE_SORTEDTIMERS_H
diff --git a/tools.cpp b/pagelib/tools.cpp
index aeaba36..aeaba36 100644
--- a/tools.cpp
+++ b/pagelib/tools.cpp
diff --git a/tools.h b/pagelib/tools.h
index 18f968d..f9eb33a 100644
--- a/tools.h
+++ b/pagelib/tools.h
@@ -19,6 +19,8 @@ public:
bool operator!() { return !m_locked; }
private:
+ ReadLock( ReadLock const& );
+
cRwLock& m_lock;
bool m_locked;
};
diff --git a/pages/Makefile b/pages/Makefile
index 8ab9c87..1e91fb6 100644
--- a/pages/Makefile
+++ b/pages/Makefile
@@ -7,9 +7,10 @@ CXXFLAGS ?= -O2 -Woverloaded-virtual -Wall -fPIC
CXXFLAGS += `tntnet-config --cxxflags`
LDFLAGS += `tntnet-config --libs`
-INCLUDES += -I.. -I$(VDRDIR)/include
+INCLUDES += -I.. -I../pagelib -I$(VDRDIR)/include
### The directory environment:
+
VDRDIR ?= ../../../..
### The object files (add further files here):
diff --git a/pages/channels.ecpp b/pages/channels.ecpp
index 02fb4a3..0dedcb9 100644
--- a/pages/channels.ecpp
+++ b/pages/channels.ecpp
@@ -1,5 +1,4 @@
<%pre>
-#include <boost/lexical_cast.hpp>
#include <vdr/plugin.h>
#include <vdr/channels.h>
#include "setup.h"
diff --git a/pages/timers.ecpp b/pages/timers.ecpp
index 898a854..f77f8c9 100644
--- a/pages/timers.ecpp
+++ b/pages/timers.ecpp
@@ -3,7 +3,7 @@
#include <vdr/timers.h>
#include <vdr/config.h>
#include <vdr/i18n.h>
-#include "timers.h"
+#include "sortedtimers.h"
#include "tools.h"
using namespace vdrlive;
diff --git a/setup.h b/setup.h
index e7740a7..dba4008 100644
--- a/setup.h
+++ b/setup.h
@@ -48,8 +48,7 @@ private:
inline Setup& LiveSetup()
{
- static PluginBase& plugin = *static_cast< Plugin* >( cPluginManager::GetPlugin( PLUGIN_NAME_I18N ) );
- return plugin.GetLiveSetup();
+ return LivePlugin().GetLiveSetup();
}
} // namespace vdrlive
diff --git a/timers.cpp b/timers.cpp
index ed986be..ea3d6d1 100644
--- a/timers.cpp
+++ b/timers.cpp
@@ -1,18 +1,9 @@
#include "timers.h"
-static bool operator<( cTimer const& left, cTimer const& right )
-{
- return left.Compare( right ) < 0;
-}
-
namespace vdrlive {
-SortedTimers::SortedTimers()
+TimerManager::TimerManager()
{
- for ( cTimer* timer = Timers.First(); timer != 0; timer = Timers.Next( timer ) ) {
- m_timers.push_back( *timer );
- }
- m_timers.sort();
}
} // namespace vdrlive
diff --git a/timers.h b/timers.h
index 2ab1ee2..b6c53b8 100644
--- a/timers.h
+++ b/timers.h
@@ -3,24 +3,28 @@
#include <list>
#include <vdr/timers.h>
+#include "live.h"
namespace vdrlive {
-class SortedTimers
+class Plugin;
+
+class TimerManager
{
-public:
- typedef std::list< cTimer > List;
- typedef List::iterator iterator;
-
- SortedTimers();
+ friend TimerManager& Plugin::GetLiveTimerManager();
- iterator begin() { return m_timers.begin(); }
- iterator end() { return m_timers.end(); }
-
private:
- List m_timers;
+ TimerManager();
+ TimerManager( TimerManager const& );
+
+
};
+inline TimerManager& LiveTimerManager()
+{
+ return LivePlugin().GetLiveTimerManager();
+}
+
} // namespace vdrlive
#endif // VDR_LIVE_TIMERS_H