2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.tizenopensource.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * This file implements wifi direct application main functions.
20 * @file wfd-app-main.c
21 * @author Sungsik Jang (sungsik.jang@samsung.com)
28 #include "wfd-app-util.h"
30 wfd_appdata_t *g_wfd_ad;
33 wfd_appdata_t *wfd_get_appdata()
38 static void _win_del(void *data, Evas_Object * obj, void *event)
43 static Evas_Object *_create_win(Evas_Object * parent, const char *name)
48 eo = elm_win_add(parent, name, ELM_WIN_BASIC);
51 elm_win_title_set(eo, name);
52 elm_win_borderless_set(eo, EINA_TRUE);
53 elm_win_alpha_set(eo, EINA_TRUE);
54 evas_object_smart_callback_add(eo, "delete,request", _win_del, NULL);
55 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
56 evas_object_resize(eo, w, h);
57 evas_object_raise(eo);
64 static int _app_create(void *data)
66 __WFD_APP_FUNC_ENTER__;
68 wfd_appdata_t *ad = wfd_get_appdata();
72 WFD_APP_LOG(WFD_APP_LOG_LOW, "Incorrect parameter\n");
76 bindtextdomain(PACKAGE, LOCALEDIR);
78 ad->popup_data = (wfd_popup_t *) malloc(sizeof(wfd_popup_t));
81 WFD_APP_LOG(WFD_APP_LOG_ERROR, "malloc failed\n");
84 memset(ad->popup_data, 0x0, sizeof(wfd_popup_t));
86 ad->win = _create_win(NULL, PACKAGE);
87 elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
91 if (!ecore_x_display_get())
94 r = appcore_set_i18n(PACKAGE, NULL);
97 WFD_APP_LOG(WFD_APP_LOG_LOW, "appcore_set_i18n error\n");
101 if (init_wfd_popup_client(ad) == FALSE)
103 WFD_APP_LOG(WFD_APP_LOG_ERROR, "init_wfd_popup_client error\n");
104 wfd_prepare_popup(WFD_POP_FAIL_INIT, NULL);
107 __WFD_APP_FUNC_EXIT__;
112 static int _app_terminate(void *data)
114 __WFD_APP_FUNC_ENTER__;
118 WFD_APP_LOG(WFD_APP_LOG_ERROR, "Incorrect parameter\n");
122 wfd_appdata_t *ad = (wfd_appdata_t *) data;
124 if (deinit_wfd_popup_client() == FALSE)
126 WFD_APP_LOG(WFD_APP_LOG_ERROR, "deinit_wfd_popup_client error\n");
132 evas_object_del(ad->popup);
137 evas_object_del(ad->win);
140 if (ad->discovered_peers)
142 free(ad->discovered_peers);
143 ad->discovered_peers = NULL;
147 __WFD_APP_FUNC_EXIT__;
152 static int _app_pause(void *data)
154 __WFD_APP_FUNC_ENTER__;
155 __WFD_APP_FUNC_EXIT__;
159 static int _app_resume(void *data)
161 __WFD_APP_FUNC_ENTER__;
162 __WFD_APP_FUNC_EXIT__;
166 static int _app_reset(bundle * b, void *data)
168 __WFD_APP_FUNC_ENTER__;
169 __WFD_APP_FUNC_EXIT__;
173 int main(int argc, char *argv[])
176 struct appcore_ops ops = {
177 .create = _app_create,
178 .terminate = _app_terminate,
180 .resume = _app_resume,
184 memset(&ad, 0x0, sizeof(wfd_appdata_t));
188 return appcore_efl_main(PACKAGE, &argc, &argv, &ops);