MCPcopy Create free account
hub / github.com/Martchus/syncthingtray / requestPauseResume

Method requestPauseResume

cli/application.cpp:433–489  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

431}
432
433void Application::requestPauseResume(bool pause)
434{
435 if (!waitForConfig()) {
436 return;
437 }
438 m_connection.applyRawConfig();
439 findRelevantDirsAndDevs(OperationType::PauseResume);
440 m_expectedResponse = 0;
441 if (pause) {
442 connect(&m_connection, &SyncthingConnection::devicePauseTriggered, this, &Application::handleResponse);
443 connect(&m_connection, &SyncthingConnection::directoryPauseTriggered, this, &Application::handleResponse);
444 } else {
445 connect(&m_connection, &SyncthingConnection::deviceResumeTriggered, this, &Application::handleResponse);
446 connect(&m_connection, &SyncthingConnection::directoryResumeTriggered, this, &Application::handleResponse);
447 }
448 if (m_relevantDirs.empty() && m_relevantDevs.empty()) {
449 cerr << Phrases::Error << "No folders or devices specified." << Phrases::End << flush;
450 exit(1);
451 }
452 if (!m_relevantDirs.empty()) {
453 QStringList dirIds;
454 dirIds.reserve(trQuandity(m_relevantDirs.size()));
455 for (const RelevantDir &dir : m_relevantDirs) {
456 dirIds << dir.dirObj->id;
457 }
458 if (pause) {
459 cerr << "Request pausing folders ";
460 } else {
461 cerr << "Request resuming folders ";
462 }
463 cerr << dirIds.join(QStringLiteral(", ")).toLocal8Bit().data() << " ...\n";
464 if (pause ? m_connection.pauseDirectories(dirIds) : m_connection.resumeDirectories(dirIds)) {
465 ++m_expectedResponse;
466 }
467 }
468 if (!m_relevantDevs.empty()) {
469 QStringList devIds;
470 devIds.reserve(trQuandity(m_relevantDirs.size()));
471 for (const SyncthingDev *dev : m_relevantDevs) {
472 devIds << dev->id;
473 }
474 if (pause) {
475 cerr << "Request pausing devices ";
476 } else {
477 cerr << "Request resuming devices ";
478 }
479 cerr << devIds.join(QStringLiteral(", ")).toLocal8Bit().data() << " ...\n";
480 if (pause ? m_connection.pauseDevice(devIds) : m_connection.resumeDevice(devIds)) {
481 ++m_expectedResponse;
482 }
483 }
484 if (!m_expectedResponse) {
485 cerr << Phrases::Warning << "No folders or devices altered." << Phrases::End << flush;
486 exit(0);
487 }
488 cerr << flush;
489}
490

Callers

nothing calls this directly

Calls 8

trQuandityFunction · 0.85
applyRawConfigMethod · 0.80
pauseDirectoriesMethod · 0.80
resumeDirectoriesMethod · 0.80
pauseDeviceMethod · 0.80
resumeDeviceMethod · 0.80
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected