/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
 * Copyright (c) 2014-2017,  Regents of the University of California,
 *                           Arizona Board of Regents,
 *                           Colorado State University,
 *                           University Pierre & Marie Curie, Sorbonne University,
 *                           Washington University in St. Louis,
 *                           Beijing Institute of Technology,
 *                           The University of Memphis.
 *
 * This file is part of NFD (Named Data Networking Forwarding Daemon).
 * See AUTHORS.md for complete list of NFD authors and contributors.
 *
 * NFD is free software: you can redistribute it and/or modify it under the terms
 * of the GNU General Public License as published by the Free Software Foundation,
 * either version 3 of the License, or (at your option) any later version.
 *
 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef NFD_TOOLS_NDN_AUTOCONFIG_BASE_HPP
#define NFD_TOOLS_NDN_AUTOCONFIG_BASE_HPP

#include "core/common.hpp"

#include <ndn-cxx/face.hpp>
#include <ndn-cxx/mgmt/nfd/controller.hpp>
#include <ndn-cxx/mgmt/nfd/face-status.hpp>
#include <ndn-cxx/net/face-uri.hpp>
#include <ndn-cxx/security/key-chain.hpp>

namespace ndn {
namespace tools {
namespace autoconfig {

using ndn::nfd::ControlParameters;
using ndn::nfd::ControlResponse;

/**
 * @brief Base class for discovery stages
 */
class Base : boost::noncopyable
{
public:
  class Error : public std::runtime_error
  {
  public:
    explicit
    Error(const std::string& what)
      : std::runtime_error(what)
    {
    }
  };

  /**
   * @brief Callback to be called when the stage fails
   */
  typedef std::function<void(const std::string&)> NextStageCallback;

  /**
   * @brief Start the stage
   */
  virtual void
  start() = 0;

protected:
  /**
   * @brief Initialize variables and create Controller instance
   * @param face Face to be used for all operations (e.g., will send registration commands)
   * @param keyChain KeyChain object
   * @param nextStageOnFailure Callback to be called after the stage failed
   */
  Base(Face& face, KeyChain& keyChain, const NextStageCallback& nextStageOnFailure);

  /**
   * @brief Attempt to connect to local hub using the \p uri FaceUri
   * @throw Base::Error when failed to establish the tunnel
   */
  void
  connectToHub(const std::string& uri);

private:
  void
  onCanonizeSuccess(const FaceUri& canonicalUri);

  void
  onCanonizeFailure(const std::string& reason);

  void
  onHubConnectSuccess(const ControlParameters& resp);

  void
  onHubConnectError(const ControlResponse& response);

  void
  registerAutoConfigNames(uint64_t faceId);

  void
  registerPrefix(const Name& prefix, uint64_t faceId);

  void
  onPrefixRegistrationSuccess(const ControlParameters& commandSuccessResult);

  void
  onPrefixRegistrationError(const ControlResponse& response);

protected:
  Face& m_face;
  KeyChain& m_keyChain;
  ndn::nfd::Controller m_controller;
  NextStageCallback m_nextStageOnFailure;
};

} // namespace autoconfig
} // namespace tools
} // namespace ndn

#endif // NFD_TOOLS_NDN_AUTOCONFIG_BASE_HPP
