- plugins: simplify integratePlugins(); ...

* CPluginsExec(): switch to singleton
* move CPluginsExec() to pluginlist.cpp|h
  because it's not really a settings_helper
This commit is contained in:
svenhoefer
2014-11-10 22:41:08 +01:00
parent 02137ca987
commit 389c4c232f
11 changed files with 55 additions and 52 deletions

View File

@@ -105,8 +105,7 @@ int CInfoMenu::showMenu()
} }
//add I_TYPE_INFORMATION plugins //add I_TYPE_INFORMATION plugins
CPluginsExec pluginsExec; info->integratePlugins(CPlugins::I_TYPE_INFORMATION, 1);
info->integratePlugins(&pluginsExec, CPlugins::I_TYPE_INFORMATION, 1);
int res = info->exec(NULL, ""); int res = info->exec(NULL, "");
delete info; delete info;

View File

@@ -260,9 +260,8 @@ int CMediaPlayerMenu::initMenuMedia(CMenuWidget *m, CPersonalizeGui *p)
personalize->addPersonalizedItems(); personalize->addPersonalizedItems();
//add I_TYPE_MULTIMEDIA plugins //add I_TYPE_MULTIMEDIA plugins
CPluginsExec pluginsExec;
unsigned int nextShortcut = (unsigned int)media->getNextShortcut(); unsigned int nextShortcut = (unsigned int)media->getNextShortcut();
media->integratePlugins(&pluginsExec, CPlugins::I_TYPE_MULTIMEDIA, nextShortcut); media->integratePlugins(CPlugins::I_TYPE_MULTIMEDIA, nextShortcut);
res = media->exec(NULL, ""); res = media->exec(NULL, "");
delete media; delete media;

View File

@@ -137,3 +137,40 @@ int CPluginChooser::run()
*selectedFilePtr = g_PluginList->getFileName(number); *selectedFilePtr = g_PluginList->getFileName(number);
return menu_return::RETURN_EXIT; return menu_return::RETURN_EXIT;
} }
CPluginsExec* CPluginsExec::getInstance()
{
static CPluginsExec* pluginsExec = NULL;
if (!pluginsExec)
pluginsExec = new CPluginsExec();
return pluginsExec;
}
int CPluginsExec::exec(CMenuTarget* parent, const std::string & actionKey)
{
if (actionKey.empty())
return menu_return::RETURN_NONE;
//printf("CPluginsExec exec: %s\n", actionKey.c_str());
int sel = atoi(actionKey.c_str());
if (parent != NULL)
parent->hide();
if (actionKey == "teletext") {
g_RCInput->postMsg(CRCInput::RC_timeout, 0);
g_RCInput->postMsg(CRCInput::RC_text, 0);
}
else if (sel >= 0)
g_PluginList->startPlugin(sel);
if (!g_PluginList->getScriptOutput().empty())
ShowMsg(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_SHELL);
if (g_PluginList->getIntegration(sel) == CPlugins::I_TYPE_DISABLED)
return menu_return::RETURN_EXIT;
return menu_return::RETURN_REPAINT;
}

View File

@@ -67,4 +67,11 @@ class CPluginChooser : public CPluginList
int run (); int run ();
}; };
class CPluginsExec : public CMenuTarget
{
public:
static CPluginsExec* getInstance();
int exec(CMenuTarget* parent, const std::string & actionKey);
};
#endif #endif

View File

