MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / ensureApiServerForLaunch

Method ensureApiServerForLaunch

app/src/Misc/ExtensionManager.cpp:1369–1408  ·  view source on GitHub ↗

* @brief Verifies gRPC build support and prompts the user to enable the API server. */

Source from the content-addressed store, hash-verified

1367 * @brief Verifies gRPC build support and prompts the user to enable the API server.
1368 */
1369bool Misc::ExtensionManager::ensureApiServerForLaunch(const QString& id, bool usesGrpc)
1370{
1371#ifndef ENABLE_GRPC
1372 if (usesGrpc) {
1373 m_pluginOutput[id] += QStringLiteral(
1374 "[Error] Plugin requires gRPC but this build does not include gRPC support.\n");
1375 Q_EMIT pluginOutputChanged(id);
1376 Misc::Utilities::showMessageBox(
1377 tr("Plugin Error"),
1378 tr("Plugin \"%1\" requires gRPC but this build does not include gRPC support.").arg(id),
1379 QMessageBox::Critical);
1380 return false;
1381 }
1382#endif
1383
1384 if (API::Server::instance().enabled())
1385 return true;
1386
1387 const auto msg = usesGrpc ? tr("This plugin uses gRPC for high-performance data streaming. "
1388 "The API server needs to be enabled.\n\n"
1389 "Would you like to enable it now?")
1390 : tr("Plugins need the API server to communicate with Serial Studio. "
1391 "Would you like to enable it now?");
1392
1393 const auto result = Misc::Utilities::showMessageBox(tr("API Server Required"),
1394 msg,
1395 QMessageBox::Question,
1396 QString(),
1397 QMessageBox::Yes | QMessageBox::No,
1398 QMessageBox::Yes);
1399
1400 if (result == QMessageBox::Yes) {
1401 API::Server::instance().setEnabled(true);
1402 return true;
1403 }
1404
1405 m_pluginOutput[id] += QStringLiteral("[Cancelled] API Server not enabled.\n");
1406 Q_EMIT pluginOutputChanged(id);
1407 return false;
1408}
1409
1410/**
1411 * @brief Resolves the absolute entry-point path and validates it stays within the plugin dir.

Callers

nothing calls this directly

Calls 2

enabledMethod · 0.45
setEnabledMethod · 0.45

Tested by

no test coverage detected