Debian Codegraph @

HercConfiguration/ConfigurationEditor.cpp

raw symbols SCIP
1 /*
2 * File: ConfigurationEditor.cpp
3 *
4 * Author: Jacob Dekel
5 * Created on: Aug 7, 2009
6 *
7 * Copyright (c) 2009-2013 Jacob Dekel
8 * $Id$
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 *
23 */
24
25 #include "ConfigurationEditor.h"
26 #include "HerculesStudio.h"
27
28 #include <QRegExp>
29
30 #include <iostream>
31 #include <sstream>
32 #include <iomanip>
33
34 #define min(a,b) ((a) < (b) ? (a) : (b)) //util
35 #define max(a,b) ((a) > (b) ? (a) : (b)) //util
36
37 #define TextItem(PARM,_parm) \
38 void ConfigurationEditor::PARM(Ui::ConfigurationClass * configUi, const ConfigLine * configLine, Direction dir) \
39 { \
40 handleText(configUi->_parm, configLine, dir);\
41 }
42
43 #define SliderItem(PARM,_parm) \
44 void ConfigurationEditor::PARM(Ui::ConfigurationClass * configUi, const ConfigLine * configLine, Direction dir) \
45 { \
46 handleSlider(configUi->_parm, configLine, dir); \
47 }
48
49 #define CheckBoxItem(PARM,parm, CHECKED, UNCHECKED) \
50 void ConfigurationEditor::PARM(Ui::ConfigurationClass * configUi, const ConfigLine * configLine, Direction dir) \
51 { \
52 handleCheckbox(configUi->parm, configLine, dir, #CHECKED, #UNCHECKED); \
53 }
54
55 #define SpinItem(PARM,_parm, default_) \
56 void ConfigurationEditor::PARM(Ui::ConfigurationClass * configUi, const ConfigLine * configLine, Direction dir) \
57 {\
58 handleSpin(configUi->_parm, configLine, dir, default_); \
59 }
60
61 void ConfigurationEditor::handleText(QLineEdit * lineEdit, const ConfigLine * configLine, Direction dir)
62 {
63 std::string parm = configLine->getToken(1);
64 hOutDebug(4,configLine->getToken(0) << std::endl);
65 if (dir == toScreen)
66 {
67 if (configLine->getToken(2).length() != 0)
68 configLine->setInError(configLine->getAbsoluteTokenColumn(2));
69 lineEdit->setText(parm.c_str());
70 }
71 else
72 {
73 /*TODO: verification routine*/
74 if (lineEdit->isModified())
75 {
76 const_cast<ConfigLine *>(configLine)->replaceParameters(lineEdit->text().toStdString());
77 }
78 }
79 }
80
81 void ConfigurationEditor::handleSpin(QSpinBox * spinBox, const ConfigLine * configLine, Direction dir, int dflt)
82 {
83 std::string keyword = configLine->getUppercaseToken(0);
84 std::string parm = configLine->getToken(1);
85 hOutDebug(4,parm);
86 if (dir == toScreen)
87 {
88 std::string parm = configLine->getToken(1);
89 if (parm.length() > 0)
90 {
91 if (parm[0] == '+') parm = parm.substr(1);
92 int num = parseNum(parm);
93 if (parm.length() > 0 && num == 0 && parm[0] != '0')
94 {
95 num = dflt;
96 configLine->setInError(configLine->getAbsoluteTokenColumn(1));
97 }
98 spinBox->setValue(num);
99 }
100 else
101 {
102 spinBox->setValue(0);
103 }
104 mSpinMap[keyword] = spinBox->value();
105 if (configLine->getToken(2).length() != 0)
106 configLine->setInError(configLine->getAbsoluteTokenColumn(2));
107 }
108 else
109 {
110 /*TODO: verification routine*/
111 if (mSpinMap[keyword] != spinBox->value())
112 const_cast<ConfigLine *>(configLine)->replaceParameters(spinBox->text().toStdString());
113 }
114 }
115
116 void ConfigurationEditor::handleSpin(QDoubleSpinBox * doubleSpinBox, const ConfigLine * configLine, Direction dir, int dflt)
117 {
118 std::string parm = configLine->getToken(1);
119 hOutDebug(4, parm);
120 if (dir == toScreen)
121 {
122 std::string parm = configLine->getToken(1);
123 if (parm.length() > 0)
124 {
125 if (parm[0] == '+') parm = parm.substr(1);
126 int num = parseNum(parm);
127 if (parm.length() > 0 && num == 0 && parm[0] != '0')
128 {
129 num = dflt;
130 configLine->setInError(configLine->getAbsoluteTokenColumn(1));
131 }
132 doubleSpinBox->setValue(num);
133 }
134 else
135 {
136 doubleSpinBox->setValue(0);
137 }
138 mSpinMap[parm] = doubleSpinBox->value();
139 if (configLine->getToken(2).length() != 0)
140 configLine->setInError(configLine->getAbsoluteTokenColumn(2));
141 }
142 else
143 {
144 /*TODO: verification routine*/
145 if (mSpinMap[parm] != doubleSpinBox->value())
146 const_cast<ConfigLine *>(configLine)->replaceParameters(doubleSpinBox->text().toStdString());
147 }
148 }
149
150 void ConfigurationEditor::handleSlider(QSlider * slider, const ConfigLine * configLine, Direction dir)
151 {
152 std::string keyword = configLine->getToken(0);
153 std::string parm = configLine->getToken(1);
154 if (dir == toScreen)
155 {
156 int num = parseNum(parm);
157 if (parm[0] == '-' || parm[0] == '+') parm = parm.substr(1);
158 if (num == 0 && parm.find_first_not_of("0123456789") != std::string::npos)
159 configLine->setInError(configLine->getAbsoluteTokenColumn(1));
160 slider->setValue(num);
161 mSpinMap[keyword] = slider->value();
162 if (configLine->getToken(2).length() != 0)
163 configLine->setInError(configLine->getAbsoluteTokenColumn(2));
164 }
165 else
166 {
167 if(slider->isWindowModified()){};
168 /*TODO: verification routine*/
169 if (mSpinMap[keyword] != slider->value())
170 {
171 std::stringstream s;
172 s << slider->value();
173 std::string parm = s.str();
174 const_cast<ConfigLine *>(configLine)->replaceParameters(s.str());
175 }
176 }
177 }
178
179 void ConfigurationEditor::handleCheckbox(QCheckBox * checkbox, const ConfigLine * configLine, Direction dir, QString checked, QString unchecked)
180 {
181 QString name=configLine->getToken(0).c_str();
182 QString parm=configLine->getToken(1).c_str();
183 hOutDebug(2,parm.toStdString());
184 if (dir == toScreen)
185 {
186 if (parm=="") parm=unchecked;
187 checkbox->setChecked( (parm.toUpper() == checked ) ? true : false);
188 mCheckBoxMap[name.toStdString()] = checkbox->isChecked();
189 if (configLine->getToken(2).length() != 0)
190 configLine->setInError(configLine->getAbsoluteTokenColumn(2));
191 }
192 else
193 {
194 if ( (checkbox->isChecked() != mCheckBoxMap[name.toStdString()]) )
195 {
196 if (checkbox->isChecked())
197 const_cast<ConfigLine *>(configLine)->replaceParameters(checked.toStdString());
198 else
199 const_cast<ConfigLine *>(configLine)->replaceParameters(unchecked.toStdString());
200 }
201 }
202 }
203
204
205 std::map<std::string,bool>ConfigurationEditor::mCheckBoxMap;
206 std::map<std::string,int>ConfigurationEditor::mSpinMap;
207
208 ConfigurationEditor::ConfigurationEditor()
209 {
210 hOutDebug(5,"ConfigurationEditor::ConfigurationEditor");
211 }
212
213 ConfigurationEditor::~ConfigurationEditor()
214 {
215 }
216
217 void ConfigurationEditor::ARCHMODE(Ui::ConfigurationClass * configUi, const ConfigLine * configLine, Direction dir)
218 {
219 if (dir == toScreen)
220 {
221 hOutDebug(4,"ARCHMODE");
222 std::string token = configLine->getLowercaseToken(1);
223 if (token == "s/370")
224 configUi->s370Button->setChecked(true);
225 else if (token == "esa/390")
226 configUi->ESA390Button->setChecked(true);
227 else if ((token == "esame") || (token == "z/arch") || (token == "z/arch"))
228 configUi->ZArchButton->setChecked(true);
229 else
230 {
231 configLine->setInError(configLine->getAbsoluteTokenColumn(1));
232 }
233 int value;
234 if (configUi->s370Button->isChecked()) value = 0;
235 else if (configUi->ESA390Button->isChecked()) value = 1;
236 else value = 2;
237 mSpinMap["ARCHMODE"] = value;
238 validateMaxTokens(configLine, 1);
239 }
240 else
241 {
242 int value;
243 if (configUi->s370Button->isChecked()) value = 0;
244 else if (configUi->ESA390Button->isChecked()) value = 1;
245 else value = 2;
246 if (value != mSpinMap["ARCHMODE"])
247 {
248 std::string parm;
249 if (configUi->s370Button->isChecked())
250 parm="S/370";
251 else if(configUi->ESA390Button->isChecked())
252 parm="ESA/390";
253 else
254 parm="z/Arch";
255 const_cast<ConfigLine *>(configLine)->replaceParameters(parm);
256 }
257 }
258 }
259
260 CheckBoxItem(ASN_AND_LX_REUSE,alrfCheck, ENABLE, DISABLE)
261 //CheckBoxItem(ALRF,alrfCheck, ENABLE, DISABLE)
262
263 void ConfigurationEditor::ALRF(Ui::ConfigurationClass * configUi, const ConfigLine * configLine, Direction dir)
264 {
265 handleCheckbox(configUi->alrfCheck, configLine, dir, "ENABLE", "DISABLE");
266 }
267
268 void ConfigurationEditor::AUTO_MOUNT(Ui::ConfigurationClass * configUi, const ConfigLine * configLine, Direction dir)
269 {
270 // TODO: accept "-", but do not generate one
271 hOutDebug(4,"AUTO_MOUNT");
272 if (dir == toScreen)
273 {
274 std::string parm=configLine->getToken(1);
275 if (parm=="+" || parm == "-")
276 parm=configLine->getToken(1);
277 configUi->autoMountDir->setText(parm.c_str());
278 }
279 else if (configUi->autoMountDir->isModified())
280 {
281 const std::string val = configUi->autoMountDir->text().toStdString();
282 const_cast<ConfigLine *>(configLine)->replaceParameters(val);
283 }
284 }
285
286 void ConfigurationEditor::AUTO_SCSI_MOUNT(Ui::ConfigurationClass * configUi, const ConfigLine * configLine, Direction dir)
287 {
288 hOutDebug(4,"AUTO_SCSI_MOUNT");
289 if (dir == toScreen)
290 {
291 std::string parm = configLine->getLowercaseToken(1);
292 int num = parseNum(parm);
293 if (parm.length() == 0)
294 num = 50;
295 if (parm.length() != 0 && parm.compare("yes") == 0)
296 {
297 configUi->autoScsiMountCheck->setChecked(true);
298 configUi->autoScisiSecSpin->setDisabled(false);
299 configUi->autoScisiSecSpin->setValue(50);
300 }
301 else if (parm.length() != 0 && parm.compare("no") == 0)
302 {
303
304 configUi->autoScsiMountCheck->setChecked(true);
305 configUi->autoScisiSecSpin->setDisabled(false);
306 configUi->autoScisiSecSpin->setValue(num);
307 }
308 else
309 {
310 configUi->autoScsiMountCheck->setChecked(false);
311 configUi->autoScisiSecSpin->setValue(num);
312 configUi->autoScisiSecSpin->setDisabled(true);
313 }
314 mCheckBoxMap["AUTO_SCSI_MOUNT"] = configUi->autoScsiMountCheck->isChecked();
315 mSpinMap["AUTO_SCSI_MOUNT"] = configUi->autoScisiSecSpin->value();
316 }
317 else if (mCheckBoxMap["AUTO_SCSI_MOUNT"] != configUi->autoScsiMountCheck->isChecked() ||
318 mSpinMap["AUTO_SCSI_MOUNT"] != configUi->autoScisiSecSpin->value() )
319 {
320 std::string parm;
321 if (!configUi->autoScsiMountCheck->isChecked())
322 {
323 parm = "NO";
324 }
325 else
326 {
327 int val = configUi->autoScisiSecSpin->value();
328 std::stringstream s;
329 s << val;
330 parm = s.str();
331 }
332 hOutDebug(3,"parm=" << parm);
333 const_cast<ConfigLine *>(configLine)->replaceParameters(parm);
334 }
335 }
336
337 SpinItem(CNSLPORT,ConsolePortSpin, 3270)
338
339 void ConfigurationEditor::CONKPALV(Ui::ConfigurationClass *, const ConfigLine * configLine, Direction dir)
340 {
341 if (dir == toScreen)
342 {
343 // just parse (we do not yet have a screen display for this parameter
344 QRegExp exp("\\s+\\((\\d*),(\\d*),(\\d*)\\)");
345
346 QString line(configLine->getLine().substr(8).c_str());
347 if (exp.indexIn(line) == -1)
348 configLine->setInError(8);
349 else
350 configLine->setNoError();
351 }
352 }
353
354 TextItem(CPUMODEL,CpuModel)
355 SliderItem(CPUPRIO,cpuPrioSlider)
356 TextItem(CPUSERIAL,cpuSerial)
357 TextItem(CPUVERID,cpuVerid)
358 SliderItem(DEVPRIO,devPrioSlider)
359 SpinItem(DEVTMAX,devTMaxSpin, 0)
360
361 void ConfigurationEditor::DIAG8CMD(Ui::ConfigurationClass * configUi, const ConfigLine * configLine, Direction dir)
362 {
363 hOutDebug(4,"DIAG8CMD");
364 if (dir == toScreen)
365 {
366 std::string enableDisable = configLine->getLowercaseToken(1);
367 std::string echoNoEcho = configLine->getLowercaseToken(2);
368
369 if (enableDisable.compare("enable") == 0)
370 configUi->diag8CmdCheckBox->setChecked(true);
371 else if (enableDisable.compare("disable") == 0)
372 configUi->diag8CmdCheckBox->setChecked(false);
373 else
374 configLine->setInError(configLine->getAbsoluteTokenColumn(1));
375
376 if (echoNoEcho.length() > 0 && echoNoEcho.compare("echo") == 0)
377 configUi->diag8EchoCheckBox->setChecked(true);
378 else if (echoNoEcho.length() > 0 && echoNoEcho.compare("noecho") == 0)
379 configUi->diag8EchoCheckBox->setChecked(false);
380 else if (echoNoEcho.length() == 0)
381 configUi->diag8EchoCheckBox->setChecked(false);
382 else configLine->setInError(configLine->getAbsoluteTokenColumn(2));
383 validateMaxTokens(configLine, 2);
384 mCheckBoxMap["DIAG8CMD"]=configUi->diag8CmdCheckBox->isChecked();
385 mCheckBoxMap["DIAG8ECHO"]=configUi->diag8EchoCheckBox->isChecked();
386 }
387 else if (mCheckBoxMap["DIAG8CMD"] != configUi->diag8CmdCheckBox->isChecked() ||
388 mCheckBoxMap["DIAG8ECHO"]!= configUi->diag8EchoCheckBox->isChecked())
389 {
390 std::string enable, echo;
391 if (configUi->diag8EchoCheckBox->isChecked())
392 echo = "ECHO";
393 else
394 echo = "NOECHO";
395 if (configUi->diag8CmdCheckBox->isChecked())
396 enable = "ENABLE";
397 else
398 enable = "DISABLE";
399
400 std::string parm = enable + " " + echo;
401 const_cast<ConfigLine *>(configLine)->replaceParameters(parm);
402 }
403 }
404
405 TextItem(ENGINES,engines)
406
407 void ConfigurationEditor::ECPSVM(Ui::ConfigurationClass * configUi, const ConfigLine * configLine, Direction dir)
408 {
409 hOutDebug(4,"ECPSVM");
410 if (dir == toScreen)
411 {
412 if (configLine->getLowercaseToken(1) == "yes" || configLine->getLowercaseToken(1) == "level")
413 {
414 configUi->ecpSvmSpin->setEnabled(true);
415 configUi->ecpSvm->setChecked(true);
416 int level = 20;
417 if (configLine->getToken(2) != "")
418 level = parseNum(configLine->getToken(2));
419 configUi->ecpSvmSpin->setValue(level);
420 }
421 else if (configLine->getLowercaseToken(1) == "no")
422 {
423 configUi->ecpSvm->setChecked(false);
424 configUi->ecpSvmSpin->setValue(20);
425 configUi->ecpSvmSpin->setEnabled(false);
426 }
427 else configLine->setInError(configLine->getAbsoluteTokenColumn(1));
428 mCheckBoxMap["ECPSVM"] = configUi->ecpSvm->isChecked();
429 mSpinMap["ECPSVM"] = configUi->ecpSvmSpin->value();
430 validateMaxTokens(configLine, 1);
431 }
432 else if ( mCheckBoxMap["ECPSVM"] != configUi->ecpSvm->isChecked() ||
433 mSpinMap["ECPSVM"] != configUi->ecpSvmSpin->value() )
434 {
435 std::string parm;
436 if (configUi->ecpSvm->isChecked())
437 {
438 std::stringstream ss;
439 ss << configUi->ecpSvmSpin->value();
440 parm = "LEVEL " + ss.str();
441 }
442 else parm = "NO";
443 const_cast<ConfigLine *>(configLine)->replaceParameters(parm);
444 }
445 }
446
447 SliderItem(HERCPRIO,hercPrioSlider)
448
449 void ConfigurationEditor::HTTPPORT(Ui::ConfigurationClass * configUi, const ConfigLine * configLine, Direction dir) \
450 {
451 hOutDebug(4,"HTTPPORT");
452 if (dir == toScreen)
453 {
454 std::string parm = configLine->getToken(1);
455 if ( parm.find_first_not_of("01234567890") != std::string::npos )
456 configLine->setInError(configLine->getAbsoluteTokenColumn(1));
457 int num = parseNum(parm);
458 if (num !=0)
459 {
460 configUi->httpPortSpin->setValue(num);
461 configUi->httpPortSpin->setEnabled(true);
462 configUi->httpPortCheckBox->setChecked(true);
463 }
464 else
465 {
466 configUi->httpPortCheckBox->setChecked(false);
467 configUi->httpPortSpin->setValue(0);
468 configUi->httpPortSpin->setEnabled(false);
469 }
470 mSpinMap["HTTPPORT"] = configUi->httpPortSpin->value();
471 validateMaxTokens(configLine,1);
472 }
473 else
474 {
475 if (mSpinMap["HTTPPORT"] != configUi->httpPortSpin->value())
476 const_cast<ConfigLine *>(configLine)->replaceParameters(configUi->httpPortSpin->text().toStdString());
477 }
478 }
479
480 void ConfigurationEditor::HTTPROOT(Ui::ConfigurationClass * configUi, const ConfigLine * configLine, Direction dir)
481 {
482 hOutDebug(4,"HTTPROOT");
483 if (dir == toScreen)
484 {
485 std::string parm=configLine->getToken(1);
486 if (parm=="+" || parm == "-")
487 parm=configLine->getToken(1);
488 configUi->httpRootDir->setText(parm.c_str());
489 validateMaxTokens(configLine,1);
490 }
491 else if (configUi->httpRootDir->isModified())
492 {
493 const std::string val = configUi->httpRootDir->text().toStdString();
494 const_cast<ConfigLine *>(configLine)->replaceParameters(val);
495 }
496 }
497
498 SpinItem(IODELAY,ioDelaySpin, 0)
499 TextItem(LDMOD,ldmod)
500
501 void ConfigurationEditor::LEGACYSENSEID(Ui::ConfigurationClass * configUi, const ConfigLine * configLine, Direction dir)
502 {
503 hOutDebug(4,"LEGACYSENSEID");
504 if (dir == toScreen)
505 {
506 std::string parm=configLine->getUppercaseToken(1);
507 if ( (parm == "ON") || (parm == "ENABLE") )
508 configUi->legacySenseIdCheckbox->setChecked(true);
509 else if ( (parm == "OFF") || (parm == "DISABLE") )
510 configUi->legacySenseIdCheckbox->setChecked(false);
511 else
512 configLine->setInError(configLine->getAbsoluteTokenColumn(1));
513 validateMaxTokens(configLine,1);
514 mCheckBoxMap["LEGACYSENSEID"] = configUi->legacySenseIdCheckbox->isChecked();
515 }
516 else
517 {
518 if (mCheckBoxMap["LEGACYSENSEID"] != configUi->legacySenseIdCheckbox->isChecked())
519 {
520 if (configUi->legacySenseIdCheckbox->isChecked())
521 const_cast<ConfigLine *>(configLine)->replaceParameters("ENABLE");
522 else
523 const_cast<ConfigLine *>(configLine)->replaceParameters("DISABLE");
524 }
525 }
526 }
527
528 TextItem(LOADPARM,loadParm)
529 CheckBoxItem(LOGOPT,logopt, TIMESTAMP, NOTIMESTAMP)
530 TextItem(LPARNAME,lparName)
531 SpinItem(MAINSIZE,mainSizeSpin, 64)
532 TextItem(MANUFACTURER,manufacturer)
533 TextItem(MODEL,model)
534 CheckBoxItem(MOUNTED_TAPE_REINIT,mountedTapeReinitCheckbox,ALLOW,DISALLOW)
535
536 void ConfigurationEditor::MODPATH(Ui::ConfigurationClass * configUi, const ConfigLine * configLine, Direction dir)
537 {
538 hOutDebug(4,"MODPATH");
539 if (dir == toScreen)
540 {
541 std::string parm=configLine->getToken(1);
542 configUi->modPath->setText(parm.c_str());
543 validateMaxTokens(configLine,1);
544 }
545 else if (configUi->modPath->isModified())
546 {
547 const std::string val = configUi->modPath->text().toStdString();
548 const_cast<ConfigLine *>(configLine)->replaceParameters(val);
549 }
550 }
551
552 SpinItem(NUMCPU,numCpuSpin, 1)
553 SpinItem(NUMVEC,numVecSpin, 0)
554
555 void ConfigurationEditor::OSTAILOR(Ui::ConfigurationClass * configUi, const ConfigLine * configLine, Direction dir)
556 {
557 hOutDebug(4,"OSTAILOR");
558 if (dir == toScreen)
559 {
560 std::string parm = configLine->getUppercaseToken(1);
561 int initialValue = 0;
562 if (parm == "QUIET")
563 {
564 configUi->quiet->setChecked(true);
565 initialValue = 1;
566 }
567 else if (parm == "VM")
568 {
569 configUi->vm->setChecked(true);
570 initialValue = 2;
571 }
572 else if (parm == "VSE")
573 {
574 configUi->vse->setChecked(true);
575 initialValue = 3;
576 }
577 else if (parm == "LINUX")
578 {
579 configUi->linuxb->setChecked(true);
580 initialValue = 4;
581 }
582 else if (parm == "OS/390")
583 {
584 configUi->os390->setChecked(true);
585 initialValue = 5;
586
587 }
588 else if (parm == "Z/OS")
589 {
590 configUi->zOS->setChecked(true);
591 initialValue = 6;
592 }
593 else if (parm == "")
594 {
595 configUi->none->setChecked(true);
596 initialValue = 0;
597 }
598 else
599 {
600 configLine->setInError(configLine->getAbsoluteTokenColumn(1));
601 }
602 validateMaxTokens(configLine,1);
603 mSpinMap["OSTAILOR"] = initialValue;
604 }
605 else
606 {
607 int value;
608 if (configUi->quiet->isChecked()) value=1;
609 else if (configUi->vm->isChecked()) value=2;
610 else if (configUi->vse->isChecked()) value=3;
611 else if (configUi->linuxb->isChecked()) value=4;
612 else if (configUi->os390->isChecked()) value=5;
613 else if (configUi->zOS->isChecked()) value=6;
614 else value=0;
615 if (value != mSpinMap["OSTAILOR"])
616 {
617 if (configUi->quiet->isChecked())
618 const_cast<ConfigLine *>(configLine)->replaceParameters("QUIET");
619 else if (configUi->vm->isChecked())
620 const_cast<ConfigLine *>(configLine)->replaceParameters("VM");
621 else if (configUi->vse->isChecked())
622 const_cast<ConfigLine *>(configLine)->replaceParameters("VSE");
623 else if (configUi->linuxb->isChecked())
624 const_cast<ConfigLine *>(configLine)->replaceParameters("LINUX");
625 else if (configUi->os390->isChecked())
626 const_cast<ConfigLine *>(configLine)->replaceParameters("OS/390");
627 else if (configUi->zOS->isChecked())
628 const_cast<ConfigLine *>(configLine)->replaceParameters("z/OS");
629 else if (configUi->none->isChecked())
630 const_cast<ConfigLine *>(configLine)->replaceParameters("NONE");
631 }
632 }
633 }
634
635 void ConfigurationEditor::PANRATE(Ui::ConfigurationClass * configUi, const ConfigLine * configLine, Direction dir)
636 {
637 hOutDebug(4,"PANRATE");
638 if (dir == toScreen)
639 {
640 std::string panRateSpin = configLine->getLowercaseToken(1);
641 if (panRateSpin.length() == 0)
642 configLine->setInError(configLine->getAbsoluteTokenColumn(1));
643 if (panRateSpin[0] == '+') panRateSpin = panRateSpin.substr(1);
644 int num = parseNum(panRateSpin);
645 if (panRateSpin.length() > 0 && num == 0)
646 {
647 if (panRateSpin.compare("fast") == 0) num=50;
648 else if (panRateSpin.compare("slow") == 0) num=500;
649 else
650 {
651 num = 500;
652 configLine->setInError(configLine->getAbsoluteTokenColumn(1));
653 }
654 }
655 configUi->panRateSpin->setValue(num);
656 mSpinMap["PANRATE"] = configUi->panRateSpin->value();
657 if (configLine->getToken(2).length() != 0)
658 configLine->setInError(configLine->getAbsoluteTokenColumn(2));
659 }
660 else
661 {
662 /*TODO: verification routine*/
663 if (mSpinMap["PANRATE"] != configUi->panRateSpin->value())
664 const_cast<ConfigLine *>(configLine)->replaceParameters(configUi->panRateSpin->text().toStdString());
665 }
666 }
667
668 CheckBoxItem(PGMPRDOS,pgmPrdOs,LICENSED,RESTRICTED)
669 TextItem(PLANT,plant)
670 CheckBoxItem(SHCMDOPT,shCmdOpt,DISABLE, NODIAG8)
671 SpinItem(SHRDPORT,shrdPortSpin, 3990)
672 SpinItem(SYSEPOCH,sysepochSpin, 1900)
673 SpinItem(TIMERINT,timerIntSpin, 50)
674 SpinItem(TODDRAG,todDragSpin, 0)
675 SliderItem(TODPRIO,todPrioSlider)
676
677 void ConfigurationEditor::TZOFFSET(Ui::ConfigurationClass * configUi, const ConfigLine * configLine, Direction dir)
678 {
679 hOutDebug(5,"TZOFFSET:");
680 if (dir == toScreen)
681 {
682 std::string parm = configLine->getToken(1);
683 if (parm.length() < 4)
684 {
685 configLine->setInError(configLine->getAbsoluteTokenColumn(1));
686 return;
687 }
688 hOutDebug(5,"parm=" << parm);
689 int hh = 0, mm = 0;
690 int sig = 1;
691 if (parm[0] == '+') parm = parm.substr(1);
692 if (parm[0] == '-')
693 {
694 parm = parm.substr(1);
695 sig = -1;
696 }
697 if (parm.length() == 3)
698 {
699 hh = sig*(parm[0]-'0');
700 mm = parseNum(parm.substr(1));
701 }
702 else if (parm.length() == 4)
703 {
704 hh = sig*parseNum(parm.substr(0,2));
705 mm = parseNum(parm.substr(2,2));
706 }
707 else
708 {
709 configLine->setInError(configLine->getAbsoluteTokenColumn(1));
710 }
711 configUi->tzOffsetHH->setValue(hh);
712 configUi->tzOffsetMM->setValue(mm);
713 hOutDebug(5,"HH:" << hh << "MM:" << mm);
714 mSpinMap["TZOFFSET"] = parseNum(parm);
715 validateMaxTokens(configLine,1);
716 }
717 else
718 {
719 int iParm = configUi->tzOffsetHH->value()*100 + configUi->tzOffsetMM->value();
720 if (mSpinMap["TZOFFSET"] != iParm)
721 {
722 QString parm = configUi->tzOffsetHH->text() + configUi->tzOffsetMM->text();
723 hOutDebug(5, "parm:" << parm.toUtf8().data());
724 const_cast<ConfigLine *>(configLine)->replaceParameters(parm.toStdString());
725 }
726 }
727 }
728
729
730
731 SpinItem(XPNDSIZE,xpndSizeSpin, 0)
732 SpinItem(YROFFSET,yrOffsetSpin, 0)
733
734 /////////////////////////////////////////////////////////////////////////////////////////////////
735
736 bool ConfigurationEditor::validateNum(const std::string& str, int base)
737 {
738 if (base == 16)
739 {
740 QString qstr = str.c_str();
741 if (qstr.toLower().toStdString().find_first_not_of("0123456789abcdef") != std::string::npos)
742 return false;
743 else
744 return true;
745 }
746 return true;
747 }
748 int ConfigurationEditor::parseNum(const std::string& str, int base)
749 {
750 int ret=0;
751 int sign = 1;
752 const char *c = str.c_str();
753 static std::string digits = "0123456789abcdef";
754 if (*c == '-')
755 {
756 sign = -1;
757 c++;
758 }
759 for ( ; *c != '\0' ; c++)
760 {
761 char pc = *c;
762 if (base==10 && !isdigit(pc)) break;
763 if ( (pc <= 'Z') && (pc >= 'A') ) pc+=('a'-'A');
764 ret *= base;
765 //ret += (*c-'0');
766 size_t i = digits.find_first_of(pc) ;
767 ret += i;
768 }
769 return ret*sign;
770 }
771
772 std::string ConfigurationEditor::normalizeNum(const std::string& str, int width, int base)
773 {
774 int devno = parseNum(str,base);
775 std::stringstream newLine;
776 newLine << std::hex << std::setw(width) << std::setfill('0') << std::uppercase
777 << devno ;
778 return newLine.str();
779 }
780
781 void ConfigurationEditor::validateMaxTokens(const ConfigLine * configLine, int maxNum)
782 {
783 if (configLine->size() > maxNum+1) // size is 1-based maxNum is 0-based
784 configLine->setInError(configLine->getAbsoluteTokenColumn(maxNum+1));
785 }