comparison 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
comparison
equal deleted inserted replaced
3:9bcd6eadcff5 4:1ed03945c057
577 { 577 {
578 OrthancPluginSendMethodNotAllowed(context.GetOrthanc(), output, "GET"); 578 OrthancPluginSendMethodNotAllowed(context.GetOrthanc(), output, "GET");
579 return; 579 return;
580 } 580 }
581 581
582 std::set<std::string> activePeers; 582 OrthancPlugins::DetectTransferPlugin::Peers peers;
583 OrthancPlugins::DetectTransferPlugin::Apply 583 OrthancPlugins::DetectTransferPlugin::Apply
584 (activePeers, context.GetOrthanc(), context.GetThreadsCount(), 2 /* timeout */); 584 (peers, context.GetOrthanc(), context.GetThreadsCount(), 2 /* timeout */);
585 585
586 Json::Value result = Json::arrayValue; 586 Json::Value result = Json::objectValue;
587 587
588 for (std::set<std::string>::const_iterator 588 for (OrthancPlugins::DetectTransferPlugin::Peers::const_iterator
589 it = activePeers.begin(); it != activePeers.end(); ++it) 589 it = peers.begin(); it != peers.end(); ++it)
590 { 590 {
591 result.append(*it); 591 switch (it->second)
592 {
593 case OrthancPlugins::PeerCapabilities_Disabled:
594 result[it->first] = "disabled";
595 break;
596
597 case OrthancPlugins::PeerCapabilities_Installed:
598 {
599 std::string remoteSelf;
600
601 if (context.LookupBidirectionalPeer(remoteSelf, it->first))
602 {
603 result[it->first] = "installed";
604 }
605 else
606 {
607 result[it->first] = "bidirectional";
608 }
609 break;
610 }
611
612 default:
613 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
614 }
592 } 615 }
593 616
594 std::string s = result.toStyledString(); 617 std::string s = result.toStyledString();
595 OrthancPluginAnswerBuffer(context.GetOrthanc(), output, s.c_str(), s.size(), "application/json"); 618 OrthancPluginAnswerBuffer(context.GetOrthanc(), output, s.c_str(), s.size(), "application/json");
596 } 619 }