@@ -151,7 +151,6 @@ bool CUserMenu::showUserMenu(neutrino_msg_t msg)
// define classes // define classes
CSubChannelSelectMenu subchanselect; CSubChannelSelectMenu subchanselect;
CPluginsExec plugins;
CNeutrinoApp * neutrino = CNeutrinoApp::getInstance(); CNeutrinoApp * neutrino = CNeutrinoApp::getInstance();
std::string txt = g_settings.usermenu[button]->title; std::string txt = g_settings.usermenu[button]->title;
@@ -318,7 +317,7 @@ bool CUserMenu::showUserMenu(neutrino_msg_t msg)
neutrino_msg_t d_key = g_PluginList->getKey(count); neutrino_msg_t d_key = g_PluginList->getKey(count);
//printf("[neutrino usermenu] plugin %d, set key %d...\n", count, g_PluginList->getKey(count)); //printf("[neutrino usermenu] plugin %d, set key %d...\n", count, g_PluginList->getKey(count));
keyhelper.get(&key,&icon, d_key); keyhelper.get(&key,&icon, d_key);
menu_item = new CMenuForwarder(g_PluginList->getName(count), true, NULL, &plugins, to_string(count).c_str(), key, icon); menu_item = new CMenuForwarder(g_PluginList->getName(count), true, NULL, CPluginsExec::getInstance(), to_string(count).c_str(), key, icon);
menu_item->setHint(g_PluginList->getHintIcon(count), g_PluginList->getDescription(count)); menu_item->setHint(g_PluginList->getHintIcon(count), g_PluginList->getDescription(count));
menu->addItem(menu_item, false); menu->addItem(menu_item, false);
@@ -329,7 +328,7 @@ bool CUserMenu::showUserMenu(neutrino_msg_t msg)
} }
case SNeutrinoSettings::ITEM_VTXT: case SNeutrinoSettings::ITEM_VTXT:
keyhelper.get(&key,&icon, feat_key[g_settings.personalize[SNeutrinoSettings::P_FEAT_KEY_VTXT]].key); //CRCInput::RC_blue keyhelper.get(&key,&icon, feat_key[g_settings.personalize[SNeutrinoSettings::P_FEAT_KEY_VTXT]].key); //CRCInput::RC_blue
menu_item = new CMenuForwarder(LOCALE_USERMENU_ITEM_VTXT, true, NULL, &plugins, "teletext", key, icon); menu_item = new CMenuForwarder(LOCALE_USERMENU_ITEM_VTXT, true, NULL, CPluginsExec::getInstance(), "teletext", key, icon);
// FIXME menu_item->setHint("", NONEXISTANT_LOCALE); // FIXME menu_item->setHint("", NONEXISTANT_LOCALE);
break; break;
case SNeutrinoSettings::ITEM_IMAGEINFO: case SNeutrinoSettings::ITEM_IMAGEINFO:
@@ -431,7 +430,7 @@ bool CUserMenu::showUserMenu(neutrino_msg_t msg)
if (pname && (std::string(pname) == *it) && !g_PluginList->isHidden(count)) { if (pname && (std::string(pname) == *it) && !g_PluginList->isHidden(count)) {
neutrino_msg_t d_key = g_PluginList->getKey(count); neutrino_msg_t d_key = g_PluginList->getKey(count);
keyhelper.get(&key,&icon, d_key); keyhelper.get(&key,&icon, d_key);
menu_item = new CMenuForwarder(g_PluginList->getName(count), true, NULL, &plugins, to_string(count).c_str(), key, icon); menu_item = new CMenuForwarder(g_PluginList->getName(count), true, NULL, CPluginsExec::getInstance(), to_string(count).c_str(), key, icon);
menu_item->setHint(g_PluginList->getHintIcon(count), g_PluginList->getDescription(count)); menu_item->setHint(g_PluginList->getHintIcon(count), g_PluginList->getDescription(count));
break; break;
} }

View File

@@ -35,6 +35,7 @@
#include <driver/fontrenderer.h> #include <driver/fontrenderer.h>
#include <driver/screen_max.h> #include <driver/screen_max.h>
#include <gui/pluginlist.h>
#include <gui/widget/stringinput.h> #include <gui/widget/stringinput.h>
#include <neutrino_menue.h> #include <neutrino_menue.h>
@@ -966,11 +967,9 @@ int CMenuWidget::exec(CMenuTarget* parent, const std::string &)
return retval; return retval;
} }
void CMenuWidget::integratePlugins(void *pluginsExec, CPlugins::i_type_t integration, const unsigned int shortcut) void CMenuWidget::integratePlugins(CPlugins::i_type_t integration, const unsigned int shortcut)
{ {
CPluginsExec *_pluginsExec = static_cast<CPluginsExec*>(pluginsExec);
bool separatorline = false; bool separatorline = false;
char id_plugin[5];
unsigned int number_of_plugins = (unsigned int) g_PluginList->getNumberOfPlugins(); unsigned int number_of_plugins = (unsigned int) g_PluginList->getNumberOfPlugins();
unsigned int sc = shortcut; unsigned int sc = shortcut;
for (unsigned int count = 0; count < number_of_plugins; count++) for (unsigned int count = 0; count < number_of_plugins; count++)
@@ -983,9 +982,8 @@ void CMenuWidget::integratePlugins(void *pluginsExec, CPlugins::i_type_t integra
separatorline = true; separatorline = true;
} }
printf("[neutrino] integratePlugins: add %s\n", g_PluginList->getName(count)); printf("[neutrino] integratePlugins: add %s\n", g_PluginList->getName(count));
sprintf(id_plugin, "%d", count);
neutrino_msg_t dk = (shortcut != CRCInput::RC_nokey) ? CRCInput::convertDigitToKey(sc++) : CRCInput::RC_nokey; neutrino_msg_t dk = (shortcut != CRCInput::RC_nokey) ? CRCInput::convertDigitToKey(sc++) : CRCInput::RC_nokey;
CMenuForwarder *fw_plugin = new CMenuForwarder(g_PluginList->getName(count), true, NULL, _pluginsExec, id_plugin, dk); CMenuForwarder *fw_plugin = new CMenuForwarder(g_PluginList->getName(count), true, NULL, CPluginsExec::getInstance(), to_string(count).c_str(), dk);
fw_plugin->setHint(g_PluginList->getHintIcon(count), g_PluginList->getDescription(count)); fw_plugin->setHint(g_PluginList->getHintIcon(count), g_PluginList->getDescription(count));
addItem(fw_plugin); addItem(fw_plugin);
} }

