ctkHostSoapMessageProcessor.cpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) 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_p.h"
  16. #include <ctkDicomAppHostingTypesHelper.h>
  17. ctkHostSoapMessageProcessor::ctkHostSoapMessageProcessor( ctkDicomHostInterface* inter )
  18. : hostInterface(inter)
  19. {}
  20. bool ctkHostSoapMessageProcessor::process(
  21. const QtSoapMessage& message,
  22. QtSoapMessage* reply ) const
  23. {
  24. // TODO check for NULL hostInterface?
  25. const QtSoapType& method = message.method();
  26. QString methodName = method.name().name();
  27. qDebug() << "HostMessageProcessor: Received soap method request: " << methodName;
  28. bool foundMethod = false;
  29. if (methodName == "getAvailableScreen")
  30. {
  31. processGetAvailableScreen(message, reply);
  32. foundMethod = true;
  33. }
  34. else if (methodName == "notifyStateChanged")
  35. {
  36. processNotifyStateChanged(message, reply);
  37. foundMethod = true;
  38. }
  39. else if (methodName == "notifyStatus")
  40. {
  41. processNotifyStatus(message, reply);
  42. foundMethod = true;
  43. }
  44. else if (methodName == "generateUID")
  45. {
  46. processGenerateUID(message, reply);
  47. foundMethod = true;
  48. }
  49. else if (methodName == "getOutputLocation")
  50. {
  51. processGetOutputLocation(message, reply);
  52. foundMethod = true;
  53. }
  54. return foundMethod;
  55. }
  56. void ctkHostSoapMessageProcessor::processGetAvailableScreen(
  57. const QtSoapMessage &message, QtSoapMessage *reply) const
  58. {
  59. // extract arguments from input message
  60. const QtSoapType& inputType = message.method()["preferredScreen"];
  61. const QRect preferredScreen = ctkDicomSoapRectangle::getQRect(inputType);
  62. // query interface
  63. const QRect result = hostInterface->getAvailableScreen(preferredScreen);
  64. // set reply message
  65. reply->setMethod("getAvailableScreenResponse");
  66. QtSoapStruct* returnType = new ctkDicomSoapRectangle("availableScreen",result);
  67. reply->addMethodArgument(returnType);
  68. }
  69. void ctkHostSoapMessageProcessor::processNotifyStateChanged(
  70. const QtSoapMessage &message, QtSoapMessage * /* reply */) const
  71. {
  72. // extract arguments from input message
  73. const QtSoapType& inputType = message.method()[0];//["state"]; java sends ["newState"]; FIX JAVA/STANDARD
  74. // query interface
  75. hostInterface->notifyStateChanged(ctkDicomSoapState::getState(inputType));
  76. // set reply message: nothing to be done
  77. }
  78. void ctkHostSoapMessageProcessor::processNotifyStatus(
  79. const QtSoapMessage &message, QtSoapMessage * /* reply */) const
  80. {
  81. // extract arguments from input message
  82. const QtSoapType& inputType = message.method()["status"];
  83. // query interface
  84. hostInterface->notifyStatus(ctkDicomSoapStatus::getStatus(inputType));
  85. // set reply message: nothing to be done
  86. }
  87. void ctkHostSoapMessageProcessor::processGenerateUID(
  88. const QtSoapMessage& message, QtSoapMessage* reply) const
  89. {
  90. Q_UNUSED(message)
  91. // extract arguments from input message: nothing to be done
  92. // query interface
  93. const QString uid = hostInterface->generateUID();
  94. // set reply message
  95. reply->setMethod("generateUID");
  96. QtSoapType* resultType = new ctkDicomSoapUID("uid",uid);
  97. reply->addMethodArgument(resultType);
  98. }
  99. void ctkHostSoapMessageProcessor::processGetOutputLocation(
  100. const QtSoapMessage& message, QtSoapMessage* reply) const
  101. {
  102. // extract arguments from input message
  103. const QtSoapType& inputType = message.method()["preferredProtocols"];
  104. const QStringList preferredProtocols = ctkDicomSoapArrayOfStringType::getArray(
  105. dynamic_cast<const QtSoapArray&>(inputType));
  106. // query interface
  107. const QString result = hostInterface->getOutputLocation(preferredProtocols);
  108. // set reply message
  109. reply->setMethod("getOutputLocation");
  110. QtSoapType* resultType = new QtSoapSimpleType( QtSoapQName("preferredProtocols"), result );
  111. reply->addMethodArgument(resultType);
  112. }