summaryrefslogtreecommitdiff
path: root/ug-wifidirect/include/wfd_ug.h
blob: c24b1ee236bf6089a3e96505290704a3ae628661 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/*
*  WiFi-Direct UG
*
* Copyright 2012  Samsung Electronics Co., Ltd

* Licensed under the Flora License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

* http://www.tizenopensource.org/license

* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/


#ifndef __WFD_UG_H__
#define __WFD_UG_H__

#include <dlog.h>
#include <ui-gadget-module.h>
#include <tethering.h>

#define PACKAGE "ug-setting-wifidirect-efl"
#define LOCALEDIR "/opt/ug/res/locale"

#define DIRECT_TAG  "wfd_ug"
#define DBG(log_level, format, args...) \
       LOG(log_level, DIRECT_TAG, "[%s()][%d] " format, __FUNCTION__, __LINE__, ##args)

#define __FUNC_ENTER__  DBG(LOG_VERBOSE, "+\n")
#define __FUNC_EXIT__   DBG(LOG_VERBOSE, "-\n")

#define VCONF_WFD_APNAME 			"db/setting/device_name"

#define assertm_if(expr, fmt, arg...) do { \
   if(expr) { \
	  DBG(LOG_VERBOSE, " ##(%s) -> %s() assert!!## "fmt, #expr, __FUNCTION__, ##arg); \
		 assert(1); \
   } \
} while (0)			// retvm if

#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"

#define AP_NAME_LENGTH_MAX		32	//allowed lenght is 31 + '\0'
#define AP_PASSWORD_LENGTH_MAX	64	//allowed lenght is 63 + '\0'
#define AP_PASSWORD_LENGTH_MIN	8	//min limit
#define AP_REJECT_CHAR_LIST		"=,"

#define DEFAULT_DEV_NAME        "GT_I9500"
#define MAC_LENGTH  18
#define SSID_LENGTH 32
#define MAX_PEER_NUM 10
#define MAX_POPUP_PEER_NUM 7
#define MAX_POPUP_TEXT_SIZE 256
#define MAX_DISPLAY_TIME_OUT	30

#define _(s)        dgettext(PACKAGE, s)
#define N_(s)      dgettext_noop(s)
#define S_(s)      dgettext("sys_string", s)


#if 1	//To-Do : Text should be translated.

#define IDS_WFD_POP_SCAN_AGAIN "To start new scanning,<br>current connection will be<br>ended.Continue?"
#define IDS_WFD_POP_WARN_BUSY_DEVICE "Unavailable device. Device is connected to another device."
#define IDS_WFD_BODY_FAILED_DEVICES "Failed Devices"
 
#endif


#define WFD_GLOBALIZATION_STR_LENGTH 256

typedef enum {
	WFD_MULTI_CONNECT_MODE_NONE,
	WFD_MULTI_CONNECT_MODE_IN_PROGRESS,
	WFD_MULTI_CONNECT_MODE_COMPLETED,
} wfd_multi_connect_mode_e;

typedef enum
{
    PEER_CONN_STATUS_DISCONNECTED,
    PEER_CONN_STATUS_DISCONNECTING,
    PEER_CONN_STATUS_CONNECTING = PEER_CONN_STATUS_DISCONNECTING,
    PEER_CONN_STATUS_CONNECTED,
    PEER_CONN_STATUS_FAILED_TO_CONNECT,
    PEER_CONN_STATUS_WAIT_FOR_CONNECT,
} conn_status_e;


typedef struct
{
    char ssid[SSID_LENGTH];    // 31 + 1('\0')
    unsigned int category;
    char mac_addr[MAC_LENGTH];
    char if_addr[MAC_LENGTH];
    conn_status_e conn_status;
    bool is_group_owner;  /** Is an active P2P Group Owner */
    bool is_persistent_group_owner;  /** Is a stored Persistent GO */
    bool is_connected;  /** Is peer connected*/
    Elm_Object_Item *gl_item;
} device_type_s;

typedef struct
{
    bool dev_sel_state;
    device_type_s peer;
} wfd_multi_sel_data_s;

struct ug_data
{
    Evas_Object *base;
    ui_gadget_h ug;

