2 * Network Configuration Module
4 * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
22 #include "netsupplicant.h"
24 char *netconfig_wifi_get_supplicant_interface(void)
26 GVariant *message = NULL;
27 GVariant *params = NULL;
30 params = g_variant_new("(s)", WIFI_IFNAME);
32 message = netconfig_supplicant_invoke_dbus_method(
33 SUPPLICANT_SERVICE, SUPPLICANT_PATH,
34 SUPPLICANT_INTERFACE, "GetInterface", params);
36 if (message == NULL) {
37 ERR("Failed to get object path");
41 g_variant_get(message, "(o)", &path);
43 g_variant_unref(message);
48 GVariant *netconfig_supplicant_invoke_dbus_method(const char *dest, const char *path,
49 const char *interface_name, const char *method, GVariant *params)
52 GVariant *reply = NULL;
53 GDBusConnection *connection = NULL;
55 INFO("[DBUS Sync] %s %s %s", interface_name, method, path);
57 connection = netdbus_get_connection();
58 if (connection == NULL) {
59 ERR("Failed to get GDBus Connection");
63 reply = g_dbus_connection_call_sync(
71 G_DBUS_CALL_FLAGS_NONE,
72 NETCONFIG_DBUS_REPLY_TIMEOUT,
73 netdbus_get_cancellable(),
78 ERR("g_dbus_connection_call_sync() failed"
79 "error [%d: %s]", error->code, error->message);
82 ERR("g_dbus_connection_call_sync() failed");
91 gboolean netconfig_supplicant_invoke_dbus_method_nonblock(const char *dest,
92 const char *path, const char *interface_name,
93 const char *method, GVariant *params,
94 GAsyncReadyCallback notify_func)
96 GDBusConnection *connection = NULL;
98 INFO("[DBUS Async] %s %s %s", interface_name, method, path);
100 connection = netdbus_get_connection();
101 if (connection == NULL) {
102 DBG("Failed to get GDBusconnection");
106 g_dbus_connection_call(connection,
113 G_DBUS_CALL_FLAGS_NONE,
114 NETCONFIG_DBUS_REPLY_TIMEOUT,
115 netdbus_get_cancellable(),
116 (GAsyncReadyCallback) notify_func,
122 GVariant *netconfig_supplicant_invoke_dbus_interface_property_get(const char *interface,
125 GVariant *params = NULL;
126 GVariant *reply = NULL;
129 ERR("[GDBUS] property_get : %s", key);
131 path = netconfig_wifi_get_supplicant_interface();
133 DBG("Failed to get wpa_supplicant DBus path");
137 params = g_variant_new("(ss)", interface, key);
139 reply = netconfig_supplicant_invoke_dbus_method(SUPPLICANT_SERVICE,
141 DBUS_INTERFACE_PROPERTIES,
147 ERR("netconfig_supplicant_invoke_dbus_method() failed.");
154 gboolean netconfig_supplicant_invoke_dbus_interface_property_set(const char *interface,
155 const char *key, GVariant *var,
156 GAsyncReadyCallback notify_func)
158 gboolean result = FALSE;
159 GVariant *message = NULL;
162 DBG("[DBUS] property_set : %s", key);
164 path = netconfig_wifi_get_supplicant_interface();
166 ERR("Failed to get wpa_supplicant DBus path");
170 message = g_variant_new("(ssv)", interface, key, var);
171 result = netconfig_invoke_dbus_method_nonblock(SUPPLICANT_SERVICE,
173 DBUS_INTERFACE_PROPERTIES,
179 if (result == FALSE) {
180 ERR("dbus_connection_send_with_reply() failed");