blob: 9e07886700b778efbb19cdc8c755b529102c9996 [file] [log] [blame]
Darin Petkovb72b62e2012-05-15 16:55:36 +02001// 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
15using base::Bind;
16using base::Unretained;
17using std::string;
18using std::vector;
19
20namespace shill {
21
22namespace {
23// TODO(petkov): Declare these in chromeos/dbus/service_constants.h.
24const char kWiMaxManagerServicePath[] = "/org/chromium/WiMaxManager";
25const char kWiMaxManagerServiceName[] = "org.chromium.WiMaxManager";
26} // namespace
27
28WiMaxProvider::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
38WiMaxProvider::~WiMaxProvider() {
39 Stop();
40}
41
42void 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
57void WiMaxProvider::Stop() {
58 SLOG(WiMax, 2) << __func__;
59 properties_proxy_.reset();
60 manager_proxy_.reset();
61}
62
63void 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
70void 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