diff --git a/src/kcms/kio/cache.cpp b/src/kcms/kio/cache.cpp index 00ece582..a5dc3bd8 100644 --- a/src/kcms/kio/cache.cpp +++ b/src/kcms/kio/cache.cpp @@ -1,130 +1,130 @@ /* cache.cpp - Proxy configuration dialog Copyright (C) 2001,02,03 Dawit Alemayehu This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License (GPL) version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // Own #include "cache.h" // Qt #include #include #include // KDE #include #include #include #include #include // Local #include "ksaveioconfig.h" K_PLUGIN_FACTORY_DECLARATION(KioConfigFactory) CacheConfigModule::CacheConfigModule(QWidget *parent, const QVariantList &) - :KCModule(/*KioConfigFactory::componentData(),*/ parent) + :KCModule(parent) { ui.setupUi(this); } CacheConfigModule::~CacheConfigModule() { } void CacheConfigModule::load() { ui.cbUseCache->setChecked(KProtocolManager::useCache()); ui.sbMaxCacheSize->setValue( KProtocolManager::maxCacheSize() ); KIO::CacheControl cc = KProtocolManager::cacheControl(); if (cc==KIO::CC_Verify) ui.rbVerifyCache->setChecked( true ); else if (cc==KIO::CC_Refresh) ui.rbVerifyCache->setChecked( true ); else if (cc==KIO::CC_CacheOnly) ui.rbOfflineMode->setChecked( true ); else if (cc==KIO::CC_Cache) ui.rbCacheIfPossible->setChecked( true ); // Config changed notifications... connect ( ui.cbUseCache, SIGNAL(toggled(bool)), SLOT(configChanged()) ); connect ( ui.rbVerifyCache, SIGNAL(toggled(bool)), SLOT(configChanged()) ); connect ( ui.rbOfflineMode, SIGNAL(toggled(bool)), SLOT(configChanged()) ); connect ( ui.rbCacheIfPossible, SIGNAL(toggled(bool)), SLOT(configChanged()) ); connect ( ui.sbMaxCacheSize, SIGNAL(valueChanged(int)), SLOT(configChanged()) ); emit changed( false ); } void CacheConfigModule::save() { KSaveIOConfig::setUseCache( ui.cbUseCache->isChecked() ); KSaveIOConfig::setMaxCacheSize( ui.sbMaxCacheSize->value() ); if ( !ui.cbUseCache->isChecked() ) KSaveIOConfig::setCacheControl(KIO::CC_Refresh); else if ( ui.rbVerifyCache->isChecked() ) KSaveIOConfig::setCacheControl(KIO::CC_Refresh); else if ( ui.rbOfflineMode->isChecked() ) KSaveIOConfig::setCacheControl(KIO::CC_CacheOnly); else if ( ui.rbCacheIfPossible->isChecked() ) KSaveIOConfig::setCacheControl(KIO::CC_Cache); KProtocolManager::reparseConfiguration(); // Update running io-slaves... KSaveIOConfig::updateRunningIOSlaves (this); emit changed( false ); } void CacheConfigModule::defaults() { ui.cbUseCache->setChecked( true ); ui.rbVerifyCache->setChecked( true ); ui.sbMaxCacheSize->setValue( DEFAULT_MAX_CACHE_SIZE ); } QString CacheConfigModule::quickHelp() const { return i18n( "

Cache

This module lets you configure your cache settings.

" "

This specific cache is an area on the disk where recently " "read web pages are stored. If you want to retrieve a web " "page again that you have recently read, it will not be " "downloaded from the Internet, but rather retrieved from the " "cache, which is a lot faster.

" ); } void CacheConfigModule::configChanged() { emit changed( true ); } void CacheConfigModule::on_clearCacheButton_clicked() { - QString exe = QFile::decodeName(CMAKE_INSTALL_FULL_LIBEXECDIR_KF5 "/kio_http_cache_cleaner"); + const QString exe = QFile::decodeName(CMAKE_INSTALL_FULL_LIBEXECDIR_KF5 "/kio_http_cache_cleaner"); if (QFile::exists(exe)) { QProcess::startDetached(exe, QStringList(QStringLiteral("--clear-all"))); } } diff --git a/src/kcms/kio/kcookiesmain.cpp b/src/kcms/kio/kcookiesmain.cpp index 2ace6cb4..1ba1975f 100644 --- a/src/kcms/kio/kcookiesmain.cpp +++ b/src/kcms/kio/kcookiesmain.cpp @@ -1,97 +1,97 @@ /* kcookiesmain.cpp - Cookies configuration * * First version of cookies configuration: * Copyright (C) Waldo Bastian * This dialog box: * Copyright (C) David Faure * */ // Own #include "kcookiesmain.h" // Local #include "kcookiespolicies.h" #include "kcookiesmanagement.h" // Qt #include #include // KDE #include #include #include K_PLUGIN_FACTORY_DECLARATION (KioConfigFactory) KCookiesMain::KCookiesMain (QWidget* parent, const QVariantList&) - : KCModule (/*KioConfigFactory::componentData(),*/ parent) + : KCModule (parent) { management = nullptr; bool managerOK = true; QVBoxLayout* layout = new QVBoxLayout (this); tab = new QTabWidget (this); layout->addWidget (tab); - policies = new KCookiesPolicies (/*componentData(),*/ this); + policies = new KCookiesPolicies (this); tab->addTab (policies, i18n ("&Policy")); connect (policies, SIGNAL (changed (bool)), SIGNAL (changed (bool))); if (managerOK) { - management = new KCookiesManagement (/*componentData(),*/ this); + management = new KCookiesManagement (this); tab->addTab (management, i18n ("&Management")); connect (management, SIGNAL (changed (bool)), SIGNAL (changed (bool))); } } KCookiesMain::~KCookiesMain() { } void KCookiesMain::save() { policies->save(); if (management) management->save(); } void KCookiesMain::load() { policies->load(); if (management) management->load(); } void KCookiesMain::defaults() { KCModule* module = static_cast (tab->currentWidget()); if (module == policies) policies->defaults(); else if (management) management->defaults(); } QString KCookiesMain::quickHelp() const { return i18n ("

Cookies

Cookies contain information that KDE applications" " using the HTTP protocol (like Konqueror) store on your" " computer, initiated by a remote Internet server. This means that" " a web server can store information about you and your browsing activities" " on your machine for later use. You might consider this an invasion of" " privacy.

However, cookies are useful in certain situations. For example, they" " are often used by Internet shops, so you can 'put things into a shopping basket'." " Some sites require you have a browser that supports cookies.

" " Because most people want a compromise between privacy and the benefits cookies offer," " the HTTP kioslave offers you the ability to customize the way it handles cookies. So you might want" " to set the default policy to ask you whenever a server wants to set a cookie," " allowing you to decide. For your favorite shopping web sites that you trust, you might" " want to set the policy to accept, then you can access the web sites without being prompted" " every time a cookie is received.

"); } diff --git a/src/kcms/kio/kcookiesmanagement.cpp b/src/kcms/kio/kcookiesmanagement.cpp index 2e97f11f..1ba5d192 100644 --- a/src/kcms/kio/kcookiesmanagement.cpp +++ b/src/kcms/kio/kcookiesmanagement.cpp @@ -1,428 +1,428 @@ /** * kcookiesmanagement.cpp - Cookies manager * * Copyright 2000-2001 Marco Pinelli * Copyright 2000-2001 Dawit Alemayehu * * 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. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // Own #include "kcookiesmanagement.h" // Qt #include #include #include #include // KDE #include #include #include #include #include #include #include #include #include // Local #include "kcookiesmain.h" #include "kcookiespolicies.h" QString tolerantFromAce(const QByteArray& _domain); struct CookieProp { QString host; QString name; QString value; QString domain; QString path; QString expireDate; QString secure; bool allLoaded; }; CookieListViewItem::CookieListViewItem(QTreeWidget *parent, const QString &dom) :QTreeWidgetItem(parent) { init( nullptr, dom ); } CookieListViewItem::CookieListViewItem(QTreeWidgetItem *parent, CookieProp *cookie) :QTreeWidgetItem(parent) { init( cookie ); } CookieListViewItem::~CookieListViewItem() { delete mCookie; } void CookieListViewItem::init( CookieProp* cookie, const QString &domain, bool cookieLoaded ) { mCookie = cookie; mDomain = domain; mCookiesLoaded = cookieLoaded; if (mCookie) { if (mDomain.isEmpty()) setText(0, tolerantFromAce(mCookie->host.toLatin1())); else setText(0, tolerantFromAce(mDomain.toLatin1())); setText(1, mCookie->name); } else { QString siteName; if (mDomain.startsWith(QLatin1Char('.'))) siteName = mDomain.mid(1); else siteName = mDomain; setText(0, tolerantFromAce(siteName.toLatin1())); } } CookieProp* CookieListViewItem::leaveCookie() { CookieProp *ret = mCookie; mCookie = nullptr; return ret; } -KCookiesManagement::KCookiesManagement(/*const KComponentData &componentData,*/ QWidget *parent) - : KCModule(/*componentData,*/ parent), +KCookiesManagement::KCookiesManagement(QWidget *parent) + : KCModule(parent), mDeleteAllFlag(false), mMainWidget(parent) { mUi.setupUi(this); mUi.searchLineEdit->setTreeWidget(mUi.cookiesTreeWidget); mUi.cookiesTreeWidget->setColumnWidth(0, 150); connect(mUi.cookiesTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), SLOT(on_configPolicyButton_clicked())); } KCookiesManagement::~KCookiesManagement() { } void KCookiesManagement::load() { defaults(); } void KCookiesManagement::save() { // If delete all cookies was requested! if(mDeleteAllFlag) { QDBusInterface kded(QStringLiteral("org.kde.kcookiejar5"), QStringLiteral("/modules/kcookiejar"), QStringLiteral("org.kde.KCookieServer"), QDBusConnection::sessionBus()); QDBusReply reply = kded.call( QStringLiteral("deleteAllCookies") ); if (!reply.isValid()) { - QString caption = i18n ("D-Bus Communication Error"); - QString message = i18n ("Unable to delete all the cookies as requested."); + const QString caption = i18n ("D-Bus Communication Error"); + const QString message = i18n ("Unable to delete all the cookies as requested."); KMessageBox::sorry (this, message, caption); return; } mDeleteAllFlag = false; // deleted[Cookies|Domains] have been cleared yet } // Certain groups of cookies were deleted... QMutableStringListIterator it (mDeletedDomains); while (it.hasNext()) { QDBusInterface kded(QStringLiteral("org.kde.kcookiejar5"), QStringLiteral("/modules/kcookiejar"), QStringLiteral("org.kde.KCookieServer"), QDBusConnection::sessionBus()); QDBusReply reply = kded.call( QStringLiteral("deleteCookiesFromDomain"),( it.next() ) ); if (!reply.isValid()) { - QString caption = i18n ("D-Bus Communication Error"); - QString message = i18n ("Unable to delete cookies as requested."); + const QString caption = i18n ("D-Bus Communication Error"); + const QString message = i18n ("Unable to delete cookies as requested."); KMessageBox::sorry (this, message, caption); return; } it.remove(); } // Individual cookies were deleted... bool success = true; // Maybe we can go on... QMutableHashIterator cookiesDom(mDeletedCookies); while(cookiesDom.hasNext()) { cookiesDom.next(); CookiePropList list = cookiesDom.value(); foreach(CookieProp *cookie, list) { QDBusInterface kded(QStringLiteral("org.kde.kcookiejar5"), QStringLiteral("/modules/kcookiejar"), QStringLiteral("org.kde.KCookieServer"), QDBusConnection::sessionBus()); QDBusReply reply = kded.call( QStringLiteral("deleteCookie"), cookie->domain, cookie->host, cookie->path, cookie->name ); if (!reply.isValid()) { success = false; break; } list.removeOne(cookie); } if (!success) break; mDeletedCookies.remove(cookiesDom.key()); } emit changed( false ); } void KCookiesManagement::defaults() { reset(); on_reloadButton_clicked(); } void KCookiesManagement::reset(bool deleteAll) { if (!deleteAll) mDeleteAllFlag = false; clearCookieDetails(); mDeletedDomains.clear(); mDeletedCookies.clear(); mUi.cookiesTreeWidget->clear(); mUi.deleteButton->setEnabled(false); mUi.deleteAllButton->setEnabled(false); mUi.configPolicyButton->setEnabled(false); } void KCookiesManagement::clearCookieDetails() { mUi.nameLineEdit->clear(); mUi.valueLineEdit->clear(); mUi.domainLineEdit->clear(); mUi.pathLineEdit->clear(); mUi.expiresLineEdit->clear(); mUi.secureLineEdit->clear(); } QString KCookiesManagement::quickHelp() const { return i18n("

Cookie Management Quick Help

" ); } void KCookiesManagement::on_reloadButton_clicked() { QDBusInterface kded(QStringLiteral("org.kde.kcookiejar5"), QStringLiteral("/modules/kcookiejar"), QStringLiteral("org.kde.KCookieServer"), QDBusConnection::sessionBus()); QDBusReply reply = kded.call( QStringLiteral("findDomains") ); if (!reply.isValid()) { - QString caption = i18n ("Information Lookup Failure"); - QString message = i18n ("Unable to retrieve information about the " + const QString caption = i18n ("Information Lookup Failure"); + const QString message = i18n ("Unable to retrieve information about the " "cookies stored on your computer."); KMessageBox::sorry (this, message, caption); return; } if (mUi.cookiesTreeWidget->topLevelItemCount() > 0) reset(); CookieListViewItem *dom; const QStringList domains (reply.value()); Q_FOREACH(const QString& domain, domains) { const QString siteName = (domain.startsWith(QLatin1Char('.')) ? domain.mid(1) : domain); if (mUi.cookiesTreeWidget->findItems(siteName, Qt::MatchFixedString).isEmpty()) { dom = new CookieListViewItem(mUi.cookiesTreeWidget, domain); dom->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator); } } // are there any cookies? mUi.deleteAllButton->setEnabled(mUi.cookiesTreeWidget->topLevelItemCount() > 0); mUi.cookiesTreeWidget->sortItems(0, Qt::AscendingOrder); emit changed(false); } Q_DECLARE_METATYPE( QList ) void KCookiesManagement::on_cookiesTreeWidget_itemExpanded(QTreeWidgetItem *item) { CookieListViewItem* cookieDom = static_cast(item); if (!cookieDom || cookieDom->cookiesLoaded()) return; QStringList cookies; QList fields; fields << 0 << 1 << 2 << 3; // Always check for cookies in both "foo.bar" and ".foo.bar" domains... const QString domain = cookieDom->domain() + QLatin1String(" .") + cookieDom->domain(); QDBusInterface kded(QStringLiteral("org.kde.kcookiejar5"), QStringLiteral("/modules/kcookiejar"), QStringLiteral("org.kde.KCookieServer"), QDBusConnection::sessionBus()); QDBusReply reply = kded.call(QStringLiteral("findCookies"), QVariant::fromValue(fields), domain, QString(), QString(), QString()); if (reply.isValid()) cookies.append(reply.value()); QStringListIterator it(cookies); while (it.hasNext()) { CookieProp *details = new CookieProp; details->domain = it.next(); details->path = it.next(); details->name = it.next(); details->host = it.next(); details->allLoaded = false; new CookieListViewItem(item, details); } if (!cookies.isEmpty()) { static_cast(item)->setCookiesLoaded(); mUi.searchLineEdit->updateSearch(); } } bool KCookiesManagement::cookieDetails(CookieProp *cookie) { QList fields; fields << 4 << 5 << 7; QDBusInterface kded(QStringLiteral("org.kde.kcookiejar5"), QStringLiteral("/modules/kcookiejar"), QStringLiteral("org.kde.KCookieServer"), QDBusConnection::sessionBus()); QDBusReply reply = kded.call( QStringLiteral("findCookies"), QVariant::fromValue( fields ), cookie->domain, cookie->host, cookie->path, cookie->name); if (!reply.isValid()) return false; const QStringList fieldVal = reply.value(); QStringList::const_iterator c = fieldVal.begin(); if (c == fieldVal.end()) // empty list, do not crash return false; bool ok; cookie->value = *c++; qint64 tmp = (*c++).toLongLong(&ok); if (!ok || tmp == 0) cookie->expireDate = i18n("End of session"); else { QDateTime expDate; expDate.setTime_t(tmp); cookie->expireDate = QLocale().toString((expDate), QLocale::ShortFormat); } tmp = (*c).toUInt(&ok); cookie->secure = i18n((ok && tmp) ? "Yes" : "No"); cookie->allLoaded = true; return true; } void KCookiesManagement::on_cookiesTreeWidget_currentItemChanged(QTreeWidgetItem* item) { if (item) { CookieListViewItem* cookieItem = static_cast(item); CookieProp *cookie = cookieItem->cookie(); if (cookie) { if (cookie->allLoaded || cookieDetails(cookie)) { mUi.nameLineEdit->setText(cookie->name); mUi.valueLineEdit->setText(cookie->value); mUi.domainLineEdit->setText(cookie->domain); mUi.pathLineEdit->setText(cookie->path); mUi.expiresLineEdit->setText(cookie->expireDate); mUi.secureLineEdit->setText(cookie->secure); } mUi.configPolicyButton->setEnabled(false); } else { clearCookieDetails(); mUi.configPolicyButton->setEnabled(true); } } else { mUi.configPolicyButton->setEnabled(false); } mUi.deleteButton->setEnabled(item != nullptr); } void KCookiesManagement::on_configPolicyButton_clicked() { // Get current item CookieListViewItem *item = static_cast(mUi.cookiesTreeWidget->currentItem()); Q_ASSERT(item); // the button is disabled otherwise if (item) { KCookiesMain* mainDlg = qobject_cast(mMainWidget); // must be present or something is really wrong. Q_ASSERT(mainDlg); KCookiesPolicies* policyDlg = mainDlg->policyDlg(); // must be present unless someone rewrote the widget in which case // this needs to be re-written as well. Q_ASSERT(policyDlg); policyDlg->setPolicy(item->domain()); } } void KCookiesManagement::on_deleteButton_clicked() { QTreeWidgetItem* currentItem = mUi.cookiesTreeWidget->currentItem(); Q_ASSERT(currentItem); // the button is disabled otherwise CookieListViewItem *item = static_cast( currentItem ); if (item->cookie()) { CookieListViewItem *parent = static_cast(item->parent()); CookiePropList list = mDeletedCookies.value(parent->domain()); list.append(item->leaveCookie()); mDeletedCookies.insert(parent->domain(), list); delete item; if (parent->childCount() == 0) delete parent; } else { mDeletedDomains.append(item->domain()); delete item; } currentItem = mUi.cookiesTreeWidget->currentItem(); if (currentItem) { mUi.cookiesTreeWidget->setCurrentItem( currentItem ); } else clearCookieDetails(); mUi.deleteAllButton->setEnabled(mUi.cookiesTreeWidget->topLevelItemCount() > 0); emit changed( true ); } void KCookiesManagement::on_deleteAllButton_clicked() { mDeleteAllFlag = true; reset(true); emit changed(true); } diff --git a/src/kcms/kio/kcookiespolicies.cpp b/src/kcms/kio/kcookiespolicies.cpp index b6dbf327..dafeba36 100644 --- a/src/kcms/kio/kcookiespolicies.cpp +++ b/src/kcms/kio/kcookiespolicies.cpp @@ -1,457 +1,457 @@ /** * kcookiespolicies.cpp - Cookies configuration * * Original Authors * Copyright (c) Waldo Bastian * Copyright (c) 1999 David Faure * Copyright (c) 2008 Urs Wolfer * * Re-written by: * Copyright (c) 2000- Dawit Alemayehu * * 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. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // Own #include "kcookiespolicies.h" // Local #include "ksaveioconfig.h" // Qt #include #include #include // KDE #include #include #include #include #include #include // QUrl::fromAce/toAce don't accept a domain that starts with a '.', like we do here. // So we use these wrappers. QString tolerantFromAce (const QByteArray& _domain) { QByteArray domain (_domain); const bool hasDot = domain.startsWith ('.'); if (hasDot) domain.remove (0, 1); QString ret = QUrl::fromAce(domain); if (hasDot) { ret.prepend ('.'); } return ret; } static QByteArray tolerantToAce (const QString& _domain) { QString domain (_domain); const bool hasDot = domain.startsWith ('.'); if (hasDot) domain.remove (0, 1); QByteArray ret = QUrl::toAce (domain); if (hasDot) { ret.prepend ('.'); } return ret; } -KCookiesPolicies::KCookiesPolicies (/*const KComponentData& componentData,*/ QWidget* parent) - : KCModule (/*componentData,*/ parent), mSelectedItemsCount(0) +KCookiesPolicies::KCookiesPolicies (QWidget* parent) + : KCModule (parent), mSelectedItemsCount(0) { mUi.setupUi (this); mUi.kListViewSearchLine->setTreeWidget (mUi.policyTreeWidget); QList columns; columns.append (0); mUi.kListViewSearchLine->setSearchColumns (columns); mUi.pbNew->setIcon (QIcon::fromTheme(QStringLiteral("list-add"))); mUi.pbChange->setIcon (QIcon::fromTheme(QStringLiteral("edit-rename"))); mUi.pbDelete->setIcon (QIcon::fromTheme(QStringLiteral("list-remove"))); mUi.pbDeleteAll->setIcon (QIcon::fromTheme(QStringLiteral("edit-delete"))); // Connect the main swicth :) Enable/disable cookie support connect (mUi.cbEnableCookies, SIGNAL (toggled (bool)), SLOT (cookiesEnabled (bool))); connect (mUi.cbEnableCookies, SIGNAL (toggled (bool)), SLOT (configChanged())); // Connect the preference check boxes... connect (mUi.cbRejectCrossDomainCookies, SIGNAL (toggled (bool)), SLOT (configChanged())); connect (mUi.cbAutoAcceptSessionCookies, SIGNAL (toggled (bool)), SLOT (configChanged())); connect (mUi.rbPolicyAsk, SIGNAL (toggled (bool)), SLOT (configChanged())); connect (mUi.rbPolicyAccept, SIGNAL (toggled (bool)), SLOT (configChanged())); connect (mUi.rbPolicyAcceptForSession, SIGNAL(toggled(bool)), SLOT(configChanged())); connect (mUi.rbPolicyReject, SIGNAL (toggled (bool)), SLOT (configChanged())); // Connect signals from the domain specific policy listview. connect (mUi.policyTreeWidget, SIGNAL (itemSelectionChanged()), SLOT (selectionChanged())); connect (mUi.policyTreeWidget, SIGNAL (itemDoubleClicked (QTreeWidgetItem*, int)), SLOT (changePressed())); // Connect the buttons... connect (mUi.pbNew, SIGNAL (clicked()), SLOT (addPressed())); connect (mUi.pbChange, SIGNAL (clicked()), SLOT (changePressed())); connect (mUi.pbDelete, SIGNAL (clicked()), SLOT (deletePressed())); connect (mUi.pbDeleteAll, SIGNAL (clicked()), SLOT (deleteAllPressed())); } KCookiesPolicies::~KCookiesPolicies() { } void KCookiesPolicies::configChanged () { //kDebug() << "KCookiesPolicies::configChanged..."; emit changed (true); } void KCookiesPolicies::cookiesEnabled (bool enable) { mUi.bgDefault->setEnabled (enable); mUi.bgPreferences->setEnabled (enable); mUi.gbDomainSpecific->setEnabled (enable); } void KCookiesPolicies::setPolicy (const QString& domain) { QTreeWidgetItemIterator it (mUi.policyTreeWidget); bool hasExistingPolicy = false; while (*it) { if ((*it)->text(0) == domain) { hasExistingPolicy = true; break; } ++it; } if (hasExistingPolicy) { changePressed((*it), false); } else { addPressed(domain); } } void KCookiesPolicies::changePressed() { changePressed(mUi.policyTreeWidget->currentItem()); } void KCookiesPolicies::addPressed() { addPressed(QString()); } void KCookiesPolicies::changePressed(QTreeWidgetItem* item, bool state) { Q_ASSERT(item); const QString oldDomain(item->text (0)); KCookiesPolicySelectionDlg pdlg (this); pdlg.setWindowTitle (i18nc ("@title:window", "Change Cookie Policy")); pdlg.setPolicy (KCookieAdvice::strToAdvice (mDomainPolicyMap.value(oldDomain))); pdlg.setEnableHostEdit (state, oldDomain); if (pdlg.exec() && !pdlg.domain().isEmpty()) { const QString newDomain = tolerantFromAce (pdlg.domain().toLatin1()); int advice = pdlg.advice(); if (newDomain == oldDomain || !handleDuplicate (newDomain, advice)) { mDomainPolicyMap[newDomain] = KCookieAdvice::adviceToStr(advice); item->setText(0, newDomain); item->setText(1, i18n (mDomainPolicyMap.value(newDomain))); configChanged(); } } } void KCookiesPolicies::addPressed(const QString& domain, bool state) { KCookiesPolicySelectionDlg pdlg (this); pdlg.setWindowTitle (i18nc ("@title:window", "New Cookie Policy")); pdlg.setEnableHostEdit(state, domain); if (mUi.rbPolicyAccept->isChecked()) pdlg.setPolicy (KCookieAdvice::Reject); else pdlg.setPolicy (KCookieAdvice::Accept); if (pdlg.exec() && !pdlg.domain().isEmpty()) { const QString domain = tolerantFromAce (pdlg.domain().toLatin1()); int advice = pdlg.advice(); if (!handleDuplicate (domain, advice)) { const char* strAdvice = KCookieAdvice::adviceToStr (advice); QTreeWidgetItem* item = new QTreeWidgetItem (mUi.policyTreeWidget, QStringList() << domain << i18n (strAdvice)); mDomainPolicyMap.insert (item->text(0), strAdvice); configChanged(); updateButtons(); } } } bool KCookiesPolicies::handleDuplicate (const QString& domain, int advice) { QTreeWidgetItem* item = mUi.policyTreeWidget->topLevelItem (0); while (item != nullptr) { if (item->text (0) == domain) { const int res = KMessageBox::warningContinueCancel (this, i18n ("A policy already exists for" "
%1
" "Do you want to replace it?
", domain), i18nc ("@title:window", "Duplicate Policy"), KGuiItem (i18n ("Replace"))); if (res == KMessageBox::Continue) { mDomainPolicyMap[domain] = KCookieAdvice::adviceToStr(advice); item->setText (0, domain); item->setText (1, i18n (mDomainPolicyMap.value(domain))); configChanged(); return true; } else return true; // User Cancelled!! } item = mUi.policyTreeWidget->itemBelow (item); } return false; } void KCookiesPolicies::deletePressed() { QTreeWidgetItem* nextItem = nullptr; Q_FOREACH (QTreeWidgetItem * item, mUi.policyTreeWidget->selectedItems()) { nextItem = mUi.policyTreeWidget->itemBelow (item); if (!nextItem) nextItem = mUi.policyTreeWidget->itemAbove (item); mDomainPolicyMap.remove (item->text(0)); delete item; } if (nextItem) nextItem->setSelected (true); updateButtons(); configChanged(); } void KCookiesPolicies::deleteAllPressed() { mDomainPolicyMap.clear(); mUi.policyTreeWidget->clear(); updateButtons(); configChanged(); } void KCookiesPolicies::updateButtons() { bool hasItems = mUi.policyTreeWidget->topLevelItemCount() > 0; mUi.pbChange->setEnabled((hasItems && mSelectedItemsCount == 1)); mUi.pbDelete->setEnabled((hasItems && mSelectedItemsCount > 0)); mUi.pbDeleteAll->setEnabled(hasItems); } void KCookiesPolicies::updateDomainList (const QStringList& domainConfig) { mUi.policyTreeWidget->clear(); QStringList::ConstIterator it = domainConfig.begin(); for (; it != domainConfig.end(); ++it) { QString domain; KCookieAdvice::Value advice = KCookieAdvice::Dunno; splitDomainAdvice (*it, domain, advice); if (!domain.isEmpty()) { QStringList items; items << tolerantFromAce(domain.toLatin1()) << i18n(KCookieAdvice::adviceToStr(advice)); QTreeWidgetItem* item = new QTreeWidgetItem (mUi.policyTreeWidget, items); mDomainPolicyMap[item->text(0)] = KCookieAdvice::adviceToStr(advice); } } mUi.policyTreeWidget->sortItems(0, Qt::AscendingOrder); } void KCookiesPolicies::selectionChanged () { mSelectedItemsCount = mUi.policyTreeWidget->selectedItems().count(); updateButtons (); } void KCookiesPolicies::load() { mSelectedItemsCount = 0; KConfig cfg (QStringLiteral("kcookiejarrc")); KConfigGroup group = cfg.group ("Cookie Policy"); bool enableCookies = group.readEntry ("Cookies", true); mUi.cbEnableCookies->setChecked (enableCookies); cookiesEnabled (enableCookies); // Warning: the default values are duplicated in kcookiejar.cpp KCookieAdvice::Value advice = KCookieAdvice::strToAdvice (group.readEntry ( "CookieGlobalAdvice", "Accept")); switch (advice) { case KCookieAdvice::Accept: mUi.rbPolicyAccept->setChecked (true); break; case KCookieAdvice::AcceptForSession: mUi.rbPolicyAcceptForSession->setChecked (true); break; case KCookieAdvice::Reject: mUi.rbPolicyReject->setChecked (true); break; case KCookieAdvice::Ask: case KCookieAdvice::Dunno: default: mUi.rbPolicyAsk->setChecked (true); } bool enable = group.readEntry ("RejectCrossDomainCookies", true); mUi.cbRejectCrossDomainCookies->setChecked (enable); bool sessionCookies = group.readEntry ("AcceptSessionCookies", true); mUi.cbAutoAcceptSessionCookies->setChecked (sessionCookies); updateDomainList (group.readEntry ("CookieDomainAdvice", QStringList())); if (enableCookies) { updateButtons(); } } void KCookiesPolicies::save() { KConfig cfg (QStringLiteral("kcookiejarrc")); KConfigGroup group = cfg.group ("Cookie Policy"); bool state = mUi.cbEnableCookies->isChecked(); group.writeEntry ("Cookies", state); state = mUi.cbRejectCrossDomainCookies->isChecked(); group.writeEntry ("RejectCrossDomainCookies", state); state = mUi.cbAutoAcceptSessionCookies->isChecked(); group.writeEntry ("AcceptSessionCookies", state); QString advice; if (mUi.rbPolicyAccept->isChecked()) advice = KCookieAdvice::adviceToStr (KCookieAdvice::Accept); else if (mUi.rbPolicyAcceptForSession->isChecked()) advice = KCookieAdvice::adviceToStr (KCookieAdvice::AcceptForSession); else if (mUi.rbPolicyReject->isChecked()) advice = KCookieAdvice::adviceToStr (KCookieAdvice::Reject); else advice = KCookieAdvice::adviceToStr (KCookieAdvice::Ask); group.writeEntry ("CookieGlobalAdvice", advice); QStringList domainConfig; QMapIterator it (mDomainPolicyMap); while (it.hasNext()) { it.next(); QString policy = tolerantToAce(it.key()); policy += QLatin1Char (':'); policy += QLatin1String (it.value()); domainConfig << policy; } group.writeEntry ("CookieDomainAdvice", domainConfig); group.sync(); // Update the cookiejar... if (!mUi.cbEnableCookies->isChecked()) { QDBusInterface kded (QStringLiteral("org.kde.kcookiejar5"), QStringLiteral("/modules/kcookiejar"), QStringLiteral("org.kde.KCookieServer"), QDBusConnection::sessionBus()); kded.call (QStringLiteral("shutdown")); } else { QDBusInterface kded (QStringLiteral("org.kde.kcookiejar5"), QStringLiteral("/modules/kcookiejar"), QStringLiteral("org.kde.KCookieServer"), QDBusConnection::sessionBus()); QDBusReply reply = kded.call (QStringLiteral("reloadPolicy")); if (!reply.isValid()) KMessageBox::sorry (nullptr, i18n ("Unable to communicate with the cookie handler service.\n" "Any changes you made will not take effect until the service " "is restarted.")); } // Force running io-slave to reload configurations... KSaveIOConfig::updateRunningIOSlaves (this); emit changed (false); } void KCookiesPolicies::defaults() { mUi.cbEnableCookies->setChecked (true); mUi.rbPolicyAsk->setChecked (true); mUi.rbPolicyAccept->setChecked (false); mUi.rbPolicyAcceptForSession->setChecked (false); mUi.rbPolicyReject->setChecked (false); mUi.cbRejectCrossDomainCookies->setChecked (true); mUi.cbAutoAcceptSessionCookies->setChecked (false); mUi.policyTreeWidget->clear(); mDomainPolicyMap.clear(); cookiesEnabled (mUi.cbEnableCookies->isChecked()); updateButtons(); } void KCookiesPolicies::splitDomainAdvice (const QString& cfg, QString& domain, KCookieAdvice::Value& advice) { int sepPos = cfg.lastIndexOf (':'); // Ignore any policy that does not contain a domain... if (sepPos <= 0) return; domain = cfg.left (sepPos); advice = KCookieAdvice::strToAdvice (cfg.mid (sepPos + 1)); } QString KCookiesPolicies::quickHelp() const { return i18n ("

Cookies

Cookies contain information that KDE" " application using the HTTP protocol (like Konqueror) stores" " on your computer from a remote Internet server. This means" " that a web server can store information about you and your" " browsing activities on your machine for later use. You might" " consider this an invasion of privacy.

However, cookies are" " useful in certain situations. For example, they are often used" " by Internet shops, so you can 'put things into a shopping" " basket'. Some sites require you have a browser that supports" " cookies.

Because most people want a compromise between privacy" " and the benefits cookies offer, KDE offers you the ability to" " customize the way it handles cookies. You might, for example" " want to set KDE's default policy to ask you whenever a server" " wants to set a cookie or simply reject or accept everything." " For example, you might choose to accept all cookies from your" " favorite shopping web site. For this all you have to do is" " either browse to that particular site and when you are presented" " with the cookie dialog box, click on This domain under" " the 'apply to' tab and choose accept or simply specify the name" " of the site in the Domain Specific Policy tab and set" " it to accept. This enables you to receive cookies from trusted" " web sites without being asked every time KDE receives a cookie.

" ); } diff --git a/src/kcms/kio/kcookiespolicyselectiondlg.cpp b/src/kcms/kio/kcookiespolicyselectiondlg.cpp index 7e12b744..2f3d215a 100644 --- a/src/kcms/kio/kcookiespolicyselectiondlg.cpp +++ b/src/kcms/kio/kcookiespolicyselectiondlg.cpp @@ -1,140 +1,139 @@ /** * Copyright (c) 2000- Dawit Alemayehu * * 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. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // Own #include "kcookiespolicyselectiondlg.h" // Qt #include #include #include #include // KDE #include #include #include #include class DomainNameValidator : public QValidator { Q_OBJECT public: DomainNameValidator (QObject* parent) :QValidator(parent) { setObjectName(QStringLiteral("domainValidator")); } State validate (QString& input, int&) const Q_DECL_OVERRIDE { if (input.isEmpty() || (input == QLatin1String("."))) { return Intermediate; } const int length = input.length(); for (int i = 0 ; i < length; i++) { if (!input[i].isLetterOrNumber() && input[i] != '.' && input[i] != '-') { return Invalid; } } return Acceptable; } }; KCookiesPolicySelectionDlg::KCookiesPolicySelectionDlg (QWidget* parent, Qt::WindowFlags flags) : QDialog (parent, flags) , mOldPolicy(-1) , mButtonBox(nullptr) { QWidget *mainWidget = new QWidget(this); - QVBoxLayout *mainLayout = new QVBoxLayout; - setLayout(mainLayout); + QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->addWidget(mainWidget); mUi.setupUi(mainWidget); mUi.leDomain->setValidator(new DomainNameValidator (mUi.leDomain)); mUi.cbPolicy->setMinimumWidth(mUi.cbPolicy->fontMetrics().maxWidth() * 15); mButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); mainLayout->addWidget(mButtonBox); - connect(mButtonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(mButtonBox, SIGNAL(rejected()), this, SLOT(reject())); + connect(mButtonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(mButtonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); mButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false); connect(mUi.leDomain, SIGNAL(textEdited(QString)), SLOT(slotTextChanged(QString))); connect(mUi.cbPolicy, SIGNAL(currentIndexChanged(QString)), SLOT(slotPolicyChanged(QString))); mUi.leDomain->setFocus(); } void KCookiesPolicySelectionDlg::setEnableHostEdit (bool state, const QString& host) { if (!host.isEmpty()) { mUi.leDomain->setText (host); mButtonBox->button(QDialogButtonBox::Ok)->setEnabled(state); } mUi.leDomain->setEnabled (state); } void KCookiesPolicySelectionDlg::setPolicy (int policy) { if (policy > -1 && policy <= static_cast (mUi.cbPolicy->count())) { const bool blocked = mUi.cbPolicy->blockSignals(true); mUi.cbPolicy->setCurrentIndex (policy - 1); mUi.cbPolicy->blockSignals(blocked); mOldPolicy = policy; } if (!mUi.leDomain->isEnabled()) mUi.cbPolicy->setFocus(); } int KCookiesPolicySelectionDlg::advice () const { return mUi.cbPolicy->currentIndex() + 1; } QString KCookiesPolicySelectionDlg::domain () const { return mUi.leDomain->text(); } void KCookiesPolicySelectionDlg::slotTextChanged (const QString& text) { mButtonBox->button(QDialogButtonBox::Ok)->setEnabled (text.length() > 1); } void KCookiesPolicySelectionDlg::slotPolicyChanged(const QString& policyText) { const int policy = KCookieAdvice::strToAdvice(policyText); if (!mUi.leDomain->isEnabled()) { mButtonBox->button(QDialogButtonBox::Ok)->setEnabled(policy != mOldPolicy); } else { slotTextChanged(policyText); } } #include "kcookiespolicyselectiondlg.moc" diff --git a/src/kcms/kio/ksaveioconfig.cpp b/src/kcms/kio/ksaveioconfig.cpp index 45cd0679..2b96e9cd 100644 --- a/src/kcms/kio/ksaveioconfig.cpp +++ b/src/kcms/kio/ksaveioconfig.cpp @@ -1,240 +1,239 @@ /* Copyright (C) 2001 Dawit Alemayehu This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // Own #include "ksaveioconfig.h" // Qt #include // KDE #include #include #include #include #include class KSaveIOConfigPrivate { public: KSaveIOConfigPrivate (); ~KSaveIOConfigPrivate (); - KConfig* config; - KConfig* http_config; + KConfig* config = nullptr; + KConfig* http_config = nullptr; }; Q_GLOBAL_STATIC(KSaveIOConfigPrivate, d) KSaveIOConfigPrivate::KSaveIOConfigPrivate () - : config(nullptr), http_config(nullptr) { } KSaveIOConfigPrivate::~KSaveIOConfigPrivate () { delete config; delete http_config; } static KConfig* config() { if (!d->config) d->config = new KConfig(QStringLiteral("kioslaverc"), KConfig::NoGlobals); return d->config; } static KConfig* http_config() { if (!d->http_config) d->http_config = new KConfig(QStringLiteral("kio_httprc"), KConfig::NoGlobals); return d->http_config; } int KSaveIOConfig::proxyDisplayUrlFlags() { KConfigGroup cfg (config(), QString()); return cfg.readEntry("ProxyUrlDisplayFlags", 0); } void KSaveIOConfig::setProxyDisplayUrlFlags (int flags) { KConfigGroup cfg (config(), QString()); cfg.writeEntry("ProxyUrlDisplayFlags", flags); cfg.sync(); } void KSaveIOConfig::reparseConfiguration () { delete d->config; d->config = nullptr; delete d->http_config; d->http_config = nullptr; } void KSaveIOConfig::setReadTimeout( int _timeout ) { KConfigGroup cfg (config(), QString()); cfg.writeEntry("ReadTimeout", qMax(MIN_TIMEOUT_VALUE,_timeout)); cfg.sync(); } void KSaveIOConfig::setConnectTimeout( int _timeout ) { KConfigGroup cfg (config(), QString()); cfg.writeEntry("ConnectTimeout", qMax(MIN_TIMEOUT_VALUE,_timeout)); cfg.sync(); } void KSaveIOConfig::setProxyConnectTimeout( int _timeout ) { KConfigGroup cfg (config(), QString()); cfg.writeEntry("ProxyConnectTimeout", qMax(MIN_TIMEOUT_VALUE,_timeout)); cfg.sync(); } void KSaveIOConfig::setResponseTimeout( int _timeout ) { KConfigGroup cfg (config(), QString()); cfg.writeEntry("ResponseTimeout", qMax(MIN_TIMEOUT_VALUE,_timeout)); cfg.sync(); } void KSaveIOConfig::setMarkPartial( bool _mode ) { KConfigGroup cfg (config(), QString()); cfg.writeEntry( "MarkPartial", _mode ); cfg.sync(); } void KSaveIOConfig::setMinimumKeepSize( int _size ) { KConfigGroup cfg (config(), QString()); cfg.writeEntry( "MinimumKeepSize", _size ); cfg.sync(); } void KSaveIOConfig::setAutoResume( bool _mode ) { KConfigGroup cfg (config(), QString()); cfg.writeEntry( "AutoResume", _mode ); cfg.sync(); } void KSaveIOConfig::setUseCache( bool _mode ) { KConfigGroup cfg (http_config(), QString()); cfg.writeEntry( "UseCache", _mode ); cfg.sync(); } void KSaveIOConfig::setMaxCacheSize( int cache_size ) { KConfigGroup cfg (http_config(), QString()); cfg.writeEntry( "MaxCacheSize", cache_size ); cfg.sync(); } void KSaveIOConfig::setCacheControl(KIO::CacheControl policy) { KConfigGroup cfg (http_config(), QString()); QString tmp = KIO::getCacheControlString(policy); cfg.writeEntry("cache", tmp); cfg.sync(); } void KSaveIOConfig::setMaxCacheAge( int cache_age ) { KConfigGroup cfg (http_config(), QString()); cfg.writeEntry( "MaxCacheAge", cache_age ); cfg.sync(); } void KSaveIOConfig::setUseReverseProxy( bool mode ) { KConfigGroup cfg (config(), "Proxy Settings"); cfg.writeEntry("ReversedException", mode); cfg.sync(); } void KSaveIOConfig::setProxyType(KProtocolManager::ProxyType type) { KConfigGroup cfg (config(), "Proxy Settings"); cfg.writeEntry("ProxyType", static_cast(type)); cfg.sync(); } QString KSaveIOConfig::noProxyFor() { KConfigGroup cfg(config(), "Proxy Settings"); return cfg.readEntry("NoProxyFor"); } void KSaveIOConfig::setNoProxyFor( const QString& _noproxy ) { KConfigGroup cfg (config(), "Proxy Settings"); cfg.writeEntry("NoProxyFor", _noproxy); cfg.sync(); } void KSaveIOConfig::setProxyFor( const QString& protocol, const QString& _proxy ) { KConfigGroup cfg (config(), "Proxy Settings"); cfg.writeEntry(protocol.toLower() + "Proxy", _proxy); cfg.sync(); } void KSaveIOConfig::setProxyConfigScript( const QString& _url ) { KConfigGroup cfg (config(), "Proxy Settings"); cfg.writeEntry("Proxy Config Script", _url); cfg.sync(); } void KSaveIOConfig::updateRunningIOSlaves (QWidget *parent) { // Inform all running io-slaves about the changes... // if we cannot update, ioslaves inform the end user... QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/KIO/Scheduler"), QStringLiteral("org.kde.KIO.Scheduler"), QStringLiteral("reparseSlaveConfiguration")); message << QString(); if (!QDBusConnection::sessionBus().send(message)) { KMessageBox::information (parent, i18n("You have to restart the running applications " "for these changes to take effect."), i18nc("@title:window", "Update Failed")); } } void KSaveIOConfig::updateProxyScout(QWidget * parent) { // Inform the proxyscout kded module about changes if we cannot update, // ioslaves inform the end user... QDBusInterface kded(QStringLiteral("org.kde.kcookiejar5"), QStringLiteral("/modules/proxyscout"), QStringLiteral("org.kde.KPAC.ProxyScout")); QDBusReply reply = kded.call(QStringLiteral("reset")); if (!reply.isValid()) { KMessageBox::information (parent, i18n("You have to restart KDE for these changes to take effect."), i18nc("@title:window", "Update Failed")); } } diff --git a/src/kcms/kio/netpref.cpp b/src/kcms/kio/netpref.cpp index 30952153..8f4b96cf 100644 --- a/src/kcms/kio/netpref.cpp +++ b/src/kcms/kio/netpref.cpp @@ -1,175 +1,175 @@ // Own #include "netpref.h" // Qt #include #include #include #include // KDE #include #include #include #include #include #include #include // Local #include "ksaveioconfig.h" #define MAX_TIMEOUT_VALUE 3600 K_PLUGIN_FACTORY_DECLARATION(KioConfigFactory) KIOPreferences::KIOPreferences(QWidget *parent, const QVariantList &) - :KCModule(/*KioConfigFactory::componentData(),*/ parent) + :KCModule(parent) { QVBoxLayout* mainLayout = new QVBoxLayout( this ); mainLayout->setMargin(0); gb_Timeout = new QGroupBox( i18n("Timeout Values"), this ); gb_Timeout->setWhatsThis( i18np("Here you can set timeout values. " "You might want to tweak them if your " "connection is very slow. The maximum " "allowed value is 1 second." , "Here you can set timeout values. " "You might want to tweak them if your " "connection is very slow. The maximum " "allowed value is %1 seconds.", MAX_TIMEOUT_VALUE)); mainLayout->addWidget( gb_Timeout ); QFormLayout* timeoutLayout = new QFormLayout(gb_Timeout); sb_socketRead = new KPluralHandlingSpinBox( this ); sb_socketRead->setSuffix( ki18np( " second", " seconds" ) ); connect(sb_socketRead, SIGNAL(valueChanged(int)), SLOT(configChanged())); timeoutLayout->addRow(i18n( "Soc&ket read:" ), sb_socketRead); sb_proxyConnect = new KPluralHandlingSpinBox( this ); sb_proxyConnect->setValue(0); sb_proxyConnect->setSuffix( ki18np( " second", " seconds" ) ); connect(sb_proxyConnect, SIGNAL(valueChanged(int)), SLOT(configChanged())); timeoutLayout->addRow(i18n( "Pro&xy connect:" ), sb_proxyConnect); sb_serverConnect = new KPluralHandlingSpinBox( this ); sb_serverConnect->setValue(0); sb_serverConnect->setSuffix( ki18np( " second", " seconds" ) ); connect(sb_serverConnect, SIGNAL(valueChanged(int)), SLOT(configChanged())); timeoutLayout->addRow(i18n("Server co&nnect:"), sb_serverConnect); sb_serverResponse = new KPluralHandlingSpinBox( this ); sb_serverResponse->setValue(0); sb_serverResponse->setSuffix( ki18np( " second", " seconds" ) ); connect(sb_serverResponse, SIGNAL(valueChanged(int)), SLOT(configChanged())); timeoutLayout->addRow(i18n("&Server response:"), sb_serverResponse); QGroupBox* gb_Global = new QGroupBox( i18n( "Global Options" ), this ); mainLayout->addWidget( gb_Global ); QVBoxLayout* globalLayout = new QVBoxLayout(gb_Global); cb_globalMarkPartial = new QCheckBox( i18n( "Mark &partially uploaded files" ), this ); cb_globalMarkPartial->setWhatsThis( i18n( "

Marks partially uploaded files " "through SMB, SFTP and other protocols." "

When this option is " "enabled, partially uploaded files " "will have a \".part\" extension. " "This extension will be removed " "once the transfer is complete.

") ); connect(cb_globalMarkPartial, SIGNAL(toggled(bool)), SLOT(configChanged())); globalLayout->addWidget(cb_globalMarkPartial); gb_Ftp = new QGroupBox( i18n( "FTP Options" ), this ); mainLayout->addWidget( gb_Ftp ); QVBoxLayout* ftpLayout = new QVBoxLayout(gb_Ftp); cb_ftpEnablePasv = new QCheckBox( i18n( "Enable passive &mode (PASV)" ), this ); cb_ftpEnablePasv->setWhatsThis( i18n("Enables FTP's \"passive\" mode. " "This is required to allow FTP to " "work from behind firewalls.") ); connect(cb_ftpEnablePasv, SIGNAL(toggled(bool)), SLOT(configChanged())); ftpLayout->addWidget(cb_ftpEnablePasv); cb_ftpMarkPartial = new QCheckBox( i18n( "Mark &partially uploaded files" ), this ); cb_ftpMarkPartial->setWhatsThis( i18n( "

Marks partially uploaded FTP " "files.

When this option is " "enabled, partially uploaded files " "will have a \".part\" extension. " "This extension will be removed " "once the transfer is complete.

") ); connect(cb_ftpMarkPartial, SIGNAL(toggled(bool)), SLOT(configChanged())); ftpLayout->addWidget(cb_ftpMarkPartial); mainLayout->addStretch( 1 ); } KIOPreferences::~KIOPreferences() { } void KIOPreferences::load() { KProtocolManager proto; sb_socketRead->setRange( MIN_TIMEOUT_VALUE, MAX_TIMEOUT_VALUE ); sb_serverResponse->setRange( MIN_TIMEOUT_VALUE, MAX_TIMEOUT_VALUE ); sb_serverConnect->setRange( MIN_TIMEOUT_VALUE, MAX_TIMEOUT_VALUE ); sb_proxyConnect->setRange( MIN_TIMEOUT_VALUE, MAX_TIMEOUT_VALUE ); sb_socketRead->setValue( proto.readTimeout() ); sb_serverResponse->setValue( proto.responseTimeout() ); sb_serverConnect->setValue( proto.connectTimeout() ); sb_proxyConnect->setValue( proto.proxyConnectTimeout() ); cb_globalMarkPartial->setChecked( proto.markPartial() ); KConfig config( QStringLiteral("kio_ftprc"), KConfig::NoGlobals ); cb_ftpEnablePasv->setChecked( !config.group("").readEntry( "DisablePassiveMode", false ) ); cb_ftpMarkPartial->setChecked( config.group("").readEntry( "MarkPartial", true ) ); emit changed( false ); } void KIOPreferences::save() { KSaveIOConfig::setReadTimeout( sb_socketRead->value() ); KSaveIOConfig::setResponseTimeout( sb_serverResponse->value() ); KSaveIOConfig::setConnectTimeout( sb_serverConnect->value() ); KSaveIOConfig::setProxyConnectTimeout( sb_proxyConnect->value() ); KSaveIOConfig::setMarkPartial( cb_globalMarkPartial->isChecked() ); KConfig config(QStringLiteral("kio_ftprc"), KConfig::NoGlobals); config.group("").writeEntry( "DisablePassiveMode", !cb_ftpEnablePasv->isChecked() ); config.group("").writeEntry( "MarkPartial", cb_ftpMarkPartial->isChecked() ); config.sync(); KSaveIOConfig::updateRunningIOSlaves(this); emit changed( false ); } void KIOPreferences::defaults() { sb_socketRead->setValue( DEFAULT_READ_TIMEOUT ); sb_serverResponse->setValue( DEFAULT_RESPONSE_TIMEOUT ); sb_serverConnect->setValue( DEFAULT_CONNECT_TIMEOUT ); sb_proxyConnect->setValue( DEFAULT_PROXY_CONNECT_TIMEOUT ); cb_globalMarkPartial->setChecked( true ); cb_ftpEnablePasv->setChecked( true ); cb_ftpMarkPartial->setChecked( true ); emit changed(true); } QString KIOPreferences::quickHelp() const { return i18n("

Network Preferences

Here you can define" " the behavior of KDE programs when using Internet" " and network connections. If you experience timeouts" " or use a modem to connect to the Internet, you might" " want to adjust these settings." ); } diff --git a/src/kcms/kio/smbrodlg.cpp b/src/kcms/kio/smbrodlg.cpp index 1b4538d0..5e145659 100644 --- a/src/kcms/kio/smbrodlg.cpp +++ b/src/kcms/kio/smbrodlg.cpp @@ -1,185 +1,185 @@ /* This file is part of the KDE project Copyright (C) 2000 Alexander Neundorf This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // Own #include "smbrodlg.h" // Qt #include #include #include // KDE #include #include #include #include #include #include //#include #include K_PLUGIN_FACTORY_DECLARATION(KioConfigFactory) -SMBRoOptions::SMBRoOptions(QWidget *parent, const QVariantList &/*, const KComponentData &componentData*/) - : KCModule(/*componentData.isValid() ? componentData : KioConfigFactory::componentData(),*/ parent) +SMBRoOptions::SMBRoOptions(QWidget *parent, const QVariantList &) + : KCModule(parent) { QGridLayout *layout = new QGridLayout(this ); QLabel *label=new QLabel(i18n("These settings apply to network browsing only."),this); layout->addWidget(label,0,0, 1, 2 ); m_userLe=new QLineEdit(this); label=new QLabel(i18n("Default user name:"),this); label->setAlignment(Qt::AlignRight | Qt::AlignVCenter); label->setBuddy( m_userLe ); layout->addWidget(label,1,0); layout->addWidget(m_userLe,1,1); m_passwordLe=new QLineEdit(this); m_passwordLe->setEchoMode(QLineEdit::Password); label=new QLabel(i18n("Default password:"),this); label->setAlignment(Qt::AlignRight | Qt::AlignVCenter); label->setBuddy( m_passwordLe ); layout->addWidget(label,2,0); layout->addWidget(m_passwordLe,2,1); /* m_workgroupLe=new QLineEdit(this); label=new QLabel(m_workgroupLe,i18n("Workgroup:"),this); layout->addWidget(label,3,0); layout->addWidget(m_workgroupLe,3,1); m_showHiddenShares=new QCheckBox(i18n("Show hidden shares"),this); layout->addWidget(m_showHiddenShares,4,0, 1, 2 ); m_encodingList = new KComboBox( false, this ); QStringList _strList = KCharsets::charsets()->availableEncodingNames(); m_encodingList->addItems( _strList ); label = new QLabel( i18n( "MS Windows encoding:" ), this ); label->setBuddy( m_encodingList ); layout->addWidget( label, 3, 0 ); layout->addWidget( m_encodingList, 3, 1 ); */ layout->addWidget(new QWidget(this),4,0); // connect(m_showHiddenShares, SIGNAL(toggled(bool)), this, SLOT(changed())); connect(m_userLe, SIGNAL(textChanged(QString)), this, SLOT(changed())); connect(m_passwordLe, SIGNAL(textChanged(QString)), this, SLOT(changed())); // connect(m_workgroupLe, SIGNAL(textChanged(QString)), this, SLOT(changed())); // connect( m_encodingList, SIGNAL(activated(QString)), this , SLOT(changed()) ); layout->setRowStretch(4, 1); } SMBRoOptions::~SMBRoOptions() { } void SMBRoOptions::load() { KConfig *cfg = new KConfig(QStringLiteral("kioslaverc")); QString tmp; KConfigGroup group = cfg->group("Browser Settings/SMBro" ); m_userLe->setText(group.readEntry("User")); // m_workgroupLe->setText(group.readEntry("Workgroup")); // m_showHiddenShares->setChecked(group.readEntry("ShowHiddenShares", QVariant(false)).toBool()); //QStringList _strList = KCharsets::charsets()->availableEncodingNames(); //QString m_encoding = QTextCodec::codecForLocale()->name(); //m_encodingList->setCurrentIndex( _strList.indexOf( group.readEntry( "Encoding", m_encoding.toLower() ) ) ); // unscramble QString scrambled = group.readEntry( "Password" ); QString password = QLatin1String(""); for (int i=0; isetText(password); delete cfg; } void SMBRoOptions::save() { KConfig *cfg = new KConfig(QStringLiteral("kioslaverc")); KConfigGroup group = cfg->group("Browser Settings/SMBro" ); group.writeEntry( "User", m_userLe->text()); // group.writeEntry( "Workgroup", m_workgroupLe->text()); // group.writeEntry( "ShowHiddenShares", m_showHiddenShares->isChecked()); // group.writeEntry( "Encoding", m_encodingList->currentText() ); //taken from Nicola Brodu's smb ioslave //it's not really secure, but at //least better than storing the plain password QString password(m_passwordLe->text()); QString scrambled; for (int i=0; i> 10; unsigned int a2 = (num & 0x3E0) >> 5; unsigned int a3 = (num & 0x1F); scrambled += (char)(a1+'0'); scrambled += (char)(a2+'A'); scrambled += (char)(a3+'0'); } group.writeEntry( "Password", scrambled); delete cfg; } void SMBRoOptions::defaults() { m_userLe->setText(QLatin1String("")); m_passwordLe->setText(QLatin1String("")); // m_workgroupLe->setText(""); // m_showHiddenShares->setChecked(false); } void SMBRoOptions::changed() { emit KCModule::changed(true); } QString SMBRoOptions::quickHelp() const { return i18n("

Windows Shares

Applications using the " "SMB kioslave (like Konqueror) are able to access shared Microsoft " "Windows file systems, if properly configured.

You can specify " "here the credentials used to access the shared resources. " "Passwords will be stored locally, and scrambled so as to render them " "unreadable to the human eye. For security reasons, you may not want to " "do that, as entries with passwords are clearly indicated as such.

"); } diff --git a/src/kcms/kio/useragentdlg.cpp b/src/kcms/kio/useragentdlg.cpp index 862eef6f..c6178e32 100644 --- a/src/kcms/kio/useragentdlg.cpp +++ b/src/kcms/kio/useragentdlg.cpp @@ -1,394 +1,394 @@ /* Original Authors: Copyright (c) Kalle Dalheimer 1997 Copyright (c) David Faure 1998 Copyright (c) Dirk Mueller 2000 Completely re-written by: Copyright (C) 2000- Dawit Alemayehu This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License (GPL) version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // Own #include "useragentdlg.h" // Local #include "ksaveioconfig.h" #include "useragentinfo.h" #include "useragentselectordlg.h" // Qt #include #include #include #include // KDE #include #include #include #include #include #include Q_DECLARE_LOGGING_CATEGORY(KIO_USERAGENTDLG) Q_LOGGING_CATEGORY(KIO_USERAGENTDLG, "kf5.kio.useragentdlg") K_PLUGIN_FACTORY_DECLARATION (KioConfigFactory) typedef QList SiteList; typedef SiteList::iterator SiteListIterator; UserAgentDlg::UserAgentDlg (QWidget* parent, const QVariantList&) - : KCModule (/*ioConfigFactory::componentData(),*/ parent), + : KCModule (parent), m_userAgentInfo (nullptr), m_config (nullptr) { ui.setupUi (this); ui.newButton->setIcon (QIcon::fromTheme(QStringLiteral("list-add"))); ui.changeButton->setIcon (QIcon::fromTheme(QStringLiteral("edit-rename"))); ui.deleteButton->setIcon (QIcon::fromTheme(QStringLiteral("list-remove"))); ui.deleteAllButton->setIcon (QIcon::fromTheme(QStringLiteral("edit-delete"))); } UserAgentDlg::~UserAgentDlg() { delete m_userAgentInfo; delete m_config; } void UserAgentDlg::on_sendUACheckBox_clicked() { configChanged(); } void UserAgentDlg::on_newButton_clicked() { const QPointer pdlg (new UserAgentSelectorDlg (m_userAgentInfo, this)); pdlg->setWindowTitle(i18nc ("@title:window", "Add Identification")); if (pdlg->exec() == QDialog::Accepted && pdlg) { if (!handleDuplicate (pdlg->siteName(), pdlg->identity(), pdlg->alias())) { QTreeWidgetItem* item = new QTreeWidgetItem (ui.sitePolicyTreeWidget); item->setText (0, pdlg->siteName()); item->setText (1, pdlg->identity()); item->setText (2, pdlg->alias()); ui.sitePolicyTreeWidget->setCurrentItem (item); configChanged(); } } delete pdlg; } void UserAgentDlg::on_changeButton_clicked() { on_sitePolicyTreeWidget_itemDoubleClicked (ui.sitePolicyTreeWidget->currentItem(), -1); } void UserAgentDlg::on_deleteButton_clicked() { SiteList selectedItems = ui.sitePolicyTreeWidget->selectedItems(); SiteListIterator endIt = selectedItems.end(); QString siteName; for (SiteListIterator it = selectedItems.begin(); it != endIt; ++it) delete (*it); updateButtons(); configChanged(); } void UserAgentDlg::on_deleteAllButton_clicked() { ui.sitePolicyTreeWidget->clear(); updateButtons(); configChanged(); } void UserAgentDlg::on_osNameCheckBox_clicked() { changeDefaultUAModifiers(); } void UserAgentDlg::on_osVersionCheckBox_clicked() { changeDefaultUAModifiers(); } void UserAgentDlg::on_processorTypeCheckBox_clicked() { changeDefaultUAModifiers(); } void UserAgentDlg::on_languageCheckBox_clicked() { changeDefaultUAModifiers(); } void UserAgentDlg::on_sitePolicyTreeWidget_itemDoubleClicked (QTreeWidgetItem* item, int) { if (item) { // Store the current site name... const QString currentSiteName = item->text (0); UserAgentSelectorDlg pdlg (m_userAgentInfo, this); pdlg.setWindowTitle (i18nc ("@title:window", "Modify Identification")); pdlg.setSiteName (currentSiteName); pdlg.setIdentity (item->text (1)); if (pdlg.exec() == QDialog::Accepted) { if (pdlg.siteName() == currentSiteName || !handleDuplicate (pdlg.siteName(), pdlg.identity(), pdlg.alias())) { item->setText (0, pdlg.siteName()); item->setText (1, pdlg.identity()); item->setText (2, pdlg.alias()); configChanged(); } } } } void UserAgentDlg::changeDefaultUAModifiers() { - m_ua_keys = ':'; // Make sure it's not empty + m_ua_keys = QLatin1Char(':'); // Make sure it's not empty if (ui.osNameCheckBox->isChecked()) - m_ua_keys += 'o'; + m_ua_keys += QLatin1Char('o'); if (ui.osVersionCheckBox->isChecked()) - m_ua_keys += 'v'; + m_ua_keys += QLatin1Char('v'); if (ui.processorTypeCheckBox->isChecked()) - m_ua_keys += 'm'; + m_ua_keys += QLatin1Char('m'); if (ui.languageCheckBox->isChecked()) - m_ua_keys += 'l'; + m_ua_keys += QLatin1Char('l'); ui.osVersionCheckBox->setEnabled (m_ua_keys.contains ('o')); QString modVal = KProtocolManager::defaultUserAgent (m_ua_keys); if (ui.defaultIdLineEdit->text() != modVal) { ui.defaultIdLineEdit->setText (modVal); configChanged(); } } bool UserAgentDlg::handleDuplicate (const QString& site, const QString& identity, const QString& alias) { SiteList list = ui.sitePolicyTreeWidget->findItems (site, Qt::MatchExactly, 0); if (!list.isEmpty()) { QString msg = i18n ("
Found an existing identification for" "
%1
" "Do you want to replace it?
" "
", site); int res = KMessageBox::warningContinueCancel (this, msg, i18nc ("@title:window", "Duplicate Identification"), KGuiItem (i18n ("Replace"))); if (res == KMessageBox::Continue) { list[0]->setText (0, site); list[0]->setText (1, identity); list[0]->setText (2, alias); configChanged(); } return true; } return false; } void UserAgentDlg::configChanged (bool enable) { emit changed (enable); } void UserAgentDlg::updateButtons() { const int selectedItemCount = ui.sitePolicyTreeWidget->selectedItems().count(); const bool hasItems = ui.sitePolicyTreeWidget->topLevelItemCount() > 0; ui.changeButton->setEnabled ( (hasItems && selectedItemCount == 1)); ui.deleteButton->setEnabled ( (hasItems && selectedItemCount > 0)); ui.deleteAllButton->setEnabled (hasItems); } void UserAgentDlg::on_sitePolicyTreeWidget_itemSelectionChanged() { updateButtons(); } void UserAgentDlg::load() { ui.sitePolicyTreeWidget->clear(); if (!m_config) m_config = new KConfig (QStringLiteral("kio_httprc"), KConfig::NoGlobals); else m_config->reparseConfiguration(); if (!m_userAgentInfo) m_userAgentInfo = new UserAgentInfo(); const QStringList list = m_config->groupList(); QStringList::ConstIterator endIt = list.end(); QString agentStr; for (QStringList::ConstIterator it = list.begin(); it != endIt; ++it) { if ( (*it) == QLatin1String("")) continue; KConfigGroup cg (m_config, *it); agentStr = cg.readEntry ("UserAgent"); if (!agentStr.isEmpty()) { QTreeWidgetItem* item = new QTreeWidgetItem (ui.sitePolicyTreeWidget); item->setText (0, (*it).toLower()); item->setText (1, m_userAgentInfo->aliasStr (agentStr)); item->setText (2, agentStr); } } // Update buttons and checkboxes... KConfigGroup cg2 (m_config, QString()); bool b = cg2.readEntry ("SendUserAgent", true); ui.sendUACheckBox->setChecked (b); m_ua_keys = cg2.readEntry ("UserAgentKeys", DEFAULT_USER_AGENT_KEYS).toLower(); ui.defaultIdLineEdit->setText (KProtocolManager::defaultUserAgent (m_ua_keys)); ui.osNameCheckBox->setChecked (m_ua_keys.contains ('o')); ui.osVersionCheckBox->setChecked (m_ua_keys.contains ('v')); ui.processorTypeCheckBox->setChecked (m_ua_keys.contains ('m')); ui.languageCheckBox->setChecked (m_ua_keys.contains ('l')); updateButtons(); configChanged (false); } void UserAgentDlg::defaults() { ui.sitePolicyTreeWidget->clear(); m_ua_keys = QStringLiteral(DEFAULT_USER_AGENT_KEYS); ui.defaultIdLineEdit->setText (KProtocolManager::defaultUserAgent (m_ua_keys)); ui.osNameCheckBox->setChecked (m_ua_keys.contains ('o')); ui.osVersionCheckBox->setChecked (m_ua_keys.contains ('v')); ui.processorTypeCheckBox->setChecked (m_ua_keys.contains ('m')); ui.languageCheckBox->setChecked (m_ua_keys.contains ('l')); ui.sendUACheckBox->setChecked (true); updateButtons(); configChanged(); } void UserAgentDlg::save() { Q_ASSERT (m_config); // Put all the groups except the default into the delete list. QStringList deleteList = m_config->groupList(); //Remove all the groups that DO NOT contain a "UserAgent" entry... QStringList::ConstIterator endIt = deleteList.constEnd(); for (QStringList::ConstIterator it = deleteList.constBegin(); it != endIt; ++it) { if ( (*it) == QLatin1String ("")) continue; KConfigGroup cg (m_config, *it); if (!cg.hasKey ("UserAgent")) deleteList.removeAll (*it); } QString domain; QTreeWidgetItem* item; int itemCount = ui.sitePolicyTreeWidget->topLevelItemCount(); // Save and remove from the delete list all the groups that were // not deleted by the end user. for (int i = 0; i < itemCount; i++) { item = ui.sitePolicyTreeWidget->topLevelItem (i); domain = item->text (0); KConfigGroup cg (m_config, domain); cg.writeEntry ("UserAgent", item->text (2)); deleteList.removeAll (domain); qCDebug (KIO_USERAGENTDLG, "UserAgentDlg::save: Removed [%s] from delete list", domain.toLatin1().constData()); } // Write the global configuration information... KConfigGroup cg (m_config, QString()); cg.writeEntry ("SendUserAgent", ui.sendUACheckBox->isChecked()); cg.writeEntry ("UserAgentKeys", m_ua_keys); // Sync up all the changes so far... m_config->sync(); // If delete list is not empty, delete the specified domains. if (!deleteList.isEmpty()) { // Remove entries from local file. endIt = deleteList.constEnd(); KConfig cfg (QStringLiteral("kio_httprc"), KConfig::SimpleConfig); for (QStringList::ConstIterator it = deleteList.constBegin(); it != endIt; ++it) { KConfigGroup cg (&cfg, *it); cg.deleteEntry ("UserAgent"); qCDebug (KIO_USERAGENTDLG, "UserAgentDlg::save: Deleting UserAgent of group [%s]", (*it).toLatin1().constData()); if (cg.keyList().count() < 1) cg.deleteGroup(); } // Sync up the configuration... cfg.sync(); // Check everything is gone, reset to blank otherwise. m_config->reparseConfiguration(); endIt = deleteList.constEnd(); for (QStringList::ConstIterator it = deleteList.constBegin(); it != endIt; ++it) { KConfigGroup cg (m_config, *it); if (cg.hasKey ("UserAgent")) cg.writeEntry ("UserAgent", QString()); } // Sync up the configuration... m_config->sync(); } KSaveIOConfig::updateRunningIOSlaves (this); configChanged (false); } QString UserAgentDlg::quickHelp() const { return i18n ("

Browser Identification

" "

The browser-identification module allows you to have " "full control over how KDE applications using the HTTP " "protocol (like Konqueror) will identify itself to web sites " "you browse.

" "

This ability to fake identification is necessary because " "some web sites do not display properly when they detect that " "they are not talking to current versions of either Netscape " "Navigator or Internet Explorer, even if the browser actually " "supports all the necessary features to render those pages " "properly. " "For such sites, you can use this feature to try to browse " "them. Please understand that this might not always work, since " "such sites might be using non-standard web protocols and or " "specifications.

" "

NOTE: To obtain specific help on a particular section " "of the dialog box, simply click on the quick help button on " "the window title bar, then click on the section " "for which you are seeking help.

"); }