annotate Sources/StorageCommitmentScpCallback.cpp @ 213:f8dc8dd2da76

documented orthanc.RegisterIncomingCStoreInstanceFilter() and orthanc.RegisterReceivedInstanceCallback()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 03 Jul 2024 14:56:51 +0200
parents c8de83fe7faa
children b124c74e6968
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
119
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
1 /**
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
2 * Python plugin for Orthanc
166
6fada29b6759 updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 155
diff changeset
3 * Copyright (C) 2020-2023 Osimis S.A., Belgium
6fada29b6759 updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 155
diff changeset
4 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
155
71d305c29cfa updated year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 119
diff changeset
5 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
119
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
6 *
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
10 * the License, or (at your option) any later version.
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
11 *
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
15 * Affero General Public License for more details.
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
16 *
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
19 **/
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
20
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
21
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
22 #include "StorageCommitmentScpCallback.h"
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
23
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
24 #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h"
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
25 #include "ICallbackRegistration.h"
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
26 #include "PythonString.h"
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
27
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
28
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
29 static PyObject* storageCommitmentScpCallback_ = NULL;
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
30 static PyObject* storageCommitmentLookupCallback_ = NULL;
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
31
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
32
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
33 static OrthancPluginErrorCode StorageCommitmentSCPCallback(
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
34 void** handler /* out */,
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
35 const char* jobId,
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
36 const char* transactionUid,
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
37 const char* const* sopClassUids,
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
38 const char* const* sopInstanceUids,
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
39 uint32_t countInstances,
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
40 const char* remoteAet,
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
41 const char* calledAet)
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
42 {
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
43 try
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
44 {
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
45 PythonLock lock;
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
46
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
47 PythonObject args(lock, PyTuple_New(6));
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
48 {
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
49 PythonString str(lock, jobId);
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
50 PyTuple_SetItem(args.GetPyObject(), 0, str.Release());
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
51 }
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
52 {
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
53 PythonString str(lock, transactionUid);
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
54 PyTuple_SetItem(args.GetPyObject(), 1, str.Release());
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
55 }
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
56 {
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
57 PythonObject sopClassUidList(lock, PyList_New(countInstances));
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
58 for (uint32_t i = 0; i < countInstances; i++)
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
59 {
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
60 PythonString str(lock, sopClassUids[i]);
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
61 PyList_SetItem(sopClassUidList.GetPyObject(), i, str.Release());
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
62 }
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
63 PyTuple_SetItem(args.GetPyObject(), 2, sopClassUidList.Release());
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
64 PythonObject sopInstanceUidList(lock, PyList_New(countInstances));
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
65 for (uint32_t i = 0; i < countInstances; i++)
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
66 {
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
67 PythonString str(lock, sopInstanceUids[i]);
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
68 PyList_SetItem(sopInstanceUidList.GetPyObject(), i, str.Release());
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
69 }
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
70 PyTuple_SetItem(args.GetPyObject(), 3, sopInstanceUidList.Release());
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
71 }
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
72 {
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
73 PythonString str(lock, remoteAet);
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
74 PyTuple_SetItem(args.GetPyObject(), 4, str.Release());
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
75 }
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
76 {
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
77 PythonString str(lock, calledAet);
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
78 PyTuple_SetItem(args.GetPyObject(), 5, str.Release());
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
79 }
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
80
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
81 PythonObject result(lock, PyObject_CallObject(storageCommitmentScpCallback_, args.GetPyObject()));
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
82 *handler = result.Release();
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
83
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
84 std::string traceback;
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
85 if (lock.HasErrorOccurred(traceback))
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
86 {
171
c8de83fe7faa removed deprecation warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 166
diff changeset
87 ORTHANC_PLUGINS_LOG_ERROR("Error in the Python storage commitment SCP callback, traceback:\n" + traceback);
119
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
88 return OrthancPluginErrorCode_Plugin;
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
89 }
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
90 }
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
91 catch (OrthancPlugins::PluginException& e)
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
92 {
171
c8de83fe7faa removed deprecation warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 166
diff changeset
93 ORTHANC_PLUGINS_LOG_ERROR("Error in the Python storage commitment SCP callback: " +
c8de83fe7faa removed deprecation warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 166
diff changeset
94 std::string(e.What(OrthancPlugins::GetGlobalContext())));
119
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
95 }
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
96 return OrthancPluginErrorCode_Success;
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
97 }
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
98
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
99 static OrthancPluginErrorCode StorageCommitmentLookupCallback(
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
100 OrthancPluginStorageCommitmentFailureReason* target /* out */,
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
101 void* handler,
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
102 const char* sopClassUid,
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
103 const char* sopInstanceUid)
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
104 {
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
105 try
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
106 {
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
107 PythonLock lock;
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
108
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
109 PythonObject args(lock, PyTuple_New(3));
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
110 {
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
111 PythonString str(lock, sopClassUid);
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
112 PyTuple_SetItem(args.GetPyObject(), 0, str.Release());
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
113 }
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
114 {
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
115 PythonString str(lock, sopInstanceUid);
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
116 PyTuple_SetItem(args.GetPyObject(), 1, str.Release());
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
117 }
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
118 {
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
119 PyObject* data = (PyObject*) handler;
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
120 Py_INCREF(data); // Keep a reference before it was stolen by PyTuple_SetItem.
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
121 PyTuple_SetItem(args.GetPyObject(), 2, data);
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
122 }
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
123
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
124 PythonObject result(lock, PyObject_CallObject(storageCommitmentLookupCallback_, args.GetPyObject()));
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
125
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
126 if (!PyLong_Check(result.GetPyObject()))
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
127 {
171
c8de83fe7faa removed deprecation warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 166
diff changeset
128 ORTHANC_PLUGINS_LOG_ERROR("The Python storage commitment Lookup callback has not returned an int as the return value");
119
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
129 return OrthancPluginErrorCode_Plugin;
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
130 }
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
131
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
132 *target = static_cast<OrthancPluginStorageCommitmentFailureReason>(PyLong_AsLong(result.GetPyObject()));
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
133
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
134 std::string traceback;
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
135 if (lock.HasErrorOccurred(traceback))
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
136 {
171
c8de83fe7faa removed deprecation warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 166
diff changeset
137 ORTHANC_PLUGINS_LOG_ERROR("Error in the Python storage commitment Lookup callback, traceback:\n" + traceback);
119
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
138 return OrthancPluginErrorCode_Plugin;
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
139 }
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
140 }
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
141 catch (OrthancPlugins::PluginException& e)
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
142 {
171
c8de83fe7faa removed deprecation warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 166
diff changeset
143 ORTHANC_PLUGINS_LOG_ERROR("Error in the Python storage commitment Lookup callback: " +
c8de83fe7faa removed deprecation warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 166
diff changeset
144 std::string(e.What(OrthancPlugins::GetGlobalContext())));
119
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
145 }
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
146 return OrthancPluginErrorCode_Success;
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
147 }
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
148
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
149 static void StorageCommitmentDestructor(void *handler)
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
150 {
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
151 PythonLock lock;
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
152 Py_DECREF((PyObject*)handler); // Release the reference
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
153 }
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
154
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
155 PyObject* RegisterStorageCommitmentScpCallback(PyObject* module, PyObject* args)
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
156 {
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
157 // The GIL is locked at this point (no need to create "PythonLock")
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
158
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
159 class Registration : public ICallbackRegistration
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
160 {
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
161 public:
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
162 virtual void Register() ORTHANC_OVERRIDE
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
163 {
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
164 OrthancPluginRegisterStorageCommitmentScpCallback(
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
165 OrthancPlugins::GetGlobalContext(),
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
166 StorageCommitmentSCPCallback,
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
167 StorageCommitmentDestructor,
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
168 StorageCommitmentLookupCallback);
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
169 }
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
170 };
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
171
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
172 {
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
173 Registration registration;
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
174 return ICallbackRegistration::Apply2(registration, args,
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
175 storageCommitmentScpCallback_,
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
176 storageCommitmentLookupCallback_,
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
177 "Python storage commitment SCP & Lookup callback");
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
178 }
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
179 }
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
180
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
181 void FinalizeStorageCommitmentScpCallback()
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
182 {
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
183 ICallbackRegistration::Unregister(storageCommitmentScpCallback_);
cf6decdf9e15 wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
184 ICallbackRegistration::Unregister(storageCommitmentLookupCallback_);
171
c8de83fe7faa removed deprecation warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 166
diff changeset
185 }