#include <fcntl.h>
#include "genint1.h"
-#include "comm.h"
#include "socu.h"
#include <netinet/in.h>
#include <libconfig.h>
+#include "kernel.h"
+
/* File resides in top directory (where are Makefiles)*/
#include "../../config.h"
-#define GPATH "loggr"
-#define IPATH "logi"
-#define NPATH "logn"
-#define REMOTE_PATH "REMOTE"
-#define MAXINTERP 20
-#define MAXINSTANCES 256
-
-
-#define MESG_COL 0
-#define WARN_COL 1
-#define NORM_COL 2
-
char CharLine[25] = "________________________";
char myargs[5][255];
-/**
- * Interpreter slot
- */
-class InterpEntry {
-public:
- /** Interpreter identifier */
- int ID;
- /** Defines if interpreter is remote or not */
- bool remote;
- /* Program name */
- char fullname[255];
- char shortname[255];
-
- /* Socket */
- int sock;
- QSocketNotifier *notify;
- /* IDs of my remote INT modules */
- int RInstances[MAXINSTANCES];
- /* Parent interpreter info */
- ctx_struct p_ctx;
-};
-
-/**
- * Connection slot
- */
-class ConnectEntry {
-public:
- char addr[256];
-
- ConnectEntry(char *s) {
- strcpy(addr, s);
- };
-};
-
-QApplication *app;
-
-/**
- * Kernel class
- */
-class QKernel : public QMainWindow {
- Q_OBJECT
-public:
- QTextEdit *desktop;
- QMenuBar *bar;
- QMenu *programMenu;
- QMenu *machineMenu;
- QMenu *toolsMenu;
- char progdir[256];
- int NodeNumber;
- int ConType;
-
- QKernel();
-
- virtual void resizeEvent(QResizeEvent *ev);
-
- void WriteMessage(char* msg);
- void InitMessage();
-
-public slots:
- void n_impl();
- void Run_Prog();
- void Edit();
- void Help();
- void SetOptions();
- void AddAddress();
- void DelAddress();
- void LockConsole();
- void UnlockConsole();
- void MessageToNode();
- void QuitProc();
- void NetMessage();
- void IntMessage(int);
- void KillInterpreter();
- void Disconnect();
- void SetMessages();
- void Connect();
- void Info();
-
-protected:
- virtual void closeEvent (QCloseEvent * e);
-
-private:
- QList<InterpEntry*> Interpreters;
- QList<ConnectEntry*> ConnectList;
- QListWidget *connections;
-
- /**
- * number of working interpreters
- * @attention Currently not in use
- */
- int Tasks;
-
- /**
- * number of connected VLPs
- */
- int ActiveConnections;
- bool LOCKED;
- bool synchro;
- bool wait_for_info;
- char LockPasswd[25];
- QAction * lockid;
- QAction * unlockid;
- QAction * qid;
- QAction * cwid;
- QAction * optid;
- QAction * programExecuteAction;
- QAction * programKillAction;
- QAction * machineMessageAction;
- QAction * machineConnectAction;
- QAction * machineDisconnectAction;
- QAction * machineInfoAction;
- QAction * msgid;
- QAction * hid;
-
- int net_sock;
- int freeINTid;
- QSocketNotifier *Net_Notify;
- char HomeDir[255];
- bool info_messages;
-
- void LoadConfig(char *);
- void RunGraphModule(char*);
- void RunNetModule();
- InterpEntry *findINTbySocket(int);
- InterpEntry *findINTbyID(int);
- InterpEntry *RunIntModule(char *ss, int r);
- void RemoteInstance(InterpEntry*, int);
- void CloseInstances(InterpEntry*);
-};
+//QApplication *app;
/**
* Event invoked on program close.
}
}
+void QKernel::setLocked(bool locked)
+{
+ LOCKED = locked;
+
+ quitAction->setDisabled(locked);
+ programExecuteAction->setDisabled(locked);
+ programKillAction->setDisabled(locked);
+ machineMessageAction->setDisabled(locked);
+ machineConnectAction->setDisabled(locked);
+ machineDisconnectAction->setDisabled(locked);
+ machineInfoAction->setDisabled(locked);
+
+ /* Enable only menu entry for unlocking */
+ toolsEditorAction->setDisabled(locked);
+ toolsOptionsAction->setDisabled(locked);
+ toolsLockAction->setDisabled(locked);
+ toolsUnlockAction->setEnabled(locked);
+}
+
/**
* Kernel program constructor.
* Prepares everything to work.
machineInfoAction = machineMenu->addAction("Info", this, SLOT(Info()));
toolsMenu = menuBar()->addMenu("&Tools");
- cwid = toolsMenu->addAction("Editor", this, SLOT(Edit()));
- hid = toolsMenu->addAction("Help", this, SLOT(Help()));
+ toolsEditorAction = toolsMenu->addAction("Editor", this, SLOT(Edit()));
+ toolsMenu->addAction("Help", this, SLOT(Help()));
toolsMenu->addSeparator();
- optid = toolsMenu->addAction("Options", this, SLOT(SetOptions()));
- msgid = toolsMenu->addAction("Info messages", this, SLOT(SetMessages()));
- msgid->setCheckable(TRUE);
- msgid->setChecked(TRUE);
- toolsMenu->addSeparator();
- lockid = toolsMenu->addAction("Lock console", this, SLOT(LockConsole()));
- unlockid = toolsMenu->addAction("Unlock console", this,
+ toolsOptionsAction = toolsMenu->addAction("Options", this, SLOT(SetOptions()));
+ toolsInfoAction = toolsMenu->addAction("Info messages", this, SLOT(SetMessages()));
+ toolsInfoAction->setCheckable(TRUE);
+ toolsInfoAction->setChecked(TRUE);
+ toolsMenu->addSeparator();
+ toolsLockAction = toolsMenu->addAction("Lock console", this, SLOT(LockConsole()));
+ toolsUnlockAction = toolsMenu->addAction("Unlock console", this,
SLOT(UnlockConsole()));
- unlockid->setDisabled(TRUE);
+ toolsUnlockAction->setDisabled(TRUE);
LOCKED = FALSE;
- qid = menuBar()->addAction("&Quit", this, SLOT(QuitProc()));
+ quitAction = menuBar()->addAction("&Quit", this, SLOT(QuitProc()));
desktop = new QTextEdit(this);
desktop->setReadOnly(TRUE);
config_error_line(&cfg));
config_destroy(&cfg);
fclose(file);
- exit(3);/* from original code. */
+ exit(3);
}
setting = config_lookup(&cfg, "node_number");
void QKernel::Help()
{
char cmd[255];
- sprintf(cmd, "%s/modules/loghelp %s/doc %s %s %s %s %s &", HomeDir,
+ sprintf(cmd, "%s/modules/loghelp %s/doc %s %s %s %s %s &", HomeDir,
HomeDir, myargs[0], myargs[1], myargs[2], myargs[3], myargs[4]);
system(cmd);
}
{
char cmd[255];
- sprintf(cmd, "%s/modules/loggraph %s %s %s %s %s %s", HomeDir, sk,
- myargs[0], myargs[1], myargs[2], myargs[3], myargs[4]);
- strcat(cmd, " &");
+ sprintf(cmd, "%s/modules/loggraph %s %s %s %s %s %s &", HomeDir,
+ sk, myargs[0], myargs[1], myargs[2], myargs[3], myargs[4]);
if (system(cmd) != 0)
WriteMessage("Cannot connect GRAPH resources");
int len, on;
int sock;
char cmd[255];
- sprintf(cmd, "%s/modules/lognet %s %s %s %s %s %s", HomeDir, NPATH,
- myargs[0], myargs[1], myargs[2], myargs[3], myargs[4]);
- strcat(cmd, " &");
+ sprintf(cmd, "%s/modules/lognet %s %s %s %s %s %s &", HomeDir,
+ NPATH, myargs[0], myargs[1], myargs[2], myargs[3], myargs[4]);
/* -------- socket for NET module -------- */
unlink(NPATH);
msg.param.pword[0] = NET_EXIT;
write(net_sock, &msg, sizeof(MESSAGE));
/* ::close(net_sock);*/
- app->quit();
+ QApplication::instance()->quit();
}
/**
void QKernel::SetMessages()
{
if (toolsMenu != NULL) {
- if (msgid->isChecked()) {
- msgid->setChecked(FALSE);
- info_messages = FALSE;
- } else {
- msgid->setChecked(TRUE);
- info_messages = TRUE;
- }
+ toolsInfoAction->setChecked(!toolsInfoAction->isChecked());
+// toolsInfoAction->toggle();
+ info_messages = toolsInfoAction->isChecked();
+ fprintf(stderr, "Info is checked? %s\n", toolsInfoAction->isChecked() ? "yes" : "no");
}
- /* bar->repaint(); */
+// menuBar()->repaint();
}
/**
*/
if (d.exec()) {
if (strcmp(ed.text().toAscii().data(), LockPasswd) == 0) {
- qid->setDisabled(TRUE);
- programExecuteAction->setDisabled(TRUE);
- programKillAction->setDisabled(TRUE);
- machineMessageAction->setDisabled(TRUE);
- machineConnectAction->setDisabled(TRUE);
- machineDisconnectAction->setDisabled(TRUE);
- machineInfoAction->setDisabled(TRUE);
-
- unlockid->setEnabled(TRUE);
- lockid->setDisabled(TRUE);
- cwid->setDisabled(TRUE);
- optid->setDisabled(TRUE);
+ setLocked(TRUE);
WriteMessage("CONSOLE LOCKED");
- LOCKED = TRUE;
} else {
QMessageBox msg(this);
msg.setText("Not matching!");
if (d.exec()) {
if (strcmp(ed.text().toAscii().data(), LockPasswd) == 0) {
- qid->setEnabled(TRUE);
- programExecuteAction->setEnabled(TRUE);
- programKillAction->setEnabled(TRUE);
- machineMessageAction->setEnabled(TRUE);
- machineConnectAction->setEnabled(TRUE);
- machineDisconnectAction->setEnabled(TRUE);
- machineInfoAction->setEnabled(TRUE);
- unlockid->setEnabled(FALSE);
- lockid->setEnabled(TRUE);
- cwid->setEnabled(TRUE);
- optid->setEnabled(TRUE);
+ setLocked(FALSE);
WriteMessage("CONSOLE UNLOCKED");
- LOCKED = FALSE;
} else {
QMessageBox msg(this);
msg.setText("Wrong password!");
wait_for_info = TRUE;
}
-#include "kernel.moc"
-
/**
* Program main function
* All program arguments but the first one (argv[0]: program name) are saved and
strcpy(myargs[i - 1], argv[i]);
}
- app = new QApplication(argc, argv);
+ QApplication * app = new QApplication(argc, argv);
QKernel kernel;
kernel.show();
kernel.InitMessage();
--- /dev/null
+/**************************************************************
+
+ Copyright (C) 1997 Oskar Swida
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+
+
+ NOTE: This software is using the free software license of
+ the QT library v.1.30 from Troll Tech AS.
+ See the file LICENSE.QT.
+
+
+ To contact the author, write:
+ e-mail: swida@aragorn.pb.bialystok.pl
+
+************************************************************/
+
+#ifndef VLP_KERNEL_H
+#define VLP_KERNEL_H
+
+#include <QtGui/QMainWindow>
+#include <QtGui/QListWidget>
+#include <QtGui/QTextEdit>
+#include <QtCore/QSocketNotifier>
+
+#include "comm.h"
+
+#define GPATH "loggr"
+#define IPATH "logi"
+#define NPATH "logn"
+#define REMOTE_PATH "REMOTE"
+#define MAXINTERP 20
+#define MAXINSTANCES 256
+
+
+#define MESG_COL 0
+#define WARN_COL 1
+#define NORM_COL 2
+
+
+/**
+ * Interpreter slot
+ */
+class InterpEntry {
+public:
+ /** Interpreter identifier */
+ int ID;
+ /** Defines if interpreter is remote or not */
+ bool remote;
+ /* Program name */
+ char fullname[255];
+ char shortname[255];
+
+ /* Socket */
+ int sock;
+ QSocketNotifier *notify;
+ /* IDs of my remote INT modules */
+ int RInstances[MAXINSTANCES];
+ /* Parent interpreter info */
+ ctx_struct p_ctx;
+};
+
+/**
+ * Connection slot
+ */
+class ConnectEntry {
+public:
+ char addr[256];
+
+ ConnectEntry(char *s) {
+ strcpy(addr, s);
+ };
+};
+
+
+/**
+ * Kernel class
+ */
+class QKernel : public QMainWindow {
+ Q_OBJECT
+public:
+ QTextEdit *desktop;
+ QMenuBar *bar;
+ QMenu *programMenu;
+ QMenu *machineMenu;
+ QMenu *toolsMenu;
+ char progdir[256];
+ int NodeNumber;
+ int ConType;
+
+ QKernel();
+
+ virtual void resizeEvent(QResizeEvent *ev);
+
+ void WriteMessage(char* msg);
+ void InitMessage();
+
+public slots:
+ void n_impl();
+ void Run_Prog();
+ void Edit();
+ void Help();
+ void SetOptions();
+ void AddAddress();
+ void DelAddress();
+ void LockConsole();
+ void UnlockConsole();
+ void MessageToNode();
+ void QuitProc();
+ void NetMessage();
+ void IntMessage(int);
+ void KillInterpreter();
+ void Disconnect();
+ void SetMessages();
+ void Connect();
+ void Info();
+
+protected:
+ virtual void closeEvent (QCloseEvent * e);
+
+private:
+ QList<InterpEntry*> Interpreters;
+ QList<ConnectEntry*> ConnectList;
+ QListWidget *connections;
+
+ /**
+ * number of working interpreters
+ * @attention Currently not in use
+ */
+ int Tasks;
+
+ /**
+ * number of connected VLPs
+ */
+ int ActiveConnections;
+ /**
+ * Indicates state of the Kernel Program. Is it locked or not.
+ */
+ bool LOCKED;
+ bool synchro;
+ bool wait_for_info;
+ char LockPasswd[25];
+ QAction * toolsEditorAction;
+ QAction * toolsOptionsAction;
+ QAction * toolsInfoAction;
+ QAction * programExecuteAction;
+ QAction * programKillAction;
+ QAction * machineMessageAction;
+ QAction * machineConnectAction;
+ QAction * machineDisconnectAction;
+ QAction * machineInfoAction;
+ QAction * toolsLockAction;
+ QAction * toolsUnlockAction;
+ QAction * quitAction;
+
+ int net_sock;
+ int freeINTid;
+ QSocketNotifier *Net_Notify;
+ char HomeDir[255];
+ bool info_messages;
+
+ void LoadConfig(char *);
+ void RunGraphModule(char*);
+ void RunNetModule();
+ InterpEntry *findINTbySocket(int);
+ InterpEntry *findINTbyID(int);
+ InterpEntry *RunIntModule(char *ss, int r);
+ void RemoteInstance(InterpEntry*, int);
+ void CloseInstances(InterpEntry*);
+
+ /**
+ * Sets QKernel menu entries to the given status
+ * @param locked status which will be set on the menu entries.
+ */
+ void setLocked(bool locked);
+};
+
+#endif /* VLP_KERNEL_H */