Пример #1
0
//----------------------------------------------------------------------------
bool ctkAppSoapMessageProcessor::process(
  const QtSoapMessage& message, QtSoapMessage* reply ) const
{
  // TODO check for NULL appInterface?
  
  const QtSoapType& method = message.method();
  QString methodName = method.name().name();

  qDebug() << "AppMessageProcessor: Received soap method request: " << methodName;

  bool foundMethod = false;
  
  if (methodName == "GetState")
    {
    processGetState(message, reply);
    foundMethod = true;
    }
  else if (methodName == "SetState")
    {
    processSetState(message, reply);
    foundMethod = true;
    }
  else if (methodName == "BringToFront")
    {
    processBringToFront(message, reply);
    foundMethod = true;
    }
  
  return foundMethod;
}
//----------------------------------------------------------------------------
void ctkExchangeSoapMessageProcessor::processGetData(
    const QtSoapMessage &message, QtSoapMessage *reply) const
{
  // extract arguments from input message
  const QtSoapType& inputType = message.method()["objectUUIDs"];
  const QList<QUuid> objectUUIDs = ctkDicomSoapArrayOfUUIDS::getArray(inputType);
  const QtSoapType& inputType2 = message.method()["acceptableTransferSyntaxUIDs"];
  const QStringList acceptableTransferSyntaxUIDs = ctkDicomSoapArrayOfStringType::getArray(inputType2);
  const QtSoapType& inputType3 = message.method()["includeBulkData"];
  const bool includeBulkData = ctkDicomSoapBool::getBool(inputType3);
  // query interface
  const QList<ctkDicomAppHosting::ObjectLocator> result = exchangeInterface->getData(
    objectUUIDs, acceptableTransferSyntaxUIDs, includeBulkData);
  // set reply message
  reply->setMethod("getData");
  QtSoapType* resultType = new ctkDicomSoapArrayOfObjectLocators("arrayOfObjectLocator", result);
  reply->addMethodArgument(resultType);
}
void ctkHostSoapMessageProcessor::processNotifyStatus(
    const QtSoapMessage &message, QtSoapMessage * /* reply */) const
{
  // extract arguments from input message
  const QtSoapType& inputType = message.method()["status"];
  // query interface
  hostInterface->notifyStatus(ctkDicomSoapStatus::getStatus(inputType));
  // set reply message: nothing to be done
}
void ctkHostSoapMessageProcessor::processNotifyStateChanged(
    const QtSoapMessage &message, QtSoapMessage * /* reply */) const
{
  // extract arguments from input message
  const QtSoapType& inputType = message.method()[0];//["state"]; java sends ["newState"]; FIX JAVA/STANDARD
  // query interface
  hostInterface->notifyStateChanged(ctkDicomSoapState::getState(inputType));
  // set reply message: nothing to be done
}
//----------------------------------------------------------------------------
void ctkExchangeSoapMessageProcessor::processReleaseData(
    const QtSoapMessage &message, QtSoapMessage * /*reply*/) const
{
  // extract arguments from input message
  const QtSoapType& inputType = message.method()["objectUUIDs"];
  const QList<QUuid> objectUUIDs = ctkDicomSoapArrayOfUUIDS::getArray(
    dynamic_cast<const QtSoapArray&>(inputType));
  // query interface
  exchangeInterface->releaseData(objectUUIDs);
  // set reply message: nothing to be done
}
void ctkAppSoapMessageProcessor::processSetState(
  const QtSoapMessage &message, QtSoapMessage *reply) const
{
  // extract arguments from input message
  const QtSoapType& inputType = message.method()["newState"];
  // query interface
  bool result = appInterface->setState(ctkDicomSoapState::getState(inputType));
  // set reply message
  reply->setMethod("setState");
  QtSoapType* resultType = new ctkDicomSoapBool("setStateResponse",result);
  reply->addMethodArgument(resultType);
}
void ctkAppSoapMessageProcessor::processBringToFront(
  const QtSoapMessage &message, QtSoapMessage *reply) const
{
  // extract arguments from input message
  const QtSoapType& inputType = message.method()["requestedScreenArea"];
  const QRect requestedScreenArea = ctkDicomSoapRectangle::getQRect(inputType);
  // query interface
  bool result = appInterface->bringToFront(requestedScreenArea);
  // set reply message
  reply->setMethod("bringToFront");
  QtSoapType* resultType = new ctkDicomSoapBool("bringToFrontResponse",result);
  reply->addMethodArgument(resultType);
}
//----------------------------------------------------------------------------
void ctkExchangeSoapMessageProcessor::processNotifyDataAvailable(
  const QtSoapMessage &message, QtSoapMessage *reply) const
{
  // extract arguments from input message
  const QtSoapType& inputType = message.method()[0];//"availableData"];
  if(inputType.isValid()==false)
    {
    qCritical() << "  NotifyDataAvailable: availableData not valid. " << inputType.errorString();
    }
  CTK_SOAP_LOG( << inputType.toString());
  const ctkDicomAppHosting::AvailableData data = ctkDicomSoapAvailableData::getAvailableData(inputType);
  const QtSoapType& inputType2 = message.method()["lastData"];
  const bool lastData = ctkDicomSoapBool::getBool(inputType2);

  CTK_SOAP_LOG_HIGHLEVEL( << "  NotifyDataAvailable: patients.count: " << data.patients.count());
  // query interface
  bool result = exchangeInterface->notifyDataAvailable(data, lastData);
  // set reply message
  reply->setMethod("notifyDataAvailable");
  QtSoapType* resultType = new ctkDicomSoapBool("dataAvailable",result);
  reply->addMethodArgument(resultType);
}
void ctkHostSoapMessageProcessor::processGetAvailableScreen(
    const QtSoapMessage &message, QtSoapMessage *reply) const
{
  // extract arguments from input message
  const QtSoapType& inputType = message.method()["preferredScreen"];
  const QRect preferredScreen = ctkDicomSoapRectangle::getQRect(inputType);
  // query interface
  const QRect result = hostInterface->getAvailableScreen(preferredScreen);
  // set reply message
  reply->setMethod("getAvailableScreenResponse");
  QtSoapStruct* returnType = new ctkDicomSoapRectangle("availableScreen",result);
  reply->addMethodArgument(returnType);
}
void ctkHostSoapMessageProcessor::processGetOutputLocation(
  const QtSoapMessage& message, QtSoapMessage* reply) const
{
  // extract arguments from input message
  const QtSoapType& inputType = message.method()["preferredProtocols"];
  const QStringList preferredProtocols = ctkDicomSoapArrayOfStringType::getArray(
    dynamic_cast<const QtSoapArray&>(inputType));
  // query interface
  const QString result = hostInterface->getOutputLocation(preferredProtocols);
  // set reply message
  reply->setMethod("getOutputLocation");
  QtSoapType* resultType = new QtSoapSimpleType( QtSoapQName("preferredProtocols"), result );
  reply->addMethodArgument(resultType);
}
bool ctkHostSoapMessageProcessor::process(
	const QtSoapMessage& message,
	QtSoapMessage* reply ) const
{
  // TODO check for NULL hostInterface?
  
  const QtSoapType& method = message.method();
  QString methodName = method.name().name();

  qDebug() << "HostMessageProcessor: Received soap method request: " << methodName;

  bool foundMethod = false;
  
  if (methodName == "getAvailableScreen")
  {
    processGetAvailableScreen(message, reply);
    foundMethod = true;
  }
  else if (methodName == "notifyStateChanged")
  {
    processNotifyStateChanged(message, reply);
    foundMethod = true;
  }
  else if (methodName == "notifyStatus")
  {
    processNotifyStatus(message, reply);
    foundMethod = true;
  }
  else if (methodName == "generateUID")
  {
    processGenerateUID(message, reply);
    foundMethod = true;
  }
  else if (methodName == "getOutputLocation")
  {
    processGetOutputLocation(message, reply);
    foundMethod = true;
  }
  
  return foundMethod;
}