X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=src%2Fkernel%2Fkernel.cpp;h=0ac3ba7f21806a3a9198d38ceecc30f2b7ec47c0;hb=refs%2Ftags%2F3.1.2-a4;hp=6c0f27c72c413cb164865d2671dcc2e667bc618c;hpb=8849f9b808821b280514f23a8a26394963d97a77;p=vlp.git diff --git a/src/kernel/kernel.cpp b/src/kernel/kernel.cpp index 6c0f27c..0ac3ba7 100644 --- a/src/kernel/kernel.cpp +++ b/src/kernel/kernel.cpp @@ -65,6 +65,8 @@ #include "kernel.h" #include "send-message.h" +#include "kill-interpreter.h" +#include "options.h" /* File resides in top directory (where are Makefiles)*/ #include "../../config.h" @@ -430,50 +432,6 @@ void QKernel::QuitProc() QApplication::instance()->quit(); } -/** - * Adds IP address to the configuration. - * Additional window is displayed to add address to the list - */ -void QKernel::AddAddress() -{ - QDialog d(this, Qt::Dialog); - QLabel lab("IP Address:", &d); - QLineEdit ed("", &d); - QPushButton ob("", &d); - QPushButton cb("", &d); - - if (connections) { - ob.setGeometry(30, 60, 80, 30); - ob.setText("Ok"); - ob.setDefault(TRUE); - lab.setGeometry(10, 10, 60, 30); - lab.setText("Address"); - ed.setGeometry(70, 10, 140, 30); - cb.setGeometry(130, 60, 80, 30); - cb.setText("Cancel"); - d.resize(240, 100); - connect(&ob, SIGNAL(clicked()), &d, SLOT(accept())); - connect(&cb, SIGNAL(clicked()), &d, SLOT(reject())); - if (d.exec()) - if (strcmp(ed.text().toAscii().data(), "") != 0) { - connections->addItem(ed.text()); - } - } -} - -/** - * Deletes current address from available connections. - */ -void QKernel::DelAddress() -{ - if (connections) { - if (connections->currentRow() != -1) { - /* TODO: Checki if this work correctly after porting */ - connections->removeItemWidget(connections->currentItem()); - } - } -} - /** * Sends message to node. * Additional window is displayed to set Node Number of node where send message, @@ -483,7 +441,7 @@ void QKernel::on_actionMessage_triggered() { MESSAGE m; SendMessageDialog *dlg; - dlg = new SendMessageDialog(this); + dlg = new SendMessageDialog(this, Qt::Dialog); if (dlg->exec()) { m.msg_type = MSG_NET; @@ -504,35 +462,16 @@ void QKernel::on_actionMessage_triggered() */ 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)); @@ -777,92 +716,20 @@ void QKernel::on_actionInfo_messages_triggered() */ void QKernel::on_actionOptions_triggered() { - QDialog dlg(this, Qt::Dialog); - dlg.setWindowTitle("Options"); + OptionsDialog * dlg = new OptionsDialog(this, Qt::Dialog); ConnectEntry *e; + QListWidget *connections; unsigned int i; - QLineEdit* progs; - progs = new QLineEdit(progdir, &dlg); - progs->setGeometry(150, 20, 180, 30); - - QLabel* tmpQLabel; - tmpQLabel = new QLabel("Programs directory", &dlg); - tmpQLabel->setGeometry(30, 20, 120, 30); + dlg->setDefaultNodeNumber(NodeNumber); + dlg->setDefaultProgramsDirectory(progdir); - QFrame* tmpQFrame; - tmpQFrame = new QFrame(&dlg); - tmpQFrame->setGeometry(10, 60, 380, 30); - tmpQFrame->setFrameStyle(52); - - tmpQLabel = new QLabel("Virtual Processor properties (activated after " - "restarting VLP):", &dlg); - tmpQLabel->setGeometry(10, 80, 340, 30); - - QLineEdit *nn; - char nns[256]; - sprintf(nns, "%d", NodeNumber); - nn = new QLineEdit(nns, &dlg); - nn->setGeometry(110, 110, 40, 30); - - tmpQLabel = new QLabel("Node number:", &dlg); - tmpQLabel->setGeometry(20, 110, 90, 30); - - QRadioButton *exp, *reg; - exp = new QRadioButton("Explicit", &dlg); - exp->setGeometry(30, 170, 100, 30); - exp->setChecked(TRUE); - - reg = new QRadioButton("Registration", &dlg); - reg->setGeometry(30, 200, 100, 30); - reg->setEnabled(FALSE); - - connections = new QListWidget(&dlg); - connections->setGeometry(170, 140, 130, 100); - - for (int i = 0; i < ConnectList.size(); i++) { + for (i = 0; i < ConnectList.size(); i++) { e = ConnectList.at(i); - connections->addItem(e->addr); + dlg->addConnection(e); } - tmpQLabel = new QLabel("Connection list:", &dlg); - tmpQLabel->setGeometry(170, 110, 100, 30); - - QPushButton *addbtn; - QPushButton *delbtn; - QPushButton *okbtn; - QPushButton *cancelbtn; - addbtn = new QPushButton("Add", &dlg); - addbtn->setGeometry(310, 150, 60, 30); - connect(addbtn, SIGNAL(clicked()), this, SLOT(AddAddress())); - - delbtn = new QPushButton("Del", &dlg); - delbtn->setGeometry(310, 200, 60, 30); - connect(delbtn, SIGNAL(clicked()), this, SLOT(DelAddress())); - - okbtn = new QPushButton("Ok", &dlg); - okbtn->setGeometry(80, 260, 100, 30); - okbtn->setDefault(TRUE); - connect(okbtn, SIGNAL(clicked()), &dlg, SLOT(accept())); - - cancelbtn = new QPushButton("Cancel", &dlg); - cancelbtn->setGeometry(210, 260, 100, 30); - connect(cancelbtn, SIGNAL(clicked()), &dlg, SLOT(reject())); - - QGroupBox* group; - group = new QGroupBox("Connection type", &dlg); - group->setGeometry(20, 150, 120, 90); - group->setAlignment(Qt::AlignLeft); - group->lower(); - - QVBoxLayout *vbox = new QVBoxLayout(); - vbox->addWidget(exp); - vbox->addWidget(reg); - vbox->addStretch(1); - group->setLayout(vbox); - - dlg.resize(400, 310); - if (dlg.exec()) { + if (dlg->exec()) { config_t cfg; config_setting_t *root; config_setting_t *setting; @@ -872,12 +739,12 @@ void QKernel::on_actionOptions_triggered() setting = config_setting_add(root, "progdir", CONFIG_TYPE_STRING); - config_setting_set_string(setting, progs->text().toAscii().data()); - strcpy(progdir, progs->text().toAscii().data()); + strcpy(progdir, dlg->getProgramsDirectory().toAscii().data()); + config_setting_set_string(setting, progdir); setting = config_setting_add(root, "node_number", CONFIG_TYPE_INT); - config_setting_set_int(setting, atoi(nn->text().toAscii().data())); + config_setting_set_int(setting, dlg->getNodeNumber()); setting = config_setting_add(root, "homedir", CONFIG_TYPE_STRING); @@ -885,12 +752,15 @@ void QKernel::on_actionOptions_triggered() setting = config_setting_add(root, "type", CONFIG_TYPE_STRING); - if (exp->isChecked()) { + if (strcmp(dlg->getConnectionType().toLower().toAscii().data(), + "explicit") == 0) { config_setting_set_string(setting, "explicit"); config_setting_t *hosts = NULL; hosts = config_setting_add(root, "host", CONFIG_TYPE_ARRAY); + + connections = dlg->getConnectionList(); for(i = 0; i < connections->count(); i++) { setting = config_setting_add(hosts, NULL, CONFIG_TYPE_STRING);