Changeset View
Changeset View
Standalone View
Standalone View
privacyfunctions.cpp
Show All 19 Lines | |||||
20 | 20 | | |||
21 | #include "privacyfunctions.h" | 21 | #include "privacyfunctions.h" | ||
22 | 22 | | |||
23 | #include <KBookmarkManager> | 23 | #include <KBookmarkManager> | ||
24 | #include <KConfig> | 24 | #include <KConfig> | ||
25 | #include <KConfigGroup> | 25 | #include <KConfigGroup> | ||
26 | #include <KRecentDocument> | 26 | #include <KRecentDocument> | ||
27 | #include <KToolInvocation> | 27 | #include <KToolInvocation> | ||
28 | #include <KActivities/Stats/Cleaning> | ||||
29 | #include <KActivities/Stats/ResultSet> | ||||
30 | #include <KActivities/Stats/Terms> | ||||
31 | | ||||
28 | 32 | | |||
29 | #include <QDir> | 33 | #include <QDir> | ||
30 | #include <QFile> | 34 | #include <QFile> | ||
31 | #include <QLatin1String> | 35 | #include <QLatin1String> | ||
32 | #include <QProcess> | 36 | #include <QProcess> | ||
33 | #include <QRegularExpression> | 37 | #include <QRegularExpression> | ||
34 | #include <QStandardPaths> | 38 | #include <QStandardPaths> | ||
35 | #include <QStringList> | 39 | #include <QStringList> | ||
36 | #include <QtDBus> | 40 | #include <QtDBus> | ||
37 | 41 | | |||
38 | #include "config-sweeper.h" | 42 | #include "config-sweeper.h" | ||
39 | 43 | | |||
44 | namespace KAStats = KActivities::Stats; | ||||
45 | | ||||
46 | using namespace KAStats; | ||||
47 | using namespace KAStats::Terms; | ||||
48 | | ||||
40 | bool ClearThumbnailsAction::action() | 49 | bool ClearThumbnailsAction::action() | ||
41 | { | 50 | { | ||
42 | // http://freedesktop.org/Standards/Home | 51 | // http://freedesktop.org/Standards/Home | ||
43 | // http://triq.net/~jens/thumbnail-spec/index.html | 52 | // http://triq.net/~jens/thumbnail-spec/index.html | ||
44 | 53 | | |||
45 | QDir thumbnailDir( QDir::homePath() + QLatin1String( "/.thumbnails/normal" )); | 54 | QDir thumbnailDir( QDir::homePath() + QLatin1String( "/.thumbnails/normal" )); | ||
46 | thumbnailDir.setFilter( QDir::Files ); | 55 | thumbnailDir.setFilter( QDir::Files ); | ||
47 | const QStringList entries = thumbnailDir.entryList(); | 56 | const QStringList entries = thumbnailDir.entryList(); | ||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Line(s) | |||||
146 | { | 155 | { | ||
147 | QStringList lst; | 156 | QStringList lst; | ||
148 | lst << QStringLiteral("--clear-all"); | 157 | lst << QStringLiteral("--clear-all"); | ||
149 | return QProcess::startDetached(QFile::decodeName(KDE_INSTALL_FULL_LIBEXECDIR_KF5 "/kio_http_cache_cleaner"), lst); | 158 | return QProcess::startDetached(QFile::decodeName(KDE_INSTALL_FULL_LIBEXECDIR_KF5 "/kio_http_cache_cleaner"), lst); | ||
150 | } | 159 | } | ||
151 | 160 | | |||
152 | bool ClearRecentDocumentsAction::action() | 161 | bool ClearRecentDocumentsAction::action() | ||
153 | { | 162 | { | ||
163 | auto query = UsedResources | ||||
164 | | Agent::any() | ||||
165 | | Type::any() | ||||
166 | | Url::file(); | ||||
167 | | ||||
168 | KAStats::forgetResources(query); | ||||
169 | | ||||
154 | KRecentDocument::clear(); | 170 | KRecentDocument::clear(); | ||
155 | return KRecentDocument::recentDocuments().isEmpty(); | 171 | return KRecentDocument::recentDocuments().isEmpty(); | ||
156 | } | 172 | } | ||
157 | 173 | | |||
158 | bool ClearWebHistoryAction::action() | 174 | bool ClearWebHistoryAction::action() | ||
159 | { | 175 | { | ||
160 | // Clear the history from the memory of the running konquerors | 176 | // Clear the history from the memory of the running konquerors | ||
161 | QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/KonqHistoryManager"), QStringLiteral("org.kde.Konqueror.HistoryManager"), QStringLiteral("notifyClear")); | 177 | QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/KonqHistoryManager"), QStringLiteral("org.kde.Konqueror.HistoryManager"), QStringLiteral("notifyClear")); | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 229 | for( QStringList::const_iterator it = entries.begin() ; it != entries.end() ; ++it) { | |||
221 | } | 237 | } | ||
222 | } | 238 | } | ||
223 | 239 | | |||
224 | return true; | 240 | return true; | ||
225 | } | 241 | } | ||
226 | 242 | | |||
227 | bool ClearRecentApplicationAction::action() | 243 | bool ClearRecentApplicationAction::action() | ||
228 | { | 244 | { | ||
229 | QDBusMessage message = | 245 | auto query = UsedResources | ||
230 | QDBusMessage::createSignal(QLatin1String( "/kickoff/RecentAppDoc" ), QLatin1String( "org.kde.plasma" ), QLatin1String( "clearRecentDocumentsAndApplications" )); | 246 | | Agent::any() | ||
mart: it seems the method is called ClearRecentApplicationAction, tough this would nuke all usage… | |||||
231 | QDBusConnection::sessionBus().send(message); | 247 | | Type::any() | ||
It is not advisable to use KAMD d-bus directly. It is not officially a stable API. You should use the KAStats library instead. ivan: It is not advisable to use KAMD d-bus directly. It is not officially a stable API. You should… | |||||
248 | | Url::startsWith(QStringLiteral("applications:")); | ||||
249 | KAStats::forgetResources(query); | ||||
232 | 250 | | |||
233 | return true; | 251 | return true; | ||
234 | } | 252 | } | ||
235 | 253 | | |||
236 | 254 | | |||
237 | // kate: tab-width 3; indent-mode cstyle; replace-tabs true; | 255 | // kate: tab-width 3; indent-mode cstyle; replace-tabs true; |
it seems the method is called ClearRecentApplicationAction, tough this would nuke all usage stats on every kind of documents as well.. is this the intended behavior?