blob: e684361b1f67e3480465378e607352ea7425166d [file] [log] [blame]
Chris Masone3bd3c8c2011-06-13 08:20:26 -07001// 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_
6#define SHILL_CELLULAR_
7
8#include <string>
9
10#include <base/basictypes.h>
Darin Petkove9d12e02011-07-27 15:09:37 -070011#include <gtest/gtest_prod.h> // for FRIEND_TEST
Chris Masone3bd3c8c2011-06-13 08:20:26 -070012
Chris Masone3bd3c8c2011-06-13 08:20:26 -070013#include "shill/device.h"
Chris Masone2b105542011-06-22 10:58:09 -070014#include "shill/refptr_types.h"
Chris Masone3bd3c8c2011-06-13 08:20:26 -070015#include "shill/shill_event.h"
16
17namespace shill {
18
Darin Petkove9d12e02011-07-27 15:09:37 -070019class ModemProxyInterface;
20
Chris Masone3bd3c8c2011-06-13 08:20:26 -070021class Cellular : public Device {
22 public:
Darin Petkove9d12e02011-07-27 15:09:37 -070023 enum Type {
24 kTypeGSM,
25 kTypeCDMA
26 };
27
28 enum State {
29 kStateDisabled,
30 kStateEnabled,
31 kStateRegistered,
32 kStateConnected,
33 };
34
Chris Masone889666b2011-07-03 12:58:50 -070035 class Network {
36 public:
37 Network();
Darin Petkove9d12e02011-07-27 15:09:37 -070038 ~Network();
Chris Masone889666b2011-07-03 12:58:50 -070039
40 const std::string &GetStatus() const;
41 void SetStatus(const std::string &status);
42
43 const std::string &GetId() const;
44 void SetId(const std::string &id);
45
46 const std::string &GetShortName() const;
47 void SetShortName(const std::string &name);
48
49 const std::string &GetLongName() const;
50 void SetLongName(const std::string &name);
51
52 const std::string &GetTechnology() const;
53 void SetTechnology(const std::string &technology);
54
55 const Stringmap &ToDict() const;
56
57 private:
58 Stringmap dict_;
Darin Petkove9d12e02011-07-27 15:09:37 -070059
Chris Masone889666b2011-07-03 12:58:50 -070060 DISALLOW_COPY_AND_ASSIGN(Network);
61 };
62
63 struct SimLockStatus {
64 public:
Darin Petkove9d12e02011-07-27 15:09:37 -070065 SimLockStatus() : retries_left(0) {}
66
Chris Masone889666b2011-07-03 12:58:50 -070067 std::string lock_type;
68 uint32 retries_left;
69 };
70
Darin Petkove9d12e02011-07-27 15:09:37 -070071 // |owner| is the ModemManager DBus service owner (e.g., ":1.17"). |path| is
72 // the ModemManager.Modem DBus object path (e.g.,
73 // "/org/chromium/ModemManager/Gobi/0").
Chris Masone3bd3c8c2011-06-13 08:20:26 -070074 Cellular(ControlInterface *control_interface,
75 EventDispatcher *dispatcher,
76 Manager *manager,
Darin Petkove9d12e02011-07-27 15:09:37 -070077 const std::string &link_name,
78 int interface_index,
79 Type type,
80 const std::string &owner,
81 const std::string &path);
82 virtual ~Cellular();
83
84 // Inherited from Device.
85 virtual void Start();
86 virtual void Stop();
87 virtual bool TechnologyIs(Technology type);
Chris Masone3bd3c8c2011-06-13 08:20:26 -070088
89 private:
Darin Petkove9d12e02011-07-27 15:09:37 -070090 FRIEND_TEST(CellularTest, GetStateString);
91 FRIEND_TEST(CellularTest, GetTypeString);
92 FRIEND_TEST(CellularTest, Start);
93
Chris Masone889666b2011-07-03 12:58:50 -070094 Stringmaps EnumerateNetworks();
95 StrIntPair SimLockStatusToProperty();
96 void HelpRegisterDerivedStringmaps(const std::string &name,
97 Stringmaps(Cellular::*get)(void),
98 bool(Cellular::*set)(const Stringmaps&));
99 void HelpRegisterDerivedStrIntPair(const std::string &name,
100 StrIntPair(Cellular::*get)(void),
101 bool(Cellular::*set)(const StrIntPair&));
102
Darin Petkove9d12e02011-07-27 15:09:37 -0700103 std::string GetTypeString();
104 std::string GetStateString();
105
106 Type type_;
107 State state_;
108
109 const std::string dbus_owner_; // ModemManager.Modem
110 const std::string dbus_path_; // ModemManager.Modem
111 scoped_ptr<ModemProxyInterface> proxy_;
112
Chris Masone853b81b2011-06-24 14:11:41 -0700113 ServiceRefPtr service_;
114 bool service_registered_;
115
Chris Masoneb925cc82011-06-22 15:39:57 -0700116 // Properties
117 bool allow_roaming_;
118 std::string carrier_;
119 std::string meid_;
120 std::string imei_;
121 std::string imsi_;
122 std::string esn_;
123 std::string mdn_;
124 std::string min_;
125 std::string model_id_;
126 std::string manufacturer_;
127 std::string firmware_revision_;
128 std::string hardware_revision_;
129 int16 prl_version_;
Chris Masoneb925cc82011-06-22 15:39:57 -0700130 bool scanning_;
131 uint16 scan_interval_;
Chris Masone889666b2011-07-03 12:58:50 -0700132 std::vector<Network> found_networks_;
133 SimLockStatus sim_lock_status_;
Chris Masoneb925cc82011-06-22 15:39:57 -0700134
Chris Masone3bd3c8c2011-06-13 08:20:26 -0700135 DISALLOW_COPY_AND_ASSIGN(Cellular);
136};
137
138} // namespace shill
139
140#endif // SHILL_CELLULAR_