[P2PCommonFramework] Added concept of prd plugin for OEM to add product specific... 79/83879/10
authorNishant Chaprana <n.chaprana@samsung.com>
Wed, 10 Aug 2016 07:40:19 +0000 (13:10 +0530)
committerNishant Chaprana <n.chaprana@samsung.com>
Mon, 22 Aug 2016 10:46:34 +0000 (16:16 +0530)
Description: This patch adds concept of prd plugin, so that any OEM can add
product specific code and merge profile specific code easily.
1. oem/wifi-direct-prd.c :-
This file will have product specific code for manager layer.
This will override and define new event handlers.
2. prd-plugin :-
This will have product specific plugin code(event handlers and methods).
This will override profile methods and define new prd specific methods.

Change-Id: Iea5d5c6a888521d516a26d718a7a9845e269c6e6
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
27 files changed:
CMakeLists.txt
include/wifi-direct-dbus.h
include/wifi-direct-event.h
include/wifi-direct-manager.h
oem/wifi-direct-oem.c
oem/wifi-direct-oem.h
packaging/wifi-direct-manager.spec
plugin/wpasupplicant/ctrl_iface_dbus/include/wfd-plugin-wpasupplicant.h
plugin/wpasupplicant/ctrl_iface_dbus/wfd-plugin-wpasupplicant.c
plugin/wpasupplicant/ctrl_iface_sock/include/wfd-plugin-wpasupplicant.h
plugin/wpasupplicant/ctrl_iface_sock/wfd-plugin-wpasupplicant.c
plugin/wpasupplicant/emul/include/wfd-plugin-wpasupplicant.h
plugin/wpasupplicant/emul/wfd-plugin-wpasupplicant-emul.c
prd/include/wifi-direct-prd.h [new file with mode: 0644]
prd/plugin/wpasupplicant/ctrl_iface_dbus/CMakeLists.txt [new file with mode: 0644]
prd/plugin/wpasupplicant/ctrl_iface_dbus/include/wfd-prd-plugin-log.h [new file with mode: 0644]
prd/plugin/wpasupplicant/ctrl_iface_dbus/include/wfd-prd-plugin-wpasupplicant.h [new file with mode: 0644]
prd/plugin/wpasupplicant/ctrl_iface_dbus/wfd-prd-plugin-wpasupplicant.c [new file with mode: 0644]
prd/plugin/wpasupplicant/ctrl_iface_sock/CMakeLists.txt [new file with mode: 0644]
prd/plugin/wpasupplicant/ctrl_iface_sock/include/wfd-prd-plugin-log.h [new file with mode: 0644]
prd/plugin/wpasupplicant/ctrl_iface_sock/include/wfd-prd-plugin-wpasupplicant.h [new file with mode: 0644]
prd/plugin/wpasupplicant/ctrl_iface_sock/wfd-prd-plugin-wpasupplicant.c [new file with mode: 0644]
prd/src/wifi-direct-prd.c [new file with mode: 0644]
src/wifi-direct-dbus.c
src/wifi-direct-event.c
src/wifi-direct-manager.c
wifi-direct-prd-plugin-wpasupplicant.manifest [new file with mode: 0644]

index 8248578..aae3e95 100644 (file)
@@ -7,9 +7,16 @@ FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
 
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
-                                       ${CMAKE_SOURCE_DIR}/oem
-                                       )
+INCLUDE_DIRECTORIES(
+       ${CMAKE_SOURCE_DIR}/include
+       ${CMAKE_SOURCE_DIR}/oem
+       )
+
+IF(TIZEN_ENABLE_PRD)
+INCLUDE_DIRECTORIES(
+       ${CMAKE_SOURCE_DIR}/prd/include
+       )
+ENDIF(TIZEN_ENABLE_PRD)
 
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Werror -fPIE")
 SET(CMAKE_C_FLAGS_DEBUG "O0 -g -fPIE")
@@ -73,6 +80,10 @@ IF(TIZEN_DEBUG_DBUS_VALUE)
        ADD_DEFINITIONS(-DTIZEN_DEBUG_DBUS_VALUE)
 ENDIF(TIZEN_DEBUG_DBUS_VALUE)
 
+IF(TIZEN_ENABLE_PRD)
+       ADD_DEFINITIONS(-DTIZEN_ENABLE_PRD)
+ENDIF(TIZEN_ENABLE_PRD)
+
 SET(SRCS
        ${CMAKE_SOURCE_DIR}/src/wifi-direct-manager.c
        ${CMAKE_SOURCE_DIR}/src/wifi-direct-state.c
@@ -91,6 +102,10 @@ IF(TIZEN_FEATURE_SERVICE_DISCOVERY)
        SET(SRCS ${SRCS} ${CMAKE_SOURCE_DIR}/src/wifi-direct-service.c)
 ENDIF(TIZEN_FEATURE_SERVICE_DISCOVERY)
 
+IF(TIZEN_ENABLE_PRD)
+       SET(SRCS ${SRCS} ${CMAKE_SOURCE_DIR}/prd/src/wifi-direct-prd.c)
+ENDIF(TIZEN_ENABLE_PRD)
+
 ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -ldl)
@@ -124,3 +139,13 @@ IF("${ARCH}" MATCHES "^arm.*|.*86.*")
 ELSE()
        ADD_SUBDIRECTORY(plugin/wpasupplicant/emul)
 ENDIF()
+
+IF(TIZEN_ENABLE_PRD)
+       IF("${ARCH}" MATCHES "^arm.*|.*86.*")
+               IF(CTRL_IFACE_DBUS)
+                       ADD_SUBDIRECTORY(prd/plugin/wpasupplicant/ctrl_iface_dbus)
+               ELSE(CTRL_IFACE_DBUS)
+                       ADD_SUBDIRECTORY(prd/plugin/wpasupplicant/ctrl_iface_sock)
+               ENDIF(CTRL_IFACE_DBUS)
+       ENDIF()
+ENDIF(TIZEN_ENABLE_PRD)
index ead6f7e..4fdcd23 100644 (file)
@@ -79,4 +79,4 @@ GVariant* wfd_manager_dbus_pack_ay(const unsigned char *src, int size);
 }
 #endif
 
-#endif /* __NETCONFIG_NETDBUS_H__ */
+#endif /* __WIFI_DIRECT_DBUS_H__ */
index 4f7f623..ec0292e 100644 (file)
 #ifndef __WIFI_DIRECT_EVENT_H__
 #define __WIFI_DIRECT_EVENT_H__
 
+void wfd_event_deactivated(wfd_oem_event_s *event);
+void wfd_event_peer_found(wfd_oem_event_s *event);
+void wfd_event_peer_disappeared(wfd_oem_event_s *event);
+void wfd_event_discovery_finished(wfd_oem_event_s *event);
+void wfd_event_prov_disc_req(wfd_oem_event_s *event);
+void wfd_event_prov_disc_resp(wfd_oem_event_s *event);
+void wfd_event_prov_disc_fail(wfd_oem_event_s *event);
+void wfd_event_go_neg_req(wfd_oem_event_s *event);
+void wfd_event_go_neg_fail(wfd_oem_event_s *event);
+void wfd_event_go_neg_done(wfd_oem_event_s *event);
+void wfd_event_wps_fail(wfd_oem_event_s *event);
+void wfd_event_wps_done(wfd_oem_event_s *event);
+void wfd_event_key_neg_fail(wfd_oem_event_s *event);
+void wfd_event_key_neg_done(wfd_oem_event_s *event);
+void wfd_event_conn_fail(wfd_oem_event_s *event);
+void wfd_event_conn_done(wfd_oem_event_s *event);
+void wfd_event_group_created(wfd_oem_event_s *event);
+void wfd_event_group_destroyed(wfd_oem_event_s *event);
+void wfd_event_invitation_req(wfd_oem_event_s *event);
+void wfd_event_invitation_res(wfd_oem_event_s *event);
+void wfd_event_sta_connected(wfd_oem_event_s *event);
+void wfd_event_sta_disconnected(wfd_oem_event_s *event);
+void wfd_event_terminating(wfd_oem_event_s *event);
+void wfd_event_group_formation_failure(wfd_oem_event_s *event);
+void wfd_event_invitation_accepted(wfd_oem_event_s *event);
+void wfd_event_serv_disc_resp(wfd_oem_event_s *event);
+void wfd_event_serv_disc_started(wfd_oem_event_s *event);
+void wfd_event_asp_serv_resp(wfd_oem_event_s *event);
+void wfd_event_asp_prov_start(wfd_oem_event_s *event);
+void wfd_event_asp_prov_done(wfd_oem_event_s *event);
 
-
-int wfd_process_event(void *user_data, void *data);
+void wfd_event_init(wfd_oem_event_cbs_s *event_cb);
 
 #endif /* __WIFI_DIRECT_EVENT_H__ */
index 3964f1f..04abeb3 100644 (file)
@@ -202,6 +202,10 @@ typedef struct {
 
        void *oem_ops;
        void *plugin_handle;
+#if defined TIZEN_ENABLE_PRD
+       void *prd_plugin_handle;
+#endif /* TIZEN_ENABLE_PRD */
+
        int session_timer;
        gboolean auto_group_remove_enable;
 } wfd_manager_s;
index 2c0d656..6ac9be1 100644 (file)
 #include <glib.h>
 
 #include "wifi-direct-oem.h"
+#include "wifi-direct-event.h"
 
-int wfd_oem_init(wfd_oem_ops_s *ops, wfd_oem_event_cb event_callback, void *user_data)
+#if defined TIZEN_ENABLE_PRD
+#include "wifi-direct-prd.h"
+
+wfd_oem_prd_event_cbs_s g_prd_event_cbs;
+#endif /* TIZEN_ENABLE_PRD */
+
+wfd_oem_event_cbs_s g_event_cbs;
+
+int wfd_oem_init(wfd_oem_ops_s *ops)
 {
        if (!ops || !ops->init)
                return -1;
 
-       return ops->init(event_callback, user_data);
+       wfd_event_init(&g_event_cbs);
+
+       return ops->init(&g_event_cbs);
 }
 
 #if 0
@@ -448,3 +459,23 @@ int wfd_oem_asp_prov_disc_req(wfd_oem_ops_s *ops, wfd_oem_asp_prov_s *params)
        return ops->asp_prov_disc_req(params);
 }
 #endif /* TIZEN_FEATURE_ASP */
+
+#if defined TIZEN_ENABLE_PRD
+int wfd_oem_prd_init(wfd_oem_ops_s *ops)
+{
+       wfd_oem_prd_ops_s *prd_ops;
+
+       if (!ops)
+               return -1;
+
+       prd_ops = ops->extra_data;
+
+       if (!prd_ops || !prd_ops->prd_init)
+               return -1;
+
+       g_event_cbs.extra_data = &g_prd_event_cbs;
+       wfd_prd_event_init(&g_event_cbs);
+
+       return prd_ops->prd_init(&g_event_cbs);
+}
+#endif /* TIZEN_ENABLE_PRD */
index 95cbecb..a9f428f 100644 (file)
 #define SUPPL_PLUGIN_PATH "/usr/lib/wifi-direct-plugin-wpasupplicant.so"
 #define SUPPL_PLUGIN_64BIT_PATH "/usr/lib64/wifi-direct-plugin-wpasupplicant.so"
 
