Mercurial > hg > orthanc-python
annotate Sources/StorageCommitmentScpCallback.cpp @ 170:b49eeb36cd0d
removed generation of code model, now part of orthanc-java
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 27 Jun 2024 14:26:59 +0200 |
parents | 6fada29b6759 |
children | c8de83fe7faa |
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 { |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
87 OrthancPlugins::LogError("Error in the Python storage commitment SCP callback, " |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
88 "traceback:\n" + traceback); |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
89 return OrthancPluginErrorCode_Plugin; |
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 } |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
92 catch (OrthancPlugins::PluginException& e) |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
93 { |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
94 OrthancPlugins::LogError("Error in the Python storage commitment SCP callback: " + |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
95 std::string(e.What(OrthancPlugins::GetGlobalContext()))); |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
96 } |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
97 return OrthancPluginErrorCode_Success; |
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 |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
100 static OrthancPluginErrorCode StorageCommitmentLookupCallback( |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
101 OrthancPluginStorageCommitmentFailureReason* target /* out */, |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
102 void* handler, |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
103 const char* sopClassUid, |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
104 const char* sopInstanceUid) |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
105 { |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
106 try |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
107 { |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
108 PythonLock lock; |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
109 |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
110 PythonObject args(lock, PyTuple_New(3)); |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
111 { |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
112 PythonString str(lock, sopClassUid); |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
113 PyTuple_SetItem(args.GetPyObject(), 0, str.Release()); |
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 { |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
116 PythonString str(lock, sopInstanceUid); |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
117 PyTuple_SetItem(args.GetPyObject(), 1, str.Release()); |
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 { |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
120 PyObject* data = (PyObject*) handler; |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
121 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
|
122 PyTuple_SetItem(args.GetPyObject(), 2, data); |
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 |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
125 PythonObject result(lock, PyObject_CallObject(storageCommitmentLookupCallback_, args.GetPyObject())); |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
126 |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
127 if (!PyLong_Check(result.GetPyObject())) |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
128 { |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
129 OrthancPlugins::LogError("The Python storage commitment Lookup callback has not returned an int as the return value"); |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
130 return OrthancPluginErrorCode_Plugin; |
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 |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
133 *target = static_cast<OrthancPluginStorageCommitmentFailureReason>(PyLong_AsLong(result.GetPyObject())); |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
134 |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
135 std::string traceback; |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
136 if (lock.HasErrorOccurred(traceback)) |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
137 { |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
138 OrthancPlugins::LogError("Error in the Python storage commitment Lookup callback, " |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
139 "traceback:\n" + traceback); |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
140 return OrthancPluginErrorCode_Plugin; |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
141 } |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
142 } |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
143 catch (OrthancPlugins::PluginException& e) |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
144 { |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
145 OrthancPlugins::LogError("Error in the Python storage commitment Lookup callback: " + |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
146 std::string(e.What(OrthancPlugins::GetGlobalContext()))); |
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 return OrthancPluginErrorCode_Success; |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
149 } |
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 static void StorageCommitmentDestructor(void *handler) |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
152 { |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
153 PythonLock lock; |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
154 Py_DECREF((PyObject*)handler); // Release the reference |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
155 } |
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 PyObject* RegisterStorageCommitmentScpCallback(PyObject* module, PyObject* args) |
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 // 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
|
160 |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
161 class Registration : public ICallbackRegistration |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
162 { |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
163 public: |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
164 virtual void Register() ORTHANC_OVERRIDE |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
165 { |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
166 OrthancPluginRegisterStorageCommitmentScpCallback( |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
167 OrthancPlugins::GetGlobalContext(), |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
168 StorageCommitmentSCPCallback, |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
169 StorageCommitmentDestructor, |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
170 StorageCommitmentLookupCallback); |
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 |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
174 { |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
175 Registration registration; |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
176 return ICallbackRegistration::Apply2(registration, args, |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
177 storageCommitmentScpCallback_, |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
178 storageCommitmentLookupCallback_, |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
179 "Python storage commitment SCP & Lookup callback"); |
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 } |
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 void FinalizeStorageCommitmentScpCallback() |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
184 { |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
185 ICallbackRegistration::Unregister(storageCommitmentScpCallback_); |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
186 ICallbackRegistration::Unregister(storageCommitmentLookupCallback_); |
cf6decdf9e15
wrapped new SDK callback: orthanc.RegisterStorageCommitmentScpCallback()
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
187 } |