Modify send_arp
[platform/core/connectivity/net-config.git] / src / wifi-passpoint.c
old mode 100644 (file)
new mode 100755 (executable)
index debb4d1..340019d
-/*\r
- * Network Configuration Module\r
- *\r
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <errno.h>\r
-\r
-#include "log.h"\r
-#include "util.h"\r
-#include "neterror.h"\r
-#include "netdbus.h"\r
-#include "netsupplicant.h"\r
-#include "wifi-passpoint.h"\r
-\r
-\r
-static gboolean netconfig_wifi_get_passpoint(gint32 *enabled)\r
-{\r
-       DBusMessage *reply;\r
-       DBusMessageIter iter, variant;\r
-       dbus_bool_t value;\r
-       gboolean result = FALSE;\r
-\r
-       reply = netconfig_supplicant_invoke_dbus_interface_property_get(SUPPLICANT_IFACE_INTERFACE,\r
-                               "Passpoint");\r
-       if (reply == NULL) {\r
-               ERR("Error!!! Failed to get passpoint property");\r
-               return result;\r
-       }\r
-\r
-       if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) {\r
-               const char *err_msg = dbus_message_get_error_name(reply);\r
-               ERR("Error!!! Error message received [%s]", err_msg);\r
-               return result;\r
-       }\r
-\r
-       dbus_message_iter_init(reply, &iter);\r
-\r
-       if (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_VARIANT) {\r
-               dbus_message_iter_recurse(&iter, &variant);\r
-               if (dbus_message_iter_get_arg_type(&variant) == DBUS_TYPE_INT32) {\r
-                       dbus_message_iter_get_basic(&variant, &value);\r
-                       if (value == TRUE)\r
-                               *enabled = 1;\r
-                       else\r
-                               *enabled = 0;\r
-\r
-                       result = TRUE;\r
-               }\r
-       }\r
-\r
-       dbus_message_unref(reply);\r
-\r
-       return result;\r
-}\r
-\r
-static gboolean netconfig_wifi_set_passpoint(gint32 enable)\r
-{\r
-       gint32 value = enable;\r
-       gboolean result = FALSE;\r
-       GList *input_args = NULL;\r
-\r
-       struct dbus_input_arguments args_enable[2] = {\r
-                       {DBUS_TYPE_INT32, &value},\r
-                       {DBUS_TYPE_INVALID, NULL}\r
-       };\r
-\r
-       input_args = setup_input_args(input_args, args_enable);\r
-\r
-       result = netconfig_supplicant_invoke_dbus_interface_property_set(SUPPLICANT_IFACE_INTERFACE,\r
-                       "Passpoint", DBUS_TYPE_INT32_AS_STRING, input_args, NULL);\r
-       if (result == FALSE)\r
-               ERR("Fail to set passpoint enable [%d]", enable);\r
-\r
-       g_list_free(input_args);\r
-\r
-       return result;\r
-}\r
-\r
-gboolean netconfig_iface_wifi_get_passpoint(NetconfigWifi *wifi,\r
-               gint32 *result, GError **error)\r
-{\r
-       g_return_val_if_fail(wifi != NULL, FALSE);\r
-\r
-       if (netconfig_wifi_get_passpoint(result))\r
-               return TRUE;\r
-\r
-       return FALSE;\r
-}\r
-\r
-gboolean netconfig_iface_wifi_set_passpoint(NetconfigWifi *wifi,\r
-               gint32 enable, GError **error)\r
-{\r
-       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
-\r
-       return netconfig_wifi_set_passpoint(enable);\r
-}\r
-\r
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <errno.h>
+
+#include "log.h"
+#include "util.h"
+#include "neterror.h"
+#include "netdbus.h"
+#include "netsupplicant.h"
+#include "wifi-passpoint.h"
+
+#if defined TIZEN_WLAN_PASSPOINT
+static gboolean netconfig_wifi_get_passpoint(gint32 *enabled)
+{
+       GVariant *reply, *var = NULL;
+       gboolean value;
+       gboolean result = FALSE;
+
+       reply = netconfig_supplicant_invoke_dbus_interface_property_get(SUPPLICANT_IFACE_INTERFACE,
+                               "Passpoint");
+       if (reply == NULL) {
+               ERR("Error!!! Failed to get passpoint property");
+               return FALSE;
+       }
+
+       g_variant_get(reply, "(v)", &var);
+
+       if (g_variant_is_of_type(var, G_VARIANT_TYPE_INT32)) {
+               value = g_variant_get_int32(var);
+               if (value == TRUE)
+                       *enabled = 1;
+               else
+                       *enabled = 0;
+
+               result = TRUE;
+       }
+
+       if (var)
+               g_variant_unref(var);
+
+       g_variant_unref(reply);
+
+       return result;
+}
+
+static gboolean netconfig_wifi_set_passpoint(gint32 enable)
+{
+       gint32 value = enable ? 1 : 0;
+       gboolean result = FALSE;
+
+       result = netconfig_supplicant_invoke_dbus_interface_property_set(
+                       SUPPLICANT_IFACE_INTERFACE, "Passpoint",
+                       g_variant_new_int32(value), NULL);
+       if (result == FALSE)
+               ERR("Fail to set passpoint enable[%d]", enable);
+
+       return result;
+}
+#endif
+
+gboolean handle_get_passpoint(Wifi *wifi, GDBusMethodInvocation *context)
+{
+       gint32 enable = 0;
+       g_return_val_if_fail(wifi != NULL, TRUE);
+
+#if defined TIZEN_WLAN_PASSPOINT
+       netconfig_wifi_get_passpoint(&enable);;
+#else
+       enable = 0;
+#endif
+       wifi_complete_get_passpoint(wifi, context, enable);
+       return TRUE;
+}
+
+gboolean handle_set_passpoint(Wifi *wifi, GDBusMethodInvocation *context, gint enable)
+{
+       g_return_val_if_fail(wifi != NULL, TRUE);
+
+#if defined TIZEN_WLAN_PASSPOINT
+       netconfig_wifi_set_passpoint(enable);
+#endif
+       wifi_complete_set_passpoint(wifi, context);
+       return TRUE;
+}