Changeset View
Changeset View
Standalone View
Standalone View
krfb/mainwindow.cpp
Show All 12 Lines | |||||
13 | #include "krfbconfig.h" | 13 | #include "krfbconfig.h" | ||
14 | #include "ui_configtcp.h" | 14 | #include "ui_configtcp.h" | ||
15 | #include "ui_configsecurity.h" | 15 | #include "ui_configsecurity.h" | ||
16 | #include "ui_configframebuffer.h" | 16 | #include "ui_configframebuffer.h" | ||
17 | 17 | | |||
18 | #include <KConfigDialog> | 18 | #include <KConfigDialog> | ||
19 | #include <KLocalizedString> | 19 | #include <KLocalizedString> | ||
20 | #include <KMessageBox> | 20 | #include <KMessageBox> | ||
21 | #include <KMessageWidget> | ||||
21 | #include <KStandardAction> | 22 | #include <KStandardAction> | ||
22 | #include <KActionCollection> | 23 | #include <KActionCollection> | ||
23 | #include <KLineEdit> | 24 | #include <KLineEdit> | ||
24 | #include <KNewPasswordDialog> | 25 | #include <KNewPasswordDialog> | ||
25 | #include <KPluginLoader> | 26 | #include <KPluginLoader> | ||
26 | #include <KPluginMetaData> | 27 | #include <KPluginMetaData> | ||
27 | 28 | | |||
28 | #include <QIcon> | 29 | #include <QIcon> | ||
Show All 14 Lines | 41 | public: | |||
43 | } | 44 | } | ||
44 | }; | 45 | }; | ||
45 | 46 | | |||
46 | class Security: public QWidget, public Ui::Security | 47 | class Security: public QWidget, public Ui::Security | ||
47 | { | 48 | { | ||
48 | public: | 49 | public: | ||
49 | Security(QWidget *parent = nullptr) : QWidget(parent) { | 50 | Security(QWidget *parent = nullptr) : QWidget(parent) { | ||
50 | setupUi(this); | 51 | setupUi(this); | ||
52 | walletWarning = new KMessageWidget(this); | ||||
53 | walletWarning->setText(i18n("Storing passwords in config file is insecure!")); | ||||
54 | walletWarning->setCloseButtonVisible(false); | ||||
55 | walletWarning->setMessageType(KMessageWidget::Warning); | ||||
56 | walletWarning->hide(); | ||||
57 | vboxLayout->addWidget(walletWarning); | ||||
58 | | ||||
59 | // show warning when "noWallet" checkbox is unchecked | ||||
60 | QObject::connect(kcfg_noWallet, &QCheckBox::toggled, [this](bool checked){ | ||||
61 | walletWarning->setVisible(!checked); | ||||
62 | }); | ||||
51 | } | 63 | } | ||
64 | | ||||
65 | KMessageWidget *walletWarning = nullptr; | ||||
52 | }; | 66 | }; | ||
53 | 67 | | |||
54 | class ConfigFramebuffer: public QWidget, public Ui::Framebuffer | 68 | class ConfigFramebuffer: public QWidget, public Ui::Framebuffer | ||
55 | { | 69 | { | ||
56 | public: | 70 | public: | ||
57 | ConfigFramebuffer(QWidget *parent = nullptr) : QWidget(parent) { | 71 | ConfigFramebuffer(QWidget *parent = nullptr) : QWidget(parent) { | ||
58 | setupUi(this); | 72 | setupUi(this); | ||
59 | // hide the line edit with framebuffer string | 73 | // hide the line edit with framebuffer string | ||
▲ Show 20 Lines • Show All 161 Lines • ▼ Show 20 Line(s) | 234 | { | |||
221 | KMessageBox::about(this, | 235 | KMessageBox::about(this, | ||
222 | i18n("Any remote user with normal desktop sharing password will have to be authenticated.\n\nIf unattended access is on, and the remote user provides unattended mode password, desktop sharing access will be granted without explicit confirmation."), | 236 | i18n("Any remote user with normal desktop sharing password will have to be authenticated.\n\nIf unattended access is on, and the remote user provides unattended mode password, desktop sharing access will be granted without explicit confirmation."), | ||
223 | i18n("KDE Desktop Sharing")); | 237 | i18n("KDE Desktop Sharing")); | ||
224 | } | 238 | } | ||
225 | 239 | | |||
226 | void MainWindow::showConfiguration() | 240 | void MainWindow::showConfiguration() | ||
227 | { | 241 | { | ||
228 | static QString s_prevFramebufferPlugin; | 242 | static QString s_prevFramebufferPlugin; | ||
243 | static bool s_prevNoWallet; | ||||
229 | // ^^ needs to be static, because lambda will be called long time | 244 | // ^^ needs to be static, because lambda will be called long time | ||
230 | // after showConfiguration() ends, so auto variable would go out of scope | 245 | // after showConfiguration() ends, so auto variable would go out of scope | ||
231 | // save previously selected framebuffer plugin config | 246 | // save previously selected framebuffer plugin config | ||
232 | s_prevFramebufferPlugin = KrfbConfig::preferredFrameBufferPlugin(); | 247 | s_prevFramebufferPlugin = KrfbConfig::preferredFrameBufferPlugin(); | ||
248 | s_prevNoWallet = KrfbConfig::noWallet(); | ||||
233 | 249 | | |||
234 | if (KConfigDialog::showDialog("settings")) { | 250 | if (KConfigDialog::showDialog("settings")) { | ||
235 | return; | 251 | return; | ||
236 | } | 252 | } | ||
237 | 253 | | |||
238 | KConfigDialog *dialog = new KConfigDialog(this, "settings", KrfbConfig::self()); | 254 | KConfigDialog *dialog = new KConfigDialog(this, "settings", KrfbConfig::self()); | ||
239 | dialog->addPage(new TCP, i18n("Network"), "network-wired"); | 255 | dialog->addPage(new TCP, i18n("Network"), "network-wired"); | ||
240 | dialog->addPage(new Security, i18n("Security"), "security-high"); | 256 | dialog->addPage(new Security, i18n("Security"), "security-high"); | ||
241 | dialog->addPage(new ConfigFramebuffer, i18n("Screen capture"), "video-display"); | 257 | dialog->addPage(new ConfigFramebuffer, i18n("Screen capture"), "video-display"); | ||
242 | dialog->show(); | 258 | dialog->show(); | ||
243 | connect(dialog, &KConfigDialog::settingsChanged, [this] () { | 259 | connect(dialog, &KConfigDialog::settingsChanged, [this] () { | ||
244 | // check if framebuffer plugin config has changed | 260 | // check if framebuffer plugin config has changed | ||
245 | if (s_prevFramebufferPlugin != KrfbConfig::preferredFrameBufferPlugin()) { | 261 | if (s_prevFramebufferPlugin != KrfbConfig::preferredFrameBufferPlugin()) { | ||
246 | KMessageBox::information(this, i18n("To apply framebuffer plugin setting, " | 262 | KMessageBox::information(this, i18n("To apply framebuffer plugin setting, " | ||
247 | "you need to restart the program.")); | 263 | "you need to restart the program.")); | ||
248 | } | 264 | } | ||
265 | // check if kwallet config has changed | ||||
266 | if (s_prevNoWallet != KrfbConfig::noWallet()) { | ||||
267 | // try to apply settings immediately | ||||
268 | if (KrfbConfig::noWallet()) { | ||||
269 | InvitationsRfbServer::instance->closeKWallet(); | ||||
270 | } else { | ||||
271 | InvitationsRfbServer::instance->openKWallet(); | ||||
272 | // erase stored passwords from krfbconfig file | ||||
273 | KConfigGroup securityConfigGroup(KSharedConfig::openConfig(), "Security"); | ||||
274 | securityConfigGroup.deleteEntry("desktopPassword"); | ||||
275 | securityConfigGroup.deleteEntry("unattendedPassword"); | ||||
276 | } | ||||
277 | } | ||||
249 | }); | 278 | }); | ||
250 | } | 279 | } | ||
251 | 280 | | |||
252 | void MainWindow::readProperties(const KConfigGroup& group) | 281 | void MainWindow::readProperties(const KConfigGroup& group) | ||
253 | { | 282 | { | ||
254 | if (group.readEntry("Visible", true)) { | 283 | if (group.readEntry("Visible", true)) { | ||
255 | show(); | 284 | show(); | ||
256 | } | 285 | } | ||
257 | KMainWindow::readProperties(group); | 286 | KMainWindow::readProperties(group); | ||
258 | } | 287 | } | ||
259 | 288 | | |||
260 | void MainWindow::saveProperties(KConfigGroup& group) | 289 | void MainWindow::saveProperties(KConfigGroup& group) | ||
261 | { | 290 | { | ||
262 | group.writeEntry("Visible", isVisible()); | 291 | group.writeEntry("Visible", isVisible()); | ||
263 | KMainWindow::saveProperties(group); | 292 | KMainWindow::saveProperties(group); | ||
264 | } | 293 | } |