Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: chromeos_network.cc

Issue 6606024: Eliminate ConenctionType, etc from chromeos_network.h (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/cros.git@master
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium OS 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 "chromeos_network.h" // NOLINT 5 #include "chromeos_network.h" // NOLINT
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 #include <list> 9 #include <list>
10 #include <set> 10 #include <set>
11 #include <vector> 11 #include <vector>
12 12
13 #include "marshal.glibmarshal.h" // NOLINT 13 #include "marshal.glibmarshal.h" // NOLINT
14 #include "base/scoped_ptr.h" 14 #include "base/scoped_ptr.h"
15 #include "base/scoped_vector.h" 15 #include "base/scoped_vector.h"
16 #include "base/string_util.h" 16 #include "base/string_util.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "chromeos/dbus/dbus.h" // NOLINT 18 #include "chromeos/dbus/dbus.h" // NOLINT
19 #include "chromeos/glib/object.h" // NOLINT 19 #include "chromeos/glib/object.h" // NOLINT
20 #include "chromeos/string.h" 20 #include "chromeos/string.h"
21 21
22 // TODO(rtc): Unittest this code as soon as the tree is refactored. 22 // TODO(rtc): Unittest this code as soon as the tree is refactored.
23 namespace chromeos { // NOLINT 23 namespace chromeos { // NOLINT
24 24
25 namespace { // NOLINT 25 namespace { // NOLINT
26 26
27 // Connman D-Bus service identifiers. 27 // Flimflam D-Bus service identifiers.
28 static const char* kConnmanManagerInterface = "org.chromium.flimflam.Manager"; 28 static const char* kFlimflamManagerInterface = "org.chromium.flimflam.Manager";
29 static const char* kConnmanServiceInterface = "org.chromium.flimflam.Service"; 29 static const char* kFlimflamServiceInterface = "org.chromium.flimflam.Service";
30 static const char* kConnmanServiceName = "org.chromium.flimflam"; 30 static const char* kFlimflamServiceName = "org.chromium.flimflam";
31 static const char* kConnmanIPConfigInterface = "org.chromium.flimflam.IPConfig"; 31 static const char* kFlimflamIPConfigInterface = "org.chromium.flimflam.IPConfig" ;
32 static const char* kConnmanDeviceInterface = "org.chromium.flimflam.Device"; 32 static const char* kFlimflamDeviceInterface = "org.chromium.flimflam.Device";
33 static const char* kConnmanProfileInterface = "org.chromium.flimflam.Profile"; 33 static const char* kFlimflamProfileInterface = "org.chromium.flimflam.Profile";
34 static const char* kConnmanNetworkInterface = "org.chromium.flimflam.Network"; 34 static const char* kFlimflamNetworkInterface = "org.chromium.flimflam.Network";
35 35
36 // Connman function names. 36 // Flimflam function names.
37 static const char* kGetPropertiesFunction = "GetProperties"; 37 static const char* kGetPropertiesFunction = "GetProperties";
38 static const char* kSetPropertyFunction = "SetProperty"; 38 static const char* kSetPropertyFunction = "SetProperty";
39 static const char* kClearPropertyFunction = "ClearProperty"; 39 static const char* kClearPropertyFunction = "ClearProperty";
40 static const char* kConnectFunction = "Connect"; 40 static const char* kConnectFunction = "Connect";
41 static const char* kDisconnectFunction = "Disconnect"; 41 static const char* kDisconnectFunction = "Disconnect";
42 static const char* kRequestScanFunction = "RequestScan"; 42 static const char* kRequestScanFunction = "RequestScan";
43 static const char* kGetWifiServiceFunction = "GetWifiService"; 43 static const char* kGetWifiServiceFunction = "GetWifiService";
44 static const char* kEnableTechnologyFunction = "EnableTechnology"; 44 static const char* kEnableTechnologyFunction = "EnableTechnology";
45 static const char* kDisableTechnologyFunction = "DisableTechnology"; 45 static const char* kDisableTechnologyFunction = "DisableTechnology";
46 static const char* kAddIPConfigFunction = "AddIPConfig"; 46 static const char* kAddIPConfigFunction = "AddIPConfig";
47 static const char* kRemoveConfigFunction = "Remove"; 47 static const char* kRemoveConfigFunction = "Remove";
48 static const char* kGetEntryFunction = "GetEntry"; 48 static const char* kGetEntryFunction = "GetEntry";
49 static const char* kDeleteEntryFunction = "DeleteEntry"; 49 static const char* kDeleteEntryFunction = "DeleteEntry";
50 static const char* kActivateCellularModemFunction = "ActivateCellularModem"; 50 static const char* kActivateCellularModemFunction = "ActivateCellularModem";
51 51
52 // Connman property names. 52 // Flimflam property names.
53 static const char* kSecurityProperty = "Security"; 53 static const char* kSecurityProperty = "Security";
54 static const char* kPassphraseProperty = "Passphrase"; 54 static const char* kPassphraseProperty = "Passphrase";
55 static const char* kIdentityProperty = "Identity"; 55 static const char* kIdentityProperty = "Identity";
56 static const char* kCertPathProperty = "CertPath"; // DEPRECATED 56 static const char* kCertPathProperty = "CertPath"; // DEPRECATED
57 static const char* kOfflineModeProperty = "OfflineMode"; 57 static const char* kOfflineModeProperty = "OfflineMode";
58 static const char* kSignalStrengthProperty = "Strength"; 58 static const char* kSignalStrengthProperty = "Strength";
59 static const char* kNameProperty = "Name"; 59 static const char* kNameProperty = "Name";
60 static const char* kTypeProperty = "Type"; 60 static const char* kTypeProperty = "Type";
61 static const char* kUnknownString = "UNKNOWN"; 61 static const char* kUnknownString = "UNKNOWN";
62 static const char* kAutoConnectProperty = "AutoConnect"; 62 static const char* kAutoConnectProperty = "AutoConnect";
63 static const char* kModeProperty = "Mode"; 63 static const char* kModeProperty = "Mode";
64 static const char* kActiveProfileProperty = "ActiveProfile"; 64 static const char* kActiveProfileProperty = "ActiveProfile";
65 static const char* kSSIDProperty = "SSID"; 65 static const char* kSSIDProperty = "SSID";
66 static const char* kDevicesProperty = "Devices"; 66 static const char* kDevicesProperty = "Devices";
67 static const char* kNetworksProperty = "Networks"; 67 static const char* kNetworksProperty = "Networks";
68 static const char* kConnectedProperty = "Connected"; 68 static const char* kConnectedProperty = "Connected";
69 static const char* kWifiChannelProperty = "WiFi.Channel"; 69 static const char* kWifiChannelProperty = "WiFi.Channel";
70 static const char* kScanIntervalProperty = "ScanInterval"; 70 static const char* kScanIntervalProperty = "ScanInterval";
71 static const char* kPoweredProperty = "Powered"; 71 static const char* kPoweredProperty = "Powered";
72 72
73 // Connman device info property names. 73 // Flimflam device info property names.
74 static const char* kIPConfigsProperty = "IPConfigs"; 74 static const char* kIPConfigsProperty = "IPConfigs";
75 static const char* kCertpathSettingsPrefix = "SETTINGS:"; 75 static const char* kCertpathSettingsPrefix = "SETTINGS:";
76 76
77 // Connman EAP service properties 77 // Flimflam EAP service properties
78 static const char* kEAPEAPProperty = "EAP.EAP"; 78 static const char* kEAPEAPProperty = "EAP.EAP";
79 static const char* kEAPClientCertProperty = "EAP.ClientCert"; 79 static const char* kEAPClientCertProperty = "EAP.ClientCert";
80 static const char* kEAPCertIDProperty = "EAP.CertID"; 80 static const char* kEAPCertIDProperty = "EAP.CertID";
81 static const char* kEAPKeyIDProperty = "EAP.KeyID"; 81 static const char* kEAPKeyIDProperty = "EAP.KeyID";
82 static const char* kEAPPINProperty = "EAP.PIN"; 82 static const char* kEAPPINProperty = "EAP.PIN";
83 83
84 // Connman monitored properties 84 // Flimflam monitored properties
85 static const char* kMonitorPropertyChanged = "PropertyChanged"; 85 static const char* kMonitorPropertyChanged = "PropertyChanged";
86 86
87 // Connman type options. 87 // Flimflam type options.
88 static const char* kTypeEthernet = "ethernet";
89 static const char* kTypeWifi = "wifi"; 88 static const char* kTypeWifi = "wifi";
90 static const char* kTypeWimax = "wimax";
91 static const char* kTypeBluetooth = "bluetooth";
92 static const char* kTypeCellular = "cellular";
93 static const char* kTypeUnknown = "";
94 89
95 // Connman mode options. 90 // Flimflam mode options.
96 static const char* kModeManaged = "managed"; 91 static const char* kModeManaged = "managed";
97 92
98 // Connman security options.
99 static const char* kSecurityWpa = "wpa";
100 static const char* kSecurityWep = "wep";
101 static const char* kSecurityRsn = "rsn";
102 static const char* kSecurity8021x = "802_1x";
103 static const char* kSecurityNone = "none";
104
105 // Cashew D-Bus service identifiers. 93 // Cashew D-Bus service identifiers.
106 static const char* kCashewServiceName = "org.chromium.Cashew"; 94 static const char* kCashewServiceName = "org.chromium.Cashew";
107 static const char* kCashewServicePath = "/org/chromium/Cashew"; 95 static const char* kCashewServicePath = "/org/chromium/Cashew";
108 static const char* kCashewServiceInterface = "org.chromium.Cashew"; 96 static const char* kCashewServiceInterface = "org.chromium.Cashew";
109 97
110 // Cashew function names. 98 // Cashew function names.
111 static const char* kRequestDataPlanFunction = "RequestDataPlansUpdate"; 99 static const char* kRequestDataPlanFunction = "RequestDataPlansUpdate";
112 static const char* kRetrieveDataPlanFunction = "GetDataPlans"; 100 static const char* kRetrieveDataPlanFunction = "GetDataPlans";
113 101
114 // Connman monitored properties 102 // Flimflam monitored properties
115 static const char* kMonitorDataPlanUpdate = "DataPlansUpdate"; 103 static const char* kMonitorDataPlanUpdate = "DataPlansUpdate";
116 104
117 // Cashew data plan properties 105 // Cashew data plan properties
118 static const char* kCellularPlanNameProperty = "CellularPlanName"; 106 static const char* kCellularPlanNameProperty = "CellularPlanName";
119 static const char* kCellularPlanTypeProperty = "CellularPlanType"; 107 static const char* kCellularPlanTypeProperty = "CellularPlanType";
120 static const char* kCellularPlanUpdateTimeProperty = "CellularPlanUpdateTime"; 108 static const char* kCellularPlanUpdateTimeProperty = "CellularPlanUpdateTime";
121 static const char* kCellularPlanStartProperty = "CellularPlanStart"; 109 static const char* kCellularPlanStartProperty = "CellularPlanStart";
122 static const char* kCellularPlanEndProperty = "CellularPlanEnd"; 110 static const char* kCellularPlanEndProperty = "CellularPlanEnd";
123 static const char* kCellularPlanDataBytesProperty = "CellularPlanDataBytes"; 111 static const char* kCellularPlanDataBytesProperty = "CellularPlanDataBytes";
124 static const char* kCellularDataBytesUsedProperty = "CellularDataBytesUsed"; 112 static const char* kCellularDataBytesUsedProperty = "CellularDataBytesUsed";
(...skipping 16 matching lines...) Expand all
141 129
142 // IPConfig type options. 130 // IPConfig type options.
143 static const char* kTypeIPv4 = "ipv4"; 131 static const char* kTypeIPv4 = "ipv4";
144 static const char* kTypeIPv6 = "ipv6"; 132 static const char* kTypeIPv6 = "ipv6";
145 static const char* kTypeDHCP = "dhcp"; 133 static const char* kTypeDHCP = "dhcp";
146 static const char* kTypeBOOTP = "bootp"; 134 static const char* kTypeBOOTP = "bootp";
147 static const char* kTypeZeroConf = "zeroconf"; 135 static const char* kTypeZeroConf = "zeroconf";
148 static const char* kTypeDHCP6 = "dhcp6"; 136 static const char* kTypeDHCP6 = "dhcp6";
149 static const char* kTypePPP = "ppp"; 137 static const char* kTypePPP = "ppp";
150 138
151 static const char* TypeToString(ConnectionType type) {
152 switch (type) {
153 case TYPE_UNKNOWN:
154 break;
155 case TYPE_ETHERNET:
156 return kTypeEthernet;
157 case TYPE_WIFI:
158 return kTypeWifi;
159 case TYPE_WIMAX:
160 return kTypeWimax;
161 case TYPE_BLUETOOTH:
162 return kTypeBluetooth;
163 case TYPE_CELLULAR:
164 return kTypeCellular;
165 }
166 return kTypeUnknown;
167 }
168
169 static const char* SecurityToString(ConnectionSecurity security) {
170 switch (security) {
171 case SECURITY_UNKNOWN:
172 break;
173 case SECURITY_8021X:
174 return kSecurity8021x;
175 case SECURITY_RSN:
176 return kSecurityRsn;
177 case SECURITY_WPA:
178 return kSecurityWpa;
179 case SECURITY_WEP:
180 return kSecurityWep;
181 case SECURITY_NONE:
182 return kSecurityNone;
183 }
184 return kUnknownString;
185 }
stevenjb 2011/03/02 23:35:57 Moved to chromeos_network_deprecated.cc
186
187 static CellularDataPlanType ParseCellularDataPlanType(const std::string& type) { 139 static CellularDataPlanType ParseCellularDataPlanType(const std::string& type) {
188 if (type == kCellularDataPlanUnlimited) 140 if (type == kCellularDataPlanUnlimited)
189 return CELLULAR_DATA_PLAN_UNLIMITED; 141 return CELLULAR_DATA_PLAN_UNLIMITED;
190 if (type == kCellularDataPlanMeteredPaid) 142 if (type == kCellularDataPlanMeteredPaid)
191 return CELLULAR_DATA_PLAN_METERED_PAID; 143 return CELLULAR_DATA_PLAN_METERED_PAID;
192 if (type == kCellularDataPlanMeteredBase) 144 if (type == kCellularDataPlanMeteredBase)
193 return CELLULAR_DATA_PLAN_METERED_BASE; 145 return CELLULAR_DATA_PLAN_METERED_BASE;
194 return CELLULAR_DATA_PLAN_UNKNOWN; 146 return CELLULAR_DATA_PLAN_UNKNOWN;
195 } 147 }
196 148
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 } 456 }
505 457
506 // Returns a IPConfig object populated with data from a 458 // Returns a IPConfig object populated with data from a
507 // given DBus object path. 459 // given DBus object path.
508 // 460 //
509 // returns true on success. 461 // returns true on success.
510 bool ParseIPConfig(const char* path, IPConfig *ipconfig) { 462 bool ParseIPConfig(const char* path, IPConfig *ipconfig) {
511 ipconfig->path = NewStringCopy(path); 463 ipconfig->path = NewStringCopy(path);
512 464
513 dbus::Proxy config_proxy(dbus::GetSystemBusConnection(), 465 dbus::Proxy config_proxy(dbus::GetSystemBusConnection(),
514 kConnmanServiceName, 466 kFlimflamServiceName,
515 path, 467 path,
516 kConnmanIPConfigInterface); 468 kFlimflamIPConfigInterface);
517 glib::ScopedHashTable properties; 469 glib::ScopedHashTable properties;
518 if (!GetProperties(config_proxy, &properties)) 470 if (!GetProperties(config_proxy, &properties))
519 return false; 471 return false;
520 ParseIPConfigProperties(properties, ipconfig); 472 ParseIPConfigProperties(properties, ipconfig);
521 return true; 473 return true;
522 } 474 }
523 475
524 extern "C" 476 extern "C"
525 IPConfigStatus* ChromeOSListIPConfigs(const char* device_path) { 477 IPConfigStatus* ChromeOSListIPConfigs(const char* device_path) {
526 if (!device_path || strlen(device_path) == 0) 478 if (!device_path || strlen(device_path) == 0)
527 return NULL; 479 return NULL;
528 480
529 dbus::BusConnection bus = dbus::GetSystemBusConnection(); 481 dbus::BusConnection bus = dbus::GetSystemBusConnection();
530 dbus::Proxy device_proxy(bus, 482 dbus::Proxy device_proxy(bus,
531 kConnmanServiceName, 483 kFlimflamServiceName,
532 device_path, 484 device_path,
533 kConnmanDeviceInterface); 485 kFlimflamDeviceInterface);
534 486
535 glib::ScopedHashTable properties; 487 glib::ScopedHashTable properties;
536 if (!GetProperties(device_proxy, &properties)) { 488 if (!GetProperties(device_proxy, &properties)) {
537 return NULL; 489 return NULL;
538 } 490 }
539 491
540 GHashTable* table = properties.get(); 492 GHashTable* table = properties.get();
541 gpointer ptr = g_hash_table_lookup(table, kIPConfigsProperty); 493 gpointer ptr = g_hash_table_lookup(table, kIPConfigsProperty);
542 if (ptr == NULL) 494 if (ptr == NULL)
543 return NULL; 495 return NULL;
(...skipping 28 matching lines...) Expand all
572 properties.Retrieve(kAddressProperty, &hardware_address); 524 properties.Retrieve(kAddressProperty, &hardware_address);
573 result->hardware_address = NewStringCopy(hardware_address); 525 result->hardware_address = NewStringCopy(hardware_address);
574 526
575 return result; 527 return result;
576 } 528 }
577 529
578 extern "C" 530 extern "C"
579 bool ChromeOSAddIPConfig(const char* device_path, IPConfigType type) { 531 bool ChromeOSAddIPConfig(const char* device_path, IPConfigType type) {
580 dbus::BusConnection bus = dbus::GetSystemBusConnection(); 532 dbus::BusConnection bus = dbus::GetSystemBusConnection();
581 dbus::Proxy device_proxy(bus, 533 dbus::Proxy device_proxy(bus,
582 kConnmanServiceName, 534 kFlimflamServiceName,
583 device_path, 535 device_path,
584 kConnmanDeviceInterface); 536 kFlimflamDeviceInterface);
585 537
586 glib::ScopedError error; 538 glib::ScopedError error;
587 ::DBusGProxy obj; 539 ::DBusGProxy obj;
588 const char* type_str = NULL; 540 const char* type_str = NULL;
589 switch(type) { 541 switch(type) {
590 case IPCONFIG_TYPE_IPV4: 542 case IPCONFIG_TYPE_IPV4:
591 type_str = kTypeIPv4; 543 type_str = kTypeIPv4;
592 break; 544 break;
593 case IPCONFIG_TYPE_IPV6: 545 case IPCONFIG_TYPE_IPV6:
594 type_str = kTypeIPv6; 546 type_str = kTypeIPv6;
(...skipping 30 matching lines...) Expand all
625 << (error->message ? error->message : "Unknown Error."); 577 << (error->message ? error->message : "Unknown Error.");
626 return false; 578 return false;
627 } 579 }
628 return true; 580 return true;
629 } 581 }
630 582
631 extern "C" 583 extern "C"
632 bool ChromeOSSaveIPConfig(IPConfig* config) { 584 bool ChromeOSSaveIPConfig(IPConfig* config) {
633 dbus::BusConnection bus = dbus::GetSystemBusConnection(); 585 dbus::BusConnection bus = dbus::GetSystemBusConnection();
634 dbus::Proxy device_proxy(bus, 586 dbus::Proxy device_proxy(bus,
635 kConnmanServiceName, 587 kFlimflamServiceName,
636 config->path, 588 config->path,
637 kConnmanIPConfigInterface); 589 kFlimflamIPConfigInterface);
638 /* 590 /*
639 TODO(chocobo): Save all the values 591 TODO(chocobo): Save all the values
640 592
641 glib::Value value_set; 593 glib::Value value_set;
642 594
643 glib::ScopedError error; 595 glib::ScopedError error;
644 596
645 if (!::dbus_g_proxy_call(device_proxy.gproxy(), 597 if (!::dbus_g_proxy_call(device_proxy.gproxy(),
646 kSetPropertyFunction, 598 kSetPropertyFunction,
647 &Resetter(&error).lvalue(), 599 &Resetter(&error).lvalue(),
648 G_TYPE_STRING, 600 G_TYPE_STRING,
649 key, 601 key,
650 G_TYPE_VALUE, 602 G_TYPE_VALUE,
651 &value_set, 603 &value_set,
652 G_TYPE_INVALID, 604 G_TYPE_INVALID,
653 G_TYPE_INVALID)) { 605 G_TYPE_INVALID)) {
654 LOG(WARNING) <<"Set IPConfig Property failed: " 606 LOG(WARNING) <<"Set IPConfig Property failed: "
655 << (error->message ? error->message : "Unknown Error."); 607 << (error->message ? error->message : "Unknown Error.");
656 return false; 608 return false;
657 } 609 }
658 */ 610 */
659 return true; 611 return true;
660 } 612 }
661 613
662 extern "C" 614 extern "C"
663 bool ChromeOSRemoveIPConfig(IPConfig* config) { 615 bool ChromeOSRemoveIPConfig(IPConfig* config) {
664 dbus::BusConnection bus = dbus::GetSystemBusConnection(); 616 dbus::BusConnection bus = dbus::GetSystemBusConnection();
665 dbus::Proxy config_proxy(bus, 617 dbus::Proxy config_proxy(bus,
666 kConnmanServiceName, 618 kFlimflamServiceName,
667 config->path, 619 config->path,
668 kConnmanIPConfigInterface); 620 kFlimflamIPConfigInterface);
669 621
670 glib::ScopedError error; 622 glib::ScopedError error;
671 623
672 if (!::dbus_g_proxy_call(config_proxy.gproxy(), 624 if (!::dbus_g_proxy_call(config_proxy.gproxy(),
673 kRemoveConfigFunction, 625 kRemoveConfigFunction,
674 &Resetter(&error).lvalue(), 626 &Resetter(&error).lvalue(),
675 G_TYPE_INVALID, 627 G_TYPE_INVALID,
676 G_TYPE_INVALID)) { 628 G_TYPE_INVALID)) {
677 LOG(WARNING) <<"Set IPConfig Property failed: " 629 LOG(WARNING) <<"Set IPConfig Property failed: "
678 << (error->message ? error->message : "Unknown Error."); 630 << (error->message ? error->message : "Unknown Error.");
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 delete status; 666 delete status;
715 667
716 } 668 }
717 669
718 extern "C" 670 extern "C"
719 PropertyChangeMonitor ChromeOSMonitorNetworkManager( 671 PropertyChangeMonitor ChromeOSMonitorNetworkManager(
720 MonitorPropertyCallback callback, 672 MonitorPropertyCallback callback,
721 void* object) { 673 void* object) {
722 RegisterNetworkMarshallers(); 674 RegisterNetworkMarshallers();
723 dbus::Proxy proxy(dbus::GetSystemBusConnection(), 675 dbus::Proxy proxy(dbus::GetSystemBusConnection(),
724 kConnmanServiceName, 676 kFlimflamServiceName,
725 "/", 677 "/",
726 kConnmanManagerInterface); 678 kFlimflamManagerInterface);
727 PropertyChangeMonitor monitor = 679 PropertyChangeMonitor monitor =
728 new PropertyChangedHandler(callback, "/", object); 680 new PropertyChangedHandler(callback, "/", object);
729 monitor->set_connection(dbus::Monitor(proxy, 681 monitor->set_connection(dbus::Monitor(proxy,
730 kMonitorPropertyChanged, 682 kMonitorPropertyChanged,
731 &PropertyChangedHandler::Run, 683 &PropertyChangedHandler::Run,
732 monitor)); 684 monitor));
733 685
734 return monitor; 686 return monitor;
735 } 687 }
736 688
737 extern "C" 689 extern "C"
738 void ChromeOSDisconnectPropertyChangeMonitor( 690 void ChromeOSDisconnectPropertyChangeMonitor(
739 PropertyChangeMonitor connection) { 691 PropertyChangeMonitor connection) {
740 dbus::Disconnect(connection->connection()); 692 dbus::Disconnect(connection->connection());
741 delete connection; 693 delete connection;
742 } 694 }
743 695
744 extern "C" 696 extern "C"
745 PropertyChangeMonitor ChromeOSMonitorNetworkService( 697 PropertyChangeMonitor ChromeOSMonitorNetworkService(
746 MonitorPropertyCallback callback, 698 MonitorPropertyCallback callback,
747 const char* service_path, 699 const char* service_path,
748 void* object) { 700 void* object) {
749 RegisterNetworkMarshallers(); 701 RegisterNetworkMarshallers();
750 dbus::Proxy service_proxy(dbus::GetSystemBusConnection(), 702 dbus::Proxy service_proxy(dbus::GetSystemBusConnection(),
751 kConnmanServiceName, 703 kFlimflamServiceName,
752 service_path, 704 service_path,
753 kConnmanServiceInterface); 705 kFlimflamServiceInterface);
754 PropertyChangeMonitor monitor = 706 PropertyChangeMonitor monitor =
755 new PropertyChangedHandler(callback, service_path, object); 707 new PropertyChangedHandler(callback, service_path, object);
756 monitor->set_connection(dbus::Monitor(service_proxy, 708 monitor->set_connection(dbus::Monitor(service_proxy,
757 kMonitorPropertyChanged, 709 kMonitorPropertyChanged,
758 &PropertyChangedHandler::Run, 710 &PropertyChangedHandler::Run,
759 monitor)); 711 monitor));
760 return monitor; 712 return monitor;
761 } 713 }
762 714
763 extern "C" 715 extern "C"
764 void ChromeOSDisconnectMonitorService(PropertyChangeMonitor connection) { 716 void ChromeOSDisconnectMonitorService(PropertyChangeMonitor connection) {
765 dbus::Disconnect(connection->connection()); 717 dbus::Disconnect(connection->connection());
766 delete connection; 718 delete connection;
767 } 719 }
768 720
769 extern "C" 721 extern "C"
770 void ChromeOSRequestScan(ConnectionType type) {
771 dbus::Proxy manager_proxy(dbus::GetSystemBusConnection(),
772 kConnmanServiceName,
773 "/",
774 kConnmanManagerInterface);
775 gchar* device = ::g_strdup(TypeToString(type));
776 glib::ScopedError error;
777 if (!::dbus_g_proxy_call(manager_proxy.gproxy(),
778 kRequestScanFunction,
779 &Resetter(&error).lvalue(),
780 G_TYPE_STRING,
781 device,
782 G_TYPE_INVALID,
783 G_TYPE_INVALID)) {
784 LOG(WARNING) << "ChromeOSRequestScan failed: "
785 << (error->message ? error->message : "Unknown Error.");
786 }
787 }
stevenjb 2011/03/02 23:35:57 Moved to chromeos_network_deprecated.cc
788
789 extern "C"
790 bool ChromeOSActivateCellularModem(const char* service_path, 722 bool ChromeOSActivateCellularModem(const char* service_path,
791 const char* carrier) { 723 const char* carrier) {
792 if (carrier == NULL) 724 if (carrier == NULL)
793 carrier = ""; 725 carrier = "";
794 726
795 dbus::Proxy service_proxy(dbus::GetSystemBusConnection(), 727 dbus::Proxy service_proxy(dbus::GetSystemBusConnection(),
796 kConnmanServiceName, 728 kFlimflamServiceName,
797 service_path, 729 service_path,
798 kConnmanServiceInterface); 730 kFlimflamServiceInterface);
799 731
800 // Now try activating. 732 // Now try activating.
801 glib::ScopedError error; 733 glib::ScopedError error;
802 if (!::dbus_g_proxy_call(service_proxy.gproxy(), 734 if (!::dbus_g_proxy_call(service_proxy.gproxy(),
803 kActivateCellularModemFunction, 735 kActivateCellularModemFunction,
804 &Resetter(&error).lvalue(), 736 &Resetter(&error).lvalue(),
805 G_TYPE_STRING, 737 G_TYPE_STRING,
806 carrier, 738 carrier,
807 G_TYPE_INVALID, 739 G_TYPE_INVALID,
808 G_TYPE_INVALID)) { 740 G_TYPE_INVALID)) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 845
914 } // namespace 846 } // namespace
915 847
916 848
917 extern "C" 849 extern "C"
918 bool ChromeOSConnectToNetworkWithCertInfo(const char* service_path, 850 bool ChromeOSConnectToNetworkWithCertInfo(const char* service_path,
919 const char* passphrase, 851 const char* passphrase,
920 const char* identity, 852 const char* identity,
921 const char* certpath) { 853 const char* certpath) {
922 dbus::Proxy service_proxy(dbus::GetSystemBusConnection(), 854 dbus::Proxy service_proxy(dbus::GetSystemBusConnection(),
923 kConnmanServiceName, 855 kFlimflamServiceName,
924 service_path, 856 service_path,
925 kConnmanServiceInterface); 857 kFlimflamServiceInterface);
926 858
927 // Set passphrase if non-null. 859 // Set passphrase if non-null.
928 if (passphrase) { 860 if (passphrase) {
929 glib::Value value_passphrase(passphrase); 861 glib::Value value_passphrase(passphrase);
930 glib::ScopedError error; 862 glib::ScopedError error;
931 if (!::dbus_g_proxy_call(service_proxy.gproxy(), 863 if (!::dbus_g_proxy_call(service_proxy.gproxy(),
932 kSetPropertyFunction, 864 kSetPropertyFunction,
933 &Resetter(&error).lvalue(), 865 &Resetter(&error).lvalue(),
934 G_TYPE_STRING, 866 G_TYPE_STRING,
935 kPassphraseProperty, 867 kPassphraseProperty,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 bool ChromeOSConnectToNetwork(const char* service_path, 919 bool ChromeOSConnectToNetwork(const char* service_path,
988 const char* passphrase) { 920 const char* passphrase) {
989 921
990 return ChromeOSConnectToNetworkWithCertInfo(service_path, passphrase, 922 return ChromeOSConnectToNetworkWithCertInfo(service_path, passphrase,
991 NULL, NULL); 923 NULL, NULL);
992 } 924 }
993 925
994 extern "C" 926 extern "C"
995 bool ChromeOSDisconnectFromNetwork(const char* service_path) { 927 bool ChromeOSDisconnectFromNetwork(const char* service_path) {
996 dbus::Proxy service_proxy(dbus::GetSystemBusConnection(), 928 dbus::Proxy service_proxy(dbus::GetSystemBusConnection(),
997 kConnmanServiceName, 929 kFlimflamServiceName,
998 service_path, 930 service_path,
999 kConnmanServiceInterface); 931 kFlimflamServiceInterface);
1000 932
1001 // Now try disconnecting. 933 // Now try disconnecting.
1002 glib::ScopedError error; 934 glib::ScopedError error;
1003 if (!::dbus_g_proxy_call(service_proxy.gproxy(), 935 if (!::dbus_g_proxy_call(service_proxy.gproxy(),
1004 kDisconnectFunction, 936 kDisconnectFunction,
1005 &Resetter(&error).lvalue(), 937 &Resetter(&error).lvalue(),
1006 G_TYPE_INVALID, 938 G_TYPE_INVALID,
1007 G_TYPE_INVALID)) { 939 G_TYPE_INVALID)) {
1008 LOG(WARNING) << "DisconnectFromNetwork failed: " 940 LOG(WARNING) << "DisconnectFromNetwork failed: "
1009 << (error->message ? error->message : "Unknown Error."); 941 << (error->message ? error->message : "Unknown Error.");
1010 return false; 942 return false;
1011 } 943 }
1012 return true; 944 return true;
1013 } 945 }
1014 946
1015 extern "C" 947 extern "C"
1016 bool ChromeOSDeleteRememberedService(const char* service_path) { 948 bool ChromeOSDeleteRememberedService(const char* service_path) {
1017 dbus::BusConnection bus = dbus::GetSystemBusConnection(); 949 dbus::BusConnection bus = dbus::GetSystemBusConnection();
1018 dbus::Proxy manager_proxy(bus, 950 dbus::Proxy manager_proxy(bus,
1019 kConnmanServiceName, 951 kFlimflamServiceName,
1020 "/", 952 "/",
1021 kConnmanManagerInterface); 953 kFlimflamManagerInterface);
1022 954
1023 glib::ScopedHashTable properties; 955 glib::ScopedHashTable properties;
1024 if (!GetProperties(manager_proxy, &properties)) { 956 if (!GetProperties(manager_proxy, &properties)) {
1025 return false; 957 return false;
1026 } 958 }
1027 959
1028 glib::Value profile_val; 960 glib::Value profile_val;
1029 properties.Retrieve(kActiveProfileProperty, &profile_val); 961 properties.Retrieve(kActiveProfileProperty, &profile_val);
1030 const gchar* profile_path = 962 const gchar* profile_path =
1031 static_cast<const gchar*>(g_value_get_boxed(&profile_val)); 963 static_cast<const gchar*>(g_value_get_boxed(&profile_val));
1032 964
1033 dbus::Proxy profile_proxy(bus, 965 dbus::Proxy profile_proxy(bus,
1034 kConnmanServiceName, 966 kFlimflamServiceName,
1035 profile_path, 967 profile_path,
1036 kConnmanProfileInterface); 968 kFlimflamProfileInterface);
1037 969
1038 glib::ScopedError error; 970 glib::ScopedError error;
1039 if (!::dbus_g_proxy_call(profile_proxy.gproxy(), 971 if (!::dbus_g_proxy_call(profile_proxy.gproxy(),
1040 kDeleteEntryFunction, 972 kDeleteEntryFunction,
1041 &Resetter(&error).lvalue(), 973 &Resetter(&error).lvalue(),
1042 G_TYPE_STRING, 974 G_TYPE_STRING,
1043 service_path, 975 service_path,
1044 G_TYPE_INVALID, 976 G_TYPE_INVALID,
1045 G_TYPE_INVALID)) { 977 G_TYPE_INVALID)) {
1046 LOG(WARNING) << "DeleteEntry failed: " 978 LOG(WARNING) << "DeleteEntry failed: "
1047 << (error->message ? error->message : "Unknown Error."); 979 << (error->message ? error->message : "Unknown Error.");
1048 return false; 980 return false;
1049 } 981 }
1050 return true; 982 return true;
1051 } 983 }
1052 984
1053 extern "C"
1054 bool ChromeOSEnableNetworkDevice(ConnectionType type, bool enable) {
1055 dbus::BusConnection bus = dbus::GetSystemBusConnection();
1056 dbus::Proxy manager_proxy(bus,
1057 kConnmanServiceName,
1058 "/",
1059 kConnmanManagerInterface);
1060 if (type == TYPE_UNKNOWN) {
1061 LOG(WARNING) << "EnableNetworkDevice called with an unknown type: " << type;
1062 return false;
1063 }
1064
1065 gchar* device = ::g_strdup(TypeToString(type));
1066 glib::ScopedError error;
1067 if (!::dbus_g_proxy_call(manager_proxy.gproxy(),
1068 enable ? kEnableTechnologyFunction :
1069 kDisableTechnologyFunction,
1070 &Resetter(&error).lvalue(),
1071 G_TYPE_STRING,
1072 device,
1073 G_TYPE_INVALID,
1074 G_TYPE_INVALID)) {
1075 LOG(WARNING) << "EnableNetworkDevice failed: "
1076 << (error->message ? error->message : "Unknown Error.");
1077 ::g_free(device);
1078 return false;
1079 }
1080
1081 ::g_free(device);
1082 return true;
1083 }
stevenjb 2011/03/02 23:35:57 Moved to chromeos_network_deprecated.cc
1084 985
1085 extern "C" 986 extern "C"
1086 bool ChromeOSSetOfflineMode(bool offline) { 987 bool ChromeOSSetOfflineMode(bool offline) {
1087 dbus::BusConnection bus = dbus::GetSystemBusConnection(); 988 dbus::BusConnection bus = dbus::GetSystemBusConnection();
1088 dbus::Proxy manager_proxy(bus, 989 dbus::Proxy manager_proxy(bus,
1089 kConnmanServiceName, 990 kFlimflamServiceName,
1090 "/", 991 "/",
1091 kConnmanManagerInterface); 992 kFlimflamManagerInterface);
1092 993
1093 glib::Value value_offline(offline); 994 glib::Value value_offline(offline);
1094 995
1095 glib::ScopedError error; 996 glib::ScopedError error;
1096 if (!::dbus_g_proxy_call(manager_proxy.gproxy(), 997 if (!::dbus_g_proxy_call(manager_proxy.gproxy(),
1097 kSetPropertyFunction, 998 kSetPropertyFunction,
1098 &Resetter(&error).lvalue(), 999 &Resetter(&error).lvalue(),
1099 G_TYPE_STRING, 1000 G_TYPE_STRING,
1100 kOfflineModeProperty, 1001 kOfflineModeProperty,
1101 G_TYPE_VALUE, 1002 G_TYPE_VALUE,
1102 &value_offline, 1003 &value_offline,
1103 G_TYPE_INVALID, 1004 G_TYPE_INVALID,
1104 G_TYPE_INVALID)) { 1005 G_TYPE_INVALID)) {
1105 LOG(WARNING) << "SetOfflineMode failed: " 1006 LOG(WARNING) << "SetOfflineMode failed: "
1106 << (error->message ? error->message : "Unknown Error."); 1007 << (error->message ? error->message : "Unknown Error.");
1107 return false; 1008 return false;
1108 } 1009 }
1109 1010
1110 return true; 1011 return true;
1111 } 1012 }
1112 1013
1113 extern "C" 1014 extern "C"
1114 bool ChromeOSSetAutoConnect(const char* service_path, bool auto_connect) { 1015 bool ChromeOSSetAutoConnect(const char* service_path, bool auto_connect) {
1115 dbus::Proxy service_proxy(dbus::GetSystemBusConnection(), 1016 dbus::Proxy service_proxy(dbus::GetSystemBusConnection(),
1116 kConnmanServiceName, 1017 kFlimflamServiceName,
1117 service_path, 1018 service_path,
1118 kConnmanServiceInterface); 1019 kFlimflamServiceInterface);
1119 1020
1120 glib::Value value_auto_connect(auto_connect); 1021 glib::Value value_auto_connect(auto_connect);
1121 1022
1122 glib::ScopedError error; 1023 glib::ScopedError error;
1123 if (!::dbus_g_proxy_call(service_proxy.gproxy(), 1024 if (!::dbus_g_proxy_call(service_proxy.gproxy(),
1124 kSetPropertyFunction, 1025 kSetPropertyFunction,
1125 &Resetter(&error).lvalue(), 1026 &Resetter(&error).lvalue(),
1126 G_TYPE_STRING, 1027 G_TYPE_STRING,
1127 kAutoConnectProperty, 1028 kAutoConnectProperty,
1128 G_TYPE_VALUE, 1029 G_TYPE_VALUE,
1129 &value_auto_connect, 1030 &value_auto_connect,
1130 G_TYPE_INVALID, 1031 G_TYPE_INVALID,
1131 G_TYPE_INVALID)) { 1032 G_TYPE_INVALID)) {
1132 LOG(WARNING) << "SetAutoConnect failed: " 1033 LOG(WARNING) << "SetAutoConnect failed: "
1133 << (error->message ? error->message : "Unknown Error."); 1034 << (error->message ? error->message : "Unknown Error.");
1134 return false; 1035 return false;
1135 } 1036 }
1136 1037
1137 return true; 1038 return true;
1138 } 1039 }
1139 1040
1140 static bool ClearServiceProperty(const char* service_path, 1041 static bool ClearServiceProperty(const char* service_path,
1141 const char* property) { 1042 const char* property) {
1142 dbus::Proxy service_proxy(dbus::GetSystemBusConnection(), 1043 dbus::Proxy service_proxy(dbus::GetSystemBusConnection(),
1143 kConnmanServiceName, 1044 kFlimflamServiceName,
1144 service_path, 1045 service_path,
1145 kConnmanServiceInterface); 1046 kFlimflamServiceInterface);
1146 1047
1147 glib::ScopedError error; 1048 glib::ScopedError error;
1148 if (!::dbus_g_proxy_call(service_proxy.gproxy(), 1049 if (!::dbus_g_proxy_call(service_proxy.gproxy(),
1149 kClearPropertyFunction, 1050 kClearPropertyFunction,
1150 &Resetter(&error).lvalue(), 1051 &Resetter(&error).lvalue(),
1151 G_TYPE_STRING, 1052 G_TYPE_STRING,
1152 property, 1053 property,
1153 G_TYPE_INVALID, 1054 G_TYPE_INVALID,
1154 G_TYPE_INVALID)) { 1055 G_TYPE_INVALID)) {
1155 LOG(WARNING) << "Clearing property " << property << " failed: " 1056 LOG(WARNING) << "Clearing property " << property << " failed: "
1156 << (error->message ? error->message : "Unknown Error."); 1057 << (error->message ? error->message : "Unknown Error.");
1157 return false; 1058 return false;
1158 } 1059 }
1159 1060
1160 return true; 1061 return true;
1161 } 1062 }
1162 1063
1163 static bool SetServiceStringProperty(const char* service_path, 1064 static bool SetServiceStringProperty(const char* service_path,
1164 const char* property, const char* value) { 1065 const char* property, const char* value) {
1165 dbus::Proxy service_proxy(dbus::GetSystemBusConnection(), 1066 dbus::Proxy service_proxy(dbus::GetSystemBusConnection(),
1166 kConnmanServiceName, 1067 kFlimflamServiceName,
1167 service_path, 1068 service_path,
1168 kConnmanServiceInterface); 1069 kFlimflamServiceInterface);
1169 1070
1170 glib::Value value_string(value); 1071 glib::Value value_string(value);
1171 glib::ScopedError error; 1072 glib::ScopedError error;
1172 if (!::dbus_g_proxy_call(service_proxy.gproxy(), 1073 if (!::dbus_g_proxy_call(service_proxy.gproxy(),
1173 kSetPropertyFunction, 1074 kSetPropertyFunction,
1174 &Resetter(&error).lvalue(), 1075 &Resetter(&error).lvalue(),
1175 G_TYPE_STRING, 1076 G_TYPE_STRING,
1176 property, 1077 property,
1177 G_TYPE_VALUE, 1078 G_TYPE_VALUE,
1178 &value_string, 1079 &value_string,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 1111
1211 namespace { 1112 namespace {
1212 // Returns a DeviceNetworkInfo object populated with data from a 1113 // Returns a DeviceNetworkInfo object populated with data from a
1213 // given DBus object path. 1114 // given DBus object path.
1214 // 1115 //
1215 // returns true on success. 1116 // returns true on success.
1216 bool ParseDeviceNetworkInfo(dbus::BusConnection bus, 1117 bool ParseDeviceNetworkInfo(dbus::BusConnection bus,
1217 const char* path, 1118 const char* path,
1218 DeviceNetworkInfo* info) { 1119 DeviceNetworkInfo* info) {
1219 dbus::Proxy network_proxy(bus, 1120 dbus::Proxy network_proxy(bus,
1220 kConnmanServiceName, 1121 kFlimflamServiceName,
1221 path, 1122 path,
1222 kConnmanNetworkInterface); 1123 kFlimflamNetworkInterface);
1223 glib::ScopedHashTable properties; 1124 glib::ScopedHashTable properties;
1224 if (!GetProperties(network_proxy, &properties)) 1125 if (!GetProperties(network_proxy, &properties))
1225 return false; 1126 return false;
1226 info->network_path = NewStringCopy(path); 1127 info->network_path = NewStringCopy(path);
1227 1128
1228 // Address (mandatory) 1129 // Address (mandatory)
1229 const char* default_string = kUnknownString; 1130 const char* default_string = kUnknownString;
1230 if (!properties.Retrieve(kAddressProperty, &default_string)) 1131 if (!properties.Retrieve(kAddressProperty, &default_string))
1231 return false; 1132 return false;
1232 info->address = NewStringCopy(default_string); 1133 info->address = NewStringCopy(default_string);
(...skipping 24 matching lines...) Expand all
1257 return true; 1158 return true;
1258 } 1159 }
1259 } // namespace 1160 } // namespace
1260 1161
1261 extern "C" 1162 extern "C"
1262 DeviceNetworkList* ChromeOSGetDeviceNetworkList() { 1163 DeviceNetworkList* ChromeOSGetDeviceNetworkList() {
1263 glib::Value devices_val; 1164 glib::Value devices_val;
1264 dbus::BusConnection bus = dbus::GetSystemBusConnection(); 1165 dbus::BusConnection bus = dbus::GetSystemBusConnection();
1265 { 1166 {
1266 dbus::Proxy manager_proxy(bus, 1167 dbus::Proxy manager_proxy(bus,
1267 kConnmanServiceName, 1168 kFlimflamServiceName,
1268 "/", 1169 "/",
1269 kConnmanManagerInterface); 1170 kFlimflamManagerInterface);
1270 1171
1271 glib::ScopedHashTable properties; 1172 glib::ScopedHashTable properties;
1272 if (!GetProperties(manager_proxy, &properties)) { 1173 if (!GetProperties(manager_proxy, &properties)) {
1273 LOG(WARNING) << "Couldn't read managers's properties"; 1174 LOG(WARNING) << "Couldn't read managers's properties";
1274 return NULL; 1175 return NULL;
1275 } 1176 }
1276 1177
1277 // Get the Devices property from the manager 1178 // Get the Devices property from the manager
1278 if (!properties.Retrieve(kDevicesProperty, &devices_val)) { 1179 if (!properties.Retrieve(kDevicesProperty, &devices_val)) {
1279 LOG(WARNING) << kDevicesProperty << " property not found"; 1180 LOG(WARNING) << kDevicesProperty << " property not found";
1280 return NULL; 1181 return NULL;
1281 } 1182 }
1282 } 1183 }
1283 GPtrArray* devices = static_cast<GPtrArray*>(g_value_get_boxed(&devices_val)); 1184 GPtrArray* devices = static_cast<GPtrArray*>(g_value_get_boxed(&devices_val));
1284 std::vector<DeviceNetworkInfo> buffer; 1185 std::vector<DeviceNetworkInfo> buffer;
1285 bool found_at_least_one_device = false; 1186 bool found_at_least_one_device = false;
1286 for (size_t i = 0; i < devices->len; i++) { 1187 for (size_t i = 0; i < devices->len; i++) {
1287 const char* device_path = 1188 const char* device_path =
1288 static_cast<const char*>(g_ptr_array_index(devices, i)); 1189 static_cast<const char*>(g_ptr_array_index(devices, i));
1289 dbus::Proxy device_proxy(bus, 1190 dbus::Proxy device_proxy(bus,
1290 kConnmanServiceName, 1191 kFlimflamServiceName,
1291 device_path, 1192 device_path,
1292 kConnmanDeviceInterface); 1193 kFlimflamDeviceInterface);
1293 1194
1294 glib::ScopedHashTable properties; 1195 glib::ScopedHashTable properties;
1295 if (!GetProperties(device_proxy, &properties)) { 1196 if (!GetProperties(device_proxy, &properties)) {
1296 LOG(WARNING) << "Couldn't read device's properties"; 1197 LOG(WARNING) << "Couldn't read device's properties";
1297 continue; 1198 continue;
1298 } 1199 }
1299 1200
1300 glib::Value networks_val; 1201 glib::Value networks_val;
1301 if (!properties.Retrieve(kNetworksProperty, &networks_val)) 1202 if (!properties.Retrieve(kNetworksProperty, &networks_val))
1302 continue; // Some devices do not list networks, e.g. ethernet. 1203 continue; // Some devices do not list networks, e.g. ethernet.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 void ChromeOSFreeDeviceNetworkList(DeviceNetworkList* list) { 1243 void ChromeOSFreeDeviceNetworkList(DeviceNetworkList* list) {
1343 delete [] list->networks; 1244 delete [] list->networks;
1344 delete list; 1245 delete list;
1345 } 1246 }
1346 1247
1347 ////////////////////////////////////////////////////////////////////////////// 1248 //////////////////////////////////////////////////////////////////////////////
1348 // Flimflam asynchronous interface code 1249 // Flimflam asynchronous interface code
1349 1250
1350 namespace { 1251 namespace {
1351 1252
1352 struct GetPropertiesCallbackData { 1253 struct FlimflamCallbackData {
1254 FlimflamCallbackData(const char* interface,
1255 const char* service_path) {
1256 DCHECK(interface);
1257 interface_name = std::string(interface);
1258 proxy = new dbus::Proxy(dbus::GetSystemBusConnection(),
1259 kFlimflamServiceName,
1260 service_path,
1261 interface);
1262 }
1263 virtual ~FlimflamCallbackData() {
1264 delete proxy;
1265 }
1266 // Owned by the callback, deleteted in the destructor:
1267 dbus::Proxy* proxy;
1268 std::string interface_name; // Store for error reporting.
1269 };
1270
1271 // DBus will always call the Delete function passed to it by
1272 // dbus_g_proxy_begin_call, whether DBus calls the callback or not.
1273 void DeleteFlimflamCallbackData(void* user_data) {
1274 FlimflamCallbackData* cb_data = static_cast<FlimflamCallbackData*>(user_data);
1275 delete cb_data; // virtual destructor.
1276 }
1277
1278 // Generic hander for logging errors from messages with no return value.
1279 void FlimflamNotifyHandleError(DBusGProxy* gproxy,
1280 DBusGProxyCall* call_id,
1281 void* user_data) {
1282 glib::ScopedError error;
1283 if (!::dbus_g_proxy_end_call(gproxy,
1284 call_id,
1285 &Resetter(&error).lvalue(),
1286 G_TYPE_INVALID)) {
1287 FlimflamCallbackData* cb_data =
1288 static_cast<FlimflamCallbackData*>(user_data);
1289 LOG(WARNING) << "DBus Error: " << cb_data->interface_name << ": "
1290 << (error->message ? error->message : "Unknown Error.");
1291 }
1292 }
1293
1294 struct GetPropertiesCallbackData : public FlimflamCallbackData {
1353 GetPropertiesCallbackData(const char* interface, 1295 GetPropertiesCallbackData(const char* interface,
1354 const char* service_path, 1296 const char* service_path,
1355 const char* cb_path, 1297 const char* cb_path,
1356 NetworkPropertiesCallback cb, 1298 NetworkPropertiesCallback cb,
1357 void* obj) : 1299 void* obj) :
1300 FlimflamCallbackData(interface, service_path),
1358 callback(cb), 1301 callback(cb),
1359 object(obj) { 1302 object(obj) {
1360 callback_path = NewStringCopy(cb_path); 1303 callback_path = NewStringCopy(cb_path);
1361 proxy = new dbus::Proxy(dbus::GetSystemBusConnection(),
1362 kConnmanServiceName,
1363 service_path,
1364 interface);
1365 } 1304 }
1366 ~GetPropertiesCallbackData() { 1305 virtual ~GetPropertiesCallbackData() {
1367 delete callback_path; 1306 delete callback_path;
1368 delete proxy;
1369 } 1307 }
1370 1308
1371 // Owned by the caller (i.e. Chrome), do not destroy them: 1309 // Owned by the caller (i.e. Chrome), do not destroy them:
1372 NetworkPropertiesCallback callback; 1310 NetworkPropertiesCallback callback;
1373 void* object; 1311 void* object;
1374 // Owned by the callback, deleteted in the destructor: 1312 // Owned by the callback, deleteted in the destructor:
1375 const char* callback_path; 1313 const char* callback_path;
1376 dbus::Proxy* proxy;
1377 }; 1314 };
1378 1315
1379 // DBus will always call the Delete function passed to it in
1380 // dbus_g_proxy_begin_call, whether DBus calls the callback or not.
1381 void DeleteGetPropertiesCallbackData(void* user_data) {
1382 GetPropertiesCallbackData* cb_data =
1383 static_cast<GetPropertiesCallbackData*>(user_data);
1384 delete cb_data;
1385 }
1386
1387 void GetPropertiesNotify(DBusGProxy* gproxy, 1316 void GetPropertiesNotify(DBusGProxy* gproxy,
1388 DBusGProxyCall* call_id, 1317 DBusGProxyCall* call_id,
1389 void* user_data) { 1318 void* user_data) {
1390 GetPropertiesCallbackData* cb_data = 1319 GetPropertiesCallbackData* cb_data =
1391 static_cast<GetPropertiesCallbackData*>(user_data); 1320 static_cast<GetPropertiesCallbackData*>(user_data);
1392 DCHECK(cb_data); 1321 DCHECK(cb_data);
1393 glib::ScopedError error; 1322 glib::ScopedError error;
1394 glib::ScopedHashTable properties; 1323 glib::ScopedHashTable properties;
1395 if (!::dbus_g_proxy_end_call( 1324 if (!::dbus_g_proxy_end_call(
1396 gproxy, 1325 gproxy,
(...skipping 17 matching lines...) Expand all
1414 NetworkPropertiesCallback callback, 1343 NetworkPropertiesCallback callback,
1415 void* object) { 1344 void* object) {
1416 DCHECK(interface && service_path && callback); 1345 DCHECK(interface && service_path && callback);
1417 GetPropertiesCallbackData* cb_data = new GetPropertiesCallbackData( 1346 GetPropertiesCallbackData* cb_data = new GetPropertiesCallbackData(
1418 interface, service_path, service_path, callback, object); 1347 interface, service_path, service_path, callback, object);
1419 DBusGProxyCall* call_id = ::dbus_g_proxy_begin_call( 1348 DBusGProxyCall* call_id = ::dbus_g_proxy_begin_call(
1420 cb_data->proxy->gproxy(), 1349 cb_data->proxy->gproxy(),
1421 kGetPropertiesFunction, 1350 kGetPropertiesFunction,
1422 &GetPropertiesNotify, 1351 &GetPropertiesNotify,
1423 cb_data, 1352 cb_data,
1424 &DeleteGetPropertiesCallbackData, 1353 &DeleteFlimflamCallbackData,
1425 G_TYPE_INVALID); 1354 G_TYPE_INVALID);
1426 if (!call_id) { 1355 if (!call_id) {
1427 LOG(ERROR) << "NULL call_id for: " << interface << " : " << service_path; 1356 LOG(ERROR) << "NULL call_id for: " << interface << " : " << service_path;
1428 callback(object, service_path, NULL); 1357 callback(object, service_path, NULL);
1429 delete cb_data; 1358 delete cb_data;
1430 } 1359 }
1431 } 1360 }
1432 1361
1433 void GetEntryAsync(const char* interface, 1362 void GetEntryAsync(const char* interface,
1434 const char* profile_path, 1363 const char* profile_path,
1435 const char* entry_path, 1364 const char* entry_path,
1436 NetworkPropertiesCallback callback, 1365 NetworkPropertiesCallback callback,
1437 void* object) { 1366 void* object) {
1438 DCHECK(interface && profile_path && entry_path && callback); 1367 DCHECK(interface && profile_path && entry_path && callback);
1439 GetPropertiesCallbackData* cb_data = new GetPropertiesCallbackData( 1368 GetPropertiesCallbackData* cb_data = new GetPropertiesCallbackData(
1440 interface, profile_path, entry_path, callback, object); 1369 interface, profile_path, entry_path, callback, object);
1441 DBusGProxyCall* call_id = ::dbus_g_proxy_begin_call( 1370 DBusGProxyCall* call_id = ::dbus_g_proxy_begin_call(
1442 cb_data->proxy->gproxy(), 1371 cb_data->proxy->gproxy(),
1443 kGetEntryFunction, 1372 kGetEntryFunction,
1444 &GetPropertiesNotify, 1373 &GetPropertiesNotify,
1445 cb_data, 1374 cb_data,
1446 &DeleteGetPropertiesCallbackData, 1375 &DeleteFlimflamCallbackData,
1447 G_TYPE_STRING, 1376 G_TYPE_STRING,
1448 entry_path, 1377 entry_path,
1449 G_TYPE_INVALID); 1378 G_TYPE_INVALID);
1450 if (!call_id) { 1379 if (!call_id) {
1451 LOG(ERROR) << "NULL call_id for: " 1380 LOG(ERROR) << "NULL call_id for: "
1452 << interface << " : " << profile_path << " : " << entry_path; 1381 << interface << " : " << profile_path << " : " << entry_path;
1453 callback(object, entry_path, NULL); 1382 callback(object, entry_path, NULL);
1454 delete cb_data; 1383 delete cb_data;
1455 } 1384 }
1456 } 1385 }
(...skipping 12 matching lines...) Expand all
1469 &Resetter(&error).lvalue(), 1398 &Resetter(&error).lvalue(),
1470 DBUS_TYPE_G_OBJECT_PATH, 1399 DBUS_TYPE_G_OBJECT_PATH,
1471 &service_path, 1400 &service_path,
1472 G_TYPE_INVALID)) { 1401 G_TYPE_INVALID)) {
1473 LOG(WARNING) << "GetWifiNotify for path: '" 1402 LOG(WARNING) << "GetWifiNotify for path: '"
1474 << cb_data->callback_path << "' error: " 1403 << cb_data->callback_path << "' error: "
1475 << (error->message ? error->message : "Unknown Error."); 1404 << (error->message ? error->message : "Unknown Error.");
1476 cb_data->callback(cb_data->object, cb_data->callback_path, NULL); 1405 cb_data->callback(cb_data->object, cb_data->callback_path, NULL);
1477 } else { 1406 } else {
1478 // Now request the properties for the service. 1407 // Now request the properties for the service.
1479 GetPropertiesAsync(kConnmanServiceInterface, 1408 GetPropertiesAsync(kFlimflamServiceInterface,
1480 service_path, 1409 service_path,
1481 cb_data->callback, 1410 cb_data->callback,
1482 cb_data->object); 1411 cb_data->object);
1483 } 1412 }
1484 } 1413 }
1485 1414
1486 struct NetworkActionCallbackData { 1415 struct NetworkActionCallbackData : public FlimflamCallbackData {
1487 NetworkActionCallbackData(const char* interface, 1416 NetworkActionCallbackData(const char* interface,
1488 const char* service_path, 1417 const char* service_path,
1489 const char* cb_path, 1418 const char* cb_path,
1490 NetworkActionCallback cb, 1419 NetworkActionCallback cb,
1491 void* obj) : 1420 void* obj) :
1421 FlimflamCallbackData(interface, service_path),
1492 callback(cb), 1422 callback(cb),
1493 object(obj) { 1423 object(obj) {
1494 callback_path = NewStringCopy(cb_path); 1424 callback_path = NewStringCopy(cb_path);
1495 proxy = new dbus::Proxy(dbus::GetSystemBusConnection(),
1496 kConnmanServiceName,
1497 service_path,
1498 interface);
1499 } 1425 }
1500 ~NetworkActionCallbackData() { 1426 virtual ~NetworkActionCallbackData() {
1501 delete callback_path; 1427 delete callback_path;
1502 delete proxy;
1503 } 1428 }
1504 1429
1505 // Owned by the caller (i.e. Chrome), do not destroy them: 1430 // Owned by the caller (i.e. Chrome), do not destroy them:
1506 NetworkActionCallback callback; 1431 NetworkActionCallback callback;
1507 void* object; 1432 void* object;
1508 // Owned by the callback, deleteted in the destructor: 1433 // Owned by the callback, deleteted in the destructor:
1509 const char* callback_path; 1434 const char* callback_path;
1510 dbus::Proxy* proxy;
1511 }; 1435 };
1512 1436
1513 // DBus will always call the Delete function passed to it in
1514 // dbus_g_proxy_begin_call, whether DBus calls the callback or not.
1515 void DeleteNetworkActionCallbackData(void* user_data) {
1516 NetworkActionCallbackData* cb_data =
1517 static_cast<NetworkActionCallbackData*>(user_data);
1518 delete cb_data;
1519 }
1520
1521 void NetworkServiceConnectNotify(DBusGProxy* gproxy, 1437 void NetworkServiceConnectNotify(DBusGProxy* gproxy,
1522 DBusGProxyCall* call_id, 1438 DBusGProxyCall* call_id,
1523 void* user_data) { 1439 void* user_data) {
1524 NetworkActionCallbackData* cb_data = 1440 NetworkActionCallbackData* cb_data =
1525 static_cast<NetworkActionCallbackData*>(user_data); 1441 static_cast<NetworkActionCallbackData*>(user_data);
1526 DCHECK(cb_data); 1442 DCHECK(cb_data);
1527 glib::ScopedError error; 1443 glib::ScopedError error;
1528 if (!::dbus_g_proxy_end_call( 1444 if (!::dbus_g_proxy_end_call(
1529 gproxy, 1445 gproxy,
1530 call_id, 1446 call_id,
(...skipping 16 matching lines...) Expand all
1547 NETWORK_METHOD_ERROR_NONE, NULL); 1463 NETWORK_METHOD_ERROR_NONE, NULL);
1548 } 1464 }
1549 } 1465 }
1550 1466
1551 void NetworkServiceConnectAsync( 1467 void NetworkServiceConnectAsync(
1552 const char* service_path, 1468 const char* service_path,
1553 NetworkActionCallback callback, 1469 NetworkActionCallback callback,
1554 void* object) { 1470 void* object) {
1555 DCHECK(service_path && callback); 1471 DCHECK(service_path && callback);
1556 NetworkActionCallbackData* cb_data = new NetworkActionCallbackData( 1472 NetworkActionCallbackData* cb_data = new NetworkActionCallbackData(
1557 kConnmanServiceInterface, service_path, service_path, callback, object); 1473 kFlimflamServiceInterface, service_path, service_path, callback, object);
1558 1474
1559 DBusGProxyCall* call_id = ::dbus_g_proxy_begin_call( 1475 DBusGProxyCall* call_id = ::dbus_g_proxy_begin_call(
1560 cb_data->proxy->gproxy(), 1476 cb_data->proxy->gproxy(),
1561 kConnectFunction, 1477 kConnectFunction,
1562 &NetworkServiceConnectNotify, 1478 &NetworkServiceConnectNotify,
1563 cb_data, 1479 cb_data,
1564 &DeleteNetworkActionCallbackData, 1480 &DeleteFlimflamCallbackData,
1565 DBUS_TYPE_G_OBJECT_PATH, 1481 DBUS_TYPE_G_OBJECT_PATH,
1566 &service_path, 1482 &service_path,
1567 G_TYPE_INVALID); 1483 G_TYPE_INVALID);
1568 if (!call_id) { 1484 if (!call_id) {
1569 LOG(ERROR) << "NULL call_id for: " << kConnmanServiceInterface 1485 LOG(ERROR) << "NULL call_id for: " << kFlimflamServiceInterface
1570 << " : " << service_path; 1486 << " : " << service_path;
1571 callback(object, service_path, NETWORK_METHOD_ERROR_LOCAL, 1487 callback(object, service_path, NETWORK_METHOD_ERROR_LOCAL,
1572 "dbus: NULL call_id"); 1488 "dbus: NULL call_id");
1573 delete cb_data; 1489 delete cb_data;
1574 } 1490 }
1575 } 1491 }
1576 1492
1577 1493
1578 } // namespace 1494 } // namespace
1579 1495
1580 extern "C" 1496 extern "C"
1581 void ChromeOSRequestNetworkServiceConnect( 1497 void ChromeOSRequestNetworkServiceConnect(
1582 const char* service_path, 1498 const char* service_path,
1583 NetworkActionCallback callback, 1499 NetworkActionCallback callback,
1584 void* object) { 1500 void* object) {
1585 NetworkServiceConnectAsync(service_path, callback, object); 1501 NetworkServiceConnectAsync(service_path, callback, object);
1586 } 1502 }
1587 1503
1588 1504
1589 extern "C" 1505 extern "C"
1590 void ChromeOSRequestNetworkManagerInfo( 1506 void ChromeOSRequestNetworkManagerInfo(
1591 NetworkPropertiesCallback callback, 1507 NetworkPropertiesCallback callback,
1592 void* object) { 1508 void* object) {
1593 GetPropertiesAsync(kConnmanManagerInterface, "/", callback, object); 1509 GetPropertiesAsync(kFlimflamManagerInterface, "/", callback, object);
1594 } 1510 }
1595 1511
1596 extern "C" 1512 extern "C"
1597 void ChromeOSRequestNetworkServiceInfo( 1513 void ChromeOSRequestNetworkServiceInfo(
1598 const char* service_path, 1514 const char* service_path,
1599 NetworkPropertiesCallback callback, 1515 NetworkPropertiesCallback callback,
1600 void* object) { 1516 void* object) {
1601 GetPropertiesAsync(kConnmanServiceInterface, service_path, callback, object); 1517 GetPropertiesAsync(kFlimflamServiceInterface, service_path, callback, object);
1602 } 1518 }
1603 1519
1604 extern "C" 1520 extern "C"
1605 void ChromeOSRequestNetworkDeviceInfo( 1521 void ChromeOSRequestNetworkDeviceInfo(
1606 const char* device_path, 1522 const char* device_path,
1607 NetworkPropertiesCallback callback, 1523 NetworkPropertiesCallback callback,
1608 void* object) { 1524 void* object) {
1609 GetPropertiesAsync(kConnmanDeviceInterface, device_path, callback, object); 1525 GetPropertiesAsync(kFlimflamDeviceInterface, device_path, callback, object);
1610 } 1526 }
1611 1527
1612 extern "C" 1528 extern "C"
1613 void ChromeOSRequestNetworkProfile( 1529 void ChromeOSRequestNetworkProfile(
1614 const char* profile_path, 1530 const char* profile_path,
1615 NetworkPropertiesCallback callback, 1531 NetworkPropertiesCallback callback,
1616 void* object) { 1532 void* object) {
1617 GetPropertiesAsync(kConnmanProfileInterface, profile_path, callback, object); 1533 GetPropertiesAsync(kFlimflamProfileInterface, profile_path, callback, object);
1618 } 1534 }
1619 1535
1620 extern "C" 1536 extern "C"
1621 void ChromeOSRequestNetworkProfileEntry( 1537 void ChromeOSRequestNetworkProfileEntry(
1622 const char* profile_path, 1538 const char* profile_path,
1623 const char* entry_service_path, 1539 const char* entry_service_path,
1624 NetworkPropertiesCallback callback, 1540 NetworkPropertiesCallback callback,
1625 void* object) { 1541 void* object) {
1626 GetEntryAsync(kConnmanProfileInterface, profile_path, entry_service_path, 1542 GetEntryAsync(kFlimflamProfileInterface, profile_path, entry_service_path,
1627 callback, object); 1543 callback, object);
1628 } 1544 }
1629 1545
1630 extern "C" 1546 extern "C"
1631 void ChromeOSRequestWifiServicePath( 1547 void ChromeOSRequestHiddenWifiNetwork(
1632 const char* ssid, 1548 const char* ssid,
1633 ConnectionSecurity security, 1549 const char* security,
1634 NetworkPropertiesCallback callback, 1550 NetworkPropertiesCallback callback,
1635 void* object) { 1551 void* object) {
1636 DCHECK(ssid && callback); 1552 DCHECK(ssid && callback);
1637 GetPropertiesCallbackData* cb_data = new GetPropertiesCallbackData( 1553 GetPropertiesCallbackData* cb_data = new GetPropertiesCallbackData(
1638 kConnmanManagerInterface, "/", ssid, callback, object); 1554 kFlimflamManagerInterface, "/", ssid, callback, object);
1639 1555
1640 glib::ScopedHashTable scoped_properties = 1556 glib::ScopedHashTable scoped_properties =
1641 glib::ScopedHashTable(::g_hash_table_new_full( 1557 glib::ScopedHashTable(::g_hash_table_new_full(
1642 ::g_str_hash, ::g_str_equal, ::g_free, NULL)); 1558 ::g_str_hash, ::g_str_equal, ::g_free, NULL));
1643 1559
1644 glib::Value value_mode(kModeManaged); 1560 glib::Value value_mode(kModeManaged);
1645 glib::Value value_type(kTypeWifi); 1561 glib::Value value_type(kTypeWifi);
1646 glib::Value value_ssid(ssid); 1562 glib::Value value_ssid(ssid);
1647 if (security == SECURITY_UNKNOWN) 1563 glib::Value value_security(security);
1648 security = SECURITY_RSN;
1649 glib::Value value_security(SecurityToString(security));
1650 ::GHashTable* properties = scoped_properties.get(); 1564 ::GHashTable* properties = scoped_properties.get();
1651 ::g_hash_table_insert(properties, ::g_strdup(kModeProperty), &value_mode); 1565 ::g_hash_table_insert(properties, ::g_strdup(kModeProperty), &value_mode);
1652 ::g_hash_table_insert(properties, ::g_strdup(kTypeProperty), &value_type); 1566 ::g_hash_table_insert(properties, ::g_strdup(kTypeProperty), &value_type);
1653 ::g_hash_table_insert(properties, ::g_strdup(kSSIDProperty), &value_ssid); 1567 ::g_hash_table_insert(properties, ::g_strdup(kSSIDProperty), &value_ssid);
1654 ::g_hash_table_insert(properties, ::g_strdup(kSecurityProperty), 1568 ::g_hash_table_insert(properties, ::g_strdup(kSecurityProperty),
1655 &value_security); 1569 &value_security);
1656 1570
1657 // flimflam.Manger.GetWifiService() will apply the property changes in 1571 // flimflam.Manger.GetWifiService() will apply the property changes in
1658 // |properties| and return a new or existing service to GetWifiNotify. 1572 // |properties| and return a new or existing service to GetWifiNotify.
1659 // GetWifiNotify will then call GetPropertiesAsync, triggering a second 1573 // GetWifiNotify will then call GetPropertiesAsync, triggering a second
1660 // asynchronous call to GetPropertiesNotify which will then call |callback|. 1574 // asynchronous call to GetPropertiesNotify which will then call |callback|.
1661 DBusGProxyCall* call_id = ::dbus_g_proxy_begin_call( 1575 DBusGProxyCall* call_id = ::dbus_g_proxy_begin_call(
1662 cb_data->proxy->gproxy(), 1576 cb_data->proxy->gproxy(),
1663 kGetWifiServiceFunction, 1577 kGetWifiServiceFunction,
1664 &GetWifiNotify, 1578 &GetWifiNotify,
1665 cb_data, 1579 cb_data,
1666 &DeleteGetPropertiesCallbackData, 1580 &DeleteFlimflamCallbackData,
1667 ::dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), 1581 ::dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
1668 properties, 1582 properties,
1669 G_TYPE_INVALID); 1583 G_TYPE_INVALID);
1670 if (!call_id) { 1584 if (!call_id) {
1671 LOG(ERROR) << "NULL call_id for: " << kGetWifiServiceFunction; 1585 LOG(ERROR) << "NULL call_id for: " << kGetWifiServiceFunction;
1672 delete cb_data; 1586 delete cb_data;
1673 callback(object, ssid, NULL); 1587 callback(object, ssid, NULL);
1674 } 1588 }
1675 } 1589 }
1676 1590
1591 extern "C"
1592 void ChromeOSRequestNetworkScan(const char* network_type) {
1593 FlimflamCallbackData* cb_data =
1594 new FlimflamCallbackData(kFlimflamManagerInterface, "/");
1595 DBusGProxyCall* call_id = ::dbus_g_proxy_begin_call(
1596 cb_data->proxy->gproxy(),
1597 kRequestScanFunction,
1598 &FlimflamNotifyHandleError,
1599 cb_data,
1600 &DeleteFlimflamCallbackData,
1601 G_TYPE_STRING,
1602 network_type,
1603 G_TYPE_INVALID);
1604 if (!call_id) {
1605 LOG(ERROR) << "NULL call_id for: " << kRequestScanFunction;
1606 delete cb_data;
1607 }
1608 }
1609
1610 extern "C"
1611 void ChromeOSRequestNetworkDeviceEnable(const char* network_type, bool enable) {
1612 FlimflamCallbackData* cb_data =
1613 new FlimflamCallbackData(kFlimflamManagerInterface, "/");
1614 DBusGProxyCall* call_id = ::dbus_g_proxy_begin_call(
1615 cb_data->proxy->gproxy(),
1616 enable ? kEnableTechnologyFunction : kDisableTechnologyFunction,
1617 &FlimflamNotifyHandleError,
1618 cb_data,
1619 &DeleteFlimflamCallbackData,
1620 G_TYPE_STRING,
1621 network_type,
1622 G_TYPE_INVALID);
1623 if (!call_id) {
1624 LOG(ERROR) << "NULL call_id for: " << kRequestScanFunction;
1625 delete cb_data;
1626 }
1627 }
1628
1677 ////////////////////////////////////////////////////////////////////////////// 1629 //////////////////////////////////////////////////////////////////////////////
1678 1630
1679 static glib::Value *ConvertToGlibValue(const ::Value* value) { 1631 static glib::Value *ConvertToGlibValue(const ::Value* value) {
1680 switch (value->GetType()) { 1632 switch (value->GetType()) {
1681 case ::Value::TYPE_BOOLEAN: { 1633 case ::Value::TYPE_BOOLEAN: {
1682 bool out; 1634 bool out;
1683 if (value->GetAsBoolean(&out)) 1635 if (value->GetAsBoolean(&out))
1684 return new glib::Value(out); 1636 return new glib::Value(out);
1685 break; 1637 break;
1686 } 1638 }
(...skipping 22 matching lines...) Expand all
1709 } 1661 }
1710 LOG(ERROR) << "Value conversion failed, type: " << value->GetType(); 1662 LOG(ERROR) << "Value conversion failed, type: " << value->GetType();
1711 return NULL; 1663 return NULL;
1712 } 1664 }
1713 1665
1714 1666
1715 extern "C" 1667 extern "C"
1716 void ChromeOSSetNetworkServiceProperty(const char* service_path, 1668 void ChromeOSSetNetworkServiceProperty(const char* service_path,
1717 const char* property, 1669 const char* property,
1718 const ::Value* setting) { 1670 const ::Value* setting) {
1719 dbus::Proxy service_proxy(dbus::GetSystemBusConnection(), 1671 FlimflamCallbackData* cb_data =
1720 kConnmanServiceName, 1672 new FlimflamCallbackData(kFlimflamServiceInterface, service_path);
1721 service_path,
1722 kConnmanServiceInterface);
1723 1673
1724 // DEPRECATED 1674 // DEPRECATED
1725 // Backwards-compatibility for "CertPath=SETTINGS:key_id=1,cert_id=2,..." 1675 // Backwards-compatibility for "CertPath=SETTINGS:key_id=1,cert_id=2,..."
1726 if (strcmp(property, "CertPath") == 0) { 1676 if (strcmp(property, "CertPath") == 0) {
1727 std::string str; 1677 std::string certpath;
1728 const char* certpath; 1678 if (setting->GetAsString(&certpath)) {
1729 setting->GetAsString(&str); 1679 // Synchronous call for backwards compatibility.
1730 certpath = str.c_str(); 1680 // TODO(njw): remove once CertPath is deprecated in favor of
1731 // Synchronous call for backwards compatibility. 1681 // explicit EAP.* properties.
1732 // TODO(njw): remove once CertPath is deprecated in favor of 1682 set_certpath_properties(certpath.c_str(), cb_data->proxy);
1733 // explicit EAP.* properties. 1683 }
1734 set_certpath_properties(certpath, &service_proxy); 1684 delete cb_data;
1735 return; 1685 return;
1736 } 1686 }
1737 1687
1688 // Start the DBus call. FlimflamNotifyHandleError will get called when
1689 // it completes and log any errors.
1738 scoped_ptr<glib::Value> gsetting(ConvertToGlibValue(setting)); 1690 scoped_ptr<glib::Value> gsetting(ConvertToGlibValue(setting));
1739 ::dbus_g_proxy_call_no_reply(service_proxy.gproxy(), 1691 DBusGProxyCall* call_id = ::dbus_g_proxy_begin_call(
1740 kSetPropertyFunction, 1692 cb_data->proxy->gproxy(),
1741 G_TYPE_STRING, 1693 kSetPropertyFunction,
1742 property, 1694 &FlimflamNotifyHandleError,
1743 G_VALUE_TYPE(gsetting.get()), 1695 cb_data,
1744 gsetting.get(), 1696 &DeleteFlimflamCallbackData,
1745 G_TYPE_INVALID); 1697 G_TYPE_STRING,
1698 property,
1699 G_VALUE_TYPE(gsetting.get()),
1700 gsetting.get(),
1701 G_TYPE_INVALID);
1702 if (!call_id) {
1703 LOG(ERROR) << "NULL call_id for: " << kRequestScanFunction;
1704 delete cb_data;
1705 }
1746 } 1706 }
1747 1707
1748 // Cashew services 1708 // Cashew services
1749 1709
1750 extern "C" 1710 extern "C"
1751 void ChromeOSFreeCellularDataPlanList(CellularDataPlanList* data_plan_list) { 1711 void ChromeOSFreeCellularDataPlanList(CellularDataPlanList* data_plan_list) {
1752 if (data_plan_list == NULL) 1712 if (data_plan_list == NULL)
1753 return; 1713 return;
1754 if (data_plan_list->plans_size > 0) { 1714 if (data_plan_list->plans_size > 0) {
1755 std::for_each(data_plan_list->plans, 1715 std::for_each(data_plan_list->plans,
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 } 1863 }
1904 DCHECK(properties_array); 1864 DCHECK(properties_array);
1905 1865
1906 CellularDataPlanList *data_plan_list = 1866 CellularDataPlanList *data_plan_list =
1907 ParseCellularDataPlanList(properties_array); 1867 ParseCellularDataPlanList(properties_array);
1908 g_ptr_array_unref(properties_array); 1868 g_ptr_array_unref(properties_array);
1909 return data_plan_list; 1869 return data_plan_list;
1910 } 1870 }
1911 1871
1912 } // namespace chromeos 1872 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos_network.h ('k') | chromeos_network_deprecated.h » ('j') | load.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698