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 | #ifndef SHILL_CELLULAR_CAPABILITY_ |
| 6 | #define SHILL_CELLULAR_CAPABILITY_ |
| 7 | |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 8 | #include <string> |
| 9 | |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 10 | #include <base/basictypes.h> |
| 11 | |
Darin Petkov | ae0c64e | 2011-11-15 15:50:27 +0100 | [diff] [blame] | 12 | #include "shill/dbus_properties.h" |
| 13 | |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 14 | namespace shill { |
| 15 | |
| 16 | class Cellular; |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 17 | class Error; |
| 18 | class EventDispatcher; |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 19 | class ProxyFactory; |
| 20 | |
| 21 | // Cellular devices instantiate subclasses of CellularCapability that handle the |
| 22 | // specific modem technologies and capabilities. |
| 23 | class CellularCapability { |
| 24 | public: |
| 25 | // |cellular| is the parent Cellular device. |
| 26 | CellularCapability(Cellular *cellular); |
| 27 | virtual ~CellularCapability(); |
| 28 | |
| 29 | Cellular *cellular() const { return cellular_; } |
| 30 | ProxyFactory *proxy_factory() const { return proxy_factory_; } |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 31 | EventDispatcher *dispatcher() const; |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 32 | |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 33 | // Invoked on starting and stopping the cellular device. |
Darin Petkov | 5f316f6 | 2011-11-18 12:10:26 +0100 | [diff] [blame] | 34 | virtual void OnDeviceStarted() = 0; |
| 35 | virtual void OnDeviceStopped() = 0; |
| 36 | |
| 37 | // Invoked by the parent Cellular device when a new service is created. |
| 38 | virtual void OnServiceCreated() = 0; |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 39 | |
Darin Petkov | ae0c64e | 2011-11-15 15:50:27 +0100 | [diff] [blame] | 40 | virtual void UpdateStatus(const DBusPropertiesMap &properties) = 0; |
| 41 | |
| 42 | virtual void SetupConnectProperties(DBusPropertiesMap *properties) = 0; |
| 43 | |
Darin Petkov | a3d3be5 | 2011-11-14 21:34:16 +0100 | [diff] [blame] | 44 | // Activates the modem. Populates |error| on failure, leaves it unchanged |
| 45 | // otherwise. The default implementation fails by populating |error|. |
| 46 | virtual void Activate(const std::string &carrier, Error *error); |
| 47 | |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 48 | // Network registration. |
| 49 | virtual void Register(); |
| 50 | virtual void RegisterOnNetwork(const std::string &network_id, Error *error); |
Darin Petkov | b72cf40 | 2011-11-22 14:51:39 +0100 | [diff] [blame^] | 51 | virtual bool IsRegistered() = 0; |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 52 | |
Darin Petkov | cb54773 | 2011-11-09 13:55:26 +0100 | [diff] [blame] | 53 | // Retrieves identifiers associated with the modem and the capability. |
| 54 | virtual void GetIdentifiers() = 0; |
| 55 | |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 56 | virtual void GetProperties() = 0; |
| 57 | |
Darin Petkov | 3e50924 | 2011-11-10 14:46:44 +0100 | [diff] [blame] | 58 | // Retrieves the current cellular signal strength. |
| 59 | virtual void GetSignalQuality() = 0; |
| 60 | |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 61 | virtual void GetRegistrationState() = 0; |
| 62 | |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 63 | // PIN management. The default implementation fails by populating |error|. |
| 64 | virtual void RequirePIN(const std::string &pin, bool require, Error *error); |
| 65 | virtual void EnterPIN(const std::string &pin, Error *error); |
| 66 | virtual void UnblockPIN(const std::string &unblock_code, |
| 67 | const std::string &pin, |
| 68 | Error *error); |
| 69 | virtual void ChangePIN(const std::string &old_pin, |
| 70 | const std::string &new_pin, |
| 71 | Error *error); |
| 72 | |
Darin Petkov | 1272a43 | 2011-11-10 15:53:37 +0100 | [diff] [blame] | 73 | // Network scanning. The default implementation fails by populating |error|. |
| 74 | virtual void Scan(Error *error); |
| 75 | |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 76 | // Returns an empty string if the network technology is unknown. |
| 77 | virtual std::string GetNetworkTechnologyString() const = 0; |
| 78 | |
| 79 | virtual std::string GetRoamingStateString() const = 0; |
| 80 | |
Darin Petkov | ae0c64e | 2011-11-15 15:50:27 +0100 | [diff] [blame] | 81 | virtual void OnModemManagerPropertiesChanged( |
| 82 | const DBusPropertiesMap &properties) = 0; |
| 83 | |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 84 | private: |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 85 | friend class CellularTest; |
| 86 | |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 87 | Cellular *cellular_; |
| 88 | ProxyFactory *proxy_factory_; |
| 89 | |
| 90 | DISALLOW_COPY_AND_ASSIGN(CellularCapability); |
| 91 | }; |
| 92 | |
| 93 | } // namespace shill |
| 94 | |
| 95 | #endif // SHILL_CELLULAR_CAPABILITY_ |