4 * Copyright 2012 Samsung Electronics Co., Ltd
6 * Licensed under the Flora License, Version 1.1 (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://floralicense.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);
57 elm_win_title_set(eo, name);
58 elm_win_borderless_set(eo, EINA_TRUE);
59 elm_win_alpha_set(eo, EINA_TRUE);
60 evas_object_smart_callback_add(eo, "delete,request", _win_del, NULL);
61 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
62 evas_object_resize(eo, w, h);
63 evas_object_raise(eo);
69 static int _app_create(void *data)
71 __WDPOP_LOG_FUNC_ENTER__;
72 wfd_appdata_t *ad = wfd_get_appdata();
75 WDPOP_LOGD( "Incorrect parameter\n");
79 bindtextdomain(LOCALE_FILE_NAME, LOCALEDIR);
81 ad->popup_data = (wfd_popup_t *) malloc(sizeof(wfd_popup_t));
82 if (!ad->popup_data) {
83 WDPOP_LOGE("malloc failed\n");
87 memset(ad->popup_data, 0x0, sizeof(wfd_popup_t));
88 ad->win = _create_win(NULL, PACKAGE);
89 elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
93 if (!ecore_x_display_get()) {
97 r = appcore_set_i18n(PACKAGE, NULL);
99 WDPOP_LOGD( "appcore_set_i18n error\n");
103 if (init_wfd_popup_client(ad) == FALSE) {
104 WDPOP_LOGE("init_wfd_popup_client error\n");
105 wfd_prepare_popup(WFD_POP_FAIL_INIT, NULL);
108 __WDPOP_LOG_FUNC_EXIT__;
112 static int _app_terminate(void *data)
114 __WDPOP_LOG_FUNC_ENTER__;
117 WDPOP_LOGE("Incorrect parameter\n");
121 wfd_appdata_t *ad = (wfd_appdata_t *) data;
123 if (deinit_wfd_popup_client(ad) == FALSE) {
124 WDPOP_LOGE("deinit_wfd_popup_client error\n");
127 evas_object_del(ad->popup);
131 evas_object_del(ad->win);
134 if (ad->discovered_peers) {
135 free(ad->discovered_peers);
136 ad->discovered_peers = NULL;
140 __WDPOP_LOG_FUNC_EXIT__;
144 static int _app_pause(void *data)
146 __WDPOP_LOG_FUNC_ENTER__;
147 __WDPOP_LOG_FUNC_EXIT__;
151 static int _app_resume(void *data)
153 __WDPOP_LOG_FUNC_ENTER__;
154 __WDPOP_LOG_FUNC_EXIT__;
158 static int _app_reset(bundle *b, void *data)
160 __WDPOP_LOG_FUNC_ENTER__;
163 WDPOP_LOGD( "Bundle is NULL");
168 char *noti_type = NULL;
169 noti_type = (char *)appsvc_get_data(b, NOTIFICATION_BUNDLE_PARAM);
171 if (noti_type == NULL) {
172 WDPOP_LOGD( "Notification type is wrong.");
176 WDPOP_LOGD( "Notification type is [%s]", noti_type);
177 if (strncmp(noti_type, NOTIFICATION_BUNDLE_VALUE, strlen(NOTIFICATION_BUNDLE_PARAM)) == 0) {
178 WDPOP_LOGD( "Launch wifidirect-ugapp");
180 service_create(&service);
181 service_set_operation(service, SERVICE_OPERATION_DEFAULT);
182 service_set_package(service, "org.tizen.wifi-direct-ugapp");
183 service_send_launch_request(service, NULL, NULL);
184 service_destroy(service);
187 __WDPOP_LOG_FUNC_EXIT__;
191 int main(int argc, char *argv[])
194 struct appcore_ops ops = {
195 .create = _app_create,
196 .terminate = _app_terminate,
198 .resume = _app_resume,
202 memset(&ad, 0x0, sizeof(wfd_appdata_t));
206 return appcore_efl_main(PACKAGE, &argc, &argv, &ops);