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 <cstring> | 8 #include <cstring> |
9 #include <list> | 9 #include <list> |
10 #include <set> | 10 #include <set> |
(...skipping 1898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1909 // aren't passed through this mechanism, and so we're not going to | 1909 // aren't passed through this mechanism, and so we're not going to |
1910 // bother to try converting them. | 1910 // bother to try converting them. |
1911 // If we get here, it's a programming error, so complain. | 1911 // If we get here, it's a programming error, so complain. |
1912 LOG(ERROR) << "Unconverted Value of type: " << value->GetType(); | 1912 LOG(ERROR) << "Unconverted Value of type: " << value->GetType(); |
1913 return NULL; | 1913 return NULL; |
1914 } | 1914 } |
1915 LOG(ERROR) << "Value conversion failed, type: " << value->GetType(); | 1915 LOG(ERROR) << "Value conversion failed, type: " << value->GetType(); |
1916 return NULL; | 1916 return NULL; |
1917 } | 1917 } |
1918 | 1918 |
1919 | 1919 static void SetNetworkProperty(FlimflamCallbackData *cb_data, |
1920 extern "C" | 1920 const char* property, |
1921 void ChromeOSSetNetworkServiceProperty(const char* service_path, | 1921 const ::Value* setting) { |
1922 const char* property, | |
1923 const ::Value* setting) { | |
1924 FlimflamCallbackData* cb_data = | |
1925 new FlimflamCallbackData(kFlimflamServiceInterface, service_path); | |
1926 | |
1927 // DEPRECATED | |
1928 // Backwards-compatibility for "CertPath=SETTINGS:key_id=1,cert_id=2,..." | |
1929 if (strcmp(property, "CertPath") == 0) { | |
1930 std::string certpath; | |
1931 if (setting->GetAsString(&certpath)) { | |
1932 // Synchronous call for backwards compatibility. | |
1933 // TODO(njw): remove once CertPath is deprecated in favor of | |
1934 // explicit EAP.* properties. | |
1935 set_certpath_properties(certpath.c_str(), cb_data->proxy.get()); | |
1936 } | |
1937 delete cb_data; | |
1938 return; | |
1939 } | |
1940 | |
1941 // Start the DBus call. FlimflamNotifyHandleError will get called when | 1922 // Start the DBus call. FlimflamNotifyHandleError will get called when |
1942 // it completes and log any errors. | 1923 // it completes and log any errors. |
1943 scoped_ptr<glib::Value> gsetting(ConvertToGlibValue(setting)); | 1924 scoped_ptr<glib::Value> gsetting(ConvertToGlibValue(setting)); |
1944 DBusGProxyCall* call_id = ::dbus_g_proxy_begin_call( | 1925 DBusGProxyCall* call_id = ::dbus_g_proxy_begin_call( |
1945 cb_data->proxy->gproxy(), | 1926 cb_data->proxy->gproxy(), |
1946 kSetPropertyFunction, | 1927 kSetPropertyFunction, |
1947 &FlimflamNotifyHandleError, | 1928 &FlimflamNotifyHandleError, |
1948 cb_data, | 1929 cb_data, |
1949 &DeleteFlimflamCallbackData, | 1930 &DeleteFlimflamCallbackData, |
1950 G_TYPE_STRING, | 1931 G_TYPE_STRING, |
1951 property, | 1932 property, |
1952 G_TYPE_VALUE, | 1933 G_TYPE_VALUE, |
1953 gsetting.get(), | 1934 gsetting.get(), |
1954 G_TYPE_INVALID); | 1935 G_TYPE_INVALID); |
1955 if (!call_id) { | 1936 if (!call_id) { |
1956 LOG(ERROR) << "NULL call_id for: " << kSetPropertyFunction; | 1937 LOG(ERROR) << "NULL call_id for: " << kSetPropertyFunction; |
1957 delete cb_data; | 1938 delete cb_data; |
1958 } | 1939 } |
1959 } | 1940 } |
1960 | 1941 |
1961 extern "C" | 1942 static void ClearNetworkProperty(FlimflamCallbackData *cb_data, |
1962 void ChromeOSClearNetworkServiceProperty(const char* service_path, | 1943 const char* property) { |
1963 const char* property) { | |
1964 FlimflamCallbackData* cb_data = | |
1965 new FlimflamCallbackData(kFlimflamServiceInterface, service_path); | |
1966 | |
1967 // Start the DBus call. FlimflamNotifyHandleError will get called when | 1944 // Start the DBus call. FlimflamNotifyHandleError will get called when |
1968 // it completes and log any errors. | 1945 // it completes and log any errors. |
1969 DBusGProxyCall* call_id = ::dbus_g_proxy_begin_call( | 1946 DBusGProxyCall* call_id = ::dbus_g_proxy_begin_call( |
1970 cb_data->proxy->gproxy(), | 1947 cb_data->proxy->gproxy(), |
1971 kClearPropertyFunction, | 1948 kClearPropertyFunction, |
1972 &FlimflamNotifyHandleError, | 1949 &FlimflamNotifyHandleError, |
1973 cb_data, | 1950 cb_data, |
1974 &DeleteFlimflamCallbackData, | 1951 &DeleteFlimflamCallbackData, |
1975 G_TYPE_STRING, | 1952 G_TYPE_STRING, |
1976 property, | 1953 property, |
1977 G_TYPE_INVALID); | 1954 G_TYPE_INVALID); |
1978 if (!call_id) { | 1955 if (!call_id) { |
1979 LOG(ERROR) << "NULL call_id for: " << kClearPropertyFunction; | 1956 LOG(ERROR) << "NULL call_id for: " << kClearPropertyFunction; |
1980 delete cb_data; | 1957 delete cb_data; |
1981 } | 1958 } |
1982 } | 1959 } |
1983 | 1960 |
| 1961 extern "C" |
| 1962 void ChromeOSSetNetworkServiceProperty(const char* service_path, |
| 1963 const char* property, |
| 1964 const ::Value* setting) { |
| 1965 FlimflamCallbackData* cb_data = |
| 1966 new FlimflamCallbackData(kFlimflamServiceInterface, service_path); |
| 1967 |
| 1968 // DEPRECATED |
| 1969 // Backwards-compatibility for "CertPath=SETTINGS:key_id=1,cert_id=2,..." |
| 1970 if (strcmp(property, "CertPath") == 0) { |
| 1971 std::string certpath; |
| 1972 if (setting->GetAsString(&certpath)) { |
| 1973 // Synchronous call for backwards compatibility. |
| 1974 // TODO(njw): remove once CertPath is deprecated in favor of |
| 1975 // explicit EAP.* properties. |
| 1976 set_certpath_properties(certpath.c_str(), cb_data->proxy.get()); |
| 1977 } |
| 1978 delete cb_data; |
| 1979 return; |
| 1980 } |
| 1981 |
| 1982 SetNetworkProperty(cb_data, property, setting); |
| 1983 } |
| 1984 |
| 1985 extern "C" |
| 1986 void ChromeOSClearNetworkServiceProperty(const char* service_path, |
| 1987 const char* property) { |
| 1988 FlimflamCallbackData* cb_data = |
| 1989 new FlimflamCallbackData(kFlimflamServiceInterface, service_path); |
| 1990 |
| 1991 ClearNetworkProperty(cb_data, property); |
| 1992 } |
| 1993 |
| 1994 extern "C" |
| 1995 void ChromeOSSetNetworkDeviceProperty(const char* device_path, |
| 1996 const char* property, |
| 1997 const ::Value* setting) { |
| 1998 FlimflamCallbackData* cb_data = |
| 1999 new FlimflamCallbackData(kFlimflamDeviceInterface, device_path); |
| 2000 |
| 2001 SetNetworkProperty(cb_data, property, setting); |
| 2002 } |
| 2003 |
| 2004 extern "C" |
| 2005 void ChromeOSClearNetworkDeviceProperty(const char* device_path, |
| 2006 const char* property) { |
| 2007 FlimflamCallbackData* cb_data = |
| 2008 new FlimflamCallbackData(kFlimflamDeviceInterface, device_path); |
| 2009 |
| 2010 ClearNetworkProperty(cb_data, property); |
| 2011 } |
| 2012 |
1984 // Cashew services | 2013 // Cashew services |
1985 | 2014 |
1986 extern "C" | 2015 extern "C" |
1987 void ChromeOSFreeCellularDataPlanList(CellularDataPlanList* data_plan_list) { | 2016 void ChromeOSFreeCellularDataPlanList(CellularDataPlanList* data_plan_list) { |
1988 if (data_plan_list == NULL) | 2017 if (data_plan_list == NULL) |
1989 return; | 2018 return; |
1990 if (data_plan_list->plans_size > 0) { | 2019 if (data_plan_list->plans_size > 0) { |
1991 std::for_each(data_plan_list->plans, | 2020 std::for_each(data_plan_list->plans, |
1992 data_plan_list->plans + data_plan_list->plans_size, | 2021 data_plan_list->plans + data_plan_list->plans_size, |
1993 &DeleteDataPlanProperties); | 2022 &DeleteDataPlanProperties); |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2528 } | 2557 } |
2529 | 2558 |
2530 extern "C" | 2559 extern "C" |
2531 void ChromeOSDisconnectSMSMonitor(SMSMonitor monitor) { | 2560 void ChromeOSDisconnectSMSMonitor(SMSMonitor monitor) { |
2532 if (monitor->connection()) | 2561 if (monitor->connection()) |
2533 dbus::Disconnect(monitor->connection()); | 2562 dbus::Disconnect(monitor->connection()); |
2534 delete monitor; | 2563 delete monitor; |
2535 } | 2564 } |
2536 | 2565 |
2537 } // namespace chromeos | 2566 } // namespace chromeos |
OLD | NEW |