blob: 6ab80b65afe80e3f98ea300203963106b3afc983 [file] [log] [blame]
Chris Masone3bd3c8c2011-06-13 08:20:26 -07001// Copyright (c) 2011 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/cellular.h"
6
7#include <string>
8
9#include <base/logging.h>
Chris Masoneb925cc82011-06-22 15:39:57 -070010#include <chromeos/dbus/service_constants.h>
Chris Masone3bd3c8c2011-06-13 08:20:26 -070011
12#include "shill/cellular_service.h"
13#include "shill/control_interface.h"
14#include "shill/device.h"
15#include "shill/device_info.h"
16#include "shill/manager.h"
17#include "shill/shill_event.h"
18
19using std::string;
20
21namespace shill {
22
23Cellular::Cellular(ControlInterface *control_interface,
24 EventDispatcher *dispatcher,
25 Manager *manager,
26 const string &link,
27 int interface_index)
28 : Device(control_interface,
29 dispatcher,
30 manager,
31 link,
32 interface_index),
33 service_(new CellularService(control_interface,
34 dispatcher,
35 this,
36 "service-" + link)),
37 service_registered_(false) {
Chris Masone27c4aa52011-07-02 13:10:14 -070038 store_.RegisterConstString(flimflam::kCarrierProperty, &carrier_);
Chris Masone4d42df82011-07-02 17:09:39 -070039 store_.RegisterBool(flimflam::kCellularAllowRoamingProperty, &allow_roaming_);
Chris Masone27c4aa52011-07-02 13:10:14 -070040 store_.RegisterConstString(flimflam::kEsnProperty, &esn_);
Chris Masone27c4aa52011-07-02 13:10:14 -070041 store_.RegisterConstString(flimflam::kFirmwareRevisionProperty,
42 &firmware_revision_);
43 store_.RegisterConstString(flimflam::kHardwareRevisionProperty,
44 &hardware_revision_);
Chris Masone4d42df82011-07-02 17:09:39 -070045 store_.RegisterConstString(flimflam::kImeiProperty, &imei_);
46 store_.RegisterConstString(flimflam::kImsiProperty, &imsi_);
47 store_.RegisterConstString(flimflam::kManufacturerProperty, &manufacturer_);
48 store_.RegisterConstString(flimflam::kMdnProperty, &mdn_);
49 store_.RegisterConstString(flimflam::kMeidProperty, &meid_);
50 store_.RegisterConstString(flimflam::kMinProperty, &min_);
51 store_.RegisterConstString(flimflam::kModelIDProperty, &model_id_);
Chris Masone27c4aa52011-07-02 13:10:14 -070052 store_.RegisterConstInt16(flimflam::kPRLVersionProperty, &prl_version_);
Chris Masoneb925cc82011-06-22 15:39:57 -070053
54 // TODO(cmasone): Deal with these compound properties
55 // known_properties_.push_back(flimflam::kSIMLockStatusProperty);
56 // known_properties_.push_back(flimflam::kFoundNetworksProperty);
57
Chris Masone4d42df82011-07-02 17:09:39 -070058 store_.RegisterConstBool(flimflam::kScanningProperty, &scanning_);
59 store_.RegisterUint16(flimflam::kScanIntervalProperty, &scan_interval_);
60
Chris Masone3bd3c8c2011-06-13 08:20:26 -070061 VLOG(2) << "Cellular device " << link_name() << " initialized.";
62}
63
64Cellular::~Cellular() {
65 Stop();
66}
67
68void Cellular::Start() {
69 Device::Start();
70}
71
72void Cellular::Stop() {
Chris Masone2b105542011-06-22 10:58:09 -070073 manager_->DeregisterService(service_);
Chris Masone3bd3c8c2011-06-13 08:20:26 -070074 Device::Stop();
75}
76
77bool Cellular::TechnologyIs(const Device::Technology type) {
78 return type == Device::kCellular;
79}
80
81} // namespace shill