OLD | NEW |
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 <vector> | 8 #include <vector> |
9 #include <cstring> | 9 #include <cstring> |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 static const char* kConnmanServiceInterface = "org.moblin.connman.Service"; | 24 static const char* kConnmanServiceInterface = "org.moblin.connman.Service"; |
25 static const char* kConnmanServiceName = "org.moblin.connman"; | 25 static const char* kConnmanServiceName = "org.moblin.connman"; |
26 static const char* kConnmanIPConfigInterface = "org.moblin.connman.IPConfig"; | 26 static const char* kConnmanIPConfigInterface = "org.moblin.connman.IPConfig"; |
27 static const char* kConnmanDeviceInterface = "org.moblin.connman.Device"; | 27 static const char* kConnmanDeviceInterface = "org.moblin.connman.Device"; |
28 static const char* kConnmanProfileInterface = "org.moblin.connman.Profile"; | 28 static const char* kConnmanProfileInterface = "org.moblin.connman.Profile"; |
29 | 29 |
30 // Connman function names. | 30 // Connman function names. |
31 static const char* kGetPropertiesFunction = "GetProperties"; | 31 static const char* kGetPropertiesFunction = "GetProperties"; |
32 static const char* kSetPropertyFunction = "SetProperty"; | 32 static const char* kSetPropertyFunction = "SetProperty"; |
33 static const char* kConnectFunction = "Connect"; | 33 static const char* kConnectFunction = "Connect"; |
| 34 static const char* kDisconnectFunction = "Disconnect"; |
34 static const char* kRequestScanFunction = "RequestScan"; | 35 static const char* kRequestScanFunction = "RequestScan"; |
35 static const char* kGetWifiServiceFunction = "GetWifiService"; | 36 static const char* kGetWifiServiceFunction = "GetWifiService"; |
36 static const char* kEnableTechnologyFunction = "EnableTechnology"; | 37 static const char* kEnableTechnologyFunction = "EnableTechnology"; |
37 static const char* kDisableTechnologyFunction = "DisableTechnology"; | 38 static const char* kDisableTechnologyFunction = "DisableTechnology"; |
38 static const char* kAddIPConfigFunction = "AddIPConfig"; | 39 static const char* kAddIPConfigFunction = "AddIPConfig"; |
39 static const char* kRemoveConfigFunction = "Remove"; | 40 static const char* kRemoveConfigFunction = "Remove"; |
40 static const char* kGetEntryFunction = "GetEntry"; | 41 static const char* kGetEntryFunction = "GetEntry"; |
41 static const char* kDeleteEntryFunction = "DeleteEntry"; | 42 static const char* kDeleteEntryFunction = "DeleteEntry"; |
42 | 43 |
43 // Connman property names. | 44 // Connman property names. |
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
924 | 925 |
925 extern "C" | 926 extern "C" |
926 bool ChromeOSConnectToNetwork(const char* service_path, | 927 bool ChromeOSConnectToNetwork(const char* service_path, |
927 const char* passphrase) { | 928 const char* passphrase) { |
928 | 929 |
929 return ChromeOSConnectToNetworkWithCertInfo(service_path, passphrase, | 930 return ChromeOSConnectToNetworkWithCertInfo(service_path, passphrase, |
930 NULL, NULL); | 931 NULL, NULL); |
931 } | 932 } |
932 | 933 |
933 extern "C" | 934 extern "C" |
| 935 bool ChromeOSDisconnectFromNetwork(const char* service_path) { |
| 936 dbus::Proxy service_proxy(dbus::GetSystemBusConnection(), |
| 937 kConnmanServiceName, |
| 938 service_path, |
| 939 kConnmanServiceInterface); |
| 940 |
| 941 // Now try disconnecting. |
| 942 glib::ScopedError error; |
| 943 if (!::dbus_g_proxy_call(service_proxy.gproxy(), |
| 944 kDisconnectFunction, |
| 945 &Resetter(&error).lvalue(), |
| 946 G_TYPE_INVALID, |
| 947 G_TYPE_INVALID)) { |
| 948 LOG(WARNING) << "DisconnectFromNetwork failed: " |
| 949 << (error->message ? error->message : "Unknown Error."); |
| 950 return false; |
| 951 } |
| 952 return true; |
| 953 } |
| 954 |
| 955 extern "C" |
934 bool ChromeOSDeleteRememberedService(const char* service_path) { | 956 bool ChromeOSDeleteRememberedService(const char* service_path) { |
935 dbus::BusConnection bus = dbus::GetSystemBusConnection(); | 957 dbus::BusConnection bus = dbus::GetSystemBusConnection(); |
936 dbus::Proxy manager_proxy(bus, | 958 dbus::Proxy manager_proxy(bus, |
937 kConnmanServiceName, | 959 kConnmanServiceName, |
938 "/", | 960 "/", |
939 kConnmanManagerInterface); | 961 kConnmanManagerInterface); |
940 | 962 |
941 glib::ScopedHashTable properties; | 963 glib::ScopedHashTable properties; |
942 if (!GetProperties(manager_proxy, &properties)) { | 964 if (!GetProperties(manager_proxy, &properties)) { |
943 return false; | 965 return false; |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 G_TYPE_INVALID, | 1196 G_TYPE_INVALID, |
1175 G_TYPE_INVALID)) { | 1197 G_TYPE_INVALID)) { |
1176 LOG(WARNING) << "SetAutoConnect failed: " | 1198 LOG(WARNING) << "SetAutoConnect failed: " |
1177 << (error->message ? error->message : "Unknown Error."); | 1199 << (error->message ? error->message : "Unknown Error."); |
1178 return false; | 1200 return false; |
1179 } | 1201 } |
1180 | 1202 |
1181 return true; | 1203 return true; |
1182 } | 1204 } |
1183 | 1205 |
| 1206 extern "C" |
| 1207 bool ChromeOSSetPassphrase(const char* service_path, const char* passphrase) { |
| 1208 dbus::Proxy service_proxy(dbus::GetSystemBusConnection(), |
| 1209 kConnmanServiceName, |
| 1210 service_path, |
| 1211 kConnmanServiceInterface); |
| 1212 |
| 1213 glib::Value value_passphrase(passphrase); |
| 1214 glib::ScopedError error; |
| 1215 if (!::dbus_g_proxy_call(service_proxy.gproxy(), |
| 1216 kSetPropertyFunction, |
| 1217 &Resetter(&error).lvalue(), |
| 1218 G_TYPE_STRING, |
| 1219 kPassphraseProperty, |
| 1220 G_TYPE_VALUE, |
| 1221 &value_passphrase, |
| 1222 G_TYPE_INVALID, |
| 1223 G_TYPE_INVALID)) { |
| 1224 LOG(WARNING) << "SetPassphrase failed: " |
| 1225 << (error->message ? error->message : "Unknown Error."); |
| 1226 return false; |
| 1227 } |
| 1228 |
| 1229 return true; |
| 1230 } |
| 1231 |
1184 } // namespace chromeos | 1232 } // namespace chromeos |
OLD | NEW |