ctkAppSoapMessageProcessor.cpp 3.2 KB

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