Make new source file for main function 76/164876/1
authorJiung <jiung.yu@samsung.com>
Thu, 21 Dec 2017 07:01:41 +0000 (16:01 +0900)
committerJiung <jiung.yu@samsung.com>
Thu, 21 Dec 2017 07:01:52 +0000 (16:01 +0900)
Change-Id: I92675e24b2bd55f6fa21e3f213049006b0baffe1
Signed-off-by: Yu jiung <jiung.yu@samsung.com>
include/wifi-direct-manager.h
packaging/wifi-direct-manager.spec
src/wifi-direct-main.c [new file with mode: 0644]
src/wifi-direct-manager.c

index 7af213d..e28ad62 100644 (file)
@@ -191,6 +191,8 @@ int wfd_local_get_intf_mac(unsigned char *intf_mac);
 int wfd_local_set_wps_mode(int wps_mode);
 wfd_device_s *wfd_manager_find_connected_peer(wfd_manager_s *manager, unsigned char *peer_addr);
 #endif
+int wfd_manager_load();
+void wfd_manager_unload();
 int wfd_local_get_ip_addr(char *ip_str);
 int wfd_local_get_supported_wps_mode(int *wps_mode);
 int wfd_local_get_wps_mode(int *wps_mode);
index 48faad4..d4d2d06 100644 (file)
@@ -6,7 +6,7 @@
 
 Name:          wifi-direct-manager
 Summary:       Wi-Fi Direct manger
-Version:       1.2.258
+Version:       1.2.259
 Release:       1
 Group:      Network & Connectivity/Wireless
 License:    Apache-2.0
diff --git a/src/wifi-direct-main.c b/src/wifi-direct-main.c
new file mode 100644 (file)
index 0000000..67cbbd6
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2015 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.
+ *
+ */
+
+/**
+ * This file implements wifi direct manager main functions.
+ *
+ * @file        wifi-direct-main.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+#include <glib.h>
+
+#include <wifi-direct.h>
+
+#include "wifi-direct-ipc.h"
+#include "wifi-direct-log.h"
+#include "wifi-direct-oem.h"
+#include "wifi-direct-manager.h"
+
+
+int main(int argc, char *argv[])
+{
+       __WDS_LOG_FUNC_ENTER__;
+       GMainLoop *main_loop = NULL;
+       wfd_manager_s *manager = NULL;
+
+#if !GLIB_CHECK_VERSION(2, 32, 0)
+       if (!g_thread_supported())
+               g_thread_init(NULL);
+#endif
+
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+       g_type_init();
+#endif
+
+       if (wfd_manager_load() < 0) {
+               WDS_LOGE("Failed to initialize wifi-direct manager");
+               __WDS_LOG_FUNC_EXIT__;
+               return -1;
+       }
+       manager = wfd_get_manager();
+       if (!manager) {
+               WDS_LOGE("Failed to initialize wifi-direct manager");
+               __WDS_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       main_loop = g_main_loop_new(NULL, FALSE);
+       if (main_loop == NULL) {
+               WDS_LOGE("Failed to create GMainLoop structure");
+               __WDS_LOG_FUNC_EXIT__;
+               return -1;
+       }
+       manager->main_loop = main_loop;
+       g_main_loop_run(main_loop);
+
+       wfd_manager_unload();
+
+       __WDS_LOG_FUNC_EXIT__;
+       return 0;
+}
index f7795da..cc9bb38 100644 (file)
@@ -1948,19 +1948,9 @@ static int wfd_prd_plugin_deinit(wfd_manager_s *manager)
 }
 #endif /* TIZEN_ENABLE_PRD */
 
-int main(int argc, char *argv[])
+int wfd_manager_load()
 {
        __WDS_LOG_FUNC_ENTER__;
-       GMainLoop *main_loop = NULL;
-
-#if !GLIB_CHECK_VERSION(2, 32, 0)
-       if (!g_thread_supported())
-               g_thread_init(NULL);
-#endif
-
-#if !GLIB_CHECK_VERSION(2, 36, 0)
-       g_type_init();
-#endif
 
        /* TODO: Parsing argument */
        /* Wi-Fi direct connection for S-Beam can be optimized using argument */
@@ -2007,15 +1997,12 @@ int main(int argc, char *argv[])
                return -1;
        }
 
-       main_loop = g_main_loop_new(NULL, FALSE);
-       if (main_loop == NULL) {
-               WDS_LOGE("Failed to create GMainLoop structure");
-               __WDS_LOG_FUNC_EXIT__;
-               return -1;
-       }
-       g_manager->main_loop = main_loop;
-       g_main_loop_run(main_loop);
-
+       __WDS_LOG_FUNC_EXIT__;
+       return 0;
+}
+void wfd_manager_unload()
+{
+       __WDS_LOG_FUNC_ENTER__;
        wfd_manager_dbus_unregister_nameowner_signal();
 
        wfd_manager_dbus_unregister();
@@ -2027,7 +2014,6 @@ int main(int argc, char *argv[])
 
        wfd_plugin_deinit(g_manager);
        wfd_manager_deinit(g_manager);
-
        __WDS_LOG_FUNC_EXIT__;
-       return 0;
+       return;
 }