ctkHostSoapMessageProcessor.cpp 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. //----------------------------------------------------------------------------
  18. ctkHostSoapMessageProcessor::ctkHostSoapMessageProcessor( ctkDicomHostInterface* inter )
  19. : HostInterface(inter)
  20. {}
  21. //----------------------------------------------------------------------------
  22. bool ctkHostSoapMessageProcessor::process(
  23. const QtSoapMessage& message, QtSoapMessage* reply ) const
  24. {
  25. // TODO check for NULL hostInterface?
  26. const QtSoapType& method = message.method();
  27. QString methodName = method.name().name();
  28. qDebug() << "HostMessageProcessor: Received soap method request: " << methodName;
  29. bool foundMethod = false;
  30. if (methodName == "GetAvailableScreen")
  31. {
  32. processGetAvailableScreen(message, reply);
  33. foundMethod = true;
  34. }
  35. else if (methodName == "NotifyStateChanged")
  36. {
  37. processNotifyStateChanged(message, reply);
  38. foundMethod = true;
  39. }
  40. else if (methodName == "NotifyStatus")
  41. {
  42. processNotifyStatus(message, reply);
  43. foundMethod = true;
  44. }
  45. else if (methodName == "GenerateUID")
  46. {
  47. processGenerateUID(message, reply);
  48. foundMethod = true;
  49. }
  50. else if (methodName == "GetOutputLocation")
  51. {
  52. processGetOutputLocation(message, reply);
  53. foundMethod = true;
  54. }
  55. return foundMethod;
  56. }
  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 = this->HostInterface->getAvailableScreen(preferredScreen);
  66. // set reply message
  67. reply->setMethod("GetAvailableScreenResponse");
  68. QtSoapStruct* returnType = new ctkDicomSoapRectangle("AvailableScreen",result);
  69. reply->addMethodArgument(returnType);
  70. }
  71. //----------------------------------------------------------------------------
  72. void ctkHostSoapMessageProcessor::processNotifyStateChanged(
  73. const QtSoapMessage &message, QtSoapMessage *reply) const
  74. {
  75. // extract arguments from input message
  76. const QtSoapType& inputType = message.method()[0];//["state"]; java sends ["newState"]; FIX JAVA/STANDARD
  77. // query interface
  78. this->HostInterface->notifyStateChanged(ctkDicomSoapState::getState(inputType));
  79. // set reply message: nothing to be done
  80. /*bool result = true;
  81. reply->setMethod("NotifyStateChanged");
  82. QtSoapType* resultType = new ctkDicomSoapBool("NotifyStateChangedResponse",result);
  83. reply->addMethodArgument(resultType);*/
  84. }
  85. //----------------------------------------------------------------------------
  86. void ctkHostSoapMessageProcessor::processNotifyStatus(
  87. const QtSoapMessage &message, QtSoapMessage *reply) const
  88. {
  89. // extract arguments from input message
  90. const QtSoapType& inputType = message.method()["status"];
  91. // query interface
  92. this->HostInterface->notifyStatus(ctkDicomSoapStatus::getStatus(inputType));
  93. // set reply message: nothing to be done
  94. /*bool result = true;
  95. reply->setMethod("NotifyStatus");
  96. QtSoapType* resultType = new ctkDicomSoapBool("NotifyStatusResponse",result);
  97. reply->addMethodArgument(resultType);*/
  98. }
  99. //----------------------------------------------------------------------------
  100. void ctkHostSoapMessageProcessor::processGenerateUID(
  101. const QtSoapMessage& message, QtSoapMessage* reply) const
  102. {
  103. Q_UNUSED(message)
  104. // extract arguments from input message: nothing to be done
  105. // query interface
  106. const QString uid = this->HostInterface->generateUID();
  107. // set reply message
  108. reply->setMethod("GenerateUID");
  109. QtSoapType* resultType = new ctkDicomSoapUID("uid",uid);
  110. reply->addMethodArgument(resultType);
  111. }
  112. //----------------------------------------------------------------------------
  113. void ctkHostSoapMessageProcessor::processGetOutputLocation(
  114. const QtSoapMessage& message, QtSoapMessage* reply) const
  115. {
  116. // extract arguments from input message
  117. //const QtSoapType& inputType = message.method()["preferredProtocols"];
  118. //const QStringList preferredProtocols = ctkDicomSoapArrayOfStringType::getArray(
  119. //dynamic_cast<const QtSoapArray&>(inputType));
  120. const QtSoapType& inputType = message.method()["preferredProtocols"];
  121. const QStringList preferredProtocols = ctkDicomSoapArrayOfStringType::getArray(inputType);
  122. // query interface
  123. const QString result = this->HostInterface->getOutputLocation(preferredProtocols);
  124. // set reply message
  125. reply->setMethod("GetOutputLocation");
  126. QtSoapType* resultType = new QtSoapSimpleType( QtSoapQName("preferredProtocols"), result );
  127. reply->addMethodArgument(resultType);
  128. }