Restore compilation of loggraph, extract code layout of kernel's message dialog into...
[vlp.git] / src / kernel / kernel.cpp
index 31cb74d1a3277635f1b2a51fa1e02c7e5477540d..b39fa3cdc4e627b64168efbdd18ab7260fec11ad 100644 (file)
 
 #include "kernel.h"
 #include "ui/KernelWindow.h"
+#include "ConnectDialog.h"
+#include "KillDialog.h"
 #include "LockDialog.h"
 #include "OptionsDialog.h"
-#include "KillDialog.h"
-#include "ConnectDialog.h"
+#include "MessageDialog.h"
 
 #include "vlp/config.h"
 
+#include <sys/prctl.h>
 /* File resides in top directory (where are Makefiles)*/
 #include "../../config.h"
 
@@ -243,6 +245,7 @@ void QKernel::on_actionEditor_triggered()
        QString program = getHomeDir();
        program += "/modules/logedit";
 
+       fprintf(stderr, "Run EDIT Module: %s, %s\n", program.toStdString().c_str(), getHomeDir());
        pid_t pid = fork();
        if (pid == 0) {
                if (execl(program.toStdString().c_str(),
@@ -277,6 +280,8 @@ void QKernel::on_actionHelp_triggered()
        QString docDir = getHomeDir();
        docDir += "/doc";
 
+       fprintf(stderr, "Run HELP Module: %s, %s\n", program.toStdString().c_str(), docDir.toStdString().c_str());
+
        pid_t pid = fork();
        if (pid == 0) {
                if (execl(program.toStdString().c_str(),
@@ -309,6 +314,8 @@ void QKernel::RunGraphModule(char *sk)
        QString program = getHomeDir();
        program += "/modules/loggraph";
 
+       fprintf(stderr, "Run GRAPH Module: %s, %s\n", program.toStdString().c_str(), sk);
+
        pid_t pid = fork();
        if (pid == 0) {
                if (execl(program.toStdString().c_str(),
@@ -342,6 +349,7 @@ void QKernel::RunGraphModule(char *sk)
  */
 void QKernel::RunNetModule()
 {
+
        struct sockaddr_un svr;
        int len;
        int on;
@@ -350,6 +358,7 @@ void QKernel::RunNetModule()
        QString program = getHomeDir();
        program += "/modules/lognet";
 
+       fprintf(stderr, "Run NET Module: %s, %s %s\n", program.toStdString().c_str(), getNetModuleSocket(), getConfigFilePath().toStdString().c_str());
        pid_t pid = fork();
        if (pid == 0) {
                if (execl(program.toStdString().c_str(),
@@ -474,48 +483,17 @@ void QKernel::on_actionQuit_triggered()
  */
 void QKernel::on_actionMessage_triggered()
 {
-       QDialog *dlg;
-       QLineEdit *nodenr;
+       dialog::MessageDialog dialog(this);
        MESSAGE m;
 
-       dlg = new QDialog(this, Qt::Dialog);
-       dlg->setWindowTitle("Send message to node");
-
-       nodenr = new QLineEdit("number", dlg);
-       nodenr->setGeometry(90, 10, 50, 30);
-       nodenr->setText("");
-
-       QLabel *tmpQLabel;
-       tmpQLabel = new QLabel("Node number:", dlg);
-       tmpQLabel->setGeometry(10, 10, 77, 30);
-
-       tmpQLabel = new QLabel("Message:", dlg);
-       tmpQLabel->setGeometry(10, 50, 70, 30);
-
-       QLineEdit *msg;
-       msg = new QLineEdit("", dlg);
-       msg->setGeometry(80, 60, 330, 30);
-
-       QPushButton *ob;
-       ob = new QPushButton("Send", dlg);
-       ob->setGeometry(230, 10, 80, 30);
-       ob->setDefault(TRUE);
-       
-       QPushButton *cb;
-       cb = new QPushButton("Cancel", dlg);
-       cb->setGeometry(330, 10, 80, 30);
-       dlg->resize(430, 110);
-       connect(ob, SIGNAL(clicked()), dlg, SLOT(accept()));
-       connect(cb, SIGNAL(clicked()), dlg, SLOT(reject()));
-
-       if (dlg->exec()) {
+       if (dialog.exec()) {
                m.msg_type = MSG_NET;
                m.param.pword[0] = NET_PROPAGATE;
                m.param.pword[1] = MSG_VLP;
                m.param.pword[2] = NodeNumber;
-               m.param.pword[4] = atoi(nodenr->text().toAscii().data());
+               m.param.pword[4] = dialog.getNodeNumber();
                m.param.pword[6] = VLP_WRITE;
-               strcpy(m.param.pstr, msg->text().toAscii().data());
+               strcpy(m.param.pstr, dialog.getMessage().toStdString().c_str());
                write(net_sock, &m, sizeof(MESSAGE));
        }
 }
@@ -584,17 +562,17 @@ void QKernel::NetMessage()
                                case VLP_WRITE:
                                        QApplication::beep();
                                        WriteMessage(CharLine);
-                                       WriteMessage(
-                                               "### Incoming Messsage ###");
-                                       sprintf(ss, "Mesg from Node %d: %s",
-                                                       msg.param.pword[2],
-                                                       msg.param.pstr);
+                                       WriteMessage("### Incoming Messsage ###");
+                                       sprintf(ss,
+                                               "Mesg from Node %d: %s",
+                                               msg.param.pword[2],
+                                               msg.param.pstr
+                                       );
                                        WriteMessage(ss);
                                        WriteMessage(CharLine);
                                        break;
                                case VLP_REMOTE_INSTANCE:
-                                       sprintf(ss, "%s/%s", getRemoteDir(),
-                                                               msg.param.pstr);
+                                       sprintf(ss, "%s/%s", getRemoteDir(), msg.param.pstr);
 
                                        if (info_messages) { 
                                                WriteMessage("Running program:");
@@ -679,6 +657,7 @@ void QKernel::IntMessage(int sock)
                switch (msg.msg_type) { 
                case MSG_GRAPH:
                        if (msg.param.pword[0] == GRAPH_ALLOCATE) {
+                               fprintf(stderr, "Running graph module with arg: %s\n", msg.param.pstr);
                                RunGraphModule(msg.param.pstr);
                        }
                        break;
@@ -897,6 +876,7 @@ InterpEntry *QKernel::findINTbyID(int _id)
  */
 InterpEntry *QKernel::RunIntModule(char *ss, int r)
 {
+       fprintf(stderr, "Run INT Module: %s, %d\n", ss, r);
        char a[256], b[255];
        struct sockaddr_un svr;
        int len, sock, on;