Remove weave::Privet interface Methods moved into weave::Device BUG:24267885 Change-Id: Id400faff1db457ad1a4911c8c8c5d4118f03deb4 Reviewed-on: https://weave-review.googlesource.com/1216 Reviewed-by: Alex Vakulenko <avakulenko@google.com>
diff --git a/libweave/include/weave/device.h b/libweave/include/weave/device.h index edc2075..5517d10 100644 --- a/libweave/include/weave/device.h +++ b/libweave/include/weave/device.h
@@ -12,7 +12,6 @@ #include <weave/cloud.h> #include <weave/commands.h> #include <weave/export.h> -#include <weave/privet.h> #include <weave/provider/bluetooth.h> #include <weave/provider/config_store.h> #include <weave/provider/dns_service_discovery.h> @@ -27,10 +26,6 @@ class Device { public: - // Callback type for AddSettingsChangedCallback. - using SettingsChangedCallback = - base::Callback<void(const Settings& settings)>; - virtual ~Device() = default; virtual void Start(provider::ConfigStore* config_store, @@ -45,6 +40,9 @@ // Returns reference the current settings. virtual const Settings& GetSettings() = 0; + // Callback type for AddSettingsChangedCallback. + using SettingsChangedCallback = + base::Callback<void(const Settings& settings)>; // Subscribes to notification settings changes. virtual void AddSettingsChangedCallback( const SettingsChangedCallback& callback) = 0; @@ -52,7 +50,19 @@ virtual Commands* GetCommands() = 0; virtual State* GetState() = 0; virtual Cloud* GetCloud() = 0; - virtual Privet* GetPrivet() = 0; + + // Handler should display pin code to the user. + using PairingBeginCallback = + base::Callback<void(const std::string& session_id, + PairingType pairing_type, + const std::vector<uint8_t>& code)>; + // Handler should stop displaying pin code. + using PairingEndCallback = + base::Callback<void(const std::string& session_id)>; + // Subscribes to notification about client pairing events. + virtual void AddPairingChangedCallbacks( + const PairingBeginCallback& begin_callback, + const PairingEndCallback& end_callback) = 0; LIBWEAVE_EXPORT static std::unique_ptr<Device> Create(); };
diff --git a/libweave/include/weave/privet.h b/libweave/include/weave/privet.h deleted file mode 100644 index 25f15a4..0000000 --- a/libweave/include/weave/privet.h +++ /dev/null
@@ -1,35 +0,0 @@ -// Copyright 2015 The Chromium OS Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef LIBWEAVE_INCLUDE_WEAVE_PRIVET_H_ -#define LIBWEAVE_INCLUDE_WEAVE_PRIVET_H_ - -#include <string> -#include <vector> - -#include <base/callback.h> -#include <weave/settings.h> - -namespace weave { - -class Privet { - public: - using OnPairingStartedCallback = - base::Callback<void(const std::string& session_id, - PairingType pairing_type, - const std::vector<uint8_t>& code)>; - using OnPairingEndedCallback = - base::Callback<void(const std::string& session_id)>; - - virtual void AddOnPairingChangedCallbacks( - const OnPairingStartedCallback& on_start, - const OnPairingEndedCallback& on_end) = 0; - - protected: - virtual ~Privet() = default; -}; - -} // namespace weave - -#endif // LIBWEAVE_INCLUDE_WEAVE_PRIVET_H_
diff --git a/libweave/src/device_manager.cc b/libweave/src/device_manager.cc index ff19082..c2712e8 100644 --- a/libweave/src/device_manager.cc +++ b/libweave/src/device_manager.cc
@@ -88,10 +88,6 @@ return device_info_.get(); } -Privet* DeviceManager::GetPrivet() { - return privet_.get(); -} - void DeviceManager::StartPrivet(provider::TaskRunner* task_runner, provider::Network* network, provider::DnsServiceDiscovery* dns_sd, @@ -104,6 +100,12 @@ state_manager_.get()); } +void DeviceManager::AddPairingChangedCallbacks( + const PairingBeginCallback& begin_callback, + const PairingEndCallback& end_callback) { + privet_->AddOnPairingChangedCallbacks(begin_callback, end_callback); +} + std::unique_ptr<Device> Device::Create() { return std::unique_ptr<Device>{new DeviceManager}; }
diff --git a/libweave/src/device_manager.h b/libweave/src/device_manager.h index de294e7..6f68054 100644 --- a/libweave/src/device_manager.h +++ b/libweave/src/device_manager.h
@@ -41,7 +41,9 @@ Commands* GetCommands() override; State* GetState() override; Cloud* GetCloud() override; - Privet* GetPrivet() override; + void AddPairingChangedCallbacks( + const PairingBeginCallback& begin_callback, + const PairingEndCallback& end_callback) override; Config* GetConfig();
diff --git a/libweave/src/privet/privet_manager.h b/libweave/src/privet/privet_manager.h index 3881971..35fb6f9 100644 --- a/libweave/src/privet/privet_manager.h +++ b/libweave/src/privet/privet_manager.h
@@ -42,7 +42,7 @@ class Publisher; class SecurityManager; -class Manager : public Privet, public CloudDelegate::Observer { +class Manager : public CloudDelegate::Observer { public: Manager(); ~Manager() override; @@ -59,8 +59,8 @@ std::string GetCurrentlyConnectedSsid() const; void AddOnPairingChangedCallbacks( - const OnPairingStartedCallback& on_start, - const OnPairingEndedCallback& on_end) override; + const Device::PairingBeginCallback& begin_callback, + const Device::PairingEndCallback& end_callback); private: // CloudDelegate::Observer
diff --git a/libweave/src/privet/privet_types.cc b/libweave/src/privet/privet_types.cc index 3b801f4..8d380f0 100644 --- a/libweave/src/privet/privet_types.cc +++ b/libweave/src/privet/privet_types.cc
@@ -8,7 +8,6 @@ #include <weave/enum_to_string.h> #include <weave/export.h> -#include <weave/privet.h> #include <weave/provider/network.h> namespace weave {
diff --git a/libweave/src/privet/security_delegate.h b/libweave/src/privet/security_delegate.h index 46eb425..e56dee7 100644 --- a/libweave/src/privet/security_delegate.h +++ b/libweave/src/privet/security_delegate.h
@@ -10,7 +10,6 @@ #include <string> #include <base/time/time.h> -#include <weave/privet.h> #include "src/privet/privet_types.h"
diff --git a/libweave/src/privet/wifi_bootstrap_manager.h b/libweave/src/privet/wifi_bootstrap_manager.h index d93884f..6423b9d 100644 --- a/libweave/src/privet/wifi_bootstrap_manager.h +++ b/libweave/src/privet/wifi_bootstrap_manager.h
@@ -14,7 +14,6 @@ #include <base/memory/weak_ptr.h> #include <base/scoped_observer.h> #include <base/time/time.h> -#include <weave/privet.h> #include "src/privet/privet_types.h" #include "src/privet/wifi_delegate.h"