Mercurial > hg > orthanc
changeset 7136:843c4e99e96f
SDK: Added OrthancPluginGetInstanceCalledAet() and OrthancPluginGetInstanceRemoteIp()
| author | Alain Mazy <am@orthanc.team> |
|---|---|
| date | Thu, 20 Aug 2026 17:24:07 +0200 |
| parents | 4ba287b00973 |
| children | a3923ae96abd |
| files | NEWS OrthancServer/Plugins/Engine/OrthancPlugins.cpp OrthancServer/Plugins/Include/orthanc/OrthancCPlugin.h OrthancServer/Plugins/Include/orthanc/OrthancPluginCodeModel.json OrthancServer/Sources/DicomInstanceOrigin.cpp OrthancServer/Sources/DicomInstanceOrigin.h |
| diffstat | 6 files changed, 154 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Wed Aug 19 14:11:33 2026 +0200 +++ b/NEWS Thu Aug 20 17:24:07 2026 +0200 @@ -1,6 +1,11 @@ Pending changes in the mainline =============================== +Plugin SDK +---------- + +* Added OrthancPluginGetInstanceCalledAet() and OrthancPluginGetInstanceRemoteIp() + Version 1.13.0 (2026-08-15) ===========================
--- a/OrthancServer/Plugins/Engine/OrthancPlugins.cpp Wed Aug 19 14:11:33 2026 +0200 +++ b/OrthancServer/Plugins/Engine/OrthancPlugins.cpp Thu Aug 20 17:24:07 2026 +0200 @@ -3836,6 +3836,15 @@ *p.resultString = instance.GetOrigin().GetRemoteAetC(); return; + case _OrthancPluginService_GetInstanceCalledAet: + *p.resultString = instance.GetOrigin().GetCalledAetC(); + return; + + + case _OrthancPluginService_GetInstanceRemoteIp: + *p.resultString = instance.GetOrigin().GetRemoteIpC(); + return; + case _OrthancPluginService_GetInstanceSize: *p.resultInt64 = static_cast<int64_t>(instance.GetBufferSize()); return; @@ -5439,6 +5448,8 @@ return true; case _OrthancPluginService_GetInstanceRemoteAet: + case _OrthancPluginService_GetInstanceCalledAet: + case _OrthancPluginService_GetInstanceRemoteIp: case _OrthancPluginService_GetInstanceSize: case _OrthancPluginService_GetInstanceData: case _OrthancPluginService_GetInstanceJson:
--- a/OrthancServer/Plugins/Include/orthanc/OrthancCPlugin.h Wed Aug 19 14:11:33 2026 +0200 +++ b/OrthancServer/Plugins/Include/orthanc/OrthancCPlugin.h Thu Aug 20 17:24:07 2026 +0200 @@ -126,7 +126,7 @@ #define ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER 1 #define ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER 13 -#define ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER 0 +#define ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER 1 #if !defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) @@ -618,6 +618,8 @@ _OrthancPluginService_GetInstanceDicomWebJson = 4018, /* New in Orthanc 1.7.0 */ _OrthancPluginService_GetInstanceDicomWebXml = 4019, /* New in Orthanc 1.7.0 */ _OrthancPluginService_LoadDicomInstance = 4020, /* New in Orthanc 1.12.1 */ + _OrthancPluginService_GetInstanceCalledAet = 4021, /* New in Orthanc 1.13.1 */ + _OrthancPluginService_GetInstanceRemoteIp = 4022, /* New in Orthanc 1.13.1 */ /* Services for plugins implementing a database back-end */ _OrthancPluginService_RegisterDatabaseBackend = 5000, /* New in Orthanc 0.8.6 */ @@ -3397,6 +3399,75 @@ /** + * @brief Get the Called AET of a DICOM instance. + * + * This function returns the Called Application Entity Title (AET) that + * was used when this instance was sent to Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return The AET if success, NULL if error. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.13.1") + ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetInstanceCalledAet( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + const char* result; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultString = &result; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceCalledAet, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Get the Remote IP of a DICOM instance. + * + * This function returns the IP of the modality that has sent this instance to Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return The AET if success, NULL if error. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.13.1") + ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetInstanceRemoteIp( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + const char* result; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultString = &result; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceRemoteIp, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** * @brief Get the size of a DICOM file. * * This function returns the number of bytes of the given DICOM instance.
--- a/OrthancServer/Plugins/Include/orthanc/OrthancPluginCodeModel.json Wed Aug 19 14:11:33 2026 +0200 +++ b/OrthancServer/Plugins/Include/orthanc/OrthancPluginCodeModel.json Thu Aug 20 17:24:07 2026 +0200 @@ -86,6 +86,44 @@ }, { "args": [], + "c_function": "OrthancPluginGetInstanceCalledAet", + "const": true, + "documentation": { + "args": {}, + "description": [ + "This function returns the Called Application Entity Title (AET) that was used when this instance was sent to Orthanc." + ], + "return": "The AET if success, NULL if error.", + "summary": "Get the Called AET of a DICOM instance." + }, + "return_sdk_type": "const char *", + "since_sdk": [ + 1, + 13, + 1 + ] + }, + { + "args": [], + "c_function": "OrthancPluginGetInstanceRemoteIp", + "const": true, + "documentation": { + "args": {}, + "description": [ + "This function returns the IP of the modality that has sent this instance to Orthanc." + ], + "return": "The AET if success, NULL if error.", + "summary": "Get the Remote IP of a DICOM instance." + }, + "return_sdk_type": "const char *", + "since_sdk": [ + 1, + 13, + 1 + ] + }, + { + "args": [], "c_function": "OrthancPluginGetInstanceSize", "const": true, "documentation": {
--- a/OrthancServer/Sources/DicomInstanceOrigin.cpp Wed Aug 19 14:11:33 2026 +0200 +++ b/OrthancServer/Sources/DicomInstanceOrigin.cpp Thu Aug 20 17:24:07 2026 +0200 @@ -117,6 +117,30 @@ } } + const char* DicomInstanceOrigin::GetCalledAetC() const + { + if (origin_ == RequestOrigin_DicomProtocol) + { + return dicomCalledAet_.c_str(); + } + else + { + return ""; + } + } + + const char* DicomInstanceOrigin::GetRemoteIpC() const + { + if (origin_ == RequestOrigin_DicomProtocol) + { + return remoteIp_.c_str(); + } + else + { + return ""; + } + } + bool DicomInstanceOrigin::LookupRemoteAet(std::string& result) const { if (origin_ == RequestOrigin_DicomProtocol)
--- a/OrthancServer/Sources/DicomInstanceOrigin.h Wed Aug 19 14:11:33 2026 +0200 +++ b/OrthancServer/Sources/DicomInstanceOrigin.h Thu Aug 20 17:24:07 2026 +0200 @@ -80,6 +80,10 @@ const char* GetRemoteAetC() const; + const char* GetCalledAetC() const; + + const char* GetRemoteIpC() const; + bool LookupRemoteAet(std::string& result) const; bool LookupRemoteIp(std::string& result) const;
