# HG changeset patch # User Benjamin Golinvaux # Date 1596375482 -7200 # Node ID c815ad10a10f86bf6cea175952104c4783ee4781 # Parent 4c4b267e4004b3f6a2204e57793f9ca61144d92a RtViewerPlugin : added detection of web-viewer plugin diff -r 4c4b267e4004 -r c815ad10a10f OrthancStone/Samples/RtViewerPlugin/Plugin.cpp --- a/OrthancStone/Samples/RtViewerPlugin/Plugin.cpp Sun Aug 02 15:13:58 2020 +0200 +++ b/OrthancStone/Samples/RtViewerPlugin/Plugin.cpp Sun Aug 02 15:38:02 2020 +0200 @@ -26,6 +26,32 @@ #include #include +OrthancPluginErrorCode OnChangeCallback(OrthancPluginChangeType changeType, + OrthancPluginResourceType resourceType, + const char* resourceId) +{ + try + { + if (changeType == OrthancPluginChangeType_OrthancStarted) + { + Json::Value info; + if (!OrthancPlugins::RestApiGet(info, "/plugins/web-viewer", false)) + { + throw Orthanc::OrthancException( + Orthanc::ErrorCode_InternalError, + "The Stone MPR RT viewer requires the Web Viewer plugin to be installed"); + } + } + } + catch (Orthanc::OrthancException& e) + { + LOG(ERROR) << "Exception: " << e.What(); + return static_cast(e.GetErrorCode()); + } + + return OrthancPluginErrorCode_Success; +} + template void ServeEmbeddedFolder(OrthancPluginRestOutput* output, const char* url, @@ -128,6 +154,8 @@ OrthancPlugins::RegisterRestCallback > ("/stone-rtviewer/index.html", true); + + OrthancPluginRegisterOnChangeCallback(context, OnChangeCallback); } catch (...) {