• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeutils API Reference
  • KDE Home
  • Contact Us
 

sweeper

  • sources
  • kde-4.12
  • kdeutils
  • sweeper
privacyfunctions.cpp
Go to the documentation of this file.
1 
21 #include "privacyfunctions.h"
22 
23 #include <ktoolinvocation.h>
24 #include <kconfig.h>
25 #include <kglobal.h>
26 #include <kdebug.h>
27 #include <krecentdocument.h>
28 #include <kstandarddirs.h>
29 #include <kbookmarkmanager.h>
30 #include <klocale.h>
31 #include <QtDBus/QtDBus>
32 
33 #include <qstringlist.h>
34 #include <QFile>
35 #include <QDir>
36 #include <kconfiggroup.h>
37 #include <QProcess>
38 #include <QLatin1String>
39 
40 bool ClearThumbnailsAction::action()
41 {
42  // http://freedesktop.org/Standards/Home
43  // http://triq.net/~jens/thumbnail-spec/index.html
44 
45  QDir thumbnailDir( QDir::homePath() + QLatin1String( "/.thumbnails/normal" ));
46  thumbnailDir.setFilter( QDir::Files );
47  const QStringList entries = thumbnailDir.entryList();
48  for( QStringList::const_iterator it = entries.begin() ; it != entries.end() ; ++it) {
49  if(!thumbnailDir.remove(*it)) {
50  errMsg = i18n("A thumbnail could not be removed.");
51  return false;
52  }
53  }
54 
55  thumbnailDir.setPath(QDir::homePath() + QLatin1String( "/.thumbnails/large" ));
56  const QStringList entries2 = thumbnailDir.entryList();
57  for( QStringList::const_iterator it = entries2.begin() ; it != entries2.end() ; ++it) {
58  if(!thumbnailDir.remove(*it)) {
59  errMsg = i18n("A thumbnail could not be removed.");
60  return false;
61  }
62  }
63 
64  thumbnailDir.setPath(QDir::homePath() + QLatin1String( "/.thumbnails/fail" ));
65  const QStringList entries3 = thumbnailDir.entryList();
66  for( QStringList::const_iterator it = entries3.begin() ; it != entries3.end() ; ++it) {
67  if(!thumbnailDir.remove(*it)) {
68  errMsg = i18n("A thumbnail could not be removed.");
69  return false;
70  }
71  }
72 
73  return true;
74 }
75 
76 bool ClearRunCommandHistoryAction::action()
77 {
78  QDBusInterface krunner(QLatin1String( "org.kde.krunner" ), QLatin1String( "/App" ), QLatin1String( "org.kde.krunner.App" ));
79  QDBusReply<void> reply = krunner.call(QLatin1String( "clearHistory" ));
80  return reply.isValid();
81 }
82 
83 bool ClearAllCookiesAction::action()
84 {
85  QDBusInterface mediamanager(QLatin1String( "org.kde.kded" ), QLatin1String( "/modules/kcookiejar" ), QLatin1String( "org.kde.KCookieServer" ));
86  QDBusReply<void> reply = mediamanager.call(QLatin1String( "deleteAllCookies" ));
87  return reply.isValid();
88 }
89 
90 bool ClearAllCookiesPoliciesAction::action()
91 {
92  // load the config file and section
93  KConfig cfg(QLatin1String( "kcookiejarrc" ));
94  KConfigGroup group = cfg.group("Cookie Policy");
95 
96  kDebug() << "removing all saved cookie policies" ;
97  group.deleteEntry("CookieDomainAdvice");
98  cfg.sync();
99 
100  // inform the cookie jar we pillaged it
101  QDBusInterface kcookiejar(QLatin1String( "org.kde.kded" ), QLatin1String( "/modules/kcookiejar" ), QLatin1String( "org.kde.KCookieServer" ));
102  QDBusReply<void> reply = kcookiejar.call(QLatin1String( "reloadPolicy" ));
103 
104  return reply.isValid();
105 }
106 
107 bool ClearSavedClipboardContentsAction::action()
108 {
109  if(!QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String( "org.kde.klipper" ))) {
110  KConfig *c = new KConfig(QLatin1String( "klipperrc" ), KConfig::NoGlobals);
111  KConfigGroup group(c, "General");
112  group.deleteEntry("ClipboardData");
113  c->sync();
114 
115  delete c;
116  return true;
117  }
118  QDBusInterface klipper(QLatin1String( "org.kde.klipper" ), QLatin1String( "/klipper" ), QLatin1String( "org.kde.klipper.klipper" ));
119  QDBusReply<void> reply = klipper.call(QLatin1String( "clearClipboardHistory" ));
120  return reply.isValid();
121 }
122 
123 bool ClearFormCompletionAction::action()
124 {
125  bool status;
126 
127  // try to delete the file, if it exists
128  QFile completionFile(KStandardDirs::locateLocal("data", QLatin1String( "khtml/formcompletions" )));
129  (completionFile.exists() ? status = completionFile.remove() : status = true);
130 
131  if (!status) {
132  errMsg = i18n("The file exists but could not be removed.");
133  }
134 
135  return status;
136 }
137 
138 bool ClearWebCacheAction::action()
139 {
140  QStringList lst;
141  lst << QLatin1String( "--clear-all" );
142  return QProcess::startDetached(KStandardDirs::findExe(QLatin1String( "kio_http_cache_cleaner" )),lst);
143 }
144 
145 bool ClearRecentDocumentsAction::action()
146 {
147  KRecentDocument::clear();
148  return KRecentDocument::recentDocuments().isEmpty();
149 }
150 
151 bool ClearWebHistoryAction::action()
152 {
153  // Clear the history from the memory of the running konquerors
154  QDBusMessage message = QDBusMessage::createSignal(QLatin1String( "/KonqHistoryManager" ), QLatin1String( "org.kde.Konqueror.HistoryManager" ), QLatin1String( "notifyClear" ) );
155  (void) QDBusConnection::sessionBus().send(message);
156 
157  // Delete the file
158  const QString file = KStandardDirs::locateLocal("data", QLatin1String("konqueror/konq_history"));
159  QFile::remove(file);
160 
161  const QDBusMessage message2 = QDBusMessage::createSignal(QLatin1String( "/KonqUndoManager" ), QLatin1String( "org.kde.Konqueror.UndoManager" ), QLatin1String( "notifyRemove" ) );
162  (void) QDBusConnection::sessionBus().send(message2);
163 
164  // Delete the file
165  const QString file2 = KStandardDirs::locateLocal("data", QLatin1String("konqueror/closeditems_saved"));
166  QFile::remove(file2);
167  return true;
168 }
169 
170 bool ClearFaviconsAction::action()
171 {
172  QDir favIconDir(KGlobal::dirs()->saveLocation( "cache", QLatin1String( "favicons/" ) ));
173  QStringList saveTheseFavicons;
174  KBookmarkManager* konqiBookmarkMgr;
175 
176  konqiBookmarkMgr =
177  KBookmarkManager::managerForFile(KStandardDirs::locateLocal("data",
178  QLatin1String("konqueror/bookmarks.xml")), QLatin1String( "konqueror" ));
179  kDebug() << "saving the favicons that are in konqueror bookmarks" ;
180  kDebug() << "opened konqueror bookmarks at " << konqiBookmarkMgr->path() ;
181 
182  // get the entire slew of bookmarks
183  KBookmarkGroup konqiBookmarks = konqiBookmarkMgr->root();
184 
185  // walk through the bookmarks, if they have a favicon we should keep it
186  KBookmark bookmark = konqiBookmarks.first();
187 
188  while (!bookmark.isNull()) {
189  if ((bookmark.icon()).startsWith(QLatin1String("favicons/"))) {
190  // pick out the name, throw .png on the end, and store the filename
191  QRegExp regex(QLatin1String( "favicons/(.*)" ));
192  regex.indexIn(bookmark.icon(), 0);
193  kDebug() << "will save " << (regex.cap(1) + QLatin1String( ".png" )) ;
194  saveTheseFavicons << (regex.cap(1) + QLatin1String( ".png" ));
195  }
196  bookmark = konqiBookmarks.next(bookmark);
197  }
198 
199  favIconDir.setFilter( QDir::Files );
200 
201  const QStringList entries = favIconDir.entryList();
202 
203  // erase all files in favicon directory...
204  for( QStringList::const_iterator it = entries.begin() ; it != entries.end() ; ++it) {
205  // ...if we're not supposed to save them, of course
206  if (!saveTheseFavicons.contains(*it)) {
207  kDebug() << "removing " << *it ;
208  if(!favIconDir.remove(*it)) {
209  errMsg = i18n("A favicon could not be removed.");
210  return false;
211  }
212  }
213  }
214 
215  return true;
216 }
217 
218 bool ClearRecentApplicationAction::action()
219 {
220  QDBusMessage message =
221  QDBusMessage::createSignal(QLatin1String( "/kickoff/RecentAppDoc" ), QLatin1String( "org.kde.plasma" ), QLatin1String( "clearRecentDocumentsAndApplications" ));
222  QDBusConnection::sessionBus().send(message);
223 
224  return true;
225 }
226 
227 
228 // kate: tab-width 3; indent-mode cstyle; replace-tabs true;
ClearFaviconsAction::action
bool action()
Definition: privacyfunctions.cpp:170
ClearAllCookiesAction::action
bool action()
Definition: privacyfunctions.cpp:83
privacyfunctions.h
ClearWebHistoryAction::action
bool action()
Definition: privacyfunctions.cpp:151
ClearAllCookiesPoliciesAction::action
bool action()
Definition: privacyfunctions.cpp:90
PrivacyAction::errMsg
QString errMsg
Definition: privacyaction.h:36
ClearRecentDocumentsAction::action
bool action()
Definition: privacyfunctions.cpp:145
ClearThumbnailsAction::action
bool action()
kprivacymanager.cpp
Definition: privacyfunctions.cpp:40
ClearFormCompletionAction::action
bool action()
Definition: privacyfunctions.cpp:123
ClearRunCommandHistoryAction::action
bool action()
Definition: privacyfunctions.cpp:76
ClearRecentApplicationAction::action
bool action()
Definition: privacyfunctions.cpp:218
ClearWebCacheAction::action
bool action()
Definition: privacyfunctions.cpp:138
ClearSavedClipboardContentsAction::action
bool action()
Definition: privacyfunctions.cpp:107
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:07:17 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

sweeper

Skip menu "sweeper"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • kremotecontrol
  • ktimer
  • kwallet
  • superkaramba
  • sweeper

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal