summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBastian Wissler2008-11-28 18:28:08 +0100
committerBastian Wissler2008-11-28 18:28:08 +0100
commit0a22f0e4a0cbc763d18c8a18af891cf4727ef2fc (patch)
tree508a9cbf57b9e3fd7b5cd06f2d7b6f48e4c1245e
parent vmchooser plugin: * changed version of binary (diff)
downloadvmchooser-0a22f0e4a0cbc763d18c8a18af891cf4727ef2fc.tar.gz
vmchooser-0a22f0e4a0cbc763d18c8a18af891cf4727ef2fc.tar.xz
vmchooser-0a22f0e4a0cbc763d18c8a18af891cf4727ef2fc.zip
vmchooser:
* added 10 secs messge to tell about image start * fixed bug with waiting on fork() git-svn-id: http://svn.openslx.org/svn/openslx/openslx-src-tools/vmchooser/trunk@2390 95ad53e4-c205-0410-b2fa-d234c58c8868
-rw-r--r--mesgdisp/Makefile13
-rw-r--r--mesgdisp/MessageWindow.cxx63
-rw-r--r--mesgdisp/MessageWindow.h10
-rw-r--r--vmchooser/Makefile4
-rw-r--r--vmchooser/inc/DataEntry.h3
-rw-r--r--vmchooser/main.cxx6
-rw-r--r--vmchooser/readXmlDir.cxx4
-rw-r--r--vmchooser/runImage.cxx42
8 files changed, 130 insertions, 15 deletions
diff --git a/mesgdisp/Makefile b/mesgdisp/Makefile
new file mode 100644
index 0000000..9eea0d7
--- /dev/null
+++ b/mesgdisp/Makefile
@@ -0,0 +1,13 @@
+CC=g++
+LIBS=-lXinerama -lXi -lXrender -lXft ../fltk-2/lib/libfltk2.a -I../fltk-2/include/
+
+TARGET=mesgdisp
+SRC=$(wildcard *.cxx)
+
+all: MessageWindow.cxx
+ $(CC) -o $(TARGET) $(SRC) $(LIBS)
+ strip $(TARGET)
+
+install: all
+ cp $(TARGET) ../../../../openslx/trunk/os-plugins/plugins/vmchooser/files/
+
diff --git a/mesgdisp/MessageWindow.cxx b/mesgdisp/MessageWindow.cxx
new file mode 100644
index 0000000..21f97ce
--- /dev/null
+++ b/mesgdisp/MessageWindow.cxx
@@ -0,0 +1,63 @@
+// generated by Fast Light User Interface Designer (fluid) version 2.1000
+
+#include "MessageWindow.h"
+#include <iostream>
+#include <string>
+#include <csignal>
+#include <fltk/run.h>
+
+fltk::Window *win=(fltk::Window *)0;
+fltk::TextDisplay *w_text=(fltk::TextDisplay *)0;
+
+
+
+
+void sig_handler(int sig) {
+ // just terminate after 10 seconds
+ // here we could change the text after each second ;-)
+ exit(0);
+}
+
+int main (int argc, char **argv) {
+
+ if(argc < 2 ) {
+ std::cout << "Please give some message to display!" << std::endl;
+ exit(1);
+ }
+
+ fltk::Window* w;
+ {
+ fltk::Window* o = win = new fltk::Window(510, 160);
+ o->border(false);
+ w = o;
+ o->shortcut(0xff1b);
+ o->begin();
+ {
+ fltk::Clock* o = new fltk::Clock(5, 5, 155, 150);
+ o->labelsize(16);
+ o->tooltip("Aktuelle Uhrzeit des Rechners");
+ }
+ {
+ fltk::TextDisplay* o = w_text = new fltk::TextDisplay(165, 5, 340, 150);
+ fltk::TextBuffer* buf = new fltk::TextBuffer();
+ buf->text(argv[1]);
+ o->tooltip("Dieses Fenster schließt automatisch nach 10 Sekunden");
+ o->buffer(buf);
+ o->box(fltk::UP_BOX);
+ o->color((fltk::Color)0xe0e0e000);
+ o->selection_textcolor((fltk::Color)0xffffff00);
+ o->labelsize(16);
+ o->textsize(16);
+ o->wrap_mode(true);
+ }
+ o->end();
+ o->resizable(o);
+ }
+
+ // set an alarm after 10 seconds
+ alarm(10);
+ signal(SIGALRM, sig_handler);
+
+ w->show();
+ return fltk::run();
+}
diff --git a/mesgdisp/MessageWindow.h b/mesgdisp/MessageWindow.h
new file mode 100644
index 0000000..16bd7de
--- /dev/null
+++ b/mesgdisp/MessageWindow.h
@@ -0,0 +1,10 @@
+// generated by Fast Light User Interface Designer (fluid) version 2.1000
+
+#ifndef MessageWindow_h
+#define MessageWindow_h
+#include <fltk/Window.h>
+extern fltk::Window* win;
+#include <fltk/Clock.h>
+#include <fltk/TextDisplay.h>
+extern fltk::TextDisplay* w_text;
+#endif
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