Darin Petkov | b72b62e | 2012-05-15 16:55:36 +0200 | [diff] [blame^] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "shill/wimax_provider.h" |
| 6 | |
| 7 | #include <base/bind.h> |
| 8 | |
| 9 | #include "shill/dbus_properties_proxy_interface.h" |
| 10 | #include "shill/error.h" |
| 11 | #include "shill/proxy_factory.h" |
| 12 | #include "shill/scope_logger.h" |
| 13 | #include "shill/wimax_manager_proxy_interface.h" |
| 14 | |
| 15 | using base::Bind; |
| 16 | using base::Unretained; |
| 17 | using std::string; |
| 18 | using std::vector; |
| 19 | |
| 20 | namespace shill { |
| 21 | |
| 22 | namespace { |
| 23 | // TODO(petkov): Declare these in chromeos/dbus/service_constants.h. |
| 24 | const char kWiMaxManagerServicePath[] = "/org/chromium/WiMaxManager"; |
| 25 | const char kWiMaxManagerServiceName[] = "org.chromium.WiMaxManager"; |
| 26 | } // namespace |
| 27 | |
| 28 | WiMaxProvider::WiMaxProvider(ControlInterface *control, |
| 29 | EventDispatcher *dispatcher, |
| 30 | Metrics *metrics, |
| 31 | Manager *manager) |
| 32 | : control_(control), |
| 33 | dispatcher_(dispatcher), |
| 34 | metrics_(metrics), |
| 35 | manager_(manager), |
| 36 | proxy_factory_(ProxyFactory::GetInstance()) {} |
| 37 | |
| 38 | WiMaxProvider::~WiMaxProvider() { |
| 39 | Stop(); |
| 40 | } |
| 41 | |
| 42 | void WiMaxProvider::Start() { |
| 43 | SLOG(WiMax, 2) << __func__; |
| 44 | if (manager_proxy_.get()) { |
| 45 | return; |
| 46 | } |
| 47 | properties_proxy_.reset( |
| 48 | proxy_factory_->CreateDBusPropertiesProxy( |
| 49 | kWiMaxManagerServicePath, kWiMaxManagerServiceName)); |
| 50 | properties_proxy_->set_properties_changed_callback( |
| 51 | Bind(&WiMaxProvider::OnPropertiesChanged, Unretained(this))); |
| 52 | manager_proxy_.reset(proxy_factory_->CreateWiMaxManagerProxy()); |
| 53 | Error error; |
| 54 | UpdateDevices(manager_proxy_->Devices(&error)); |
| 55 | } |
| 56 | |
| 57 | void WiMaxProvider::Stop() { |
| 58 | SLOG(WiMax, 2) << __func__; |
| 59 | properties_proxy_.reset(); |
| 60 | manager_proxy_.reset(); |
| 61 | } |
| 62 | |
| 63 | void WiMaxProvider::UpdateDevices(const vector<RpcIdentifier> &/*devices*/) { |
| 64 | SLOG(WiMax, 2) << __func__; |
| 65 | // TODO(petkov): Create/register and destroy/unregister WiMax devices as |
| 66 | // necessary. |
| 67 | NOTIMPLEMENTED(); |
| 68 | } |
| 69 | |
| 70 | void WiMaxProvider::OnPropertiesChanged( |
| 71 | const string &/*interface*/, |
| 72 | const DBusPropertiesMap &/*changed_properties*/, |
| 73 | const vector<string> &/*invalidated_properties*/) { |
| 74 | SLOG(WiMax, 2) << __func__; |
| 75 | // TODO(petkov): Parse the "Devices" property and invoke UpdateDevices. |
| 76 | NOTIMPLEMENTED(); |
| 77 | } |
| 78 | |
| 79 | } // namespace shill |