Tizen directory path migration
[apps/native/ug-wifi-direct.git] / popup-wifidirect / include / wfd-app.h
1 /*
2 *  WiFi-Direct UG
3 *
4 * Copyright 2012  Samsung Electronics Co., Ltd
5
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
9
10 * http://www.tizenopensource.org/license
11
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.
17 *
18 */
19
20 /**
21  * This file declares wifi direct application functions.
22  *
23  * @file    wfd-app.h
24  * @author  Sungsik Jang (sungsik.jang@samsung.com)
25  * @version 0.1
26  */
27
28
29 #ifndef __WFD_SYS_POPAPP_MAIN_H__
30 #define __WFD_SYS_POPAPP_MAIN_H__
31
32 #include <wifi-direct.h>
33 #include <wifi-direct-internal.h>
34
35 #define PACKAGE "org.tizen.wifi-direct-popup"
36 #define PACKAGE_ALLSHARE_CAST "org.tizen.allshare-cast-popup"
37 #define EDJ_NAME RESDIR"/edje/wifi-direct-popup.edj"
38 #define WFD_MAX_CONNECTED_PEER  7
39 #define WFD_POP_STR_MAX_LEN     256
40 #define NO_ACTION_TIME_OUT      300            /*5min*/
41
42 #define NOTIFICATION_BUNDLE_PARAM "NotiType"
43 #define NOTIFICATION_BUNDLE_VALUE "WiFi-Direct"
44
45 #define LOCALE_FILE_NAME "ug-setting-wifidirect-efl"
46 #define LOCALEDIR "/usr/ug/res/locale"
47 #define WFD_NOTI_ICON_PATH "/usr/apps/org.tizen.quickpanel/shared/res/noti_icons/Wi-Fi/noti_wifi_direct_auto_off.png"
48 #define WFD_INDICATOR_ICON_PATH "/usr/apps/org.tizen.wifi-direct-popup/res/images/B03_wi-fi_direct_on_connected.png"
49 #define WFD_ACTIVATED_NOTI_ICON_PATH "/usr/apps/org.tizen.wifi-direct-popup/res/images/B03_wi-fi_direct_on_not_connected.png"
50 #define WFD_EDJ_POPUP_PATH "/usr/apps/org.tizen.wifi-direct-popup/res/edje/wfd_popup.edj"
51 #define SCREEN_MIRRIONG_INDICATOR_ICON_PATH "/usr/apps/org.tizen.wifi-direct-popup/res/images/B03_event_screen_mirroring.png"
52 #define SCREEN_MIRRIONG_INDICATOR_PLAY_ICON_PATH "/usr/apps/org.tizen.wifi-direct-popup/res/images/B03_event_screen_mirroring_play.png"
53 #define SCREEN_MIRRIONG_NOTI_ICON_PATH "/usr/apps/org.tizen.wifi-direct-popup/res/images/ug-setting-allshare-cast-efl.png"
54
55 #define D_(s)        dgettext(LOCALE_FILE_NAME, s)
56 #define N_(s)      dgettext_noop(s)
57 #define S_(s)      dgettext("sys_string", s)
58
59 #define MAX_NO_ACTION_TIME_OUT  300            /*5min*/
60 #define MAX_POPUP_TEXT_SIZE 256
61 #define DEV_NAME_LENGTH 32
62 #define MACSTR_LENGTH 17
63 #define PIN_LENGTH 64
64
65 #ifndef FALSE
66 #define FALSE (0)
67 #endif
68 #ifndef TRUE
69 #define TRUE (!FALSE)
70 #endif
71
72 enum {
73         WFD_POP_TIMER_3 = 3,
74         WFD_POP_TIMER_10 = 10,
75         WFD_POP_TIMER_30 = 30,
76         WFD_POP_TIMER_120 = 120,
77 };
78
79 enum {
80         WFD_POP_APRV_CONNECTION_WPS_PUSHBUTTON_REQ,
81         WFD_POP_APRV_CONNECTION_WPS_DISPLAY_REQ,
82         WFD_POP_APRV_CONNECTION_WPS_KEYPAD_REQ,
83
84         WFD_POP_PROG_CONNECT,
85         WFD_POP_PROG_DISCONNECT,
86         WFD_POP_PROG_CONNECT_CANCEL,
87         WFD_POP_PROG_CONNECT_WITH_PIN,
88         WFD_POP_PROG_CONNECT_WITH_KEYPAD,
89         WFD_POP_NOTI_DISCONNECTED,
90
91         WFD_POP_FAIL_INIT,
92 };
93
94 enum {
95         WFD_POP_RESP_OK,
96         WFD_POP_RESP_CANCEL,
97         WFD_POP_RESP_APRV_CONNECT_PBC_YES = 1,
98         WFD_POP_RESP_APRV_CONNECT_DISPLAY_OK,
99         WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES,
100         WFD_POP_RESP_APRV_CONNECT_NO,
101         WFD_POP_RESP_PROG_CONNECT_KEYPAD_OK,
102         WFD_POP_RESP_APRV_ENTER_PIN_YES,
103         WFD_POP_RESP_APRV_ENTER_PIN_NO,
104 };
105
106 #ifdef WFD_SCREEN_MIRRORING_ENABLED
107 enum {
108         WFD_POP_SCREEN_MIRROR_NONE,
109         WFD_POP_SCREEN_MIRROR_DISCONNECT_BY_RECONNECT_WIFI_AP,
110 };
111 #endif
112
113 typedef struct {
114         int type;
115         char text[WFD_POP_STR_MAX_LEN];
116         char label1[WFD_POP_STR_MAX_LEN];
117         char label2[WFD_POP_STR_MAX_LEN];
118         int timeout;
119         int resp_data1;
120         int resp_data2;
121         int data;
122 } wfd_popup_t;
123
124 typedef struct {
125         char ssid[32];
126         char mac_address[18];
127         unsigned int category;
128         bool is_miracast_device;
129 } wfd_device_info_t;
130
131 typedef struct {
132         int status;
133         char peer_name[DEV_NAME_LENGTH+1];
134         char peer_addr[MACSTR_LENGTH+1];
135         unsigned int device_type;
136         int wifi_display;
137         wifi_direct_wps_type_e wps_type;
138         char wps_pin[PIN_LENGTH+1];
139         bool auto_conn;
140 } wfd_connection_info_s;
141
142 typedef struct {
143         Evas_Object *win;
144         Evas_Object *popup;
145         Evas_Object *pin_entry;
146         Evas_Object *conformant;
147         Evas_Object *layout;
148         Evas_Object *back_grnd;
149         wfd_popup_t *popup_data;
150         uint popup_timeout_handle;
151
152         wfd_connection_info_s *connection;
153
154         /* notification */
155 #ifdef NOT_CONNECTED_INDICATOR_ICON
156         notification_h noti_wifi_direct_on;
157 #endif
158         notification_h noti_wifi_direct_connected;
159         notification_h noti_screen_mirroring_on;
160         notification_h noti_screen_mirroring_play;
161         wfd_device_info_t raw_connected_peers[WFD_MAX_CONNECTED_PEER];
162         int raw_connected_peer_cnt;
163
164         /* Transmit timer */
165         wifi_direct_state_e wfd_status;
166         int last_wfd_transmit_time;
167         Ecore_Timer *transmit_timer;
168
169         /* auto deactivation after 5 mins if not connected*/
170 #ifdef WFD_FIVE_MIN_IDLE_DEACTIVATION
171         Ecore_Timer *monitor_timer;
172 #endif
173         wifi_direct_state_e last_wfd_status;
174         int last_wfd_time;
175
176 #ifdef WFD_SCREEN_MIRRORING_ENABLED
177         int screen_mirroring_state;
178 #endif
179         int timeout;
180
181         Elm_Genlist_Item_Class *pin_entry_itc;
182         Elm_Genlist_Item_Class *pin_desc_itc;
183         Elm_Genlist_Item_Class *paswd_itc;
184
185         /*Mac address for connecting device*/
186         char mac_addr_connecting[MACSTR_LENGTH];
187
188         /* Down Key Press Handler */
189         Ecore_Event_Handler *downkey_handler;
190 } wfd_appdata_t;
191
192 typedef struct {
193         int step;
194         Evas_Object *progressbar;
195         Evas_Object *time;
196 } wfd_wps_display_popup_t;
197
198 extern wfd_appdata_t *wfd_get_appdata();
199
200 /**
201  *      This function let the app do initialization
202  *      @return   If success, return TRUE, else return FALSE
203  *      @param[in] ad the pointer to the main data structure
204  */
205 bool init_wfd_client(wfd_appdata_t *ad);
206
207 /**
208  *      This function let the app do de-initialization
209  *      @return   If success, return TRUE, else return FALSE
210  *      @param[in] ad the pointer to the main data structure
211  */
212 int deinit_wfd_client(wfd_appdata_t *ad);
213
214 void wfd_app_util_del_notification(wfd_appdata_t *ad);
215 Eina_Bool wfd_automatic_deactivated_for_connection_cb(void *user_data);
216 int wfd_app_util_deregister_hard_key_down_cb(void *data);
217 int wfd_app_get_connected_peers(void *user_data);
218 int wfd_app_client_switch_off(void *data);
219
220 /**
221  *      This function let the app destroy the popup
222  *      @return   void
223  *      @param[in] null
224  */
225 extern void wfd_destroy_popup();
226
227 /**
228  *      This function let the app create a popup
229  *      @return   void
230  *      @param[in] type the type of popup
231  *      @param[in] userdata the pointer to the data which will be used
232  */
233 extern void wfd_prepare_popup(int type, void *userdata);
234
235 #endif                          /* __WFD_SYS_POPAPP_MAIN_H__ */