X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=src%2Fkernel%2Fkernel.cpp;h=1c0b7921b96806dd5accaecddd8398e0973090b9;hb=1c031379a5928fe8a268f4b54bbef4b898a1ee20;hp=b39fa3cdc4e627b64168efbdd18ab7260fec11ad;hpb=bb5fb3ccafc4e5cd0dd55134588630c263d0cb9c;p=vlp.git diff --git a/src/kernel/kernel.cpp b/src/kernel/kernel.cpp index b39fa3c..1c0b792 100644 --- a/src/kernel/kernel.cpp +++ b/src/kernel/kernel.cpp @@ -73,6 +73,8 @@ #include "MessageDialog.h" #include "vlp/config.h" +#include "vlp/QtConfigurationFinder.h" +#include "vlp/exception/ConfigFileNotFound.h" #include /* File resides in top directory (where are Makefiles)*/ @@ -126,12 +128,6 @@ QKernel::QKernel(int argc, char **argv) { setupUi(this); - QString arg0(argv[0]); - arg0 += "/"; - homeDir = QDir(arg0); - homeDir.cdUp(); - - int i; for(i = 0; (i < 5) && (i < argc-1); i++) { strcpy(myargs[i], ""); @@ -140,6 +136,9 @@ QKernel::QKernel(int argc, char **argv) } } + loglan::vlp::QtConfigurationFinder configFinder; + configFinder.initSearchDirs(); + QDir q(getRemoteDir()); if (!q.exists()) { @@ -158,7 +157,7 @@ QKernel::QKernel(int argc, char **argv) ActiveConnections = 0; strcpy(LockPasswd, ""); - loadConfig(getConfigFilePath()); + loadConfig(configFinder.findConfig().c_str()); RunNetModule(); @@ -215,6 +214,8 @@ void QKernel::loadConfig(const char * fname) } strncpy(progdir, config.getProgramDir(), 256); + + homeDir = QDir(QCoreApplication::applicationDirPath()); } } @@ -249,6 +250,7 @@ void QKernel::on_actionEditor_triggered() pid_t pid = fork(); if (pid == 0) { if (execl(program.toStdString().c_str(), + "logedit", getHomeDir(), myargs[0], myargs[1], @@ -285,6 +287,7 @@ void QKernel::on_actionHelp_triggered() pid_t pid = fork(); if (pid == 0) { if (execl(program.toStdString().c_str(), + "loghelp", docDir.toStdString().c_str(), myargs[0], myargs[1], @@ -319,6 +322,7 @@ void QKernel::RunGraphModule(char *sk) pid_t pid = fork(); if (pid == 0) { if (execl(program.toStdString().c_str(), + "loggraph", program.toStdString().c_str(), sk, myargs[0], @@ -362,7 +366,7 @@ void QKernel::RunNetModule() pid_t pid = fork(); if (pid == 0) { if (execl(program.toStdString().c_str(), - program.toStdString().c_str(), + "lognet", getNetModuleSocket(), getConfigFilePath().toStdString().c_str(), myargs[0], @@ -421,7 +425,6 @@ void QKernel::on_actionConnect_triggered() MESSAGE m; dialog::ConnectDialog dialog(this); - dialog.setWindowTitle("IP Address:"); if (dialog.exec()) { m.msg_type = MSG_NET; @@ -506,7 +509,6 @@ void QKernel::on_actionMessage_triggered() void QKernel::on_actionKill_triggered() { dialog::KillInterpreterDialog dialog(this); - dialog.setWindowTitle("Kill interpreter"); if (dialog.exec()) { MESSAGE m; @@ -532,6 +534,8 @@ void QKernel::on_actionKill_triggered() /** * Sends message to the net module. + * + * \todo method needs to be refactored */ void QKernel::NetMessage() { @@ -674,8 +678,6 @@ void QKernel::IntMessage(int sock) case MSG_INT: switch(msg.param.pword[0]) { case INT_EXITING: - char ss[255]; - MESSAGE m; m.msg_type = MSG_VLP; m.param.pword[0] = VLP_INTERPRETER_DOWN; @@ -690,6 +692,7 @@ void QKernel::IntMessage(int sock) delete e; if (info_messages) { + char ss[255]; sprintf(ss, "%s : End of program " "execution", msg.param.pstr); WriteMessage(ss); @@ -923,7 +926,7 @@ InterpEntry *QKernel::RunIntModule(char *ss, int r) strcpy(newINT->shortname, b); strcpy(newINT->fullname, ss); - sprintf(a, "%s%d", IPATH, newint); + sprintf(a, "%s%d", homeDir.absoluteFilePath(IPATH).toStdString().c_str(), newint); sprintf(cmd, "%s/modules/logint %s %s", getHomeDir(), a, @@ -931,9 +934,11 @@ InterpEntry *QKernel::RunIntModule(char *ss, int r) if (r) { strcat(cmd, " r"); } - sprintf(b, " %s %s %s %s %s", - myargs[0], myargs[1], myargs[2], myargs[3], myargs[4]); - strcat(cmd, b); +// sprintf(b, " %s %s %s %s %s", +// myargs[0], myargs[1], myargs[2], myargs[3], myargs[4]); +// sprintf(cmd, "%s %s", cmd, b); +// strcat(cmd, b); + fprintf(stderr, "%s\n", cmd); strcat(cmd, " &"); sock = socket(AF_UNIX, SOCK_STREAM, 0);