mirror of
				https://projects.vdr-developer.org/git/vdr-plugin-skindesigner.git
				synced 2023-10-19 15:58:31 +00:00 
			
		
		
		
	first api implementation
This commit is contained in:
		
							
								
								
									
										3
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								Makefile
									
									
									
									
									
								
							| @@ -54,6 +54,9 @@ LIBS += $(shell pkg-config --libs librsvg-2.0 cairo-png) -ljpeg | ||||
|  | ||||
| LIBS += $(shell xml2-config --libs) | ||||
|  | ||||
| INCLUDES += $(shell pkg-config --cflags libskindesignerapi) | ||||
| LIBS += $(shell pkg-config --libs libskindesignerapi) | ||||
|  | ||||
| ### The object files: | ||||
| OBJS = $(PLUGIN).o \ | ||||
|        config.o \ | ||||
|   | ||||
| @@ -1,203 +0,0 @@ | ||||
| #include "osdelements.h" | ||||
|  | ||||
| /********************************************************************** | ||||
| * cOsdElement | ||||
| **********************************************************************/ | ||||
| cOsdElement::cOsdElement(cSkinDisplayPlugin *view) { | ||||
|     this->view = view; | ||||
| } | ||||
|  | ||||
| cOsdElement::~cOsdElement() { | ||||
| } | ||||
|  | ||||
| void cOsdElement::ClearTokens(void) { | ||||
|     stringTokens.clear(); | ||||
|     intTokens.clear(); | ||||
|     loopTokens.clear(); | ||||
| } | ||||
|  | ||||
| void cOsdElement::AddStringToken(string key, string value) { | ||||
|     stringTokens.insert(pair<string,string>(key, value)); | ||||
| } | ||||
|  | ||||
| void cOsdElement::AddIntToken(string key, int value) { | ||||
|     intTokens.insert(pair<string,int>(key, value)); | ||||
| } | ||||
|  | ||||
| void 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 cOsdElement::ChannelLogoExists(string channelId) { | ||||
|     return view->ChannelLogoExists(channelId); | ||||
| } | ||||
|  | ||||
| string cOsdElement::GetEpgImagePath(void) { | ||||
|     return view->GetEpgImagePath();     | ||||
| } | ||||
|  | ||||
|  | ||||
| /********************************************************************** | ||||
| * cViewElement | ||||
| **********************************************************************/ | ||||
| cViewElement::cViewElement(cSkinDisplayPlugin *view, int viewElementID) : cOsdElement(view) { | ||||
|     this->viewElementID = viewElementID; | ||||
| } | ||||
|  | ||||
| cViewElement::~cViewElement() { | ||||
| } | ||||
|  | ||||
| void cViewElement::Clear(void) { | ||||
|     if (!view) | ||||
|         return; | ||||
|     view->ClearViewElement(viewElementID); | ||||
| } | ||||
|  | ||||
| void cViewElement::Display(void) { | ||||
|     if (!view) | ||||
|         return; | ||||
|     view->SetViewElementIntTokens(&intTokens); | ||||
|     view->SetViewElementStringTokens(&stringTokens); | ||||
|     view->SetViewElementLoopTokens(&loopTokens); | ||||
|     view->DisplayViewElement(viewElementID); | ||||
| } | ||||
|  | ||||
| /********************************************************************** | ||||
| * cViewGrid | ||||
| **********************************************************************/ | ||||
| cViewGrid::cViewGrid(cSkinDisplayPlugin *view, int viewGridID) : cOsdElement(view) { | ||||
|     this->viewGridID = viewGridID; | ||||
| } | ||||
|  | ||||
| cViewGrid::~cViewGrid() { | ||||
| } | ||||
|  | ||||
| void 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 cViewGrid::SetCurrent(long gridID, bool current) { | ||||
|     if (!view) | ||||
|         return; | ||||
|     view->SetGridCurrent(viewGridID, gridID, current); | ||||
| } | ||||
|  | ||||
| void 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 cViewGrid::Delete(long gridID) { | ||||
|     if (!view) | ||||
|         return; | ||||
|     view->DeleteGrid(viewGridID, gridID); | ||||
| } | ||||
|  | ||||
| void cViewGrid::Clear(void) { | ||||
|     if (!view) | ||||
|         return; | ||||
|     view->ClearGrids(viewGridID);     | ||||
| } | ||||
|  | ||||
| void cViewGrid::Display(void) { | ||||
|     if (!view) | ||||
|         return; | ||||
|     view->DisplayGrids(viewGridID); | ||||
| } | ||||
|  | ||||
| /********************************************************************** | ||||
| * cViewTab | ||||
| **********************************************************************/ | ||||
| cViewTab::cViewTab(cSkinDisplayPlugin *view) : cOsdElement(view) { | ||||
| } | ||||
|  | ||||
| cViewTab::~cViewTab() { | ||||
| } | ||||
|  | ||||
| void cViewTab::Init(void) { | ||||
|     view->SetTabIntTokens(&intTokens); | ||||
|     view->SetTabStringTokens(&stringTokens); | ||||
|     view->SetTabLoopTokens(&loopTokens); | ||||
|     view->SetTabs();     | ||||
| } | ||||
|  | ||||
| void cViewTab::Left(void) { | ||||
|     view->TabLeft(); | ||||
| } | ||||
|  | ||||
| void cViewTab::Right(void) { | ||||
|     view->TabRight(); | ||||
| } | ||||
|  | ||||
| void cViewTab::Up(void) { | ||||
|     view->TabUp(); | ||||
| } | ||||
|  | ||||
| void cViewTab::Down(void) { | ||||
|     view->TabDown(); | ||||
| } | ||||
|  | ||||
| void cViewTab::Display(void) { | ||||
|     if (!view) | ||||
|         return; | ||||
|     view->DisplayTabs(); | ||||
| } | ||||
|  | ||||
| /********************************************************************** | ||||
| * cOsdView | ||||
| **********************************************************************/ | ||||
| cOsdView::cOsdView(cSkinDisplayPlugin *displayPlugin) { | ||||
|     this->displayPlugin = displayPlugin; | ||||
| } | ||||
|  | ||||
| cOsdView::~cOsdView() { | ||||
|     delete displayPlugin; | ||||
| } | ||||
|  | ||||
| void cOsdView::Deactivate(bool hide) { | ||||
|     if (!displayPlugin) | ||||
|         return; | ||||
|     displayPlugin->Deactivate(hide); | ||||
| } | ||||
|  | ||||
| void cOsdView::Activate(void) { | ||||
|     if (!displayPlugin) | ||||
|         return; | ||||
|     displayPlugin->Activate(); | ||||
| } | ||||
|  | ||||
| cViewElement *cOsdView::GetViewElement(int viewElementID) { | ||||
|     if (!displayPlugin) | ||||
|         return NULL; | ||||
|     return new cViewElement(displayPlugin, viewElementID); | ||||
| } | ||||
|  | ||||
| cViewGrid *cOsdView::GetViewGrid(int viewGridID) { | ||||
|     if (!displayPlugin) | ||||
|         return NULL; | ||||
|     displayPlugin->InitGrids(viewGridID); | ||||
|     return new cViewGrid(displayPlugin, viewGridID); | ||||
| } | ||||
|  | ||||
| cViewTab *cOsdView::GetViewTabs(void) { | ||||
|     if (!displayPlugin) | ||||
|         return NULL; | ||||
|     return new cViewTab(displayPlugin); | ||||
| } | ||||
|  | ||||
| void cOsdView::Display(void) { | ||||
|     if (!displayPlugin) | ||||
|         return; | ||||
|     displayPlugin->Flush();    | ||||
| } | ||||
| @@ -1,91 +0,0 @@ | ||||
| #ifndef __OSDELEMENTS_H | ||||
| #define __OSDELEMENTS_H | ||||
|  | ||||
| #include <vdr/plugin.h> | ||||
| #include "services.h" | ||||
|  | ||||
| /********************************************************************** | ||||
| * cOsdElement | ||||
| **********************************************************************/ | ||||
|  | ||||
| class cOsdElement { | ||||
| protected: | ||||
|     cSkinDisplayPlugin *view; | ||||
|     map < string, string > stringTokens; | ||||
|     map < string, int > intTokens; | ||||
|     map < string, vector< map< string, string > > > loopTokens; | ||||
| public: | ||||
|     cOsdElement(cSkinDisplayPlugin *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(cSkinDisplayPlugin *view, int viewElementID); | ||||
|     virtual ~cViewElement(); | ||||
|     void Clear(void); | ||||
|     void Display(void); | ||||
| }; | ||||
|  | ||||
| /********************************************************************** | ||||
| * cViewGrid | ||||
| **********************************************************************/ | ||||
| class cViewGrid : public cOsdElement { | ||||
| private: | ||||
|     int viewGridID; | ||||
| public: | ||||
|     cViewGrid(cSkinDisplayPlugin *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(cSkinDisplayPlugin *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: | ||||
|     cSkinDisplayPlugin *displayPlugin; | ||||
| public: | ||||
|     cOsdView(cSkinDisplayPlugin *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 | ||||
| @@ -1,131 +0,0 @@ | ||||
| #ifndef __SKINDESIGNERSERVICES_H | ||||
| #define __SKINDESIGNERSERVICES_H | ||||
|  | ||||
| using namespace std; | ||||
|  | ||||
| #include <string> | ||||
| #include <vector> | ||||
| #include <map> | ||||
|  | ||||
| enum eMenuType { | ||||
|     mtList, | ||||
|     mtText | ||||
| }; | ||||
|  | ||||
| class cSDDisplayMenu : public cSkinDisplayMenu { | ||||
| public: | ||||
|     virtual void SetTitle(const char *Title); | ||||
|     virtual void SetPluginMenu(string name, int menu, int type, bool init); | ||||
|     virtual bool SetItemPlugin(map<string,string> *stringTokens, map<string,int> *intTokens, map<string,vector<map<string,string> > > *loopTokens, int Index, bool Current, bool Selectable); | ||||
|     virtual bool SetPluginText(map<string,string> *stringTokens, map<string,int> *intTokens, map<string,vector<map<string,string> > > *loopTokens); | ||||
| }; | ||||
|  | ||||
| class cSkinDisplayPlugin { | ||||
| public: | ||||
|     cSkinDisplayPlugin(void); | ||||
|     virtual ~cSkinDisplayPlugin(void); | ||||
|     virtual void Deactivate(bool hide); | ||||
|     virtual void Activate(void); | ||||
|     virtual void ClearViewElement(int id); | ||||
|     virtual void DisplayViewElement(int id); | ||||
|     virtual void SetViewElementIntTokens(map<string,int> *intTokens); | ||||
|     virtual void SetViewElementStringTokens(map<string,string> *stringTokens); | ||||
|     virtual void SetViewElementLoopTokens(map<string,vector<map<string,string> > > *loopTokens); | ||||
|     virtual void InitGrids(int viewGridID); | ||||
|     virtual void SetGrid(int viewGridID, long gridID, double x, double y, double width, double height, map<string,int> *intTokens, map<string,string> *stringTokens); | ||||
|     virtual void SetGridCurrent(int viewGridID, long gridID, bool current); | ||||
|     virtual void DeleteGrid(int viewGridID, long gridID); | ||||
|     virtual void DisplayGrids(int viewGridID); | ||||
|     virtual void ClearGrids(int viewGridID); | ||||
|     virtual void SetTabIntTokens(map<string,int> *intTokens); | ||||
|     virtual void SetTabStringTokens(map<string,string> *stringTokens); | ||||
|     virtual void SetTabLoopTokens(map<string,vector<map<string,string> > > *loopTokens); | ||||
|     virtual void SetTabs(void); | ||||
|     virtual void TabLeft(void); | ||||
|     virtual void TabRight(void); | ||||
|     virtual void TabUp(void); | ||||
|     virtual void TabDown(void); | ||||
|     virtual void DisplayTabs(void); | ||||
|     virtual void Flush(void); | ||||
|     virtual bool ChannelLogoExists(string channelId); | ||||
|     virtual string GetEpgImagePath(void); | ||||
| }; | ||||
|  | ||||
| /********************************************************************* | ||||
| * 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 | ||||
| @@ -1,209 +0,0 @@ | ||||
| #include "skindesignerosdbase.h" | ||||
| #include "osdelements.h" | ||||
|  | ||||
| /********************************************************************** | ||||
| * cSkindesignerOsdObject | ||||
| **********************************************************************/ | ||||
|  | ||||
| cSkindesignerOsdObject::cSkindesignerOsdObject(void) { | ||||
|     pSkinDesigner = NULL; | ||||
|     pluginName = ""; | ||||
| } | ||||
|  | ||||
| cSkindesignerOsdObject::~cSkindesignerOsdObject() { | ||||
| } | ||||
|  | ||||
| bool cSkindesignerOsdObject::InitSkindesignerInterface(string pluginName) { | ||||
|     this->pluginName = pluginName; | ||||
|     pSkinDesigner = cPluginManager::GetPlugin("skindesigner"); | ||||
|     if (!pSkinDesigner) { | ||||
|         return false;    | ||||
|     } | ||||
|     return true; | ||||
| } | ||||
|  | ||||
| cOsdView *cSkindesignerOsdObject::GetOsdView(int viewID, int subViewID) { | ||||
|     cSkinDisplayPlugin *displayPlugin = NULL; | ||||
|     cOsdView *view = NULL; | ||||
|     GetDisplayPlugin call; | ||||
|     call.pluginName = pluginName; | ||||
|     call.viewID = viewID; | ||||
|     call.subViewID = subViewID; | ||||
|     bool ok = pSkinDesigner->Service("GetDisplayPlugin", &call); | ||||
|     if (ok) { | ||||
|         displayPlugin = call.displayPlugin; | ||||
|         view = new cOsdView(displayPlugin); | ||||
|     } | ||||
|     return view; | ||||
| } | ||||
|  | ||||
| /********************************************************************** | ||||
| * cSkindesignerOsdItem | ||||
| **********************************************************************/ | ||||
| cSkindesignerOsdItem::cSkindesignerOsdItem(eOSState State) : cOsdItem(State) { | ||||
|     sdDisplayMenu = NULL; | ||||
| } | ||||
|  | ||||
| cSkindesignerOsdItem::cSkindesignerOsdItem(const char *Text, eOSState State, bool Selectable) : cOsdItem(Text, State, Selectable) { | ||||
|     sdDisplayMenu = NULL; | ||||
| }   | ||||
|  | ||||
| cSkindesignerOsdItem::~cSkindesignerOsdItem() { | ||||
|  | ||||
| } | ||||
|  | ||||
| void 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 cSkindesignerOsdItem::AddStringToken(string key, string value) { | ||||
|     stringTokens.insert(pair<string,string>(key, value)); | ||||
| } | ||||
|  | ||||
| void cSkindesignerOsdItem::AddIntToken(string key, int value) { | ||||
|     intTokens.insert(pair<string,int>(key, value)); | ||||
| } | ||||
|  | ||||
| void 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 | ||||
| **********************************************************************/ | ||||
| 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(); | ||||
| } | ||||
|  | ||||
| cSkindesignerOsdMenu::~cSkindesignerOsdMenu() { | ||||
|  | ||||
| } | ||||
|  | ||||
| void 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 cSkindesignerOsdMenu::SetSkinDesignerDisplayMenu(void) { | ||||
|     static cPlugin *pSkinDesigner = cPluginManager::GetPlugin("skindesigner"); | ||||
|     if (!pSkinDesigner) { | ||||
|         return false;    | ||||
|     } | ||||
|     GetDisplayMenu call; | ||||
|     bool ok = pSkinDesigner->Service("GetDisplayMenu", &call); | ||||
|     if (ok && call.displayMenu) { | ||||
|         sdDisplayMenu = call.displayMenu; | ||||
|         return true; | ||||
|     } | ||||
|     return false; | ||||
| } | ||||
|  | ||||
| void cSkindesignerOsdMenu::ClearTokens(void) { | ||||
|     text = ""; | ||||
|     stringTokens.clear(); | ||||
|     intTokens.clear(); | ||||
|     loopTokens.clear(); | ||||
| } | ||||
|  | ||||
| void cSkindesignerOsdMenu::AddStringToken(string key, string value) { | ||||
|     stringTokens.insert(pair<string,string>(key, value)); | ||||
| } | ||||
|  | ||||
| void cSkindesignerOsdMenu::AddIntToken(string key, int value) { | ||||
|     intTokens.insert(pair<string,int>(key, value)); | ||||
| } | ||||
|  | ||||
| void 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 cSkindesignerOsdMenu::TextKeyLeft(void) { | ||||
|     if (!displayText) | ||||
|         return; | ||||
|     DisplayMenu()->Scroll(true, true); | ||||
| } | ||||
|  | ||||
| void cSkindesignerOsdMenu::TextKeyRight(void) { | ||||
|     if (!displayText) | ||||
|         return; | ||||
|     DisplayMenu()->Scroll(false, true); | ||||
| } | ||||
|  | ||||
| void cSkindesignerOsdMenu::TextKeyUp(void) { | ||||
|     if (!displayText) | ||||
|         return; | ||||
|     DisplayMenu()->Scroll(true, false); | ||||
| } | ||||
|  | ||||
| void cSkindesignerOsdMenu::TextKeyDown(void) { | ||||
|     if (!displayText) | ||||
|         return; | ||||
|     DisplayMenu()->Scroll(false, false); | ||||
| } | ||||
|  | ||||
| void 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(); | ||||
| } | ||||
| @@ -1,84 +0,0 @@ | ||||
| #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 "services.h" | ||||
|  | ||||
| class cOsdView; | ||||
|  | ||||
| /********************************************************************** | ||||
| * cSkindesignerOsdObject | ||||
| **********************************************************************/ | ||||
| class cSkindesignerOsdObject : public cOsdObject { | ||||
| protected: | ||||
|     string pluginName; | ||||
|     cPlugin *pSkinDesigner; | ||||
|     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: | ||||
|     cSDDisplayMenu *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(cSDDisplayMenu *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; | ||||
|     cSDDisplayMenu *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 | ||||
|  | ||||
							
								
								
									
										94
									
								
								libskindesignerapi/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								libskindesignerapi/Makefile
									
									
									
									
									
										Normal file
									
								
							| @@ -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 | ||||
							
								
								
									
										31
									
								
								libskindesignerapi/skindesignerapi.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								libskindesignerapi/skindesignerapi.c
									
									
									
									
									
										Normal file
									
								
							| @@ -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; | ||||
| } | ||||
							
								
								
									
										38
									
								
								libskindesignerapi/skindesignerapi.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								libskindesignerapi/skindesignerapi.h
									
									
									
									
									
										Normal file
									
								
							| @@ -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 | ||||
| @@ -7,6 +7,7 @@ | ||||
|  */ | ||||
| #include <getopt.h> | ||||
| #include <vdr/plugin.h> | ||||
| #include <libskindesignerapi/skindesignerapi.h> | ||||
|  | ||||
| #define DEFINE_CONFIG 1 | ||||
| #include "config.h" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user