blob: 464d62bf037270ee93a9894e2538bcf1d43b61d4 [file] [log] [blame]
Darin Petkovdaf43862011-10-27 11:37:28 +02001// 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_capability_gsm.h"
6
7#include <base/logging.h>
8
9#include "shill/cellular.h"
10#include "shill/proxy_factory.h"
11
Darin Petkovb05315f2011-11-07 10:14:25 +010012using std::string;
13
Darin Petkovdaf43862011-10-27 11:37:28 +020014namespace shill {
15
16CellularCapabilityGSM::CellularCapabilityGSM(Cellular *cellular)
Darin Petkovb05315f2011-11-07 10:14:25 +010017 : CellularCapability(cellular),
18 task_factory_(this) {}
Darin Petkovdaf43862011-10-27 11:37:28 +020019
20void CellularCapabilityGSM::InitProxies() {
21 VLOG(2) << __func__;
22 // TODO(petkov): Move GSM-specific proxy ownership from Cellular to this.
23 cellular()->set_modem_gsm_card_proxy(
24 proxy_factory()->CreateModemGSMCardProxy(cellular(),
25 cellular()->dbus_path(),
26 cellular()->dbus_owner()));
27 cellular()->set_modem_gsm_network_proxy(
28 proxy_factory()->CreateModemGSMNetworkProxy(cellular(),
29 cellular()->dbus_path(),
30 cellular()->dbus_owner()));
31}
32
Darin Petkovb05315f2011-11-07 10:14:25 +010033void CellularCapabilityGSM::RequirePIN(
34 const string &pin, bool require, Error */*error*/) {
35 VLOG(2) << __func__ << "(" << pin << ", " << require << ")";
36 // Defer because we may be in a dbus-c++ callback.
37 dispatcher()->PostTask(
38 task_factory_.NewRunnableMethod(
39 &CellularCapabilityGSM::RequirePINTask, pin, require));
40}
41
42void CellularCapabilityGSM::RequirePINTask(const string &pin, bool require) {
43 VLOG(2) << __func__ << "(" << pin << ", " << require << ")";
44 // TODO(petkov): Switch to asynchronous calls (crosbug.com/17583).
45 cellular()->modem_gsm_card_proxy()->EnablePIN(pin, require);
46}
47
48void CellularCapabilityGSM::EnterPIN(const string &pin, Error */*error*/) {
49 VLOG(2) << __func__ << "(" << pin << ")";
50 // Defer because we may be in a dbus-c++ callback.
51 dispatcher()->PostTask(
52 task_factory_.NewRunnableMethod(
53 &CellularCapabilityGSM::EnterPINTask, pin));
54}
55
56void CellularCapabilityGSM::EnterPINTask(const string &pin) {
57 VLOG(2) << __func__ << "(" << pin << ")";
58 // TODO(petkov): Switch to asynchronous calls (crosbug.com/17583).
59 cellular()->modem_gsm_card_proxy()->SendPIN(pin);
60}
61
62void CellularCapabilityGSM::UnblockPIN(
63 const string &unblock_code, const string &pin, Error */*error*/) {
64 VLOG(2) << __func__ << "(" << unblock_code << ", " << pin << ")";
65 // Defer because we may be in a dbus-c++ callback.
66 dispatcher()->PostTask(
67 task_factory_.NewRunnableMethod(
68 &CellularCapabilityGSM::UnblockPINTask, unblock_code, pin));
69}
70
71void CellularCapabilityGSM::UnblockPINTask(
72 const string &unblock_code, const string &pin) {
73 VLOG(2) << __func__ << "(" << unblock_code << ", " << pin << ")";
74 // TODO(petkov): Switch to asynchronous calls (crosbug.com/17583).
75 cellular()->modem_gsm_card_proxy()->SendPUK(unblock_code, pin);
76}
77
78void CellularCapabilityGSM::ChangePIN(
79 const string &old_pin, const string &new_pin, Error */*error*/) {
80 VLOG(2) << __func__ << "(" << old_pin << ", " << new_pin << ")";
81 // Defer because we may be in a dbus-c++ callback.
82 dispatcher()->PostTask(
83 task_factory_.NewRunnableMethod(
84 &CellularCapabilityGSM::ChangePINTask, old_pin, new_pin));
85}
86
87void CellularCapabilityGSM::ChangePINTask(
88 const string &old_pin, const string &new_pin) {
89 VLOG(2) << __func__ << "(" << old_pin << ", " << new_pin << ")";
90 // TODO(petkov): Switch to asynchronous calls (crosbug.com/17583).
91 cellular()->modem_gsm_card_proxy()->ChangePIN(old_pin, new_pin);
92}
93
Darin Petkovdaf43862011-10-27 11:37:28 +020094} // namespace shill