Mercurial > hg > orthanc
changeset 1587:d7e569640d09
New function "GetOrthancConfiguration()" to get the Orthanc configuration
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 26 Aug 2015 12:12:25 +0200 |
parents | e088bc2c3a1a |
children | b5bc87a7212d |
files | Core/Lua/LuaContext.h NEWS OrthancServer/LuaScripting.cpp OrthancServer/LuaScripting.h OrthancServer/OrthancInitialization.cpp OrthancServer/OrthancInitialization.h |
diffstat | 6 files changed, 30 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/Core/Lua/LuaContext.h Wed Aug 26 07:40:18 2015 +0200 +++ b/Core/Lua/LuaContext.h Wed Aug 26 12:12:25 2015 +0200 @@ -53,8 +53,6 @@ std::string log_; HttpClient httpClient_; - static LuaContext& GetLuaContext(lua_State *state); - static int PrintToLog(lua_State *state); static int ParseJson(lua_State *state); static int DumpJson(lua_State *state); @@ -73,8 +71,6 @@ void ExecuteInternal(std::string* output, const std::string& command); - void PushJson(const Json::Value& value); - void GetJson(Json::Value& result, int top); @@ -118,7 +114,11 @@ void SetGlobalVariable(const char* name, void* value); + static LuaContext& GetLuaContext(lua_State *state); + static const void* GetGlobalVariable(lua_State* state, const char* name); + + void PushJson(const Json::Value& value); }; }
--- a/NEWS Wed Aug 26 07:40:18 2015 +0200 +++ b/NEWS Wed Aug 26 12:12:25 2015 +0200 @@ -14,6 +14,7 @@ * More information about the origin request in the "OnStoredInstance()" and "ReceivedInstanceFilter()" callbacks. WARNING: This can result in incompatibilities wrt. previous versions of Orthanc. +* New function "GetOrthancConfiguration()" to get the Orthanc configuration Plugins -------
--- a/OrthancServer/LuaScripting.cpp Wed Aug 26 07:40:18 2015 +0200 +++ b/OrthancServer/LuaScripting.cpp Wed Aug 26 12:12:25 2015 +0200 @@ -200,6 +200,18 @@ } + // Syntax in Lua: GetOrthancConfiguration() + int LuaScripting::GetOrthancConfiguration(lua_State *state) + { + Json::Value configuration; + Configuration::GetConfiguration(configuration); + + LuaContext::GetLuaContext(state).PushJson(configuration); + + return 1; + } + + IServerCommand* LuaScripting::ParseOperation(const std::string& operation, const Json::Value& parameters) { @@ -357,6 +369,7 @@ lua_.RegisterFunction("RestApiPost", RestApiPost); lua_.RegisterFunction("RestApiPut", RestApiPut); lua_.RegisterFunction("RestApiDelete", RestApiDelete); + lua_.RegisterFunction("GetOrthancConfiguration", GetOrthancConfiguration); lua_.Execute(Orthanc::EmbeddedResources::LUA_TOOLBOX); lua_.SetHttpProxy(Configuration::GetGlobalStringParameter("HttpProxy", ""));
--- a/OrthancServer/LuaScripting.h Wed Aug 26 07:40:18 2015 +0200 +++ b/OrthancServer/LuaScripting.h Wed Aug 26 12:12:25 2015 +0200 @@ -51,6 +51,7 @@ static int RestApiPost(lua_State *state); static int RestApiPut(lua_State *state); static int RestApiDelete(lua_State *state); + static int GetOrthancConfiguration(lua_State *state); void ApplyOnStoredInstance(const std::string& instanceId, const Json::Value& simplifiedDicom,
--- a/OrthancServer/OrthancInitialization.cpp Wed Aug 26 07:40:18 2015 +0200 +++ b/OrthancServer/OrthancInitialization.cpp Wed Aug 26 12:12:25 2015 +0200 @@ -896,14 +896,18 @@ } + + void Configuration::GetConfiguration(Json::Value& result) + { + boost::mutex::scoped_lock lock(globalMutex_); + result = configuration_; + } + + void Configuration::FormatConfiguration(std::string& result) { Json::Value config; - - { - boost::mutex::scoped_lock lock(globalMutex_); - config = configuration_; - } + GetConfiguration(config); Json::StyledWriter w; result = w.write(config);
--- a/OrthancServer/OrthancInitialization.h Wed Aug 26 07:40:18 2015 +0200 +++ b/OrthancServer/OrthancInitialization.h Wed Aug 26 12:12:25 2015 +0200 @@ -109,6 +109,8 @@ static IStorageArea* CreateStorageArea(); + static void GetConfiguration(Json::Value& result); + static void FormatConfiguration(std::string& result); }; }