Changeset View
Changeset View
Standalone View
Standalone View
src/util/externalcommand.cpp
Show First 20 Lines • Show All 177 Lines • ▼ Show 20 Line(s) | 176 | { | |||
---|---|---|---|---|---|
178 | const qint64 blockSize = 10 * 1024 * 1024; // number of bytes per block to copy | 178 | const qint64 blockSize = 10 * 1024 * 1024; // number of bytes per block to copy | ||
179 | 179 | | |||
180 | if (!QDBusConnection::systemBus().isConnected()) { | 180 | if (!QDBusConnection::systemBus().isConnected()) { | ||
181 | qWarning() << QDBusConnection::systemBus().lastError().message(); | 181 | qWarning() << QDBusConnection::systemBus().lastError().message(); | ||
182 | return false; | 182 | return false; | ||
183 | } | 183 | } | ||
184 | 184 | | |||
185 | auto interface = new org::kde::kpmcore::externalcommand(QStringLiteral("org.kde.kpmcore.externalcommand"), | 185 | auto interface = new org::kde::kpmcore::externalcommand(QStringLiteral("org.kde.kpmcore.externalcommand"), | ||
186 | | ||||
187 | | ||||
188 | | ||||
189 | | ||||
190 | QStringLiteral("/Helper"), QDBusConnection::systemBus(), this); | 186 | QStringLiteral("/Helper"), QDBusConnection::systemBus(), this); | ||
191 | interface->setTimeout(10 * 24 * 3600 * 1000); // 10 days | 187 | interface->setTimeout(10 * 24 * 3600 * 1000); // 10 days | ||
192 | 188 | | |||
193 | QDBusPendingCall pcall = interface->copyblocks(source.path(), source.firstByte(), source.length(), | 189 | QDBusPendingCall pcall = interface->copyblocks(source.path(), source.firstByte(), source.length(), | ||
194 | target.path(), target.firstByte(), blockSize); | 190 | target.path(), target.firstByte(), blockSize); | ||
195 | 191 | | |||
196 | QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall, this); | 192 | QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall, this); | ||
197 | QEventLoop loop; | 193 | QEventLoop loop; | ||
▲ Show 20 Lines • Show All 170 Lines • ▼ Show 20 Line(s) | 346 | { | |||
368 | 364 | | |||
369 | // initialize KDE Polkit daemon | 365 | // initialize KDE Polkit daemon | ||
370 | m_authJob->initPolkitAgent(QStringLiteral("org.kde.kpmcore.externalcommand.init"), parent); | 366 | m_authJob->initPolkitAgent(QStringLiteral("org.kde.kpmcore.externalcommand.init"), parent); | ||
371 | 367 | | |||
372 | bool isActionAuthorized = m_authJob->authorizeAction(QStringLiteral("org.kde.kpmcore.externalcommand.init"), m_authJob->callerID()); | 368 | bool isActionAuthorized = m_authJob->authorizeAction(QStringLiteral("org.kde.kpmcore.externalcommand.init"), m_authJob->callerID()); | ||
373 | 369 | | |||
374 | auto authResult = m_authJob->actionStatus(QStringLiteral("org.kde.kpmcore.externalcommand.init"), m_authJob->callerID()); | 370 | auto authResult = m_authJob->actionStatus(QStringLiteral("org.kde.kpmcore.externalcommand.init"), m_authJob->callerID()); | ||
375 | 371 | | |||
376 | | ||||
377 | // Wait until ExternalCommand Helper is ready and sends signal | 372 | // Wait until ExternalCommand Helper is ready and sends signal | ||
378 | QEventLoop loop; | 373 | QEventLoop loop; | ||
379 | auto exitLoop = [&] () { loop.exit(); }; | 374 | auto exitLoop = [&] () { loop.exit(); }; | ||
380 | 375 | | |||
376 | //Connect to newData signal | ||||
381 | 377 | | |||
stikonas: Fix this, this will give you infinite recursion. | |||||
382 | loop.exec(); | 378 | loop.exec(); | ||
383 | 379 | | |||
384 | if (!isActionAuthorized || authResult == PolkitQt1::Authority::No || authResult == PolkitQt1::Authority::Unknown) { | 380 | if (!isActionAuthorized || authResult == PolkitQt1::Authority::No || authResult == PolkitQt1::Authority::Unknown) { | ||
385 | qDebug() << "Unable to obtain Administrative privileges, the action can not be executed!!"; | 381 | qDebug() << "Unable to obtain Administrative privileges, the action can not be executed!!"; | ||
386 | } | 382 | } | ||
387 | 383 | | |||
388 | helperStarted = true; | 384 | helperStarted = true; | ||
389 | return true; | 385 | return true; | ||
390 | } | 386 | } | ||
391 | 387 | | |||
392 | void ExternalCommand::stopHelper() | 388 | void ExternalCommand::stopHelper() | ||
393 | { | 389 | { | ||
394 | auto interface = new org::kde::kpmcore::externalcommand(QStringLiteral("org.kde.kpmcore.externalcommand"), | 390 | auto interface = new org::kde::kpmcore::externalcommand(QStringLiteral("org.kde.kpmcore.externalcommand"), | ||
395 | QStringLiteral("/Helper"), QDBusConnection::systemBus()); | 391 | QStringLiteral("/Helper"), QDBusConnection::systemBus()); | ||
396 | interface->exit(); | 392 | interface->exit(); | ||
397 | 393 | | |||
398 | } | 394 | } | ||
399 | 395 | | |||
396 | void ExternalCommand::emitNewData(int percent) | ||||
397 | { | ||||
398 | emit newData(); | ||||
399 | } | ||||
400 | | ||||
401 | void ExternalCommand::emitNewData(QString& message) | ||||
402 | { | ||||
403 | emit newData(); | ||||
404 | } | ||||
405 | | ||||
400 | void DBusThread::run() | 406 | void DBusThread::run() | ||
401 | { | 407 | { | ||
402 | if (!QDBusConnection::systemBus().registerService(QStringLiteral("org.kde.kpmcore.applicationinterface")) || | 408 | if (!QDBusConnection::systemBus().registerService(QStringLiteral("org.kde.kpmcore.applicationinterface")) || | ||
403 | !QDBusConnection::systemBus().registerObject(QStringLiteral("/Application"), this, QDBusConnection::ExportAllSlots)) { | 409 | !QDBusConnection::systemBus().registerObject(QStringLiteral("/Application"), this, QDBusConnection::ExportAllSlots)) { | ||
404 | qWarning() << QDBusConnection::systemBus().lastError().message(); | 410 | qWarning() << QDBusConnection::systemBus().lastError().message(); | ||
405 | return; | 411 | return; | ||
406 | } | 412 | } | ||
407 | 413 | | |||
408 | QEventLoop loop; | 414 | QEventLoop loop; | ||
409 | loop.exec(); | 415 | loop.exec(); | ||
410 | } | 416 | } |
Fix this, this will give you infinite recursion.