ctkHostSoapMessageProcessor.cpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) 2010 German Cancer Research Center,
  4. Division of Medical and Biological Informatics
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================================*/
  15. #include "ctkHostSoapMessageProcessor.h"
  16. #include <ctkDicomWG23TypesHelper.h>
  17. #include "ctkPluginContext.h"
  18. #include "ctkDicomWG23HostPlugin_p.h"
  19. ctkHostSoapMessageProcessor::ctkHostSoapMessageProcessor( ctkDicomHostInterface* inter )
  20. : hostInterface(inter)
  21. {}
  22. bool ctkHostSoapMessageProcessor::process(
  23. const QtSoapMessage& message,
  24. QtSoapMessage* reply ) const
  25. {
  26. // TODO check for NULL hostInterface?
  27. const QtSoapType& method = message.method();
  28. QString methodName = method.name().name();
  29. qDebug() << "HostMessageProcessor: Received soap method request: " << methodName;
  30. bool foundMethod = false;
  31. if (methodName == "getAvailableScreen")
  32. {
  33. processGetAvailableScreen(message, reply);
  34. foundMethod = true;
  35. }
  36. else if (methodName == "notifyStateChanged")
  37. {
  38. processNotifyStateChanged(message, reply);
  39. foundMethod = true;
  40. }
  41. else if (methodName == "notifyStatus")
  42. {
  43. processNotifyStatus(message, reply);
  44. foundMethod = true;
  45. }
  46. else if (methodName == "generateUID")
  47. {
  48. processGenerateUID(message, reply);
  49. foundMethod = true;
  50. }
  51. else if (methodName == "getOutputLocation")
  52. {
  53. processGetOutputLocation(message, reply);
  54. foundMethod = true;
  55. }
  56. return foundMethod;
  57. }
  58. void ctkHostSoapMessageProcessor::processGetAvailableScreen(
  59. const QtSoapMessage &message, QtSoapMessage *reply) const
  60. {
  61. // extract arguments from input message
  62. const QtSoapType& inputType = message.method()["preferredScreen"];
  63. const QRect preferredScreen = ctkDicomSoapRectangle::getQRect(inputType);
  64. // query interface
  65. const QRect result = hostInterface->getAvailableScreen(preferredScreen);
  66. // set reply message
  67. reply->setMethod("getAvailableScreenResponse");
  68. QtSoapStruct* returnType = new ctkDicomSoapRectangle("availableScreen",result);
  69. reply->addMethodArgument(returnType);
  70. }
  71. void ctkHostSoapMessageProcessor::processNotifyStateChanged(
  72. const QtSoapMessage &message, QtSoapMessage * /* reply */) const
  73. {
  74. // extract arguments from input message
  75. const QtSoapType& inputType = message.method()["state"];
  76. // query interface
  77. hostInterface->notifyStateChanged(ctkDicomSoapState::getState(inputType));
  78. // set reply message: nothing to be done
  79. }
  80. void ctkHostSoapMessageProcessor::processNotifyStatus(
  81. const QtSoapMessage &message, QtSoapMessage * /* reply */) const
  82. {
  83. // extract arguments from input message
  84. const QtSoapType& inputType = message.method()["status"];
  85. // query interface
  86. hostInterface->notifyStatus(ctkDicomSoapStatus::getStatus(inputType));
  87. // set reply message: nothing to be done
  88. }
  89. void ctkHostSoapMessageProcessor::processGenerateUID(
  90. const QtSoapMessage& message, QtSoapMessage* reply) const
  91. {
  92. // extract arguments from input message: nothing to be done
  93. // query interface
  94. const QString uid = hostInterface->generateUID();
  95. // set reply message
  96. reply->setMethod("generateUID");
  97. QtSoapType* resultType = new ctkDicomSoapUID("uid",uid);
  98. reply->addMethodArgument(resultType);
  99. }
  100. void ctkHostSoapMessageProcessor::processGetOutputLocation(
  101. const QtSoapMessage& message, QtSoapMessage* reply) const
  102. {
  103. // extract arguments from input message
  104. const QtSoapType& inputType = message.method()["preferredProtocols"];
  105. const QStringList* preferredProtocols = ctkDicomSoapArrayOfStringType::getArray(
  106. dynamic_cast<const QtSoapArray&>(inputType));
  107. // query interface
  108. const QString result = hostInterface->getOutputLocation(*preferredProtocols);
  109. // set reply message
  110. reply->setMethod("getOutputLocation");
  111. QtSoapType* resultType = new QtSoapSimpleType( QtSoapQName("preferredProtocols"), result );
  112. reply->addMethodArgument(resultType);
  113. }