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

Method deleteSession

app/src/API/Handlers/SessionsHandler.cpp:432–453  ·  view source on GitHub ↗

* @brief Delete a stored session by id. */

Source from the content-addressed store, hash-verified

430 * @brief Delete a stored session by id.
431 */
432API::CommandResponse API::Handlers::SessionsHandler::deleteSession(const QString& id,
433 const QJsonObject& params)
434{
435 if (!params.contains(QStringLiteral("sessionId")))
436 return CommandResponse::makeError(
437 id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: sessionId"));
438
439 const int sessionId = params.value(QStringLiteral("sessionId")).toInt();
440 auto& db = Sessions::DatabaseManager::instance();
441 if (!db.isOpen())
442 return CommandResponse::makeError(
443 id,
444 ErrorCode::ExecutionError,
445 QStringLiteral("No database open. Call sessions.openDatabase first."));
446
447 db.confirmDeleteSession(sessionId);
448
449 QJsonObject result;
450 result[QStringLiteral("sessionId")] = sessionId;
451 result[QStringLiteral("deleting")] = true;
452 return CommandResponse::makeSuccess(id, result);
453}
454
455/**
456 * @brief Set the free-form notes on a stored session.

Callers

nothing calls this directly

Calls 4

confirmDeleteSessionMethod · 0.80
containsMethod · 0.45
valueMethod · 0.45
isOpenMethod · 0.45

Tested by

no test coverage detected