diff Plugin/Plugin.cpp @ 4:1ed03945c057

showing unavailable peers
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 17 Sep 2018 14:42:57 +0200
parents 95226b754d9e
children 5e6de82bb10f
line wrap: on
line diff
--- a/Plugin/Plugin.cpp	Mon Sep 17 12:14:20 2018 +0200
+++ b/Plugin/Plugin.cpp	Mon Sep 17 14:42:57 2018 +0200
@@ -579,16 +579,39 @@
     return;
   }
 
-  std::set<std::string> activePeers;
+  OrthancPlugins::DetectTransferPlugin::Peers peers;
   OrthancPlugins::DetectTransferPlugin::Apply
-    (activePeers, context.GetOrthanc(), context.GetThreadsCount(), 2 /* timeout */);
+    (peers, context.GetOrthanc(), context.GetThreadsCount(), 2 /* timeout */);
+
+  Json::Value result = Json::objectValue;
+
+  for (OrthancPlugins::DetectTransferPlugin::Peers::const_iterator
+         it = peers.begin(); it != peers.end(); ++it)
+  {
+    switch (it->second)
+    {
+      case OrthancPlugins::PeerCapabilities_Disabled:
+        result[it->first] = "disabled";
+        break;
 
-  Json::Value result = Json::arrayValue;
+      case OrthancPlugins::PeerCapabilities_Installed:
+      {
+        std::string remoteSelf;
 
-  for (std::set<std::string>::const_iterator
-         it = activePeers.begin(); it != activePeers.end(); ++it)
-  {
-    result.append(*it);
+        if (context.LookupBidirectionalPeer(remoteSelf, it->first))
+        {    
+          result[it->first] = "installed";
+        }
+        else
+        {
+          result[it->first] = "bidirectional";
+        }
+        break;
+      }
+
+      default:
+        throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
+    }
   }
 
   std::string s = result.toStyledString();