vlp-27 Replaced hardcoded dialog for killing interpreters with QtDesigner generated...
[vlp.git] / src / kernel / kernel.cpp
index d05e12e949f200dc0e1bbea0a4adf921d825c065..8321476ff915e4c37d017939894065d160f132e9 100644 (file)
 ************************************************************/
 
 
-#include <qpixmap.h>
-//#include <qwindow.h>
 #include <QtGui/QApplication>
 #include <QtGui/QMainWindow>
-//#include <qframe.h>
-//#include <qmlined.h>
-//#include <qpainter.h>
 #include <QtGui/QTextEdit>
-#include <qcolor.h>
-#include <qbrush.h>
 #include <QtGui/QMenuBar>
-//#include <qmenubar.h>
-//#include <qpopmenu.h>
-#include <qfont.h>
 #include <QtGui/QMessageBox>
-//#include <qmsgbox.h>
-//#include <qfiledlg.h>
 #include <QtGui/QFileDialog>
 #include <QtGui/QDialog>
-//#include <qtabdlg.h>
 #include <qstring.h>
-#include <qrect.h>
-//#include <qdialog.h>
-//#include <qbttngrp.h>
 #include <QtGui/QLabel>
 #include <QtGui/QLineEdit>
 #include <QtGui/QPushButton>
 #include <QtGui/QRadioButton>
 #include <QtGui/QGroupBox>
 #include <QtGui/QVBoxLayout>
-//#include <qlined.h>
-//#include <qlistbox.h>
-//#include <qpushbt.h>
-//#include <qradiobt.h>
-//#include <qlist.h>
 #include <QtCore/QList>
 #include <QtGui/QListWidget>
 #include <qfile.h>
 #include <qcursor.h>
-//#include <qcombo.h>
-//#include <qsocknot.h>
 #include <QtCore/QSocketNotifier>
+#include <QtGui/QCloseEvent>
 #include <qdir.h>
-#include <qwindowsstyle.h>
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <fcntl.h>
 
 #include "genint1.h"
-#include "comm.h"
 #include "socu.h"
 #include <netinet/in.h>
 
 #include <libconfig.h>
 
+#include "kernel.h"
+#include "send-message.h"
+#include "kill-interpreter.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
-        */
-       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 * prid;
-       QAction * mid;
-       QAction * msgid;
-       QAction * toolsid;
-       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.
@@ -238,18 +82,40 @@ private:
  */
 void QKernel::closeEvent(QCloseEvent * e)
 {
-       QuitProc();
+       e->ignore();
+
+       if (!LOCKED) {
+               QuitProc();
+       }
+}
+
+void QKernel::setLocked(bool locked)
+{
+       LOCKED = locked;
+
+       actionExecute->setDisabled(locked);
+       actionKill->setDisabled(locked);
+       actionConnect->setDisabled(locked);
+       actionDisconnect->setDisabled(locked);
+       actionInfo_messages->setDisabled(locked);
+       actionMessage->setDisabled(locked);
+
+       /* Enable only menu entry for unlocking */
+       actionEditor->setDisabled(locked);
+       actionOptions->setDisabled(locked);
+       actionLock_Console->setDisabled(locked);
+       actionUnlock_console->setEnabled(locked);
 }
 
 /**
  * Kernel program constructor.
  * Prepares everything to work.
  */
