blob: cf0f8482131b21c9c3ddee0671d61fa3305f9a96 [file] [log] [blame]
Darin Petkovc64fe5e2012-01-11 12:46:13 +01001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Darin Petkovdaf43862011-10-27 11:37:28 +02002// 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 Petkovb05315f2011-11-07 10:14:25 +01008#include <string>
9
Darin Petkovdaf43862011-10-27 11:37:28 +020010#include <base/basictypes.h>
11
Darin Petkovae0c64e2011-11-15 15:50:27 +010012#include "shill/dbus_properties.h"
13
Darin Petkovdaf43862011-10-27 11:37:28 +020014namespace shill {
15
16class Cellular;
Darin Petkovb05315f2011-11-07 10:14:25 +010017class Error;
18class EventDispatcher;
Darin Petkovdaf43862011-10-27 11:37:28 +020019class ProxyFactory;
Darin Petkove5bc2cb2011-12-07 14:47:32 +010020class ReturnerInterface;
Darin Petkovdaf43862011-10-27 11:37:28 +020021
22// Cellular devices instantiate subclasses of CellularCapability that handle the
23// specific modem technologies and capabilities.
24class 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 Petkovb05315f2011-11-07 10:14:25 +010032 EventDispatcher *dispatcher() const;
Darin Petkovdaf43862011-10-27 11:37:28 +020033
Darin Petkov721ac932011-11-16 15:43:09 +010034 // Invoked on starting and stopping the cellular device.
Darin Petkov5f316f62011-11-18 12:10:26 +010035 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 Petkovdaf43862011-10-27 11:37:28 +020040
Darin Petkovae0c64e2011-11-15 15:50:27 +010041 virtual void UpdateStatus(const DBusPropertiesMap &properties) = 0;
42
43 virtual void SetupConnectProperties(DBusPropertiesMap *properties) = 0;
44
Darin Petkova3d3be52011-11-14 21:34:16 +010045 // 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 Petkov184c54e2011-11-15 12:44:39 +010049 // Network registration.
50 virtual void Register();
51 virtual void RegisterOnNetwork(const std::string &network_id, Error *error);
Darin Petkovb72cf402011-11-22 14:51:39 +010052 virtual bool IsRegistered() = 0;
Darin Petkov184c54e2011-11-15 12:44:39 +010053
Darin Petkovcb547732011-11-09 13:55:26 +010054 // Retrieves identifiers associated with the modem and the capability.
55 virtual void GetIdentifiers() = 0;
56
Darin Petkov184c54e2011-11-15 12:44:39 +010057 virtual void GetProperties() = 0;
58
Darin Petkov3e509242011-11-10 14:46:44 +010059 // Retrieves the current cellular signal strength.
60 virtual void GetSignalQuality() = 0;
61
Darin Petkov184c54e2011-11-15 12:44:39 +010062 virtual void GetRegistrationState() = 0;
63
Darin Petkovac635a82012-01-10 16:51:58 +010064 virtual std::string CreateFriendlyServiceName() = 0;
65
Darin Petkovc64fe5e2012-01-11 12:46:13 +010066 // PIN management. The default implementation fails by returning an error.
67 virtual void RequirePIN(
68 const std::string &pin, bool require, ReturnerInterface *returner);
Darin Petkove5bc2cb2011-12-07 14:47:32 +010069 virtual void EnterPIN(const std::string &pin, ReturnerInterface *returner);
Darin Petkovb05315f2011-11-07 10:14:25 +010070 virtual void UnblockPIN(const std::string &unblock_code,
71 const std::string &pin,
Darin Petkovc64fe5e2012-01-11 12:46:13 +010072 ReturnerInterface *returner);
Darin Petkovb05315f2011-11-07 10:14:25 +010073 virtual void ChangePIN(const std::string &old_pin,
74 const std::string &new_pin,
Darin Petkovc64fe5e2012-01-11 12:46:13 +010075 ReturnerInterface *returner);
Darin Petkovb05315f2011-11-07 10:14:25 +010076
Darin Petkov1272a432011-11-10 15:53:37 +010077 // Network scanning. The default implementation fails by populating |error|.
78 virtual void Scan(Error *error);
79
Darin Petkov20c13ec2011-11-09 15:07:15 +010080 // 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 Petkovae0c64e2011-11-15 15:50:27 +010085 virtual void OnModemManagerPropertiesChanged(
86 const DBusPropertiesMap &properties) = 0;
87
Darin Petkovdaf43862011-10-27 11:37:28 +020088 private:
Darin Petkov721ac932011-11-16 15:43:09 +010089 friend class CellularTest;
90
Darin Petkovdaf43862011-10-27 11:37:28 +020091 Cellular *cellular_;
92 ProxyFactory *proxy_factory_;
93
94 DISALLOW_COPY_AND_ASSIGN(CellularCapability);
95};
96
97} // namespace shill
98
99#endif // SHILL_CELLULAR_CAPABILITY_