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_SERVICE_ |
| 6 | #define SHILL_CELLULAR_SERVICE_ |
| 7 | |
| 8 | #include <map> |
| 9 | #include <string> |
| 10 | |
| 11 | #include <base/basictypes.h> |
Darin Petkov | b72cf40 | 2011-11-22 14:51:39 +0100 | [diff] [blame] | 12 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 13 | |
Darin Petkov | 3335b37 | 2011-08-22 11:05:32 -0700 | [diff] [blame] | 14 | #include "shill/cellular.h" |
Chris Masone | 2b10554 | 2011-06-22 10:58:09 -0700 | [diff] [blame] | 15 | #include "shill/refptr_types.h" |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 16 | #include "shill/service.h" |
| 17 | |
| 18 | namespace shill { |
| 19 | |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 20 | class ControlInterface; |
Darin Petkov | b100ae7 | 2011-08-24 16:19:45 -0700 | [diff] [blame] | 21 | class Error; |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 22 | class EventDispatcher; |
| 23 | class Manager; |
| 24 | |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 25 | class CellularService : public Service { |
| 26 | public: |
| 27 | CellularService(ControlInterface *control_interface, |
| 28 | EventDispatcher *dispatcher, |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 29 | Manager *manager, |
mukesh agrawal | 51a7e93 | 2011-07-27 16:18:26 -0700 | [diff] [blame] | 30 | const CellularRefPtr &device); |
Darin Petkov | d966195 | 2011-08-03 16:25:42 -0700 | [diff] [blame] | 31 | virtual ~CellularService(); |
| 32 | |
Darin Petkov | c408e69 | 2011-08-17 13:47:15 -0700 | [diff] [blame] | 33 | // Inherited from Service. |
Darin Petkov | 4d6d941 | 2011-08-24 13:19:54 -0700 | [diff] [blame] | 34 | virtual void Connect(Error *error); |
mukesh agrawal | 0ed0f2e | 2011-12-05 20:36:17 +0000 | [diff] [blame] | 35 | virtual void Disconnect(Error *error); |
Darin Petkov | b100ae7 | 2011-08-24 16:19:45 -0700 | [diff] [blame] | 36 | virtual void ActivateCellularModem(const std::string &carrier, Error *error); |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 37 | virtual bool TechnologyIs(const Technology::Identifier type) const; |
Darin Petkov | c408e69 | 2011-08-17 13:47:15 -0700 | [diff] [blame] | 38 | |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 39 | // cellular_<MAC>_<Service_Operator_Name> |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 40 | std::string GetStorageIdentifier() const; |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 41 | |
Darin Petkov | c408e69 | 2011-08-17 13:47:15 -0700 | [diff] [blame] | 42 | const std::string &activation_state() const { return activation_state_; } |
| 43 | void set_activation_state(const std::string &state) { |
| 44 | activation_state_ = state; |
| 45 | } |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 46 | |
Darin Petkov | d966195 | 2011-08-03 16:25:42 -0700 | [diff] [blame] | 47 | uint8 strength() const { return strength_; } |
| 48 | void set_strength(uint8 strength) { strength_ = strength; } |
| 49 | |
Darin Petkov | b27e544 | 2011-08-16 14:36:45 -0700 | [diff] [blame] | 50 | const std::string &payment_url() const { return payment_url_; } |
| 51 | void set_payment_url(const std::string &url) { payment_url_ = url; } |
| 52 | |
| 53 | const std::string &usage_url() const { return usage_url_; } |
| 54 | void set_usage_url(const std::string &url) { usage_url_ = url; } |
| 55 | |
Darin Petkov | 3335b37 | 2011-08-22 11:05:32 -0700 | [diff] [blame] | 56 | const Cellular::Operator &serving_operator() const; |
| 57 | void set_serving_operator(const Cellular::Operator &oper); |
| 58 | |
Darin Petkov | b72cf40 | 2011-11-22 14:51:39 +0100 | [diff] [blame] | 59 | // Sets network technology to |technology| and broadcasts the property change. |
| 60 | void SetNetworkTechnology(const std::string &technology); |
| 61 | const std::string &network_technology() const { return network_technology_; } |
Darin Petkov | d204580 | 2011-08-23 11:09:25 -0700 | [diff] [blame] | 62 | |
Darin Petkov | b72cf40 | 2011-11-22 14:51:39 +0100 | [diff] [blame] | 63 | // Sets roaming state to |state| and broadcasts the property change. |
| 64 | void SetRoamingState(const std::string &state); |
Darin Petkov | d204580 | 2011-08-23 11:09:25 -0700 | [diff] [blame] | 65 | const std::string &roaming_state() const { return roaming_state_; } |
Darin Petkov | d204580 | 2011-08-23 11:09:25 -0700 | [diff] [blame] | 66 | |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 67 | private: |
Darin Petkov | b72cf40 | 2011-11-22 14:51:39 +0100 | [diff] [blame] | 68 | friend class CellularServiceTest; |
| 69 | FRIEND_TEST(CellularTest, Connect); |
| 70 | |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 71 | static const char kServiceType[]; |
| 72 | |
Gaurav Shah | 1b7a616 | 2011-11-09 11:41:01 -0800 | [diff] [blame] | 73 | virtual std::string GetDeviceRpcId(Error *error); |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 74 | |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 75 | // Properties |
| 76 | std::string activation_state_; |
Darin Petkov | 3335b37 | 2011-08-22 11:05:32 -0700 | [diff] [blame] | 77 | Cellular::Operator serving_operator_; |
Darin Petkov | b72cf40 | 2011-11-22 14:51:39 +0100 | [diff] [blame] | 78 | std::string network_technology_; |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 79 | std::string roaming_state_; |
| 80 | std::string payment_url_; |
| 81 | uint8 strength_; |
Darin Petkov | b27e544 | 2011-08-16 14:36:45 -0700 | [diff] [blame] | 82 | std::string usage_url_; |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 83 | |
| 84 | std::map<std::string, std::string> apn_info_; |
| 85 | std::map<std::string, std::string> last_good_apn_info_; |
| 86 | |
Chris Masone | 2b10554 | 2011-06-22 10:58:09 -0700 | [diff] [blame] | 87 | CellularRefPtr cellular_; |
Darin Petkov | d966195 | 2011-08-03 16:25:42 -0700 | [diff] [blame] | 88 | |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 89 | DISALLOW_COPY_AND_ASSIGN(CellularService); |
| 90 | }; |
| 91 | |
| 92 | } // namespace shill |
| 93 | |
| 94 | #endif // SHILL_CELLULAR_SERVICE_ |