diff options
author | Bastian Wissler | 2009-08-26 16:46:16 +0200 |
---|---|---|
committer | Bastian Wissler | 2009-08-26 16:46:16 +0200 |
commit | 67064b9d58b1b514f15e06b62fcbe74945e31243 (patch) | |
tree | 62ef9f3e20229e795426e748ac026171dd806264 | |
parent | vmchooser bug: (diff) | |
download | vmchooser-67064b9d58b1b514f15e06b62fcbe74945e31243.tar.gz vmchooser-67064b9d58b1b514f15e06b62fcbe74945e31243.tar.xz vmchooser-67064b9d58b1b514f15e06b62fcbe74945e31243.zip |
Version 0.0.12 of vmchooser ;-)
===============================
* now omits <active> flag when starting xml explicitly
* reads <active param="false" /> and just does not display them
* fixed ugly bug, when the above mentioned flag was false ;-)
git-svn-id: http://svn.openslx.org/svn/openslx/openslx-src-tools/vmchooser/trunk@3135 95ad53e4-c205-0410-b2fa-d234c58c8868
-rw-r--r-- | vmchooser/CMakeLists.txt | 2 | ||||
-rw-r--r-- | vmchooser/SWindow.cxx | 1 | ||||
-rw-r--r-- | vmchooser/addPrinters.cxx | 2 | ||||
-rw-r--r-- | vmchooser/addScanners.cxx | 2 | ||||
-rw-r--r-- | vmchooser/main.cxx | 27 | ||||
-rw-r--r-- | vmchooser/readXmlDir.cxx | 13 |
6 files changed, 33 insertions, 14 deletions
diff --git a/vmchooser/CMakeLists.txt b/vmchooser/CMakeLists.txt index fd84407..bd3d9e7 100644 --- a/vmchooser/CMakeLists.txt +++ b/vmchooser/CMakeLists.txt @@ -38,4 +38,4 @@ target_link_libraries(vmchooser fltk2 fltk2_images xml2 Xi Xinerama X11 Xft ${Boost_LIBRARIES}) install(TARGETS vmchooser RUNTIME DESTINATION - "${OPENSLX_ROOT}/openslx/trunk/os-plugins/plugins/vmchooser/files/")
\ No newline at end of file + "${OPENSLX_ROOT}/openslx/trunk/os-plugins/plugins/vmchooser/files/") diff --git a/vmchooser/SWindow.cxx b/vmchooser/SWindow.cxx index cb2f6cc..0ec578a 100644 --- a/vmchooser/SWindow.cxx +++ b/vmchooser/SWindow.cxx @@ -169,6 +169,7 @@ void SWindow::set_entries(DataEntry** ent) entgroup = (ItemGroup*)sel.add_group("VMWARE SESSIONS", &sel); for (int i=0; ent[i] != '\0'; i++) { + if(!ent[i]->active) continue; Item* w= (Item*)sel.add_leaf(ent[i]->short_description.c_str(), entgroup, (void*)ent[i] ); xpmImage* xpm = new xpmImage(get_symbol(ent[i])); diff --git a/vmchooser/addPrinters.cxx b/vmchooser/addPrinters.cxx index 05f7cad..9ed0ab9 100644 --- a/vmchooser/addPrinters.cxx +++ b/vmchooser/addPrinters.cxx @@ -71,7 +71,7 @@ bool addPrinters(xmlNode* node, char* script) { // Parse input of printer-Skript (called by "char* script") // and write into <printer> nodes - if( bfs::is_regular_file(bfs::path(script)) ) + if( bfs::is_regular(bfs::path(script)) ) if( (inp = popen(script, "r" )) ) { while(fgets(line, MAX_LENGTH, inp ) != NULL) { strline = string(line); diff --git a/vmchooser/addScanners.cxx b/vmchooser/addScanners.cxx index 0dc75bd..c13d83e 100644 --- a/vmchooser/addScanners.cxx +++ b/vmchooser/addScanners.cxx @@ -71,7 +71,7 @@ bool addScanners(xmlNode* node, char* script) { // Parse input of scanner-Skript (called by "char* script") // and write into <scanner> nodes - if( bfs::is_regular_file(bfs::path(script)) ) + if( bfs::is_regular(bfs::path(script)) ) if( (inp = popen(script, "r" )) ) { while(fgets(line, MAX_LENGTH, inp ) != NULL) { strline = string(line); diff --git a/vmchooser/main.cxx b/vmchooser/main.cxx index 579e938..a029a3a 100644 --- a/vmchooser/main.cxx +++ b/vmchooser/main.cxx @@ -12,6 +12,10 @@ #include <libxml/tree.h> #include <libxml/xpath.h> +#include <boost/filesystem.hpp> + +namespace bfs=boost::filesystem; + using namespace std; using namespace fltk; @@ -30,6 +34,7 @@ SWindow* mainwin; * */ int main(int argc, char** argv) { + string version = "0.0.12"; AnyOption* opt = new AnyOption(); char* xmlpath = NULL; char* lsesspath = NULL; @@ -114,7 +119,7 @@ int main(int argc, char** argv) { /* VERSION */ if(opt->getFlag('v') || opt->getFlag("version")) { // just print out version information - helps testing - cout << "virtual machine chooser 0.0.11"<< endl; + cout << "virtual machine chooser " << version << endl; delete opt; return 0; @@ -159,15 +164,26 @@ int main(int argc, char** argv) { // additional xml argument -> start image directly if(opt->getArgc() > 0) { + string single_arg = opt->getArgv(0); + if(bfs::is_directory(single_arg)) { + fprintf(stderr, "Only argument is a folder, should be a valid xml file!\n"); + return 1; + } // read xml image - xmlDoc* doc = xmlReadFile(opt->getArgv(0), NULL, XML_PARSE_RECOVER); + xmlDoc* doc = xmlReadFile(single_arg.c_str(), NULL, XML_PARSE_RECOVER); if (doc == NULL) { - fprintf(stderr, "Error: could not parse file %s\n", opt->getArgv(0)); + fprintf(stderr, "Error: could not parse file %s\n", single_arg.c_str()); return 1; } DataEntry* result = get_entry(doc); - runImage(*result, opt->getArgv(0)); + if(result) { + runImage(*result, single_arg ); + } + else { + fprintf(stderr, "Error: can not start image from xml\n\tcheck your <active> setting!\n"); + return 1; + } } delete opt; @@ -201,7 +217,8 @@ int main(int argc, char** argv) { } win.show(); // argc,argv win.border(false); - free(xmlpath); + +// free(xmlpath); bool retval = run(); diff --git a/vmchooser/readXmlDir.cxx b/vmchooser/readXmlDir.cxx index d3a2f70..b90238b 100644 --- a/vmchooser/readXmlDir.cxx +++ b/vmchooser/readXmlDir.cxx @@ -204,10 +204,11 @@ DataEntry* get_entry(xmlDoc * doc) tempc = getAttribute(doc,(char *) "active"); if (tempc != NULL ) { de->active = (strstr(tempc,"true")!= NULL?true:false); - if(de->active == false) { - delete de; - return NULL; - } + // This has to be considered elsewhere + //if(de->active == false) { + // delete de; + // return NULL; + //} } tempc = NULL; @@ -278,10 +279,10 @@ DataEntry** readXmlDir(char* path) bfs::path filter(string(fpath).append("/").append(filterscript)); - if(bfs::is_regular_file(filter)) { + if(bfs::is_regular(filter)) { if( (inp = popen(string(fpath).append("/") .append(filterscript).append(" ") - .append(path).c_str(), "r" )) && bfs::is_regular_file(filter) ) { + .append(path).c_str(), "r" )) ) { while(fgets(line, MAX_LENGTH, inp ) != NULL) { xmlVec.push_back(string(line).substr(0,strlen(line)-1) ); } |