summaryrefslogtreecommitdiffstats
path: root/chromeos/network/cros_network_functions.h
blob: e787a3fd31b819243047da263159cfc56e9da7a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROMEOS_NETWORK_CROS_NETWORK_FUNCTIONS_H_
#define CHROMEOS_NETWORK_CROS_NETWORK_FUNCTIONS_H_

// This header is introduced to make it easy to switch from chromeos_network.cc
// to Chrome's own DBus code.  crosbug.com/16557
//
// All calls to functions in chromeos_network.h should be made through
// functions provided by this header.
//
// DO NOT INCLUDE THIS HEADER DIRECTLY, THESE FUNCTIONS ARE BEING DEPRECATED.
// Contact stevenjb@chromium.org and/or see crbug.com/154852

#include <vector>

#include "base/callback.h"
#include "chromeos/chromeos_export.h"
#include "chromeos/network/network_ip_config.h"
#include "chromeos/network/network_util.h"

namespace base {

class DictionaryValue;
class Value;

}  // namespace base

namespace chromeos {

// Callback to be called when receiving a SMS.
typedef base::Callback<void(const std::string& modem_device_path,
                            const SMS& message)> MonitorSMSCallback;

// Callback for asynchronous getters.
typedef base::Callback<void(
    const std::string& path,
    const base::DictionaryValue* properties)> NetworkPropertiesCallback;

// Callback for network properties watchers.
typedef base::Callback<void(
    const std::string& path,
    const std::string& key,
    const base::Value& value)> NetworkPropertiesWatcherCallback;

// Base class of signal watchers.
class CHROMEOS_EXPORT CrosNetworkWatcher {
 public:
  virtual ~CrosNetworkWatcher() {}

