Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [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 | #ifndef SHILL_CELLULAR_ |
| 6 | #define SHILL_CELLULAR_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | #include <base/basictypes.h> |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 11 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 12 | |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 13 | #include "shill/device.h" |
Chris Masone | 2b10554 | 2011-06-22 10:58:09 -0700 | [diff] [blame] | 14 | #include "shill/refptr_types.h" |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 15 | #include "shill/shill_event.h" |
| 16 | |
| 17 | namespace shill { |
| 18 | |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 19 | class ModemProxyInterface; |
Darin Petkov | e604f70 | 2011-07-28 15:51:17 -0700 | [diff] [blame] | 20 | class ModemSimpleProxyInterface; |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 21 | |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 22 | class Cellular : public Device { |
| 23 | public: |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 24 | enum Type { |
| 25 | kTypeGSM, |
| 26 | kTypeCDMA |
| 27 | }; |
| 28 | |
| 29 | enum State { |
| 30 | kStateDisabled, |
| 31 | kStateEnabled, |
| 32 | kStateRegistered, |
| 33 | kStateConnected, |
| 34 | }; |
| 35 | |
Chris Masone | 889666b | 2011-07-03 12:58:50 -0700 | [diff] [blame] | 36 | class Network { |
| 37 | public: |
| 38 | Network(); |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 39 | ~Network(); |
Chris Masone | 889666b | 2011-07-03 12:58:50 -0700 | [diff] [blame] | 40 | |
| 41 | const std::string &GetStatus() const; |
| 42 | void SetStatus(const std::string &status); |
| 43 | |
| 44 | const std::string &GetId() const; |
| 45 | void SetId(const std::string &id); |
| 46 | |
| 47 | const std::string &GetShortName() const; |
| 48 | void SetShortName(const std::string &name); |
| 49 | |
| 50 | const std::string &GetLongName() const; |
| 51 | void SetLongName(const std::string &name); |
| 52 | |
| 53 | const std::string &GetTechnology() const; |
| 54 | void SetTechnology(const std::string &technology); |
| 55 | |
| 56 | const Stringmap &ToDict() const; |
| 57 | |
| 58 | private: |
| 59 | Stringmap dict_; |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 60 | |
Chris Masone | 889666b | 2011-07-03 12:58:50 -0700 | [diff] [blame] | 61 | DISALLOW_COPY_AND_ASSIGN(Network); |
| 62 | }; |
| 63 | |
| 64 | struct SimLockStatus { |
| 65 | public: |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 66 | SimLockStatus() : retries_left(0) {} |
| 67 | |
Chris Masone | 889666b | 2011-07-03 12:58:50 -0700 | [diff] [blame] | 68 | std::string lock_type; |
| 69 | uint32 retries_left; |
| 70 | }; |
| 71 | |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 72 | // |owner| is the ModemManager DBus service owner (e.g., ":1.17"). |path| is |
| 73 | // the ModemManager.Modem DBus object path (e.g., |
| 74 | // "/org/chromium/ModemManager/Gobi/0"). |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 75 | Cellular(ControlInterface *control_interface, |
| 76 | EventDispatcher *dispatcher, |
| 77 | Manager *manager, |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 78 | const std::string &link_name, |
| 79 | int interface_index, |
| 80 | Type type, |
| 81 | const std::string &owner, |
| 82 | const std::string &path); |
| 83 | virtual ~Cellular(); |
| 84 | |
| 85 | // Inherited from Device. |
| 86 | virtual void Start(); |
| 87 | virtual void Stop(); |
| 88 | virtual bool TechnologyIs(Technology type); |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 89 | |
| 90 | private: |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 91 | FRIEND_TEST(CellularTest, GetStateString); |
| 92 | FRIEND_TEST(CellularTest, GetTypeString); |
| 93 | FRIEND_TEST(CellularTest, Start); |
| 94 | |
Chris Masone | 889666b | 2011-07-03 12:58:50 -0700 | [diff] [blame] | 95 | Stringmaps EnumerateNetworks(); |
| 96 | StrIntPair SimLockStatusToProperty(); |
| 97 | void HelpRegisterDerivedStringmaps(const std::string &name, |
| 98 | Stringmaps(Cellular::*get)(void), |
| 99 | bool(Cellular::*set)(const Stringmaps&)); |
| 100 | void HelpRegisterDerivedStrIntPair(const std::string &name, |
| 101 | StrIntPair(Cellular::*get)(void), |
| 102 | bool(Cellular::*set)(const StrIntPair&)); |
| 103 | |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 104 | std::string GetTypeString(); |
| 105 | std::string GetStateString(); |
| 106 | |
Darin Petkov | f5f61e0 | 2011-07-29 11:35:40 -0700 | [diff] [blame^] | 107 | void EnableModem(); |
| 108 | void GetModemStatus(); |
| 109 | |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 110 | Type type_; |
| 111 | State state_; |
| 112 | |
| 113 | const std::string dbus_owner_; // ModemManager.Modem |
| 114 | const std::string dbus_path_; // ModemManager.Modem |
| 115 | scoped_ptr<ModemProxyInterface> proxy_; |
Darin Petkov | e604f70 | 2011-07-28 15:51:17 -0700 | [diff] [blame] | 116 | scoped_ptr<ModemSimpleProxyInterface> simple_proxy_; |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 117 | |
Chris Masone | 853b81b | 2011-06-24 14:11:41 -0700 | [diff] [blame] | 118 | ServiceRefPtr service_; |
| 119 | bool service_registered_; |
| 120 | |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 121 | // Properties |
| 122 | bool allow_roaming_; |
| 123 | std::string carrier_; |
| 124 | std::string meid_; |
| 125 | std::string imei_; |
| 126 | std::string imsi_; |
| 127 | std::string esn_; |
| 128 | std::string mdn_; |
| 129 | std::string min_; |
| 130 | std::string model_id_; |
| 131 | std::string manufacturer_; |
| 132 | std::string firmware_revision_; |
| 133 | std::string hardware_revision_; |
| 134 | int16 prl_version_; |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 135 | bool scanning_; |
| 136 | uint16 scan_interval_; |
Chris Masone | 889666b | 2011-07-03 12:58:50 -0700 | [diff] [blame] | 137 | std::vector<Network> found_networks_; |
| 138 | SimLockStatus sim_lock_status_; |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 139 | |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 140 | DISALLOW_COPY_AND_ASSIGN(Cellular); |
| 141 | }; |
| 142 | |
| 143 | } // namespace shill |
| 144 | |
| 145 | #endif // SHILL_CELLULAR_ |