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

Side by Side Diff: chromeos_network_deprecated.cc

Issue 6606024: Eliminate ConenctionType, etc from chromeos_network.h (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/cros.git@master
Patch Set: Rebase. 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
« no previous file with comments | « chromeos_network_deprecated.h ('k') | load.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chromeos_network_deprecated.h" // NOLINT 6 #include "chromeos_network_deprecated.h" // NOLINT
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <cstring> 9 #include <cstring>
10 #include <list> 10 #include <list>
(...skipping 20 matching lines...) Expand all
31 31
32 // Connman D-Bus service identifiers. 32 // Connman D-Bus service identifiers.
33 static const char* kConnmanManagerInterface = "org.chromium.flimflam.Manager"; 33 static const char* kConnmanManagerInterface = "org.chromium.flimflam.Manager";
34 static const char* kConnmanServiceInterface = "org.chromium.flimflam.Service"; 34 static const char* kConnmanServiceInterface = "org.chromium.flimflam.Service";
35 static const char* kConnmanServiceName = "org.chromium.flimflam"; 35 static const char* kConnmanServiceName = "org.chromium.flimflam";
36 static const char* kConnmanDeviceInterface = "org.chromium.flimflam.Device"; 36 static const char* kConnmanDeviceInterface = "org.chromium.flimflam.Device";
37 static const char* kConnmanProfileInterface = "org.chromium.flimflam.Profile"; 37 static const char* kConnmanProfileInterface = "org.chromium.flimflam.Profile";
38 38
39 // Connman function names. 39 // Connman function names.
40 static const char* kGetPropertiesFunction = "GetProperties"; 40 static const char* kGetPropertiesFunction = "GetProperties";
41 static const char* kRequestScanFunction = "RequestScan";
41 static const char* kConfigureWifiServiceFunction = "ConfigureWifiService"; 42 static const char* kConfigureWifiServiceFunction = "ConfigureWifiService";
42 static const char* kGetWifiServiceFunction = "GetWifiService"; 43 static const char* kGetWifiServiceFunction = "GetWifiService";
44 static const char* kEnableTechnologyFunction = "EnableTechnology";
45 static const char* kDisableTechnologyFunction = "DisableTechnology";
43 static const char* kGetEntryFunction = "GetEntry"; 46 static const char* kGetEntryFunction = "GetEntry";
44 47
45 // Connman property names. 48 // Connman property names.
46 static const char* kSecurityProperty = "Security"; 49 static const char* kSecurityProperty = "Security";
47 static const char* kPassphraseProperty = "Passphrase"; 50 static const char* kPassphraseProperty = "Passphrase";
48 static const char* kPassphraseRequiredProperty = "PassphraseRequired"; 51 static const char* kPassphraseRequiredProperty = "PassphraseRequired";
49 static const char* kServicesProperty = "Services"; 52 static const char* kServicesProperty = "Services";
50 static const char* kAvailableTechnologiesProperty = "AvailableTechnologies"; 53 static const char* kAvailableTechnologiesProperty = "AvailableTechnologies";
51 static const char* kEnabledTechnologiesProperty = "EnabledTechnologies"; 54 static const char* kEnabledTechnologiesProperty = "EnabledTechnologies";
52 static const char* kConnectedTechnologiesProperty = "ConnectedTechnologies"; 55 static const char* kConnectedTechnologiesProperty = "ConnectedTechnologies";
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 return TYPE_WIFI; 197 return TYPE_WIFI;
195 if (type == kTypeWimax) 198 if (type == kTypeWimax)
196 return TYPE_WIMAX; 199 return TYPE_WIMAX;
197 if (type == kTypeBluetooth) 200 if (type == kTypeBluetooth)
198 return TYPE_BLUETOOTH; 201 return TYPE_BLUETOOTH;
199 if (type == kTypeCellular) 202 if (type == kTypeCellular)
200 return TYPE_CELLULAR; 203 return TYPE_CELLULAR;
201 return TYPE_UNKNOWN; 204 return TYPE_UNKNOWN;
202 } 205 }
203 206
207 static const char* TypeToString(ConnectionType type) {
208 switch (type) {
209 case TYPE_UNKNOWN:
210 break;
211 case TYPE_ETHERNET:
212 return kTypeEthernet;
213 case TYPE_WIFI:
214 return kTypeWifi;
215 case TYPE_WIMAX:
216 return kTypeWimax;
217 case TYPE_BLUETOOTH:
218 return kTypeBluetooth;
219 case TYPE_CELLULAR:
220 return kTypeCellular;
221 }
222 return kTypeUnknown;
223 }
224
204 static ConnectionMode ParseMode(const std::string& mode) { 225 static ConnectionMode ParseMode(const std::string& mode) {
205 if (mode == kModeManaged) 226 if (mode == kModeManaged)
206 return MODE_MANAGED; 227 return MODE_MANAGED;
207 if (mode == kModeAdhoc) 228 if (mode == kModeAdhoc)
208 return MODE_ADHOC; 229 return MODE_ADHOC;
209 return MODE_UNKNOWN; 230 return MODE_UNKNOWN;
210 } 231 }
211 232
212 static ConnectionSecurity ParseSecurity(const std::string& security) { 233 static ConnectionSecurity ParseSecurity(const std::string& security) {
213 if (security == kSecurity8021x) 234 if (security == kSecurity8021x)
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 delete info.carrier_info; 780 delete info.carrier_info;
760 info.carrier_info = NULL; 781 info.carrier_info = NULL;
761 } 782 }
762 783
763 // Note: DeviceInfo is owned by SystemInfo. 784 // Note: DeviceInfo is owned by SystemInfo.
764 } 785 }
765 786
766 } 787 }
767 788
768 extern "C" 789 extern "C"
790 void ChromeOSRequestScan(ConnectionType type) {
791 dbus::Proxy manager_proxy(dbus::GetSystemBusConnection(),
792 kConnmanServiceName,
793 "/",
794 kConnmanManagerInterface);
795 gchar* device = ::g_strdup(TypeToString(type));
796 glib::ScopedError error;
797 if (!::dbus_g_proxy_call(manager_proxy.gproxy(),
798 kRequestScanFunction,
799 &Resetter(&error).lvalue(),
800 G_TYPE_STRING,
801 device,
802 G_TYPE_INVALID,
803 G_TYPE_INVALID)) {
804 LOG(WARNING) << "ChromeOSRequestScan failed: "
805 << (error->message ? error->message : "Unknown Error.");
806 }
807 ::g_free(device);
808 }
809
810 extern "C"
769 ServiceInfo* ChromeOSGetWifiService(const char* ssid, 811 ServiceInfo* ChromeOSGetWifiService(const char* ssid,
770 ConnectionSecurity security) { 812 ConnectionSecurity security) {
771 dbus::Proxy manager_proxy(dbus::GetSystemBusConnection(), 813 dbus::Proxy manager_proxy(dbus::GetSystemBusConnection(),
772 kConnmanServiceName, 814 kConnmanServiceName,
773 "/", 815 "/",
774 kConnmanManagerInterface); 816 kConnmanManagerInterface);
775 817
776 glib::ScopedHashTable scoped_properties = 818 glib::ScopedHashTable scoped_properties =
777 glib::ScopedHashTable( 819 glib::ScopedHashTable(
778 ::g_hash_table_new_full(::g_str_hash, 820 ::g_hash_table_new_full(::g_str_hash,
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 system->service_info_size = sizeof(ServiceInfo); 1169 system->service_info_size = sizeof(ServiceInfo);
1128 system->device_info_size = sizeof(DeviceInfo); 1170 system->device_info_size = sizeof(DeviceInfo);
1129 1171
1130 base::TimeDelta dt = (base::Time::Now() - t0); 1172 base::TimeDelta dt = (base::Time::Now() - t0);
1131 LOG(INFO) << "SystemInfo: " << dt.InMilliseconds() << " ms."; 1173 LOG(INFO) << "SystemInfo: " << dt.InMilliseconds() << " ms.";
1132 1174
1133 return system; 1175 return system;
1134 } 1176 }
1135 1177
1136 extern "C" 1178 extern "C"
1179 bool ChromeOSEnableNetworkDevice(ConnectionType type, bool enable) {
1180 dbus::BusConnection bus = dbus::GetSystemBusConnection();
1181 dbus::Proxy manager_proxy(bus,
1182 kConnmanServiceName,
1183 "/",
1184 kConnmanManagerInterface);
1185 if (type == TYPE_UNKNOWN) {
1186 LOG(WARNING) << "EnableNetworkDevice called with an unknown type: " << type;
1187 return false;
1188 }
1189
1190 gchar* device = ::g_strdup(TypeToString(type));
1191 glib::ScopedError error;
1192 if (!::dbus_g_proxy_call(manager_proxy.gproxy(),
1193 enable ? kEnableTechnologyFunction :
1194 kDisableTechnologyFunction,
1195 &Resetter(&error).lvalue(),
1196 G_TYPE_STRING,
1197 device,
1198 G_TYPE_INVALID,
1199 G_TYPE_INVALID)) {
1200 LOG(WARNING) << "EnableNetworkDevice failed: "
1201 << (error->message ? error->message : "Unknown Error.");
1202 ::g_free(device);
1203 return false;
1204 }
1205 ::g_free(device);
1206 return true;
1207 }
1208
1209 extern "C"
1137 void ChromeOSFreeSystemInfo(SystemInfo* system) { 1210 void ChromeOSFreeSystemInfo(SystemInfo* system) {
1138 if (system == NULL) 1211 if (system == NULL)
1139 return; 1212 return;
1140 if (system->service_size > 0) { 1213 if (system->service_size > 0) {
1141 std::for_each(system->services, 1214 std::for_each(system->services,
1142 system->services + system->service_size, 1215 system->services + system->service_size,
1143 &DeleteServiceInfoProperties); 1216 &DeleteServiceInfoProperties);
1144 delete [] system->services; 1217 delete [] system->services;
1145 } 1218 }
1146 if (system->remembered_service_size > 0) { 1219 if (system->remembered_service_size > 0) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 &ManagerPropertyChangedHandler::Run, result); 1290 &ManagerPropertyChangedHandler::Run, result);
1218 return result; 1291 return result;
1219 } 1292 }
1220 1293
1221 extern "C" 1294 extern "C"
1222 void ChromeOSDisconnectMonitorNetwork(MonitorNetworkConnection connection) { 1295 void ChromeOSDisconnectMonitorNetwork(MonitorNetworkConnection connection) {
1223 dbus::Disconnect(connection->connection()); 1296 dbus::Disconnect(connection->connection());
1224 delete connection; 1297 delete connection;
1225 } 1298 }
1226 1299
1300 extern "C"
1301 void ChromeOSRequestHiddenWifiNetwork(const char* ssid,
1302 const char* security,
1303 NetworkPropertiesCallback callback,
1304 void* object);
1305
1306 extern "C"
1307 void ChromeOSRequestWifiServicePath(
1308 const char* ssid,
1309 ConnectionSecurity security,
1310 NetworkPropertiesCallback callback,
1311 void* object) {
1312 ChromeOSRequestHiddenWifiNetwork(
1313 ssid, SecurityToString(security), callback, object);
1314 }
1315
1227 } // namespace chromeos 1316 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos_network_deprecated.h ('k') | load.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698