* @brief Set the driver mode. */
| 98 | * @brief Set the driver mode. |
| 99 | */ |
| 100 | API::CommandResponse API::Handlers::ProcessHandler::setMode(const QString& id, |
| 101 | const QJsonObject& params) |
| 102 | { |
| 103 | if (!params.contains(QStringLiteral("mode"))) { |
| 104 | return CommandResponse::makeError( |
| 105 | id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: mode")); |
| 106 | } |
| 107 | |
| 108 | const int mode = params.value(QStringLiteral("mode")).toInt(); |
| 109 | if (mode < 0 || mode > 1) { |
| 110 | return CommandResponse::makeError( |
| 111 | id, |
| 112 | ErrorCode::InvalidParam, |
| 113 | QStringLiteral("Invalid mode: %1. Valid values: 0=Launch, 1=NamedPipe").arg(mode)); |
| 114 | } |
| 115 | |
| 116 | IO::ConnectionManager::instance().process()->setMode(mode); |
| 117 | |
| 118 | QJsonObject result; |
| 119 | result[QStringLiteral("mode")] = mode; |
| 120 | return CommandResponse::makeSuccess(id, result); |
| 121 | } |
| 122 | |
| 123 | /** |
| 124 | * @brief Set the executable path for Launch mode. |
no test coverage detected