4 * Copyright 2012 Samsung Electronics Co., Ltd
6 * Licensed under the Flora License, Version 1.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.tizenopensource.org/license
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
21 * This file implements wifi direct application main functions.
23 * @file wfd-ug-app-main.c
24 * @author Dongwook Lee (dwmax.lee@samsung.com)
28 #include <ui-gadget-module.h>
31 #include "wfd-ugapp.h"
32 #include "wfd-ugapp-util.h"
35 wfd_appdata_t *g_wfd_ad = NULL;
36 static struct ug_cbs wifi_direct_cbs;
38 wfd_appdata_t *wfd_get_appdata()
44 _ug_layout_cb(struct ui_gadget *ug, enum ug_mode mode, void *priv)
46 __WFD_APP_FUNC_ENTER__;
48 Evas_Object *base = NULL;
49 base = ug_get_layout(ug);
53 WFD_APP_LOG(WFD_APP_LOG_LOW,"ug_get_layout failed!");
60 case UG_MODE_FULLVIEW:
61 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
62 elm_win_resize_object_add(ug_get_window(), base);
63 evas_object_show(base);
71 _ug_destroy_cb(struct ui_gadget *ug, void *priv)
73 __WFD_APP_FUNC_ENTER__;
75 // TODO: free all memory allocation
81 void ug_result_cb(struct ui_gadget *ug, bundle * result, void *priv)
83 __WFD_APP_FUNC_ENTER__;
85 // TODO: free all memory allocation
89 static int load_wifi_direct_ug(struct ui_gadget *parent_ug, void *data)
91 __WFD_APP_FUNC_ENTER__;
92 wfd_appdata_t *ugd = (wfd_appdata_t *)data;
95 UG_INIT_EFL(ugd->win, UG_OPT_INDICATOR_ENABLE);
97 memset(&wifi_direct_cbs, 0, sizeof(struct ug_cbs));
99 wifi_direct_cbs.layout_cb = _ug_layout_cb;
100 wifi_direct_cbs.result_cb = ug_result_cb;
101 wifi_direct_cbs.destroy_cb = _ug_destroy_cb;
102 wifi_direct_cbs.priv = ugd;
104 ugd->wifi_direct_ug = ug_create(parent_ug, "setting-wifidirect-efl", UG_MODE_FULLVIEW, param, &wifi_direct_cbs);
105 if (ugd->wifi_direct_ug)
112 static void _win_del(void *data, Evas_Object * obj, void *event)
117 static Evas_Object *_create_win(Evas_Object * parent, const char *name)
122 eo = elm_win_add(parent, name, ELM_WIN_BASIC);
125 elm_win_title_set(eo, name);
126 elm_win_borderless_set(eo, EINA_TRUE);
127 elm_win_alpha_set(eo, EINA_TRUE);
128 evas_object_smart_callback_add(eo, "delete,request", _win_del, NULL);
129 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
130 evas_object_resize(eo, w, h);
131 evas_object_show(eo);
132 //evas_object_raise(eo);
139 static int _app_create(void *data)
141 __WFD_APP_FUNC_ENTER__;
143 wfd_appdata_t *ad = wfd_get_appdata();
147 WFD_APP_LOG(WFD_APP_LOG_LOW, "Incorrect parameter\n");
151 bindtextdomain(PACKAGE, LOCALEDIR);
153 ad->win = _create_win(NULL, PACKAGE);
154 elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
158 if (!ecore_x_display_get())
161 r = appcore_set_i18n(PACKAGE, NULL);
164 WFD_APP_LOG(WFD_APP_LOG_LOW, "appcore_set_i18n error\n");
168 __WFD_APP_FUNC_EXIT__;
173 static int _app_terminate(void *data)
175 __WFD_APP_FUNC_ENTER__;
179 WFD_APP_LOG(WFD_APP_LOG_ERROR, "Incorrect parameter\n");
183 wfd_appdata_t *ad = (wfd_appdata_t *) data;
187 evas_object_del(ad->win);
191 __WFD_APP_FUNC_EXIT__;
196 static int _app_pause(void *data)
198 __WFD_APP_FUNC_ENTER__;
199 __WFD_APP_FUNC_EXIT__;
203 static int _app_resume(void *data)
205 __WFD_APP_FUNC_ENTER__;
206 __WFD_APP_FUNC_EXIT__;
210 static int _app_reset(bundle * b, void *data)
212 __WFD_APP_FUNC_ENTER__;
214 wfd_appdata_t *ad = wfd_get_appdata();
216 load_wifi_direct_ug(NULL, ad);
218 __WFD_APP_FUNC_EXIT__;
222 int main(int argc, char *argv[])
225 struct appcore_ops ops = {
226 .create = _app_create,
227 .terminate = _app_terminate,
229 .resume = _app_resume,
233 memset(&ad, 0x0, sizeof(wfd_appdata_t));
237 return appcore_efl_main(PACKAGE, &argc, &argv, &ops);