libweave: Buffet includes only weave/include files

External components should include only weave/include files

BUG=brillo:1242
TEST='FEATURES=test emerge-gizmo buffet'

Change-Id: I39edb5662694be23afa2a09aaca39f041e2d009b
Reviewed-on: https://chromium-review.googlesource.com/285673
Trybot-Ready: Vitaly Buka <vitalybuka@chromium.org>
Tested-by: Vitaly Buka <vitalybuka@chromium.org>
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
diff --git a/libweave/src/privet/cloud_delegate.cc b/libweave/src/privet/cloud_delegate.cc
index 1737b10..8f2aefc 100644
--- a/libweave/src/privet/cloud_delegate.cc
+++ b/libweave/src/privet/cloud_delegate.cc
@@ -21,6 +21,7 @@
 #include "libweave/src/commands/command_manager.h"
 #include "libweave/src/device_registration_info.h"
 #include "libweave/src/privet/constants.h"
+#include "libweave/src/registration_status.h"
 #include "libweave/src/states/state_manager.h"
 
 using chromeos::ErrorPtr;
diff --git a/libweave/src/privet/privet_manager.cc b/libweave/src/privet/privet_manager.cc
index 7fe3a78..1c48548 100644
--- a/libweave/src/privet/privet_manager.cc
+++ b/libweave/src/privet/privet_manager.cc
@@ -35,9 +35,7 @@
 #include "libweave/src/privet/device_delegate.h"
 #include "libweave/src/privet/peerd_client.h"
 #include "libweave/src/privet/privet_handler.h"
-#include "libweave/src/privet/security_manager.h"
 #include "libweave/src/privet/shill_client.h"
