bool MMSSwitcher::switchToPluginEx(int toplugin) { if (toplugin >= 0) { try { MMSPluginData *data = &this->plugins[toplugin]->plugindata; if(!data) { DEBUGMSG("Switcher", "Plugin with ID = %d not found", toplugin); return false; } if(data->getType()->getName() == "OSD_PLUGIN") { MMSOSDPluginHandler *handler = this->pluginmanager->getOSDPluginHandler(data->getId()); handler->invokeShow(NULL); } else if(data->getType()->getName() == "CENTRAL_PLUGIN") { MMSCentralPluginHandler *handler = this->pluginmanager->getCentralPluginHandler(data->getId()); handler->invokeShow(NULL); } return true; } catch(MMSError &error) { DEBUGMSG("Switcher", "Abort due to: " + error.getMessage()); } } return false; }
void MMSSwitcher::onReturn(MMSWidget *widget) { try { // get the selected item widget = this->menu->getSelectedItem(); // get access to the plugin data MMSPluginData *data = (MMSPluginData*)widget->getBinData(); // invoke show if(data->getType()->getName() == "OSD_PLUGIN") { MMSOSDPluginHandler *handler = this->pluginmanager->getOSDPluginHandler(data->getId()); handler->invokeShow(NULL); } else if(data->getType()->getName() == "CENTRAL_PLUGIN") { MMSCentralPluginHandler *handler = this->pluginmanager->getCentralPluginHandler(data->getId()); handler->invokeShow(NULL); } } catch(MMSError &error) { DEBUGMSG("Switcher", "Abort due to: " + error.getMessage()); } }
void Cmd::executeExec() { MMSPluginService service(datasource); string import=cmdline["import"]; MMSPluginData *data = NULL; if(import.empty()) { cons.printError("No import plugin is given to execute. See cmd --help for further information."); exit(1); } if(isdigit(import.c_str())) data = service.getPluginByID(atoi(import.c_str())); else data = service.getPluginByName(import); if(data!=NULL) { if(data->getType()->getName() != PT_IMPORT_PLUGIN) { char text[1024]; sprintf(text, "Plugin with name or id %s is not an import plugin. ", import.c_str()); cons.printError(text); exit(1); } MMSImportPluginHandler myhandler = MMSImportPluginHandler(*data, true); myhandler.invokeInitialize(NULL); char text[1024]; sprintf(text,"executing import %s. ", data->getName().c_str()); cons.linefeed(); cons.printText(text); myhandler.invokeExecute(NULL); sprintf(text,"import %s sucessfully executed. ", data->getName().c_str()); cons.printText(text); } else { char text[1024]; sprintf(text, "Import plugin with name or id %s not found.", import.c_str()); cons.printError(text); exit(1); } }