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