introduced libskindesignerapi

This commit is contained in:
louis 2015-04-02 15:09:41 +02:00
parent 9d3d613013
commit e48aa00164
13 changed files with 736 additions and 165 deletions

2
.gitignore vendored
View File

@ -6,3 +6,5 @@
*.mo
*.pot
*.tgz
*.pc
libskindesignerapi.so*

View File

@ -259,8 +259,10 @@ Version 0.3.3
- added parameter mode to viewelement <devices>. if mode="light"
no signal information will be fetched to improve performance.
Version 0.3.4
Version 0.3.4
- fixed backward compatibility to VDR version < 2.1.1 where
cRecording::IsInUse() was introduced
- automatically detect type of image if no file extension is available
- introduced libskindesignerapi

View File

@ -1,6 +1,6 @@
#ifndef __DISPLAYMENU_H
#define __DISPLAYMENU_H
#include <libskindesignerapi/skindesignerapi.h>
#include "libtemplate/template.h"
#include "views/displaymenurootview.h"
@ -12,7 +12,7 @@ enum eViewState {
vsIdle
};
class cSDDisplayMenu : public cSkinDisplayMenu {
class cSDDisplayMenu : public skindesignerapi::ISDDisplayMenu {
private:
cDisplayMenuRootView *rootView;
eViewState state;

View File

@ -1,10 +1,11 @@
#ifndef __DISPLAYPLUGIN_H
#define __DISPLAYPLUGIN_H
#include <libskindesignerapi/skindesignerapi.h>
#include "libtemplate/template.h"
#include "views/displaypluginview.h"
class cSkinDisplayPlugin {
class cSkinDisplayPlugin : public skindesignerapi::ISkinDisplayPlugin {
private:
bool doOutput;
bool initial;

View File

@ -1,4 +1,4 @@
# Makefile for libskindesigner
# Makefile for libskindesignerapi
NAME = skindesignerapi
LIBNAME = lib$(NAME)

View File

@ -0,0 +1,203 @@
#include "osdelements.h"
/**********************************************************************
* cOsdElement
**********************************************************************/
skindesignerapi::cOsdElement::cOsdElement(skindesignerapi::ISkinDisplayPlugin *view) {
this->view = view;
}
skindesignerapi::cOsdElement::~cOsdElement() {
}
void skindesignerapi::cOsdElement::ClearTokens(void) {
stringTokens.clear();
intTokens.clear();
loopTokens.clear();
}
void skindesignerapi::cOsdElement::AddStringToken(string key, string value) {
stringTokens.insert(pair<string,string>(key, value));
}
void skindesignerapi::cOsdElement::AddIntToken(string key, int value) {
intTokens.insert(pair<string,int>(key, value));
}
void skindesignerapi::cOsdElement::AddLoopToken(string loopName, map<string, string> &tokens) {
map<string, vector<map<string, string> > >::iterator hitLoop = loopTokens.find(loopName);
if (hitLoop == loopTokens.end()) {
vector<map<string, string> > tokenVector;
tokenVector.push_back(tokens);
loopTokens.insert(pair<string, vector<map<string, string> > >(loopName, tokenVector));
} else {
vector<map<string, string> > *tokenVector = &hitLoop->second;
tokenVector->push_back(tokens);
}
}
bool skindesignerapi::cOsdElement::ChannelLogoExists(string channelId) {
return view->ChannelLogoExists(channelId);
}
string skindesignerapi::cOsdElement::GetEpgImagePath(void) {
return view->GetEpgImagePath();
}
/**********************************************************************
* cViewElement
**********************************************************************/
skindesignerapi::cViewElement::cViewElement(skindesignerapi::ISkinDisplayPlugin *view, int viewElementID) : cOsdElement(view) {
this->viewElementID = viewElementID;
}
skindesignerapi::cViewElement::~cViewElement() {
}
void skindesignerapi::cViewElement::Clear(void) {
if (!view)
return;
view->ClearViewElement(viewElementID);
}
void skindesignerapi::cViewElement::Display(void) {
if (!view)
return;
view->SetViewElementIntTokens(&intTokens);
view->SetViewElementStringTokens(&stringTokens);
view->SetViewElementLoopTokens(&loopTokens);
view->DisplayViewElement(viewElementID);
}
/**********************************************************************
* cViewGrid
**********************************************************************/
skindesignerapi::cViewGrid::cViewGrid(skindesignerapi::ISkinDisplayPlugin *view, int viewGridID) : cOsdElement(view) {
this->viewGridID = viewGridID;
}
skindesignerapi::cViewGrid::~cViewGrid() {
}
void skindesignerapi::cViewGrid::SetGrid(long gridID, double x, double y, double width, double height) {
if (!view)
return;
view->SetGrid(viewGridID, gridID, x, y, width, height, &intTokens, &stringTokens);
}
void skindesignerapi::cViewGrid::SetCurrent(long gridID, bool current) {
if (!view)
return;
view->SetGridCurrent(viewGridID, gridID, current);
}
void skindesignerapi::cViewGrid::MoveGrid(long gridID, double x, double y, double width, double height) {
if (!view)
return;
view->SetGrid(viewGridID, gridID, x, y, width, height, NULL, NULL);
}
void skindesignerapi::cViewGrid::Delete(long gridID) {
if (!view)
return;
view->DeleteGrid(viewGridID, gridID);
}
void skindesignerapi::cViewGrid::Clear(void) {
if (!view)
return;
view->ClearGrids(viewGridID);
}
void skindesignerapi::cViewGrid::Display(void) {
if (!view)
return;
view->DisplayGrids(viewGridID);
}
/**********************************************************************
* cViewTab
**********************************************************************/
skindesignerapi::cViewTab::cViewTab(skindesignerapi::ISkinDisplayPlugin *view) : cOsdElement(view) {
}
skindesignerapi::cViewTab::~cViewTab() {
}
void skindesignerapi::cViewTab::Init(void) {
view->SetTabIntTokens(&intTokens);
view->SetTabStringTokens(&stringTokens);
view->SetTabLoopTokens(&loopTokens);
view->SetTabs();
}
void skindesignerapi::cViewTab::Left(void) {
view->TabLeft();
}
void skindesignerapi::cViewTab::Right(void) {
view->TabRight();
}
void skindesignerapi::cViewTab::Up(void) {
view->TabUp();
}
void skindesignerapi::cViewTab::Down(void) {
view->TabDown();
}
void skindesignerapi::cViewTab::Display(void) {
if (!view)
return;
view->DisplayTabs();
}
/**********************************************************************
* cOsdView
**********************************************************************/
skindesignerapi::cOsdView::cOsdView(skindesignerapi::ISkinDisplayPlugin *displayPlugin) {
this->displayPlugin = displayPlugin;
}
skindesignerapi::cOsdView::~cOsdView() {
delete displayPlugin;
}
void skindesignerapi::cOsdView::Deactivate(bool hide) {
if (!displayPlugin)
return;
displayPlugin->Deactivate(hide);
}
void skindesignerapi::cOsdView::Activate(void) {
if (!displayPlugin)
return;
displayPlugin->Activate();
}
skindesignerapi::cViewElement *skindesignerapi::cOsdView::GetViewElement(int viewElementID) {
if (!displayPlugin)
return NULL;
return new cViewElement(displayPlugin, viewElementID);
}
skindesignerapi::cViewGrid *skindesignerapi::cOsdView::GetViewGrid(int viewGridID) {
if (!displayPlugin)
return NULL;
displayPlugin->InitGrids(viewGridID);
return new cViewGrid(displayPlugin, viewGridID);
}
skindesignerapi::cViewTab *skindesignerapi::cOsdView::GetViewTabs(void) {
if (!displayPlugin)
return NULL;
return new cViewTab(displayPlugin);
}
void skindesignerapi::cOsdView::Display(void) {
if (!displayPlugin)
return;
displayPlugin->Flush();
}

View File

@ -0,0 +1,94 @@
#ifndef __OSDELEMENTS_H
#define __OSDELEMENTS_H
#include <vdr/plugin.h>
#include "skindesignerapi.h"
namespace skindesignerapi {
/**********************************************************************
* cOsdElement
**********************************************************************/
class cOsdElement {
protected:
ISkinDisplayPlugin *view;
map < string, string > stringTokens;
map < string, int > intTokens;
map < string, vector< map< string, string > > > loopTokens;
public:
cOsdElement(ISkinDisplayPlugin *view);
virtual ~cOsdElement();
void AddLoopToken(string loopName, map<string, string> &tokens);
void AddStringToken(string key, string value);
void AddIntToken(string key, int value);
void ClearTokens(void);
bool ChannelLogoExists(string channelId);
string GetEpgImagePath(void);
};
/**********************************************************************
* cViewElement
**********************************************************************/
class cViewElement : public cOsdElement {
private:
int viewElementID;
public:
cViewElement(ISkinDisplayPlugin *view, int viewElementID);
virtual ~cViewElement();
void Clear(void);
void Display(void);
};
/**********************************************************************
* cViewGrid
**********************************************************************/
class cViewGrid : public cOsdElement {
private:
int viewGridID;
public:
cViewGrid(ISkinDisplayPlugin *view, int viewGridID);
virtual ~cViewGrid();
void SetGrid(long gridID, double x, double y, double width, double height);
void SetCurrent(long gridID, bool current);
void MoveGrid(long gridID, double x, double y, double width, double height);
void Delete(long gridID);
void Clear(void);
void Display(void);
};
/**********************************************************************
* cViewTab
**********************************************************************/
class cViewTab : public cOsdElement {
private:
public:
cViewTab(ISkinDisplayPlugin *view);
virtual ~cViewTab();
void Init(void);
void Left(void);
void Right(void);
void Up(void);
void Down(void);
void Display(void);
};
/**********************************************************************
* cOsdView
**********************************************************************/
class cOsdView {
private:
ISkinDisplayPlugin *displayPlugin;
public:
cOsdView(ISkinDisplayPlugin *displayPlugin);
virtual ~cOsdView();
void Deactivate(bool hide);
void Activate(void);
cViewElement *GetViewElement(int viewElementID);
cViewGrid *GetViewGrid(int viewGridID);
cViewTab *GetViewTabs(void);
void Display(void);
};
}
#endif // __OSDELEMENTS_H

View File

@ -1,31 +1,33 @@
#include "skindesignerapi.h"
skindesignerapi::SkindesignerAPI* skindesignerapi::SkindesignerAPI::skindesigner = NULL;
skindesignerapi::SkindesignerAPI *skindesignerapi::SkindesignerAPI::skindesigner = NULL;
skindesignerapi::SkindesignerAPI::SkindesignerAPI(void)
{
skindesignerapi::SkindesignerAPI::SkindesignerAPI(void) {
if (skindesigner != NULL)
esyslog("skindesigner should only be loaded once");
else
skindesigner = this;
}
skindesignerapi::SkindesignerAPI::~SkindesignerAPI(void)
{
skindesignerapi::SkindesignerAPI::~SkindesignerAPI(void) {
if (skindesigner == this)
skindesigner = NULL;
}
bool skindesignerapi::SkindesignerAPI::CallRegisterPlugin(string name, map< int, string > menus)
{
bool skindesignerapi::SkindesignerAPI::RegisterPlugin(cPluginStructure *plugStructure) {
if (skindesigner)
return skindesigner->OnRegisterPlugin(name, menus);
return skindesigner->ServiceRegisterPlugin(plugStructure);
return false;
}
skindesignerapi::ISDDisplayMenu* skindesignerapi::SkindesignerAPI::CallGetDisplayMenu()
{
skindesignerapi::ISDDisplayMenu *skindesignerapi::SkindesignerAPI::GetDisplayMenu() {
if (skindesigner)
return skindesigner->OnGetDisplayMenu();
return skindesigner->ServiceGetDisplayMenu();
return NULL;
}
skindesignerapi::ISkinDisplayPlugin *skindesignerapi::SkindesignerAPI::GetDisplayPlugin(string pluginName, int viewID, int subViewID) {
if (skindesigner)
return skindesigner->ServiceGetDisplayPlugin(pluginName, viewID, subViewID);
return NULL;
}

View File

@ -12,25 +12,98 @@ namespace skindesignerapi {
class ISDDisplayMenu : public cSkinDisplayMenu {
public:
virtual void SetTitle(const char *Title) = 0;
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 ISkinDisplayPlugin {
public:
virtual ~ISkinDisplayPlugin(void) {};
virtual void Deactivate(bool hide) = 0;
virtual void Activate(void) = 0;
virtual void ClearViewElement(int id) = 0;
virtual void DisplayViewElement(int id) = 0;
virtual void SetViewElementIntTokens(map<string,int> *intTokens) = 0;
virtual void SetViewElementStringTokens(map<string,string> *stringTokens) = 0;
virtual void SetViewElementLoopTokens(map<string,vector<map<string,string> > > *loopTokens) = 0;
virtual void InitGrids(int viewGridID) = 0;
virtual void SetGrid(int viewGridID, long gridID, double x, double y, double width, double height, map<string,int> *intTokens, map<string,string> *stringTokens) = 0;
virtual void SetGridCurrent(int viewGridID, long gridID, bool current) = 0;
virtual void DeleteGrid(int viewGridID, long gridID) = 0;
virtual void DisplayGrids(int viewGridID) = 0;
virtual void ClearGrids(int viewGridID) = 0;
virtual void SetTabIntTokens(map<string,int> *intTokens) = 0;
virtual void SetTabStringTokens(map<string,string> *stringTokens) = 0;
virtual void SetTabLoopTokens(map<string,vector<map<string,string> > > *loopTokens) = 0;
virtual void SetTabs(void) = 0;
virtual void TabLeft(void) = 0;
virtual void TabRight(void) = 0;
virtual void TabUp(void) = 0;
virtual void TabDown(void) = 0;
virtual void DisplayTabs(void) = 0;
virtual void Flush(void) = 0;
virtual bool ChannelLogoExists(string channelId) = 0;
virtual string GetEpgImagePath(void) = 0;
};
class cPluginStructure {
public:
cPluginStructure(void) {
name = "";
};
void SetMenu(int key, string templateName) {
menus.insert(pair<int, string>(key, templateName));
}
void SetView(int key, string templateName) {
views.insert(pair<int, string>(key, templateName));
}
void SetSubView(int view, int subView, string templateName) {
pair<int, string> sub = make_pair(subView, templateName);
subViews.insert(pair<int, pair<int, string> >(view, sub));
}
void SetViewElement(int view, int viewElement, string name) {
map< int, map<int, string> >::iterator hit = viewElements.find(view);
if (hit == viewElements.end()) {
map<int, string> vE;
vE.insert(pair<int, string >(viewElement, name));
viewElements.insert(pair<int, map < int, string > >(view, vE));
} else {
(hit->second).insert(pair<int, string >(viewElement, name));
}
}
void SetViewGrid(int view, int viewGrid, string name) {
map< int, map<int, string> >::iterator hit = viewGrids.find(view);
if (hit == viewGrids.end()) {
map<int, string> vG;
vG.insert(pair<int, string >(viewGrid, name));
viewGrids.insert(pair<int, map < int, string > >(view, vG));
} else {
(hit->second).insert(pair<int, string >(viewGrid, name));
}
}
string name; //name of plugin
map< int, string > menus; //menus as key -> templatename hashmap
map< int, string> views; //standalone views as key -> templatename hashmap
multimap< int, pair <int, string> > subViews; //subviews of standalone views as view -> (subview, templatename) multimap
map< int, map <int, string> > viewElements; //viewelements as key -> (viewelement, viewelementname) hashmap
map< int, map <int, string> > viewGrids; //viewgrids as key -> (viewgrid, viewgridname) hashmap
};
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;
virtual bool ServiceRegisterPlugin(cPluginStructure *plugStructure) = 0;
virtual ISDDisplayMenu *ServiceGetDisplayMenu(void) = 0;
virtual ISkinDisplayPlugin *ServiceGetDisplayPlugin(string pluginName, int viewID, int subViewID) = 0;
public:
static bool CallRegisterPlugin(string name, map< int, string > menus);
static ISDDisplayMenu* CallGetDisplayMenu();
static bool RegisterPlugin(cPluginStructure *plugStructure);
static ISDDisplayMenu *GetDisplayMenu(void);
static ISkinDisplayPlugin *GetDisplayPlugin(string pluginName, int viewID, int subViewID);
};
}

View File

@ -0,0 +1,187 @@
#include "skindesignerosdbase.h"
/**********************************************************************
* cSkindesignerOsdObject
**********************************************************************/
skindesignerapi::cSkindesignerOsdObject::cSkindesignerOsdObject(void) {
pluginName = "";
}
skindesignerapi::cSkindesignerOsdObject::~cSkindesignerOsdObject() {
}
bool skindesignerapi::cSkindesignerOsdObject::InitSkindesignerInterface(string pluginName) {
this->pluginName = pluginName;
return true;
}
skindesignerapi::cOsdView *skindesignerapi::cSkindesignerOsdObject::GetOsdView(int viewID, int subViewID) {
ISkinDisplayPlugin *displayPlugin = SkindesignerAPI::GetDisplayPlugin(pluginName, viewID, subViewID);
if (!displayPlugin)
return NULL;
cOsdView *view = new cOsdView(displayPlugin);
return view;
}
/**********************************************************************
* cSkindesignerOsdItem
**********************************************************************/
skindesignerapi::cSkindesignerOsdItem::cSkindesignerOsdItem(eOSState State) : cOsdItem(State) {
sdDisplayMenu = NULL;
}
skindesignerapi::cSkindesignerOsdItem::cSkindesignerOsdItem(const char *Text, eOSState State, bool Selectable) : cOsdItem(Text, State, Selectable) {
sdDisplayMenu = NULL;
}
skindesignerapi::cSkindesignerOsdItem::~cSkindesignerOsdItem() {
}
void skindesignerapi::cSkindesignerOsdItem::SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable) {
if (sdDisplayMenu) {
if (!sdDisplayMenu->SetItemPlugin(&stringTokens, &intTokens, &loopTokens, Index, Current, Selectable)) {
DisplayMenu->SetItem(Text(), Index, Current, Selectable);
}
} else {
DisplayMenu->SetItem(Text(), Index, Current, Selectable);
}
}
void skindesignerapi::cSkindesignerOsdItem::AddStringToken(string key, string value) {
stringTokens.insert(pair<string,string>(key, value));
}
void skindesignerapi::cSkindesignerOsdItem::AddIntToken(string key, int value) {
intTokens.insert(pair<string,int>(key, value));
}
void skindesignerapi::cSkindesignerOsdItem::AddLoopToken(string loopName, map<string, string> &tokens) {
map<string, vector<map<string, string> > >::iterator hitLoop = loopTokens.find(loopName);
if (hitLoop == loopTokens.end()) {
vector<map<string, string> > tokenVector;
tokenVector.push_back(tokens);
loopTokens.insert(pair<string, vector<map<string, string> > >(loopName, tokenVector));
} else {
vector<map<string, string> > *tokenVector = &hitLoop->second;
tokenVector->push_back(tokens);
}
}
/**********************************************************************
* cSkindesignerOsdMenu
**********************************************************************/
skindesignerapi::cSkindesignerOsdMenu::cSkindesignerOsdMenu(const char *Title, int c0, int c1, int c2, int c3, int c4) : cOsdMenu(Title, c0, c1, c2, c3, c4) {
init = true;
displayText = false;
sdDisplayMenu = NULL;
pluginName = "";
SetMenuCategory(mcPlugin);
SetSkinDesignerDisplayMenu();
}
skindesignerapi::cSkindesignerOsdMenu::~cSkindesignerOsdMenu() {
}
void skindesignerapi::cSkindesignerOsdMenu::SetPluginMenu(int menu, eMenuType type) {
if (type == mtList)
displayText = false;
else if (type == mtText)
displayText = true;
if (sdDisplayMenu) {
sdDisplayMenu->SetPluginMenu(pluginName, menu, type, init);
}
init = false;
}
bool skindesignerapi::cSkindesignerOsdMenu::SetSkinDesignerDisplayMenu(void) {
sdDisplayMenu = SkindesignerAPI::GetDisplayMenu();
return (sdDisplayMenu != NULL);
}
void skindesignerapi::cSkindesignerOsdMenu::ClearTokens(void) {
text = "";
stringTokens.clear();
intTokens.clear();
loopTokens.clear();
}
void skindesignerapi::cSkindesignerOsdMenu::AddStringToken(string key, string value) {
stringTokens.insert(pair<string,string>(key, value));
}
void skindesignerapi::cSkindesignerOsdMenu::AddIntToken(string key, int value) {
intTokens.insert(pair<string,int>(key, value));
}
void skindesignerapi::cSkindesignerOsdMenu::AddLoopToken(string loopName, map<string, string> &tokens) {
map<string, vector<map<string, string> > >::iterator hitLoop = loopTokens.find(loopName);
if (hitLoop == loopTokens.end()) {
vector<map<string, string> > tokenVector;
tokenVector.push_back(tokens);
loopTokens.insert(pair<string, vector<map<string, string> > >(loopName, tokenVector));
} else {
vector<map<string, string> > *tokenVector = &hitLoop->second;
tokenVector->push_back(tokens);
}
}
void skindesignerapi::cSkindesignerOsdMenu::TextKeyLeft(void) {
if (!displayText)
return;
DisplayMenu()->Scroll(true, true);
}
void skindesignerapi::cSkindesignerOsdMenu::TextKeyRight(void) {
if (!displayText)
return;
DisplayMenu()->Scroll(false, true);
}
void skindesignerapi::cSkindesignerOsdMenu::TextKeyUp(void) {
if (!displayText)
return;
DisplayMenu()->Scroll(true, false);
}
void skindesignerapi::cSkindesignerOsdMenu::TextKeyDown(void) {
if (!displayText)
return;
DisplayMenu()->Scroll(false, false);
}
void skindesignerapi::cSkindesignerOsdMenu::Display(void) {
if (displayText) {
if (sdDisplayMenu) {
sdDisplayMenu->SetTitle(Title());
if (sdDisplayMenu->SetPluginText(&stringTokens, &intTokens, &loopTokens)) {
sdDisplayMenu->Flush();
} else {
DisplayMenu()->Clear();
DisplayMenu()->SetTitle(Title());
DisplayMenu()->SetText(text.c_str(), false);
DisplayMenu()->Flush();
}
} else {
DisplayMenu()->Clear();
DisplayMenu()->SetTitle(Title());
DisplayMenu()->SetText(text.c_str(), false);
DisplayMenu()->Flush();
}
return;
}
if (sdDisplayMenu) {
sdDisplayMenu->SetTitle(Title());
for (cOsdItem *item = First(); item; item = Next(item)) {
cSkindesignerOsdItem *sdItem = dynamic_cast<cSkindesignerOsdItem*>(item);
if (sdItem) {
sdItem->SetDisplayMenu(sdDisplayMenu);
}
}
}
cOsdMenu::Display();
}

View File

@ -0,0 +1,92 @@
#ifndef __SKINDESIGNEROSDBASE_H
#define __SKINDESIGNEROSDBASE_H
#include <string>
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <vdr/osdbase.h>
#include <vdr/plugin.h>
#include "osdelements.h"
#include "skindesignerapi.h"
namespace skindesignerapi {
enum eMenuType {
mtList,
mtText
};
class cOsdView;
/**********************************************************************
* cSkindesignerOsdObject
**********************************************************************/
class cSkindesignerOsdObject : public cOsdObject {
protected:
string pluginName;
bool InitSkindesignerInterface(string pluginName);
cOsdView *GetOsdView(int viewID, int subViewID = -1);
public:
cSkindesignerOsdObject(void);
virtual ~cSkindesignerOsdObject();
virtual void Show(void) {};
};
/**********************************************************************
* cSkindesignerOsdItem
**********************************************************************/
class cSkindesignerOsdItem : public cOsdItem {
private:
ISDDisplayMenu *sdDisplayMenu;
map < string, string > stringTokens;
map < string, int > intTokens;
map < string, vector< map< string, string > > > loopTokens;
protected:
public:
cSkindesignerOsdItem(eOSState State = osUnknown);
cSkindesignerOsdItem(const char *Text, eOSState State = osUnknown, bool Selectable = true);
virtual ~cSkindesignerOsdItem();
virtual void SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable);
void SetDisplayMenu(ISDDisplayMenu *sdDisplayMenu) { this->sdDisplayMenu = sdDisplayMenu; };
void AddStringToken(string key, string value);
void AddIntToken(string key, int value);
void AddLoopToken(string loopName, map<string, string> &tokens);
};
/**********************************************************************
* cSkindesignerOsdMenu
**********************************************************************/
class cSkindesignerOsdMenu : public cOsdMenu {
private:
bool init;
bool displayText;
string pluginName;
ISDDisplayMenu *sdDisplayMenu;
string text;
map < string, string > stringTokens;
map < string, int > intTokens;
map < string, vector< map< string, string > > > loopTokens;
bool SetSkinDesignerDisplayMenu(void);
protected:
void ClearTokens(void);
void SetPluginName(string name) {pluginName = name; };
void SetPluginMenu(int menu, eMenuType type);
void SetText(string text) { this->text = text; };
void AddStringToken(string key, string value);
void AddIntToken(string key, int value);
void AddLoopToken(string loopName, map<string, string> &tokens);
void TextKeyLeft(void);
void TextKeyRight(void);
void TextKeyUp(void);
void TextKeyDown(void);
public:
cSkindesignerOsdMenu(const char *Title, int c0 = 0, int c1 = 0, int c2 = 0, int c3 = 0, int c4 = 0);
virtual ~cSkindesignerOsdMenu();
virtual void Display(void);
};
}
#endif // __SKINDESIGNEROSDBASE_H

View File

@ -1,86 +0,0 @@
#ifndef __SKINDESIGNERSERVICES_H
#define __SKINDESIGNERSERVICES_H
using namespace std;
#include <string>
#include <map>
/*********************************************************************
* Data Structures for Service Calls
*********************************************************************/
// Data structure for service "RegisterPlugin"
class RegisterPlugin {
public:
RegisterPlugin(void) {
name = "";
};
void SetMenu(int key, string templateName) {
menus.insert(pair<int, string>(key, templateName));
}
void SetView(int key, string templateName) {
views.insert(pair<int, string>(key, templateName));
}
void SetSubView(int view, int subView, string templateName) {
pair<int, string> sub = make_pair(subView, templateName);
subViews.insert(pair<int, pair<int, string> >(view, sub));
}
void SetViewElement(int view, int viewElement, string name) {
map< int, map<int, string> >::iterator hit = viewElements.find(view);
if (hit == viewElements.end()) {
map<int, string> vE;
vE.insert(pair<int, string >(viewElement, name));
viewElements.insert(pair<int, map < int, string > >(view, vE));
} else {
(hit->second).insert(pair<int, string >(viewElement, name));
}
}
void SetViewGrid(int view, int viewGrid, string name) {
map< int, map<int, string> >::iterator hit = viewGrids.find(view);
if (hit == viewGrids.end()) {
map<int, string> vG;
vG.insert(pair<int, string >(viewGrid, name));
viewGrids.insert(pair<int, map < int, string > >(view, vG));
} else {
(hit->second).insert(pair<int, string >(viewGrid, name));
}
}
// in
string name; //name of plugin
map< int, string > menus; //menus as key -> templatename hashmap
map< int, string> views; //standalone views as key -> templatename hashmap
multimap< int, pair <int, string> > subViews; //subviews of standalone views as view -> (subview, templatename) multimap
map< int, map <int, string> > viewElements; //viewelements as key -> (viewelement, viewelementname) hashmap
map< int, map <int, string> > viewGrids; //viewgrids as key -> (viewgrid, viewgridname) hashmap
//out
};
// Data structure for service "GetDisplayMenu"
class GetDisplayMenu {
public:
GetDisplayMenu(void) {
displayMenu = NULL;
};
// in
//out
cSDDisplayMenu *displayMenu;
};
// Data structure for service "GetDisplayPlugin"
class GetDisplayPlugin {
public:
GetDisplayPlugin(void) {
pluginName = "";
viewID = -1;
subViewID = -1;
displayPlugin = NULL;
};
// in
string pluginName;
int viewID;
int subViewID;
//out
cSkinDisplayPlugin *displayPlugin;
};
#endif //__SKINDESIGNERSERVICES_H

View File

@ -13,7 +13,6 @@
#include "config.h"
#include "designer.h"
#include "setup.h"
#include "services.h"
#if defined(APIVERSNUM) && APIVERSNUM < 20000
#error "VDR-2.0.0 API version or greater is required!"
@ -23,9 +22,13 @@
static const char *VERSION = "0.3.4";
static const char *DESCRIPTION = trNOOP("Skin Designer");
class cPluginSkinDesigner : public cPlugin {
class cPluginSkinDesigner : public cPlugin, public skindesignerapi::SkindesignerAPI {
private:
vector<cSkinDesigner*> skins;
protected:
bool ServiceRegisterPlugin(skindesignerapi::cPluginStructure *plugStructure);
skindesignerapi::ISDDisplayMenu *ServiceGetDisplayMenu(void);
skindesignerapi::ISkinDisplayPlugin *ServiceGetDisplayPlugin(string pluginName, int viewID, int subViewID);
public:
cPluginSkinDesigner(void);
virtual ~cPluginSkinDesigner();
@ -159,54 +162,6 @@ bool cPluginSkinDesigner::SetupParse(const char *Name, const char *Value) {
}
bool cPluginSkinDesigner::Service(const char *Id, void *Data) {
if (Data == NULL)
return false;
if (strcmp(Id, "RegisterPlugin") == 0) {
RegisterPlugin *call = (RegisterPlugin*) Data;
if (call->menus.size() < 1 && call->views.size() < 1) {
esyslog("skindesigner: error - plugin without menus or views registered");
return false;
}
config.AddPluginMenus(call->name, call->menus);
config.AddPluginViews(call->name, call->views, call->subViews, call->viewElements, call->viewGrids);
if (call->menus.size() > 0)
dsyslog("skindesigner: plugin %s has registered %ld menus", call->name.c_str(), call->menus.size());
if (call->views.size() > 0)
dsyslog("skindesigner: plugin %s has registered %ld views", call->name.c_str(), call->views.size());
return true;
} else if (strcmp(Id, "GetDisplayMenu") == 0) {
GetDisplayMenu* call = (GetDisplayMenu*) Data;
cSkin *current = Skins.Current();
for (vector<cSkinDesigner*>::iterator skin = skins.begin(); skin != skins.end(); skin++) {
if (*skin == current) {
cSDDisplayMenu *displayMenu = (*skin)->GetDisplayMenu();
if (displayMenu) {
call->displayMenu = displayMenu;
return true;
} else
return false;
}
}
return false;
} else if (strcmp(Id, "GetDisplayPlugin") == 0) {
GetDisplayPlugin* call = (GetDisplayPlugin*) Data;
if (call->pluginName.size() == 0 || call->viewID < 0)
return false;
cSkin *current = Skins.Current();
for (vector<cSkinDesigner*>::iterator skin = skins.begin(); skin != skins.end(); skin++) {
if (*skin == current) {
cSkinDisplayPlugin *displayPlugin = (*skin)->DisplayPlugin(call->pluginName, call->viewID, call->subViewID);
if (displayPlugin) {
call->displayPlugin = displayPlugin;
return true;
} else
return false;
}
}
return false;
}
return false;
}
@ -280,4 +235,50 @@ cString cPluginSkinDesigner::SVDRPCommand(const char *Command, const char *Optio
return "";
}
bool cPluginSkinDesigner::ServiceRegisterPlugin(skindesignerapi::cPluginStructure *plugStructure) {
if (plugStructure->menus.size() < 1 && plugStructure->views.size() < 1) {
esyslog("skindesigner: error - plugin without menus or views registered");
return false;
}
config.AddPluginMenus(plugStructure->name, plugStructure->menus);
config.AddPluginViews(plugStructure->name, plugStructure->views, plugStructure->subViews, plugStructure->viewElements, plugStructure->viewGrids);
if (plugStructure->menus.size() > 0)
dsyslog("skindesigner: plugin %s has registered %ld menus", plugStructure->name.c_str(), plugStructure->menus.size());
if (plugStructure->views.size() > 0)
dsyslog("skindesigner: plugin %s has registered %ld views", plugStructure->name.c_str(), plugStructure->views.size());
return true;
}
skindesignerapi::ISDDisplayMenu *cPluginSkinDesigner::ServiceGetDisplayMenu(void) {
cSkin *current = Skins.Current();
for (vector<cSkinDesigner*>::iterator skin = skins.begin(); skin != skins.end(); skin++) {
if (*skin == current) {
cSDDisplayMenu *displayMenu = (*skin)->GetDisplayMenu();
if (displayMenu) {
return displayMenu;
} else {
return NULL;
}
}
}
return NULL;
}
skindesignerapi::ISkinDisplayPlugin *cPluginSkinDesigner::ServiceGetDisplayPlugin(string pluginName, int viewID, int subViewID) {
if (pluginName.size() == 0 || viewID < 0)
return NULL;
cSkin *current = Skins.Current();
for (vector<cSkinDesigner*>::iterator skin = skins.begin(); skin != skins.end(); skin++) {
if (*skin == current) {
cSkinDisplayPlugin *displayPlugin = (*skin)->DisplayPlugin(pluginName, viewID, subViewID);
if (displayPlugin) {
return displayPlugin;
} else {
return NULL;
}
}
}
return NULL;
}
VDRPLUGINCREATOR(cPluginSkinDesigner); // Don't touch this!