    Evas_Object *win;
    Evas_Object *bg;
    Evas_Object *naviframe;
    Evas_Object *genlist;
    Evas_Object *multiconn_view_genlist;
    Evas_Object *popup;
    Evas_Object *act_popup;
    Evas_Object *warn_popup;

    Elm_Object_Item *head;
    Elm_Object_Item *scan_btn;
    Elm_Object_Item *multi_scan_btn;
    Elm_Object_Item *multi_connect_btn;

    Elm_Object_Item *nodevice_title_item;
    Elm_Object_Item *nodevice_item;
    Elm_Object_Item *nodevice_sep_low_item;

    Elm_Object_Item *about_wfd_item;
    Elm_Object_Item *about_wfdsp_sep_end_item;

    Elm_Object_Item *conn_wfd_item;

    Elm_Object_Item *conn_failed_wfd_item;
    Elm_Object_Item *conn_failed_wfd_sep_item;

    Elm_Object_Item *avlbl_wfd_item;

    Elm_Object_Item *busy_wfd_item;
    Elm_Object_Item *busy_wfd_sep_item;

    Elm_Object_Item *multi_connect_wfd_item;

    Elm_Object_Item *multi_button_item;
    Elm_Object_Item *multi_button_sep_high_item;
    Elm_Object_Item *multi_button_sep_low_item;


    Elm_Object_Item *mcview_select_all_item;
    Elm_Object_Item *mcview_title_item;
    Elm_Object_Item *mcview_nodevice_item;


    Evas_Object *multi_btn;

    int head_text_mode;

    // Raw peer data
    device_type_s raw_connected_peers[MAX_PEER_NUM];
    int raw_connected_peer_cnt;
    device_type_s raw_discovered_peers[MAX_PEER_NUM];
    int raw_discovered_peer_cnt;

    // Peer data in the Genlist
    device_type_s gl_connected_peers[MAX_PEER_NUM];
    int gl_connected_peer_cnt;

    device_type_s gl_connected_failed_peers[MAX_PEER_NUM];
    int gl_connected_failed_peer_cnt;

    device_type_s gl_available_peers[MAX_PEER_NUM];
    int gl_available_peer_cnt;

    device_type_s gl_busy_peers[MAX_PEER_NUM];
    int gl_busy_peer_cnt;

    device_type_s raw_multi_selected_peers[MAX_PEER_NUM];
    int raw_multi_selected_peer_cnt;

    device_type_s gl_multi_connect_peers[MAX_PEER_NUM];
    int gl_multi_connect_peer_cnt;

    // My status
    bool I_am_group_owner;
    bool I_am_connected;

    // Following variables are used at the Multi connect view.
    wfd_multi_connect_mode_e multi_connect_mode;
    wfd_multi_sel_data_s multi_conn_dev_list[MAX_PEER_NUM];
    int gl_available_dev_cnt_at_multiconn_view;
    int g_source_multi_connect_next;

    int wfd_onoff;
    int wfd_status;
    char *dev_name;
    char *dev_pass;

    // For connect failed peers
    int last_display_time;
    Ecore_Timer *display_timer;

    //tethering
    tethering_h hotspot_handle;
    
};

extern Elm_Gen_Item_Class sep_itc;
extern Elm_Gen_Item_Class sep_itc_end;
extern Elm_Gen_Item_Class head_itc;
extern Elm_Gen_Item_Class name_itc;
extern Elm_Gen_Item_Class title_itc;
extern Elm_Gen_Item_Class peer_itc;
extern Elm_Gen_Item_Class noitem_itc;
extern Elm_Gen_Item_Class help_itc;
extern Elm_Gen_Item_Class button_itc;

extern Elm_Gen_Item_Class title_conn_itc;
extern Elm_Gen_Item_Class peer_conn_itc;

extern Elm_Gen_Item_Class title_busy_itc;
extern Elm_Gen_Item_Class peer_busy_itc;

extern Elm_Gen_Item_Class title_multi_connect_itc;
extern Elm_Gen_Item_Class peer_multi_connect_itc;

extern Elm_Gen_Item_Class title_conn_failed_itc;
extern Elm_Gen_Item_Class peer_conn_failed_itc;


#endif  /* __WFD_UG_H__ */