Changeset View
Changeset View
Standalone View
Standalone View
src/util/externalcommand.cpp
Show First 20 Lines • Show All 181 Lines • ▼ Show 20 Line(s) | 180 | if (!QDBusConnection::systemBus().isConnected()) { | |||
---|---|---|---|---|---|
182 | return false; | 182 | return false; | ||
183 | } | 183 | } | ||
184 | 184 | | |||
185 | // TODO KF6:Use new signal-slot syntax | 185 | // TODO KF6:Use new signal-slot syntax | ||
186 | connect(m_job, SIGNAL(percent(KJob*, unsigned long)), this, SLOT(emitProgress(KJob*, unsigned long))); | 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); | 187 | connect(m_job, &KAuth::ExecuteJob::newData, this, &ExternalCommand::emitReport); | ||
188 | 188 | | |||
189 | auto *interface = new org::kde::kpmcore::externalcommand(QStringLiteral("org.kde.kpmcore.externalcommand"), | 189 | auto *interface = new org::kde::kpmcore::externalcommand(QStringLiteral("org.kde.kpmcore.externalcommand"), | ||
190 | QStringLiteral("/Helper"), QDBusConnection::systemBus(), this); | 190 | QStringLiteral("/Helper"), QDBusConnection::systemBus(), this); | ||
shubham: these connect gives error and correctly so because of m_authJob. Any suggestion how to tackle? | |||||
Well, report progress used KAuth, Now progress will have to be sent via DBus message. So ExternalCommandHelper class will act as DBus client and send messages to ExternalCommand class. Comment it out for now. It will obviously make kpmcore not fully functional until it is reimplemnted, but I think it might still work (just no progress reporting). stikonas: Well, report progress used KAuth, Now progress will have to be sent via DBus message. So… | |||||
progress() and reportProgress() signals have been reimplemented in the qdbus patch. We are now NOT using KAuth's HelperSupport::reportProgress() function which internally used to emit the signal. shubham: progress() and reportProgress() signals have been reimplemented in the qdbus patch. We are now… | |||||
191 | interface->setTimeout(10 * 24 * 3600 * 1000); // 10 days | 191 | interface->setTimeout(10 * 24 * 3600 * 1000); // 10 days | ||
192 | 192 | | |||
193 | QDBusPendingCall pcall = interface->copyblocks(source.path(), source.firstByte(), source.length(), | 193 | QDBusPendingCall pcall = interface->copyblocks(source.path(), source.firstByte(), source.length(), | ||
194 | target.path(), target.firstByte(), blockSize); | 194 | target.path(), target.firstByte(), blockSize); | ||
195 | 195 | | |||
196 | QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall, this); | 196 | QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall, this); | ||
197 | QEventLoop loop; | 197 | QEventLoop loop; | ||
198 | 198 | | |||
▲ Show 20 Lines • Show All 174 Lines • ▼ Show 20 Line(s) | 350 | { | |||
373 | // Wait until ExternalCommand Helper is ready (helper sends newData signal just before it enters event loop) | 373 | // Wait until ExternalCommand Helper is ready (helper sends newData signal just before it enters event loop) | ||
374 | QEventLoop loop; | 374 | QEventLoop loop; | ||
375 | auto exitLoop = [&] () { loop.exit(); }; | 375 | auto exitLoop = [&] () { loop.exit(); }; | ||
376 | auto conn = QObject::connect(m_job, &KAuth::ExecuteJob::newData, exitLoop); | 376 | auto conn = QObject::connect(m_job, &KAuth::ExecuteJob::newData, exitLoop); | ||
377 | QObject::connect(m_job, &KJob::finished, [=] () { if(m_job->error()) exitLoop(); } ); | 377 | QObject::connect(m_job, &KJob::finished, [=] () { if(m_job->error()) exitLoop(); } ); | ||
378 | loop.exec(); | 378 | loop.exec(); | ||
379 | QObject::disconnect(conn); | 379 | QObject::disconnect(conn); | ||
380 | 380 | | |||
381 | | ||||
382 | /* | ||||
383 | * Going to use executeAction() and stopAction() soon | ||||
stikonas: spelling, `executeAction()` | |||||
384 | * instead of using KAuth::Action | ||||
385 | */ | ||||
386 | | ||||
381 | helperStarted = true; | 387 | helperStarted = true; | ||
382 | return true; | 388 | return true; | ||
383 | } | 389 | } | ||
384 | 390 | | |||
385 | void ExternalCommand::stopHelper() | 391 | void ExternalCommand::stopHelper() | ||
386 | { | 392 | { | ||
387 | auto *interface = new org::kde::kpmcore::externalcommand(QStringLiteral("org.kde.kpmcore.externalcommand"), | 393 | auto *interface = new org::kde::kpmcore::externalcommand(QStringLiteral("org.kde.kpmcore.externalcommand"), | ||
388 | QStringLiteral("/Helper"), QDBusConnection::systemBus()); | 394 | QStringLiteral("/Helper"), QDBusConnection::systemBus()); | ||
389 | interface->exit(); | 395 | interface->exit(); | ||
390 | 396 | | |||
391 | } | 397 | } | ||
392 | 398 | | |||
399 | void ExternalCommand::executeAction(const QString &action, const QString &helperID, const QVariantMap &arguments, int timeout/*= -1*/) | ||||
400 | { | ||||
401 | // Use PolkitQt1 backend to execute the action | ||||
402 | QTimer::singleShot(timeout, this, &ExternalCommand::quit); | ||||
403 | } | ||||
404 | | ||||
405 | void ExternalCommand::stopAction(const QString &action, const QString &helperID) | ||||
406 | { | ||||
407 | // Use PolkitQt1 backend to revoke the action | ||||
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 | } |
these connect gives error and correctly so because of m_authJob. Any suggestion how to tackle? Ditto at line 377