diff --git a/main.cpp b/main.cpp index d71f6ba..c299553 100644 --- a/main.cpp +++ b/main.cpp @@ -1,76 +1,76 @@ /** * Copyright (C) 2005 Benjamin C Meyer (ben at meyerhome dot net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser 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. */ #include "sweeper.h" #include #include #include #include #include #include int main(int argc, char *argv[]) { QApplication a(argc, argv); KLocalizedString::setApplicationDomain("sweeper"); Kdelibs4ConfigMigrator migrator(QStringLiteral("sweeper")); migrator.setConfigFiles(QStringList() << QStringLiteral("sweeperrc")); migrator.setConfigFiles(QStringList() << QStringLiteral("kprivacyrc")); migrator.setUiFiles(QStringList() << QStringLiteral("sweeperui.rc")); migrator.migrate(); KAboutData aboutData(QStringLiteral("sweeper"), i18n("Sweeper"), QStringLiteral("1.9"), i18n("Helps clean unwanted traces the user leaves on the system."), KAboutLicense::LGPL, i18n("(c) 2003-2005, Ralf Hoelzer"), QString(), QStringLiteral("http://utils.kde.org/projects/sweeper")); aboutData.addAuthor(i18n("Ralf Hoelzer"), i18n("Original author"), QStringLiteral("ralf@well.com")); aboutData.addAuthor(i18n("Brian S. Stephan"), i18n("Maintainer"), QStringLiteral("bssteph@irtonline.org")); aboutData.addAuthor(i18n("Benjamin Meyer"), i18n("Thumbnail Cache"), QStringLiteral("ben+kdeprivacy@meyerhome.net")); // command line QCommandLineParser parser; KAboutData::setApplicationData(aboutData); - a.setWindowIcon(QIcon::fromTheme(QLatin1String("trash-empty"))); + a.setWindowIcon(QIcon::fromTheme(QStringLiteral("trash-empty"))); parser.addVersionOption(); parser.addHelpOption(); parser.addOption(QCommandLineOption(QStringLiteral("automatic"), i18n("Sweeps without user interaction"))); aboutData.setupCommandLine(&parser); parser.process(a); aboutData.processCommandLine(&parser); // Application Sweeper *app; if(parser.isSet(QStringLiteral("automatic"))) { app = new Sweeper(true); } else { app = new Sweeper(false); app->show(); } return a.exec(); } // kate: tab-width 3; indent-mode cstyle; replace-tabs true; diff --git a/privacyfunctions.cpp b/privacyfunctions.cpp index 7eafb69..d938952 100644 --- a/privacyfunctions.cpp +++ b/privacyfunctions.cpp @@ -1,236 +1,236 @@ /** * kprivacymanager.cpp * * Copyright (c) 2003 Ralf Hoelzer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser 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. */ #include "privacyfunctions.h" #include #include #include #include #include #include #include #include #include #include #include #include #include "config-sweeper.h" bool ClearThumbnailsAction::action() { // http://freedesktop.org/Standards/Home // http://triq.net/~jens/thumbnail-spec/index.html QDir thumbnailDir( QDir::homePath() + QLatin1String( "/.thumbnails/normal" )); thumbnailDir.setFilter( QDir::Files ); const QStringList entries = thumbnailDir.entryList(); for( QStringList::const_iterator it = entries.begin() ; it != entries.end() ; ++it) { if(!thumbnailDir.remove(*it)) { errMsg = i18n("A thumbnail could not be removed."); return false; } } thumbnailDir.setPath(QDir::homePath() + QLatin1String( "/.thumbnails/large" )); const QStringList entries2 = thumbnailDir.entryList(); for( QStringList::const_iterator it = entries2.begin() ; it != entries2.end() ; ++it) { if(!thumbnailDir.remove(*it)) { errMsg = i18n("A thumbnail could not be removed."); return false; } } thumbnailDir.setPath(QDir::homePath() + QLatin1String( "/.thumbnails/fail" )); const QStringList entries3 = thumbnailDir.entryList(); for( QStringList::const_iterator it = entries3.begin() ; it != entries3.end() ; ++it) { if(!thumbnailDir.remove(*it)) { errMsg = i18n("A thumbnail could not be removed."); return false; } } return true; } bool ClearRunCommandHistoryAction::action() { - KConfig cfg(QLatin1String("krunnerrc")); + KConfig cfg(QStringLiteral("krunnerrc")); KConfigGroup configGroup = cfg.group("General"); configGroup.writeEntry("history", QStringList()); configGroup.sync(); return true; } bool ClearAllCookiesAction::action() { QDBusInterface cookiejar(QStringLiteral("org.kde.kcookiejar5"), QStringLiteral("/modules/kcookiejar" ), QStringLiteral("org.kde.KCookieServer"), QDBusConnection::sessionBus()); QDBusReply reply = cookiejar.call(QStringLiteral("deleteAllCookies")); return reply.isValid(); } bool ClearAllCookiesPoliciesAction::action() { // load the config file and section - KConfig cfg(QLatin1String( "kcookiejarrc" )); + KConfig cfg(QStringLiteral("kcookiejarrc")); KConfigGroup group = cfg.group("Cookie Policy"); qDebug() << "removing all saved cookie policies" ; group.deleteEntry("CookieDomainAdvice"); cfg.sync(); // inform the cookie jar we pillaged it QDBusInterface kcookiejar(QStringLiteral("org.kde.kcookiejar5" ), QStringLiteral("/modules/kcookiejar" ), QStringLiteral( "org.kde.KCookieServer" )); QDBusReply reply = kcookiejar.call(QStringLiteral("reloadPolicy")); return reply.isValid(); } bool ClearSavedClipboardContentsAction::action() { - if(!QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String( "org.kde.klipper" ))) { - KConfig *c = new KConfig(QLatin1String( "klipperrc" ), KConfig::NoGlobals); + if(!QDBusConnection::sessionBus().interface()->isServiceRegistered(QStringLiteral("org.kde.klipper"))) { + KConfig *c = new KConfig(QStringLiteral("klipperrc"), KConfig::NoGlobals); KConfigGroup group(c, "General"); group.deleteEntry("ClipboardData"); c->sync(); delete c; return true; } - QDBusInterface klipper(QLatin1String( "org.kde.klipper" ), QLatin1String( "/klipper" ), QLatin1String( "org.kde.klipper.klipper" )); - QDBusReply reply = klipper.call(QLatin1String( "clearClipboardHistory" )); + QDBusInterface klipper(QStringLiteral("org.kde.klipper"), QStringLiteral("/klipper"), QStringLiteral("org.kde.klipper.klipper")); + QDBusReply reply = klipper.call(QStringLiteral("clearClipboardHistory")); return reply.isValid(); } bool ClearFormCompletionAction::action() { bool status; // try to delete the file, if it exists QFile completionFile(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/khtml/formcompletions" )); (completionFile.exists() ? status = completionFile.remove() : status = true); if (!status) { errMsg = i18n("The file exists but could not be removed."); } return status; } bool ClearWebCacheAction::action() { QStringList lst; - lst << QLatin1String( "--clear-all" ); + lst << QStringLiteral("--clear-all"); return QProcess::startDetached(QFile::decodeName(KDE_INSTALL_FULL_LIBEXECDIR_KF5 "/kio_http_cache_cleaner"), lst); } bool ClearRecentDocumentsAction::action() { KRecentDocument::clear(); return KRecentDocument::recentDocuments().isEmpty(); } bool ClearWebHistoryAction::action() { // Clear the history from the memory of the running konquerors - QDBusMessage message = QDBusMessage::createSignal(QLatin1String( "/KonqHistoryManager" ), QLatin1String( "org.kde.Konqueror.HistoryManager" ), QLatin1String( "notifyClear" ) ); + QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/KonqHistoryManager"), QStringLiteral("org.kde.Konqueror.HistoryManager"), QStringLiteral("notifyClear")); (void) QDBusConnection::sessionBus().send(message); // Delete the file const QString file = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/konqueror/konq_history"); QFile::remove(file); - const QDBusMessage message2 = QDBusMessage::createSignal(QLatin1String( "/KonqUndoManager" ), QLatin1String( "org.kde.Konqueror.UndoManager" ), QLatin1String( "notifyRemove" ) ); + const QDBusMessage message2 = QDBusMessage::createSignal(QStringLiteral("/KonqUndoManager"), QStringLiteral("org.kde.Konqueror.UndoManager"), QStringLiteral("notifyRemove")); (void) QDBusConnection::sessionBus().send(message2); // Delete the file const QString file2 = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/konqueror/closeditems_saved"); QFile::remove(file2); return true; } bool ClearFaviconsAction::action() { QDir favIconDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QLatin1Char('/') + QLatin1String( "favicons/" )); QStringList saveTheseFavicons; KBookmarkManager* konqiBookmarkMgr; const QString path = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/konqueror/bookmarks.xml"); QDir().mkpath(path); konqiBookmarkMgr = KBookmarkManager::managerForFile(path, QStringLiteral("konqueror")); qDebug() << "saving the favicons that are in konqueror bookmarks" ; qDebug() << "opened konqueror bookmarks at " << konqiBookmarkMgr->path() ; // get the entire slew of bookmarks KBookmarkGroup konqiBookmarks = konqiBookmarkMgr->root(); // walk through the bookmarks, if they have a favicon we should keep it KBookmark bookmark = konqiBookmarks.first(); while (!bookmark.isNull()) { - if ((bookmark.icon()).startsWith(QLatin1String("favicons/"))) { + if ((bookmark.icon()).startsWith(QStringLiteral("favicons/"))) { // pick out the name, throw .png on the end, and store the filename QRegExp regex(QLatin1String( "favicons/(.*)" )); regex.indexIn(bookmark.icon(), 0); qDebug() << "will save " << (regex.cap(1) + QLatin1String( ".png" )) ; saveTheseFavicons << (regex.cap(1) + QLatin1String( ".png" )); } bookmark = konqiBookmarks.next(bookmark); } favIconDir.setFilter( QDir::Files ); const QStringList entries = favIconDir.entryList(); // erase all files in favicon directory... for( QStringList::const_iterator it = entries.begin() ; it != entries.end() ; ++it) { // ...if we're not supposed to save them, of course if (!saveTheseFavicons.contains(*it)) { qDebug() << "removing " << *it ; if(!favIconDir.remove(*it)) { errMsg = i18n("A favicon could not be removed."); return false; } } } return true; } bool ClearRecentApplicationAction::action() { QDBusMessage message = QDBusMessage::createSignal(QLatin1String( "/kickoff/RecentAppDoc" ), QLatin1String( "org.kde.plasma" ), QLatin1String( "clearRecentDocumentsAndApplications" )); QDBusConnection::sessionBus().send(message); return true; } // kate: tab-width 3; indent-mode cstyle; replace-tabs true; diff --git a/privacyfunctions.h b/privacyfunctions.h index 496319d..a5a8971 100644 --- a/privacyfunctions.h +++ b/privacyfunctions.h @@ -1,147 +1,147 @@ /** * kprivacymanager.h * * Copyright (c) 2003 Ralf Hoelzer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser 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. */ #ifndef PRIVACYFUNCTIONS_H #define PRIVACYFUNCTIONS_H #include "privacyaction.h" #include /** @author Ralf Hoelzer */ class ClearAllCookiesAction : public PrivacyAction { public: ClearAllCookiesAction(QTreeWidgetItem * parent) : PrivacyAction(parent, i18n("Cookies"), i18n("Clears all stored cookies set by websites")) { } bool action(); - /* reimp */ QString configKey() const { return QLatin1String( "ClearAllCookies" ); } + /* reimp */ QString configKey() const { return QStringLiteral("ClearAllCookies"); } }; class ClearAllCookiesPoliciesAction : public PrivacyAction { public: ClearAllCookiesPoliciesAction(QTreeWidgetItem * parent) : PrivacyAction(parent, i18n("Cookie Policies"), i18n("Clears the cookie policies for all visited websites")) { } bool action(); - /* reimp */ QString configKey() const { return QLatin1String( "ClearAllCookiesPolicies" ); } + /* reimp */ QString configKey() const { return QStringLiteral("ClearAllCookiesPolicies"); } }; class ClearSavedClipboardContentsAction : public PrivacyAction { public: ClearSavedClipboardContentsAction(QTreeWidgetItem * parent) : PrivacyAction(parent, i18n("Saved Clipboard Contents"), i18n("Clears the clipboard contents stored by Klipper")) { } bool action(); - /* reimp */ QString configKey() const { return QLatin1String( "ClearSavedClipboardContents" ); } + /* reimp */ QString configKey() const { return QStringLiteral("ClearSavedClipboardContents"); } }; class ClearThumbnailsAction : public PrivacyAction { public: ClearThumbnailsAction(QTreeWidgetItem * parent) : PrivacyAction(parent, i18n("Thumbnail Cache"), i18n("Clears all cached thumbnails")) { } bool action(); - /* reimp */ QString configKey() const { return QLatin1String( "ClearThumbnails" ); } + /* reimp */ QString configKey() const { return QStringLiteral("ClearThumbnails"); } }; class ClearRunCommandHistoryAction : public PrivacyAction { public: ClearRunCommandHistoryAction(QTreeWidgetItem * parent) : PrivacyAction(parent, i18n("Run Command History"), i18n("Clears the history of commands run through the Run Command tool on the desktop")) { } bool action(); - /* reimp */ QString configKey() const { return QLatin1String( "ClearRunCommandHistory" ); } + /* reimp */ QString configKey() const { return QStringLiteral("ClearRunCommandHistory"); } }; class ClearFormCompletionAction : public PrivacyAction { public: ClearFormCompletionAction(QTreeWidgetItem * parent) : PrivacyAction(parent, i18n("Form Completion Entries"), i18n("Clears values which were entered into forms on websites")) { } bool action(); - /* reimp */ QString configKey() const { return QLatin1String( "ClearFormCompletion" ); } + /* reimp */ QString configKey() const { return QStringLiteral("ClearFormCompletion"); } }; class ClearWebHistoryAction : public PrivacyAction { public: ClearWebHistoryAction(QTreeWidgetItem * parent) : PrivacyAction(parent, i18n("Web History"), i18n("Clears the history of visited websites")) { } bool action(); - /* reimp */ QString configKey() const { return QLatin1String( "ClearWebHistory" ); } + /* reimp */ QString configKey() const { return QStringLiteral("ClearWebHistory"); } }; class ClearWebCacheAction : public PrivacyAction { public: ClearWebCacheAction(QTreeWidgetItem * parent) : PrivacyAction(parent, i18n("Web Cache"), i18n("Clears the temporary cache of websites visited")) { } bool action(); - /* reimp */ QString configKey() const { return QLatin1String( "ClearWebCache" ); } + /* reimp */ QString configKey() const { return QStringLiteral("ClearWebCache"); } }; class ClearRecentDocumentsAction : public PrivacyAction { public: ClearRecentDocumentsAction(QTreeWidgetItem * parent) : PrivacyAction(parent, i18n("Recent Documents"), i18n("Clears the list of recently used documents from the KDE applications menu")) { } bool action(); - /* reimp */ QString configKey() const { return QLatin1String( "ClearRecentDocuments" ); } + /* reimp */ QString configKey() const { return QStringLiteral("ClearRecentDocuments"); } }; class ClearFaviconsAction : public PrivacyAction { public: ClearFaviconsAction(QTreeWidgetItem * parent) : PrivacyAction(parent, i18n("Favorite Icons"), i18n("Clears the FavIcons cached from visited websites")) { } bool action(); - /* reimp */ QString configKey() const { return QLatin1String( "ClearFavIcons" ); } + /* reimp */ QString configKey() const { return QStringLiteral("ClearFavIcons"); } }; class ClearRecentApplicationAction : public PrivacyAction { public: ClearRecentApplicationAction(QTreeWidgetItem * parent) : PrivacyAction(parent, i18n("Recent Applications"), i18n("Clears the list of recently used applications from KDE menu")) { } bool action(); - /* reimp */ QString configKey() const { return QLatin1String( "ClearQuickStartMenu" ); } + /* reimp */ QString configKey() const { return QStringLiteral("ClearQuickStartMenu"); } }; #endif // kate: tab-width 3; indent-mode cstyle; replace-tabs true; diff --git a/sweeper.cpp b/sweeper.cpp index caafec4..879ef22 100644 --- a/sweeper.cpp +++ b/sweeper.cpp @@ -1,174 +1,174 @@ /** * Copyright (c) 2003-2005 Ralf Hoelzer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser 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. */ #include "sweeper.h" #include "privacyaction.h" #include "privacyfunctions.h" #include "sweeperadaptor.h" #include #include #include #include #include #include Sweeper::Sweeper(bool automatic) : KXmlGuiWindow(0) - , m_privacyConfGroup(KSharedConfig::openConfig(QLatin1String( "kprivacyrc" ), KConfig::NoGlobals), "Cleaning") + , m_privacyConfGroup(KSharedConfig::openConfig(QStringLiteral("kprivacyrc"), KConfig::NoGlobals), "Cleaning") , m_automatic(automatic) { QWidget *mainWidget = new QWidget(this); ui.setupUi(mainWidget); setCentralWidget(mainWidget); QTreeWidget *sw = ui.privacyListView; KStandardAction::quit(this, SLOT(close()), actionCollection()); - createGUI(QLatin1String( "sweeperui.rc" )); + createGUI(QStringLiteral("sweeperui.rc")); setAutoSaveSettings(); generalCLI = new QTreeWidgetItem(QStringList() << i18nc("General system content", "General")); sw->addTopLevelItem(generalCLI); webbrowsingCLI = new QTreeWidgetItem(QStringList() << i18nc("Web browsing content", "Web Browsing")); sw->addTopLevelItem(webbrowsingCLI); generalCLI->setExpanded(true); webbrowsingCLI->setExpanded(true); this->InitActions(); connect(ui.cleanupButton, SIGNAL(clicked()), SLOT(cleanup())); connect(ui.selectAllButton, SIGNAL(clicked()), SLOT(selectAll())); connect(ui.selectNoneButton, SIGNAL(clicked()), SLOT(selectNone())); new KsweeperAdaptor(this); - QDBusConnection::sessionBus().registerObject(QLatin1String( "/ksweeper" ), this); + QDBusConnection::sessionBus().registerObject(QStringLiteral("/ksweeper"), this); load(); if(automatic) { cleanup(); close(); } } Sweeper::~Sweeper() { save(); } void Sweeper::load() { QLinkedList::iterator itr; for (itr = checklist.begin(); itr != checklist.end(); ++itr) { (*itr)->setCheckState(0, m_privacyConfGroup.readEntry((*itr)->configKey(), true) ? Qt::Checked : Qt::Unchecked); } } void Sweeper::save() { QLinkedList::iterator itr; for (itr = checklist.begin(); itr != checklist.end(); ++itr) { m_privacyConfGroup.writeEntry((*itr)->configKey(), (*itr)->checkState(0) == Qt::Checked); } m_privacyConfGroup.sync(); } void Sweeper::selectAll() { QLinkedList::iterator itr; for (itr = checklist.begin(); itr != checklist.end(); ++itr) { (*itr)->setCheckState(0, Qt::Checked); } } void Sweeper::selectNone() { QLinkedList::iterator itr; for (itr = checklist.begin(); itr != checklist.end(); ++itr) { (*itr)->setCheckState(0, Qt::Unchecked); } } void Sweeper::cleanup() { if (!m_automatic) { if (KMessageBox::warningContinueCancel(this, i18n("You are deleting data that is potentially valuable to you. Are you sure?")) != KMessageBox::Continue) { return; } } ui.statusTextEdit->clear(); ui.statusTextEdit->setText(i18n("Starting cleanup...")); QLinkedList::iterator itr; for (itr = checklist.begin(); itr != checklist.end(); ++itr) { if((*itr)->checkState(0) == Qt::Checked) { QString statusText = i18n("Clearing %1...", (*itr)->text(0)); ui.statusTextEdit->append(statusText); // actions return whether they were successful if(!(*itr)->action()) { QString errorText = i18n("Clearing of %1 failed: %2", (*itr)->text(0), (*itr)->getErrMsg()); ui.statusTextEdit->append(errorText); } } } ui.statusTextEdit->append(i18n("Clean up finished.")); } void Sweeper::InitActions() { // store all entries in a list for easy access later on checklist.append(new ClearSavedClipboardContentsAction(generalCLI)); checklist.append(new ClearRecentDocumentsAction(generalCLI)); checklist.append(new ClearRunCommandHistoryAction(generalCLI)); #ifdef Q_WS_X11 checklist.append( new ClearRecentApplicationAction( generalCLI ) ); #endif checklist.append(new ClearThumbnailsAction(generalCLI)); checklist.append(new ClearAllCookiesAction(webbrowsingCLI)); checklist.append(new ClearFaviconsAction(webbrowsingCLI)); checklist.append(new ClearWebHistoryAction(webbrowsingCLI)); checklist.append(new ClearWebCacheAction(webbrowsingCLI)); checklist.append(new ClearFormCompletionAction(webbrowsingCLI)); checklist.append(new ClearAllCookiesPoliciesAction(webbrowsingCLI)); ui.privacyListView->resizeColumnToContents(0); } #include "sweeper.moc" // kate: tab-width 3; indent-mode cstyle; replace-tabs true;