I need help coding plugin to start an other
emanuel 27 jan 2008
Hi draemies,
I have got problems coding a plugin, which can start all other Plugins.
Can you help me finding a solution?
First I have tryed to start like this:
but the Plugin crashed.
then I found a solution, but it only can start Plugins like jukebox, rss, ...
trying to start tuxtxt, tuxcom, failed/or crashed with reboot. Tuxterm for Example crashes enigma-skin.
thanks a lot
CU Emanuel
I have got problems coding a plugin, which can start all other Plugins.
Can you help me finding a solution?
First I have tryed to start like this:
eZapPlugins plugins(eZapPlugins::StandardPlugin); if ( plugins.execPluginByName("tuxtxt.cfg") != "OK" ) plugins.execPluginByName("_tuxtxt.cfg");
but the Plugin crashed.
then I found a solution, but it only can start Plugins like jukebox, rss, ...
trying to start tuxtxt, tuxcom, failed/or crashed with reboot. Tuxterm for Example crashes enigma-skin.
#include <stdio.h> #include <plugin.h> #include <dlfcn.h> #include <lib/gui/ewindow.h> #include <lib/gui/elabel.h> #include <lib/gui/ebutton.h> #include <lib/gui/emessage.h> #include <src/enigma.h> //funktions int pl_exec(char *filename); char * find_file (const char *file); //find_file checking path to plugins char * find_file (const char *file) { struct stat st; static char filename[256]; printf ("FINDFILE: file=(%s)\n", file); sprintf ( filename, "/usr/lib/tuxbox/plugins/%s", file); if (stat (filename, &st) == 0) return filename; sprintf ( filename, "/var/tuxbox/plugins/%s", file); if (stat (filename, &st) == 0) return filename; sprintf ( filename, "/lib/tuxbox/plugins/%s", file); if (stat (filename, &st) == 0) return filename; sprintf ( filename, "/var/bin/%s", file); if (stat (filename, &st) == 0) return filename; sprintf ( filename, "/usr/bin/%s", file); if (stat (filename, &st) == 0) return filename; sprintf ( filename, "/bin/%s", file); if (stat (filename, &st) == 0) return filename; //printf ("NOT FOUND\n"); strcpy (filename, file); return filename; } //controlling handle of plugins int pl_exec(char *so) { int ok = 0; void *handle; char filename[256]; char *error; int (*do_plugin_exec) (PluginParam * par); strcpy (filename, find_file (so) ); ok = 1; if (ok == 1) { handle = dlopen (filename, RTLD_GLOBAL | RTLD_NOW); if (!handle) { fprintf (stderr, "%s\n", dlerror ()); ok = 0; } dlerror (); /* Clear any existing error */ *(void **) (&do_plugin_exec) = dlsym (handle, "plugin_exec"); if ((error = dlerror ()) != NULL) { fprintf (stderr, "%s\n", error); ok = 0; } if (ok == 1) { (*do_plugin_exec) (NULL); dlclose (handle); } } return ok; } // The Class declaration of our Main Window class MyMainWindow: public eWindow { // the label1 to show the text eLabel *label1; // the button eButton *button_ok; eString *plug; void MyMainWindow::exeplug(); public: // the constructor. MyMainWindow(); // the destructor. ~MyMainWindow(); }; // The plugin entry point, Here start the code execution extern "C" int plugin_exec( PluginParam *par ) { // our demo dialog instance. MyMainWindow dlg; // show the dialog... dlg.show(); // give control to dialog.. (the dialog is modal!) int result=dlg.exec(); // and after it, hide it again. dlg.hide(); return result; } //exec a plugin void MyMainWindow::exeplug() { this->hide(); if ( !pl_exec("jukebox.so") ) { eMessageBox msg (_("Cannot find the 'jukebox.so' plugin"), _("Cannot find plugin"), eMessageBox::btOK | eMessageBox::iconError); msg.show (); msg.exec (); msg.hide (); } this->show (); } MyMainWindow::MyMainWindow(): eWindow(1) { // move our dialog to 100.100... cmove(ePoint(100, 100)); // ...and give x and y dimensions. cresize(eSize(520, 376)); // set a title. setText("panel"); // create a label1 to show a text. label1=new eLabel(this); // give a position label1->move(ePoint(50, 50)); // set the label1 dimensions label1->resize(eSize(300, 100)); // set the label1 text label1->setText("Press Button to launch jukebox!!"); // create the button button_ok = new eButton(this); // set the button text button_ok->setText("start"); // set position button_ok->move(ePoint((clientrect.width() - 90)/2, clientrect.height() - 60)); // set size button_ok->resize(eSize(90, 40)); // set shortcut and pixmap button_ok->setShortcut("green"); button_ok->setShortcutPixmap("green"); // decore with a frame button_ok->loadDeco(); // function to call when buton is pressed CONNECT(button_ok->selected, MyMainWindow::exeplug); // set focus to the button setFocus(button_ok); } MyMainWindow::~MyMainWindow() { }
thanks a lot
CU Emanuel
pieterg 27 jan 2008
To be honest, I don't think a plugin was ever supposed to start another plugin.
Only enigma can do that, and it stays in a 'loop' while the plugin is running, this code was never meant to be reentrant.
Only enigma can do that, and it stays in a 'loop' while the plugin is running, this code was never meant to be reentrant.
ims 27 jan 2008
Why you dont use call plugins from own PPanel ?
...
<plugin name="Bitrate viewer"
target="bitrate.cfg"
helptext="Bitrate viewer"/>
...
...
<plugin name="Bitrate viewer"
target="bitrate.cfg"
helptext="Bitrate viewer"/>
...
emanuel 27 jan 2008
Hi,
yes it stands in a loop, waiting for the exit of the embeded plugin "jukebox" like the Enigma EXTENTION-plugins eWidged do too.
This is no problem.
using PPanel: If there is a way to start a userdefined *.XML direkt from the yellowbutton, and having the common PPanel on bluebutton. It would be a good solution for me, but for other imageuser this plugin should work to. (sorting plugins, scrips, ...)
CU Emanuel;)
yes it stands in a loop, waiting for the exit of the embeded plugin "jukebox" like the Enigma EXTENTION-plugins eWidged do too.
This is no problem.
using PPanel: If there is a way to start a userdefined *.XML direkt from the yellowbutton, and having the common PPanel on bluebutton. It would be a good solution for me, but for other imageuser this plugin should work to. (sorting plugins, scrips, ...)
CU Emanuel;)
pieterg 27 jan 2008
I don't mean the widget run loop, but the plugin exec loop. It's not built to be reentrant.
emanuel 27 jan 2008
I understand,
but the flexmenu-plugin for example kann do that.
by executing sh:
I think flexmenu exit, an starts then the script, but how - I don't know.
CU Emanuel
but the flexmenu-plugin for example kann do that.
by executing sh:
wget -O- http://root:dreambox@127.0.0.1/cgi-bin/startPlugin?name=jukebox.cfg
I think flexmenu exit, an starts then the script, but how - I don't know.
CU Emanuel
emanuel 27 jan 2008
flexmenu is only translated by a member of Gemini for DB.
It comes from dbox, supported by keyword.
but src is closed.
It comes from dbox, supported by keyword.
but src is closed.