* @brief Returns the full configuration for a source. */
| 447 | * @brief Returns the full configuration for a source. |
| 448 | */ |
| 449 | API::CommandResponse API::Handlers::SourceHandler::sourceGetConfiguration(const QString& id, |
| 450 | const QJsonObject& params) |
| 451 | { |
| 452 | if (!params.contains(Keys::SourceId)) |
| 453 | return CommandResponse::makeError( |
| 454 | id, QStringLiteral("MISSING_PARAM"), QStringLiteral("sourceId is required")); |
| 455 | |
| 456 | const int sourceId = params[Keys::SourceId].toInt(-1); |
| 457 | const auto& sources = DataModel::ProjectModel::instance().sources(); |
| 458 | const int sourceCount = static_cast<int>(sources.size()); |
| 459 | |
| 460 | if (sourceId < 0 || sourceId >= sourceCount) |
| 461 | return CommandResponse::makeError( |
| 462 | id, QStringLiteral("INVALID_PARAM"), QStringLiteral("Invalid sourceId")); |
| 463 | |
| 464 | const auto& src = sources[sourceId]; |
| 465 | QJsonObject obj = DataModel::serialize(src); |
| 466 | return CommandResponse::makeSuccess(id, obj); |
| 467 | } |
| 468 | |
| 469 | /** |
| 470 | * @brief Sets the per-source JavaScript frame parser code. |