blob: db14100a3d8724583ab52f51964b9e6c5fd660fe [file] [log] [blame]
Darin Petkovb9c99332012-01-12 13:13:00 +01001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Chris Masone3bd3c8c2011-06-13 08:20:26 -07002// 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 Petkovb72cf402011-11-22 14:51:39 +010012#include <gtest/gtest_prod.h> // for FRIEND_TEST
Chris Masone3bd3c8c2011-06-13 08:20:26 -070013
Darin Petkov3335b372011-08-22 11:05:32 -070014#include "shill/cellular.h"
Chris Masone2b105542011-06-22 10:58:09 -070015#include "shill/refptr_types.h"
Chris Masone3bd3c8c2011-06-13 08:20:26 -070016#include "shill/service.h"
17
18namespace shill {
19
Chris Masone6791a432011-07-12 13:23:19 -070020class ControlInterface;
Darin Petkovb100ae72011-08-24 16:19:45 -070021class Error;
Chris Masone6791a432011-07-12 13:23:19 -070022class EventDispatcher;
23class Manager;
24
Chris Masone3bd3c8c2011-06-13 08:20:26 -070025class CellularService : public Service {
26 public:
27 CellularService(ControlInterface *control_interface,
28 EventDispatcher *dispatcher,
Chris Masone6791a432011-07-12 13:23:19 -070029 Manager *manager,
mukesh agrawal51a7e932011-07-27 16:18:26 -070030 const CellularRefPtr &device);
Darin Petkovd9661952011-08-03 16:25:42 -070031 virtual ~CellularService();
32
Darin Petkovc408e692011-08-17 13:47:15 -070033 // Inherited from Service.
Darin Petkov4d6d9412011-08-24 13:19:54 -070034 virtual void Connect(Error *error);
mukesh agrawal0ed0f2e2011-12-05 20:36:17 +000035 virtual void Disconnect(Error *error);
Darin Petkovb100ae72011-08-24 16:19:45 -070036 virtual void ActivateCellularModem(const std::string &carrier, Error *error);
Paul Stewart22aa71b2011-09-16 12:15:11 -070037 virtual bool TechnologyIs(const Technology::Identifier type) const;
Darin Petkovc408e692011-08-17 13:47:15 -070038
Chris Masone34af2182011-08-22 11:59:36 -070039 // cellular_<MAC>_<Service_Operator_Name>
Chris Masone6515aab2011-10-12 16:19:09 -070040 std::string GetStorageIdentifier() const;
Chris Masone34af2182011-08-22 11:59:36 -070041
Darin Petkovb9c99332012-01-12 13:13:00 +010042 void SetActivationState(const std::string &state);
Darin Petkovc408e692011-08-17 13:47:15 -070043 const std::string &activation_state() const { return activation_state_; }
Chris Masone3bd3c8c2011-06-13 08:20:26 -070044
Darin Petkovd9661952011-08-03 16:25:42 -070045 uint8 strength() const { return strength_; }
46 void set_strength(uint8 strength) { strength_ = strength; }
47
Darin Petkovb27e5442011-08-16 14:36:45 -070048 const std::string &payment_url() const { return payment_url_; }
49 void set_payment_url(const std::string &url) { payment_url_ = url; }
50
51 const std::string &usage_url() const { return usage_url_; }
52 void set_usage_url(const std::string &url) { usage_url_ = url; }
53
Darin Petkov3335b372011-08-22 11:05:32 -070054 const Cellular::Operator &serving_operator() const;
55 void set_serving_operator(const Cellular::Operator &oper);
56
Darin Petkovb72cf402011-11-22 14:51:39 +010057 // Sets network technology to |technology| and broadcasts the property change.
58 void SetNetworkTechnology(const std::string &technology);
59 const std::string &network_technology() const { return network_technology_; }
Darin Petkovd2045802011-08-23 11:09:25 -070060
Darin Petkovb72cf402011-11-22 14:51:39 +010061 // Sets roaming state to |state| and broadcasts the property change.
62 void SetRoamingState(const std::string &state);
Darin Petkovd2045802011-08-23 11:09:25 -070063 const std::string &roaming_state() const { return roaming_state_; }
Darin Petkovd2045802011-08-23 11:09:25 -070064
Paul Stewartac4ac002011-08-26 12:04:26 -070065 private:
Darin Petkovb72cf402011-11-22 14:51:39 +010066 friend class CellularServiceTest;
67 FRIEND_TEST(CellularTest, Connect);
68
Paul Stewartac4ac002011-08-26 12:04:26 -070069 static const char kServiceType[];
70
Gaurav Shah1b7a6162011-11-09 11:41:01 -080071 virtual std::string GetDeviceRpcId(Error *error);
Paul Stewartac4ac002011-08-26 12:04:26 -070072
Chris Masone3bd3c8c2011-06-13 08:20:26 -070073 // Properties
74 std::string activation_state_;
Darin Petkov3335b372011-08-22 11:05:32 -070075 Cellular::Operator serving_operator_;
Darin Petkovb72cf402011-11-22 14:51:39 +010076 std::string network_technology_;
Chris Masone3bd3c8c2011-06-13 08:20:26 -070077 std::string roaming_state_;
78 std::string payment_url_;
79 uint8 strength_;
Darin Petkovb27e5442011-08-16 14:36:45 -070080 std::string usage_url_;
Chris Masone3bd3c8c2011-06-13 08:20:26 -070081
82 std::map<std::string, std::string> apn_info_;
83 std::map<std::string, std::string> last_good_apn_info_;
84
Chris Masone2b105542011-06-22 10:58:09 -070085 CellularRefPtr cellular_;
Darin Petkovd9661952011-08-03 16:25:42 -070086
Chris Masone3bd3c8c2011-06-13 08:20:26 -070087 DISALLOW_COPY_AND_ASSIGN(CellularService);
88};
89
90} // namespace shill
91
92#endif // SHILL_CELLULAR_SERVICE_