-#include "libweave/src/privet/wifi_bootstrap_manager.h"
 
 namespace weave {
 namespace privet {
@@ -62,7 +60,7 @@
 Manager::~Manager() {
 }
 
-void Manager::Start(const Options& options,
+void Manager::Start(const Device::Options& options,
                     const scoped_refptr<dbus::Bus>& bus,
                     ShillClient* shill_client,
                     DeviceRegistrationInfo* device,
@@ -123,7 +121,27 @@
   }
 }
 
-void Manager::OnShutdown() {
+std::string Manager::GetCurrentlyConnectedSsid() const {
+  return wifi_bootstrap_manager_
+             ? wifi_bootstrap_manager_->GetCurrentlyConnectedSsid()
+             : "";
+}
+
+void Manager::AddOnWifiSetupChangedCallback(
+    const WifiBootstrapManager::StateListener& callback) {
+  if (wifi_bootstrap_manager_)
+    wifi_bootstrap_manager_->RegisterStateListener(callback);
+  else
+    callback.Run(WifiSetupState::kDisabled);
+}
+
+void Manager::AddOnPairingChangedCallbacks(
+    const SecurityManager::PairingStartListener& on_start,
+    const SecurityManager::PairingEndListener& on_end) {
+  security_->RegisterPairingListeners(on_start, on_end);
+}
+
+void Manager::Shutdown() {
   web_server_->Disconnect();
 }
 
diff --git a/libweave/src/privet/privet_manager.h b/libweave/src/privet/privet_manager.h
index f16330d..3a01f13 100644
--- a/libweave/src/privet/privet_manager.h
+++ b/libweave/src/privet/privet_manager.h
@@ -14,6 +14,9 @@
 #include <base/scoped_observer.h>
 
 #include "libweave/src/privet/cloud_delegate.h"
+#include "libweave/src/privet/security_manager.h"
+#include "libweave/src/privet/wifi_bootstrap_manager.h"
+#include "weave/device.h"
 
 namespace chromeos {
 namespace dbus_utils {
@@ -44,21 +47,13 @@
 class PrivetHandler;
 class SecurityManager;
 class ShillClient;
-class WifiBootstrapManager;
 
 class Manager : public CloudDelegate::Observer {
  public:
-  struct Options {
-    bool disable_privet{false};
-    bool disable_security{false};
-    bool enable_ping{false};
-    base::FilePath config_path;
-  };
-
   Manager();
   ~Manager();
 
-  void Start(const Options& options,
+  void Start(const weave::Device::Options& options,
              const scoped_refptr<dbus::Bus>& bus,
              ShillClient* shill_client,
              DeviceRegistrationInfo* device,
@@ -66,17 +61,21 @@
              StateManager* state_manager,
              chromeos::dbus_utils::AsyncEventSequencer* sequencer);
 
-  void OnShutdown();
+  std::string GetCurrentlyConnectedSsid() const;
 
-  void OnDeviceInfoChanged() override;
+  void AddOnWifiSetupChangedCallback(
+      const WifiBootstrapManager::StateListener& callback);
 
-  privet::WifiBootstrapManager* GetWifiBootstrapManager() {
-    return wifi_bootstrap_manager_.get();
-  }
+  void AddOnPairingChangedCallbacks(
+      const SecurityManager::PairingStartListener& on_start,
+      const SecurityManager::PairingEndListener& on_end);
 
-  privet::SecurityManager* GetSecurityManager() { return security_.get(); }
+  void Shutdown();
 
  private:
+  // CloudDelegate::Observer
+  void OnDeviceInfoChanged() override;
+
   void PrivetRequestHandler(std::unique_ptr<libwebserv::Request> request,
                             std::unique_ptr<libwebserv::Response> response);
 
@@ -88,7 +87,6 @@
                          std::unique_ptr<libwebserv::Response> response);
 
   void OnChanged();
-
   void OnConnectivityChanged(bool online);
 
   void OnProtocolHandlerConnected(
diff --git a/libweave/src/privet/security_delegate.h b/libweave/src/privet/security_delegate.h
index 430e882..57098f6 100644
--- a/libweave/src/privet/security_delegate.h
+++ b/libweave/src/privet/security_delegate.h
@@ -13,17 +13,11 @@
 #include <chromeos/secure_blob.h>
 
 #include "libweave/src/privet/privet_types.h"
+#include "weave/types.h"
 
 namespace weave {
 namespace privet {
 
-enum class PairingType {
-  kPinCode,
-  kEmbeddedCode,
-  kUltrasound32,
-  kAudible32,
-};
-
 enum class CryptoType {
   kNone,
   kSpake_p224,
diff --git a/libweave/src/privet/wifi_bootstrap_manager.cc b/libweave/src/privet/wifi_bootstrap_manager.cc
index ef7096a..487450c 100644
--- a/libweave/src/privet/wifi_bootstrap_manager.cc
+++ b/libweave/src/privet/wifi_bootstrap_manager.cc
@@ -70,7 +70,7 @@
     return;
   }
 
-  UpdateState(kBootstrapping);
+  UpdateState(State::kBootstrapping);
   if (!last_configured_ssid_.empty()) {
     // If we have been configured before, we'd like to periodically take down
     // our AP and find out if we can connect again.  Many kinds of failures are
@@ -94,7 +94,7 @@
                                            const std::string& passphrase) {
   VLOG(1) << "WiFi is attempting to connect. (ssid=" << ssid
           << ", pass=" << passphrase << ").";
-  UpdateState(kConnecting);
+  UpdateState(State::kConnecting);
   base::MessageLoop::current()->PostDelayedTask(
       FROM_HERE, base::Bind(&WifiBootstrapManager::OnConnectTimeout,
                             tasks_weak_factory_.GetWeakPtr()),
@@ -112,27 +112,28 @@
   VLOG(1) << "Monitoring connectivity.";
   // We already have a callback in place with |shill_client_| to update our
   // connectivity state.  See OnConnectivityChange().
-  UpdateState(kMonitoring);
+  UpdateState(State::kMonitoring);
 }
 
 void WifiBootstrapManager::EndMonitoring() {
 }
 
 void WifiBootstrapManager::UpdateState(State new_state) {
-  VLOG(3) << "Switching state from " << state_ << " to " << new_state;
+  VLOG(3) << "Switching state from " << static_cast<int>(state_) << " to "
+          << static_cast<int>(new_state);
   // Abort irrelevant tasks.
   tasks_weak_factory_.InvalidateWeakPtrs();
 
   switch (state_) {
-    case kDisabled:
+    case State::kDisabled:
       break;
-    case kBootstrapping:
+    case State::kBootstrapping:
       EndBootstrapping();
       break;
-    case kMonitoring:
+    case State::kMonitoring:
       EndMonitoring();
       break;
-    case kConnecting:
+    case State::kConnecting:
       EndConnecting();
       break;
   }
@@ -221,11 +222,11 @@
   VLOG(3) << "ConnectivityChanged: " << is_connected;
   UpdateConnectionState();
 
-  if (state_ == kBootstrapping) {
+  if (state_ == State::kBootstrapping) {
     StartMonitoring();
     return;
   }
-  if (state_ == kMonitoring) {
+  if (state_ == State::kMonitoring) {
     if (is_connected) {
       tasks_weak_factory_.InvalidateWeakPtrs();
     } else {
diff --git a/libweave/src/privet/wifi_bootstrap_manager.h b/libweave/src/privet/wifi_bootstrap_manager.h
index 5b51c87..4a68c46 100644
--- a/libweave/src/privet/wifi_bootstrap_manager.h
+++ b/libweave/src/privet/wifi_bootstrap_manager.h
@@ -31,12 +31,7 @@
 class WifiBootstrapManager : public WifiDelegate,
                              public CloudDelegate::Observer {
  public:
-  enum State {
-    kDisabled,
-    kBootstrapping,
-    kMonitoring,
-    kConnecting,
-  };
+  using State = WifiSetupState;
 
   using StateListener = base::Callback<void(State)>;
 
@@ -94,7 +89,7 @@
 
   // Initialization could be delayed if ssid_generator_ is not ready.
   bool is_initialized_{false};
-  State state_{kDisabled};
+  State state_{State::kDisabled};
   // Setup state is the temporal state of the most recent bootstrapping attempt.
   // It is not persisted to disk.
   SetupState setup_state_{SetupState::kNone};