Hi all!
I'd
like to ask for comments and/or constructive criticism on a patch/wip for
1.3.2 I've been working on these past couple of days. Files and
instructions on how to run it shall follow at the end of this message.
[please, a thousand appologies because this e-mail ended up being way longer than I anticipated]
As per Sébastien's suggestion in
this post,
we're looking into possibly developing a polling system so failed steps
of our routing can be tried again. It'll basically register images as
they come and make sure they follow the transcode/transmit steps.
Its
very first interface, the one that registers images locally, is exposed
as a Rest API and will be accessed by a plugin. To avoid further
complications, OnStoredInstance was dropped in favour of the
ReceivedInstanceFilter callback. This way, if Orthanc cannot communicate
with the polling system (eg. it's offline for whatever reason), it
simply returns false. We won't have to worry about deleting the incoming image from
Orthanc then, as would be the case with OnStoredInstance.
We're coding it in C/C++ because of the available libraries and how we can leverage its power in the context of the solution.
But, as of 1.3.2 (and latest on bitbucket), there's no way to code a plugin for that. OrhtancPlugins::FilterIncomingInstance
simply returns true. Or maybe I failed miserably at finding the right hooks.
That's where the whole patching comes into play.
Because there's a TODO ("Enable filtering of instances from plugins"),
I've taken the liberty to try and do it myself.
So
basically the OnStoredInstance related functions, hooks,
reinterpret_cast's, etc... they were taken as a starting point and a new
callback was created:
typedef OrthancPluginErrorCode (*OrthancPluginReceivedInstanceFilterCallback) (
const OrthancPluginDicomInstance* instance,
const char* originName,
bool& isAcceptedInstance);
Images
are accepted by default. To reject an image, set isAcceptedInstance to
false. You should return OrthancPluginErrorCode_Success if nothing goes
wrong.
As with other callbacks, the new ones are registered through the
OrthancPluginRegisterReceivedInstanceFilterCallback(context, callback)
function.
[insert
grin] I know the originName parameter is more complex then that and
I'll be coding a small hierarchy to support the origin parameter in a
more object oriented way in the coming days. I just wanted to get a POC
going quickly. Oh, and there's formatting to be standardized as well.
Hopefully
nothing wrong was done and I was clear on what was done (and why). But
since this is my very first serious patch on an open source project, I'd like to hear from the more
experienced (that's basically everyone). What are your opinions? What
would you do differently? Is it supposed to be done some other way?
Thanks in advance!
--- INSTRUCTIONS ON HOW TO COMPILE AND RUN ---
# sample configuration was written to point to /tmp
# to make things easier
# that's why we unpack it to /tmp
$ cd /tmp
$ tar xvf <PATH-TO>/Orthanc-1.3.2-FilterIncomingInstance.tar.gz
$ zcat cplugin-FilterIncomingInstance-1.3.2.patch.gz | patch -p0
$ cd Orthanc-1.3.2/
$ mkdir build
$ cd build
# this is how I compile, YMMV, so hit me an email should you need help
#
$ cmake -DUSE_GOOGLE_TEST_DEBIAN_PACKAGE=ON -DSYSTEM_MONGOOSE_USE_CALLBACKS=OFF ..
$ make
# the sample plugin that's configured in the provided orthanc.json
#
$ cd ../Plugins/Samples/RejectIncomingInstances/
$ mkdir build
$ cd build
$ cmake ..
$ make
# run Orthanc
#
$ cd /tmp/Orthanc-1.3.2/build
$ ./Orthanc /tmp/orthanc.json
---
By
this point you'll have a running Orthanc on port 8042 that will not
accept any image because of a C/C++ plugin. Username/password for the
web / rest interface is orthanc/orthanc.
Have a good one!
Luiz