View File

@@ -568,7 +568,7 @@ class CMenuWidget : public CMenuTarget
virtual void hide(); virtual void hide();
virtual int exec(CMenuTarget* parent, const std::string & actionKey); virtual int exec(CMenuTarget* parent, const std::string & actionKey);
virtual const char *getName(); virtual const char *getName();
virtual void integratePlugins(void *pluginsExec, CPlugins::i_type_t integration, const unsigned int shortcut=CRCInput::RC_nokey); virtual void integratePlugins(CPlugins::i_type_t integration, const unsigned int shortcut=CRCInput::RC_nokey);
void setSelected(const int &Preselected){ preselected = Preselected; }; void setSelected(const int &Preselected){ preselected = Preselected; };
int getSelected()const { return selected; }; int getSelected()const { return selected; };
void move(int xoff, int yoff); void move(int xoff, int yoff);

View File

@@ -74,7 +74,6 @@ public:
private: private:
CPluginsExec pluginsExec;
CFrameBuffer * frameBuffer; CFrameBuffer * frameBuffer;
CConfigFile configfile; CConfigFile configfile;

View File

@@ -129,12 +129,12 @@ void CNeutrinoApp::InitMenu()
unsigned int nextShortcut; unsigned int nextShortcut;
CMenuWidget &menuSettings = personalize.getWidget(MENU_SETTINGS); CMenuWidget &menuSettings = personalize.getWidget(MENU_SETTINGS);
nextShortcut = (unsigned int)menuSettings.getNextShortcut(); nextShortcut = (unsigned int)menuSettings.getNextShortcut();
menuSettings.integratePlugins(&pluginsExec, CPlugins::I_TYPE_SETTING, nextShortcut); menuSettings.integratePlugins(CPlugins::I_TYPE_SETTING, nextShortcut);
//add I_TYPE_SERVICE plugins //add I_TYPE_SERVICE plugins
CMenuWidget &menuService = personalize.getWidget(MENU_SERVICE); CMenuWidget &menuService = personalize.getWidget(MENU_SERVICE);
nextShortcut = (unsigned int)menuService.getNextShortcut(); nextShortcut = (unsigned int)menuService.getNextShortcut();
menuService.integratePlugins(&pluginsExec, CPlugins::I_TYPE_SERVICE, nextShortcut); menuService.integratePlugins(CPlugins::I_TYPE_SERVICE, nextShortcut);
} }
//init main menu //init main menu

View File

@@ -367,35 +367,6 @@ int CNVODChangeExec::exec(CMenuTarget* parent, const std::string & actionKey)
return menu_return::RETURN_EXIT; return menu_return::RETURN_EXIT;
} }
int CPluginsExec::exec(CMenuTarget* parent, const std::string & actionKey)
{
if (actionKey.empty())
return menu_return::RETURN_NONE;
//printf("CPluginsExec exec: %s\n", actionKey.c_str());
int sel= atoi(actionKey.c_str());
if(parent != NULL)
parent->hide();
if(actionKey == "teletext") {
g_RCInput->postMsg(CRCInput::RC_timeout, 0);
g_RCInput->postMsg(CRCInput::RC_text, 0);
}
else if (sel>=0)
{
g_PluginList->startPlugin(sel);
}
if (!g_PluginList->getScriptOutput().empty())
ShowMsg(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_SHELL);
if (g_PluginList->getIntegration(sel) == CPlugins::I_TYPE_DISABLED)
return menu_return::RETURN_EXIT;
return menu_return::RETURN_REPAINT;
}
int CMoviePluginChangeExec::exec(CMenuTarget* parent, const std::string & actionKey) int CMoviePluginChangeExec::exec(CMenuTarget* parent, const std::string & actionKey)
{ {
int sel= atoi(actionKey.c_str()); int sel= atoi(actionKey.c_str());

View File

@@ -115,12 +115,6 @@ class CNVODChangeExec : public CMenuTarget
int exec(CMenuTarget* parent, const std::string & actionKey); int exec(CMenuTarget* parent, const std::string & actionKey);
}; };
class CPluginsExec : public CMenuTarget
{
public:
int exec(CMenuTarget* parent, const std::string & actionKey);
};
class CMoviePluginChangeExec : public CMenuTarget class CMoviePluginChangeExec : public CMenuTarget
{ {
public: public: