ctkAppSoapMessageProcessor.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 "ctkAppSoapMessageProcessor.h"
  16. #include <ctkDicomAppHostingTypesHelper.h>
  17. //----------------------------------------------------------------------------
  18. ctkAppSoapMessageProcessor::ctkAppSoapMessageProcessor(ctkDicomAppInterface* inter)
  19. : AppInterface(inter)
  20. {}
  21. //----------------------------------------------------------------------------
  22. bool ctkAppSoapMessageProcessor::process(
  23. const QtSoapMessage& message, QtSoapMessage* reply ) const
  24. {
  25. // TODO check for NULL appInterface?
  26. const QtSoapType& method = message.method();
  27. QString methodName = method.name().name();
  28. qDebug() << "AppMessageProcessor: Received soap method request: " << methodName;
  29. bool foundMethod = false;
  30. if (methodName == "GetState")
  31. {
  32. processGetState(message, reply);
  33. foundMethod = true;
  34. }
  35. else if (methodName == "SetState")
  36. {
  37. processSetState(message, reply);
  38. foundMethod = true;
  39. }
  40. else if (methodName == "BringToFront")
  41. {
  42. processBringToFront(message, reply);
  43. foundMethod = true;
  44. }
  45. return foundMethod;
  46. }
  47. //----------------------------------------------------------------------------
  48. void ctkAppSoapMessageProcessor::processGetState(
  49. const QtSoapMessage &message, QtSoapMessage *reply) const
  50. {
  51. Q_UNUSED(message)
  52. // extract arguments from input message: nothing to be done
  53. // query interface
  54. const ctkDicomAppHosting::State result = this->AppInterface->getState();
  55. // set reply message
  56. reply->setMethod("GetStateResponse");
  57. QtSoapSimpleType* resultType = new ctkDicomSoapState("GetStateResult",result);
  58. reply->addMethodArgument(resultType);
  59. }
  60. //----------------------------------------------------------------------------
  61. void ctkAppSoapMessageProcessor::processSetState(
  62. const QtSoapMessage &message, QtSoapMessage *reply) const
  63. {
  64. // extract arguments from input message
  65. const QtSoapType& inputType = message.method()["state"];
  66. // query interface
  67. bool result = this->AppInterface->setState(ctkDicomSoapState::getState(inputType));
  68. // set reply message
  69. reply->setMethod("SetStateResponse");
  70. QtSoapType* resultType = new ctkDicomSoapBool("SetStateResult",result);
  71. reply->addMethodArgument(resultType);
  72. }
  73. //----------------------------------------------------------------------------
  74. void ctkAppSoapMessageProcessor::processBringToFront(
  75. const QtSoapMessage &message, QtSoapMessage *reply) const
  76. {
  77. // extract arguments from input message
  78. const QtSoapType& inputType = message.method()["RequestedScreenArea"];
  79. const QRect requestedScreenArea = ctkDicomSoapRectangle::getQRect(inputType);
  80. // query interface
  81. bool result = this->AppInterface->bringToFront(requestedScreenArea);
  82. // set reply message
  83. reply->setMethod("BringToFrontResponse");
  84. QtSoapType* resultType = new ctkDicomSoapBool("BringToFrontResult",result);
  85. reply->addMethodArgument(resultType);
  86. }