Changeset View
Changeset View
Standalone View
Standalone View
src/tools/balooctl/main.cpp
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | Copyright (c) 2012-2015 Vishesh Handa <me@vhanda.in> | 2 | Copyright (c) 2012-2015 Vishesh Handa <me@vhanda.in> | ||
3 | Copyright (c) 2018 Michael Heidelbach <ottwolt@gmail.com> | ||||
3 | 4 | | |||
4 | This program is free software; you can redistribute it and/or | 5 | This program is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU General Public License as | 6 | modify it under the terms of the GNU General Public License as | ||
6 | published by the Free Software Foundation; either version 2 of | 7 | published by the Free Software Foundation; either version 2 of | ||
7 | the License or (at your option) version 3 or any later version | 8 | the License or (at your option) version 3 or any later version | ||
8 | accepted by the membership of KDE e.V. (or its successor approved | 9 | accepted by the membership of KDE e.V. (or its successor approved | ||
9 | by the membership of KDE e.V.), which shall act as a proxy | 10 | by the membership of KDE e.V.), which shall act as a proxy | ||
10 | defined in Section 14 of version 3 of the license. | 11 | defined in Section 14 of version 3 of the license. | ||
Show All 37 Lines | |||||
48 | #include "idutils.h" | 49 | #include "idutils.h" | ||
49 | #include "fileindexerconfig.h" | 50 | #include "fileindexerconfig.h" | ||
50 | #include "monitorcommand.h" | 51 | #include "monitorcommand.h" | ||
51 | #include "schedulerinterface.h" | 52 | #include "schedulerinterface.h" | ||
52 | #include "maininterface.h" | 53 | #include "maininterface.h" | ||
53 | #include "indexerstate.h" | 54 | #include "indexerstate.h" | ||
54 | #include "configcommand.h" | 55 | #include "configcommand.h" | ||
55 | #include "statuscommand.h" | 56 | #include "statuscommand.h" | ||
57 | #include "purgelistcommand.h" | ||||
56 | 58 | | |||
57 | using namespace Baloo; | 59 | using namespace Baloo; | ||
58 | 60 | | |||
59 | void start() | 61 | void start() | ||
60 | { | 62 | { | ||
61 | const QString exe = QStandardPaths::findExecutable(QStringLiteral("baloo_file")); | 63 | const QString exe = QStandardPaths::findExecutable(QStringLiteral("baloo_file")); | ||
62 | QProcess::startDetached(exe); | 64 | QProcess::startDetached(exe); | ||
63 | } | 65 | } | ||
Show All 19 Lines | 68 | { | |||
83 | parser.addPositionalArgument(QStringLiteral("suspend"), i18n("Suspend the file indexer")); | 85 | parser.addPositionalArgument(QStringLiteral("suspend"), i18n("Suspend the file indexer")); | ||
84 | parser.addPositionalArgument(QStringLiteral("resume"), i18n("Resume the file indexer")); | 86 | parser.addPositionalArgument(QStringLiteral("resume"), i18n("Resume the file indexer")); | ||
85 | parser.addPositionalArgument(QStringLiteral("check"), i18n("Check for any unindexed files and index them")); | 87 | parser.addPositionalArgument(QStringLiteral("check"), i18n("Check for any unindexed files and index them")); | ||
86 | parser.addPositionalArgument(QStringLiteral("index"), i18n("Index the specified files")); | 88 | parser.addPositionalArgument(QStringLiteral("index"), i18n("Index the specified files")); | ||
87 | parser.addPositionalArgument(QStringLiteral("clear"), i18n("Forget the specified files")); | 89 | parser.addPositionalArgument(QStringLiteral("clear"), i18n("Forget the specified files")); | ||
88 | parser.addPositionalArgument(QStringLiteral("config"), i18n("Modify the Baloo configuration")); | 90 | parser.addPositionalArgument(QStringLiteral("config"), i18n("Modify the Baloo configuration")); | ||
89 | parser.addPositionalArgument(QStringLiteral("monitor"), i18n("Monitor the file indexer")); | 91 | parser.addPositionalArgument(QStringLiteral("monitor"), i18n("Monitor the file indexer")); | ||
90 | parser.addPositionalArgument(QStringLiteral("indexSize"), i18n("Display the disk space used by index")); | 92 | parser.addPositionalArgument(QStringLiteral("indexSize"), i18n("Display the disk space used by index")); | ||
93 | parser.addPositionalArgument(QStringLiteral("list"), i18n("List database contents")); | ||||
94 | | ||||
95 | parser.addOption(QCommandLineOption( | ||||
96 | QStringList{QStringLiteral("d"), QStringLiteral("device-id")}, | ||||
97 | i18n("Restrict to device id.\nOnly applies to \"%1\"", QStringLiteral("balooctl list")) | ||||
98 | , i18n("deviceId") | ||||
99 | , 0) | ||||
100 | ); | ||||
101 | | ||||
102 | parser.addOption(QCommandLineOption( | ||||
103 | QStringList{QStringLiteral("s"), QStringLiteral("simulate-purge")}, | ||||
104 | i18n("Simulate purge command.\nOnly applies to \"%1\"", QStringLiteral("balooctl list")) | ||||
105 | )); | ||||
106 | | ||||
91 | parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("f") << QStringLiteral("format"), | 107 | parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("f") << QStringLiteral("format"), | ||
92 | i18n("Output format <%1|%2|%3>.\nOnly applies to \"%4\"", | 108 | i18n("Output format <%1|%2|%3>.\nOnly applies to \"%4\"", | ||
93 | QStringLiteral("json"), | 109 | QStringLiteral("json"), | ||
94 | QStringLiteral("simple"), | 110 | QStringLiteral("simple"), | ||
95 | QStringLiteral("multiline (default)"), | 111 | QStringLiteral("multiline (default)"), | ||
96 | QStringLiteral("balooctl status <file>") | 112 | QStringLiteral("balooctl status <file>") | ||
97 | ) | 113 | ) | ||
98 | , i18n("format") | 114 | , i18n("format") | ||
Show All 20 Lines | 134 | org::kde::baloo::scheduler schedulerinterface(QStringLiteral("org.kde.baloo"), | |||
119 | QStringLiteral("/scheduler"), | 135 | QStringLiteral("/scheduler"), | ||
120 | QDBusConnection::sessionBus()); | 136 | QDBusConnection::sessionBus()); | ||
121 | 137 | | |||
122 | if (command == QStringLiteral("config")) { | 138 | if (command == QStringLiteral("config")) { | ||
123 | ConfigCommand command; | 139 | ConfigCommand command; | ||
124 | return command.exec(parser); | 140 | return command.exec(parser); | ||
125 | } | 141 | } | ||
126 | 142 | | |||
143 | if (command == QStringLiteral("list")) { | ||||
144 | PurgeListCommand command; | ||||
145 | return command.exec(parser); | ||||
146 | } | ||||
147 | | ||||
127 | if (command == QLatin1String("status")) { | 148 | if (command == QLatin1String("status")) { | ||
128 | StatusCommand command; | 149 | StatusCommand command; | ||
129 | return command.exec(parser); | 150 | return command.exec(parser); | ||
130 | } | 151 | } | ||
131 | 152 | | |||
132 | if (command == QLatin1String("enable") || command == QLatin1String("disable")) { | 153 | if (command == QLatin1String("enable") || command == QLatin1String("disable")) { | ||
133 | bool isEnabled = false; | 154 | bool isEnabled = false; | ||
134 | if (command == QLatin1String("enable")) { | 155 | if (command == QLatin1String("enable")) { | ||
▲ Show 20 Lines • Show All 177 Lines • ▼ Show 20 Line(s) | 295 | if (command == QStringLiteral("indexSize")) { | |||
312 | prFunc(QStringLiteral("DocData"), size.docData, ts); | 333 | prFunc(QStringLiteral("DocData"), size.docData, ts); | ||
313 | prFunc(QStringLiteral("ContentIndexingDB"), size.contentIndexingIds, ts); | 334 | prFunc(QStringLiteral("ContentIndexingDB"), size.contentIndexingIds, ts); | ||
314 | prFunc(QStringLiteral("FailedIdsDB"), size.failedIds, ts); | 335 | prFunc(QStringLiteral("FailedIdsDB"), size.failedIds, ts); | ||
315 | prFunc(QStringLiteral("MTimeDB"), size.mtimeDb, ts); | 336 | prFunc(QStringLiteral("MTimeDB"), size.mtimeDb, ts); | ||
316 | 337 | | |||
317 | return 0; | 338 | return 0; | ||
318 | } | 339 | } | ||
319 | 340 | | |||
341 | | ||||
320 | if (command == QStringLiteral("monitor")) { | 342 | if (command == QStringLiteral("monitor")) { | ||
321 | MonitorCommand mon; | 343 | MonitorCommand mon; | ||
322 | return mon.exec(parser); | 344 | return mon.exec(parser); | ||
323 | } | 345 | } | ||
324 | 346 | | |||
325 | /* | 347 | /* | ||
326 | TODO: Make separate executable | 348 | TODO: Make separate executable | ||
327 | if (command == QStringLiteral("checkDb")) { | 349 | if (command == QStringLiteral("checkDb")) { | ||
Show All 18 Lines |