blob: 79577cdb2fcbaa6b1b892afa89aac8060041dcf5 [file] [log] [blame]
Prathmesh Prabhu28b4a3b2014-03-28 11:52:09 -07001// Copyright (c) 2014 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/mobile_operator_info.h"
6
7#include <sstream>
8
9#include "shill/logging.h"
10#include "shill/mobile_operator_info_impl.h"
11
12namespace shill {
13
14using base::FilePath;
15using std::string;
16using std::stringstream;
17using std::vector;
18
19// /////////////////////////////////////////////////////////////////////////////
20// MobileOperatorInfo implementation note:
21// MobileOperatorInfo simply forwards all operations to |impl_|.
22// It also logs the functions/arguments/results at sane log levels. So the
23// implementation need not leave a trace itself.
24
25MobileOperatorInfo::MobileOperatorInfo(EventDispatcher *dispatcher)
26 : impl_(new MobileOperatorInfoImpl(dispatcher)) {}
27
28MobileOperatorInfo::~MobileOperatorInfo() {}
29
30void MobileOperatorInfo::ClearDatabasePaths() {
31 SLOG(Cellular, 3) << __func__;
32 impl_->ClearDatabasePaths();
33}
34
35void MobileOperatorInfo::AddDatabasePath(const FilePath &absolute_path) {
36 SLOG(Cellular, 3) << __func__ << "(" << absolute_path.value() << ")";
37 impl_->AddDatabasePath(absolute_path);
38}
39
40bool MobileOperatorInfo::Init() {
41 auto result = impl_->Init();
42 SLOG(Cellular, 3) << __func__ << ": Result[" << result << "]";
43 return result;
44}
45
46void MobileOperatorInfo::AddObserver(MobileOperatorInfo::Observer *observer) {
47 SLOG(Cellular, 3) << __func__;
48 impl_->AddObserver(observer);
49}
50
51void MobileOperatorInfo::RemoveObserver(
52 MobileOperatorInfo::Observer *observer) {
53 SLOG(Cellular, 3) << __func__;
54 impl_->RemoveObserver(observer);
55}
56
57bool MobileOperatorInfo::IsMobileNetworkOperatorKnown() const {
58 auto result = impl_->IsMobileNetworkOperatorKnown();
59 SLOG(Cellular, 3) << __func__ << ": Result[" << result << "]";
60 return result;
61}
62
63bool MobileOperatorInfo::IsMobileVirtualNetworkOperatorKnown() const {
64 auto result = impl_->IsMobileVirtualNetworkOperatorKnown();
65 SLOG(Cellular, 3) << __func__ << ": Result[" << result << "]";
66 return result;
67}
68
69const string &MobileOperatorInfo::uuid() const {
70 const auto &result = impl_->uuid();
71 SLOG(Cellular, 3) << __func__ << ": Result[" << result << "]";
72 return result;
73}
74
75const string &MobileOperatorInfo::operator_name() const {
76 const auto &result = impl_->operator_name();
77 SLOG(Cellular, 3) << __func__ << ": Result[" << result << "]";
78 return result;
79}
80
81const string &MobileOperatorInfo::country() const {
82 const auto &result = impl_->country();
83 SLOG(Cellular, 3) << __func__ << ": Result[" << result << "]";
84 return result;
85}
86
87const string &MobileOperatorInfo::mccmnc() const {
88 const auto &result = impl_->mccmnc();
89 SLOG(Cellular, 3) << __func__ << ": Result[" << result << "]";
90 return result;
91}
92
93const string &MobileOperatorInfo::sid() const {
94 const auto &result = impl_->sid();
95 SLOG(Cellular, 3) << __func__ << ": Result[" << result << "]";
96 return result;
97}
98
99const string &MobileOperatorInfo::nid() const {
100 const auto &result = impl_->nid();
101 SLOG(Cellular, 3) << __func__ << ": Result[" << result << "]";
102 return result;
103}
104
105const vector<string> &MobileOperatorInfo::mccmnc_list() const {
106 const auto &result = impl_->mccmnc_list();
107 if (SLOG_IS_ON(Cellular, 3)) {
108 stringstream pp_result;
109 for (const auto &mccmnc : result) {
110 pp_result << mccmnc << " ";
111 }
112 SLOG(Cellular, 3) << __func__ << ": Result[" << pp_result.str() << "]";
113 }
114 return result;
115}
116
117const vector<string> &MobileOperatorInfo::sid_list() const {
118 const auto &result = impl_->sid_list();
119 if (SLOG_IS_ON(Cellular, 3)) {
120 stringstream pp_result;
121 for (const auto &sid : result) {
122 pp_result << sid << " ";
123 }
124 SLOG(Cellular, 3) << __func__ << ": Result[" << pp_result.str() << "]";
125 }
126 return result;
127}
128
129const vector<MobileOperatorInfo::LocalizedName> &
130MobileOperatorInfo::operator_name_list() const {
131 const auto &result = impl_->operator_name_list();
132 if (SLOG_IS_ON(Cellular, 3)) {
133 stringstream pp_result;
134 for (const auto &operator_name : result) {
135 pp_result << "(" << operator_name.name << ", "
136 << operator_name.language << ") ";
137 }
138 SLOG(Cellular, 3) << __func__ << ": Result[" << pp_result.str() << "]";
139 }
140 return result;
141}
142
143const ScopedVector<MobileOperatorInfo::MobileAPN> &
144MobileOperatorInfo::apn_list() const {
145 const auto &result = impl_->apn_list();
146 if (SLOG_IS_ON(Cellular, 3)) {
147 stringstream pp_result;
148 for (const auto &mobile_apn : result) {
149 pp_result << "(apn: " << mobile_apn->apn
150 << ", username: " << mobile_apn->username
151 << ", password: " << mobile_apn->password;
152 pp_result << ", operator_name_list: '";
153 for (const auto &operator_name : mobile_apn->operator_name_list) {
154 pp_result << "(" << operator_name.name << ", "
155 << operator_name.language << ") ";
156 }
157 pp_result << "') ";
158 }
159 SLOG(Cellular, 3) << __func__ << ": Result[" << pp_result.str() << "]";
160 }
161 return result;
162}
163
164const vector<MobileOperatorInfo::OnlinePortal> &
165MobileOperatorInfo::olp_list() const {
166 const auto &result = impl_->olp_list();
167 if (SLOG_IS_ON(Cellular, 3)) {
168 stringstream pp_result;
169 for (const auto &olp : result) {
170 pp_result << "(url: " << olp.url
171 << ", method: " << olp.method
172 << ", post_data: " << olp.post_data
173 << ") ";
174 }
175 SLOG(Cellular, 3) << __func__ << ": Result[" << pp_result.str() << "]";
176 }
177 return result;
178}
179
180const string &MobileOperatorInfo::activation_code() const {
181 const auto &result = impl_->activation_code();
182 SLOG(Cellular, 3) << __func__ << ": Result[" << result << "]";
183 return result;
184}
185
186bool MobileOperatorInfo::requires_roaming() const {
187 auto result = impl_->requires_roaming();
188 SLOG(Cellular, 3) << __func__ << ": Result[" << result << "]";
189 return result;
190}
191
192void MobileOperatorInfo::UpdateIMSI(const string &imsi) {
193 SLOG(Cellular, 3) << __func__ << "(" << imsi << ")";
194 impl_->UpdateIMSI(imsi);
195}
196
197void MobileOperatorInfo::UpdateICCID(const string &iccid) {
198 SLOG(Cellular, 3) << __func__ << "(" << iccid << ")";
199 impl_->UpdateICCID(iccid);
200}
201
202void MobileOperatorInfo::UpdateMCCMNC(const string &mccmnc) {
203 SLOG(Cellular, 3) << __func__ << "(" << mccmnc << ")";
204 impl_->UpdateMCCMNC(mccmnc);
205}
206
207void MobileOperatorInfo::UpdateSID(const string &sid) {
208 SLOG(Cellular, 3) << __func__ << "(" << sid << ")";
209 impl_->UpdateSID(sid);
210}
211
212void MobileOperatorInfo::UpdateNID(const string &nid) {
213 SLOG(Cellular, 3) << __func__ << "(" << nid << ")";
214 impl_->UpdateNID(nid);
215}
216
217void MobileOperatorInfo::UpdateOperatorName(const string &operator_name) {
218 SLOG(Cellular, 3) << __func__ << "(" << operator_name << ")";
219 impl_->UpdateOperatorName(operator_name);
220}
221
222void MobileOperatorInfo::UpdateOnlinePortal(const string &url,
223 const string &method,
224 const string &post_data) {
225 SLOG(Cellular, 3) << __func__
226 << "(" << url
227 << ", " << method
228 << ", " << post_data
229 << ")";
230 impl_->UpdateOnlinePortal(url, method, post_data);
231}
232
233void MobileOperatorInfo::Reset() {
234 SLOG(Cellular ,3) << __func__;
235 impl_->Reset();
236}
237
238} // namespace shill