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