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 char *netconfig_wifi_get_supplicant_p2p_interface(void)
50 GVariant *message = NULL;
53 message = netconfig_supplicant_invoke_dbus_method(
54 SUPPLICANT_SERVICE, SUPPLICANT_PATH,
55 SUPPLICANT_INTERFACE, "GetP2PInterface", NULL);
57 if (message == NULL) {
58 ERR("Failed to get object path");
62 g_variant_get(message, "(o)", &path);
64 g_variant_unref(message);
69 GVariant *netconfig_supplicant_invoke_dbus_method(const char *dest, const char *path,
70 const char *interface_name, const char *method, GVariant *params)
73 GVariant *reply = NULL;
74 GDBusConnection *connection = NULL;
76 INFO("[DBUS Sync] %s %s %s", interface_name, method, path);
78 connection = netdbus_get_connection();
79 if (connection == NULL) {
80 ERR("Failed to get GDBus Connection");
84 reply = g_dbus_connection_call_sync(
92 G_DBUS_CALL_FLAGS_NONE,
93 NETCONFIG_DBUS_REPLY_TIMEOUT,
94 netdbus_get_cancellable(),
99 ERR("g_dbus_connection_call_sync() failed"
100 "error [%d: %s]", error->code, error->message);
103 ERR("g_dbus_connection_call_sync() failed");
112 gboolean netconfig_supplicant_invoke_dbus_method_nonblock(const char *dest,
113 const char *path, const char *interface_name,
114 const char *method, GVariant *params,
115 GAsyncReadyCallback notify_func)
117 GDBusConnection *connection = NULL;
119 INFO("[DBUS Async] %s %s %s", interface_name, method, path);
121 connection = netdbus_get_connection();
122 if (connection == NULL) {
123 DBG("Failed to get GDBusconnection");
127 g_dbus_connection_call(connection,
134 G_DBUS_CALL_FLAGS_NONE,
135 NETCONFIG_DBUS_REPLY_TIMEOUT,
136 netdbus_get_cancellable(),
137 (GAsyncReadyCallback) notify_func,
141 netconfig_gdbus_pending_call_ref();
146 GVariant *netconfig_supplicant_invoke_dbus_interface_property_get(const char *interface,
149 GVariant *params = NULL;
150 GVariant *reply = NULL;
153 ERR("[GDBUS] property_get : %s", key);
155 path = netconfig_wifi_get_supplicant_interface();
157 DBG("Failed to get wpa_supplicant DBus path");
161 params = g_variant_new("(ss)", interface, key);
163 reply = netconfig_supplicant_invoke_dbus_method(SUPPLICANT_SERVICE,
165 DBUS_INTERFACE_PROPERTIES,
171 ERR("netconfig_supplicant_invoke_dbus_method() failed.");
178 gboolean netconfig_supplicant_invoke_dbus_interface_property_set(const char *interface,
179 const char *key, GVariant *var,
180 GAsyncReadyCallback notify_func)
182 gboolean result = FALSE;
183 GVariant *message = NULL;
186 DBG("[DBUS] property_set : %s", key);
188 path = netconfig_wifi_get_supplicant_interface();
190 ERR("Failed to get wpa_supplicant DBus path");
194 message = g_variant_new("(ssv)", interface, key, var);
195 result = netconfig_invoke_dbus_method_nonblock(SUPPLICANT_SERVICE,
197 DBUS_INTERFACE_PROPERTIES,
203 if (result == FALSE) {
204 ERR("dbus_connection_send_with_reply() failed");