Darin Petkov | b9c9933 | 2012-01-12 13:13:00 +0100 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [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_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: |
Darin Petkov | 381928f | 2012-02-02 23:00:12 +0100 | [diff] [blame] | 27 | // Online payment portal. |
| 28 | class OLP { |
| 29 | public: |
| 30 | OLP(); |
| 31 | ~OLP(); |
| 32 | |
| 33 | void CopyFrom(const OLP &olp); |
| 34 | bool Equals(const OLP &olp) const; |
| 35 | |
| 36 | const std::string &GetURL() const; |
| 37 | void SetURL(const std::string &url); |
| 38 | |
| 39 | const std::string &GetMethod() const; |
| 40 | void SetMethod(const std::string &method); |
| 41 | |
| 42 | const std::string &GetPostData() const; |
| 43 | void SetPostData(const std::string &post_data); |
| 44 | |
| 45 | const Stringmap &ToDict() const; |
| 46 | |
| 47 | private: |
| 48 | Stringmap dict_; |
| 49 | |
| 50 | DISALLOW_COPY_AND_ASSIGN(OLP); |
| 51 | }; |
| 52 | |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 53 | CellularService(ControlInterface *control_interface, |
| 54 | EventDispatcher *dispatcher, |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 55 | Metrics *metrics, |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 56 | Manager *manager, |
mukesh agrawal | 51a7e93 | 2011-07-27 16:18:26 -0700 | [diff] [blame] | 57 | const CellularRefPtr &device); |
Darin Petkov | d966195 | 2011-08-03 16:25:42 -0700 | [diff] [blame] | 58 | virtual ~CellularService(); |
| 59 | |
Darin Petkov | c408e69 | 2011-08-17 13:47:15 -0700 | [diff] [blame] | 60 | // Inherited from Service. |
Darin Petkov | 4d6d941 | 2011-08-24 13:19:54 -0700 | [diff] [blame] | 61 | virtual void Connect(Error *error); |
Darin Petkov | fb0625e | 2012-01-16 13:05:56 +0100 | [diff] [blame] | 62 | virtual void Disconnect(Error *error); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 63 | virtual void ActivateCellularModem(const std::string &carrier, |
| 64 | ReturnerInterface *returner); |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 65 | virtual bool TechnologyIs(const Technology::Identifier type) const; |
Darin Petkov | c408e69 | 2011-08-17 13:47:15 -0700 | [diff] [blame] | 66 | |
Darin Petkov | 3133241 | 2012-01-28 01:50:02 +0100 | [diff] [blame] | 67 | virtual std::string GetStorageIdentifier() const; |
| 68 | void SetStorageIdentifier(const std::string &identifier); |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 69 | |
Darin Petkov | b9c9933 | 2012-01-12 13:13:00 +0100 | [diff] [blame] | 70 | void SetActivationState(const std::string &state); |
Darin Petkov | c408e69 | 2011-08-17 13:47:15 -0700 | [diff] [blame] | 71 | const std::string &activation_state() const { return activation_state_; } |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 72 | |
Darin Petkov | 381928f | 2012-02-02 23:00:12 +0100 | [diff] [blame] | 73 | void SetOLP(const OLP &olp); |
| 74 | const OLP &olp() const { return olp_; } |
Darin Petkov | b27e544 | 2011-08-16 14:36:45 -0700 | [diff] [blame] | 75 | |
Darin Petkov | 381928f | 2012-02-02 23:00:12 +0100 | [diff] [blame] | 76 | void SetUsageURL(const std::string &url); |
Darin Petkov | b27e544 | 2011-08-16 14:36:45 -0700 | [diff] [blame] | 77 | const std::string &usage_url() const { return usage_url_; } |
Darin Petkov | b27e544 | 2011-08-16 14:36:45 -0700 | [diff] [blame] | 78 | |
Darin Petkov | 9cb0268 | 2012-01-28 00:17:38 +0100 | [diff] [blame] | 79 | void SetServingOperator(const Cellular::Operator &oper); |
Darin Petkov | 3335b37 | 2011-08-22 11:05:32 -0700 | [diff] [blame] | 80 | const Cellular::Operator &serving_operator() const; |
Darin Petkov | 3335b37 | 2011-08-22 11:05:32 -0700 | [diff] [blame] | 81 | |
Darin Petkov | b72cf40 | 2011-11-22 14:51:39 +0100 | [diff] [blame] | 82 | // Sets network technology to |technology| and broadcasts the property change. |
| 83 | void SetNetworkTechnology(const std::string &technology); |
| 84 | const std::string &network_technology() const { return network_technology_; } |
Darin Petkov | d204580 | 2011-08-23 11:09:25 -0700 | [diff] [blame] | 85 | |
Darin Petkov | b72cf40 | 2011-11-22 14:51:39 +0100 | [diff] [blame] | 86 | // Sets roaming state to |state| and broadcasts the property change. |
| 87 | void SetRoamingState(const std::string &state); |
Darin Petkov | d204580 | 2011-08-23 11:09:25 -0700 | [diff] [blame] | 88 | const std::string &roaming_state() const { return roaming_state_; } |
Darin Petkov | d204580 | 2011-08-23 11:09:25 -0700 | [diff] [blame] | 89 | |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 90 | private: |
Darin Petkov | b72cf40 | 2011-11-22 14:51:39 +0100 | [diff] [blame] | 91 | friend class CellularServiceTest; |
| 92 | FRIEND_TEST(CellularTest, Connect); |
| 93 | |
Gaurav Shah | 1b7a616 | 2011-11-09 11:41:01 -0800 | [diff] [blame] | 94 | virtual std::string GetDeviceRpcId(Error *error); |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 95 | |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 96 | // Properties |
| 97 | std::string activation_state_; |
Darin Petkov | 3335b37 | 2011-08-22 11:05:32 -0700 | [diff] [blame] | 98 | Cellular::Operator serving_operator_; |
Darin Petkov | b72cf40 | 2011-11-22 14:51:39 +0100 | [diff] [blame] | 99 | std::string network_technology_; |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 100 | std::string roaming_state_; |
Darin Petkov | 381928f | 2012-02-02 23:00:12 +0100 | [diff] [blame] | 101 | OLP olp_; |
Darin Petkov | b27e544 | 2011-08-16 14:36:45 -0700 | [diff] [blame] | 102 | std::string usage_url_; |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 103 | |
| 104 | std::map<std::string, std::string> apn_info_; |
| 105 | std::map<std::string, std::string> last_good_apn_info_; |
| 106 | |
Darin Petkov | 3133241 | 2012-01-28 01:50:02 +0100 | [diff] [blame] | 107 | std::string storage_identifier_; |
| 108 | |
Chris Masone | 2b10554 | 2011-06-22 10:58:09 -0700 | [diff] [blame] | 109 | CellularRefPtr cellular_; |
Darin Petkov | d966195 | 2011-08-03 16:25:42 -0700 | [diff] [blame] | 110 | |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 111 | DISALLOW_COPY_AND_ASSIGN(CellularService); |
| 112 | }; |
| 113 | |
| 114 | } // namespace shill |
| 115 | |
| 116 | #endif // SHILL_CELLULAR_SERVICE_ |