summaryrefslogtreecommitdiffstats
path: root/vmchooser/main.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'vmchooser/main.cxx')
-rw-r--r--vmchooser/main.cxx61
1 files changed, 43 insertions, 18 deletions
diff --git a/vmchooser/main.cxx b/vmchooser/main.cxx
index b266333..09d382c 100644
--- a/vmchooser/main.cxx
+++ b/vmchooser/main.cxx
@@ -34,10 +34,10 @@ int main(int argc, char** argv) {
char* xmlpath = NULL;
char* lsesspath = NULL;
int width=0, height=0;
-
+
//opt->setVerbose();
opt->autoUsagePrint(false);
-
+
opt->addUsage("");
opt->addUsage("SessionChooser Usage: vmchooser [OPTS|image.xml]");
opt->addUsage("\t{-p |--path=} path to vmware (.xml) files");
@@ -47,25 +47,50 @@ int main(int argc, char** argv) {
opt->addUsage("\t{-h |--help} prints help");
opt->addUsage("");
opt->addUsage("Run with xml-file as additional argument to start image at once.");
-
+
opt->setFlag("help",'h');
opt->setFlag("version",'v');
opt->setOption("path", 'p');
opt->setOption("lpath", 'l');
opt->setOption("size",'s');
-
+
opt->processCommandArgs(argc, argv);
-
+
/** HELP */
if(opt->getFlag("help") || opt->getFlag('h')) {
opt->printUsage();
return 0;
}
-
- /** XML - PATH */
+
+ /** XML - PATH
+ *
+ * 1. read from stage3.conf
+ * 2. option -p
+ * 3. option --path
+ * 4. default value "/var/lib/virt/vmware/"
+ *
+ **/
+
+ ifstream ifs ( "/etc/opt/openslx/vmchooser-stage3.conf" , ifstream::in );
+ if(ifs) {
+ int n = 255;
+ char buf[n];
+ string s = "";
+ while(!ifs.eof()) {
+ ifs.getline(buf, n);
+ s = buf;
+ if(s.substr(0,17) == "vmchooser_xmlpath") {
+ xmlpath = new char[strlen(buf)];
+ xmlpath = (char*)s.substr(19,s.length()-20).append("/").c_str();
+ }
+ }
+
+ }
+
if(opt->getValue('p')!=NULL) {
xmlpath = opt->getValue('p');
}
+
if(opt->getValue("path")!= NULL) {
xmlpath = opt->getValue("path");
}
@@ -74,7 +99,7 @@ int main(int argc, char** argv) {
// Default Path comes here
xmlpath = (char *) "/var/lib/virt/vmware/";
}
-
+
/* VERSION */
if(opt->getFlag('v') || opt->getFlag("version")) {
// just print out version information - helps testing
@@ -83,7 +108,7 @@ int main(int argc, char** argv) {
return 0;
}
-
+
/** LINUX SESSION PATH */
if(opt->getValue('l')!=NULL) {
lsesspath = opt->getValue('l');
@@ -94,18 +119,18 @@ int main(int argc, char** argv) {
if (lsesspath == NULL) {
lsesspath = (char *) "/usr/share/xsessions/";
}
-
+
/** Size of Window */
string size;
unsigned int i;
-
+
if(opt->getValue('s')!=NULL) {
size = opt->getValue('s');
}
if(opt->getValue("size")!= NULL) {
size = opt->getValue("size");
}
-
+
if (size.empty()) {
width = 500;
height = 550;
@@ -133,7 +158,7 @@ int main(int argc, char** argv) {
DataEntry* result = get_entry(doc);
runImage(*result, opt->getArgv(0));
}
-
+
delete opt;
@@ -141,8 +166,8 @@ int main(int argc, char** argv) {
DataEntry** sessions = NULL;
DataEntry** lsessions = NULL;
sessions = readXmlDir(xmlpath);
- lsessions = readLinSess(lsesspath);
-
+ lsessions = readLinSess(lsesspath);
+
SWindow& win = *SWindow::getInstance(width, height);
mainwin = &win;
bool lin_entries=false;
@@ -156,15 +181,15 @@ int main(int argc, char** argv) {
win.set_entries(sessions);
vm_entries = true;
}
-
+
win.unfold_entries(lin_entries, vm_entries);
win.show(); // argc,argv
win.border(false);
bool retval = run();
-
+
win.free_entries();
-
+
return retval;
}