Remove syspopup
[platform/core/connectivity/net-config.git] / src / wifi-passpoint.c
1 /*\r
2  * Network Configuration Module\r
3  *\r
4  * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.\r
5  *\r
6  * Licensed under the Apache License, Version 2.0 (the "License");\r
7  * you may not use this file except in compliance with the License.\r
8  * You may obtain a copy of the License at\r
9  *\r
10  * http://www.apache.org/licenses/LICENSE-2.0\r
11  *\r
12  * Unless required by applicable law or agreed to in writing, software\r
13  * distributed under the License is distributed on an "AS IS" BASIS,\r
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
15  * See the License for the specific language governing permissions and\r
16  * limitations under the License.\r
17  *\r
18  */\r
19 \r
20 #include <errno.h>\r
21 \r
22 #include "log.h"\r
23 #include "util.h"\r
24 #include "neterror.h"\r
25 #include "netdbus.h"\r
26 #include "netsupplicant.h"\r
27 #include "wifi-passpoint.h"\r
28 \r
29 \r
30 static gboolean netconfig_wifi_get_passpoint(gint32 *enabled)\r
31 {\r
32         DBusMessage *reply;\r
33         DBusMessageIter iter, variant;\r
34         dbus_bool_t value;\r
35         gboolean result = FALSE;\r
36 \r
37         reply = netconfig_supplicant_invoke_dbus_interface_property_get(SUPPLICANT_IFACE_INTERFACE,\r
38                                 "Passpoint");\r
39         if (reply == NULL) {\r
40                 ERR("Error!!! Failed to get passpoint property");\r
41                 return result;\r
42         }\r
43 \r
44         if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) {\r
45                 const char *err_msg = dbus_message_get_error_name(reply);\r
46                 ERR("Error!!! Error message received [%s]", err_msg);\r
47                 return result;\r
48         }\r
49 \r
50         dbus_message_iter_init(reply, &iter);\r
51 \r
52         if (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_VARIANT) {\r
53                 dbus_message_iter_recurse(&iter, &variant);\r
54                 if (dbus_message_iter_get_arg_type(&variant) == DBUS_TYPE_INT32) {\r
55                         dbus_message_iter_get_basic(&variant, &value);\r
56                         if (value == TRUE)\r
57                                 *enabled = 1;\r
58                         else\r
59                                 *enabled = 0;\r
60 \r
61                         result = TRUE;\r
62                 }\r
63         }\r
64 \r
65         dbus_message_unref(reply);\r
66 \r
67         return result;\r
68 }\r
69 \r
70 static gboolean netconfig_wifi_set_passpoint(gint32 enable)\r
71 {\r
72         gint32 value = enable;\r
73         gboolean result = FALSE;\r
74         GList *input_args = NULL;\r
75 \r
76         struct dbus_input_arguments args_enable[2] = {\r
77                         {DBUS_TYPE_INT32, &value},\r
78                         {DBUS_TYPE_INVALID, NULL}\r
79         };\r
80 \r
81         input_args = setup_input_args(input_args, args_enable);\r
82 \r
83         result = netconfig_supplicant_invoke_dbus_interface_property_set(SUPPLICANT_IFACE_INTERFACE,\r
84                         "Passpoint", DBUS_TYPE_INT32_AS_STRING, input_args, NULL);\r
85         if (result == FALSE)\r
86                 ERR("Fail to set passpoint enable [%d]", enable);\r
87 \r
88         g_list_free(input_args);\r
89 \r
90         return result;\r
91 }\r
92 \r
93 gboolean netconfig_iface_wifi_get_passpoint(NetconfigWifi *wifi,\r
94                 gint32 *result, GError **error)\r
95 {\r
96         g_return_val_if_fail(wifi != NULL, FALSE);\r
97 \r
98         if (netconfig_wifi_get_passpoint(result))\r
99                 return TRUE;\r
100 \r
101         return FALSE;\r
102 }\r
103 \r
104 gboolean netconfig_iface_wifi_set_passpoint(NetconfigWifi *wifi,\r
105                 gint32 enable, GError **error)\r
106 {\r
107         g_return_val_if_fail(wifi != NULL, FALSE);//Verifies that the expression expr , usually representing a precondition, evaluates to TRUE. If the function does not return a value, use g_return_if_fail() instead\r
108 \r
109         return netconfig_wifi_set_passpoint(enable);\r
110 }\r
111 \r