summaryrefslogtreecommitdiff
path: root/libskindesignerapi
diff options
context:
space:
mode:
authorlouis <louis.braun@gmx.de>2015-04-02 11:39:43 +0200
committerlouis <louis.braun@gmx.de>2015-04-02 11:39:43 +0200
commit7420a865ac1aa8b93b96ffd84bb8efb7b1dc64aa (patch)
tree7f9aa6b9698cd3e04f0e3de31b98e29438743681 /libskindesignerapi
parent70ce62e35312afb346db473a1c70178cbba68758 (diff)
downloadvdr-plugin-skindesigner-7420a865ac1aa8b93b96ffd84bb8efb7b1dc64aa.tar.gz
vdr-plugin-skindesigner-7420a865ac1aa8b93b96ffd84bb8efb7b1dc64aa.tar.bz2
first api implementation
Diffstat (limited to 'libskindesignerapi')
-rw-r--r--libskindesignerapi/Makefile94
-rw-r--r--libskindesignerapi/skindesignerapi.c31
-rw-r--r--libskindesignerapi/skindesignerapi.h38
3 files changed, 163 insertions, 0 deletions
diff --git a/libskindesignerapi/Makefile b/libskindesignerapi/Makefile
new file mode 100644
index 0000000..e52ef0f
--- /dev/null
+++ b/libskindesignerapi/Makefile
@@ -0,0 +1,94 @@
+# Makefile for libskindesigner
+
+NAME = skindesignerapi
+LIBNAME = lib$(NAME)
+MAJOR = 0
+MINOR = 0.1
+VERSION = $(MAJOR).$(MINOR)
+
+SONAME = $(LIBNAME).so.$(MAJOR)
+TARGET_LIB = $(SONAME).$(MINOR)
+
+PREFIX ?= /usr/local
+INCDIR ?= $(PREFIX)/include
+LIBDIR ?= $(PREFIX)/lib
+PCDIR ?= $(PREFIX)/lib/pkgconfig
+TMPDIR ?= /tmp
+
+### The name of the distribution archive:
+ARCHIVE = $(LIBNAME)-$(VERSION)
+
+CXXFLAGS = $(shell pkg-config --variable=cxxflags vdr)
+LDFLAGS = -shared -Wl,-soname,$(SONAME)
+
+DEFINES += -DAPIVERSION=$(MAJOR) -DLIBVERSION=\"$(VERSION)\"
+INCLUDES +=
+
+SRCS = $(wildcard *.c)
+OBJS = $(SRCS:.c=.o)
+
+.PHONY: all
+all: ${TARGET_LIB} ${LIBNAME}.pc
+
+%.o: %.c
+ $(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) -o $@ $<
+
+# Dependencies:
+
+MAKEDEP = $(CXX) -MM -MG
+DEPFILE = .dependencies
+$(DEPFILE): Makefile
+ @$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@
+
+-include $(DEPFILE)
+
+# The main lib
+
+$(TARGET_LIB): $(OBJS)
+ $(CXX) ${LDFLAGS} -o $@ $^
+
+# pkg-config
+
+.PHONY: $(LIBNAME).pc
+$(LIBNAME).pc:
+ @echo "includedir=$(INCDIR)" > $@
+ @echo "libdir=$(LIBDIR)" >> $@
+ @echo "" >> $@
+ @echo "Name: $(LIBNAME)" >> $@
+ @echo "Description: skindesigner API Library" >> $@
+ @echo "Version: $(VERSION)" >> $@
+ @echo "Cflags: -I$(INCDIR)" >> $@
+ @echo "Libs: -L$(LIBDIR) -l$(NAME)" >> $@
+
+# install targets
+
+install-lib: $(TARGET_LIB)
+ install -D $^ $(DESTDIR)$(LIBDIR)/$^
+ if [ -z "$(DESTDIR)" ] ; then ldconfig; fi
+ cd $(DESTDIR)$(LIBDIR) ; if [ ! -e $(LIBNAME).so ] ; then ln -s $(TARGET_LIB) $(LIBNAME).so; fi
+
+install-includes:
+ @mkdir -p $(DESTDIR)$(INCDIR)/$(LIBNAME)
+ @cp -pLR *.h $(DESTDIR)$(INCDIR)/$(LIBNAME)
+
+install-pc: $(LIBNAME).pc
+ if [ -n "$(PCDIR)" ] ; then\
+ mkdir -p $(DESTDIR)$(PCDIR) ;\
+ cp $(LIBNAME).pc $(DESTDIR)$(PCDIR) ;\
+ fi
+
+install: install-lib install-pc install-includes
+
+# clean & dist
+
+.PHONY: clean
+clean:
+ -rm -f ${TARGET_LIB} ${OBJS} $(DEPFILE) $(LIBNAME).pc $(LIBNAME).so $(ARCHIVE).tgz
+
+dist: clean
+ @-rm -rf $(TMPDIR)/$(ARCHIVE)
+ @mkdir $(TMPDIR)/$(ARCHIVE)
+ @cp -a * $(TMPDIR)/$(ARCHIVE)
+ @tar czf $(ARCHIVE).tgz --exclude .git* --exclude *.o --exclude *.rej --exclude *.orig -C $(TMPDIR) $(ARCHIVE)
+ @-rm -rf $(TMPDIR)/$(ARCHIVE)
+ @echo Distribution package created as $(ARCHIVE).tgz
diff --git a/libskindesignerapi/skindesignerapi.c b/libskindesignerapi/skindesignerapi.c
new file mode 100644
index 0000000..f2bd670
--- /dev/null
+++ b/libskindesignerapi/skindesignerapi.c
@@ -0,0 +1,31 @@
+#include "skindesignerapi.h"
+
+skindesignerapi::SkindesignerAPI* skindesignerapi::SkindesignerAPI::skindesigner = NULL;
+
+skindesignerapi::SkindesignerAPI::SkindesignerAPI(void)
+{
+ if (skindesigner != NULL)
+ esyslog("skindesigner should only be loaded once");
+ else
+ skindesigner = this;
+}
+
+skindesignerapi::SkindesignerAPI::~SkindesignerAPI(void)
+{
+ if (skindesigner == this)
+ skindesigner = NULL;
+}
+
+bool skindesignerapi::SkindesignerAPI::CallRegisterPlugin(string name, map< int, string > menus)
+{
+ if (skindesigner)
+ return skindesigner->OnRegisterPlugin(name, menus);
+ return false;
+}
+
+skindesignerapi::ISDDisplayMenu* skindesignerapi::SkindesignerAPI::CallGetDisplayMenu()
+{
+ if (skindesigner)
+ return skindesigner->OnGetDisplayMenu();
+ return NULL;
+}
diff --git a/libskindesignerapi/skindesignerapi.h b/libskindesignerapi/skindesignerapi.h
new file mode 100644
index 0000000..2cbf55b
--- /dev/null
+++ b/libskindesignerapi/skindesignerapi.h
@@ -0,0 +1,38 @@
+#ifndef __LIBSKINDESIGNERAPI_SERVICES_H
+#define __LIBSKINDESIGNERAPI_SERVICES_H
+
+using namespace std;
+
+#include <string>
+#include <map>
+#include <vector>
+#include <vdr/osdbase.h>
+
+namespace skindesignerapi {
+
+class ISDDisplayMenu : public cSkinDisplayMenu {
+public:
+ virtual void SetPluginMenu(string name, int menu, int type, bool init) = 0;
+ virtual bool SetItemPlugin(map<string,string> *stringTokens, map<string,int> *intTokens, map<string,vector<map<string,string> > > *loopTokens, int Index, bool Current, bool Selectable) = 0;
+ virtual bool SetPluginText(map<string,string> *stringTokens, map<string,int> *intTokens, map<string,vector<map<string,string> > > *loopTokens) = 0;
+};
+
+class SkindesignerAPI {
+private:
+ static SkindesignerAPI* skindesigner;
+
+protected:
+ SkindesignerAPI(void);
+ virtual ~SkindesignerAPI(void);
+
+ virtual bool OnRegisterPlugin(string name, map< int, string > menus) = 0;
+ virtual ISDDisplayMenu* OnGetDisplayMenu() = 0;
+
+public:
+ static bool CallRegisterPlugin(string name, map< int, string > menus);
+ static ISDDisplayMenu* CallGetDisplayMenu();
+};
+
+}
+
+#endif //__LIBSKINDESIGNERAPI_SERVICES_H