-QKernel::QKernel()
+QKernel::QKernel(QWidget *parent)
+       : QMainWindow(parent)
 {
-//     QFont f("Helvetica", 10, QFont::Bold);
-//     QFont f1("Helvetica", 10, QFont::Normal);
-//     QFont f2("Times Roman", 10, QFont::Normal);
+       setupUi(this);
+
        QDir q(REMOTE_PATH);
        char ss[255];
 
@@ -262,66 +128,8 @@ QKernel::QKernel()
        wait_for_info = FALSE;
 
        setWindowTitle(PACKAGE_NAME);
-//     setBackgroundColor(white);
-
-//     bar = new QMenuBar(this);
-//     bar->setFont(f);
-//     p = new QPopupMenu();
-       QMenu * programMenu = NULL;
-//     p->setFont(f2);
-       programMenu = menuBar()->addMenu("&Program");
-//     prid = bar->insertItem("&Program", p);
-       programMenu->addAction("Execute", this, SLOT(Run_Prog()));
-       programMenu->addAction("Kill", this, SLOT(KillInterpreter()));
-       
 
-//     mid = bar->insertItem("&Machine", p1);
-       machineMenu = menuBar()->addMenu("&Machine");
-//     p1 = new QPopupMenu();
-       machineMenu->addAction("Message", this, SLOT(MessageToNode()));
-       machineMenu->addSeparator();
-       machineMenu->addAction("Connect", this, SLOT(Connect()));
-       machineMenu->addAction("Disconnect", this, SLOT(Disconnect()));
-       machineMenu->addAction("Info", this, SLOT(Info()));
-//     machineMenu->setFont(f);
-
-//     toolsid = bar->insertItem("&Tools", p2);
-
-//     p2 = new QPopupMenu();
-       toolsMenu = menuBar()->addMenu("&Tools");
-       cwid = toolsMenu->addAction("Editor", this, SLOT(Edit()));
-       hid = 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->setItemChecked(msgid, TRUE);
-       toolsMenu->addSeparator(); 
-       lockid = toolsMenu->addAction("Lock console", this, SLOT(LockConsole()));
-       unlockid = toolsMenu->addAction("Unlock console", this, 
-                                                       SLOT(UnlockConsole()));
-//     toolsMenu->setItemEnabled(unlockid, FALSE);
-       unlockid->setDisabled(TRUE);
        LOCKED = FALSE;
-//     p2->setFont(f);
-
-       qid = menuBar()->addAction("&Quit", this, SLOT(QuitProc()));
-//     p->setFont(f);
-
-       desktop = new QTextEdit(this);
-//     desktop->setAutoUpdate(TRUE);
-       desktop->setReadOnly(TRUE);
-//     desktop->setFont(f1);
-       QVBoxLayout * layout = new QVBoxLayout();
-       layout->setContentsMargins (3, 0, 3, 0);
-       layout->addWidget(desktop);
-//     layout->addWidget(msg);
-       QWidget *window = new QWidget();
-       window->setLayout(layout);
-       setCentralWidget(window);
-
-       resize(400, 200);
        Tasks = 0;
        freeINTid = 1;
        ActiveConnections = 0;
@@ -333,18 +141,6 @@ QKernel::QKernel()
        connect(Net_Notify, SIGNAL(activated(int)), this, SLOT(NetMessage()));
 }
 
-/**
- * Event invoked on resizing kernel application window.
- * @copydoc QWidget::resizeEvent(QResizeEvent*)
- */
-void QKernel::resizeEvent(QResizeEvent *ev)
-{
-//     QFrame::resizeEvent(ev);
-//     if (desktop)
-//             desktop->setGeometry(0, bar->height(), width(), 
-//                                             height() - bar->height());
-}
-
 /**
  * Displays window with information about not implemented functionality.
  */
@@ -383,7 +179,7 @@ void QKernel::LoadConfig(char * fname)
                        config_error_line(&cfg));
                config_destroy(&cfg);
                fclose(file);
-               exit(3);/* from original code. */
+               exit(3);
        }
 
        setting = config_lookup(&cfg, "node_number");
@@ -461,7 +257,7 @@ void QKernel::LoadConfig(char * fname)
  * Executes program.
  * Additional window id displayed to set which code to execute.
  */
