2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
15 #include <KFileDialog>
16 #include <KMessageBox>
20 #include "mastersettings.h"
22 static const char* timeseal_cmd_tool_tip
=
23 "Expandable variables ref:\n"
24 " $(HOST_IP) - The resolved ip address of the host\n"
25 " $(HOST_NAME) - The host name\n"
26 " $(PORT) - The TCP port to connect to";
28 QConnect::QConnect(QWidget
*parent
, const char *name
)
34 connect(buttonTimesealPath
, SIGNAL(clicked()), this, SLOT(setTimesealPath()));
35 chkTimesealCmd
->setToolTip(timeseal_cmd_tool_tip
);
36 editTimesealCmd
->setToolTip(timeseal_cmd_tool_tip
);
37 //kDebug() << "initializing dialog";
39 Settings s_ics
= settings().group("ics");
40 if (s_ics
["username"])
41 editUsername
->setText(s_ics
["username"].value
<QString
>());
42 if (s_ics
["password"]) {
43 editPassword
->setText(s_ics
["password"].value
<QString
>());
44 chkStore
->setChecked(true);
47 editHost
->setText(s_ics
["host"] | "");
48 spinPort
->setValue((s_ics
["port"] | 5000));
49 Settings s_timeseal
= s_ics
.group("timeseal");
50 groupTimeseal
->setChecked(s_timeseal
.flag("use", false));
51 editTimeseal
->setText(s_timeseal
["path"] |= QString());
52 chkTimesealCmd
->setChecked(s_timeseal
["command"].flag("use", false)); editTimesealCmd
->setText(s_timeseal
["command"] |= "$(HOST_IP) $(PORT)");
55 void QConnect::setTimesealPath() {
56 KUrl url
= KFileDialog::getOpenUrl(KUrl(), "*", this, i18n("Select timeseal binary"));
58 if (!url
.isLocalFile()) {
59 KMessageBox::sorry(0, i18n("Only local executables supported"));
64 editTimeseal
->setText(url
.path());
67 void QConnect::accept() {
70 Settings s_ics
= settings().group("ics");
71 s_ics
["username"] = editUsername
->text();
72 if (chkStore
->isChecked())
73 s_ics
["password"] = editPassword
->text();
75 s_ics
["password"].remove();
76 s_ics
["host"] = editHost
->text();
77 s_ics
["port"] = spinPort
->value();
80 Settings s_timeseal
= s_ics
.group("timeseal");
81 s_timeseal
.setFlag("use", groupTimeseal
->isChecked());
82 s_timeseal
["path"] = editTimeseal
->text();
83 s_timeseal
.group("command").setFlag("use", chkTimesealCmd
->isChecked());
84 s_timeseal
["command"] = editTimesealCmd
->text();
87 acceptConnection(editUsername
->text(),
91 groupTimeseal
->isChecked() ? editTimeseal
->text() : QString(),
92 chkTimesealCmd
->isChecked() ? editTimesealCmd
->text() :
93 QString("$(HOST_IP) $(PORT)")