summaryrefslogtreecommitdiff
path: root/include/mobile_hotspot.h
blob: 98b69ce376d60c34d5ad35152f3c1974c63ccb23 (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
/*
* ug-mobile-ap
*
* 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://floralicense.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 __MOBILE_HOTSPOT_H__
#define __MOBILE_HOTSPOT_H__

#ifdef __cplusplus
extern "C" {
#endif

#if !defined(PACKAGE)
#define PACKAGE "ug-setting-mobile-ap-ug"
#endif

#if !defined(LOCALEDIR)
#define	LOCALEDIR "/usr/ug/res/locale"
#endif

#if !defined(EDJDIR)
#define EDJDIR "/usr/ug/res/edje/ug-setting-mobile-ap-ug"
#endif

#if !defined(PREFIX)
#define PREFIX "/usr/ug"
#endif

#include <sys/time.h>
#include <glib.h>
#include <Elementary.h>
#include <vconf.h>
#include <ui-gadget-module.h>
#include <wifi.h>
#include <net_connection.h>
#include <sim.h>
#include <tethering.h>
#include <dlog.h>

#define MH_TEXT_DOMAIN				PACKAGE
#define MH_LOCALEDIR				LOCALEDIR

#ifdef S_
#undef S_
#endif
#define S_(str)					dgettext("sys_string", str)

#ifdef N_
#undef N_
#endif
#define N_(str)					gettext_noop(str)

#ifdef _
#undef _
#endif
#define _(str)					dgettext(MH_TEXT_DOMAIN, str)

#define VCONF_MOBILE_AP_PREV_WIFI_STATUS	"db/private/libug-setting-mobileap-efl/prev_wifi_status"

#define MOBILE_AP_TAG					"mobile_ap"
#define DBG(fmt, args...) LOG(LOG_DEBUG, MOBILE_AP_TAG, "[%s()][Ln:%d] "fmt, \
						__func__, __LINE__, ##args)
#define ERR(fmt, args...) LOG(LOG_ERROR, MOBILE_AP_TAG, "[%s()][Ln:%d] "fmt, \
						__func__, __LINE__, ##args)

#define __MOBILE_AP_FUNC_ENTER__	DBG("Entering: +\n")
#define __MOBILE_AP_FUNC_EXIT__ 	DBG("Exit: -\n")

#define TETHERING_IMAGES_EDJ		"tethering_images.edj"
#define WIFI_ICON			"Wifi.png"
#define BT_ICON				"Bluetooth.png"
#define USB_ICON			"USB.png"

#define DEVICE_NAME_LENGTH_MAX		31
#define WIFI_PASSPHRASE_LENGTH_MIN	8
#define WIFI_PASSPHRASE_LENGTH_MAX	63
#define MH_LABEL_LENGTH_MAX		1024

#define _EDJ(obj)			elm_layout_edje_get(obj)

/* This is from tethering_private.h */
#define TETHERING_MAX_CONNECTED_STA	16	/**< Maximum connected station. 8(Wi-Fi) + 7(BT) + 1(USB) */
#define TETHERING_TYPE_MAX		4	/**< All, USB, Wi-Fi, BT */

typedef enum {
	MH_POPUP_NONE,

	/* Two buttons pop-up */
	MH_POP_WIFI_OFF_CONF,
	MH_POP_WIFI_ON_CONF,
	MH_POP_BT_ON_CONF,
	MH_POP_USB_ON_CONF,
	MH_POP_USB_ON_PREVCONN_CONF,
	MH_POP_ENTER_TO_WIFI_SETUP_CONF,

	/* One button pop-up */
	MH_POP_INFORMATION,
	MH_POP_USB_CONNECT,
	MH_POP_WIFI_PASSWORD_SHORT,

	/* No button & timeout pop-up */
	MH_POP_INFORMATION_WO_BUTTON,

	MH_POPUP_TYPE_MAX
} mh_popup_type_e;

typedef enum {
	MH_STATE_NONE,
	MH_STATE_PROCESS,
	MH_STATE_MAX
} mh_state_e;

typedef struct ap_app_main {
	Evas_Object			*genlist;

	Evas_Object			*back_btn;
	Evas_Object 			*wifi_btn;
	Evas_Object 			*bt_btn;
	Evas_Object 			*usb_btn;

	Elm_Genlist_Item_Class		*sp_itc;
	Elm_Genlist_Item_Class		*end_sp_itc;
	Elm_Genlist_Item_Class		*wifi_itc;
	Elm_Genlist_Item_Class		*setup_itc;
	Elm_Genlist_Item_Class		*bt_itc;
	Elm_Genlist_Item_Class		*usb_itc;
	Elm_Genlist_Item_Class		*help_itc;

	Elm_Genlist_Item_Class		*device_itc;
	Elm_Genlist_Item_Class		*device0_itc;
	Elm_Genlist_Item_Class		*usage_itc;
	Elm_Genlist_Item_Class		*dev_itc[TETHERING_TYPE_MAX];

	Elm_Object_Item			*wifi_item;
	Elm_Object_Item			*setup_item;
	Elm_Object_Item			*bt_item;
	Elm_Object_Item			*usb_item;
	Elm_Object_Item			*device_item;
	Elm_Object_Item			*usage_item;
	Elm_Object_Item			*help_item;

	int 				hotspot_mode;
	int				wifi_state;
	int				bt_state;
	int				usb_state;
	bool				need_recover_wifi_tethering;
} mh_main_view_t;

typedef struct {
	Elm_Object_Item			*navi_it;
	Evas_Object			*genlist;

	Evas_Object			*back_btn;
	Evas_Object			*title_back_btn;
	Evas_Object 			*hide_btn;
	Evas_Object 			*security_btn;
	Evas_Object 	 		*pw_layout;
	Evas_Object 	 		*pw_entry;

	Elm_Genlist_Item_Class		*sp_itc;
	Elm_Genlist_Item_Class		*end_sp_itc;
	Elm_Genlist_Item_Class		*hide_itc;
	Elm_Genlist_Item_Class		*security_itc;
	Elm_Genlist_Item_Class		*pw_itc;
	Elm_Genlist_Item_Class		*name_itc;

	Elm_Object_Item			*hide_item;
	Elm_Object_Item			*security_item;
	Elm_Object_Item			*pw_item;
	Elm_Object_Item			*name_item;

	bool 				visibility;
	tethering_wifi_security_type_e	security_type;

	char 				device_name[DEVICE_NAME_LENGTH_MAX + 1];
	char 				wifi_passphrase[WIFI_PASSPHRASE_LENGTH_MAX + 1];
	char 				wifi_passphrase_new[WIFI_PASSPHRASE_LENGTH_MAX + 1];
} mh_wifi_setting_view_t;

typedef struct {
	int number;
	tethering_client_h handle[TETHERING_MAX_CONNECTED_STA];
} mh_clients_t;

typedef struct {
	bool			is_updated;
	unsigned long long	pdp_total_sent;
	unsigned long long	pdp_total_receive;
} mh_data_usage_t;

typedef struct {
	void				*gadget;
	tethering_h			handle;
	connection_h			conn_handle;

	Evas_Object 			*win;
	Evas_Object			*layout;
	Evas_Object			*bg;

	Evas_Object 			*naviframe;
	Evas_Object 			*popup;

	Ecore_Timer			*update_statistics_handle;

	mh_main_view_t			main;
	mh_wifi_setting_view_t		setup;

	mh_data_usage_t			data_statistics;
	mh_clients_t			clients;

	int				popup_type;
	char                            popup_string[MH_LABEL_LENGTH_MAX];
} mh_appdata_t;

typedef struct {
	mh_appdata_t		*ad;
	ui_gadget_h		ug;
} mh_ugdata_t;

#ifdef __cplusplus
}
#endif
#endif /* __MOBILE_HOTSPOT_H__ */