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-app-main.c
24 * @author Sungsik Jang (sungsik.jang@samsung.com)
29 #include <appcore-efl.h>
31 #include <app_service.h>
34 #include "wfd-app-util.h"
36 wfd_appdata_t *g_wfd_ad;
39 wfd_appdata_t *wfd_get_appdata()
44 static void _win_del(void *data, Evas_Object * obj, void *event)
49 static Evas_Object *_create_win(Evas_Object * parent, const char *name)
54 /* eo = elm_win_add(parent, name, ELM_WIN_BASIC); */
55 eo = elm_win_add(NULL, name, ELM_WIN_NOTIFICATION);
58 elm_win_title_set(eo, name);
59 elm_win_borderless_set(eo, EINA_TRUE);
60 elm_win_alpha_set(eo, EINA_TRUE);
61 evas_object_smart_callback_add(eo, "delete,request", _win_del, NULL);
62 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
63 evas_object_resize(eo, w, h);
64 evas_object_raise(eo);
71 static int _app_create(void *data)
73 __WFD_APP_FUNC_ENTER__;
75 wfd_appdata_t *ad = wfd_get_appdata();
79 WFD_APP_LOG(WFD_APP_LOG_LOW, "Incorrect parameter\n");
83 bindtextdomain(LOCALE_FILE_NAME, LOCALEDIR);
85 ad->popup_data = (wfd_popup_t *) malloc(sizeof(wfd_popup_t));
88 WFD_APP_LOG(WFD_APP_LOG_ERROR, "malloc failed\n");
91 memset(ad->popup_data, 0x0, sizeof(wfd_popup_t));
93 ad->win = _create_win(NULL, PACKAGE);
94 elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
98 if (!ecore_x_display_get())
101 r = appcore_set_i18n(PACKAGE, NULL);
104 WFD_APP_LOG(WFD_APP_LOG_LOW, "appcore_set_i18n error\n");
108 if (init_wfd_popup_client(ad) == FALSE)
110 WFD_APP_LOG(WFD_APP_LOG_ERROR, "init_wfd_popup_client error\n");
111 wfd_prepare_popup(WFD_POP_FAIL_INIT, NULL);
114 __WFD_APP_FUNC_EXIT__;
119 static int _app_terminate(void *data)
121 __WFD_APP_FUNC_ENTER__;
125 WFD_APP_LOG(WFD_APP_LOG_ERROR, "Incorrect parameter\n");
129 wfd_appdata_t *ad = (wfd_appdata_t *) data;
131 if (deinit_wfd_popup_client(ad) == FALSE)
133 WFD_APP_LOG(WFD_APP_LOG_ERROR, "deinit_wfd_popup_client error\n");
139 evas_object_del(ad->popup);
144 evas_object_del(ad->win);
147 if (ad->discovered_peers)
149 free(ad->discovered_peers);
150 ad->discovered_peers = NULL;
154 __WFD_APP_FUNC_EXIT__;
159 static int _app_pause(void *data)
161 __WFD_APP_FUNC_ENTER__;
162 __WFD_APP_FUNC_EXIT__;
166 static int _app_resume(void *data)
168 __WFD_APP_FUNC_ENTER__;
169 __WFD_APP_FUNC_EXIT__;
173 static int _app_reset(bundle * b, void *data)
175 __WFD_APP_FUNC_ENTER__;
177 wfd_appdata_t *ad = (wfd_appdata_t*) data;
181 WFD_APP_LOG(WFD_APP_LOG_LOW,"Bundle is NULL");
185 char *noti_type = NULL;
186 noti_type = (char*) appsvc_get_data(b, NOTIFICATION_BUNDLE_PARAM);
187 if (noti_type == NULL)
189 WFD_APP_LOG(WFD_APP_LOG_LOW,"Notification type is wrong.");
192 WFD_APP_LOG(WFD_APP_LOG_LOW,"Notification type is [%s]", noti_type);
193 if (strncmp(noti_type, NOTIFICATION_BUNDLE_VALUE, strlen(NOTIFICATION_BUNDLE_PARAM))==0)
195 WFD_APP_LOG(WFD_APP_LOG_LOW,"Launch wifidirect-ugapp");
197 service_create(&service);
198 service_set_operation(service, SERVICE_OPERATION_DEFAULT);
199 service_set_package(service, "org.tizen.wifi-direct-ugapp");
200 service_send_launch_request(service, NULL, NULL);
201 service_destroy(service);
205 __WFD_APP_FUNC_EXIT__;
209 int main(int argc, char *argv[])
212 struct appcore_ops ops = {
213 .create = _app_create,
214 .terminate = _app_terminate,
216 .resume = _app_resume,
220 memset(&ad, 0x0, sizeof(wfd_appdata_t));
224 return appcore_efl_main(PACKAGE, &argc, &argv, &ops);