# HG changeset patch # User Sebastien Jodogne # Date 1440583945 -7200 # Node ID d7e569640d09b275f0384f3aa816f03866de0fa5 # Parent e088bc2c3a1a6d52a4057831615b85bd4f6afe98 New function "GetOrthancConfiguration()" to get the Orthanc configuration diff -r e088bc2c3a1a -r d7e569640d09 Core/Lua/LuaContext.h --- 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); }; } diff -r e088bc2c3a1a -r d7e569640d09 NEWS --- 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 ------- diff -r e088bc2c3a1a -r d7e569640d09 OrthancServer/LuaScripting.cpp --- 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", "")); diff -r e088bc2c3a1a -r d7e569640d09 OrthancServer/LuaScripting.h --- 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, diff -r e088bc2c3a1a -r d7e569640d09 OrthancServer/OrthancInitialization.cpp --- 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); diff -r e088bc2c3a1a -r d7e569640d09 OrthancServer/OrthancInitialization.h --- 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); }; }