ctkAppSoapMessageProcessor.cpp 3.2 KB

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