 protected:
  CrosNetworkWatcher() {}
};

// Activates the cellular modem specified by |service_path| with carrier
// specified by |carrier|.
// |carrier| is NULL or an empty string, this will activate with the currently
// active carrier.
// Returns false on failure and true on success.
CHROMEOS_EXPORT bool CrosActivateCellularModem(const std::string& service_path,
                                               const std::string& carrier);

// Completes the activation for the cellular modem specified by |service_path|.
CHROMEOS_EXPORT void CrosCompleteCellularActivation(
    const std::string& service_path);

// Sets a property of a service to the provided value.
// Success is indicated by the receipt of a matching PropertyChanged signal.
CHROMEOS_EXPORT void CrosSetNetworkServiceProperty(
    const std::string& service_path,
    const std::string& property,
    const base::Value& value);

// Clears a property of a service.
CHROMEOS_EXPORT void CrosClearNetworkServiceProperty(
    const std::string& service_path,
    const std::string& property);

// Sets a property of a device to the provided value.
// Success is indicated by the receipt of a matching PropertyChanged signal.
CHROMEOS_EXPORT void CrosSetNetworkDeviceProperty(
    const std::string& device_path,
    const std::string& property,
    const base::Value& value);

// Sets a property of an ip config to the provided value.
// Success is indicated by the receipt of a matching PropertyChanged signal.
CHROMEOS_EXPORT void CrosSetNetworkIPConfigProperty(
    const std::string& ipconfig_path,
    const std::string& property,
    const base::Value& value);

// Sets a property of a manager to the provided value.
// Success is indicated by the receipt of a matching PropertyChanged signal.
CHROMEOS_EXPORT void CrosSetNetworkManagerProperty(const std::string& property,
                                                   const base::Value& value);

// Deletes a remembered service from a profile.
CHROMEOS_EXPORT void CrosDeleteServiceFromProfile(
    const std::string& profile_path,
    const std::string& service_path);

// Sets up monitoring of the PropertyChanged signal on the shill manager.
// The provided |callback| will be called whenever a manager property changes.
CHROMEOS_EXPORT CrosNetworkWatcher* CrosMonitorNetworkManagerProperties(
    const NetworkPropertiesWatcherCallback& callback);

// Similar to MonitorNetworkManagerProperties for a specified network service.
CHROMEOS_EXPORT CrosNetworkWatcher* CrosMonitorNetworkServiceProperties(
    const NetworkPropertiesWatcherCallback& callback,
    const std::string& service_path);

// Similar to MonitorNetworkManagerProperties for a specified network device.
CHROMEOS_EXPORT CrosNetworkWatcher* CrosMonitorNetworkDeviceProperties(
    const NetworkPropertiesWatcherCallback& callback,
    const std::string& device_path);

// Similar to MonitorNetworkManagerProperties for a specified network device.
CHROMEOS_EXPORT CrosNetworkWatcher* CrosMonitorSMS(
    const std::string& modem_device_path,
    MonitorSMSCallback callback);

// Connects to the service with the |service_path|.
// Service parameters such as authentication must already be configured.
// Note, a successful invocation of the callback only indicates that
// the connection process has started. You will have to query the
// connection state to determine if the connection was established
// successfully.
CHROMEOS_EXPORT void CrosRequestNetworkServiceConnect(
    const std::string& service_path,
    const NetworkOperationCallback& callback);

// Retrieves the latest info for the manager.
CHROMEOS_EXPORT void CrosRequestNetworkManagerProperties(
    const NetworkPropertiesCallback& callback);

// Retrieves the latest info for a service.
CHROMEOS_EXPORT void CrosRequestNetworkServiceProperties(
    const std::string& service_path,
    const NetworkPropertiesCallback& callback);

// Retrieves the latest info for a particular device.
CHROMEOS_EXPORT void CrosRequestNetworkDeviceProperties(
    const std::string& device_path,
    const NetworkPropertiesCallback& callback);

// Retrieves the list of remembered services for a profile.
CHROMEOS_EXPORT void CrosRequestNetworkProfileProperties(
    const std::string& profile_path,
    const NetworkPropertiesCallback& callback);

// Retrieves the latest info for a profile service entry.
CHROMEOS_EXPORT void CrosRequestNetworkProfileEntryProperties(
    const std::string& profile_path,
    const std::string& profile_entry_path,
    const NetworkPropertiesCallback& callback);

// Requests a wifi service not in the network list (i.e. hidden).
CHROMEOS_EXPORT void CrosRequestHiddenWifiNetworkProperties(
    const std::string& ssid,
    const std::string& security,
    const NetworkPropertiesCallback& callback);

// Requests a new VPN service.
CHROMEOS_EXPORT void CrosRequestVirtualNetworkProperties(
    const std::string& service_name,
    const std::string& server_hostname,
    const std::string& provider_type,
    const NetworkPropertiesCallback& callback);

// Disconnects from network service asynchronously.
CHROMEOS_EXPORT void CrosRequestNetworkServiceDisconnect(
    const std::string& service_path);

// Removes an exisiting network service (e.g. after forgetting a VPN).
CHROMEOS_EXPORT void CrosRequestRemoveNetworkService(
    const std::string& service_path);

// Requests a scan of services of |type|.
// |type| should be is a string recognized by shill's Manager API.
CHROMEOS_EXPORT void CrosRequestNetworkScan(const std::string& network_type);

// Requests enabling or disabling a device.
CHROMEOS_EXPORT void CrosRequestNetworkDeviceEnable(
    const std::string& network_type,
    bool enable);

// Enables or disables PIN protection for a SIM card.
CHROMEOS_EXPORT void CrosRequestRequirePin(
    const std::string& device_path,
    const std::string& pin,
    bool enable,
    const NetworkOperationCallback& callback);

// Enters a PIN to unlock a SIM card.
CHROMEOS_EXPORT void CrosRequestEnterPin(
    const std::string& device_path,
    const std::string& pin,
    const NetworkOperationCallback& callback);

// Enters a PUK to unlock a SIM card whose PIN has been entered
// incorrectly too many times. A new |pin| must be supplied
// along with the |unblock_code| (PUK).
CHROMEOS_EXPORT void CrosRequestUnblockPin(
    const std::string& device_path,
    const std::string& unblock_code,
    const std::string& pin,
    const NetworkOperationCallback& callback);

// Changes the PIN used to unlock a SIM card.
CHROMEOS_EXPORT void CrosRequestChangePin(
    const std::string& device_path,
    const std::string& old_pin,
    const std::string& new_pin,
    const NetworkOperationCallback& callback);

// Proposes to trigger a scan transaction. For cellular networks scan result
// is set in the property Cellular.FoundNetworks.
CHROMEOS_EXPORT void CrosProposeScan(const std::string& device_path);

// Initiates registration on the network specified by network_id, which is in
// the form MCCMNC. If the network ID is the empty string, then switch back to
// automatic registration mode before initiating registration.
CHROMEOS_EXPORT void CrosRequestCellularRegister(
    const std::string& device_path,
    const std::string& network_id,
    const NetworkOperationCallback& callback);

// Gets a list of all the NetworkIPConfigs using a given device path,
// and returns the information via callback.
CHROMEOS_EXPORT void CrosListIPConfigs(
    const std::string& device_path,
    const NetworkGetIPConfigsCallback& callback);

// Refreshes the IP config |ipconfig_path| to pick up changes in
// configuration, and renew the DHCP lease, if any.
CHROMEOS_EXPORT void CrosRequestIPConfigRefresh(
    const std::string& ipconfig_path);

// Configures the network service specified by |properties|.
CHROMEOS_EXPORT void CrosConfigureService(
    const base::DictionaryValue& properties);

// Changes the active cellular carrier.
CHROMEOS_EXPORT void CrosSetCarrier(const std::string& device_path,
                                    const std::string& carrier,
                                    const NetworkOperationCallback& callback);

}  // namespace chromeos

#endif  // CHROMEOS_NETWORK_CROS_NETWORK_FUNCTIONS_H_