Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 1 | // 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 Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 12 | using std::string; |
| 13 | |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 14 | namespace shill { |
| 15 | |
| 16 | CellularCapabilityGSM::CellularCapabilityGSM(Cellular *cellular) |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 17 | : CellularCapability(cellular), |
| 18 | task_factory_(this) {} |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 19 | |
| 20 | void 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 Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 33 | void 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 | |
| 42 | void 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 | |
| 48 | void 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 | |
| 56 | void 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 | |
| 62 | void 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 | |
| 71 | void 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 | |
| 78 | void 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 | |
| 87 | void 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 Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 94 | } // namespace shill |