-void QKernel::Run_Prog()
+void QKernel::on_actionExecute_triggered()
 {
        int i;
        QString s = QFileDialog::getOpenFileName(this, "Execute", progdir, "*.log");
@@ -479,7 +275,7 @@ void QKernel::Run_Prog()
 /**
  * Invokes editor program
  */
-void QKernel::Edit()
+void QKernel::on_actionEditor_triggered()
 {
        char cmd[255];
        sprintf(cmd, "%s/modules/logedit %s %s %s %s %s %s &", HomeDir, HomeDir, 
@@ -490,10 +286,10 @@ void QKernel::Edit()
 /**
  * Invokes help program
  */
-void QKernel::Help()
+void QKernel::on_actionHelp_triggered()
 {
        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);
 }
@@ -505,9 +301,8 @@ void QKernel::RunGraphModule(char *sk)
 {
        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");
@@ -522,9 +317,8 @@ void QKernel::RunNetModule()
        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);
@@ -565,7 +359,7 @@ void QKernel::RunNetModule()
  * Connects to the specified address
  * Additional window is displayed to connect to the specified address
  */
-void QKernel::Connect()
+void QKernel::on_actionConnect_triggered()
 {
        QDialog d(this, Qt::Dialog);
        QLabel lab("IP Address:", &d);
@@ -574,7 +368,6 @@ void QKernel::Connect()
        QPushButton cb("", &d);
        MESSAGE m;
 
-//     d.setFont(QFont("Helvetica", 12, QFont::Bold)); 
        ob.setGeometry(30, 60, 80, 30);
        ob.setText("Ok");
        ob.setDefault(TRUE);
@@ -598,7 +391,7 @@ void QKernel::Connect()
 /**
  * Disconnects from virtual machine
  */
-void QKernel::Disconnect()
+void QKernel::on_actionDisconnect_triggered()
 {
        MESSAGE msg;
 
@@ -617,24 +410,25 @@ void QKernel::QuitProc()
 {
        MESSAGE msg;
 
-       if (QMessageBox::question(this, "Close VLP", "Terminate VLP ?", 
-               QMessageBox::Yes, QMessageBox::No, 0) == QMessageBox::No) {
+       QMessageBox::StandardButton response;
+       response = QMessageBox::question(this, "Close VLP", "Terminate VLP ?",
+               QMessageBox::Ok | QMessageBox::Cancel);
+
+
+       if (response == QMessageBox::Cancel) {
                return;
        }
-       
-       if (!LOCKED) {
-               /* 
-               msg.msg_type = MSG_NET;
-               msg.param.pword[0] = NET_DISCONNECT;
-               write(net_sock, &msg, sizeof(MESSAGE));*/
-               delete Net_Notify;
-
-               msg.msg_type = MSG_NET;
-               msg.param.pword[0] = NET_EXIT;
-               write(net_sock, &msg, sizeof(MESSAGE));
-               /*  ::close(net_sock);*/
-               app->quit();
-       }
+       /*
+       msg.msg_type = MSG_NET;
+       msg.param.pword[0] = NET_DISCONNECT;
+       write(net_sock, &msg, sizeof(MESSAGE));*/
+       delete Net_Notify;
+
+       msg.msg_type = MSG_NET;
+       msg.param.pword[0] = NET_EXIT;
+       write(net_sock, &msg, sizeof(MESSAGE));
+       /*  ::close(net_sock);*/
+       QApplication::instance()->quit();
 }
 
 /**
@@ -686,50 +480,20 @@ void QKernel::DelAddress()
  * Additional window is displayed to set Node Number of node where send message,
  * and textfield to enter message.
  */
-void QKernel::MessageToNode()
+void QKernel::on_actionMessage_triggered()
 {
-       QDialog *dlg;
-       QLineEdit *nodenr;
        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())); 
+       SendMessageDialog *dlg;
+       dlg = new SendMessageDialog(this, Qt::Dialog);
 
        if (dlg->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] = dlg->getNodeNumber();
                m.param.pword[6] = VLP_WRITE;
-               strcpy(m.param.pstr, msg->text().toAscii().data());
+               strcpy(m.param.pstr, dlg->getMessage().toAscii().data());
                write(net_sock, &m, sizeof(MESSAGE));
        }
 }
@@ -739,37 +503,18 @@ void QKernel::MessageToNode()
  * Additional window is displayed to get ID of interpreter which should be
  * killed.
  */
-void QKernel::KillInterpreter()
+void QKernel::on_actionKill_triggered()
 {
-       QDialog *dlg;
-       QLineEdit *nodenr;
        MESSAGE m;
        InterpEntry *pom;
+       KillInterpreterDialog *dlg;
 
-       dlg = new QDialog(this, Qt::Dialog);
-       dlg->setWindowTitle("Kill interpreter");
-
-       nodenr = new QLineEdit("", dlg); 
-       nodenr->setGeometry(90, 10, 50, 30);
-
-       QLabel * tmpQLabel = new QLabel("Interp. ID:", dlg);
-       tmpQLabel->setGeometry(10, 10, 77, 30);
-
-       QPushButton * ob = new QPushButton("Kill", dlg);
-       ob->setGeometry( 160, 10, 80, 30);
-       ob->setDefault(TRUE);
-
-       QPushButton * cb = new QPushButton("Cancel", dlg);
-       cb->setGeometry(260, 10, 80, 30);
-       dlg->resize(360, 50);
-
-       connect(ob, SIGNAL(clicked()), dlg, SLOT(accept()));
-       connect(cb, SIGNAL(clicked()), dlg, SLOT(reject())); 
+       dlg = new KillInterpreterDialog(this, Qt::Dialog);
 
        if (dlg->exec()) {
                m.msg_type = MSG_INT;
                m.param.pword[0] = INT_KILL;
-               pom = findINTbyID(atoi(nodenr->text().toAscii().data()));
+               pom = findINTbyID(dlg->getNodeNumber());
                if (pom != NULL) {
                        if (!(pom->remote))
                                write(pom->sock, &m, sizeof(MESSAGE));
@@ -806,7 +551,7 @@ void QKernel::NetMessage()
                        case MSG_INT:
                                /*  pom = find_link_by_ID(msg.param.pword[5]);
                                msg.msg_type = MSG_NET;
-                               msg.param.pword[0] = NET_PROPAGATE;   
+                               msg.param.pword[0] = NET_PROPAGATE;
                                send_int(pom, &msg);*/
                                break;
                        case MSG_VLP:
@@ -855,7 +600,7 @@ void QKernel::NetMessage()
                                                WriteMessage("Instance not found"); 
                                        }
                                        break; 
-                               } /* VLP switch */        
+                               } /* VLP switch */
                        }/* switch */
                        break;
                case NET_CONNECTIONS:
@@ -984,7 +729,7 @@ void QKernel::WriteMessage(char *msg)
        desktop->setReadOnly(FALSE);
        desktop->append(msg);
        desktop->setReadOnly(TRUE);
-//     desktop->setCursorPosition(desktop->blockCount(), 1);
+
        QTextCursor tmpCursor = desktop->textCursor();
        tmpCursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
        desktop->setTextCursor(tmpCursor);
@@ -1000,18 +745,11 @@ void QKernel::WriteMessage(char *msg)
  * Adds checkbox to menu item. If it is checked additional info messages are
  * shown.
  */
-void QKernel::SetMessages()
+void QKernel::on_actionInfo_messages_triggered()
 {
-       if (toolsMenu != NULL) {
-               if (msgid->isChecked()) {
-                       msgid->setChecked(FALSE);
-                       info_messages = FALSE;
-               } else {
-                       msgid->setChecked(TRUE);
-                       info_messages = TRUE;
-               }
+       if (menuTools != NULL) {
+               info_messages = actionInfo_messages->isChecked();
        }
-       /* bar->repaint(); */
 }
 
 /**
@@ -1019,7 +757,7 @@ void QKernel::SetMessages()
  * Additional window is displayed to set kernel options which are saved in 
  * vlp.cfg file in kernel executable directory.
  */
-void QKernel::SetOptions()
+void QKernel::on_actionOptions_triggered()
 {
        QDialog dlg(this, Qt::Dialog);
        dlg.setWindowTitle("Options");
@@ -1158,7 +896,7 @@ void QKernel::SetOptions()
  * Additional window is displayed to enter password and retype it. If both are
  * same kernel window is locked.
  */
-void QKernel::LockConsole()
+void QKernel::on_actionLock_Console_triggered()
 {
        QDialog d(this, Qt::Dialog);
        d.setWindowTitle("Lock console");
@@ -1186,25 +924,19 @@ void QKernel::LockConsole()
                        strcpy(LockPasswd, ed.text().toAscii().data());
                        lab.setText("Retype:");
                        ed.setText("");
+                       /*
+                        * Following exec(), could produce error:
+                        * X Error: BadWindow (invalid Window parameter) 3
+                        *   Major opcode: 3 (X_GetWindowAttributes)
+                        *
+                        * This is not error in our code. Basing on:
+                        * https://bugreports.qt-project.org/browse/QTBUG-1782
+                        * this happens only on Qt 4.3 - 4.4.
+                        */
                        if (d.exec()) {
-                               if (strcmp(ed.text().toAscii().data(), LockPasswd)==0) {
-                                       qid->setEnabled(FALSE);
-                                       prid->setEnabled(FALSE);
-                                       mid->setEnabled(FALSE);
-                                       unlockid->setEnabled(TRUE);
-                                       lockid->setEnabled(FALSE);
-                                       cwid->setEnabled(FALSE);
-                                       optid->setEnabled(FALSE);
-//                                     menuBar()->setItemEnabled(qid, FALSE);
-//                                     bar->setItemEnabled(prid, FALSE);
-//                                     bar->setItemEnabled(mid, FALSE);
-//                                     p2->setItemEnabled(unlockid, TRUE);
-//                                     p2->setItemEnabled(lockid, FALSE);
-//                                     p2->setItemEnabled(cwid, FALSE);
-//                                     p2->setItemEnabled(optid, FALSE);
-                                       bar->repaint();
+                               if (strcmp(ed.text().toAscii().data(), LockPasswd) == 0) {
+                                       setLocked(TRUE);
                                        WriteMessage("CONSOLE LOCKED");
-                                       LOCKED = TRUE;
                                } else {
                                        QMessageBox msg(this);
                                        msg.setText("Not matching!");
@@ -1223,7 +955,7 @@ void QKernel::LockConsole()
  * Additional window is displayed to enter password. If it is correct, kernel 
  * window is unlocked
  */
-void QKernel::UnlockConsole()
+void QKernel::on_actionUnlock_console_triggered()
 {
        QDialog d(this, Qt::Dialog);
        d.setWindowTitle("Enter password");
@@ -1248,23 +980,8 @@ void QKernel::UnlockConsole()
 
        if (d.exec()) {
                if (strcmp(ed.text().toAscii().data(), LockPasswd) == 0) {
-                       qid->setEnabled(TRUE);
-                       prid->setEnabled(TRUE);
-                       mid->setEnabled(TRUE);
-                       unlockid->setEnabled(FALSE);
-                       lockid->setEnabled(TRUE);
-                       cwid->setEnabled(TRUE);
-                       optid->setEnabled(TRUE);
-//                     bar->setItemEnabled(qid, TRUE);
-//                     bar->setItemEnabled(prid, TRUE);
-//                     bar->setItemEnabled(mid, TRUE);
-//                     p2->setItemEnabled(unlockid, FALSE);
-//                     p2->setItemEnabled(lockid, TRUE);
-//                     p2->setItemEnabled(cwid, TRUE);
-//                     p2->setItemEnabled(optid, TRUE);
-//                     bar->repaint();
+                       setLocked(FALSE);
                        WriteMessage("CONSOLE UNLOCKED");
-                       LOCKED = FALSE;
                } else {
                        QMessageBox msg(this);
                        msg.setText("Wrong password!");
@@ -1393,7 +1110,7 @@ InterpEntry *QKernel::RunIntModule(char *ss, int r)
        len = strlen(svr.sun_path)+sizeof(svr.sun_family);
        bind(sock, (struct sockaddr*)&svr, len);
        listen(sock, 5);
-       system(cmd); 
+       system(cmd);
        newINT->sock = accept(sock, (struct sockaddr*)0, (unsigned int *)0);
        //::close(sock);
 
@@ -1402,7 +1119,7 @@ InterpEntry *QKernel::RunIntModule(char *ss, int r)
                                O_NONBLOCK|fcntl(newINT->sock, F_GETFL, 0));
                on=1; 
                setsockopt(newINT->sock, IPPROTO_TCP, TCP_NODELAY, (char*)&on,
-                                                               sizeof(on)); 
+                                                               sizeof(on));
                if (r)
                        newINT->remote = 1;
                else 
@@ -1481,7 +1198,7 @@ void QKernel::RemoteInstance(InterpEntry *interp, int on)
                                interp->RInstances[on] = m.param.pword[7];
                                break;
                        }
-                       read(net_sock, &m, sizeof(MESSAGE));  
+                       read(net_sock, &m, sizeof(MESSAGE));
                }
 
                Net_Notify->setEnabled(TRUE);
@@ -1530,7 +1247,7 @@ void QKernel::CloseInstances(InterpEntry *e)
 /**
  * Displays information about virtual machine
  */
-void QKernel::Info()
+void QKernel::on_actionInfo_triggered()
 {
        MESSAGE m;
 
@@ -1542,8 +1259,6 @@ void QKernel::Info()
        wait_for_info = TRUE;
 }
 
-#include "kernel.moc"
-
 /**
  * Program main function
  * All program arguments but the first one (argv[0]: program name) are saved and
@@ -1561,10 +1276,10 @@ int main(int argc, char **argv)
                strcpy(myargs[i - 1], argv[i]);
        }
 
-       app = new QApplication(argc, argv);
-//     app->setStyle(new QWindowsStyle());
+       QApplication * app = new QApplication(argc, argv);
+       
        QKernel kernel;
-//     app->setCentralWidget(&kernel);
+
        kernel.show();
        kernel.InitMessage();