# HG changeset patch # User Sebastien Jodogne # Date 1591731073 -7200 # Node ID e3b3af80732d8d6fb83c7f5b9774554a2537607c # Parent 100fbe9707622ad4c352b1e46e691a9d451d1ff0 ServerResources, and moving EmbeddedResourceHttpHandler from Core to OrthancServer diff -r 100fbe970762 -r e3b3af80732d CMakeLists.txt --- a/CMakeLists.txt Tue Jun 09 20:50:20 2020 +0200 +++ b/CMakeLists.txt Tue Jun 09 21:31:13 2020 +0200 @@ -65,14 +65,15 @@ OrthancServer/Database/SQLiteDatabaseWrapper.cpp OrthancServer/DicomInstanceOrigin.cpp OrthancServer/DicomInstanceToStore.cpp + OrthancServer/EmbeddedResourceHttpHandler.cpp OrthancServer/ExportedResource.cpp OrthancServer/LuaScripting.cpp OrthancServer/OrthancConfiguration.cpp OrthancServer/OrthancFindRequestHandler.cpp + OrthancServer/OrthancGetRequestHandler.cpp OrthancServer/OrthancHttpHandler.cpp OrthancServer/OrthancInitialization.cpp OrthancServer/OrthancMoveRequestHandler.cpp - OrthancServer/OrthancGetRequestHandler.cpp OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp OrthancServer/OrthancRestApi/OrthancRestApi.cpp OrthancServer/OrthancRestApi/OrthancRestArchive.cpp @@ -165,6 +166,7 @@ ${ORTHANC_DICOM_SOURCES_INTERNAL} ${ORTHANC_SERVER_SOURCES} ${ORTHANC_UNIT_TESTS_SOURCES} + ${ORTHANC_ROOT}/Core/HttpServer/EmbeddedResourceHttpHandler.cpp Plugins/Samples/ServeFolders/Plugin.cpp Plugins/Samples/ModalityWorklists/Plugin.cpp OrthancServer/main.cpp @@ -196,29 +198,26 @@ if (STANDALONE_BUILD) # We embed all the resources in the binaries for standalone builds add_definitions( - -DORTHANC_HAS_EMBEDDED_RESOURCES=1 -DORTHANC_STANDALONE=1 ) - EmbedResources( - --target=OrthancEmbeddedResources - ${ORTHANC_EMBEDDED_FILES} + + list(APPEND ORTHANC_EMBEDDED_FILES ORTHANC_EXPLORER ${CMAKE_CURRENT_SOURCE_DIR}/OrthancExplorer - ${DCMTK_DICTIONARIES} - ${LIBICU_RESOURCES} ) else() add_definitions( - -DORTHANC_HAS_EMBEDDED_RESOURCES=1 -DORTHANC_PATH=\"${CMAKE_SOURCE_DIR}\" -DORTHANC_STANDALONE=0 ) - EmbedResources( - --target=OrthancEmbeddedResources - ${ORTHANC_EMBEDDED_FILES} - ${LIBICU_RESOURCES} - ) endif() +EmbedResources( + --namespace=Orthanc.ServerResources + --target=ServerResources + ${ORTHANC_EMBEDDED_FILES} + ) + + if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") execute_process( COMMAND diff -r 100fbe970762 -r e3b3af80732d Core/HttpServer/EmbeddedResourceHttpHandler.cpp --- a/Core/HttpServer/EmbeddedResourceHttpHandler.cpp Tue Jun 09 20:50:20 2020 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,99 +0,0 @@ -/** - * Orthanc - A Lightweight, RESTful DICOM Store - * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics - * Department, University Hospital of Liege, Belgium - * Copyright (C) 2017-2020 Osimis S.A., Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * In addition, as a special exception, the copyright holders of this - * program give permission to link the code of its release with the - * OpenSSL project's "OpenSSL" library (or with modified versions of it - * that use the same license as the "OpenSSL" library), and distribute - * the linked executables. You must obey the GNU General Public License - * in all respects for all of the code used other than "OpenSSL". If you - * modify file(s) with this exception, you may extend this exception to - * your version of the file(s), but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. If you delete this exception statement from all source files - * in the program, then also delete it here. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - **/ - - -#include "../PrecompiledHeaders.h" -#include "EmbeddedResourceHttpHandler.h" - -#include "../Logging.h" -#include "../OrthancException.h" -#include "../SystemToolbox.h" -#include "HttpOutput.h" - -#include - - -namespace Orthanc -{ - EmbeddedResourceHttpHandler::EmbeddedResourceHttpHandler( - const std::string& baseUri, - EmbeddedResources::DirectoryResourceId resourceId) - { - Toolbox::SplitUriComponents(baseUri_, baseUri); - resourceId_ = resourceId; - } - - - bool EmbeddedResourceHttpHandler::Handle( - HttpOutput& output, - RequestOrigin /*origin*/, - const char* /*remoteIp*/, - const char* /*username*/, - HttpMethod method, - const UriComponents& uri, - const Arguments& headers, - const GetArguments& arguments, - const void* /*bodyData*/, - size_t /*bodySize*/) - { - if (!Toolbox::IsChildUri(baseUri_, uri)) - { - // This URI is not served by this handler - return false; - } - - if (method != HttpMethod_Get) - { - output.SendMethodNotAllowed("GET"); - return true; - } - - std::string resourcePath = Toolbox::FlattenUri(uri, baseUri_.size()); - MimeType contentType = SystemToolbox::AutodetectMimeType(resourcePath); - - try - { - const void* buffer = EmbeddedResources::GetDirectoryResourceBuffer(resourceId_, resourcePath.c_str()); - size_t size = EmbeddedResources::GetDirectoryResourceSize(resourceId_, resourcePath.c_str()); - - output.SetContentType(contentType); - output.Answer(buffer, size); - } - catch (OrthancException&) - { - LOG(WARNING) << "Unable to find HTTP resource: " << resourcePath; - output.SendStatus(HttpStatus_404_NotFound); - } - - return true; - } -} diff -r 100fbe970762 -r e3b3af80732d Core/HttpServer/EmbeddedResourceHttpHandler.h --- a/Core/HttpServer/EmbeddedResourceHttpHandler.h Tue Jun 09 20:50:20 2020 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -/** - * Orthanc - A Lightweight, RESTful DICOM Store - * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics - * Department, University Hospital of Liege, Belgium - * Copyright (C) 2017-2020 Osimis S.A., Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * In addition, as a special exception, the copyright holders of this - * program give permission to link the code of its release with the - * OpenSSL project's "OpenSSL" library (or with modified versions of it - * that use the same license as the "OpenSSL" library), and distribute - * the linked executables. You must obey the GNU General Public License - * in all respects for all of the code used other than "OpenSSL". If you - * modify file(s) with this exception, you may extend this exception to - * your version of the file(s), but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. If you delete this exception statement from all source files - * in the program, then also delete it here. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - **/ - - -#pragma once - -#include "IHttpHandler.h" - -#include // Autogenerated file -#include - -namespace Orthanc -{ - class EmbeddedResourceHttpHandler : public IHttpHandler - { - private: - UriComponents baseUri_; - EmbeddedResources::DirectoryResourceId resourceId_; - - public: - EmbeddedResourceHttpHandler( - const std::string& baseUri, - EmbeddedResources::DirectoryResourceId resourceId); - - virtual bool CreateChunkedRequestReader(std::unique_ptr& target, - RequestOrigin origin, - const char* remoteIp, - const char* username, - HttpMethod method, - const UriComponents& uri, - const Arguments& headers) - { - return false; - } - - virtual bool Handle(HttpOutput& output, - RequestOrigin origin, - const char* remoteIp, - const char* username, - HttpMethod method, - const UriComponents& uri, - const Arguments& headers, - const GetArguments& arguments, - const void* /*bodyData*/, - size_t /*bodySize*/); - }; -} diff -r 100fbe970762 -r e3b3af80732d Core/Images/FontRegistry.cpp --- a/Core/Images/FontRegistry.cpp Tue Jun 09 20:50:20 2020 +0200 +++ b/Core/Images/FontRegistry.cpp Tue Jun 09 21:31:13 2020 +0200 @@ -67,16 +67,6 @@ #endif -#if ORTHANC_HAS_EMBEDDED_RESOURCES == 1 - void FontRegistry::AddFromResource(EmbeddedResources::FileResourceId resource) - { - std::string content; - EmbeddedResources::GetFileResource(content, resource); - AddFromMemory(content); - } -#endif - - const Font& FontRegistry::GetFont(size_t i) const { if (i >= fonts_.size()) diff -r 100fbe970762 -r e3b3af80732d Core/Images/FontRegistry.h --- a/Core/Images/FontRegistry.h Tue Jun 09 20:50:20 2020 +0200 +++ b/Core/Images/FontRegistry.h Tue Jun 09 21:31:13 2020 +0200 @@ -35,14 +35,6 @@ #include "Font.h" -#if !defined(ORTHANC_HAS_EMBEDDED_RESOURCES) -# error Macro ORTHANC_HAS_EMBEDDED_RESOURCES must be defined -#endif - -#if ORTHANC_HAS_EMBEDDED_RESOURCES == 1 -# include // Autogenerated file -#endif - namespace Orthanc { class ORTHANC_PUBLIC FontRegistry : public boost::noncopyable @@ -61,10 +53,6 @@ void AddFromFile(const std::string& path); #endif -#if ORTHANC_HAS_EMBEDDED_RESOURCES == 1 - void AddFromResource(EmbeddedResources::FileResourceId resource); -#endif - size_t GetSize() const { return fonts_.size(); diff -r 100fbe970762 -r e3b3af80732d Core/Lua/LuaContext.cpp --- a/Core/Lua/LuaContext.cpp Tue Jun 09 20:50:20 2020 +0200 +++ b/Core/Lua/LuaContext.cpp Tue Jun 09 21:31:13 2020 +0200 @@ -612,16 +612,6 @@ } -#if ORTHANC_HAS_EMBEDDED_RESOURCES == 1 - void LuaContext::Execute(EmbeddedResources::FileResourceId resource) - { - std::string command; - EmbeddedResources::GetFileResource(command, resource); - ExecuteInternal(NULL, command); - } -#endif - - bool LuaContext::IsExistingFunction(const char* name) { lua_settop(lua_, 0); diff -r 100fbe970762 -r e3b3af80732d Core/Lua/LuaContext.h --- a/Core/Lua/LuaContext.h Tue Jun 09 20:50:20 2020 +0200 +++ b/Core/Lua/LuaContext.h Tue Jun 09 21:31:13 2020 +0200 @@ -40,10 +40,6 @@ # error The macro ORTHANC_ENABLE_LUA must be defined #endif -#if !defined(ORTHANC_HAS_EMBEDDED_RESOURCES) -# error Macro ORTHANC_HAS_EMBEDDED_RESOURCES must be defined -#endif - #if !defined(ORTHANC_ENABLE_CURL) # error Macro ORTHANC_ENABLE_CURL must be defined #endif @@ -52,10 +48,6 @@ # error The Lua support is disabled, cannot include this file #endif -#if ORTHANC_HAS_EMBEDDED_RESOURCES == 1 -# include // Autogenerated file -#endif - #if ORTHANC_ENABLE_CURL == 1 # include "../HttpClient.h" #endif @@ -127,10 +119,6 @@ void Execute(Json::Value& output, const std::string& command); -#if ORTHANC_HAS_EMBEDDED_RESOURCES == 1 - void Execute(EmbeddedResources::FileResourceId resource); -#endif - bool IsExistingFunction(const char* name); #if ORTHANC_ENABLE_CURL == 1 diff -r 100fbe970762 -r e3b3af80732d OrthancServer/Database/SQLiteDatabaseWrapper.cpp --- a/OrthancServer/Database/SQLiteDatabaseWrapper.cpp Tue Jun 09 20:50:20 2020 +0200 +++ b/OrthancServer/Database/SQLiteDatabaseWrapper.cpp Tue Jun 09 21:31:13 2020 +0200 @@ -40,7 +40,7 @@ #include "../Search/ISqlLookupFormatter.h" #include "../ServerToolbox.h" -#include +#include #include #include @@ -394,7 +394,7 @@ { LOG(INFO) << "Creating the database"; std::string query; - EmbeddedResources::GetFileResource(query, EmbeddedResources::PREPARE_DATABASE); + ServerResources::GetFileResource(query, ServerResources::PREPARE_DATABASE); db_.Execute(query); } @@ -430,7 +430,7 @@ { LOG(INFO) << "Installing the SQLite triggers to track the size of the attachments"; std::string query; - EmbeddedResources::GetFileResource(query, EmbeddedResources::INSTALL_TRACK_ATTACHMENTS_SIZE); + ServerResources::GetFileResource(query, ServerResources::INSTALL_TRACK_ATTACHMENTS_SIZE); db_.Execute(query); } } @@ -444,10 +444,10 @@ static void ExecuteUpgradeScript(SQLite::Connection& db, - EmbeddedResources::FileResourceId script) + ServerResources::FileResourceId script) { std::string upgrade; - EmbeddedResources::GetFileResource(upgrade, script); + ServerResources::GetFileResource(upgrade, script); db.BeginTransaction(); db.Execute(upgrade); db.CommitTransaction(); @@ -475,14 +475,14 @@ if (version_ == 3) { LOG(WARNING) << "Upgrading database version from 3 to 4"; - ExecuteUpgradeScript(db_, EmbeddedResources::UPGRADE_DATABASE_3_TO_4); + ExecuteUpgradeScript(db_, ServerResources::UPGRADE_DATABASE_3_TO_4); version_ = 4; } if (version_ == 4) { LOG(WARNING) << "Upgrading database version from 4 to 5"; - ExecuteUpgradeScript(db_, EmbeddedResources::UPGRADE_DATABASE_4_TO_5); + ExecuteUpgradeScript(db_, ServerResources::UPGRADE_DATABASE_4_TO_5); version_ = 5; } diff -r 100fbe970762 -r e3b3af80732d OrthancServer/EmbeddedResourceHttpHandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OrthancServer/EmbeddedResourceHttpHandler.cpp Tue Jun 09 21:31:13 2020 +0200 @@ -0,0 +1,97 @@ +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics + * Department, University Hospital of Liege, Belgium + * Copyright (C) 2017-2020 Osimis S.A., Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * In addition, as a special exception, the copyright holders of this + * program give permission to link the code of its release with the + * OpenSSL project's "OpenSSL" library (or with modified versions of it + * that use the same license as the "OpenSSL" library), and distribute + * the linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If you + * modify file(s) with this exception, you may extend this exception to + * your version of the file(s), but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source files + * in the program, then also delete it here. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + **/ + + +#include "PrecompiledHeadersServer.h" +#include "EmbeddedResourceHttpHandler.h" + +#include "../Core/HttpServer/HttpOutput.h" +#include "../Core/Logging.h" +#include "../Core/OrthancException.h" +#include "../Core/SystemToolbox.h" + + +namespace Orthanc +{ + EmbeddedResourceHttpHandler::EmbeddedResourceHttpHandler( + const std::string& baseUri, + ServerResources::DirectoryResourceId resourceId) + { + Toolbox::SplitUriComponents(baseUri_, baseUri); + resourceId_ = resourceId; + } + + + bool EmbeddedResourceHttpHandler::Handle( + HttpOutput& output, + RequestOrigin /*origin*/, + const char* /*remoteIp*/, + const char* /*username*/, + HttpMethod method, + const UriComponents& uri, + const Arguments& headers, + const GetArguments& arguments, + const void* /*bodyData*/, + size_t /*bodySize*/) + { + if (!Toolbox::IsChildUri(baseUri_, uri)) + { + // This URI is not served by this handler + return false; + } + + if (method != HttpMethod_Get) + { + output.SendMethodNotAllowed("GET"); + return true; + } + + std::string resourcePath = Toolbox::FlattenUri(uri, baseUri_.size()); + MimeType contentType = SystemToolbox::AutodetectMimeType(resourcePath); + + try + { + const void* buffer = ServerResources::GetDirectoryResourceBuffer(resourceId_, resourcePath.c_str()); + size_t size = ServerResources::GetDirectoryResourceSize(resourceId_, resourcePath.c_str()); + + output.SetContentType(contentType); + output.Answer(buffer, size); + } + catch (OrthancException&) + { + LOG(WARNING) << "Unable to find HTTP resource: " << resourcePath; + output.SendStatus(HttpStatus_404_NotFound); + } + + return true; + } +} diff -r 100fbe970762 -r e3b3af80732d OrthancServer/EmbeddedResourceHttpHandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OrthancServer/EmbeddedResourceHttpHandler.h Tue Jun 09 21:31:13 2020 +0200 @@ -0,0 +1,76 @@ +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics + * Department, University Hospital of Liege, Belgium + * Copyright (C) 2017-2020 Osimis S.A., Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * In addition, as a special exception, the copyright holders of this + * program give permission to link the code of its release with the + * OpenSSL project's "OpenSSL" library (or with modified versions of it + * that use the same license as the "OpenSSL" library), and distribute + * the linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If you + * modify file(s) with this exception, you may extend this exception to + * your version of the file(s), but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source files + * in the program, then also delete it here. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + **/ + + +#pragma once + +#include "../Core/HttpServer/IHttpHandler.h" + +#include // Autogenerated file +#include + +namespace Orthanc +{ + class EmbeddedResourceHttpHandler : public IHttpHandler + { + private: + UriComponents baseUri_; + ServerResources::DirectoryResourceId resourceId_; + + public: + EmbeddedResourceHttpHandler( + const std::string& baseUri, + ServerResources::DirectoryResourceId resourceId); + + virtual bool CreateChunkedRequestReader(std::unique_ptr& target, + RequestOrigin origin, + const char* remoteIp, + const char* username, + HttpMethod method, + const UriComponents& uri, + const Arguments& headers) + { + return false; + } + + virtual bool Handle(HttpOutput& output, + RequestOrigin origin, + const char* remoteIp, + const char* username, + HttpMethod method, + const UriComponents& uri, + const Arguments& headers, + const GetArguments& arguments, + const void* /*bodyData*/, + size_t /*bodySize*/); + }; +} diff -r 100fbe970762 -r e3b3af80732d OrthancServer/LuaScripting.cpp --- a/OrthancServer/LuaScripting.cpp Tue Jun 09 20:50:20 2020 +0200 +++ b/OrthancServer/LuaScripting.cpp Tue Jun 09 21:31:13 2020 +0200 @@ -42,7 +42,7 @@ #include "../Core/Logging.h" #include "../Core/Lua/LuaFunctionCall.h" -#include +#include namespace Orthanc @@ -907,7 +907,11 @@ { OrthancConfiguration::ReaderLock configLock; - lua_.Execute(Orthanc::EmbeddedResources::LUA_TOOLBOX); + { + std::string command; + Orthanc::ServerResources::GetFileResource(command, Orthanc::ServerResources::LUA_TOOLBOX); + lua_.Execute(command); + } std::list luaScripts; configLock.GetConfiguration().GetListOfStringsParameter(luaScripts, "LuaScripts"); diff -r 100fbe970762 -r e3b3af80732d OrthancServer/OrthancConfiguration.cpp --- a/OrthancServer/OrthancConfiguration.cpp Tue Jun 09 20:50:20 2020 +0200 +++ b/OrthancServer/OrthancConfiguration.cpp Tue Jun 09 21:31:13 2020 +0200 @@ -584,6 +584,14 @@ } + void OrthancConfiguration::RegisterFont(ServerResources::FileResourceId resource) + { + std::string content; + ServerResources::GetFileResource(content, resource); + fontRegistry_.AddFromMemory(content); + } + + void OrthancConfiguration::GetDicomModalityUsingSymbolicName( RemoteModalityParameters& modality, const std::string& name) const diff -r 100fbe970762 -r e3b3af80732d OrthancServer/OrthancConfiguration.h --- a/OrthancServer/OrthancConfiguration.h Tue Jun 09 20:50:20 2020 +0200 +++ b/OrthancServer/OrthancConfiguration.h Tue Jun 09 21:31:13 2020 +0200 @@ -37,7 +37,7 @@ #include "../Core/WebServiceParameters.h" #include "../Core/DicomNetworking/RemoteModalityParameters.h" -#include +#include #include #include @@ -158,10 +158,7 @@ void LoadModalitiesAndPeers(); - void RegisterFont(EmbeddedResources::FileResourceId resource) - { - fontRegistry_.AddFromResource(resource); - } + void RegisterFont(ServerResources::FileResourceId resource); bool LookupStringParameter(std::string& target, const std::string& parameter) const; diff -r 100fbe970762 -r e3b3af80732d OrthancServer/OrthancInitialization.cpp --- a/OrthancServer/OrthancInitialization.cpp Tue Jun 09 20:50:20 2020 +0200 +++ b/OrthancServer/OrthancInitialization.cpp Tue Jun 09 21:31:13 2020 +0200 @@ -48,6 +48,8 @@ #include "Database/SQLiteDatabaseWrapper.h" #include "OrthancConfiguration.h" +#include + #include // For dcmDisableGethostbyaddr() @@ -264,7 +266,7 @@ LoadCustomDictionary(lock.GetJson()); - lock.GetConfiguration().RegisterFont(EmbeddedResources::FONT_UBUNTU_MONO_BOLD_16); + lock.GetConfiguration().RegisterFont(ServerResources::FONT_UBUNTU_MONO_BOLD_16); } diff -r 100fbe970762 -r e3b3af80732d OrthancServer/OrthancRestApi/OrthancRestSystem.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestSystem.cpp Tue Jun 09 20:50:20 2020 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestSystem.cpp Tue Jun 09 21:31:13 2020 +0200 @@ -176,7 +176,7 @@ static void GetDicomConformanceStatement(RestApiGetCall& call) { std::string statement; - GetFileResource(statement, EmbeddedResources::DICOM_CONFORMANCE_STATEMENT); + GetFileResource(statement, ServerResources::DICOM_CONFORMANCE_STATEMENT); call.GetOutput().AnswerBuffer(statement, MimeType_PlainText); } diff -r 100fbe970762 -r e3b3af80732d OrthancServer/main.cpp --- a/OrthancServer/main.cpp Tue Jun 09 20:50:20 2020 +0200 +++ b/OrthancServer/main.cpp Tue Jun 09 21:31:13 2020 +0200 @@ -41,17 +41,17 @@ #include "../Core/DicomNetworking/DicomAssociationParameters.h" #include "../Core/DicomNetworking/DicomServer.h" #include "../Core/DicomParsing/FromDcmtkBridge.h" -#include "../Core/HttpServer/EmbeddedResourceHttpHandler.h" #include "../Core/HttpServer/FilesystemHttpHandler.h" #include "../Core/HttpServer/HttpServer.h" #include "../Core/Logging.h" #include "../Core/Lua/LuaFunctionCall.h" #include "../Plugins/Engine/OrthancPlugins.h" +#include "EmbeddedResourceHttpHandler.h" #include "OrthancConfiguration.h" #include "OrthancFindRequestHandler.h" +#include "OrthancGetRequestHandler.h" #include "OrthancInitialization.h" #include "OrthancMoveRequestHandler.h" -#include "OrthancGetRequestHandler.h" #include "ServerContext.h" #include "ServerJobs/StorageCommitmentScpJob.h" #include "ServerToolbox.h" @@ -1152,7 +1152,7 @@ // Secondly, apply the "static resources" layer #if ORTHANC_STANDALONE == 1 - EmbeddedResourceHttpHandler staticResources("/app", EmbeddedResources::ORTHANC_EXPLORER); + EmbeddedResourceHttpHandler staticResources("/app", ServerResources::ORTHANC_EXPLORER); #else FilesystemHttpHandler staticResources("/app", ORTHANC_PATH "/OrthancExplorer"); #endif @@ -1566,7 +1566,7 @@ { // TODO WHAT IS THE ENCODING? std::string configurationSample; - GetFileResource(configurationSample, EmbeddedResources::CONFIGURATION_SAMPLE); + GetFileResource(configurationSample, ServerResources::CONFIGURATION_SAMPLE); #if defined(_WIN32) // Replace UNIX newlines with DOS newlines diff -r 100fbe970762 -r e3b3af80732d Resources/CMake/OrthancFrameworkConfiguration.cmake --- a/Resources/CMake/OrthancFrameworkConfiguration.cmake Tue Jun 09 20:50:20 2020 +0200 +++ b/Resources/CMake/OrthancFrameworkConfiguration.cmake Tue Jun 09 21:31:13 2020 +0200 @@ -537,6 +537,7 @@ -DORTHANC_DEFAULT_DICOM_ENCODING=Encoding_Latin1 -DORTHANC_ENABLE_BASE64=1 -DORTHANC_ENABLE_MD5=1 + -DORTHANC_HAS_EMBEDDED_RESOURCES=1 -DORTHANC_MAXIMUM_TAG_LENGTH=256 -DORTHANC_VERSION="${ORTHANC_VERSION}" ) @@ -676,11 +677,11 @@ endif() -if (NOT ORTHANC_BUILDING_FRAMEWORK_LIBRARY) - list(APPEND ORTHANC_CORE_SOURCES_INTERNAL - ${ORTHANC_ROOT}/Core/HttpServer/EmbeddedResourceHttpHandler.cpp - ) -endif() +EmbedResources( + --target=OrthancEmbeddedResources + ${LIBICU_RESOURCES} + ${DCMTK_DICTIONARIES} + ) set(ORTHANC_CORE_SOURCES diff -r 100fbe970762 -r e3b3af80732d UnitTestsSources/LuaTests.cpp --- a/UnitTestsSources/LuaTests.cpp Tue Jun 09 20:50:20 2020 +0200 +++ b/UnitTestsSources/LuaTests.cpp Tue Jun 09 21:31:13 2020 +0200 @@ -42,6 +42,8 @@ #include "../Core/Toolbox.h" #include "../Core/Lua/LuaFunctionCall.h" +#include + #include #if !defined(UNIT_TESTS_WITH_HTTP_CONNEXIONS) @@ -54,9 +56,13 @@ Orthanc::LuaContext lua; #if ORTHANC_UNIT_TESTS_LINK_FRAMEWORK != 1 - lua.Execute(Orthanc::EmbeddedResources::LUA_TOOLBOX); + { + std::string command; + Orthanc::ServerResources::GetFileResource(command, Orthanc::ServerResources::LUA_TOOLBOX); + lua.Execute(command); + } #endif - + lua.Execute("a={}"); lua.Execute("a['x'] = 10"); lua.Execute("a['y'] = {}"); @@ -131,7 +137,12 @@ TEST(Lua, Simple) { Orthanc::LuaContext lua; - lua.Execute(Orthanc::EmbeddedResources::LUA_TOOLBOX); + + { + std::string command; + Orthanc::ServerResources::GetFileResource(command, Orthanc::ServerResources::LUA_TOOLBOX); + lua.Execute(command); + } { Orthanc::LuaFunctionCall f(lua, "PrintRecursive");