tools: refactor ndn-autoconfig

Hub face creation and prefix registrations are moved into a new
Procedure class. Main function is simplified.

refs #4158

Change-Id: I15b660e3b8a1bde89498a1cb549a87788de46c7a
diff --git a/tools/ndn-autoconfig/ndn-fch-discovery.cpp b/tools/ndn-autoconfig/ndn-fch-discovery.cpp
index 6f043a3..01c169e 100644
--- a/tools/ndn-autoconfig/ndn-fch-discovery.cpp
+++ b/tools/ndn-autoconfig/ndn-fch-discovery.cpp
@@ -132,19 +132,14 @@
   }
 };
 
-NdnFchDiscovery::NdnFchDiscovery(Face& face, KeyChain& keyChain,
-                                 const std::string& url,
-                                 const NextStageCallback& nextStageOnFailure)
-  : Stage(face, keyChain, nextStageOnFailure)
-  , m_url(url)
+NdnFchDiscovery::NdnFchDiscovery(const std::string& url)
+  : m_url(url)
 {
 }
 
 void
-NdnFchDiscovery::start()
+NdnFchDiscovery::doStart()
 {
-  std::cerr << "Trying NDN-FCH service..." << std::endl;
-
   try {
     using namespace boost::asio::ip;
     tcp::iostream requestStream;
@@ -205,10 +200,10 @@
       BOOST_THROW_EXCEPTION(HttpException("NDN-FCH did not return hub host"));
     }
 
-    this->connectToHub("udp://" + hubHost);
+    this->provideHubFaceUri("udp://" + hubHost);
   }
   catch (const std::runtime_error& e) {
-    m_nextStageOnFailure(std::string("Failed to find NDN router using NDN-FCH service (") + e.what() + ")");
+    this->fail(e.what());
   }
 }