Bladeren bron

ENH: receive return values

ivowolf 14 jaren geleden
bovenliggende
commit
7a9285b5d5

+ 3 - 0
Plugins/org.commontk.dicom.examplehost/ctkDicomExampleHost.cpp

@@ -45,5 +45,8 @@ void ctkDicomExampleHost::notifyStatus(const ctkDicomWG23::Status& status){
 
 ctkDicomExampleHost::~ctkDicomExampleHost()
 {
+  qDebug() << "Exiting host: trying to terminate app";
   this->appProcess.terminate();
+  qDebug() << "Exiting host: trying to kill app";
+  this->appProcess.kill();
 }

+ 10 - 3
Plugins/org.commontk.dicom.wg23.app/ctkDicomAppServerPrivate.cpp

@@ -49,7 +49,7 @@ void ctkDicomAppServerPrivate::incomingSoapMessage(const QtSoapMessage& message,
   const QtSoapType& method = message.method();
   QString methodName = method.name().name();
 
-  qDebug() << "Received soap method request: " << methodName;
+  qDebug() << "AppServer: Received soap method request: " << methodName;
 
   if(appInterface == NULL)
   {
@@ -91,7 +91,11 @@ void ctkDicomAppServerPrivate::processSetState(
     const QtSoapMessage &message, QtSoapMessage *reply)
 {
     const QtSoapType& stateType = message.method()["state"];
-    appInterface->setState(ctkDicomSoapState::getState(stateType));
+    bool result = appInterface->setState(ctkDicomSoapState::getState(stateType));
+  
+    reply->setMethod("SetState");
+    QtSoapType* stateLegal = new ctkDicomSoapBool("stateLegal",result);
+    reply->addMethodArgument(stateLegal);
 }
 
 void ctkDicomAppServerPrivate::processBringToFront(
@@ -100,5 +104,8 @@ void ctkDicomAppServerPrivate::processBringToFront(
    const QtSoapType& requestedScreenAreaType = message.method()["requestedScreenArea"];
    const QRect requestedScreenArea = ctkDicomSoapRectangle::getQRect(requestedScreenAreaType);
 
-   appInterface->bringToFront(requestedScreenArea);
+   reply->setMethod("bringToFront");
+   bool result = appInterface->bringToFront(requestedScreenArea);
+   QtSoapType* received = new ctkDicomSoapBool("received",result);
+   reply->addMethodArgument(received);
 }

+ 8 - 2
Plugins/org.commontk.dicom.wg23.core/ctkDicomServicePrivate.cpp

@@ -40,7 +40,7 @@ void ctkDicomServicePrivate::responseReady()
   blockingLoop.exit();
 }
 
-QtSoapType ctkDicomServicePrivate::askHost(const QString& methodName, QtSoapType* soapType )
+const QtSoapType & ctkDicomServicePrivate::askHost(const QString& methodName, QtSoapType* soapType )
 {
   qDebug() << "Submitting request " << methodName;
 
@@ -75,5 +75,11 @@ QtSoapType ctkDicomServicePrivate::askHost(const QString& methodName, QtSoapType
 
   qDebug() << "Response: " << response.toXmlString();
 
-  return response.returnValue();
+  const QtSoapType &returnValue = response.returnValue();
+
+  qDebug() << " Is returnValue valid:" << returnValue.isValid();
+  qDebug() << " Name of returnValue:" << returnValue.name().name();
+  qDebug() << " Value of returnValue:" << returnValue.value().toString();
+
+  return returnValue;
 }

+ 1 - 1
Plugins/org.commontk.dicom.wg23.core/ctkDicomServicePrivate.h

@@ -35,7 +35,7 @@ class org_commontk_dicom_wg23_core_EXPORT ctkDicomServicePrivate : public QObjec
 public:
   ctkDicomServicePrivate(int port);
 
-  QtSoapType askHost(const QString& methodName, QtSoapType* soapStruct);
+  const QtSoapType & askHost(const QString& methodName, QtSoapType* soapStruct);
     
   QEventLoop blockingLoop;
   QtSoapHttpTransport http;

+ 6 - 7
Plugins/org.commontk.dicom.wg23.host/ctkDicomAppService.cpp

@@ -38,8 +38,7 @@ ctkDicomAppService::~ctkDicomAppService()
 ctkDicomWG23::State ctkDicomAppService::getState()
 {
   Q_D(ctkDicomService);
-
-  QtSoapType result = d->askHost("getState", NULL);
+  const QtSoapType & result = d->askHost("getState", NULL);
   return ctkDicomSoapState::getState(result);
 }
 
@@ -47,14 +46,14 @@ bool ctkDicomAppService::setState(ctkDicomWG23::State newState)
 {
   Q_D(ctkDicomService);
   QtSoapType* input = new ctkDicomSoapState("state", newState);
-  QtSoapType result = d->askHost("setState", input);
+  const QtSoapType & result = d->askHost("setState", input);
   return ctkDicomSoapBool::getBool(result);
 }
 
 bool ctkDicomAppService::bringToFront(const QRect& requestedScreenArea)
 {
-    Q_D(ctkDicomService);
-    QtSoapType* input = new ctkDicomSoapRectangle("requestedScreenArea", requestedScreenArea);
-    QtSoapType result = d->askHost("bringToFront", input);
-    return ctkDicomSoapBool::getBool(result);
+  Q_D(ctkDicomService);
+  QtSoapType* input = new ctkDicomSoapRectangle("requestedScreenArea", requestedScreenArea);
+  const QtSoapType & result = d->askHost("bringToFront", input);
+  return ctkDicomSoapBool::getBool(result);
 }

+ 5 - 6
Plugins/org.commontk.dicom.wg23.host/ctkDicomHostServerPrivate.cpp

@@ -31,7 +31,6 @@
 ctkDicomHostServerPrivate::ctkDicomHostServerPrivate(ctkDicomHostInterface* hostInterface, int port) :
     hostInterface(hostInterface), port(port)
 {
-
   connect(&server, SIGNAL(incomingSoapMessage(QtSoapMessage,QtSoapMessage*)),
           this, SLOT(incomingSoapMessage(QtSoapMessage,QtSoapMessage*)));
 
@@ -47,7 +46,7 @@ void ctkDicomHostServerPrivate::incomingSoapMessage(
   const QtSoapType& method = message.method();
   QString methodName = method.name().name();
 
-  qDebug() << "Received soap method request: " << methodName;
+  qDebug() << "HostServer: Received soap method request: " << methodName;
 
   if (methodName == "getAvailableScreen")
   {
@@ -93,15 +92,15 @@ void ctkDicomHostServerPrivate::processGetAvailableScreen(
 void ctkDicomHostServerPrivate::processNotifyStateChanged(
     const QtSoapMessage &message, QtSoapMessage * /* reply */) const
 {
-    const QtSoapType& stateType = message.method()["state"];
-    hostInterface->notifyStateChanged(ctkDicomSoapState::getState(stateType));
+  const QtSoapType& stateType = message.method()["state"];
+  hostInterface->notifyStateChanged(ctkDicomSoapState::getState(stateType));
 }
 
 void ctkDicomHostServerPrivate::processNotifyStatus(
     const QtSoapMessage &message, QtSoapMessage * /* reply */) const
 {
-    const QtSoapType& status = message.method()["status"];
-    hostInterface->notifyStatus(ctkDicomSoapStatus::getStatus(status));
+  const QtSoapType& status = message.method()["status"];
+  hostInterface->notifyStatus(ctkDicomSoapStatus::getStatus(status));
 }
 
 void ctkDicomHostServerPrivate::processGenerateUID(