コード例 #1
0
ファイル: mmsswitcher.cpp プロジェクト: RomTok/disco-light
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;
}
コード例 #2
0
void Cmd::updateParameter() {
    MMSPluginData *plugindata;
    MMSPropertyData *parameterdata;
    MMSPluginParameterParser paramsparser;
    Console cons(true);
    string plugin;
    string parameter;
    string value;


    plugin=cmdline[MMSCMD_PLUGIN];
    parameter=cmdline[MMSCMD_PARAM];
    value=cmdline[MMSCMD_VALUE];

    if(plugin.empty()) {
    	/*cons.printError("No plugin given to update. See cmd --help for further information.");
    	exit(1);*/
    	plugin="-2";
    }
    if(parameter.empty()) {
    	cons.printError("No parameter given to update. See cmd --help for further information.");
    	exit(1);
    }
    if(value.empty()) {
    	cons.printError("No parameter value given to update. See cmd --help for further information.");
    	exit(1);
    }

    MMSPluginService service(datasource);

    if(isdigit(plugin.c_str())||plugin=="-2")
        plugindata = service.getPluginByID(atoi(plugin.c_str()));
    else
        plugindata = service.getPluginByName(plugin);

    if(plugindata == NULL) {
        string mess = "A plugin with name or id @[1m" + plugin + "@[0m was not found!";
        cons.printText((char *)mess.c_str());
        exit(1);
    }

    //paramsparser.createProperty(plugindata,parameter);

    parameterdata = plugindata->getProperty(parameter);

    parameterdata->setValue(value);

    service.setPlugin(plugindata);

    cons.printText("Parameter sucessfully updated.");

}
コード例 #3
0
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);
    }

}
コード例 #4
0
ファイル: mmsswitcher.cpp プロジェクト: RomTok/disco-light
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());
    }
}
コード例 #5
0
ファイル: mmsswitcher.cpp プロジェクト: RomTok/disco-light
void MMSSwitcher::onSelectItem(MMSWidget *widget) {
	if (!widget)
        widget = this->menu->getSelectedItem();

    // no menu item given
    if (!widget)
        return;

    // set the static menu
    if (this->menu_static)
    	this->menu_static->setSelected(menu->getSelected());

    MMSPluginData *data = (MMSPluginData*)widget->getBinData();

    // return if current plugin is selected plugin
    if(this->curr_plugin == data->getId())
        return;


    // hide all previews
    /*for (map<int, plugin_data_t *>::iterator i = this->plugins.begin(); i != this->plugins.end(); i++) {
    	vector<MMSChildWindow *> *wins = &(i->second->previewWins);
    	for (unsigned int j = 0; j < wins->size(); j++) {
    		MMSChildWindow *cw = wins->at(j);
    		cw->hide();
            cw->waitUntilHidden();
    	}
    }
    */

    // set current plugin
    this->curr_plugin = data->getId();

    // tell the switcher thread to invoke show preview
    this->switcherThread->invokeShowPreview();
}
コード例 #6
0
void Cmd::executeAct() {
    Console cons(true);
    string pluginname;

    MMSPluginService service(datasource);

    pluginname = cmdline["plugin"];
    if(pluginname.empty()) {
    	cons.printError("no plugin given to activate");
    	exit(1);
    }

    if(isdigit(pluginname.c_str())) {
        //we have a plugin id;
        MMSPluginData *plugin = service.getPluginByID(atoi(pluginname.c_str()));
        if(plugin != NULL) {
            if(plugin->getActive()==true) {
                string message = "plugin with id @[1m" + pluginname + "@[0m is already active.";
                cons.printText((char *)message.c_str());
                exit(0);
            }

            plugin->setActive(true);
            service.setPlugin(plugin);
            string message = "plugin with id @[1m" + pluginname + "@[0m sucessfully set to @[1mactive@[0m.";
            cons.printText((char *)message.c_str());

        } else {
            string message = "no plugin with id @[1m" + pluginname + "@[0m found.";
            cons.printText((char *)message.c_str());

        }

    } else {
        //it looks like a name
        MMSPluginData *plugin = service.getPluginByName(pluginname);
        if(plugin != NULL) {
            if(plugin->getActive()==true) {
                string message = "plugin " + pluginname + " is already active.";
                cons.printText((char *)message.c_str());
                exit(0);
            }

            plugin->setActive(true);
            service.setPlugin(plugin);
            string message = "plugin @[1m" + pluginname + "@[0m sucessfully set to @[1mactive@[0m.";
            cons.printText((char *)message.c_str());
        }else {
            string message = "no plugin with name @[1m" + pluginname + "@[0m found.";
            cons.printText((char *)message.c_str());
        }
    }
}
コード例 #7
0
ファイル: mmsswitcher.cpp プロジェクト: RomTok/disco-light
void MMSSwitcher::setMenuItemValues(MMSWidget *item) {
	// get the plugin data
	if (!item) return;
	MMSPluginData *plugindata = (MMSPluginData *)item->getBinData();

	// set the plugin name
	MMSLabelWidget *pluginName = dynamic_cast<MMSLabelWidget*>(item->findWidget(SWITCHER_MENU_PLUGINNAME));
    if (pluginName) pluginName->setText(plugindata->getName());

    // set the plugin title
    MMSLabelWidget *pluginTitle = dynamic_cast<MMSLabelWidget*>(item->findWidget(SWITCHER_MENU_PLUGINTITLE));
    if (pluginTitle) pluginTitle->setText(plugindata->getTitle());

    // set the plugin icon
    MMSImageWidget *pluginIcon = dynamic_cast<MMSImageWidget*>(item->findWidget(SWITCHER_MENU_PLUGINICON));
    if (pluginIcon) {
        string path;
        string name;

        name = plugindata->getIcon();
		if (!searchingForImage(plugindata->getPath(), name, &path))
            if (!path.empty())
            	pluginIcon->setImage(path, name);
            else
				pluginIcon->setImageName(name);
		else
            pluginIcon->setImageName("plugin_icon.png");

        name = plugindata->getSelectedIcon();
		if (!searchingForImage(plugindata->getPath(), name, &path))
            if (!path.empty())
            	pluginIcon->setSelImage(path, name);
            else
				pluginIcon->setSelImageName(name);
		else
            pluginIcon->setSelImageName("plugin_icon_s.png");
    }
}