ctkAppSoapMessageProcessor.cpp 3.2 KB

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