| 373 | } |
| 374 | |
| 375 | void MOApplication::externalMessage(const QString& message) |
| 376 | { |
| 377 | log::debug("received external message '{}'", message); |
| 378 | |
| 379 | MOShortcut moshortcut(message); |
| 380 | |
| 381 | if (moshortcut.isValid()) { |
| 382 | if (moshortcut.hasExecutable()) { |
| 383 | try { |
| 384 | m_core->processRunner() |
| 385 | .setFromShortcut(moshortcut) |
| 386 | .setWaitForCompletion(ProcessRunner::TriggerRefresh) |
| 387 | .run(); |
| 388 | } catch (std::exception&) { |
| 389 | // user was already warned |
| 390 | } |
| 391 | } |
| 392 | } else if (isNxmLink(message)) { |
| 393 | MessageDialog::showMessage(tr("Download started"), qApp->activeWindow(), false); |
| 394 | m_core->downloadRequestedNXM(message); |
| 395 | } else { |
| 396 | cl::CommandLine cl; |
| 397 | |
| 398 | if (auto r = cl.process(message.toStdWString())) { |
| 399 | log::debug("while processing external message, command line wants to " |
| 400 | "exit; ignoring"); |
| 401 | |
| 402 | return; |
| 403 | } |
| 404 | |
| 405 | if (auto i = cl.instance()) { |
| 406 | const auto ci = InstanceManager::singleton().currentInstance(); |
| 407 | |
| 408 | if (*i != ci->displayName()) { |
| 409 | reportError( |
| 410 | tr("This shortcut or command line is for instance '%1', but the current " |
| 411 | "instance is '%2'.") |
| 412 | .arg(*i) |
| 413 | .arg(ci->displayName())); |
| 414 | |
| 415 | return; |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | if (auto p = cl.profile()) { |
| 420 | if (*p != m_core->profileName()) { |
| 421 | reportError( |
| 422 | tr("This shortcut or command line is for profile '%1', but the current " |
| 423 | "profile is '%2'.") |
| 424 | .arg(*p) |
| 425 | .arg(m_core->profileName())); |
| 426 | |
| 427 | return; |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | cl.runPostOrganizer(*m_core); |
| 432 | } |
nothing calls this directly
no test coverage detected