diff options
Diffstat (limited to 'vmchooser')
-rw-r--r-- | vmchooser/Makefile | 4 | ||||
-rw-r--r-- | vmchooser/inc/DataEntry.h | 3 | ||||
-rw-r--r-- | vmchooser/main.cxx | 6 | ||||
-rw-r--r-- | vmchooser/readXmlDir.cxx | 4 | ||||
-rw-r--r-- | vmchooser/runImage.cxx | 42 |
5 files changed, 44 insertions, 15 deletions
diff --git a/vmchooser/Makefile b/vmchooser/Makefile index e1ce821..6bc1390 100644 --- a/vmchooser/Makefile +++ b/vmchooser/Makefile @@ -25,13 +25,13 @@ debug: ${OBJS} ${CC} ${LDFLAGS} -o vmchooserdbg $^ ${LIBS} ${OBJS}: %.o: %.cxx %.dep - ${CC} ${CCFLAGS} -o $@ -c $< + ${CC} ${DEBUG_CCFLAGS} -o $@ -c $< ${DEPS}: %.dep: %.cxx Makefile ${CC} ${CCFLAGS} -MM $< > $@ clean:: - rm -f *~ *.o ${TARGET} + rm -f *~ *.o ${TARGET} vmchooserdbg install: cp vmchooser ../../../../openslx/trunk/os-plugins/plugins/vmchooser/files/ diff --git a/vmchooser/inc/DataEntry.h b/vmchooser/inc/DataEntry.h index 2f59615..e012a4b 100644 --- a/vmchooser/inc/DataEntry.h +++ b/vmchooser/inc/DataEntry.h @@ -8,7 +8,8 @@ using namespace std; enum ImgType { LINUX, VMWARE, - VBOX + VBOX, + OTHER }; struct DataEntry { diff --git a/vmchooser/main.cxx b/vmchooser/main.cxx index 70c2d9d..fb2db46 100644 --- a/vmchooser/main.cxx +++ b/vmchooser/main.cxx @@ -11,7 +11,7 @@ using namespace std; using namespace fltk; - +SWindow* mainwin; /** * MAIN * @@ -62,6 +62,7 @@ int main(int argc, char** argv) { if(opt->getValue("path")!= NULL) { xmlpath = opt->getValue("path"); } + if (xmlpath == NULL) { // Default Path comes here xmlpath = (char *) "/var/lib/vmware/vmconfigs/"; @@ -111,7 +112,7 @@ int main(int argc, char** argv) { delete opt; // just print out version information - helps testing - cout << "virtual machine chooser 0.0.5"<< endl; + cout << "virtual machine chooser 0.0.6"<< endl; if(version) { exit(1); } @@ -129,6 +130,7 @@ int main(int argc, char** argv) { lsessions = readLinSess(lsesspath); SWindow& win = *SWindow::getInstance(width, height); + mainwin = &win; if(lsessions[0] != NULL) { win.set_lin_entries(lsessions); diff --git a/vmchooser/readXmlDir.cxx b/vmchooser/readXmlDir.cxx index de6afed..44188d1 100644 --- a/vmchooser/readXmlDir.cxx +++ b/vmchooser/readXmlDir.cxx @@ -171,8 +171,10 @@ DataEntry* get_entry(xmlDoc * doc) if (tempc != NULL ) { if ( strcmp(tempc,"vmware") == 0 ) { de->imgtype = VMWARE; - } else { + } else if (strcmp(tempc,"virtualbox") == 0) { de->imgtype = VBOX; + } else { + de->imgtype = OTHER; } } else { diff --git a/vmchooser/runImage.cxx b/vmchooser/runImage.cxx index 7810314..789098c 100644 --- a/vmchooser/runImage.cxx +++ b/vmchooser/runImage.cxx @@ -1,4 +1,6 @@ #include <fltk/Widget.h> +#include <fltk/ask.h> +#include <fltk/run.h> #include "inc/DataEntry.h" #include "inc/SWindow.h" @@ -12,9 +14,10 @@ #include <string> #include <boost/regex.hpp> + /* define MAX_LENGTH for string in getFolderName */ const int MAX_LENGTH = 200; - +extern SWindow* mainwin; /** ************************************************************* * void runImage runs a (virtual machine) image using fork() @@ -31,26 +34,38 @@ void runImage(fltk::Widget*, void* p) DataEntry& dat = *((DataEntry*) p); - if(dat.imgtype == VMWARE) { + if(dat.imgtype == VMWARE || dat.imgtype == VBOX ) { confxml = writeConfXml(dat); } pid_t pid; - int status; + // in case you want to wait hours on your thread + //int status; pid = fork(); + char* argv[] = { "mesgdisp", ///opt/openslx/plugin-repo/vmchooser/ + (char*) string("\n\nStarte Image: ").append(dat.short_description) + .append("\n").c_str(), NULL }; switch( pid ) { case -1: - cout << "Something went wrong while forking!" << endl; + fltk::alert("Error occured during forking a thread of execution!"); return; break; case 0: - exit(0); + mainwin->destroy(); + fltk::wait(); + cout << "calling " << argv[1] << endl; + execvp(argv[0], argv); break; default: - if( waitpid( pid, &status, 0 ) == -1 ) { - cerr << "No child with this pid (" << pid << ")" << endl; - } + // this is not really useful, as this + // blocks execution for about 5 seconds + // sometimes ;-) + //if( waitpid( pid, &status, 0 ) == -1 ) { + // cerr << "No child with this pid (" << pid << ")" << endl; + // fltk::alert("Failed to create child thread!"); + // return; + //} runImage(dat, confxml); break; } @@ -72,6 +87,15 @@ string runImage(DataEntry& dat, string confxml) //cout << arg << endl; //"run-vmware.sh imagename os (Window-Title) network" execvp("/var/X11R6/bin/run-vmware.sh", arg); } + if (dat.imgtype == VBOX) { + char* arg[] = { (char *) "/var/X11R6/bin/run-virtualbox.sh", + (char*)confxml.c_str(), + NULL }; + + //cout << arg << endl; //"run-vmware.sh imagename os (Window-Title) network" + execvp("/var/X11R6/bin/run-virtualbox.sh", arg); + + } if(! dat.command.empty() ) { char* arg[] = { (char*) dat.command.c_str(), '\0' }; execvp((char*) dat.command.c_str(), arg); @@ -138,7 +162,7 @@ string writeConfXml(DataEntry& dat) { // add "printers" and "scanners" - XML-Nodes addPrinters(root, (char*)pskript.c_str()); - pskript = pname + "/scanners.sh"; + pskript = pname + "/scanner.sh"; addScanners(root, (char*)pskript.c_str()); // add hostname and username information |