Fix bug N_SE-34398(Wrong PIN message not displayed)
[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 <appcore-efl.h>
33 #include <Ecore_X.h>
34 #include <Elementary.h>
35 #include <appsvc.h>
36 #include <aul.h>
37 #include <notification.h>
38 #include <syspopup_caller.h>
39 #include "wifi-direct.h"
40
41 #define PACKAGE "org.tizen.wifi-direct-popup"
42 #define EDJ_NAME RESDIR"/edje/wifi-direct-popup.edj"
43 #define WFD_MAX_PEER_NUM        10
44 #define WFD_POP_STR_MAX_LEN     256
45 #define NO_ACTION_TIME_OUT      300            /*5min*/
46
47 #define NOTIFICATION_BUNDLE_PARAM "NotiType"
48 #define NOTIFICATION_BUNDLE_VALUE "WiFi-Direct"
49 #define TICKERNOTI_SYSPOPUP "tickernoti-syspopup"
50
51
52 #define LOCALE_FILE_NAME "wifi-direct-popup"
53 #define LOCALEDIR "/usr/apps/org.tizen.wifi-direct-popup/res/locale"
54
55 #define _(s)        dgettext(LOCALE_FILE_NAME, s)
56 #define N_(s)      dgettext_noop(s)
57 #define S_(s)      dgettext("sys_string", s)
58
59
60
61 enum {
62         WFD_POP_TIMER_3 = 3,
63         WFD_POP_TIMER_10 = 10,
64         WFD_POP_TIMER_30 = 30,
65         WFD_POP_TIMER_120 = 120,
66 };
67
68 enum {
69         WFD_POP_APRV_CONNECTION_WPS_PUSHBUTTON_REQ,
70         WFD_POP_APRV_CONNECTION_WPS_DISPLAY_REQ,
71         WFD_POP_APRV_CONNECTION_WPS_KEYPAD_REQ,
72         WFD_POP_APRV_CONNECTION_INVITATION_REQ,
73
74         WFD_POP_PROG_CONNECT,
75         WFD_POP_PROG_DISCONNECT,
76         WFD_POP_PROG_CONNECT_CANCEL,
77         WFD_POP_PROG_CONNECT_WITH_PIN,
78         WFD_POP_PROG_CONNECT_WITH_KEYPAD,
79         WFD_POP_NOTI_DISCONNECTED,
80
81         WFD_POP_FAIL_INIT,
82 };
83
84 enum {
85         WFD_POP_RESP_OK,
86         WFD_POP_RESP_CANCEL,
87         WFD_POP_RESP_APRV_CONNECT_PBC_YES = 1,
88         WFD_POP_RESP_APRV_CONNECT_INVITATION_YES,
89         WFD_POP_RESP_APRV_CONNECT_DISPLAY_OK,
90         WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES,
91         WFD_POP_RESP_APRV_CONNECT_NO,
92         WFD_POP_RESP_PROG_CONNECT_KEYPAD_OK,
93         WFD_POP_RESP_APRV_ENTER_PIN_YES,
94         WFD_POP_RESP_APRV_ENTER_PIN_NO,
95 };
96
97 typedef struct {
98         int type;
99         char text[WFD_POP_STR_MAX_LEN];
100         char label1[WFD_POP_STR_MAX_LEN];
101         char label2[WFD_POP_STR_MAX_LEN];
102         int timeout;
103         int resp_data1;
104         int resp_data2;
105         int data;
106 } wfd_popup_t;
107
108 typedef struct {
109         char ssid[32];
110         char mac_address[18];
111 } wfd_device_info_t;
112
113 typedef struct {
114         Evas_Object *win;
115         Evas_Object *popup;
116         Evas_Object *pin_entry;
117         wfd_popup_t *popup_data;
118         uint popup_timeout_handle;
119         char pin_number[64];
120         char peer_mac[18];
121         char peer_name[32];
122         wfd_device_info_t *discovered_peers;
123         int discovered_peer_count;
124
125         /* notification */
126         notification_h noti;
127         wfd_device_info_t raw_connected_peers[WFD_MAX_PEER_NUM];
128         int raw_connected_peer_cnt;
129
130         /* Transmit timer */
131         wifi_direct_state_e wfd_status;
132         int last_wfd_transmit_time;
133         Ecore_Timer *transmit_timer;
134 } wfd_appdata_t;
135
136 typedef struct {
137         int step;
138         Evas_Object *progressbar;
139         Evas_Object *time;
140 } wfd_wps_display_popup_t;
141
142 extern wfd_appdata_t *wfd_get_appdata();
143
144 /**
145  *      This function let the app do initialization
146  *      @return   If success, return TRUE, else return FALSE
147  *      @param[in] ad the pointer to the main data structure
148  */
149 int init_wfd_popup_client(wfd_appdata_t *ad);
150
151 /**
152  *      This function let the app do de-initialization
153  *      @return   If success, return TRUE, else return FALSE
154  *      @param[in] ad the pointer to the main data structure
155  */
156 int deinit_wfd_popup_client(wfd_appdata_t *ad);
157
158
159 /**
160  *      This function let the app destroy the popup
161  *      @return   void
162  *      @param[in] null
163  */
164 extern void wfd_destroy_popup();
165
166 /**
167  *      This function let the app create a popup
168  *      @return   void
169  *      @param[in] type the type of popup
170  *      @param[in] userdata the pointer to the data which will be used
171  */
172 extern void wfd_prepare_popup(int type, void *userdata);
173
174 #endif                          /* __WFD_SYS_POPAPP_MAIN_H__ */