return 0;
}
+static void _ws_manage_group_iface_signal(const gchar *group_iface_obj_path,
+ gboolean is_created);
+
static void _ws_process_interface_removed(GDBusConnection *connection,
const gchar *sender, const gchar *object_path, const gchar *interface,
const gchar *signal, GVariant *parameters, gpointer user_data)
g_strlcpy(interface_path, i_path, DBUS_OBJECT_PATH_MAX);
WDP_LOGD("Retrive Added path [%s]", interface_path);
g_strlcpy(g_pd->group_iface_path, interface_path, DBUS_OBJECT_PATH_MAX);
+
dbus_property_get_all(interface_path, g_pd->g_dbus,
SUPPLICANT_IFACE, __ws_interface_property, event);
+ _ws_manage_group_iface_signal(interface_path, TRUE);
+
} else if (g_strcmp0(key, "role") == 0) {
const char *role = NULL;
g_dbus_connection_signal_unsubscribe(g_pd->g_dbus, ws_group_signal_map[i].sub_id);
ws_group_signal_map[i].sub_id = 0;
}
+
+ _ws_manage_group_iface_signal(interface, FALSE);
memset(g_pd->group_iface_path, 0x0, DBUS_OBJECT_PATH_MAX);
_ws_flush();
}
};
+static struct {
+ int sub_id;
+ const char *interface;
+ const char *member;
+ void (*function) (GDBusConnection *connection,
+ const gchar *sender, const gchar *object_path, const gchar *interface,
+ const gchar *signal, GVariant *parameters, gpointer user_data);
+} ws_group_interface_signal_map[] = {
+ {
+ 0,
+ SUPPLICANT_IFACE,
+ "StaAuthorized",
+ _ws_process_sta_authorized
+ },
+ {
+ 0,
+ SUPPLICANT_IFACE,
+ "StaDeauthorized",
+ _ws_process_sta_deauthorized
+ },
+ {
+ 0,
+ NULL,
+ NULL,
+ NULL
+ }
+};
+
static void __register_p2pdevice_signal(GVariant *value, void *user_data)
{
__WDP_LOG_FUNC_ENTER__;
return 0;
}
+static void _ws_manage_group_iface_signal(const gchar *group_iface_obj_path,
+ gboolean is_created)
+{
+ __WDP_LOG_FUNC_ENTER__;
+ GDBusConnection *connection;
+
+ if (!g_pd) {
+ WDP_LOGD("Ignore");
+ __WDP_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (!g_strcmp0(g_pd->iface_path, group_iface_obj_path)) {
+ WDP_LOGD("group iface is p2p iface, ignore");
+ __WDP_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ connection = g_pd->g_dbus;
+ int i;
+ if (is_created) {
+ /* subscribe Interface iface signal */
+ for (i = 0; ws_group_interface_signal_map[i].member != NULL; i++) {
+ ws_group_interface_signal_map[i].sub_id =
+ g_dbus_connection_signal_subscribe(connection,
+ SUPPLICANT_SERVICE, /* bus name */
+ ws_group_interface_signal_map[i].interface, /* interface */
+ ws_group_interface_signal_map[i].member, /* member */
+ group_iface_obj_path, /* object path */
+ NULL, /* arg0 */
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ ws_group_interface_signal_map[i].function,
+ NULL, NULL);
+ WDP_LOGD("Subscribed Interface iface signal [%s]", ws_group_interface_signal_map[i].member);
+ }
+
+ } else {
+ for (i = 0; ws_group_interface_signal_map[i].member != NULL; i++) {
+ g_dbus_connection_signal_unsubscribe(connection, ws_group_interface_signal_map[i].sub_id);
+ ws_group_interface_signal_map[i].sub_id = 0;
+ }
+ }
+ __WDP_LOG_FUNC_EXIT__;
+ return;
+}
+
int wfd_plugin_load(wfd_oem_ops_s **ops)
{
__WDP_LOG_FUNC_ENTER__;
static int __ws_p2p_firmware_start(const char *interface_name)
{
- int rv = 0;
-
- rv = hal_wifi_get_backend();
- if (rv < 0) {
- WDP_LOGD("hal_wifi_get_backend() failed, ret: %d", rv);
- return -1;
+ GError *error = NULL;
+ GDBusConnection *conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (conn == NULL) {
+ WDP_LOGE("Failed to get system bus");
+ return -1;
}
- rv = hal_wifi_p2p_start(interface_name);
- if (rv < 0) {
- WDP_LOGD("hal_wifi_p2p_start() failed, ret: %d", rv);
- return -1;
+ error = NULL;
+ GVariant *params = g_variant_new("(sb)", interface_name, FALSE);
+ GVariant *reply = g_dbus_connection_call_sync(
+ conn,
+ NETCONFIG_SERVICE, /* bus name */
+ NETCONFIG_WIFI_PATH, /* object path */
+ NETCONFIG_WIFI_INTERFACE, /* interface name */
+ "LoadDriver", /* method name */
+ params, /* GVariant *params */
+ NULL, /* reply_type */
+ G_DBUS_CALL_FLAGS_NONE, /* flags */
+ SUPPLICANT_TIMEOUT , /* timeout */
+ NULL, /* cancellable */
+ &error); /* error */
+
+ if (error != NULL) {
+ WDP_LOGE("Error! Failed to call method: [%s]", error->message);
+ g_error_free(error);
+ __WDP_LOG_FUNC_EXIT__;
}
- WDP_LOGI("Successfully loaded p2p device driver");
+ if (reply)
+ g_variant_unref(reply);
+ g_object_unref(conn);
+
return 0;
}