+#if defined TIZEN_ENABLE_PRD
+#define SUPPL_PRD_PLUGIN_PATH "/usr/lib/wifi-direct-prd-plugin-wpasupplicant.so"
+#define SUPPL_PRD_PLUGIN_64BIT_PATH "/usr/lib64/wifi-direct-prd-plugin-wpasupplicant.so"
+#endif /* TIZEN_ENABLE_PRD */
 
 #define OEM_MACSTR_LEN 18
 #define OEM_MACADDR_LEN 6
@@ -540,13 +544,61 @@ typedef struct {
        unsigned char p2p_client_list[OEM_MACADDR_LEN][OEM_MAX_PEER_NUM];
 } wfd_oem_persistent_group_s;
 
-typedef int (*wfd_oem_event_cb) (void *user_data, void *event);
+typedef struct {
+       void (*deactivated_cb) (wfd_oem_event_s *event);
+       void (*peer_found_cb) (wfd_oem_event_s *event);
+       void (*peer_disappeared_cb) (wfd_oem_event_s *event);
+       void (*discovery_finished_cb) (wfd_oem_event_s *event);
+
+       void (*prov_disc_req_cb) (wfd_oem_event_s *event);
+       void (*prov_disc_resp_cb) (wfd_oem_event_s *event);
+       void (*prov_disc_fail_cb) (wfd_oem_event_s *event);
+
+       void (*go_neg_req_cb) (wfd_oem_event_s *event);
+       void (*go_neg_fail_cb) (wfd_oem_event_s *event);
+       void (*go_neg_done_cb) (wfd_oem_event_s *event);
+
+       void (*wps_fail_cb) (wfd_oem_event_s *event);
+       void (*wps_done_cb) (wfd_oem_event_s *event);
+       void (*key_neg_fail_cb) (wfd_oem_event_s *event);
+       void (*key_neg_done_cb) (wfd_oem_event_s *event);
+
+       void (*conn_fail_cb) (wfd_oem_event_s *event);
+       void (*conn_done_cb) (wfd_oem_event_s *event);
+
+       void (*group_created_cb) (wfd_oem_event_s *event);
+       void (*group_destroyed_cb) (wfd_oem_event_s *event);
+
+       void (*invitation_req_cb) (wfd_oem_event_s *event);
+       void (*invitation_resp_cb) (wfd_oem_event_s *event);
+       void (*sta_connected_cb) (wfd_oem_event_s *event);
+       void (*sta_disconnected_cb) (wfd_oem_event_s *event);
 
-typedef struct _wfd_oem_ops_s {
-       int (*init) (wfd_oem_event_cb event_callback, void *user_data);
+       void (*terminating_cb) (wfd_oem_event_s *event);
+
+#ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
+       void (*serv_disc_resp_cb) (wfd_oem_event_s *event);
+       void (*serv_disc_started_cb) (wfd_oem_event_s *event);
+#endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
+
+       void (*group_formation_failure_cb) (wfd_oem_event_s *event);
+       void (*invitation_accepted_cb) (wfd_oem_event_s *event);
+
+#if defined(TIZEN_FEATURE_ASP)
+       void (*asp_serv_resp_cb) (wfd_oem_event_s *event);
+       void (*asp_prov_start_cb) (wfd_oem_event_s *event);
+       void (*asp_prov_done_cb) (wfd_oem_event_s *event);
+#endif /* TIZEN_FEATURE_ASP */
+
+       void *extra_data;
+} wfd_oem_event_cbs_s;
+
+typedef struct {
+       int (*init) (wfd_oem_event_cbs_s *event_cbs);
        int (*deinit) (void);
        int (*activate) (int concurrent);
        int (*deactivate) (int concurrent);
+
        int (*start_scan) (wfd_oem_scan_param_s *param);
        int (*stop_scan) (void);
        int (*get_visibility) (int *visibility);
@@ -611,12 +663,15 @@ typedef struct _wfd_oem_ops_s {
        int (*cancel_seek_service)(wfd_oem_asp_service_s *service);
        int (*asp_prov_disc_req)(wfd_oem_asp_prov_s *params);
 #endif /* TIZEN_FEATURE_ASP */
+
+       void *extra_data;
 } wfd_oem_ops_s;
 
-int wfd_oem_init(wfd_oem_ops_s *ops, wfd_oem_event_cb event_callback, void *user_data);
+int wfd_oem_init(wfd_oem_ops_s *ops);
 int wfd_oem_destroy(wfd_oem_ops_s *ops);
 int wfd_oem_activate(wfd_oem_ops_s *ops, int concurrent);
 int wfd_oem_deactivate(wfd_oem_ops_s *ops, int concurrent);
+
 int wfd_oem_start_scan(wfd_oem_ops_s *ops, wfd_oem_scan_param_s *param);
 int wfd_oem_stop_scan(wfd_oem_ops_s *ops);
 int wfd_oem_get_visibility(wfd_oem_ops_s *ops, int *visibility);
@@ -677,4 +732,16 @@ int wfd_oem_cancel_seek_service(wfd_oem_ops_s *ops, wfd_oem_asp_service_s *servi
 int wfd_oem_asp_prov_disc_req(wfd_oem_ops_s *ops, wfd_oem_asp_prov_s *params);
 #endif /* TIZEN_FEATURE_ASP */
 
+#if defined TIZEN_ENABLE_PRD
+typedef struct {
+       void (*prd_example_cb) (wfd_oem_event_s *event);
+} wfd_oem_prd_event_cbs_s;
+
+typedef struct {
+       int (*prd_init) (wfd_oem_event_cbs_s *event_cbs);
+} wfd_oem_prd_ops_s;
+
+int wfd_oem_prd_init(wfd_oem_ops_s *ops);
+#endif /* TIZEN_ENABLE_PRD */
+
 #endif /* __WIFI_DIRECT_OEM_H__ */
index 219586e..fefb73a 100644 (file)
@@ -40,6 +40,13 @@ Requires:   %{name} = %{version}-%{release}
 %description -n wifi-direct-plugin-wpasupplicant
 Wi-Fi direct manager plugin to abstract wpa_supplicant
 
+#%package -n wifi-direct-prd-plugin-wpasupplicant
+#Summary:    Wifi direct prd plugin for wpa supplicant
+#Group:      Network & Connectivity/Wireless
+#Requires:   %{name} = %{version}-%{release}
+
+#%description -n wifi-direct-prd-plugin-wpasupplicant
+#Wi-Fi direct manager prd plugin to abstract wpa_supplicant
 
 %prep
 %setup -q
@@ -70,6 +77,7 @@ export ARCH=i586
 %endif
 
 cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DARCHITECTURE=$ARCH \
+       -DTIZEN_ENABLE_PRD=0 \
 %if 0%{?model_build_feature_wlan_concurrent_mode}
        -DTIZEN_WLAN_CONCURRENT_ENABLE=1 \
 %endif
@@ -180,3 +188,9 @@ chmod 666 %{TZ_SYS_VAR}/lib/misc/dhcpd.leases
 %license LICENSE
 %defattr(-,root,root,-)
 %{_libdir}/wifi-direct-plugin-wpasupplicant.so
+
+#%files -n wifi-direct-prd-plugin-wpasupplicant
+#%manifest wifi-direct-prd-plugin-wpasupplicant.manifest
+#%license LICENSE
+#%defattr(-,root,root,-)
+#%{_libdir}/wifi-direct-prd-plugin-wpasupplicant.so
index d9fcd90..c3c3437 100644 (file)
@@ -392,12 +392,11 @@ typedef struct {
        char iface_path[150];
        char group_iface_path[150];
        unsigned char local_dev_addr[WS_MACADDR_LEN];
-       wfd_oem_event_cb callback;
-       void *user_data;
+       wfd_oem_event_cbs_s *callback;
 } ws_dbus_plugin_data_s;
 
-int ws_init(wfd_oem_event_cb callback, void *user_data);
-int ws_deinit();
+int ws_init(wfd_oem_event_cbs_s *event_cbs);
+int ws_deinit(void);
 int ws_activate(int concurrent);
 int ws_deactivate(int concurrent);
 int ws_start_scan(wfd_oem_scan_param_s *param);
index a24f61c..03c2133 100644 (file)
@@ -150,23 +150,17 @@ static wfd_oem_ops_s supplicant_ops = {
        .cancel_seek_service = ws_cancel_seek_service,
        .asp_prov_disc_req = ws_asp_prov_disc_req,
 #endif /* TIZEN_FEATURE_ASP */
-       };
 
-static ws_dbus_plugin_data_s *g_pd;
-
-#define G_PD_CALLBACK(user_data, event)\
-       do {\
-               if (g_pd->callback)\
-                       g_pd->callback(user_data, event);\
-       } while (0)
+       .extra_data = NULL
+};
 
+static ws_dbus_plugin_data_s *g_pd;
 static int is_peer_joined_notified = 0;
 static int is_peer_disconnected_notified = 0;
 
 #ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
 static GList *service_list;
 #endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
-
 static GList *seek_list;
 
 static int __ws_txt_to_mac(unsigned char *txt, unsigned char *mac)
@@ -550,7 +544,8 @@ static void _ws_process_interface_removed(GDBusConnection *connection,
 
                memset(&event, 0x0, sizeof(wfd_oem_event_s));
                event.event_id = WFD_OEM_EVENT_DEACTIVATED;
-               G_PD_CALLBACK(g_pd->user_data, &event);
+               if (g_pd->callback && g_pd->callback->deactivated)
+                       g_pd->callback->deactivated(&event);
 
                memset(g_pd->iface_path, 0x0, DBUS_OBJECT_PATH_MAX);
        }
@@ -957,7 +952,9 @@ static void _ws_process_peer_joined(GDBusConnection *connection,
        dbus_property_get_all(peer_path, g_pd->g_dbus, SUPPLICANT_P2P_PEER,
                        __ws_peer_property, event.edata);
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->sta_connected_cb)
+               g_pd->callback->sta_connected_cb(&event);
+
        is_peer_joined_notified = 1;
 
        g_free(edata);
@@ -987,7 +984,9 @@ static void _ws_process_peer_disconnected(GDBusConnection *connection,
 
        __ws_path_to_addr(peer_path, event.dev_addr, parameters);
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->sta_disconnected_cb)
+               g_pd->callback->sta_disconnected_cb(&event);
+
        is_peer_disconnected_notified = 1;
        __WDP_LOG_FUNC_EXIT__;
 }
@@ -1807,7 +1806,9 @@ static void _ws_process_device_found_properties(GDBusConnection *connection,
                ws_get_advertise_service(peer_path, (GList **)&(event.asp_services));
 #endif /* TIZEN_FEATURE_ASP */
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->peer_found_cb)
+               g_pd->callback->peer_found_cb(&event);
+
 #if defined(TIZEN_FEATURE_ASP)
        if (event.asp_services != NULL) {
                GList *l;
@@ -1848,7 +1849,9 @@ static void _ws_process_device_lost(GDBusConnection *connection,
 
        __ws_path_to_addr(peer_path, event.dev_addr, parameters);
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->peer_disappeared_cb)
+               g_pd->callback->peer_disappeared_cb(&event);
+
 
        __WDP_LOG_FUNC_EXIT__;
 }
@@ -1873,7 +1876,8 @@ static void _ws_process_find_stoppped(GDBusConnection *connection,
        event.edata_type = WFD_OEM_EDATA_TYPE_NONE;
        event.event_id = WFD_OEM_EVENT_DISCOVERY_FINISHED;
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->discovery_finished_cb)
+               g_pd->callback->discovery_finished_cb(&event);
 
        __WDP_LOG_FUNC_EXIT__;
 }
