From 42a57b83877c8d898554911282c929cbe5f6c17a Mon Sep 17 00:00:00 2001 From: Nathan F Syfrig Date: Tue, 21 Apr 2026 23:56:54 -0700 Subject: [PATCH 1/2] Add new JSON-RPC API calls, with documentation --- docs/JSON-RPC.md | 34 ++++++++++++++++++++++++++++++++++ src/clientrpc.cpp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/docs/JSON-RPC.md b/docs/JSON-RPC.md index 7cf7a92b3e..5556401a27 100644 --- a/docs/JSON-RPC.md +++ b/docs/JSON-RPC.md @@ -188,6 +188,40 @@ Results: | result.clients | array | The client list. See jamulusclient/clientListReceived for the format. | +### jamulusclient/getCurrentDirectory + +Returns the currently selected directory socket address. + +Parameters: + +| Name | Type | Description | +| --- | --- | --- | +| params | object | No parameters (empty object). | + +Results: + +| Name | Type | Description | +| --- | --- | --- | +| result | string | The socket address of the current directory, usable as params.directory in jamulusclient/pollServerList. | + + +### jamulusclient/getDirectories + +Returns the list of directories in the same order as presented in Jamulus. + +Parameters: + +| Name | Type | Description | +| --- | --- | --- | +| params | object | No parameters (empty object). | + +Results: + +| Name | Type | Description | +| --- | --- | --- | +| result | array | Array of directory socket address strings, usable as params.directory in jamulusclient/pollServerList. | + + ### jamulusclient/getMidiDevices Returns a list of available MIDI input devices. diff --git a/src/clientrpc.cpp b/src/clientrpc.cpp index c2efc59b25..28e632e118 100644 --- a/src/clientrpc.cpp +++ b/src/clientrpc.cpp @@ -183,6 +183,39 @@ CClientRpc::CClientRpc ( CClient* pClient, CClientSettings* pSettings, CRpcServe response["result"] = "ok"; } ); + /// @rpc_method jamulusclient/getDirectories + /// @brief Returns the list of directories in the same order as presented in Jamulus. + /// @param {object} params - No parameters (empty object). + /// @result {array} result - Array of directory socket address strings, usable as params.directory in jamulusclient/pollServerList. + pRpcServer->HandleMethod ( "jamulusclient/getDirectories", [=] ( const QJsonObject& params, QJsonObject& response ) { + QJsonArray arrDirectories; + // built-in directories in UI order + for ( int i = AT_DEFAULT; i < AT_CUSTOM; i++ ) + { + arrDirectories.append ( NetworkUtil::GetDirectoryAddress ( static_cast ( i ), "" ) ); + } + // custom directories — stored newest-first, displayed oldest-first (reverse iteration) + for ( int i = MAX_NUM_SERVER_ADDR_ITEMS - 1; i >= 0; i-- ) + { + if ( !m_pSettings->vstrDirectoryAddress[i].isEmpty() ) + { + arrDirectories.append ( m_pSettings->vstrDirectoryAddress[i] ); + } + } + response["result"] = arrDirectories; + Q_UNUSED ( params ); + } ); + + /// @rpc_method jamulusclient/getCurrentDirectory + /// @brief Returns the currently selected directory socket address. + /// @param {object} params - No parameters (empty object). + /// @result {string} result - The socket address of the current directory, usable as params.directory in jamulusclient/pollServerList. + pRpcServer->HandleMethod ( "jamulusclient/getCurrentDirectory", [=] ( const QJsonObject& params, QJsonObject& response ) { + response["result"] = NetworkUtil::GetDirectoryAddress ( m_pSettings->eDirectoryType, + m_pSettings->vstrDirectoryAddress[m_pSettings->iCustomDirectoryIndex] ); + Q_UNUSED ( params ); + } ); + /// @rpc_method jamulus/getMode /// @brief Returns the current mode, i.e. whether Jamulus is running as a server or client. /// @param {object} params - No parameters (empty object). From 05ce98aa870ad2cd77a3b78b4ed5f9788b4c5156 Mon Sep 17 00:00:00 2001 From: Nathan F Syfrig Date: Fri, 24 Apr 2026 13:06:34 -0700 Subject: [PATCH 2/2] Fix linter issue about split line --- src/clientrpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/clientrpc.cpp b/src/clientrpc.cpp index 28e632e118..c698106325 100644 --- a/src/clientrpc.cpp +++ b/src/clientrpc.cpp @@ -211,8 +211,8 @@ CClientRpc::CClientRpc ( CClient* pClient, CClientSettings* pSettings, CRpcServe /// @param {object} params - No parameters (empty object). /// @result {string} result - The socket address of the current directory, usable as params.directory in jamulusclient/pollServerList. pRpcServer->HandleMethod ( "jamulusclient/getCurrentDirectory", [=] ( const QJsonObject& params, QJsonObject& response ) { - response["result"] = NetworkUtil::GetDirectoryAddress ( m_pSettings->eDirectoryType, - m_pSettings->vstrDirectoryAddress[m_pSettings->iCustomDirectoryIndex] ); + response["result"] = + NetworkUtil::GetDirectoryAddress ( m_pSettings->eDirectoryType, m_pSettings->vstrDirectoryAddress[m_pSettings->iCustomDirectoryIndex] ); Q_UNUSED ( params ); } );