Changeset View
Changeset View
Standalone View
Standalone View
src/util/externalcommand.cpp
Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Line(s) | |||||
114 | */ | 114 | */ | ||
115 | 115 | | |||
116 | /** Executes the external command. | 116 | /** Executes the external command. | ||
117 | @param timeout timeout to wait for the process to start | 117 | @param timeout timeout to wait for the process to start | ||
118 | @return true on success | 118 | @return true on success | ||
119 | */ | 119 | */ | ||
120 | bool ExternalCommand::start(int timeout) | 120 | bool ExternalCommand::start(int timeout) | ||
121 | { | 121 | { | ||
122 | Q_UNUSED(timeout) | | |||
123 | | ||||
124 | if (command().isEmpty()) | 122 | if (command().isEmpty()) | ||
125 | return false; | 123 | return false; | ||
126 | 124 | | |||
127 | if (!QDBusConnection::systemBus().isConnected()) { | 125 | if (!QDBusConnection::systemBus().isConnected()) { | ||
128 | qWarning() << QDBusConnection::systemBus().lastError().message(); | 126 | qWarning() << QDBusConnection::systemBus().lastError().message(); | ||
127 | QTimer::singleShot(timeout, this, &ExternalCommand::quit); | ||||
stikonas: &ExternalCommand::quit | |||||
129 | return false; | 128 | return false; | ||
130 | } | 129 | } | ||
131 | 130 | | |||
132 | if (report()) | 131 | if (report()) | ||
133 | report()->setCommand(xi18nc("@info:status", "Command: %1 %2", command(), args().join(QStringLiteral(" ")))); | 132 | report()->setCommand(xi18nc("@info:status", "Command: %1 %2", command(), args().join(QStringLiteral(" ")))); | ||
134 | 133 | | |||
135 | if ( qEnvironmentVariableIsSet( "KPMCORE_DEBUG" )) | 134 | if ( qEnvironmentVariableIsSet( "KPMCORE_DEBUG" )) | ||
136 | qDebug() << xi18nc("@info:status", "Command: %1 %2", command(), args().join(QStringLiteral(" "))); | 135 | qDebug() << xi18nc("@info:status", "Command: %1 %2", command(), args().join(QStringLiteral(" "))); | ||
Show All 26 Lines | 158 | else { | |||
163 | setExitCode(reply.value()[QStringLiteral("exitCode")].toInt()); | 162 | setExitCode(reply.value()[QStringLiteral("exitCode")].toInt()); | ||
164 | rval = reply.value()[QStringLiteral("success")].toBool(); | 163 | rval = reply.value()[QStringLiteral("success")].toBool(); | ||
165 | } | 164 | } | ||
166 | }; | 165 | }; | ||
167 | 166 | | |||
168 | connect(watcher, &QDBusPendingCallWatcher::finished, exitLoop); | 167 | connect(watcher, &QDBusPendingCallWatcher::finished, exitLoop); | ||
169 | loop.exec(); | 168 | loop.exec(); | ||
170 | 169 | | |||
170 | QTimer::singleShot(timeout, this, &ExternalCommand::quit); | ||||
171 | | ||||
171 | return rval; | 172 | return rval; | ||
172 | } | 173 | } | ||
173 | 174 | | |||
174 | bool ExternalCommand::copyBlocks(const CopySource& source, CopyTarget& target) | 175 | bool ExternalCommand::copyBlocks(const CopySource& source, CopyTarget& target) | ||
175 | { | 176 | { | ||
176 | bool rval = true; | 177 | bool rval = true; | ||
177 | 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 | ||
178 | 179 | | |||
▲ Show 20 Lines • Show All 155 Lines • ▼ Show 20 Line(s) | 334 | { | |||
334 | return d->m_Report; | 335 | return d->m_Report; | ||
335 | } | 336 | } | ||
336 | 337 | | |||
337 | void ExternalCommand::setExitCode(int i) | 338 | void ExternalCommand::setExitCode(int i) | ||
338 | { | 339 | { | ||
339 | d->m_ExitCode = i; | 340 | d->m_ExitCode = i; | ||
340 | } | 341 | } | ||
341 | 342 | | |||
343 | /**< Dummy function for QTimer when needed. */ | ||||
344 | void ExternalCommand::quit() | ||||
345 | { | ||||
346 | | ||||
347 | } | ||||
348 | | ||||
342 | bool ExternalCommand::startHelper() | 349 | bool ExternalCommand::startHelper() | ||
343 | { | 350 | { | ||
344 | if (!QDBusConnection::systemBus().isConnected()) { | 351 | if (!QDBusConnection::systemBus().isConnected()) { | ||
345 | qWarning() << QDBusConnection::systemBus().lastError().message(); | 352 | qWarning() << QDBusConnection::systemBus().lastError().message(); | ||
346 | return false; | 353 | return false; | ||
347 | } | 354 | } | ||
348 | 355 | | |||
349 | QDBusInterface iface(QStringLiteral("org.kde.kpmcore.helperinterface"), QStringLiteral("/Helper"), QStringLiteral("org.kde.kpmcore.externalcommand"), QDBusConnection::systemBus()); | 356 | QDBusInterface iface(QStringLiteral("org.kde.kpmcore.helperinterface"), QStringLiteral("/Helper"), QStringLiteral("org.kde.kpmcore.externalcommand"), QDBusConnection::systemBus()); | ||
▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines |
&ExternalCommand::quit