@@ -1929,7 +1933,9 @@ static void _ws_process_prov_disc_req_display_pin(GDBusConnection *connection,
        dbus_property_get_all(peer_path, g_pd->g_dbus, SUPPLICANT_P2P_PEER,
                        __ws_peer_property, event.edata);
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->prov_disc_req_cb)
+               g_pd->callback->prov_disc_req_cb(&event);
+
        g_free(event.edata);
 
        __WDP_LOG_FUNC_EXIT__;
@@ -1986,7 +1992,9 @@ static void _ws_process_prov_disc_resp_display_pin(GDBusConnection *connection,
        dbus_property_get_all(peer_path, g_pd->g_dbus, SUPPLICANT_P2P_PEER,
                        __ws_peer_property, event.edata);
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->prov_disc_resp_cb)
+               g_pd->callback->prov_disc_resp_cb(&event);
+
        g_free(event.edata);
 
        __WDP_LOG_FUNC_EXIT__;
@@ -2028,7 +2036,9 @@ static void _ws_process_prov_disc_req_enter_pin(GDBusConnection *connection,
        dbus_property_get_all(peer_path, g_pd->g_dbus, SUPPLICANT_P2P_PEER,
                        __ws_peer_property, event.edata);
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->prov_disc_req_cb)
+               g_pd->callback->prov_disc_req_cb(&event);
+
        g_free(event.edata);
 
        __WDP_LOG_FUNC_EXIT__;
@@ -2070,7 +2080,9 @@ static void _ws_process_prov_disc_resp_enter_pin(GDBusConnection *connection,
        dbus_property_get_all(peer_path, g_pd->g_dbus, SUPPLICANT_P2P_PEER,
                        __ws_peer_property, event.edata);
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->prov_disc_resp_cb)
+               g_pd->callback->prov_disc_resp_cb(&event);
+
        g_free(event.edata);
 
        __WDP_LOG_FUNC_EXIT__;
@@ -2112,7 +2124,9 @@ static void _ws_process_prov_disc_pbc_req(GDBusConnection *connection,
        dbus_property_get_all(peer_path, g_pd->g_dbus, SUPPLICANT_P2P_PEER,
                        __ws_peer_property, event.edata);
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->prov_disc_req_cb)
+               g_pd->callback->prov_disc_req_cb(&event);
+
        g_free(event.edata);
 
        __WDP_LOG_FUNC_EXIT__;
@@ -2154,7 +2168,9 @@ static void _ws_process_prov_disc_pbc_resp(GDBusConnection *connection,
        dbus_property_get_all(peer_path, g_pd->g_dbus, SUPPLICANT_P2P_PEER,
                        __ws_peer_property, event.edata);
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->prov_disc_resp_cb)
+               g_pd->callback->prov_disc_resp_cb(&event);
+
        g_free(event.edata);
 
        __WDP_LOG_FUNC_EXIT__;
@@ -2201,7 +2217,8 @@ static void _ws_process_prov_disc_failure(GDBusConnection *connection,
                WDP_LOGE("No Properties");
        }
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->prov_disc_fail_cb)
+               g_pd->callback->prov_disc_fail_cb(&event);
 
        if (event.edata_type == WFD_OEM_EDATA_TYPE_ASP_PROV)
                g_free(edata->session_information);
@@ -2246,7 +2263,8 @@ static void _ws_process_prov_disc_failure(GDBusConnection *connection,
        __ws_txt_to_mac(peer_dev, event.dev_addr);
        WDP_LOGE("peer mac [" MACSTR "]", MAC2STR(event.dev_addr));
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->prov_disc_fail_cb)
+               g_pd->callback->prov_disc_fail_cb(&event);
 
        __WDP_LOG_FUNC_EXIT__;
 }
@@ -2294,7 +2312,9 @@ static void _ws_process_group_started(GDBusConnection *connection,
                WDP_LOGE("No properties");
        }
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->group_created_cb)
+               g_pd->callback->group_created_cb(&event);
+
        g_free(event.edata);
 
        __WDP_LOG_FUNC_EXIT__;
@@ -2341,7 +2361,9 @@ static void _ws_process_go_neg_success(GDBusConnection *connection,
                WDP_LOGE("No properties");
        }
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->go_neg_done_cb)
+               g_pd->callback->go_neg_done_cb(&event);
+
        g_free(edata);
 
        __WDP_LOG_FUNC_EXIT__;
@@ -2388,7 +2410,9 @@ static void _ws_process_go_neg_failure(GDBusConnection *connection,
                WDP_LOGE("No properties");
        }
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->go_neg_fail_cb)
+               g_pd->callback->go_neg_fail_cb(&event);
+
        g_free(event.edata);
 
        __WDP_LOG_FUNC_EXIT__;
@@ -2455,7 +2479,9 @@ static void _ws_process_go_neg_request(GDBusConnection *connection,
        dbus_property_get_all(peer_path, g_pd->g_dbus, SUPPLICANT_P2P_PEER,
                        __ws_peer_property, event.edata);
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->go_neg_req_cb)
+               g_pd->callback->go_neg_req_cb(&event);
+
        g_free(event.edata);
 
        __WDP_LOG_FUNC_EXIT__;
@@ -2502,7 +2528,9 @@ static void _ws_process_invitation_received(GDBusConnection *connection,
        }
        memcpy(&(event.dev_addr), edata->sa, OEM_MACADDR_LEN);
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->invitation_req_cb)
+               g_pd->callback->invitation_req_cb(&event);
+
        g_free(event.edata);
 
        __WDP_LOG_FUNC_EXIT__;
@@ -2556,7 +2584,8 @@ static void _ws_process_group_finished(GDBusConnection *connection,
        memset(g_pd->group_iface_path, 0x0, DBUS_OBJECT_PATH_MAX);
        _ws_flush();
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->group_destroyed_cb)
+               g_pd->callback->group_destroyed_cb(&event);
 
        __WDP_LOG_FUNC_EXIT__;
 }
@@ -2593,7 +2622,8 @@ static void _ws_process_service_discovery_response(GDBusConnection *connection,
                WDP_LOGE("No Properties");
        }
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->serv_disc_resp_cb)
+               g_pd->callback->serv_disc_resp_cb(&event);
 
        if (event.edata_type == WFD_OEM_EDATA_TYPE_NEW_SERVICE)
                g_list_free((GList*) event.edata);
@@ -2655,7 +2685,8 @@ GLIST_ITER_START(seek_list, tmp)
 GLIST_ITER_END()
 
        if (tmp != NULL && tmp->service_info != NULL)
-               g_pd->callback(g_pd->user_data, &event);
+               if (g_pd->callback->asp_serv_resp_cb)
+                       g_pd->callback->asp_serv_resp_cb(&event);
        else
                WDP_LOGD("service info is not required, don't notify to user");
 
@@ -2744,7 +2775,8 @@ static void _ws_process_wps_failed(GDBusConnection *connection,
                g_variant_iter_free(iter);
        }
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->wps_fail_cb)
+               g_pd->callback->wps_fail_cb(&event);
 
        __WDP_LOG_FUNC_EXIT__;
 }
@@ -2769,7 +2801,8 @@ static void _ws_process_group_formation_failure(GDBusConnection *connection,
        event.event_id = WFD_OEM_EVENT_GROUP_FORMATION_FAILURE;
        event.edata_type = WFD_OEM_EDATA_TYPE_NONE;
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->group_formation_failure_cb)
+               g_pd->callback->group_formation_failure_cb(&event);
 
        __WDP_LOG_FUNC_EXIT__;
 }
@@ -2813,7 +2846,9 @@ static void _ws_process_invitation_accepted(GDBusConnection *connection,
                }
        }
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->invitation_accepted_cb)
+               g_pd->callback->invitation_accepted_cb(&event);
+
        __WDP_LOG_FUNC_EXIT__;
 }
 
@@ -2858,7 +2893,8 @@ static void _ws_process_asp_provision_start(GDBusConnection *connection,
                WDP_LOGE("No Properties");
        }
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->asp_prov_start_cb)
+               g_pd->callback->asp_prov_start_cb(&event);
 
        if (event.edata_type == WFD_OEM_EDATA_TYPE_ASP_PROV)
                g_free(edata->session_information);
@@ -2907,7 +2943,9 @@ static void _ws_process_asp_provision_done(GDBusConnection *connection,
                WDP_LOGE("No Properties");
        }
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->asp_prov_done_cb)
+               g_pd->callback->asp_prov_done_cb(&event);
+
        g_free(edata);
 
        __WDP_LOG_FUNC_EXIT__;
@@ -3119,7 +3157,9 @@ static void _ws_process_sta_authorized(GDBusConnection *connection,
        event.event_id = WFD_OEM_EVENT_STA_CONNECTED;
        event.edata_type = WFD_OEM_EDATA_TYPE_NONE;
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->sta_connected_cb)
+               g_pd->callback->sta_connected_cb(&event);
+
        __WDP_LOG_FUNC_EXIT__;
 }
 
@@ -3152,7 +3192,9 @@ static void _ws_process_sta_deauthorized(GDBusConnection *connection,
        event.event_id = WFD_OEM_EVENT_STA_DISCONNECTED;
        event.edata_type = WFD_OEM_EDATA_TYPE_NONE;
 
-       g_pd->callback(g_pd->user_data, &event);
+       if (g_pd->callback->sta_disconnected_cb)
+               g_pd->callback->sta_disconnected_cb(&event);
+
        __WDP_LOG_FUNC_EXIT__;
 }
 
@@ -3530,10 +3572,15 @@ static int __ws_check_net_interface(char* if_name)
 }
 #endif
 
-int ws_init(wfd_oem_event_cb callback, void *user_data)
+int ws_init(wfd_oem_event_cbs_s *event_cbs)
 {
        __WDP_LOG_FUNC_ENTER__;
 
+       if (event_cbs == NULL) {
+               __WDP_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
        if (g_pd)
                _ws_reset_plugin(g_pd);
 
@@ -3544,15 +3591,14 @@ int ws_init(wfd_oem_event_cb callback, void *user_data)
                return -1;
        }
 
-       g_pd->callback = callback;
-       g_pd->user_data = user_data;
+       g_pd->callback = event_cbs;
        g_pd->initialized = TRUE;
 
        __WDP_LOG_FUNC_EXIT__;
        return 0;
 }
 
