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