blob: 8e2a3a183fb8c733c3ad8a8d2e71377be7f2a397 [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:
Darin Petkov381928f2012-02-02 23:00:12 +010027 // 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 Masone3bd3c8c2011-06-13 08:20:26 -070053 CellularService(ControlInterface *control_interface,
54 EventDispatcher *dispatcher,
Thieu Le3426c8f2012-01-11 17:35:11 -080055 Metrics *metrics,
Chris Masone6791a432011-07-12 13:23:19 -070056 Manager *manager,
mukesh agrawal51a7e932011-07-27 16:18:26 -070057 const CellularRefPtr &device);
Darin Petkovd9661952011-08-03 16:25:42 -070058 virtual ~CellularService();
59
Darin Petkovc408e692011-08-17 13:47:15 -070060 // Inherited from Service.
Darin Petkov4d6d9412011-08-24 13:19:54 -070061 virtual void Connect(Error *error);
Darin Petkovfb0625e2012-01-16 13:05:56 +010062 virtual void Disconnect(Error *error);
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050063 virtual void ActivateCellularModem(const std::string &carrier,
Eric Shienbrood9a245532012-03-07 14:20:39 -050064 Error *error,
65 const ResultCallback &callback);
Paul Stewart22aa71b2011-09-16 12:15:11 -070066 virtual bool TechnologyIs(const Technology::Identifier type) const;
Darin Petkovc408e692011-08-17 13:47:15 -070067
Darin Petkov31332412012-01-28 01:50:02 +010068 virtual std::string GetStorageIdentifier() const;
69 void SetStorageIdentifier(const std::string &identifier);
Chris Masone34af2182011-08-22 11:59:36 -070070
Darin Petkovb9c99332012-01-12 13:13:00 +010071 void SetActivationState(const std::string &state);
Darin Petkovc408e692011-08-17 13:47:15 -070072 const std::string &activation_state() const { return activation_state_; }
Chris Masone3bd3c8c2011-06-13 08:20:26 -070073
Darin Petkov381928f2012-02-02 23:00:12 +010074 void SetOLP(const OLP &olp);
75 const OLP &olp() const { return olp_; }
Darin Petkovb27e5442011-08-16 14:36:45 -070076
Darin Petkov381928f2012-02-02 23:00:12 +010077 void SetUsageURL(const std::string &url);
Darin Petkovb27e5442011-08-16 14:36:45 -070078 const std::string &usage_url() const { return usage_url_; }
Darin Petkovb27e5442011-08-16 14:36:45 -070079
Darin Petkov9cb02682012-01-28 00:17:38 +010080 void SetServingOperator(const Cellular::Operator &oper);
Darin Petkov3335b372011-08-22 11:05:32 -070081 const Cellular::Operator &serving_operator() const;
Darin Petkov3335b372011-08-22 11:05:32 -070082
Darin Petkovb72cf402011-11-22 14:51:39 +010083 // Sets network technology to |technology| and broadcasts the property change.
84 void SetNetworkTechnology(const std::string &technology);
85 const std::string &network_technology() const { return network_technology_; }
Darin Petkovd2045802011-08-23 11:09:25 -070086
Darin Petkovb72cf402011-11-22 14:51:39 +010087 // Sets roaming state to |state| and broadcasts the property change.
88 void SetRoamingState(const std::string &state);
Darin Petkovd2045802011-08-23 11:09:25 -070089 const std::string &roaming_state() const { return roaming_state_; }
Darin Petkovd2045802011-08-23 11:09:25 -070090
Paul Stewartac4ac002011-08-26 12:04:26 -070091 private:
Darin Petkovb72cf402011-11-22 14:51:39 +010092 friend class CellularServiceTest;
93 FRIEND_TEST(CellularTest, Connect);
94
Gaurav Shah1b7a6162011-11-09 11:41:01 -080095 virtual std::string GetDeviceRpcId(Error *error);
Paul Stewartac4ac002011-08-26 12:04:26 -070096
Chris Masone3bd3c8c2011-06-13 08:20:26 -070097 // Properties
98 std::string activation_state_;
Darin Petkov3335b372011-08-22 11:05:32 -070099 Cellular::Operator serving_operator_;
Darin Petkovb72cf402011-11-22 14:51:39 +0100100 std::string network_technology_;
Chris Masone3bd3c8c2011-06-13 08:20:26 -0700101 std::string roaming_state_;
Darin Petkov381928f2012-02-02 23:00:12 +0100102 OLP olp_;
Darin Petkovb27e5442011-08-16 14:36:45 -0700103 std::string usage_url_;
Chris Masone3bd3c8c2011-06-13 08:20:26 -0700104
105 std::map<std::string, std::string> apn_info_;
106 std::map<std::string, std::string> last_good_apn_info_;
107
Darin Petkov31332412012-01-28 01:50:02 +0100108 std::string storage_identifier_;
109
Chris Masone2b105542011-06-22 10:58:09 -0700110 CellularRefPtr cellular_;
Darin Petkovd9661952011-08-03 16:25:42 -0700111
Chris Masone3bd3c8c2011-06-13 08:20:26 -0700112 DISALLOW_COPY_AND_ASSIGN(CellularService);
113};
114
115} // namespace shill
116
117#endif // SHILL_CELLULAR_SERVICE_