Changeset View
Changeset View
Standalone View
Standalone View
src/util/externalcommand.cpp
1 | /************************************************************************* | 1 | /************************************************************************* | ||
---|---|---|---|---|---|
2 | * Copyright (C) 2008 by Volker Lanz <vl@fidra.de> * | 2 | * Copyright (C) 2008 by Volker Lanz <vl@fidra.de> * | ||
3 | * Copyright (C) 2016-2018 by Andrius Štikonas <andrius@stikonas.eu> * | 3 | * Copyright (C) 2016-2018 by Andrius Štikonas <andrius@stikonas.eu> * | ||
4 | * Copyright (C) 2019 by Shubham <aryan100jangid@gmail.com> * | ||||
4 | * * | 5 | * * | ||
5 | * This program is free software; you can redistribute it and/or * | 6 | * This program is free software; you can redistribute it and/or * | ||
6 | * modify it under the terms of the GNU General Public License as * | 7 | * modify it under the terms of the GNU General Public License as * | ||
7 | * published by the Free Software Foundation; either version 3 of * | 8 | * published by the Free Software Foundation; either version 3 of * | ||
8 | * the License, or (at your option) any later version. * | 9 | * the License, or (at your option) any later version. * | ||
9 | * * | 10 | * * | ||
10 | * This program is distributed in the hope that it will be useful, * | 11 | * This program is distributed in the hope that it will be useful, * | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
13 | * GNU General Public License for more details. * | 14 | * GNU General Public License for more details. * | ||
14 | * * | 15 | * * | ||
15 | * You should have received a copy of the GNU General Public License * | 16 | * You should have received a copy of the GNU General Public License * | ||
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>.* | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>.* | ||
17 | *************************************************************************/ | 18 | *************************************************************************/ | ||
18 | 19 | | |||
19 | #include "backend/corebackendmanager.h" | 20 | #include "backend/corebackendmanager.h" | ||
20 | #include "core/device.h" | 21 | #include "core/device.h" | ||
21 | #include "core/copysource.h" | 22 | #include "core/copysource.h" | ||
22 | #include "core/copytarget.h" | 23 | #include "core/copytarget.h" | ||
23 | #include "core/copytargetbytearray.h" | 24 | #include "core/copytargetbytearray.h" | ||
24 | #include "core/copysourcedevice.h" | 25 | #include "core/copysourcedevice.h" | ||
25 | #include "core/copytargetdevice.h" | 26 | #include "core/copytargetdevice.h" | ||
26 | #include "util/globallog.h" | 27 | #include "util/globallog.h" | ||
27 | #include "util/externalcommand.h" | 28 | #include "util/externalcommand.h" | ||
29 | #include "util/externalcommand_polkitbackend.h" | ||||
28 | #include "util/report.h" | 30 | #include "util/report.h" | ||
29 | 31 | | |||
30 | #include "externalcommandhelper_interface.h" | 32 | #include "externalcommandhelper_interface.h" | ||
31 | 33 | | |||
32 | #include <QCryptographicHash> | 34 | #include <QtDBus> | ||
33 | #include <QDBusConnection> | | |||
34 | #include <QDBusInterface> | | |||
35 | #include <QDBusReply> | | |||
36 | #include <QEventLoop> | 35 | #include <QEventLoop> | ||
37 | #include <QtGlobal> | | |||
38 | #include <QStandardPaths> | 36 | #include <QStandardPaths> | ||
39 | #include <QString> | 37 | #include <QString> | ||
40 | #include <QStringList> | 38 | #include <QStringList> | ||
41 | #include <QTimer> | | |||
42 | #include <QThread> | 39 | #include <QThread> | ||
40 | #include <QTimer> | ||||
43 | #include <QVariant> | 41 | #include <QVariant> | ||
44 | 42 | | |||
45 | #include <KAuth> | | |||
46 | #include <KJob> | 43 | #include <KJob> | ||
47 | #include <KLocalizedString> | 44 | #include <KLocalizedString> | ||
48 | 45 | | |||
46 | #include <PolkitQt1/Authority> | ||||
47 | | ||||
49 | struct ExternalCommandPrivate | 48 | struct ExternalCommandPrivate | ||
50 | { | 49 | { | ||
51 | Report *m_Report; | 50 | Report *m_Report; | ||
52 | QString m_Command; | 51 | QString m_Command; | ||
53 | QStringList m_Args; | 52 | QStringList m_Args; | ||
54 | int m_ExitCode; | 53 | int m_ExitCode; | ||
55 | QByteArray m_Output; | 54 | QByteArray m_Output; | ||
56 | QByteArray m_Input; | 55 | QByteArray m_Input; | ||
57 | DBusThread *m_thread; | 56 | DBusThread *m_thread; | ||
58 | QProcess::ProcessChannelMode processChannelMode; | 57 | QProcess::ProcessChannelMode processChannelMode; | ||
59 | }; | 58 | }; | ||
60 | 59 | | |||
61 | KAuth::ExecuteJob* ExternalCommand::m_job; | 60 | Auth::PolkitQt1Backend* ExternalCommand::m_authJob; | ||
62 | bool ExternalCommand::helperStarted = false; | 61 | bool ExternalCommand::helperStarted = false; | ||
63 | QWidget* ExternalCommand::parent; | 62 | QWidget* ExternalCommand::parent; | ||
64 | 63 | | |||
65 | | ||||
66 | /** Creates a new ExternalCommand instance without Report. | 64 | /** Creates a new ExternalCommand instance without Report. | ||
67 | @param cmd the command to run | 65 | @param cmd the command to run | ||
68 | @param args the arguments to pass to the command | 66 | @param args the arguments to pass to the command | ||
69 | */ | 67 | */ | ||
70 | ExternalCommand::ExternalCommand(const QString& cmd, const QStringList& args, const QProcess::ProcessChannelMode processChannelMode) : | 68 | ExternalCommand::ExternalCommand(const QString& cmd, const QStringList& args, const QProcess::ProcessChannelMode processChannelMode) : | ||
71 | d(std::make_unique<ExternalCommandPrivate>()) | 69 | d(std::make_unique<ExternalCommandPrivate>()) | ||
72 | { | 70 | { | ||
73 | d->m_Report = nullptr; | 71 | d->m_Report = nullptr; | ||
74 | d->m_Command = cmd; | 72 | d->m_Command = cmd; | ||
75 | d->m_Args = args; | 73 | d->m_Args = args; | ||
76 | d->m_ExitCode = -1; | 74 | d->m_ExitCode = -1; | ||
77 | d->m_Output = QByteArray(); | 75 | d->m_Output = QByteArray(); | ||
78 | 76 | | |||
77 | m_authJob = new Auth::PolkitQt1Backend; | ||||
78 | | ||||
79 | if (!helperStarted) | 79 | if (!helperStarted) | ||
80 | if(!startHelper()) | 80 | if(!startHelper()) | ||
81 | Log(Log::Level::error) << xi18nc("@info:status", "Could not obtain administrator privileges."); | 81 | Log(Log::Level::error) << xi18nc("@info:status", "Could not obtain administrator privileges."); | ||
82 | 82 | | |||
83 | d->processChannelMode = processChannelMode; | 83 | d->processChannelMode = processChannelMode; | ||
84 | } | 84 | } | ||
85 | 85 | | |||
86 | /** Creates a new ExternalCommand instance with Report. | 86 | /** Creates a new ExternalCommand instance with Report. | ||
87 | @param report the Report to write output to. | 87 | @param report the Report to write output to. | ||
88 | @param cmd the command to run | 88 | @param cmd the command to run | ||
89 | @param args the arguments to pass to the command | 89 | @param args the arguments to pass to the command | ||
90 | */ | 90 | */ | ||
91 | ExternalCommand::ExternalCommand(Report& report, const QString& cmd, const QStringList& args, const QProcess::ProcessChannelMode processChannelMode) : | 91 | ExternalCommand::ExternalCommand(Report& report, const QString& cmd, const QStringList& args, const QProcess::ProcessChannelMode processChannelMode) : | ||
92 | d(std::make_unique<ExternalCommandPrivate>()) | 92 | d(std::make_unique<ExternalCommandPrivate>()) | ||
93 | { | 93 | { | ||
94 | d->m_Report = report.newChild(); | 94 | d->m_Report = report.newChild(); | ||
95 | d->m_Command = cmd; | 95 | d->m_Command = cmd; | ||
96 | d->m_Args = args; | 96 | d->m_Args = args; | ||
97 | d->m_ExitCode = -1; | 97 | d->m_ExitCode = -1; | ||
98 | d->m_Output = QByteArray(); | 98 | d->m_Output = QByteArray(); | ||
99 | | ||||
100 | d->processChannelMode = processChannelMode; | 99 | d->processChannelMode = processChannelMode; | ||
101 | } | 100 | } | ||
102 | 101 | | |||
103 | ExternalCommand::~ExternalCommand() | 102 | ExternalCommand::~ExternalCommand() | ||
104 | { | 103 | { | ||
105 | 104 | | |||
106 | } | 105 | } | ||
107 | 106 | | |||
Show All 25 Lines | 120 | { | |||
133 | 132 | | |||
134 | if ( qEnvironmentVariableIsSet( "KPMCORE_DEBUG" )) | 133 | if ( qEnvironmentVariableIsSet( "KPMCORE_DEBUG" )) | ||
135 | qDebug() << xi18nc("@info:status", "Command: %1 %2", command(), args().join(QStringLiteral(" "))); | 134 | qDebug() << xi18nc("@info:status", "Command: %1 %2", command(), args().join(QStringLiteral(" "))); | ||
136 | 135 | | |||
137 | QString cmd = QStandardPaths::findExecutable(command()); | 136 | QString cmd = QStandardPaths::findExecutable(command()); | ||
138 | if (cmd.isEmpty()) | 137 | if (cmd.isEmpty()) | ||
139 | cmd = QStandardPaths::findExecutable(command(), { QStringLiteral("/sbin/"), QStringLiteral("/usr/sbin/"), QStringLiteral("/usr/local/sbin/") }); | 138 | cmd = QStandardPaths::findExecutable(command(), { QStringLiteral("/sbin/"), QStringLiteral("/usr/sbin/"), QStringLiteral("/usr/local/sbin/") }); | ||
140 | 139 | | |||
141 | auto *interface = new org::kde::kpmcore::externalcommand(QStringLiteral("org.kde.kpmcore.externalcommand"), | 140 | auto interface = new org::kde::kpmcore::externalcommand(QStringLiteral("org.kde.kpmcore.externalcommand"), | ||
142 | QStringLiteral("/Helper"), QDBusConnection::systemBus(), this); | 141 | QStringLiteral("/Helper"), QDBusConnection::systemBus(), this); | ||
143 | 142 | | |||
144 | interface->setTimeout(10 * 24 * 3600 * 1000); // 10 days | 143 | interface->setTimeout(10 * 24 * 3600 * 1000); // 10 days | ||
145 | 144 | | |||
146 | bool rval = false; | 145 | bool rval = false; | ||
147 | 146 | | |||
148 | QDBusPendingCall pcall = interface->start(cmd, args(), d->m_Input, d->processChannelMode); | 147 | QDBusPendingCall pcall = interface->start(cmd, args(), d->m_Input, d->processChannelMode); | ||
149 | 148 | | |||
Show All 27 Lines | 175 | { | |||
177 | bool rval = true; | 176 | bool rval = true; | ||
178 | const qint64 blockSize = 10 * 1024 * 1024; // number of bytes per block to copy | 177 | const qint64 blockSize = 10 * 1024 * 1024; // number of bytes per block to copy | ||
179 | 178 | | |||
180 | if (!QDBusConnection::systemBus().isConnected()) { | 179 | if (!QDBusConnection::systemBus().isConnected()) { | ||
181 | qWarning() << QDBusConnection::systemBus().lastError().message(); | 180 | qWarning() << QDBusConnection::systemBus().lastError().message(); | ||
182 | return false; | 181 | return false; | ||
183 | } | 182 | } | ||
184 | 183 | | |||
185 | // TODO KF6:Use new signal-slot syntax | 184 | auto interface = new org::kde::kpmcore::externalcommand(QStringLiteral("org.kde.kpmcore.externalcommand"), | ||
186 | connect(m_job, SIGNAL(percent(KJob*, unsigned long)), this, SLOT(emitProgress(KJob*, unsigned long))); | | |||
187 | connect(m_job, &KAuth::ExecuteJob::newData, this, &ExternalCommand::emitReport); | | |||
188 | | ||||
189 | auto *interface = new org::kde::kpmcore::externalcommand(QStringLiteral("org.kde.kpmcore.externalcommand"), | | |||
190 | QStringLiteral("/Helper"), QDBusConnection::systemBus(), this); | 185 | QStringLiteral("/Helper"), QDBusConnection::systemBus(), this); | ||
191 | interface->setTimeout(10 * 24 * 3600 * 1000); // 10 days | 186 | interface->setTimeout(10 * 24 * 3600 * 1000); // 10 days | ||
192 | 187 | | |||
193 | QDBusPendingCall pcall = interface->copyblocks(source.path(), source.firstByte(), source.length(), | 188 | QDBusPendingCall pcall = interface->copyblocks(source.path(), source.firstByte(), source.length(), | ||
194 | target.path(), target.firstByte(), blockSize); | 189 | target.path(), target.firstByte(), blockSize); | ||
195 | 190 | | |||
196 | QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall, this); | 191 | QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall, this); | ||
197 | QEventLoop loop; | 192 | QEventLoop loop; | ||
Show All 27 Lines | 216 | { | |||
225 | 220 | | |||
226 | bool rval = true; | 221 | bool rval = true; | ||
227 | 222 | | |||
228 | if (!QDBusConnection::systemBus().isConnected()) { | 223 | if (!QDBusConnection::systemBus().isConnected()) { | ||
229 | qWarning() << QDBusConnection::systemBus().lastError().message(); | 224 | qWarning() << QDBusConnection::systemBus().lastError().message(); | ||
230 | return false; | 225 | return false; | ||
231 | } | 226 | } | ||
232 | 227 | | |||
233 | auto *interface = new org::kde::kpmcore::externalcommand(QStringLiteral("org.kde.kpmcore.externalcommand"), | 228 | auto interface = new org::kde::kpmcore::externalcommand(QStringLiteral("org.kde.kpmcore.externalcommand"), | ||
234 | QStringLiteral("/Helper"), QDBusConnection::systemBus(), this); | 229 | QStringLiteral("/Helper"), QDBusConnection::systemBus(), this); | ||
235 | interface->setTimeout(10 * 24 * 3600 * 1000); // 10 days | 230 | interface->setTimeout(10 * 24 * 3600 * 1000); // 10 days | ||
236 | 231 | | |||
237 | QDBusPendingCall pcall = interface->writeData(buffer, deviceNode, firstByte); | 232 | QDBusPendingCall pcall = interface->writeData(buffer, deviceNode, firstByte); | ||
238 | 233 | | |||
239 | QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall, this); | 234 | QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall, this); | ||
240 | QEventLoop loop; | 235 | QEventLoop loop; | ||
241 | 236 | | |||
Show All 14 Lines | |||||
256 | return rval; | 251 | return rval; | ||
257 | } | 252 | } | ||
258 | 253 | | |||
259 | 254 | | |||
260 | bool ExternalCommand::write(const QByteArray& input) | 255 | bool ExternalCommand::write(const QByteArray& input) | ||
261 | { | 256 | { | ||
262 | if ( qEnvironmentVariableIsSet( "KPMCORE_DEBUG" )) | 257 | if ( qEnvironmentVariableIsSet( "KPMCORE_DEBUG" )) | ||
263 | qDebug() << "Command input:" << QString::fromLocal8Bit(input); | 258 | qDebug() << "Command input:" << QString::fromLocal8Bit(input); | ||
259 | | ||||
264 | d->m_Input = input; | 260 | d->m_Input = input; | ||
261 | | ||||
265 | return true; | 262 | return true; | ||
266 | } | 263 | } | ||
267 | 264 | | |||
268 | /** Runs the command. | 265 | /** Runs the command. | ||
269 | @param timeout timeout to use for waiting when starting and when waiting for the process to finish | 266 | @param timeout timeout to use for waiting when starting and when waiting for the process to finish | ||
270 | @return true on success | 267 | @return true on success | ||
271 | */ | 268 | */ | ||
272 | bool ExternalCommand::run(int timeout) | 269 | bool ExternalCommand::run(int timeout) | ||
273 | { | 270 | { | ||
274 | return start(timeout) /* && exitStatus() == 0*/; | 271 | return start(timeout) /* && exitStatus() == 0*/; | ||
275 | } | 272 | } | ||
276 | 273 | | |||
277 | void ExternalCommand::onReadOutput() | 274 | //void ExternalCommand::onReadOutput() | ||
278 | { | 275 | //{ | ||
279 | // const QByteArray s = readAllStandardOutput(); | 276 | // const QByteArray s = readAllStandardOutput(); | ||
280 | // | 277 | // | ||
281 | // if(m_Output.length() > 10*1024*1024) { // prevent memory overflow for badly corrupted file systems | 278 | // if(m_Output.length() > 10*1024*1024) { // prevent memory overflow for badly corrupted file systems | ||
282 | // if (report()) | 279 | // if (report()) | ||
283 | // report()->line() << xi18nc("@info:status", "(Command is printing too much output)"); | 280 | // report()->line() << xi18nc("@info:status", "(Command is printing too much output)"); | ||
284 | // return; | 281 | // return; | ||
285 | // } | 282 | // } | ||
286 | // | 283 | // | ||
287 | // m_Output += s; | 284 | // m_Output += s; | ||
288 | // | 285 | // | ||
289 | // if (report()) | 286 | // if (report()) | ||
290 | // *report() << QString::fromLocal8Bit(s); | 287 | // *report() << QString::fromLocal8Bit(s); | ||
291 | } | 288 | //} | ||
292 | 289 | | |||
293 | void ExternalCommand::setCommand(const QString& cmd) | 290 | void ExternalCommand::setCommand(const QString& cmd) | ||
294 | { | 291 | { | ||
295 | d->m_Command = cmd; | 292 | d->m_Command = cmd; | ||
296 | } | 293 | } | ||
297 | 294 | | |||
298 | const QString& ExternalCommand::command() const | 295 | const QString& ExternalCommand::command() const | ||
299 | { | 296 | { | ||
Show All 35 Lines | 331 | { | |||
335 | return d->m_Report; | 332 | return d->m_Report; | ||
336 | } | 333 | } | ||
337 | 334 | | |||
338 | void ExternalCommand::setExitCode(int i) | 335 | void ExternalCommand::setExitCode(int i) | ||
339 | { | 336 | { | ||
340 | d->m_ExitCode = i; | 337 | d->m_ExitCode = i; | ||
341 | } | 338 | } | ||
342 | 339 | | |||
343 | /**< Dummy function for QTimer when needed. */ | 340 | /**< Dummy function for QTimer */ | ||
344 | void ExternalCommand::quit() | 341 | void ExternalCommand::quit() | ||
345 | { | 342 | { | ||
346 | 343 | | |||
347 | } | 344 | } | ||
348 | 345 | | |||
349 | bool ExternalCommand::startHelper() | 346 | bool ExternalCommand::startHelper() | ||
350 | { | 347 | { | ||
351 | if (!QDBusConnection::systemBus().isConnected()) { | 348 | if (!QDBusConnection::systemBus().isConnected()) { | ||
352 | qWarning() << QDBusConnection::systemBus().lastError().message(); | 349 | qWarning() << QDBusConnection::systemBus().lastError().message(); | ||
353 | return false; | 350 | return false; | ||
354 | } | 351 | } | ||
355 | 352 | | |||
356 | QDBusInterface iface(QStringLiteral("org.kde.kpmcore.helperinterface"), QStringLiteral("/Helper"), QStringLiteral("org.kde.kpmcore.externalcommand"), QDBusConnection::systemBus()); | 353 | QDBusInterface iface(QStringLiteral("org.kde.kpmcore.helperinterface"), QStringLiteral("/Helper"), QStringLiteral("org.kde.kpmcore.externalcommand"), QDBusConnection::systemBus()); | ||
354 | | ||||
357 | if (iface.isValid()) { | 355 | if (iface.isValid()) { | ||
358 | exit(0); | 356 | exit(0); | ||
359 | } | 357 | } | ||
360 | 358 | | |||
361 | d->m_thread = new DBusThread; | 359 | d->m_thread = new DBusThread; | ||
362 | d->m_thread->start(); | 360 | d->m_thread->start(); | ||
363 | 361 | | |||
364 | KAuth::Action action = KAuth::Action(QStringLiteral("org.kde.kpmcore.externalcommand.init")); | 362 | /** Authorize using Polkit backend **/ | ||
365 | action.setHelperId(QStringLiteral("org.kde.kpmcore.externalcommand")); | 363 | | ||
366 | action.setTimeout(10 * 24 * 3600 * 1000); // 10 days | 364 | // initialize KDE Polkit daemon | ||
367 | action.setParentWidget(parent); | 365 | m_authJob->initPolkitAgent(QStringLiteral("org.kde.kpmcore.externalcommand.init"), parent); | ||
368 | QVariantMap arguments; | | |||
369 | action.setArguments(arguments); | | |||
370 | m_job = action.execute(); | | |||
371 | m_job->start(); | | |||
372 | 366 | | |||
373 | // Wait until ExternalCommand Helper is ready (helper sends newData signal just before it enters event loop) | 367 | bool isActionAuthorized = m_authJob->authorizeAction(QStringLiteral("org.kde.kpmcore.externalcommand.init"), m_authJob->callerID()); | ||
368 | | ||||
369 | auto authResult = m_authJob->actionStatus(QStringLiteral("org.kde.kpmcore.externalcommand.init"), m_authJob->callerID()); | ||||
370 | | ||||
371 | // Wait until ExternalCommand Helper is ready and sends signal(Connect to newData signal) | ||||
374 | QEventLoop loop; | 372 | QEventLoop loop; | ||
375 | auto exitLoop = [&] () { loop.exit(); }; | 373 | auto exitLoop = [&] () { loop.exit(); }; | ||
376 | auto conn = QObject::connect(m_job, &KAuth::ExecuteJob::newData, exitLoop); | 374 | | ||
377 | QObject::connect(m_job, &KJob::finished, [=] () { if(m_job->error()) exitLoop(); } ); | 375 | ExternalCommand cmd; | ||
376 | auto conn = QObject::connect(&cmd, &ExternalCommand::newData, exitLoop); | ||||
stikonas: Fix this, this will give you infinite recursion. | |||||
377 | | ||||
378 | loop.exec(); | 378 | loop.exec(); | ||
379 | | ||||
379 | QObject::disconnect(conn); | 380 | QObject::disconnect(conn); | ||
380 | 381 | | |||
382 | if (!isActionAuthorized || authResult == PolkitQt1::Authority::No || authResult == PolkitQt1::Authority::Unknown) { | ||||
383 | qDebug() << "Unable to obtain Administrative privileges, the action can not be executed!!"; | ||||
384 | } | ||||
385 | | ||||
381 | helperStarted = true; | 386 | helperStarted = true; | ||
382 | return true; | 387 | return true; | ||
383 | } | 388 | } | ||
384 | 389 | | |||
385 | void ExternalCommand::stopHelper() | 390 | void ExternalCommand::stopHelper() | ||
386 | { | 391 | { | ||
387 | auto *interface = new org::kde::kpmcore::externalcommand(QStringLiteral("org.kde.kpmcore.externalcommand"), | 392 | auto interface = new org::kde::kpmcore::externalcommand(QStringLiteral("org.kde.kpmcore.externalcommand"), | ||
388 | QStringLiteral("/Helper"), QDBusConnection::systemBus()); | 393 | QStringLiteral("/Helper"), QDBusConnection::systemBus()); | ||
389 | interface->exit(); | 394 | interface->exit(); | ||
390 | 395 | | |||
391 | } | 396 | } | ||
392 | 397 | | |||
398 | void ExternalCommand::emitNewData(int percent) | ||||
399 | { | ||||
400 | Q_UNUSED(percent) | ||||
401 | emit newData(); | ||||
402 | } | ||||
403 | | ||||
404 | void ExternalCommand::emitNewData(QString message) | ||||
405 | { | ||||
406 | Q_UNUSED(message) | ||||
407 | emit newData(); | ||||
408 | } | ||||
409 | | ||||
393 | void DBusThread::run() | 410 | void DBusThread::run() | ||
394 | { | 411 | { | ||
395 | if (!QDBusConnection::systemBus().registerService(QStringLiteral("org.kde.kpmcore.applicationinterface")) || | 412 | if (!QDBusConnection::systemBus().registerService(QStringLiteral("org.kde.kpmcore.applicationinterface")) || | ||
396 | !QDBusConnection::systemBus().registerObject(QStringLiteral("/Application"), this, QDBusConnection::ExportAllSlots)) { | 413 | !QDBusConnection::systemBus().registerObject(QStringLiteral("/Application"), this, QDBusConnection::ExportAllSlots)) { | ||
397 | qWarning() << QDBusConnection::systemBus().lastError().message(); | 414 | qWarning() << QDBusConnection::systemBus().lastError().message(); | ||
398 | return; | 415 | return; | ||
399 | } | 416 | } | ||
400 | 417 | | |||
401 | QEventLoop loop; | 418 | QEventLoop loop; | ||
402 | loop.exec(); | 419 | loop.exec(); | ||
403 | } | 420 | } |
Fix this, this will give you infinite recursion.