OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/cros/network_library_impl_cros.h" | 5 #include "chrome/browser/chromeos/cros/network_library_impl_cros.h" |
6 | 6 |
7 #include <dbus/dbus-glib.h> | 7 #include <dbus/dbus-glib.h> |
8 #include "base/json/json_writer.h" // for debug output only. | 8 #include "base/json/json_writer.h" // for debug output only. |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "chrome/browser/chromeos/cros/cros_library.h" | 10 #include "chrome/browser/chromeos/cros/cros_library.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 //////////////////////////////////////////////////////////////////////////// | 173 //////////////////////////////////////////////////////////////////////////// |
174 | 174 |
175 NetworkLibraryImplCros::NetworkLibraryImplCros() | 175 NetworkLibraryImplCros::NetworkLibraryImplCros() |
176 : NetworkLibraryImplBase(), | 176 : NetworkLibraryImplBase(), |
177 network_manager_monitor_(NULL), | 177 network_manager_monitor_(NULL), |
178 data_plan_monitor_(NULL) { | 178 data_plan_monitor_(NULL) { |
179 } | 179 } |
180 | 180 |
181 NetworkLibraryImplCros::~NetworkLibraryImplCros() { | 181 NetworkLibraryImplCros::~NetworkLibraryImplCros() { |
182 if (network_manager_monitor_) | 182 if (network_manager_monitor_) |
183 chromeos::DisconnectNetworkPropertiesMonitor(network_manager_monitor_); | 183 CrosDisconnectNetworkPropertiesMonitor(network_manager_monitor_); |
184 if (data_plan_monitor_) | 184 if (data_plan_monitor_) |
185 chromeos::DisconnectDataPlanUpdateMonitor(data_plan_monitor_); | 185 CrosDisconnectDataPlanUpdateMonitor(data_plan_monitor_); |
186 for (NetworkPropertiesMonitorMap::iterator iter = | 186 for (NetworkPropertiesMonitorMap::iterator iter = |
187 montitored_networks_.begin(); | 187 montitored_networks_.begin(); |
188 iter != montitored_networks_.end(); ++iter) { | 188 iter != montitored_networks_.end(); ++iter) { |
189 chromeos::DisconnectNetworkPropertiesMonitor(iter->second); | 189 CrosDisconnectNetworkPropertiesMonitor(iter->second); |
190 } | 190 } |
191 for (NetworkPropertiesMonitorMap::iterator iter = | 191 for (NetworkPropertiesMonitorMap::iterator iter = |
192 montitored_devices_.begin(); | 192 montitored_devices_.begin(); |
193 iter != montitored_devices_.end(); ++iter) { | 193 iter != montitored_devices_.end(); ++iter) { |
194 chromeos::DisconnectNetworkPropertiesMonitor(iter->second); | 194 CrosDisconnectNetworkPropertiesMonitor(iter->second); |
195 } | 195 } |
196 } | 196 } |
197 | 197 |
198 void NetworkLibraryImplCros::Init() { | 198 void NetworkLibraryImplCros::Init() { |
199 CHECK(CrosLibrary::Get()->libcros_loaded()) | 199 CHECK(CrosLibrary::Get()->libcros_loaded()) |
200 << "libcros must be loaded before NetworkLibraryImplCros::Init()"; | 200 << "libcros must be loaded before NetworkLibraryImplCros::Init()"; |
201 // First, get the currently available networks. This data is cached | 201 // First, get the currently available networks. This data is cached |
202 // on the connman side, so the call should be quick. | 202 // on the connman side, so the call should be quick. |
203 VLOG(1) << "Requesting initial network manager info from libcros."; | 203 VLOG(1) << "Requesting initial network manager info from libcros."; |
204 chromeos::RequestNetworkManagerProperties(&NetworkManagerUpdate, this); | 204 CrosRequestNetworkManagerProperties(&NetworkManagerUpdate, this); |
205 network_manager_monitor_ = | 205 network_manager_monitor_ = |
206 chromeos::MonitorNetworkManagerProperties( | 206 CrosMonitorNetworkManagerProperties( |
207 &NetworkManagerStatusChangedHandler, this); | 207 &NetworkManagerStatusChangedHandler, this); |
208 data_plan_monitor_ = | 208 data_plan_monitor_ = |
209 chromeos::MonitorCellularDataPlan(&DataPlanUpdateHandler, this); | 209 CrosMonitorCellularDataPlan(&DataPlanUpdateHandler, this); |
210 // Always have at least one device obsever so that device updates are | 210 // Always have at least one device obsever so that device updates are |
211 // always received. | 211 // always received. |
212 network_device_observer_.reset(new NetworkLibraryDeviceObserver()); | 212 network_device_observer_.reset(new NetworkLibraryDeviceObserver()); |
213 } | 213 } |
214 | 214 |
215 bool NetworkLibraryImplCros::IsCros() const { | 215 bool NetworkLibraryImplCros::IsCros() const { |
216 return true; | 216 return true; |
217 } | 217 } |
218 | 218 |
219 ////////////////////////////////////////////////////////////////////////////// | 219 ////////////////////////////////////////////////////////////////////////////// |
220 // NetworkLibraryImplBase implementation. | 220 // NetworkLibraryImplBase implementation. |
221 | 221 |
222 void NetworkLibraryImplCros::MonitorNetworkStart( | 222 void NetworkLibraryImplCros::MonitorNetworkStart( |
223 const std::string& service_path) { | 223 const std::string& service_path) { |
224 if (montitored_networks_.find(service_path) == montitored_networks_.end()) { | 224 if (montitored_networks_.find(service_path) == montitored_networks_.end()) { |
225 chromeos::NetworkPropertiesMonitor monitor = | 225 chromeos::NetworkPropertiesMonitor monitor = |
226 chromeos::MonitorNetworkServiceProperties( | 226 CrosMonitorNetworkServiceProperties( |
227 &NetworkStatusChangedHandler, service_path.c_str(), this); | 227 &NetworkStatusChangedHandler, service_path.c_str(), this); |
228 montitored_networks_[service_path] = monitor; | 228 montitored_networks_[service_path] = monitor; |
229 } | 229 } |
230 } | 230 } |
231 | 231 |
232 void NetworkLibraryImplCros::MonitorNetworkStop( | 232 void NetworkLibraryImplCros::MonitorNetworkStop( |
233 const std::string& service_path) { | 233 const std::string& service_path) { |
234 NetworkPropertiesMonitorMap::iterator iter = | 234 NetworkPropertiesMonitorMap::iterator iter = |
235 montitored_networks_.find(service_path); | 235 montitored_networks_.find(service_path); |
236 if (iter != montitored_networks_.end()) { | 236 if (iter != montitored_networks_.end()) { |
237 chromeos::DisconnectNetworkPropertiesMonitor(iter->second); | 237 CrosDisconnectNetworkPropertiesMonitor(iter->second); |
238 montitored_networks_.erase(iter); | 238 montitored_networks_.erase(iter); |
239 } | 239 } |
240 } | 240 } |
241 | 241 |
242 void NetworkLibraryImplCros::MonitorNetworkDeviceStart( | 242 void NetworkLibraryImplCros::MonitorNetworkDeviceStart( |
243 const std::string& device_path) { | 243 const std::string& device_path) { |
244 if (montitored_devices_.find(device_path) == montitored_devices_.end()) { | 244 if (montitored_devices_.find(device_path) == montitored_devices_.end()) { |
245 chromeos::NetworkPropertiesMonitor monitor = | 245 chromeos::NetworkPropertiesMonitor monitor = |
246 chromeos::MonitorNetworkDeviceProperties( | 246 CrosMonitorNetworkDeviceProperties( |
247 &NetworkDevicePropertyChangedHandler, device_path.c_str(), this); | 247 &NetworkDevicePropertyChangedHandler, device_path.c_str(), this); |
248 montitored_devices_[device_path] = monitor; | 248 montitored_devices_[device_path] = monitor; |
249 } | 249 } |
250 } | 250 } |
251 | 251 |
252 void NetworkLibraryImplCros::MonitorNetworkDeviceStop( | 252 void NetworkLibraryImplCros::MonitorNetworkDeviceStop( |
253 const std::string& device_path) { | 253 const std::string& device_path) { |
254 NetworkPropertiesMonitorMap::iterator iter = | 254 NetworkPropertiesMonitorMap::iterator iter = |
255 montitored_devices_.find(device_path); | 255 montitored_devices_.find(device_path); |
256 if (iter != montitored_devices_.end()) { | 256 if (iter != montitored_devices_.end()) { |
257 chromeos::DisconnectNetworkPropertiesMonitor(iter->second); | 257 CrosDisconnectNetworkPropertiesMonitor(iter->second); |
258 montitored_devices_.erase(iter); | 258 montitored_devices_.erase(iter); |
259 } | 259 } |
260 } | 260 } |
261 | 261 |
262 // static callback | 262 // static callback |
263 void NetworkLibraryImplCros::NetworkStatusChangedHandler( | 263 void NetworkLibraryImplCros::NetworkStatusChangedHandler( |
264 void* object, const char* path, const char* key, const GValue* gvalue) { | 264 void* object, const char* path, const char* key, const GValue* gvalue) { |
265 DCHECK(CrosLibrary::Get()->libcros_loaded()); | 265 DCHECK(CrosLibrary::Get()->libcros_loaded()); |
266 NetworkLibraryImplCros* networklib = | 266 NetworkLibraryImplCros* networklib = |
267 static_cast<NetworkLibraryImplCros*>(object); | 267 static_cast<NetworkLibraryImplCros*>(object); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 } | 330 } |
331 } | 331 } |
332 } else { | 332 } else { |
333 VLOG(1) << "UpdateNetworkDeviceStatus: Failed to update: " | 333 VLOG(1) << "UpdateNetworkDeviceStatus: Failed to update: " |
334 << path << "." << key; | 334 << path << "." << key; |
335 } | 335 } |
336 // Notify only observers on device property change. | 336 // Notify only observers on device property change. |
337 NotifyNetworkDeviceChanged(device, index); | 337 NotifyNetworkDeviceChanged(device, index); |
338 // If a device's power state changes, new properties may become defined. | 338 // If a device's power state changes, new properties may become defined. |
339 if (index == PROPERTY_INDEX_POWERED) | 339 if (index == PROPERTY_INDEX_POWERED) |
340 chromeos::RequestNetworkDeviceProperties(path.c_str(), | 340 CrosRequestNetworkDeviceProperties(path.c_str(), |
341 &NetworkDeviceUpdate, | 341 &NetworkDeviceUpdate, |
342 this); | 342 this); |
343 } | 343 } |
344 } | 344 } |
345 | 345 |
346 ///////////////////////////////////////////////////////////////////////////// | 346 ///////////////////////////////////////////////////////////////////////////// |
347 // NetworkLibraryImplBase connect implementation. | 347 // NetworkLibraryImplBase connect implementation. |
348 | 348 |
349 // static callback | 349 // static callback |
350 void NetworkLibraryImplCros::ConfigureServiceCallback( | 350 void NetworkLibraryImplCros::ConfigureServiceCallback( |
351 void* object, | 351 void* object, |
352 const char* service_path, | 352 const char* service_path, |
353 NetworkMethodErrorType error, | 353 NetworkMethodErrorType error, |
354 const char* error_message) { | 354 const char* error_message) { |
355 if (error != NETWORK_METHOD_ERROR_NONE) { | 355 if (error != NETWORK_METHOD_ERROR_NONE) { |
356 LOG(WARNING) << "Error from ConfigureService callback for: " | 356 LOG(WARNING) << "Error from ConfigureService callback for: " |
357 << service_path | 357 << service_path |
358 << " Error: " << error << " Message: " << error_message; | 358 << " Error: " << error << " Message: " << error_message; |
359 } | 359 } |
360 } | 360 } |
361 | 361 |
362 void NetworkLibraryImplCros::CallConfigureService(const std::string& identifier, | 362 void NetworkLibraryImplCros::CallConfigureService(const std::string& identifier, |
363 const DictionaryValue* info) { | 363 const DictionaryValue* info) { |
364 GHashTable* ghash = ConvertDictionaryValueToGValueMap(info); | 364 GHashTable* ghash = ConvertDictionaryValueToGValueMap(info); |
365 if (VLOG_IS_ON(2)) { | 365 if (VLOG_IS_ON(2)) { |
366 scoped_ptr<DictionaryValue> dict(ConvertGHashTable(ghash)); | 366 scoped_ptr<DictionaryValue> dict(ConvertGHashTable(ghash)); |
367 std::string dict_json; | 367 std::string dict_json; |
368 base::JSONWriter::Write(static_cast<Value*>(dict.get()), true, &dict_json); | 368 base::JSONWriter::Write(static_cast<Value*>(dict.get()), true, &dict_json); |
369 VLOG(2) << "ConfigureService will be called on:" << dict_json; | 369 VLOG(2) << "ConfigureService will be called on:" << dict_json; |
370 } | 370 } |
371 chromeos::ConfigureService(identifier.c_str(), ghash, | 371 CrosConfigureService(identifier.c_str(), ghash, |
372 ConfigureServiceCallback, this); | 372 ConfigureServiceCallback, this); |
373 } | 373 } |
374 | 374 |
375 // static callback | 375 // static callback |
376 void NetworkLibraryImplCros::NetworkConnectCallback( | 376 void NetworkLibraryImplCros::NetworkConnectCallback( |
377 void* object, | 377 void* object, |
378 const char* service_path, | 378 const char* service_path, |
379 NetworkMethodErrorType error, | 379 NetworkMethodErrorType error, |
380 const char* error_message) { | 380 const char* error_message) { |
381 DCHECK(CrosLibrary::Get()->libcros_loaded()); | 381 DCHECK(CrosLibrary::Get()->libcros_loaded()); |
382 NetworkConnectStatus status; | 382 NetworkConnectStatus status; |
(...skipping 15 matching lines...) Expand all Loading... |
398 Network* network = networklib->FindNetworkByPath(std::string(service_path)); | 398 Network* network = networklib->FindNetworkByPath(std::string(service_path)); |
399 if (!network) { | 399 if (!network) { |
400 LOG(ERROR) << "No network for path: " << service_path; | 400 LOG(ERROR) << "No network for path: " << service_path; |
401 return; | 401 return; |
402 } | 402 } |
403 networklib->NetworkConnectCompleted(network, status); | 403 networklib->NetworkConnectCompleted(network, status); |
404 } | 404 } |
405 | 405 |
406 void NetworkLibraryImplCros::CallConnectToNetwork(Network* network) { | 406 void NetworkLibraryImplCros::CallConnectToNetwork(Network* network) { |
407 DCHECK(network); | 407 DCHECK(network); |
408 chromeos::RequestNetworkServiceConnect(network->service_path().c_str(), | 408 CrosRequestNetworkServiceConnect(network->service_path().c_str(), |
409 NetworkConnectCallback, this); | 409 NetworkConnectCallback, this); |
410 } | 410 } |
411 | 411 |
412 // static callback | 412 // static callback |
413 void NetworkLibraryImplCros::WifiServiceUpdateAndConnect( | 413 void NetworkLibraryImplCros::WifiServiceUpdateAndConnect( |
414 void* object, const char* service_path, GHashTable* ghash) { | 414 void* object, const char* service_path, GHashTable* ghash) { |
415 DCHECK(CrosLibrary::Get()->libcros_loaded()); | 415 DCHECK(CrosLibrary::Get()->libcros_loaded()); |
416 NetworkLibraryImplCros* networklib = | 416 NetworkLibraryImplCros* networklib = |
417 static_cast<NetworkLibraryImplCros*>(object); | 417 static_cast<NetworkLibraryImplCros*>(object); |
418 DCHECK(networklib); | 418 DCHECK(networklib); |
419 if (service_path && ghash) { | 419 if (service_path && ghash) { |
420 scoped_ptr<DictionaryValue> dict(ConvertGHashTable(ghash)); | 420 scoped_ptr<DictionaryValue> dict(ConvertGHashTable(ghash)); |
421 Network* network = | 421 Network* network = |
422 networklib->ParseNetwork(std::string(service_path), *(dict.get())); | 422 networklib->ParseNetwork(std::string(service_path), *(dict.get())); |
423 DCHECK_EQ(network->type(), TYPE_WIFI); | 423 DCHECK_EQ(network->type(), TYPE_WIFI); |
424 networklib->ConnectToWifiNetworkUsingConnectData( | 424 networklib->ConnectToWifiNetworkUsingConnectData( |
425 static_cast<WifiNetwork*>(network)); | 425 static_cast<WifiNetwork*>(network)); |
426 } | 426 } |
427 } | 427 } |
428 | 428 |
429 void NetworkLibraryImplCros::CallRequestWifiNetworkAndConnect( | 429 void NetworkLibraryImplCros::CallRequestWifiNetworkAndConnect( |
430 const std::string& ssid, ConnectionSecurity security) { | 430 const std::string& ssid, ConnectionSecurity security) { |
431 // Asynchronously request service properties and call | 431 // Asynchronously request service properties and call |
432 // WifiServiceUpdateAndConnect. | 432 // WifiServiceUpdateAndConnect. |
433 chromeos::RequestHiddenWifiNetworkProperties( | 433 CrosRequestHiddenWifiNetworkProperties( |
434 ssid.c_str(), | 434 ssid.c_str(), |
435 SecurityToString(security), | 435 SecurityToString(security), |
436 WifiServiceUpdateAndConnect, | 436 WifiServiceUpdateAndConnect, |
437 this); | 437 this); |
438 } | 438 } |
439 | 439 |
440 // static callback | 440 // static callback |
441 void NetworkLibraryImplCros::VPNServiceUpdateAndConnect( | 441 void NetworkLibraryImplCros::VPNServiceUpdateAndConnect( |
442 void* object, const char* service_path, GHashTable* ghash) { | 442 void* object, const char* service_path, GHashTable* ghash) { |
443 DCHECK(CrosLibrary::Get()->libcros_loaded()); | 443 DCHECK(CrosLibrary::Get()->libcros_loaded()); |
(...skipping 10 matching lines...) Expand all Loading... |
454 static_cast<VirtualNetwork*>(network)); | 454 static_cast<VirtualNetwork*>(network)); |
455 } else { | 455 } else { |
456 LOG(WARNING) << "Unable to create VPN Service: " << service_path; | 456 LOG(WARNING) << "Unable to create VPN Service: " << service_path; |
457 } | 457 } |
458 } | 458 } |
459 | 459 |
460 void NetworkLibraryImplCros::CallRequestVirtualNetworkAndConnect( | 460 void NetworkLibraryImplCros::CallRequestVirtualNetworkAndConnect( |
461 const std::string& service_name, | 461 const std::string& service_name, |
462 const std::string& server_hostname, | 462 const std::string& server_hostname, |
463 ProviderType provider_type) { | 463 ProviderType provider_type) { |
464 chromeos::RequestVirtualNetworkProperties( | 464 CrosRequestVirtualNetworkProperties( |
465 service_name.c_str(), | 465 service_name.c_str(), |
466 server_hostname.c_str(), | 466 server_hostname.c_str(), |
467 ProviderTypeToString(provider_type), | 467 ProviderTypeToString(provider_type), |
468 VPNServiceUpdateAndConnect, | 468 VPNServiceUpdateAndConnect, |
469 this); | 469 this); |
470 } | 470 } |
471 | 471 |
472 void NetworkLibraryImplCros::CallDeleteRememberedNetwork( | 472 void NetworkLibraryImplCros::CallDeleteRememberedNetwork( |
473 const std::string& profile_path, | 473 const std::string& profile_path, |
474 const std::string& service_path) { | 474 const std::string& service_path) { |
475 chromeos::DeleteServiceFromProfile( | 475 CrosDeleteServiceFromProfile( |
476 profile_path.c_str(), service_path.c_str()); | 476 profile_path.c_str(), service_path.c_str()); |
477 } | 477 } |
478 | 478 |
479 ////////////////////////////////////////////////////////////////////////////// | 479 ////////////////////////////////////////////////////////////////////////////// |
480 // NetworkLibrary implementation. | 480 // NetworkLibrary implementation. |
481 | 481 |
482 void NetworkLibraryImplCros::ChangePin(const std::string& old_pin, | 482 void NetworkLibraryImplCros::ChangePin(const std::string& old_pin, |
483 const std::string& new_pin) { | 483 const std::string& new_pin) { |
484 const NetworkDevice* cellular = FindCellularDevice(); | 484 const NetworkDevice* cellular = FindCellularDevice(); |
485 if (!cellular) { | 485 if (!cellular) { |
486 NOTREACHED() << "Calling ChangePin method w/o cellular device."; | 486 NOTREACHED() << "Calling ChangePin method w/o cellular device."; |
487 return; | 487 return; |
488 } | 488 } |
489 sim_operation_ = SIM_OPERATION_CHANGE_PIN; | 489 sim_operation_ = SIM_OPERATION_CHANGE_PIN; |
490 chromeos::RequestChangePin(cellular->device_path().c_str(), | 490 CrosRequestChangePin(cellular->device_path().c_str(), |
491 old_pin.c_str(), new_pin.c_str(), | 491 old_pin.c_str(), new_pin.c_str(), |
492 PinOperationCallback, this); | 492 PinOperationCallback, this); |
493 } | 493 } |
494 | 494 |
495 void NetworkLibraryImplCros::ChangeRequirePin(bool require_pin, | 495 void NetworkLibraryImplCros::ChangeRequirePin(bool require_pin, |
496 const std::string& pin) { | 496 const std::string& pin) { |
497 VLOG(1) << "ChangeRequirePin require_pin: " << require_pin | 497 VLOG(1) << "ChangeRequirePin require_pin: " << require_pin |
498 << " pin: " << pin; | 498 << " pin: " << pin; |
499 const NetworkDevice* cellular = FindCellularDevice(); | 499 const NetworkDevice* cellular = FindCellularDevice(); |
500 if (!cellular) { | 500 if (!cellular) { |
501 NOTREACHED() << "Calling ChangeRequirePin method w/o cellular device."; | 501 NOTREACHED() << "Calling ChangeRequirePin method w/o cellular device."; |
502 return; | 502 return; |
503 } | 503 } |
504 sim_operation_ = SIM_OPERATION_CHANGE_REQUIRE_PIN; | 504 sim_operation_ = SIM_OPERATION_CHANGE_REQUIRE_PIN; |
505 chromeos::RequestRequirePin(cellular->device_path().c_str(), | 505 CrosRequestRequirePin(cellular->device_path().c_str(), |
506 pin.c_str(), require_pin, | 506 pin.c_str(), require_pin, |
507 PinOperationCallback, this); | 507 PinOperationCallback, this); |
508 } | 508 } |
509 | 509 |
510 void NetworkLibraryImplCros::EnterPin(const std::string& pin) { | 510 void NetworkLibraryImplCros::EnterPin(const std::string& pin) { |
511 const NetworkDevice* cellular = FindCellularDevice(); | 511 const NetworkDevice* cellular = FindCellularDevice(); |
512 if (!cellular) { | 512 if (!cellular) { |
513 NOTREACHED() << "Calling EnterPin method w/o cellular device."; | 513 NOTREACHED() << "Calling EnterPin method w/o cellular device."; |
514 return; | 514 return; |
515 } | 515 } |
516 sim_operation_ = SIM_OPERATION_ENTER_PIN; | 516 sim_operation_ = SIM_OPERATION_ENTER_PIN; |
517 chromeos::RequestEnterPin(cellular->device_path().c_str(), | 517 CrosRequestEnterPin(cellular->device_path().c_str(), |
518 pin.c_str(), | 518 pin.c_str(), |
519 PinOperationCallback, this); | 519 PinOperationCallback, this); |
520 } | 520 } |
521 | 521 |
522 void NetworkLibraryImplCros::UnblockPin(const std::string& puk, | 522 void NetworkLibraryImplCros::UnblockPin(const std::string& puk, |
523 const std::string& new_pin) { | 523 const std::string& new_pin) { |
524 const NetworkDevice* cellular = FindCellularDevice(); | 524 const NetworkDevice* cellular = FindCellularDevice(); |
525 if (!cellular) { | 525 if (!cellular) { |
526 NOTREACHED() << "Calling UnblockPin method w/o cellular device."; | 526 NOTREACHED() << "Calling UnblockPin method w/o cellular device."; |
527 return; | 527 return; |
528 } | 528 } |
529 sim_operation_ = SIM_OPERATION_UNBLOCK_PIN; | 529 sim_operation_ = SIM_OPERATION_UNBLOCK_PIN; |
530 chromeos::RequestUnblockPin(cellular->device_path().c_str(), | 530 CrosRequestUnblockPin(cellular->device_path().c_str(), |
531 puk.c_str(), new_pin.c_str(), | 531 puk.c_str(), new_pin.c_str(), |
532 PinOperationCallback, this); | 532 PinOperationCallback, this); |
533 } | 533 } |
534 | 534 |
535 // static callback | 535 // static callback |
536 void NetworkLibraryImplCros::PinOperationCallback( | 536 void NetworkLibraryImplCros::PinOperationCallback( |
537 void* object, | 537 void* object, |
538 const char* path, | 538 const char* path, |
539 NetworkMethodErrorType error, | 539 NetworkMethodErrorType error, |
540 const char* error_message) { | 540 const char* error_message) { |
541 DCHECK(CrosLibrary::Get()->libcros_loaded()); | 541 DCHECK(CrosLibrary::Get()->libcros_loaded()); |
542 NetworkLibraryImplCros* networklib = | 542 NetworkLibraryImplCros* networklib = |
(...skipping 20 matching lines...) Expand all Loading... |
563 } | 563 } |
564 networklib->NotifyPinOperationCompleted(pin_error); | 564 networklib->NotifyPinOperationCompleted(pin_error); |
565 } | 565 } |
566 | 566 |
567 void NetworkLibraryImplCros::RequestCellularScan() { | 567 void NetworkLibraryImplCros::RequestCellularScan() { |
568 const NetworkDevice* cellular = FindCellularDevice(); | 568 const NetworkDevice* cellular = FindCellularDevice(); |
569 if (!cellular) { | 569 if (!cellular) { |
570 NOTREACHED() << "Calling RequestCellularScan method w/o cellular device."; | 570 NOTREACHED() << "Calling RequestCellularScan method w/o cellular device."; |
571 return; | 571 return; |
572 } | 572 } |
573 chromeos::ProposeScan(cellular->device_path().c_str()); | 573 CrosProposeScan(cellular->device_path().c_str()); |
574 } | 574 } |
575 | 575 |
576 void NetworkLibraryImplCros::RequestCellularRegister( | 576 void NetworkLibraryImplCros::RequestCellularRegister( |
577 const std::string& network_id) { | 577 const std::string& network_id) { |
578 const NetworkDevice* cellular = FindCellularDevice(); | 578 const NetworkDevice* cellular = FindCellularDevice(); |
579 if (!cellular) { | 579 if (!cellular) { |
580 NOTREACHED() << "Calling CellularRegister method w/o cellular device."; | 580 NOTREACHED() << "Calling CellularRegister method w/o cellular device."; |
581 return; | 581 return; |
582 } | 582 } |
583 chromeos::RequestCellularRegister(cellular->device_path().c_str(), | 583 CrosRequestCellularRegister(cellular->device_path().c_str(), |
584 network_id.c_str(), | 584 network_id.c_str(), |
585 CellularRegisterCallback, | 585 CellularRegisterCallback, |
586 this); | 586 this); |
587 } | 587 } |
588 | 588 |
589 // static callback | 589 // static callback |
590 void NetworkLibraryImplCros::CellularRegisterCallback( | 590 void NetworkLibraryImplCros::CellularRegisterCallback( |
591 void* object, | 591 void* object, |
592 const char* path, | 592 const char* path, |
593 NetworkMethodErrorType error, | 593 NetworkMethodErrorType error, |
594 const char* error_message) { | 594 const char* error_message) { |
595 DCHECK(CrosLibrary::Get()->libcros_loaded()); | 595 DCHECK(CrosLibrary::Get()->libcros_loaded()); |
596 NetworkLibraryImplCros* networklib = | 596 NetworkLibraryImplCros* networklib = |
597 static_cast<NetworkLibraryImplCros*>(object); | 597 static_cast<NetworkLibraryImplCros*>(object); |
598 DCHECK(networklib); | 598 DCHECK(networklib); |
599 // TODO(dpolukhin): Notify observers about network registration status | 599 // TODO(dpolukhin): Notify observers about network registration status |
600 // but not UI doesn't assume such notification so just ignore result. | 600 // but not UI doesn't assume such notification so just ignore result. |
601 } | 601 } |
602 | 602 |
603 void NetworkLibraryImplCros::SetCellularDataRoamingAllowed(bool new_value) { | 603 void NetworkLibraryImplCros::SetCellularDataRoamingAllowed(bool new_value) { |
604 const NetworkDevice* cellular = FindCellularDevice(); | 604 const NetworkDevice* cellular = FindCellularDevice(); |
605 if (!cellular) { | 605 if (!cellular) { |
606 NOTREACHED() << "Calling SetCellularDataRoamingAllowed method " | 606 NOTREACHED() << "Calling SetCellularDataRoamingAllowed method " |
607 "w/o cellular device."; | 607 "w/o cellular device."; |
608 return; | 608 return; |
609 } | 609 } |
610 scoped_ptr<GValue> gvalue(ConvertBoolToGValue(new_value)); | 610 scoped_ptr<GValue> gvalue(ConvertBoolToGValue(new_value)); |
611 chromeos::SetNetworkDevicePropertyGValue( | 611 CrosSetNetworkDevicePropertyGValue( |
612 cellular->device_path().c_str(), | 612 cellular->device_path().c_str(), |
613 flimflam::kCellularAllowRoamingProperty, gvalue.get()); | 613 flimflam::kCellularAllowRoamingProperty, gvalue.get()); |
614 } | 614 } |
615 | 615 |
616 bool NetworkLibraryImplCros::IsCellularAlwaysInRoaming() { | 616 bool NetworkLibraryImplCros::IsCellularAlwaysInRoaming() { |
617 const NetworkDevice* cellular = FindCellularDevice(); | 617 const NetworkDevice* cellular = FindCellularDevice(); |
618 if (!cellular) { | 618 if (!cellular) { |
619 NOTREACHED() << "Calling IsCellularAlwaysInRoaming method " | 619 NOTREACHED() << "Calling IsCellularAlwaysInRoaming method " |
620 "w/o cellular device."; | 620 "w/o cellular device."; |
621 return false; | 621 return false; |
622 } | 622 } |
623 const std::string& home_provider_name = cellular->home_provider_name(); | 623 const std::string& home_provider_name = cellular->home_provider_name(); |
624 for (size_t i = 0; i < arraysize(kAlwaysInRoamingOperators); i++) { | 624 for (size_t i = 0; i < arraysize(kAlwaysInRoamingOperators); i++) { |
625 if (home_provider_name == kAlwaysInRoamingOperators[i]) | 625 if (home_provider_name == kAlwaysInRoamingOperators[i]) |
626 return true; | 626 return true; |
627 } | 627 } |
628 return false; | 628 return false; |
629 } | 629 } |
630 | 630 |
631 void NetworkLibraryImplCros::RequestNetworkScan() { | 631 void NetworkLibraryImplCros::RequestNetworkScan() { |
632 if (wifi_enabled()) { | 632 if (wifi_enabled()) { |
633 wifi_scanning_ = true; // Cleared when updates are received. | 633 wifi_scanning_ = true; // Cleared when updates are received. |
634 chromeos::RequestNetworkScan(flimflam::kTypeWifi); | 634 CrosRequestNetworkScan(flimflam::kTypeWifi); |
635 } | 635 } |
636 if (cellular_network()) | 636 if (cellular_network()) |
637 cellular_network()->RefreshDataPlansIfNeeded(); | 637 cellular_network()->RefreshDataPlansIfNeeded(); |
638 // Make sure all Manager info is up to date. This will also update | 638 // Make sure all Manager info is up to date. This will also update |
639 // remembered networks and visible services. | 639 // remembered networks and visible services. |
640 chromeos::RequestNetworkManagerProperties(&NetworkManagerUpdate, this); | 640 CrosRequestNetworkManagerProperties(&NetworkManagerUpdate, this); |
641 } | 641 } |
642 | 642 |
643 bool NetworkLibraryImplCros::GetWifiAccessPoints( | 643 bool NetworkLibraryImplCros::GetWifiAccessPoints( |
644 WifiAccessPointVector* result) { | 644 WifiAccessPointVector* result) { |
645 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 645 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
646 DeviceNetworkList* network_list = chromeos::GetDeviceNetworkList(); | 646 DeviceNetworkList* network_list = CrosGetDeviceNetworkList(); |
647 if (network_list == NULL) | 647 if (network_list == NULL) |
648 return false; | 648 return false; |
649 result->clear(); | 649 result->clear(); |
650 result->reserve(network_list->network_size); | 650 result->reserve(network_list->network_size); |
651 const base::Time now = base::Time::Now(); | 651 const base::Time now = base::Time::Now(); |
652 for (size_t i = 0; i < network_list->network_size; ++i) { | 652 for (size_t i = 0; i < network_list->network_size; ++i) { |
653 DCHECK(network_list->networks[i].address); | 653 DCHECK(network_list->networks[i].address); |
654 DCHECK(network_list->networks[i].name); | 654 DCHECK(network_list->networks[i].name); |
655 WifiAccessPoint ap; | 655 WifiAccessPoint ap; |
656 ap.mac_address = SafeString(network_list->networks[i].address); | 656 ap.mac_address = SafeString(network_list->networks[i].address); |
657 ap.name = SafeString(network_list->networks[i].name); | 657 ap.name = SafeString(network_list->networks[i].name); |
658 ap.timestamp = now - | 658 ap.timestamp = now - |
659 base::TimeDelta::FromSeconds(network_list->networks[i].age_seconds); | 659 base::TimeDelta::FromSeconds(network_list->networks[i].age_seconds); |
660 ap.signal_strength = network_list->networks[i].strength; | 660 ap.signal_strength = network_list->networks[i].strength; |
661 ap.channel = network_list->networks[i].channel; | 661 ap.channel = network_list->networks[i].channel; |
662 result->push_back(ap); | 662 result->push_back(ap); |
663 } | 663 } |
664 chromeos::FreeDeviceNetworkList(network_list); | 664 CrosFreeDeviceNetworkList(network_list); |
665 return true; | 665 return true; |
666 } | 666 } |
667 | 667 |
668 void NetworkLibraryImplCros::DisconnectFromNetwork(const Network* network) { | 668 void NetworkLibraryImplCros::DisconnectFromNetwork(const Network* network) { |
669 DCHECK(network); | 669 DCHECK(network); |
670 // Asynchronous disconnect request. Network state will be updated through | 670 // Asynchronous disconnect request. Network state will be updated through |
671 // the network manager once disconnect completes. | 671 // the network manager once disconnect completes. |
672 chromeos::RequestNetworkServiceDisconnect(network->service_path().c_str()); | 672 CrosRequestNetworkServiceDisconnect(network->service_path().c_str()); |
673 } | 673 } |
674 | 674 |
675 void NetworkLibraryImplCros::CallEnableNetworkDeviceType( | 675 void NetworkLibraryImplCros::CallEnableNetworkDeviceType( |
676 ConnectionType device, bool enable) { | 676 ConnectionType device, bool enable) { |
677 busy_devices_ |= 1 << device; | 677 busy_devices_ |= 1 << device; |
678 chromeos::RequestNetworkDeviceEnable( | 678 CrosRequestNetworkDeviceEnable( |
679 ConnectionTypeToString(device), enable); | 679 ConnectionTypeToString(device), enable); |
680 } | 680 } |
681 | 681 |
682 void NetworkLibraryImplCros::CallRemoveNetwork(const Network* network) { | 682 void NetworkLibraryImplCros::CallRemoveNetwork(const Network* network) { |
683 const char* service_path = network->service_path().c_str(); | 683 const char* service_path = network->service_path().c_str(); |
684 if (network->connected()) | 684 if (network->connected()) |
685 chromeos::RequestNetworkServiceDisconnect(service_path); | 685 CrosRequestNetworkServiceDisconnect(service_path); |
686 chromeos::RequestRemoveNetworkService(service_path); | 686 CrosRequestRemoveNetworkService(service_path); |
687 } | 687 } |
688 | 688 |
689 void NetworkLibraryImplCros::EnableOfflineMode(bool enable) { | 689 void NetworkLibraryImplCros::EnableOfflineMode(bool enable) { |
690 // If network device is already enabled/disabled, then don't do anything. | 690 // If network device is already enabled/disabled, then don't do anything. |
691 if (chromeos::SetOfflineMode(enable)) | 691 if (CrosSetOfflineMode(enable)) |
692 offline_mode_ = enable; | 692 offline_mode_ = enable; |
693 } | 693 } |
694 | 694 |
695 NetworkIPConfigVector NetworkLibraryImplCros::GetIPConfigs( | 695 NetworkIPConfigVector NetworkLibraryImplCros::GetIPConfigs( |
696 const std::string& device_path, | 696 const std::string& device_path, |
697 std::string* hardware_address, | 697 std::string* hardware_address, |
698 HardwareAddressFormat format) { | 698 HardwareAddressFormat format) { |
699 DCHECK(hardware_address); | 699 DCHECK(hardware_address); |
700 hardware_address->clear(); | 700 hardware_address->clear(); |
701 NetworkIPConfigVector ipconfig_vector; | 701 NetworkIPConfigVector ipconfig_vector; |
702 if (!device_path.empty()) { | 702 if (!device_path.empty()) { |
703 IPConfigStatus* ipconfig_status = ListIPConfigs(device_path.c_str()); | 703 IPConfigStatus* ipconfig_status = CrosListIPConfigs(device_path.c_str()); |
704 if (ipconfig_status) { | 704 if (ipconfig_status) { |
705 for (int i = 0; i < ipconfig_status->size; ++i) { | 705 for (int i = 0; i < ipconfig_status->size; ++i) { |
706 IPConfig ipconfig = ipconfig_status->ips[i]; | 706 IPConfig ipconfig = ipconfig_status->ips[i]; |
707 ipconfig_vector.push_back( | 707 ipconfig_vector.push_back( |
708 NetworkIPConfig(device_path, ipconfig.type, ipconfig.address, | 708 NetworkIPConfig(device_path, ipconfig.type, ipconfig.address, |
709 ipconfig.netmask, ipconfig.gateway, | 709 ipconfig.netmask, ipconfig.gateway, |
710 ipconfig.name_servers)); | 710 ipconfig.name_servers)); |
711 } | 711 } |
712 *hardware_address = ipconfig_status->hardware_address; | 712 *hardware_address = ipconfig_status->hardware_address; |
713 FreeIPConfigStatus(ipconfig_status); | 713 CrosFreeIPConfigStatus(ipconfig_status); |
714 } | 714 } |
715 } | 715 } |
716 | 716 |
717 for (size_t i = 0; i < hardware_address->size(); ++i) | 717 for (size_t i = 0; i < hardware_address->size(); ++i) |
718 (*hardware_address)[i] = toupper((*hardware_address)[i]); | 718 (*hardware_address)[i] = toupper((*hardware_address)[i]); |
719 if (format == FORMAT_COLON_SEPARATED_HEX) { | 719 if (format == FORMAT_COLON_SEPARATED_HEX) { |
720 if (hardware_address->size() % 2 == 0) { | 720 if (hardware_address->size() % 2 == 0) { |
721 std::string output; | 721 std::string output; |
722 for (size_t i = 0; i < hardware_address->size(); ++i) { | 722 for (size_t i = 0; i < hardware_address->size(); ++i) { |
723 if ((i != 0) && (i % 2 == 0)) | 723 if ((i != 0) && (i % 2 == 0)) |
724 output.push_back(':'); | 724 output.push_back(':'); |
725 output.push_back((*hardware_address)[i]); | 725 output.push_back((*hardware_address)[i]); |
726 } | 726 } |
727 *hardware_address = output; | 727 *hardware_address = output; |
728 } | 728 } |
729 } else { | 729 } else { |
730 DCHECK_EQ(format, FORMAT_RAW_HEX); | 730 DCHECK_EQ(format, FORMAT_RAW_HEX); |
731 } | 731 } |
732 return ipconfig_vector; | 732 return ipconfig_vector; |
733 } | 733 } |
734 | 734 |
735 void NetworkLibraryImplCros::SetIPConfig(const NetworkIPConfig& ipconfig) { | 735 void NetworkLibraryImplCros::SetIPConfig(const NetworkIPConfig& ipconfig) { |
736 if (ipconfig.device_path.empty()) | 736 if (ipconfig.device_path.empty()) |
737 return; | 737 return; |
738 | 738 |
739 IPConfig* ipconfig_dhcp = NULL; | 739 IPConfig* ipconfig_dhcp = NULL; |
740 IPConfig* ipconfig_static = NULL; | 740 IPConfig* ipconfig_static = NULL; |
741 | 741 |
742 IPConfigStatus* ipconfig_status = | 742 IPConfigStatus* ipconfig_status = |
743 chromeos::ListIPConfigs(ipconfig.device_path.c_str()); | 743 CrosListIPConfigs(ipconfig.device_path.c_str()); |
744 if (ipconfig_status) { | 744 if (ipconfig_status) { |
745 for (int i = 0; i < ipconfig_status->size; ++i) { | 745 for (int i = 0; i < ipconfig_status->size; ++i) { |
746 if (ipconfig_status->ips[i].type == chromeos::IPCONFIG_TYPE_DHCP) | 746 if (ipconfig_status->ips[i].type == chromeos::IPCONFIG_TYPE_DHCP) |
747 ipconfig_dhcp = &ipconfig_status->ips[i]; | 747 ipconfig_dhcp = &ipconfig_status->ips[i]; |
748 else if (ipconfig_status->ips[i].type == chromeos::IPCONFIG_TYPE_IPV4) | 748 else if (ipconfig_status->ips[i].type == chromeos::IPCONFIG_TYPE_IPV4) |
749 ipconfig_static = &ipconfig_status->ips[i]; | 749 ipconfig_static = &ipconfig_status->ips[i]; |
750 } | 750 } |
751 } | 751 } |
752 | 752 |
753 IPConfigStatus* ipconfig_status2 = NULL; | 753 IPConfigStatus* ipconfig_status2 = NULL; |
754 if (ipconfig.type == chromeos::IPCONFIG_TYPE_DHCP) { | 754 if (ipconfig.type == chromeos::IPCONFIG_TYPE_DHCP) { |
755 // If switching from static to dhcp, create new dhcp ip config. | 755 // If switching from static to dhcp, create new dhcp ip config. |
756 if (!ipconfig_dhcp) | 756 if (!ipconfig_dhcp) |
757 chromeos::AddIPConfig(ipconfig.device_path.c_str(), | 757 CrosAddIPConfig(ipconfig.device_path.c_str(), |
758 chromeos::IPCONFIG_TYPE_DHCP); | 758 chromeos::IPCONFIG_TYPE_DHCP); |
759 // User wants DHCP now. So delete the static ip config. | 759 // User wants DHCP now. So delete the static ip config. |
760 if (ipconfig_static) | 760 if (ipconfig_static) |
761 chromeos::RemoveIPConfig(ipconfig_static); | 761 CrosRemoveIPConfig(ipconfig_static); |
762 } else if (ipconfig.type == chromeos::IPCONFIG_TYPE_IPV4) { | 762 } else if (ipconfig.type == chromeos::IPCONFIG_TYPE_IPV4) { |
763 // If switching from dhcp to static, create new static ip config. | 763 // If switching from dhcp to static, create new static ip config. |
764 if (!ipconfig_static) { | 764 if (!ipconfig_static) { |
765 chromeos::AddIPConfig(ipconfig.device_path.c_str(), | 765 CrosAddIPConfig(ipconfig.device_path.c_str(), |
766 chromeos::IPCONFIG_TYPE_IPV4); | 766 chromeos::IPCONFIG_TYPE_IPV4); |
767 // Now find the newly created IP config. | 767 // Now find the newly created IP config. |
768 ipconfig_status2 = | 768 ipconfig_status2 = |
769 chromeos::ListIPConfigs(ipconfig.device_path.c_str()); | 769 CrosListIPConfigs(ipconfig.device_path.c_str()); |
770 if (ipconfig_status2) { | 770 if (ipconfig_status2) { |
771 for (int i = 0; i < ipconfig_status2->size; ++i) { | 771 for (int i = 0; i < ipconfig_status2->size; ++i) { |
772 if (ipconfig_status2->ips[i].type == chromeos::IPCONFIG_TYPE_IPV4) | 772 if (ipconfig_status2->ips[i].type == chromeos::IPCONFIG_TYPE_IPV4) |
773 ipconfig_static = &ipconfig_status2->ips[i]; | 773 ipconfig_static = &ipconfig_status2->ips[i]; |
774 } | 774 } |
775 } | 775 } |
776 } | 776 } |
777 if (ipconfig_static) { | 777 if (ipconfig_static) { |
778 // Save any changed details. | 778 // Save any changed details. |
779 if (ipconfig.address != ipconfig_static->address) { | 779 if (ipconfig.address != ipconfig_static->address) { |
780 scoped_ptr<GValue> gvalue(ConvertStringToGValue(ipconfig.address)); | 780 scoped_ptr<GValue> gvalue(ConvertStringToGValue(ipconfig.address)); |
781 chromeos::SetNetworkIPConfigPropertyGValue( | 781 CrosSetNetworkIPConfigPropertyGValue( |
782 ipconfig_static->path, flimflam::kAddressProperty, gvalue.get()); | 782 ipconfig_static->path, flimflam::kAddressProperty, gvalue.get()); |
783 } | 783 } |
784 if (ipconfig.netmask != ipconfig_static->netmask) { | 784 if (ipconfig.netmask != ipconfig_static->netmask) { |
785 int prefixlen = ipconfig.GetPrefixLength(); | 785 int prefixlen = ipconfig.GetPrefixLength(); |
786 if (prefixlen == -1) { | 786 if (prefixlen == -1) { |
787 VLOG(1) << "IP config prefixlen is invalid for netmask " | 787 VLOG(1) << "IP config prefixlen is invalid for netmask " |
788 << ipconfig.netmask; | 788 << ipconfig.netmask; |
789 } else { | 789 } else { |
790 scoped_ptr<GValue> gvalue(ConvertIntToGValue(prefixlen)); | 790 scoped_ptr<GValue> gvalue(ConvertIntToGValue(prefixlen)); |
791 chromeos::SetNetworkIPConfigPropertyGValue( | 791 CrosSetNetworkIPConfigPropertyGValue( |
792 ipconfig_static->path, | 792 ipconfig_static->path, |
793 flimflam::kPrefixlenProperty, gvalue.get()); | 793 flimflam::kPrefixlenProperty, gvalue.get()); |
794 } | 794 } |
795 } | 795 } |
796 if (ipconfig.gateway != ipconfig_static->gateway) { | 796 if (ipconfig.gateway != ipconfig_static->gateway) { |
797 scoped_ptr<GValue> gvalue(ConvertStringToGValue(ipconfig.gateway)); | 797 scoped_ptr<GValue> gvalue(ConvertStringToGValue(ipconfig.gateway)); |
798 chromeos::SetNetworkIPConfigPropertyGValue( | 798 CrosSetNetworkIPConfigPropertyGValue( |
799 ipconfig_static->path, flimflam::kGatewayProperty, gvalue.get()); | 799 ipconfig_static->path, flimflam::kGatewayProperty, gvalue.get()); |
800 } | 800 } |
801 if (ipconfig.name_servers != ipconfig_static->name_servers) { | 801 if (ipconfig.name_servers != ipconfig_static->name_servers) { |
802 scoped_ptr<GValue> gvalue(ConvertStringToGValue(ipconfig.name_servers)); | 802 scoped_ptr<GValue> gvalue(ConvertStringToGValue(ipconfig.name_servers)); |
803 chromeos::SetNetworkIPConfigPropertyGValue( | 803 CrosSetNetworkIPConfigPropertyGValue( |
804 ipconfig_static->path, | 804 ipconfig_static->path, |
805 flimflam::kNameServersProperty, gvalue.get()); | 805 flimflam::kNameServersProperty, gvalue.get()); |
806 } | 806 } |
807 // Remove dhcp ip config if there is one. | 807 // Remove dhcp ip config if there is one. |
808 if (ipconfig_dhcp) | 808 if (ipconfig_dhcp) |
809 chromeos::RemoveIPConfig(ipconfig_dhcp); | 809 CrosRemoveIPConfig(ipconfig_dhcp); |
810 } | 810 } |
811 } | 811 } |
812 | 812 |
813 if (ipconfig_status) | 813 if (ipconfig_status) |
814 chromeos::FreeIPConfigStatus(ipconfig_status); | 814 CrosFreeIPConfigStatus(ipconfig_status); |
815 if (ipconfig_status2) | 815 if (ipconfig_status2) |
816 chromeos::FreeIPConfigStatus(ipconfig_status2); | 816 CrosFreeIPConfigStatus(ipconfig_status2); |
817 } | 817 } |
818 | 818 |
819 ///////////////////////////////////////////////////////////////////////////// | 819 ///////////////////////////////////////////////////////////////////////////// |
820 // Network Manager functions. | 820 // Network Manager functions. |
821 | 821 |
822 // static | 822 // static |
823 void NetworkLibraryImplCros::NetworkManagerStatusChangedHandler( | 823 void NetworkLibraryImplCros::NetworkManagerStatusChangedHandler( |
824 void* object, const char* path, const char* key, const GValue* gvalue) { | 824 void* object, const char* path, const char* key, const GValue* gvalue) { |
825 DCHECK(CrosLibrary::Get()->libcros_loaded()); | 825 DCHECK(CrosLibrary::Get()->libcros_loaded()); |
826 NetworkLibraryImplCros* networklib = | 826 NetworkLibraryImplCros* networklib = |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 AddNetwork(found->second); | 1053 AddNetwork(found->second); |
1054 old_network_map.erase(found); | 1054 old_network_map.erase(found); |
1055 } | 1055 } |
1056 // Always request network updates. | 1056 // Always request network updates. |
1057 // TODO(stevenjb): Investigate why we are missing updates then | 1057 // TODO(stevenjb): Investigate why we are missing updates then |
1058 // rely on watched network updates and only request updates here for | 1058 // rely on watched network updates and only request updates here for |
1059 // new networks. | 1059 // new networks. |
1060 // Use update_request map to store network priority. | 1060 // Use update_request map to store network priority. |
1061 network_update_requests_[service_path] = network_priority_order++; | 1061 network_update_requests_[service_path] = network_priority_order++; |
1062 wifi_scanning_ = true; | 1062 wifi_scanning_ = true; |
1063 chromeos::RequestNetworkServiceProperties(service_path.c_str(), | 1063 CrosRequestNetworkServiceProperties(service_path.c_str(), |
1064 &NetworkServiceUpdate, | 1064 &NetworkServiceUpdate, |
1065 this); | 1065 this); |
1066 } | 1066 } |
1067 } | 1067 } |
1068 // Iterate through list of remaining networks that are no longer in the | 1068 // Iterate through list of remaining networks that are no longer in the |
1069 // list and delete them or update their status and re-add them to the list. | 1069 // list and delete them or update their status and re-add them to the list. |
1070 for (NetworkMap::iterator iter = old_network_map.begin(); | 1070 for (NetworkMap::iterator iter = old_network_map.begin(); |
1071 iter != old_network_map.end(); ++iter) { | 1071 iter != old_network_map.end(); ++iter) { |
1072 Network* network = iter->second; | 1072 Network* network = iter->second; |
1073 VLOG(2) << "Delete Network: " << network->name() | 1073 VLOG(2) << "Delete Network: " << network->name() |
1074 << " State = " << network->GetStateString() | 1074 << " State = " << network->GetStateString() |
1075 << " connecting = " << network->connecting() | 1075 << " connecting = " << network->connecting() |
(...skipping 22 matching lines...) Expand all Loading... |
1098 // Existing networks will be updated. There should not be any new networks | 1098 // Existing networks will be updated. There should not be any new networks |
1099 // in this list, but if there are they will be added appropriately. | 1099 // in this list, but if there are they will be added appropriately. |
1100 void NetworkLibraryImplCros::UpdateWatchedNetworkServiceList( | 1100 void NetworkLibraryImplCros::UpdateWatchedNetworkServiceList( |
1101 const ListValue* services) { | 1101 const ListValue* services) { |
1102 for (ListValue::const_iterator iter = services->begin(); | 1102 for (ListValue::const_iterator iter = services->begin(); |
1103 iter != services->end(); ++iter) { | 1103 iter != services->end(); ++iter) { |
1104 std::string service_path; | 1104 std::string service_path; |
1105 (*iter)->GetAsString(&service_path); | 1105 (*iter)->GetAsString(&service_path); |
1106 if (!service_path.empty()) { | 1106 if (!service_path.empty()) { |
1107 VLOG(1) << "Watched Service: " << service_path; | 1107 VLOG(1) << "Watched Service: " << service_path; |
1108 chromeos::RequestNetworkServiceProperties(service_path.c_str(), | 1108 CrosRequestNetworkServiceProperties(service_path.c_str(), |
1109 &NetworkServiceUpdate, | 1109 &NetworkServiceUpdate, |
1110 this); | 1110 this); |
1111 } | 1111 } |
1112 } | 1112 } |
1113 } | 1113 } |
1114 | 1114 |
1115 // static | 1115 // static |
1116 void NetworkLibraryImplCros::NetworkServiceUpdate( | 1116 void NetworkLibraryImplCros::NetworkServiceUpdate( |
1117 void* object, const char* service_path, GHashTable* ghash) { | 1117 void* object, const char* service_path, GHashTable* ghash) { |
1118 DCHECK(CrosLibrary::Get()->libcros_loaded()); | 1118 DCHECK(CrosLibrary::Get()->libcros_loaded()); |
1119 NetworkLibraryImplCros* networklib = | 1119 NetworkLibraryImplCros* networklib = |
1120 static_cast<NetworkLibraryImplCros*>(object); | 1120 static_cast<NetworkLibraryImplCros*>(object); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1209 // We can do this safely because we do not save any local state for | 1209 // We can do this safely because we do not save any local state for |
1210 // remembered networks. This list updates infrequently. | 1210 // remembered networks. This list updates infrequently. |
1211 DeleteRememberedNetworks(); | 1211 DeleteRememberedNetworks(); |
1212 // Request remembered networks from each profile. Later entries will | 1212 // Request remembered networks from each profile. Later entries will |
1213 // override earlier entries, so default/local entries will override | 1213 // override earlier entries, so default/local entries will override |
1214 // user entries (as desired). | 1214 // user entries (as desired). |
1215 for (NetworkProfileList::iterator iter = profile_list_.begin(); | 1215 for (NetworkProfileList::iterator iter = profile_list_.begin(); |
1216 iter != profile_list_.end(); ++iter) { | 1216 iter != profile_list_.end(); ++iter) { |
1217 NetworkProfile& profile = *iter; | 1217 NetworkProfile& profile = *iter; |
1218 VLOG(1) << " Requesting Profile: " << profile.path; | 1218 VLOG(1) << " Requesting Profile: " << profile.path; |
1219 chromeos::RequestNetworkProfileProperties( | 1219 CrosRequestNetworkProfileProperties( |
1220 profile.path.c_str(), &ProfileUpdate, this); | 1220 profile.path.c_str(), &ProfileUpdate, this); |
1221 } | 1221 } |
1222 } | 1222 } |
1223 | 1223 |
1224 // static | 1224 // static |
1225 void NetworkLibraryImplCros::ProfileUpdate( | 1225 void NetworkLibraryImplCros::ProfileUpdate( |
1226 void* object, const char* profile_path, GHashTable* ghash) { | 1226 void* object, const char* profile_path, GHashTable* ghash) { |
1227 DCHECK(CrosLibrary::Get()->libcros_loaded()); | 1227 DCHECK(CrosLibrary::Get()->libcros_loaded()); |
1228 NetworkLibraryImplCros* networklib = | 1228 NetworkLibraryImplCros* networklib = |
1229 static_cast<NetworkLibraryImplCros*>(object); | 1229 static_cast<NetworkLibraryImplCros*>(object); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 std::string service_path; | 1262 std::string service_path; |
1263 (*iter2)->GetAsString(&service_path); | 1263 (*iter2)->GetAsString(&service_path); |
1264 if (service_path.empty()) { | 1264 if (service_path.empty()) { |
1265 LOG(WARNING) << "Empty service path in profile."; | 1265 LOG(WARNING) << "Empty service path in profile."; |
1266 continue; | 1266 continue; |
1267 } | 1267 } |
1268 VLOG(1) << " Remembered service: " << service_path; | 1268 VLOG(1) << " Remembered service: " << service_path; |
1269 // Add service to profile list. | 1269 // Add service to profile list. |
1270 profile.services.insert(service_path); | 1270 profile.services.insert(service_path); |
1271 // Request update for remembered network. | 1271 // Request update for remembered network. |
1272 chromeos::RequestNetworkProfileEntryProperties( | 1272 CrosRequestNetworkProfileEntryProperties( |
1273 profile_path, | 1273 profile_path, |
1274 service_path.c_str(), | 1274 service_path.c_str(), |
1275 &RememberedNetworkServiceUpdate, | 1275 &RememberedNetworkServiceUpdate, |
1276 this); | 1276 this); |
1277 } | 1277 } |
1278 } | 1278 } |
1279 | 1279 |
1280 // static | 1280 // static |
1281 void NetworkLibraryImplCros::RememberedNetworkServiceUpdate( | 1281 void NetworkLibraryImplCros::RememberedNetworkServiceUpdate( |
1282 void* object, const char* service_path, GHashTable* ghash) { | 1282 void* object, const char* service_path, GHashTable* ghash) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1334 | 1334 |
1335 if (remembered->type() == TYPE_VPN) { | 1335 if (remembered->type() == TYPE_VPN) { |
1336 // VPNs are only stored in profiles. If we don't have a network for it, | 1336 // VPNs are only stored in profiles. If we don't have a network for it, |
1337 // request one. | 1337 // request one. |
1338 if (!FindNetworkByUniqueId(remembered->unique_id())) { | 1338 if (!FindNetworkByUniqueId(remembered->unique_id())) { |
1339 VirtualNetwork* vpn = static_cast<VirtualNetwork*>(remembered); | 1339 VirtualNetwork* vpn = static_cast<VirtualNetwork*>(remembered); |
1340 std::string provider_type = ProviderTypeToString(vpn->provider_type()); | 1340 std::string provider_type = ProviderTypeToString(vpn->provider_type()); |
1341 VLOG(1) << "Requesting VPN: " << vpn->name() | 1341 VLOG(1) << "Requesting VPN: " << vpn->name() |
1342 << " Server: " << vpn->server_hostname() | 1342 << " Server: " << vpn->server_hostname() |
1343 << " Type: " << provider_type; | 1343 << " Type: " << provider_type; |
1344 chromeos::RequestVirtualNetworkProperties( | 1344 CrosRequestVirtualNetworkProperties( |
1345 vpn->name().c_str(), | 1345 vpn->name().c_str(), |
1346 vpn->server_hostname().c_str(), | 1346 vpn->server_hostname().c_str(), |
1347 provider_type.c_str(), | 1347 provider_type.c_str(), |
1348 NetworkServiceUpdate, | 1348 NetworkServiceUpdate, |
1349 this); | 1349 this); |
1350 } | 1350 } |
1351 } | 1351 } |
1352 | 1352 |
1353 return remembered; | 1353 return remembered; |
1354 } | 1354 } |
(...skipping 12 matching lines...) Expand all Loading... |
1367 std::string device_path; | 1367 std::string device_path; |
1368 (*iter)->GetAsString(&device_path); | 1368 (*iter)->GetAsString(&device_path); |
1369 if (!device_path.empty()) { | 1369 if (!device_path.empty()) { |
1370 NetworkDeviceMap::iterator found = old_device_map.find(device_path); | 1370 NetworkDeviceMap::iterator found = old_device_map.find(device_path); |
1371 if (found != old_device_map.end()) { | 1371 if (found != old_device_map.end()) { |
1372 VLOG(2) << " Adding existing device: " << device_path; | 1372 VLOG(2) << " Adding existing device: " << device_path; |
1373 CHECK(found->second) << "Attempted to add NULL device pointer"; | 1373 CHECK(found->second) << "Attempted to add NULL device pointer"; |
1374 device_map_[device_path] = found->second; | 1374 device_map_[device_path] = found->second; |
1375 old_device_map.erase(found); | 1375 old_device_map.erase(found); |
1376 } | 1376 } |
1377 chromeos::RequestNetworkDeviceProperties(device_path.c_str(), | 1377 CrosRequestNetworkDeviceProperties(device_path.c_str(), |
1378 &NetworkDeviceUpdate, | 1378 &NetworkDeviceUpdate, |
1379 this); | 1379 this); |
1380 } | 1380 } |
1381 } | 1381 } |
1382 // Delete any old devices that no longer exist. | 1382 // Delete any old devices that no longer exist. |
1383 for (NetworkDeviceMap::iterator iter = old_device_map.begin(); | 1383 for (NetworkDeviceMap::iterator iter = old_device_map.begin(); |
1384 iter != old_device_map.end(); ++iter) { | 1384 iter != old_device_map.end(); ++iter) { |
1385 DeleteDeviceFromDeviceObserversMap(iter->first); | 1385 DeleteDeviceFromDeviceObserversMap(iter->first); |
1386 // Delete device. | 1386 // Delete device. |
1387 delete iter->second; | 1387 delete iter->second; |
1388 } | 1388 } |
1389 } | 1389 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1471 // Switch back to signed settings value. | 1471 // Switch back to signed settings value. |
1472 SetCellularDataRoamingAllowed(settings_value); | 1472 SetCellularDataRoamingAllowed(settings_value); |
1473 } | 1473 } |
1474 } | 1474 } |
1475 } | 1475 } |
1476 NotifyNetworkManagerChanged(false); // Not forced. | 1476 NotifyNetworkManagerChanged(false); // Not forced. |
1477 AddNetworkDeviceObserver(device_path, network_device_observer_.get()); | 1477 AddNetworkDeviceObserver(device_path, network_device_observer_.get()); |
1478 } | 1478 } |
1479 | 1479 |
1480 } // namespace chromeos | 1480 } // namespace chromeos |
OLD | NEW |