-int ws_deinit()
+int ws_deinit(void)
 {
        __WDP_LOG_FUNC_ENTER__;
 
index a5c5e20..8a30697 100644 (file)
@@ -520,11 +520,10 @@ typedef struct {
        ws_sock_data_s *common;
        ws_sock_data_s *group;
        unsigned char local_dev_addr[WS_MACADDR_LEN];
-       wfd_oem_event_cb callback;
-       void *user_data;
+       wfd_oem_event_cbs_s *callback;
 } ws_plugin_data_s;
 
-int ws_init(wfd_oem_event_cb callback, void *user_data);
+int ws_init(wfd_oem_event_cbs_s *event_cbs);
 int ws_deinit();
 int ws_activate(int concurrent);
 int ws_deactivate(int concurrent);
index 46f7063..22736bd 100644 (file)
@@ -2186,7 +2186,6 @@ static gboolean ws_event_handler(GIOChannel *source,
        char msg[1024] = {0, };
        char *pos = NULL;
        char *param = NULL;
-       int event_id = -1;
        wfd_oem_event_s event;
        int res = 0;
 
@@ -2224,35 +2223,49 @@ static gboolean ws_event_handler(GIOChannel *source,
        /* Converting WS event to OEM event */
        switch (event.event_id) {
        case WS_EVENT_DEVICE_FOUND:
-               event_id = WFD_OEM_EVENT_PEER_FOUND;
+               event.event_id = WFD_OEM_EVENT_PEER_FOUND;
+               if (!g_pd || !g_pd->callback || !g_pd->callback->peer_found_cb)
+                       g_pd->callback->peer_found_cb(&event);
                break;
        case WS_EVENT_DEVICE_LOST:
-               event_id = WFD_OEM_EVENT_PEER_DISAPPEARED;
+               event.event_id = WFD_OEM_EVENT_PEER_DISAPPEARED;
+               if (!g_pd || !g_pd->callback || !g_pd->callback->peer_disappeared_cb)
+                       g_pd->callback->peer_disappeared_cb(&event);
                break;
        case WS_EVENT_FIND_STOPED:
-               event_id = WFD_OEM_EVENT_DISCOVERY_FINISHED;
+               event.event_id = WFD_OEM_EVENT_DISCOVERY_FINISHED;
+               if (!g_pd || !g_pd->callback || !g_pd->callback->discovery_finished_cb)
+                       g_pd->callback->discovery_finished_cb(&event);
                break;
        case WS_EVENT_PROV_DISC_PBC_REQ:
-               event_id = WFD_OEM_EVENT_PROV_DISC_REQ;
+               event.event_id = WFD_OEM_EVENT_PROV_DISC_REQ;
+               if (!g_pd || !g_pd->callback || !g_pd->callback->prov_disc_req_cb)
+                       g_pd->callback->prov_disc_req_cb(&event);
                break;
        case WS_EVENT_PROV_DISC_PBC_RESP:
                if (!memcmp(event.dev_addr, g_pd_out, OEM_MACADDR_LEN)) {
-                       event_id = WFD_OEM_EVENT_PROV_DISC_RESP;
+                       event.event_id = WFD_OEM_EVENT_PROV_DISC_RESP;
                        memset(g_pd_out, 0x0, OEM_MACADDR_LEN);
                } else {
                        WDP_LOGE("Invalid peer mac address[" MACSTR "]", MAC2STR(event.dev_addr));
                        goto done;
                }
+               if (!g_pd || !g_pd->callback || !g_pd->callback->prov_disc_resp_cb)
+                       g_pd->callback->prov_disc_resp_cb(&event);
                break;
        case WS_EVENT_PROV_DISC_SHOW_PIN:
        case WS_EVENT_PROV_DISC_ENTER_PIN:
                if (!memcmp(event.dev_addr, g_pd_out, OEM_MACADDR_LEN)) {
-                       event_id = WFD_OEM_EVENT_PROV_DISC_RESP;
+                       event.event_id = WFD_OEM_EVENT_PROV_DISC_RESP;
                        memset(g_pd_out, 0x0, OEM_MACADDR_LEN);
                        WDP_LOGD("Peer mac address verified");
+                       if (!g_pd || !g_pd->callback || !g_pd->callback->prov_disc_resp_cb)
+                               g_pd->callback->prov_disc_resp_cb(&event);
                } else if (!memcmp(g_pd_out, null_mac, OEM_MACADDR_LEN)) {
-                       event_id = WFD_OEM_EVENT_PROV_DISC_REQ;
+                       event.event_id = WFD_OEM_EVENT_PROV_DISC_REQ;
                        WDP_LOGD("      PD request from peer[" MACSTR "]", MAC2STR(event.dev_addr));
+                       if (!g_pd || !g_pd->callback || !g_pd->callback->prov_disc_req_cb)
+                               g_pd->callback->prov_disc_req_cb(&event);
                } else {
                        WDP_LOGE("Invalid peer mac address[" MACSTR "]", MAC2STR(event.dev_addr));
                        goto done;
@@ -2260,36 +2273,54 @@ static gboolean ws_event_handler(GIOChannel *source,
 
                break;
        case WS_EVENT_PROV_DISC_FAILURE:
-               event_id = WFD_OEM_EVENT_PROV_DISC_FAIL;
+               event.event_id = WFD_OEM_EVENT_PROV_DISC_FAIL;
                if (!memcmp(event.dev_addr, g_pd_out, OEM_MACADDR_LEN)) {
                        memset(g_pd_out, 0x0, OEM_MACADDR_LEN);
                        WDP_LOGD("Peer mac address verified, but PD failed");
                }
+               if (!g_pd || !g_pd->callback || !g_pd->callback->prov_disc_fail_cb)
+                       g_pd->callback->prov_disc_fail_cb(&event);
                break;
        case WS_EVENT_GO_NEG_REQUEST:
-               event_id = WFD_OEM_EVENT_GO_NEG_REQ;
+               event.event_id = WFD_OEM_EVENT_GO_NEG_REQ;
+               if (!g_pd || !g_pd->callback || !g_pd->callback->go_neg_req_cb)
+                       g_pd->callback->go_neg_req_cb(&event);
                break;
        case WS_EVENT_GO_NEG_FAILURE:
-               event_id = WFD_OEM_EVENT_GO_NEG_FAIL;
+               event.event_id = WFD_OEM_EVENT_GO_NEG_FAIL;
+               if (!g_pd || !g_pd->callback || !g_pd->callback->go_neg_fail_cb)
+                       g_pd->callback->go_neg_fail_cb(&event);
                break;
        case WS_EVENT_GO_NEG_SUCCESS:
-               event_id = WFD_OEM_EVENT_GO_NEG_DONE;
+               event.event_id = WFD_OEM_EVENT_GO_NEG_DONE;
+               if (!g_pd || !g_pd->callback || !g_pd->callback->go_neg_done_cb)
+                       g_pd->callback->go_neg_done_cb(&event);
                break;
        case WS_EVENT_WPS_FAIL:
+               event.event_id = WFD_OEM_EVENT_WPS_FAIL;
+               if (!g_pd || !g_pd->callback || !g_pd->callback->wps_fail_cb)
+                       g_pd->callback->wps_fail_cb(&event);
+               break;
        case WS_EVENT_GROUP_FORMATION_FAILURE:
-               event_id = WFD_OEM_EVENT_WPS_FAIL;
+               event.event_id = WFD_OEM_EVENT_WPS_FAIL;
+               if (!g_pd || !g_pd->callback || !g_pd->callback->group_formation_failure_cb)
+                       g_pd->callback->group_formation_failure_cb(&event);
                break;
        case WS_EVENT_WPS_SUCCESS:
        case WS_EVENT_WPS_REG_SUCCESS:
        case WS_EVENT_GROUP_FORMATION_SUCCESS:
-               event_id = WFD_OEM_EVENT_WPS_DONE;
+               event.event_id = WFD_OEM_EVENT_WPS_DONE;
                /* TODO: connect to supplicant via group interface */
+               if (!g_pd || !g_pd->callback || !g_pd->callback->wps_done_cb)
+                       g_pd->callback->wps_done_cb(&event);
                break;
        case WS_EVENT_STA_CONNECTED:
-               event_id = WFD_OEM_EVENT_STA_CONNECTED;
+               event.event_id = WFD_OEM_EVENT_STA_CONNECTED;
+               if (!g_pd || !g_pd->callback || !g_pd->callback->sta_connected_cb)
+                       g_pd->callback->sta_connected_cb(&event);
                break;
        case WS_EVENT_GROUP_STARTED:
-               event_id = WFD_OEM_EVENT_GROUP_CREATED;
+               event.event_id = WFD_OEM_EVENT_GROUP_CREATED;
                if (!g_strcmp0(GROUP_IFACE_NAME, COMMON_IFACE_NAME)) {
                        g_pd->group = g_pd->common;
                } else {
@@ -2300,9 +2331,11 @@ static gboolean ws_event_handler(GIOChannel *source,
                                /* goto done; */
                        }
                }
+               if (!g_pd || !g_pd->callback || !g_pd->callback->group_created_cb)
+                       g_pd->callback->group_created_cb(&event);
                break;
        case WS_EVENT_GROUP_REMOVED:
-               event_id = WFD_OEM_EVENT_GROUP_DESTROYED;
+               event.event_id = WFD_OEM_EVENT_GROUP_DESTROYED;
                if (!g_strcmp0(GROUP_IFACE_NAME, COMMON_IFACE_NAME)) {
                        g_pd->group = NULL;
                        _ws_flush();
@@ -2318,22 +2351,34 @@ static gboolean ws_event_handler(GIOChannel *source,
                                _ws_flush();
                        }
                }
+               if (!g_pd || !g_pd->callback || !g_pd->callback->group_destroyed_cb)
+                       g_pd->callback->group_destroyed_cb(&event);
                break;
        case WS_EVENT_INVITATION_RECEIVED:
-               event_id = WFD_OEM_EVENT_INVITATION_REQ;
+               event.event_id = WFD_OEM_EVENT_INVITATION_REQ;
+               if (!g_pd || !g_pd->callback || !g_pd->callback->invitation_req_cb)
+                       g_pd->callback->invitation_req_cb(&event);
                break;
        case WS_EVENT_INVITATION_RESULT:
-               event_id = WFD_OEM_EVENT_INVITATION_RES;
+               event.event_id = WFD_OEM_EVENT_INVITATION_RES;
+               if (!g_pd || !g_pd->callback || !g_pd->callback->invitation_resp_cb)
+                       g_pd->callback->invitation_resp_cb(&event);
                break;
        case WS_EVENT_STA_DISCONNECTED:
-               event_id = WFD_OEM_EVENT_STA_DISCONNECTED;
+               event.event_id = WFD_OEM_EVENT_STA_DISCONNECTED;
+               if (!g_pd || !g_pd->callback || !g_pd->callback->sta_disconnected_cb)
+                       g_pd->callback->sta_disconnected_cb(&event);
                break;
        case WS_EVENT_TERMINATING:
-               event_id = WFD_OEM_EVENT_DEACTIVATED;
+               event.event_id = WFD_OEM_EVENT_DEACTIVATED;
+               if (!g_pd || !g_pd->callback || !g_pd->callback->deactivated_cb)
+                       g_pd->callback->deactivated_cb(&event);
                break;
 #ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
        case WS_EVENT_SERV_DISC_RESP:
-               event_id = WFD_OEM_EVENT_SERV_DISC_RESP;
+               event.event_id = WFD_OEM_EVENT_SERV_DISC_RESP;
+               if (!g_pd || !g_pd->callback || !g_pd->callback->serv_disc_resp_cb)
+                       g_pd->callback->serv_disc_resp_cb(&event);
                break;
 #endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
        default:
@@ -2341,9 +2386,6 @@ static gboolean ws_event_handler(GIOChannel *source,
                goto done;
                break;
        }
-       event.event_id = event_id;
-       if (g_pd->callback)
-               g_pd->callback(g_pd->user_data, &event);
 
 done:
        if (event.edata) {
@@ -2416,7 +2458,7 @@ static int __ws_check_net_interface(char* if_name)
        return 0;
 }
 
-int ws_init(wfd_oem_event_cb callback, void *user_data)
+int ws_init(wfd_oem_event_cbs_s *event_cbs)
 {
        __WDP_LOG_FUNC_ENTER__;
 
@@ -2430,15 +2472,14 @@ int ws_init(wfd_oem_event_cb callback, void *user_data)
                return -1;
        }
 
-       g_pd->callback = callback;
-       g_pd->user_data = user_data;
+       g_pd->callback = event_cbs;
        g_pd->initialized = TRUE;
 
        __WDP_LOG_FUNC_EXIT__;
        return 0;
 }
 
-int ws_deinit()
+int ws_deinit(void)
 {
        __WDP_LOG_FUNC_ENTER__;
 
index 9bb9325..3a86a19 100644 (file)
@@ -64,8 +64,8 @@
 
 #endif /* USE_DLOG */
 
-int ws_init(wfd_oem_event_cb callback, void *user_data);
-int ws_deinit();
+int ws_init(wfd_oem_event_cbs_s *event_cbs);
+int ws_deinit(void);
 int ws_activate(int concurrent);
 int ws_deactivate(int concurrent);
 int ws_start_scan(wfd_oem_scan_param_s *param);
index 9a79ad0..f673a6d 100644 (file)
@@ -97,7 +97,7 @@ int wfd_plugin_load(wfd_oem_ops_s **ops)
        return 0;
 }
 
-int ws_init(wfd_oem_event_cb callback, void *user_data)
+int ws_init(wfd_oem_event_cbs_s *event_cbs)
 {
        __WDP_LOG_FUNC_ENTER__;
 
@@ -105,7 +105,7 @@ int ws_init(wfd_oem_event_cb callback, void *user_data)
        return -1;
 }
 
-int ws_deinit()
+int ws_deinit(void)
 {
        __WDP_LOG_FUNC_ENTER__;
 
diff --git a/prd/include/wifi-direct-prd.h b/prd/include/wifi-direct-prd.h
new file mode 100644 (file)
index 0000000..412a785
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2016 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.
+ *
+ */
+
+#ifndef __WIFI_DIRECT_PRD_H__
+#define __WIFI_DIRECT_PRD_H__
+
+void wfd_prd_event_example(wfd_oem_event_s *event);
+
+void wfd_prd_event_init(wfd_oem_event_cbs_s *event_cb);
+
+#endif /* __WIFI_DIRECT_PRD_H__ */
diff --git a/prd/plugin/wpasupplicant/ctrl_iface_dbus/CMakeLists.txt b/prd/plugin/wpasupplicant/ctrl_iface_dbus/CMakeLists.txt
new file mode 100644 (file)
index 0000000..4ea33d3
--- /dev/null
@@ -0,0 +1,29 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(wifi-direct-prd-plugin-wpasupplicant C)
+
+# Set required packages
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED capi-network-wifi-direct glib-2.0 gio-2.0 dlog)
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/oem)
+INCLUDE_DIRECTORIES(SRCS include)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Werror")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+SET(SRCS
+       wfd-prd-plugin-wpasupplicant.c
+       )
+
+# library build
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+#SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION 0.1.0)
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "" OUTPUT_NAME ${PROJECT_NAME})
+
+# install
+INSTALL(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${LIB_DIR})
diff --git a/prd/plugin/wpasupplicant/ctrl_iface_dbus/include/wfd-prd-plugin-log.h b/prd/plugin/wpasupplicant/ctrl_iface_dbus/include/wfd-prd-plugin-log.h
new file mode 100644 (file)
index 0000000..e11b6af
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2016 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.
+ *
+ */
+
+#ifndef __WFD_PRD_PLUGIN_LOG_H_
+#define __WFD_PRD_PLUGIN_LOG_H_
+
+#ifdef USE_DLOG
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "WIFI_DIRECT_PRD_PLUGIN"
+
+#define WDP_LOGV(format, args...) LOGV(format, ##args)
+#define WDP_LOGD(format, args...) LOGD(format, ##args)
+#define WDP_LOGI(format, args...) LOGI(format, ##args)
+#define WDP_LOGW(format, args...) LOGW(format, ##args)
+#define WDP_LOGE(format, args...) LOGE(format, ##args)
+#define WDP_LOGF(format, args...) LOGF(format, ##args)
+
+#define __WDP_LOG_FUNC_ENTER__ LOGD("Enter")
+#define __WDP_LOG_FUNC_EXIT__ LOGD("Quit")
+
+#define WDP_SECLOGI(format, args...) SECURE_LOG(LOG_INFO, LOG_TAG, format, ##args)
+#define WDP_SECLOGD(format, args...) SECURE_LOG(LOG_DEBUG, LOG_TAG, format, ##args)
+
+#else /* USE_DLOG */
+
+#define WDP_LOGV(format, args...)
+#define WDP_LOGD(format, args...)
+#define WDP_LOGI(format, args...)
+#define WDP_LOGW(format, args...)
+#define WDP_LOGE(format, args...)
+#define WDP_LOGF(format, args...)
+
+#define __WDP_LOG_FUNC_ENTER__
+#define __WDP_LOG_FUNC_EXIT__
+
+#define WDP_SECLOGI(format, args...)
+#define WDP_SECLOGD(format, args...)
+
+#endif /* USE_DLOG */
+
+#endif /* __WFD_PRD_PLUGIN_LOG_H_ */
diff --git a/prd/plugin/wpasupplicant/ctrl_iface_dbus/include/wfd-prd-plugin-wpasupplicant.h b/prd/plugin/wpasupplicant/ctrl_iface_dbus/include/wfd-prd-plugin-wpasupplicant.h
new file mode 100644 (file)
index 0000000..8b00725
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2016 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.
+ *
+ */
+
+#ifndef __WFD_PRD_PLUGIN_WPASUPPLICANT_H__
+#define __WFD_PRD_PLUGIN_WPASUPPLICANT_H__
+
+#define WS_MACADDR_LEN 6
+#define WS_OBJECT_PATH_MAX 150
+
+typedef struct {
+       int initialized;  /* check whether plugin is initialized or not. block init function if initialized */
+       int activated;
+       int concurrent;
+       GDBusConnection *g_dbus;
+       char iface_path[WS_OBJECT_PATH_MAX];
+       char group_iface_path[WS_OBJECT_PATH_MAX];
+       unsigned char local_dev_addr[WS_MACADDR_LEN];
+       wfd_oem_event_cbs_s *callback;
+} ws_dbus_plugin_data_s;
+
+int ws_prd_init(wfd_oem_event_cbs_s *event_cb);
+int wfd_prd_plugin_load(wfd_oem_ops_s **ops);
+
+#endif /* __WFD_PRD_PLUGIN_WPASUPPLICANT_H__ */
diff --git a/prd/plugin/wpasupplicant/ctrl_iface_dbus/wfd-prd-plugin-wpasupplicant.c b/prd/plugin/wpasupplicant/ctrl_iface_dbus/wfd-prd-plugin-wpasupplicant.c
new file mode 100644 (file)
index 0000000..81525d8
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2016 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 <glib.h>
+#include <gio/gio.h>
+
+#include "wifi-direct-oem.h"
+#include "wfd-prd-plugin-log.h"
+#include "wfd-prd-plugin-wpasupplicant.h"
+
+static ws_dbus_plugin_data_s *g_pd;
+
+static int _ws_reset_plugin(ws_dbus_plugin_data_s *pd)
+{
+       __WDP_LOG_FUNC_ENTER__;
+
+       if (!pd) {
+               WDP_LOGE("Invalid parameter");
+               __WDP_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       g_free(pd);
+
+       __WDP_LOG_FUNC_EXIT__;
+       return 0;
+}
+
+int ws_prd_init(wfd_oem_event_cbs_s *event_cbs)
+{
+       __WDP_LOG_FUNC_ENTER__;
+
+       if (event_cbs == NULL) {
+               __WDP_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       if (g_pd)
+               _ws_reset_plugin(g_pd);
+
+       errno = 0;
+       g_pd = (ws_dbus_plugin_data_s*) g_try_malloc0(sizeof(ws_dbus_plugin_data_s));
+       if (!g_pd) {
+               WDP_LOGE("Failed to allocate memory for plugin data. [%s]",
+                        strerror(errno));
+               __WDP_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       g_pd->callback = event_cbs;
+       g_pd->initialized = TRUE;
+
+       __WDP_LOG_FUNC_EXIT__;
+       return 0;
+}
+
+wfd_oem_prd_ops_s prd_ops = {
+       .prd_init = ws_prd_init,
+};
+
+int wfd_prd_plugin_load(wfd_oem_ops_s **ops)
+{
+       __WDP_LOG_FUNC_ENTER__;
+
+       if (!ops) {
+               WDP_LOGE("Invalid parameter");
+               __WDP_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       (*ops)->extra_data = &prd_ops;
+
+       __WDP_LOG_FUNC_EXIT__;
+       return 0;
+}
diff --git a/prd/plugin/wpasupplicant/ctrl_iface_sock/CMakeLists.txt b/prd/plugin/wpasupplicant/ctrl_iface_sock/CMakeLists.txt
new file mode 100644 (file)
index 0000000..9bc3c43
--- /dev/null
@@ -0,0 +1,28 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(wifi-direct-prd-plugin-wpasupplicant C)
+
+# Set required packages
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED capi-network-wifi-direct glib-2.0 gio-2.0 dlog)
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/oem)
+INCLUDE_DIRECTORIES(SRCS include)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Werror")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+SET(SRCS
+       wfd-prd-plugin-wpasupplicant.c
+       )
+
+# library build
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+#SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION 0.1.0)
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "" OUTPUT_NAME ${PROJECT_NAME})
+
+# install
+INSTALL(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${LIB_DIR})
diff --git a/prd/plugin/wpasupplicant/ctrl_iface_sock/include/wfd-prd-plugin-log.h b/prd/plugin/wpasupplicant/ctrl_iface_sock/include/wfd-prd-plugin-log.h
new file mode 100644 (file)
index 0000000..e11b6af
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2016 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.
+ *
+ */
+
+#ifndef __WFD_PRD_PLUGIN_LOG_H_
+#define __WFD_PRD_PLUGIN_LOG_H_
+
+#ifdef USE_DLOG
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "WIFI_DIRECT_PRD_PLUGIN"
+
+#define WDP_LOGV(format, args...) LOGV(format, ##args)
+#define WDP_LOGD(format, args...) LOGD(format, ##args)
+#define WDP_LOGI(format, args...) LOGI(format, ##args)
+#define WDP_LOGW(format, args...) LOGW(format, ##args)
+#define WDP_LOGE(format, args...) LOGE(format, ##args)
+#define WDP_LOGF(format, args...) LOGF(format, ##args)
+
+#define __WDP_LOG_FUNC_ENTER__ LOGD("Enter")
+#define __WDP_LOG_FUNC_EXIT__ LOGD("Quit")
+
+#define WDP_SECLOGI(format, args...) SECURE_LOG(LOG_INFO, LOG_TAG, format, ##args)
+#define WDP_SECLOGD(format, args...) SECURE_LOG(LOG_DEBUG, LOG_TAG, format, ##args)
+
+#else /* USE_DLOG */
+
+#define WDP_LOGV(format, args...)
+#define WDP_LOGD(format, args...)
+#define WDP_LOGI(format, args...)
+#define WDP_LOGW(format, args...)
+#define WDP_LOGE(format, args...)
+#define WDP_LOGF(format, args...)
+
+#define __WDP_LOG_FUNC_ENTER__
+#define __WDP_LOG_FUNC_EXIT__
+
+#define WDP_SECLOGI(format, args...)
+#define WDP_SECLOGD(format, args...)
+
+#endif /* USE_DLOG */
+
+#endif /* __WFD_PRD_PLUGIN_LOG_H_ */
diff --git a/prd/plugin/wpasupplicant/ctrl_iface_sock/include/wfd-prd-plugin-wpasupplicant.h b/prd/plugin/wpasupplicant/ctrl_iface_sock/include/wfd-prd-plugin-wpasupplicant.h
new file mode 100644 (file)
index 0000000..2619e76
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2016 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.
+ *
+ */
+
+#ifndef __WFD_PRD_PLUGIN_WPASUPPLICANT_H__
+#define __WFD_PRD_PLUGIN_WPASUPPLICANT_H__
+
+#define WS_MACADDR_LEN 6
+
+typedef struct {
+       int iftype;
+       int ctrl_sock;
+       int mon_sock;
+       char *ifname;
+       int error_count;
+       int gsource;
+} ws_sock_data_s;
+
+typedef struct {
+       int initialized;        /* check whether plugin is initialized or not. block init function if initialized */
+       int activated;
+       int concurrent;
+       int global_sock;
+       ws_sock_data_s *common;
+       ws_sock_data_s *group;
+       unsigned char local_dev_addr[WS_MACADDR_LEN];
+       wfd_oem_event_cbs_s *callback;
+} ws_sock_plugin_data_s;
+
+int ws_prd_init(wfd_oem_event_cbs_s *event_cb);
+int wfd_prd_plugin_load(wfd_oem_ops_s **ops);
+
+#endif /* __WFD_PRD_PLUGIN_WPASUPPLICANT_H__ */
diff --git a/prd/plugin/wpasupplicant/ctrl_iface_sock/wfd-prd-plugin-wpasupplicant.c b/prd/plugin/wpasupplicant/ctrl_iface_sock/wfd-prd-plugin-wpasupplicant.c
new file mode 100644 (file)
index 0000000..7c770d9
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2016 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 <glib.h>
+
+#include "wifi-direct-oem.h"
+#include "wfd-prd-plugin-log.h"
+#include "wfd-prd-plugin-wpasupplicant.h"
+
+static ws_sock_plugin_data_s *g_pd;
+
+static int _ws_reset_plugin(ws_sock_plugin_data_s *pd)
+{
+       __WDP_LOG_FUNC_ENTER__;
+
+       if (!pd) {
+               WDP_LOGE("Invalid parameter");
+               __WDP_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       g_free(pd);
+
+       __WDP_LOG_FUNC_EXIT__;
+       return 0;
+}
+
+int ws_prd_init(wfd_oem_event_cbs_s *event_cbs)
+{
+       __WDP_LOG_FUNC_ENTER__;
+
+       if (event_cbs == NULL) {
+               __WDP_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       if (g_pd)
+               _ws_reset_plugin(g_pd);
+
+       errno = 0;
+       g_pd = (ws_sock_plugin_data_s*) g_try_malloc0(sizeof(ws_sock_plugin_data_s));
+       if (!g_pd) {
+               WDP_LOGE("Failed to allocate memory for plugin data. [%s]",
+                        strerror(errno));
+               __WDP_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       g_pd->callback = event_cbs;
+       g_pd->initialized = TRUE;
+
+       __WDP_LOG_FUNC_EXIT__;
+       return 0;
+}
+
+wfd_oem_prd_ops_s prd_ops = {
+       .prd_init = ws_prd_init,
+};
+
+int wfd_prd_plugin_load(wfd_oem_ops_s **ops)
+{
+       __WDP_LOG_FUNC_ENTER__;
+
+       if (!ops) {
+               WDP_LOGE("Invalid parameter");
+               __WDP_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       (*ops)->extra_data = &prd_ops;
+
+       __WDP_LOG_FUNC_EXIT__;
+       return 0;
+}
diff --git a/prd/src/wifi-direct-prd.c b/prd/src/wifi-direct-prd.c
new file mode 100644 (file)
index 0000000..4d4cdc0
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2016 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 <stdio.h>
+#include <stdlib.h>
+#include <poll.h>
+#include <unistd.h>
+#include <time.h>
+#include <errno.h>
+
+#include <glib.h>
+
+#include <wifi-direct.h>
+
+#include "wifi-direct-oem.h"
+#include "wifi-direct-log.h"
+
+void wfd_prd_event_example(wfd_oem_event_s *event)
+{
+       __WDS_LOG_FUNC_ENTER__;
+
+       __WDS_LOG_FUNC_EXIT__;
+       return;
+}
+
+void wfd_prd_event_init(wfd_oem_event_cbs_s *event_cb)
+{
+       __WDS_LOG_FUNC_ENTER__;
+
+       wfd_oem_prd_event_cbs_s *prd_event_cb = (wfd_oem_prd_event_cbs_s *)event_cb->extra_data;
+
+       prd_event_cb->prd_example_cb = wfd_prd_event_example;
+
+       __WDS_LOG_FUNC_EXIT__;
+       return;
+}
index 910dd19..ec78cea 100644 (file)
@@ -116,7 +116,7 @@ gboolean wfd_manager_dbus_iface_unregister(guint reg_id)
 
        if (reg_id > 0) {
                if (g_dbus_connection_unregister_object(connection, reg_id) == FALSE)
-                       WDS_LOGE("netconfig network migration unregister object");
+                       WDS_LOGE("Failed to unregister iface object");
        }
        return TRUE;
 }
index 0790ecd..153e1ac 100644 (file)
@@ -133,10 +133,12 @@ gboolean _wfd_connection_retry(gpointer *data)
        return G_SOURCE_REMOVE;
 }
 
-static void __wfd_process_deactivated(wfd_manager_s *manager, wfd_oem_event_s *event)
+void wfd_event_deactivated(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
+       wfd_manager_s *manager = wfd_get_manager();
+
        wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
                                     "Deactivation",
                                     g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE));
@@ -157,10 +159,11 @@ static void __wfd_process_deactivated(wfd_manager_s *manager, wfd_oem_event_s *e
        return;
 }
 
-static void __wfd_process_peer_found(wfd_manager_s *manager, wfd_oem_event_s *event)
+void wfd_event_peer_found(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
+       wfd_manager_s *manager = wfd_get_manager();
        wfd_oem_dev_data_s *edata = NULL;
        char peer_mac_address[MACSTR_LEN+1] = {0, };
        int res = 0;
@@ -218,10 +221,11 @@ static void __wfd_process_peer_found(wfd_manager_s *manager, wfd_oem_event_s *ev
        return;
 }
 
-static void __wfd_process_peer_disappeared(wfd_manager_s *manager, wfd_oem_event_s *event)
+void wfd_event_peer_disappeared(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
+       wfd_manager_s *manager = wfd_get_manager();
        wfd_session_s *session = NULL;
        wfd_device_s *peer = NULL;
        char peer_mac_address[MACSTR_LEN+1] = {0, };
@@ -248,10 +252,12 @@ static void __wfd_process_peer_disappeared(wfd_manager_s *manager, wfd_oem_event
        return;
 }
 
-static void __wfd_process_discovery_finished(wfd_manager_s *manager, wfd_oem_event_s *event)
+void wfd_event_discovery_finished(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
+       wfd_manager_s *manager = wfd_get_manager();
+
        if (manager->state != WIFI_DIRECT_STATE_DISCOVERING &&
                        manager->state != WIFI_DIRECT_STATE_ACTIVATED) {
                WDS_LOGE("Notify finding stopped when discovering or activated. [%d]", manager->state);
@@ -282,10 +288,11 @@ static void __wfd_process_discovery_finished(wfd_manager_s *manager, wfd_oem_eve
        return;
 }
 
-static void __wfd_process_prov_disc_req(wfd_manager_s *manager, wfd_oem_event_s *event)
+void wfd_event_prov_disc_req(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
+       wfd_manager_s *manager = wfd_get_manager();
        wfd_device_s *peer = NULL;
        int res = 0;
        wfd_group_s *group = (wfd_group_s*) manager->group;
@@ -352,10 +359,11 @@ static void __wfd_process_prov_disc_req(wfd_manager_s *manager, wfd_oem_event_s
        return;
 }
 
-static void __wfd_process_prov_disc_resp(wfd_manager_s *manager, wfd_oem_event_s *event)
+void wfd_event_prov_disc_resp(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
+       wfd_manager_s *manager = wfd_get_manager();
        wfd_device_s *peer = NULL;
        int res = 0;
 
@@ -397,11 +405,11 @@ static void __wfd_process_prov_disc_resp(wfd_manager_s *manager, wfd_oem_event_s
        return;
 }
 
-static void __wfd_process_prov_disc_fail(wfd_manager_s *manager,
-                                        wfd_oem_event_s *event)
+void wfd_event_prov_disc_fail(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
+       wfd_manager_s *manager = wfd_get_manager();
        wfd_session_s *session = NULL;
        unsigned char *peer_addr = NULL;
        char peer_mac_address[MACSTR_LEN+1] = {0, };
@@ -462,11 +470,11 @@ static void __wfd_process_prov_disc_fail(wfd_manager_s *manager,
        return;
 }
 
-static void __wfd_process_go_neg_req(wfd_manager_s *manager,
-                                    wfd_oem_event_s *event)
+void wfd_event_go_neg_req(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
+       wfd_manager_s *manager = wfd_get_manager();
        wfd_group_s *group = (wfd_group_s*) manager->group;
        if (group && group->role == WFD_DEV_ROLE_GC) {
                WDS_LOGD("Device has GC role - ignore this go neg request");
@@ -524,11 +532,11 @@ static void __wfd_process_go_neg_req(wfd_manager_s *manager,
        return;
 }
 
-static void __wfd_process_go_neg_fail(wfd_manager_s *manager,
-                                     wfd_oem_event_s *event)
+void wfd_event_go_neg_fail(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
+       wfd_manager_s *manager = wfd_get_manager();
        wfd_session_s *session = NULL;
        wfd_oem_conn_data_s *edata = NULL;
        unsigned char *peer_addr = NULL;
@@ -584,12 +592,12 @@ static void __wfd_process_go_neg_fail(wfd_manager_s *manager,
        return;
 }
 
-static void __wfd_process_go_neg_done(wfd_manager_s *manager,
-                                     wfd_oem_event_s *event)
+void wfd_event_go_neg_done(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
 #ifdef CTRL_IFACE_DBUS
+       wfd_manager_s *manager = wfd_get_manager();
        wfd_session_s *session = NULL;
        wfd_oem_conn_data_s *edata = NULL;
        wfd_device_s *peer = NULL;
@@ -613,11 +621,11 @@ static void __wfd_process_go_neg_done(wfd_manager_s *manager,
        return;
 }
 
-static void __wfd_process_wps_fail(wfd_manager_s *manager,
-                                  wfd_oem_event_s *event)
+void wfd_event_wps_fail(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
+       wfd_manager_s *manager = wfd_get_manager();
        wfd_session_s *session = NULL;
        unsigned char *peer_addr = NULL;
 
@@ -678,22 +686,22 @@ static void __wfd_process_wps_fail(wfd_manager_s *manager,
        return;
 }
 
-static void __wfd_process_wps_done(wfd_manager_s *manager,
-                                  wfd_oem_event_s *event)
+void wfd_event_wps_done(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
+       wfd_manager_s *manager = wfd_get_manager();
        wfd_session_process_event(manager, event);
 
        __WDS_LOG_FUNC_EXIT__;
        return;
 }
 
-static void __wfd_process_key_neg_fail(wfd_manager_s *manager,
-                                      wfd_oem_event_s *event)
+void wfd_event_key_neg_fail(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
+       wfd_manager_s *manager = wfd_get_manager();
        wfd_session_s *session = NULL;
        unsigned char *peer_addr = NULL;
        char peer_mac_address[MACSTR_LEN+1] = {0, };
@@ -754,7 +762,7 @@ static void __wfd_process_key_neg_fail(wfd_manager_s *manager,
        return;
 }
 
-static void __wfd_process_key_neg_done(wfd_manager_s *manager, wfd_oem_event_s *event)
+void wfd_event_key_neg_done(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
@@ -762,7 +770,7 @@ static void __wfd_process_key_neg_done(wfd_manager_s *manager, wfd_oem_event_s *
        return;
 }
 
-static void __wfd_process_conn_fail(wfd_manager_s *manager, wfd_oem_event_s *event)
+void wfd_event_conn_fail(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
@@ -770,7 +778,7 @@ static void __wfd_process_conn_fail(wfd_manager_s *manager, wfd_oem_event_s *eve
        return;
 }
 
-static void __wfd_process_conn_done(wfd_manager_s *manager, wfd_oem_event_s *event)
+void wfd_event_conn_done(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
@@ -778,10 +786,11 @@ static void __wfd_process_conn_done(wfd_manager_s *manager, wfd_oem_event_s *eve
        return;
 }
 
-static void __wfd_process_group_created(wfd_manager_s *manager, wfd_oem_event_s *event)
+void wfd_event_group_created(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
+       wfd_manager_s *manager = wfd_get_manager();
        wfd_group_s *group = (wfd_group_s*) manager->group;
        wfd_session_s *session = (wfd_session_s*) manager->session;
 
@@ -839,10 +848,11 @@ static void __wfd_process_group_created(wfd_manager_s *manager, wfd_oem_event_s
        return;
 }
 
-static void __wfd_process_group_destroyed(wfd_manager_s *manager, wfd_oem_event_s *event)
+void wfd_event_group_destroyed(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
+       wfd_manager_s *manager = wfd_get_manager();
        char peer_mac_address[MACSTR_LEN+1] = {0, };
        unsigned char *peer_addr = wfd_session_get_peer_addr(manager->session);
 
@@ -892,10 +902,11 @@ static void __wfd_process_group_destroyed(wfd_manager_s *manager, wfd_oem_event_
        return;
 }
 
-static void __wfd_process_invitation_req(wfd_manager_s *manager, wfd_oem_event_s *event)
+void wfd_event_invitation_req(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
+       wfd_manager_s *manager = wfd_get_manager();
        wfd_device_s *peer = NULL;
        wfd_session_s *session = NULL;
        wfd_oem_invite_data_s *edata = NULL;
@@ -948,7 +959,7 @@ static void __wfd_process_invitation_req(wfd_manager_s *manager, wfd_oem_event_s
        return;
 }
 
-static void __wfd_process_invitation_res(wfd_manager_s *manager, wfd_oem_event_s *event)
+void wfd_event_invitation_res(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
@@ -956,10 +967,11 @@ static void __wfd_process_invitation_res(wfd_manager_s *manager, wfd_oem_event_s
        return;
 }
 
-static void __wfd_process_sta_connected(wfd_manager_s *manager, wfd_oem_event_s *event)
+void wfd_event_sta_connected(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
+       wfd_manager_s *manager = wfd_get_manager();
        wfd_session_s *session = (wfd_session_s*) manager->session;
        wfd_group_s *group = (wfd_group_s*) manager->group;
        wfd_device_s *peer = NULL;
@@ -1089,10 +1101,11 @@ static void __wfd_process_sta_connected(wfd_manager_s *manager, wfd_oem_event_s
        return;
 }
 
-static void __wfd_process_sta_disconnected(wfd_manager_s *manager, wfd_oem_event_s *event)
+void wfd_event_sta_disconnected(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
+       wfd_manager_s *manager = wfd_get_manager();
        wfd_group_s *group = NULL;
        wfd_device_s *peer = NULL;
        unsigned char peer_addr[MACADDR_LEN] = {0, };
@@ -1243,7 +1256,7 @@ static void __wfd_process_sta_disconnected(wfd_manager_s *manager, wfd_oem_event
        return;
 }
 
-static void __wfd_process_terminating(wfd_manager_s *manager, wfd_oem_event_s *event)
+void wfd_event_terminating(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
@@ -1251,10 +1264,11 @@ static void __wfd_process_terminating(wfd_manager_s *manager, wfd_oem_event_s *e
        return;
 }
 
-static void __wfd_process_group_formation_failure(wfd_manager_s *manager, wfd_oem_event_s *event)
+void wfd_event_group_formation_failure(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
+       wfd_manager_s *manager = wfd_get_manager();
        wfd_session_s *session = (wfd_session_s*) manager->session;
        if (!session) {
                WDS_LOGE("Unexpected event. Session not exist");
@@ -1293,11 +1307,12 @@ static void __wfd_process_group_formation_failure(wfd_manager_s *manager, wfd_oe
  * so that wfd-manager can get indication that a peer will be connected in near future.
  * session is started for that peer, so that it is not ignored when connected.
  */
-static void __wfd_process_invitation_accepted(wfd_manager_s *manager, wfd_oem_event_s *event)
+void wfd_event_invitation_accepted(wfd_oem_event_s *event)
 {
 
        __WDS_LOG_FUNC_ENTER__;
 
+       wfd_manager_s *manager = wfd_get_manager();
        wfd_session_s *session = (wfd_session_s*) manager->session;
        wfd_device_s *peer = NULL;
        char peer_mac_address[MACSTR_LEN+1] = {0, };
@@ -1346,9 +1361,11 @@ static void __wfd_process_invitation_accepted(wfd_manager_s *manager, wfd_oem_ev
 }
 
 #ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
-static void __wfd_process_serv_disc_resp(wfd_manager_s *manager, wfd_oem_event_s *event)
+void wfd_event_serv_disc_resp(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
+
+       wfd_manager_s *manager = wfd_get_manager();
        int service_type;
        char response_data[256] = {0, };
        char peer_mac_address[MACSTR_LEN+1] = {0, };
@@ -1411,7 +1428,7 @@ next:
        return;
 }
 
-static void __wfd_process_serv_disc_started(wfd_manager_s *manager, wfd_oem_event_s *event)
+void wfd_event_serv_disc_started(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
@@ -1422,7 +1439,7 @@ static void __wfd_process_serv_disc_started(wfd_manager_s *manager, wfd_oem_even
 
 
 #if defined(TIZEN_FEATURE_ASP)
-static void __wfd_process_asp_serv_resp(wfd_manager_s *manager, wfd_oem_event_s *event)
+void wfd_event_asp_serv_resp(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
@@ -1458,7 +1475,7 @@ static void __wfd_process_asp_serv_resp(wfd_manager_s *manager, wfd_oem_event_s
        return;
 }
 
-static void __wfd_process_asp_prov_start(wfd_manager_s *manager, wfd_oem_event_s *event)
+void wfd_event_asp_prov_start(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
@@ -1466,7 +1483,7 @@ static void __wfd_process_asp_prov_start(wfd_manager_s *manager, wfd_oem_event_s
        return;
 }
 
-static void __wfd_process_asp_prov_done(wfd_manager_s *manager, wfd_oem_event_s *event)
+void wfd_event_asp_prov_done(wfd_oem_event_s *event)
 {
        __WDS_LOG_FUNC_ENTER__;
 
@@ -1475,168 +1492,62 @@ static void __wfd_process_asp_prov_done(wfd_manager_s *manager, wfd_oem_event_s
 }
 #endif /* TIZEN_FEATURE_ASP */
 
-static struct {
-       const int event_id;
-       void (*function) (wfd_manager_s *manager, wfd_oem_event_s *event);
-} wfd_oem_event_map[] = {
-       {
-               WFD_OEM_EVENT_NONE,
-               NULL
-       },
-       {
-               WFD_OEM_EVENT_DEACTIVATED,
-               __wfd_process_deactivated
-       },
-       {
-               WFD_OEM_EVENT_PEER_FOUND,
-               __wfd_process_peer_found
-       },
-       {
-               WFD_OEM_EVENT_PEER_DISAPPEARED,
-               __wfd_process_peer_disappeared
-       },
-       {
-               WFD_OEM_EVENT_DISCOVERY_FINISHED,
-               __wfd_process_discovery_finished
-       },
-       {
-               WFD_OEM_EVENT_PROV_DISC_REQ,
-               __wfd_process_prov_disc_req
-       },
-       {
-               WFD_OEM_EVENT_PROV_DISC_RESP,
-               __wfd_process_prov_disc_resp
-       },
-       {
-               WFD_OEM_EVENT_PROV_DISC_FAIL,
-               __wfd_process_prov_disc_fail
-       },
-       {
-               WFD_OEM_EVENT_GO_NEG_REQ,
-               __wfd_process_go_neg_req
-       },
-       {
-               WFD_OEM_EVENT_GO_NEG_FAIL,
-               __wfd_process_go_neg_fail
-       },
-       {
-               WFD_OEM_EVENT_GO_NEG_DONE,
-               __wfd_process_go_neg_done
-       },
-       {
-               WFD_OEM_EVENT_WPS_FAIL,
-               __wfd_process_wps_fail
-       },
-       {
-               WFD_OEM_EVENT_WPS_DONE,
-               __wfd_process_wps_done
-       },
-       {
-               WFD_OEM_EVENT_KEY_NEG_FAIL,
-               __wfd_process_key_neg_fail
-       },
-       {
-               WFD_OEM_EVENT_KEY_NEG_DONE,
-               __wfd_process_key_neg_done
-       },
-       {
-               WFD_OEM_EVENT_CONN_FAIL,
-               __wfd_process_conn_fail
-       },
-       {
-               WFD_OEM_EVENT_CONN_DONE,
-               __wfd_process_conn_done
-       },
-       {
-               WFD_OEM_EVENT_GROUP_CREATED,
-               __wfd_process_group_created
-       },
-       {
-               WFD_OEM_EVENT_GROUP_DESTROYED,
-               __wfd_process_group_destroyed
-       },
-       {
-               WFD_OEM_EVENT_INVITATION_REQ,
-               __wfd_process_invitation_req
-       },
-       {
-               WFD_OEM_EVENT_INVITATION_RES,
-               __wfd_process_invitation_res
-       },
-       {
-               WFD_OEM_EVENT_STA_CONNECTED,
-               __wfd_process_sta_connected
-       },
-       {
-               WFD_OEM_EVENT_STA_DISCONNECTED,
-               __wfd_process_sta_disconnected
-       },
-       {
-               WFD_OEM_EVENT_TERMINATING,
-               __wfd_process_terminating
-       },
-
-#ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
-       {
-               WFD_OEM_EVENT_SERV_DISC_RESP,
-               __wfd_process_serv_disc_resp
-       },
-       {
-               WFD_OEM_EVENT_SERV_DISC_STARTED,
-               __wfd_process_serv_disc_started
-       },
-#endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
-       {
-               WFD_OEM_EVENT_GROUP_FORMATION_FAILURE,
-               __wfd_process_group_formation_failure
-       },
-       {
-               WFD_OEM_EVENT_INVITATION_ACCEPTED,
-               __wfd_process_invitation_accepted
-       },
-#if defined(TIZEN_FEATURE_ASP)
-       {
-               WFD_OEM_EVENT_ASP_SERV_RESP,
-               __wfd_process_asp_serv_resp,
-       },
-       {
-               WFD_OEM_EVENT_ASP_PROV_START,
-               __wfd_process_asp_prov_start
-       },
-       {
-               WFD_OEM_EVENT_ASP_PROV_DONE,
-               __wfd_process_asp_prov_done
-       },
-#endif /* TIZEN_FEATURE_ASP */
-       {
-               WFD_OEM_EVENT_MAX,
-               NULL
-       }
-};
-
-int wfd_process_event(void *user_data, void *data)
+void wfd_event_init(wfd_oem_event_cbs_s *event_cbs)
 {
        __WDS_LOG_FUNC_ENTER__;
-       wfd_manager_s *manager = NULL;
-       wfd_oem_event_s *event = NULL;
 
-       manager = (wfd_manager_s*) user_data;
-       event = (wfd_oem_event_s*) data;
-       if (!manager || !event) {
-               WDS_LOGE("Invalid parameter");
+       if (!event_cbs) {
                __WDS_LOG_FUNC_EXIT__;
-               return -1;
+               return;
        }
 
-       WDS_LOGD("Event[%d] from " MACSECSTR, event->event_id,
-                                               MAC2SECSTR(event->dev_addr));
+       event_cbs->deactivated_cb = wfd_event_deactivated;
+       event_cbs->peer_found_cb = wfd_event_peer_found;
+       event_cbs->peer_disappeared_cb = wfd_event_peer_disappeared;
+       event_cbs->discovery_finished_cb = wfd_event_discovery_finished;
 
-       if (event->event_id > WFD_OEM_EVENT_NONE &&
-                       event->event_id < WFD_OEM_EVENT_MAX)
-                wfd_oem_event_map[event->event_id].function(manager, event);
-       else
-               WDS_LOGE("Invalid event ID");
+       event_cbs->prov_disc_req_cb = wfd_event_prov_disc_req;
+       event_cbs->prov_disc_resp_cb = wfd_event_prov_disc_resp;
+       event_cbs->prov_disc_fail_cb = wfd_event_prov_disc_fail;
+
+       event_cbs->go_neg_req_cb = wfd_event_go_neg_req;
+       event_cbs->go_neg_fail_cb = wfd_event_go_neg_fail;
+       event_cbs->go_neg_done_cb = wfd_event_go_neg_done;
+
+       event_cbs->wps_fail_cb = wfd_event_wps_fail;
+       event_cbs->wps_done_cb = wfd_event_wps_done;
+       event_cbs->key_neg_fail_cb = wfd_event_key_neg_fail;
+       event_cbs->key_neg_done_cb = wfd_event_key_neg_done;
+
+       event_cbs->conn_fail_cb = wfd_event_conn_fail;
+       event_cbs->conn_done_cb = wfd_event_conn_done;
+
+       event_cbs->group_created_cb = wfd_event_group_created;
+       event_cbs->group_destroyed_cb = wfd_event_group_destroyed;
+
+       event_cbs->invitation_req_cb = wfd_event_invitation_req;
+       event_cbs->invitation_resp_cb = wfd_event_invitation_res;
+       event_cbs->sta_connected_cb = wfd_event_sta_connected;
+       event_cbs->sta_disconnected_cb = wfd_event_sta_disconnected;
+
+       event_cbs->terminating_cb = wfd_event_terminating;
+
+#ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
+       event_cbs->serv_disc_resp_cb = wfd_event_serv_disc_resp;
+       event_cbs->serv_disc_started_cb = wfd_event_serv_disc_started;
+#endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
+
+       event_cbs->group_formation_failure_cb = wfd_event_group_formation_failure;
+       event_cbs->invitation_accepted_cb = wfd_event_invitation_accepted;
+
+#if defined(TIZEN_FEATURE_ASP)
+       event_cbs->asp_serv_resp_cb = wfd_event_asp_serv_resp;
+       event_cbs->asp_prov_start_cb = wfd_event_asp_prov_start;
+       event_cbs->asp_prov_done_cb = wfd_event_asp_prov_done;
+#endif /* TIZEN_FEATURE_ASP */
+
+       event_cbs->extra_data = NULL;
 
        __WDS_LOG_FUNC_EXIT__;
-       return 0;
+       return;
 }
index a8341ac..546e4bb 100644 (file)
 #include "wifi-direct-iface.h"
 #include "wifi-direct-dbus.h"
 
+#if defined TIZEN_ENABLE_PRD
+#include "wifi-direct-prd.h"
+#endif /* TIZEN_ENABLE_PRD */
+
 wfd_manager_s *g_manager;
 
 wfd_manager_s *wfd_get_manager()
@@ -1524,9 +1528,9 @@ static void *wfd_plugin_init(wfd_manager_s *manager)
        errno = 0;
 
 #if defined(TIZEN_ARCH_64)
-               handle = dlopen(SUPPL_PLUGIN_64BIT_PATH, RTLD_NOW);
+       handle = dlopen(SUPPL_PLUGIN_64BIT_PATH, RTLD_NOW);
 #else
-               handle = dlopen(SUPPL_PLUGIN_PATH, RTLD_NOW);
+       handle = dlopen(SUPPL_PLUGIN_PATH, RTLD_NOW);
 #endif
        if (!handle) {
                WDS_LOGE("Failed to open shared object. [%s]", dlerror());
@@ -1548,7 +1552,7 @@ static void *wfd_plugin_init(wfd_manager_s *manager)
        (*plugin_load)(&temp_ops);
        manager->oem_ops = temp_ops;
 
-       res = wfd_oem_init(temp_ops, (wfd_oem_event_cb) wfd_process_event, manager);
+       res = wfd_oem_init(temp_ops);
        if (res < 0) {
                WDS_LOGE("Failed to initialize OEM");
                dlclose(handle);
@@ -1578,6 +1582,84 @@ static int wfd_plugin_deinit(wfd_manager_s *manager)
        return 0;
 }
 
+#if defined TIZEN_ENABLE_PRD
+static void *wfd_prd_plugin_init(wfd_manager_s *manager)
+{
+       __WDS_LOG_FUNC_ENTER__;
+       void *handle;
+       struct utsname kernel_info;
+       int res;
+
+       if (!manager) {
+               WDS_LOGE("Invalid parameter");
+               __WDS_LOG_FUNC_EXIT__;
+               return NULL;
+       }
+
+       res = uname(&kernel_info);
+       if (res) {
+               WDS_LOGE("Failed to detect target type");
+               __WDS_LOG_FUNC_EXIT__;
+               return NULL;
+       }
+       WDS_LOGD("Node name [%s], HW ID [%s]", kernel_info.nodename, kernel_info.machine);
+
+       errno = 0;
+
+#if defined(TIZEN_ARCH_64)
+       handle = dlopen(SUPPL_PRD_PLUGIN_64BIT_PATH, RTLD_NOW);
+#else
+       handle = dlopen(SUPPL_PRD_PLUGIN_PATH, RTLD_NOW);
+#endif
+       if (!handle) {
+               WDS_LOGE("Failed to open shared object. [%s]", dlerror());
+               __WDS_LOG_FUNC_EXIT__;
+               return NULL;
+       }
+
+       errno = 0;
+       int (*plugin_load)(wfd_oem_ops_s **ops) = NULL;
+       plugin_load = (int (*)(wfd_oem_ops_s **ops)) dlsym(handle, "wfd_prd_plugin_load");
+       if (!plugin_load) {
+               WDS_LOGE("Failed to load symbol. Error = [%s]", strerror(errno));
+               dlclose(handle);
+               __WDS_LOG_FUNC_EXIT__;
+               return NULL;
+       }
+
+       (*plugin_load)((wfd_oem_ops_s **)&manager->oem_ops);
+
+       res = wfd_oem_prd_init((wfd_oem_ops_s *)manager->oem_ops);
+       if (res < 0) {
+               WDS_LOGE("Failed to initialize PRD OEM");
+               dlclose(handle);
+               __WDS_LOG_FUNC_EXIT__;
+               return NULL;
+       }
+       WDS_LOGD("Succeeded to initialize PRD OEM");
+
+       __WDS_LOG_FUNC_EXIT__;
+       return handle;
+}
+
+static int wfd_prd_plugin_deinit(wfd_manager_s *manager)
+{
+       __WDS_LOG_FUNC_ENTER__;
+
+       if (!manager || !manager->prd_plugin_handle) {
+               WDS_LOGE("Invalid parameter");
+               __WDS_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       dlclose(manager->prd_plugin_handle);
+       manager->prd_plugin_handle = NULL;
+
+       __WDS_LOG_FUNC_EXIT__;
+       return 0;
+}
+#endif /* TIZEN_ENABLE_PRD */
+
 int main(int argc, char *argv[])
 {
        __WDS_LOG_FUNC_ENTER__;
@@ -1618,6 +1700,17 @@ int main(int argc, char *argv[])
        }
        WDS_LOGD("Succeeded to load plugin");
 
+#if defined TIZEN_ENABLE_PRD
+       /**
+        * wfd_manager_prd_plugin initialization
+        */
+       g_manager->prd_plugin_handle = wfd_prd_plugin_init(g_manager);
+       if (!g_manager->prd_plugin_handle)
+               WDS_LOGW("Failed to initialize prd plugin");
+       else
+               WDS_LOGD("Succeeded to load plugin");
+#endif /* TIZEN_ENABLE_PRD */
+
        if (!wfd_manager_dbus_init()) {
                WDS_LOGE("Failed to DBus");
                wfd_plugin_deinit(g_manager);
@@ -1638,6 +1731,10 @@ int main(int argc, char *argv[])
        wfd_manager_dbus_unregister();
        wfd_manager_dbus_deinit();
 
+#if defined TIZEN_ENABLE_PRD
+       wfd_prd_plugin_deinit(g_manager);
+#endif /* TIZEN_ENABLE_PRD */
+
        wfd_plugin_deinit(g_manager);
        wfd_manager_deinit(g_manager);
 
diff --git a/wifi-direct-prd-plugin-wpasupplicant.manifest b/wifi-direct-prd-plugin-wpasupplicant.manifest
new file mode 100644 (file)
index 0000000..97e8c31
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_"/>
+       </request>
+</manifest>