2014-11-19 17:18:01 +00:00
|
|
|
/* This file is part of the KDE project
|
|
|
|
|
|
|
|
Copyright (C) 2008 Urs Wolfer <uwolfer @ kde.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "dlgwebinterface.h"
|
|
|
|
|
2023-06-21 03:19:30 +03:00
|
|
|
#include "core/kget.h"
|
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "extensions/webinterface/httpserver.h"
|
2014-11-19 17:18:01 +00:00
|
|
|
#include "settings.h"
|
|
|
|
|
|
|
|
#include <KMessageBox>
|
2015-09-02 08:54:43 +03:00
|
|
|
#include <KLocale>
|
2014-11-19 17:18:01 +00:00
|
|
|
|
|
|
|
DlgWebinterface::DlgWebinterface(KDialog *parent)
|
|
|
|
: QWidget(parent),
|
2022-04-05 01:40:28 +03:00
|
|
|
m_passwdstore(nullptr)
|
2014-11-19 17:18:01 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
|
|
|
|
readConfig();
|
|
|
|
|
|
|
|
connect(parent, SIGNAL(accepted()), SLOT(saveSettings()));
|
|
|
|
connect(webinterfacePwd, SIGNAL(textChanged(QString)), SIGNAL(changed()));
|
|
|
|
}
|
|
|
|
|
|
|
|
DlgWebinterface::~DlgWebinterface()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void DlgWebinterface::readConfig()
|
|
|
|
{
|
|
|
|
if (Settings::webinterfaceEnabled()) {
|
2022-04-05 01:40:28 +03:00
|
|
|
if (!m_passwdstore) {
|
|
|
|
m_passwdstore = new KPasswdStore(this);
|
|
|
|
m_passwdstore->setStoreID("KGet");
|
2014-11-19 17:18:01 +00:00
|
|
|
}
|
|
|
|
|
2022-04-05 01:40:28 +03:00
|
|
|
if (m_passwdstore->openStore(winId())) {
|
|
|
|
webinterfacePwd->setText(m_passwdstore->getPasswd("Webinterface", winId()));
|
|
|
|
} else {
|
|
|
|
KMessageBox::error(nullptr, i18n("Could not open KPasswdStore"));
|
|
|
|
}
|
2014-11-19 17:18:01 +00:00
|
|
|
}
|
2023-06-21 03:19:30 +03:00
|
|
|
|
|
|
|
QString webaddress;
|
|
|
|
if (KGet::m_mainWindow && KGet::m_mainWindow->m_webinterface) {
|
|
|
|
webaddress = KGet::m_mainWindow->m_webinterface->address();
|
|
|
|
}
|
|
|
|
if (!webaddress.isEmpty()) {
|
|
|
|
serverLabel->setText(i18n("<html>The server can be accessed at <a href=\"%1\">%1</a>.</html>", webaddress));
|
|
|
|
} else {
|
|
|
|
serverLabel->setText(QString());
|
|
|
|
}
|
2014-11-19 17:18:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DlgWebinterface::saveSettings()
|
|
|
|
{
|
2022-09-20 11:05:29 +03:00
|
|
|
if (kcfg_WebinterfaceEnabled->isChecked()) {
|
|
|
|
if (!m_passwdstore) {
|
|
|
|
m_passwdstore = new KPasswdStore(this);
|
|
|
|
m_passwdstore->setStoreID("KGet");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_passwdstore->openStore(winId())) {
|
|
|
|
m_passwdstore->storePasswd("Webinterface", webinterfacePwd->text(), winId());
|
|
|
|
}
|
2014-11-19 17:18:01 +00:00
|
|
|
}
|
|
|
|
emit saved();
|
|
|
|
}
|
|
|
|
|
2015-02-27 11:02:43 +00:00
|
|
|
#include "moc_dlgwebinterface.cpp"
|