c017276fc4dfda044796c70675d0d94732e64b33
[platform/core/connectivity/net-config.git] / include / util.h
1 /*
2  * Network Configuration Module
3  *
4  * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
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 #ifndef __NETCONFIG_UTIL_H__
21 #define __NETCONFIG_UTIL_H__
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #include <glib.h>
28
29 #include "wifi.h"
30 #include "plugin.h"
31
32 #define NETCONFIG_TIZEN_SYSTEM_ENV "/run/tizen-system-env"
33
34 #define MAX_SIZE_ERROR_BUFFER 256
35
36 gboolean netconfig_check_passphrase(const gchar *service, const char *passphrase);
37 GKeyFile *netconfig_keyfile_load(const char *pathname);
38 void netconfig_keyfile_save(GKeyFile *keyfile, const char *pathname);
39
40 void netconfig_start_timer_seconds(guint secs,
41                 gboolean(*callback) (gpointer), void *user_data, guint *timer_id);
42 void netconfig_start_timer(guint msecs,
43                 gboolean(*callback) (gpointer), void *user_data, guint *timer_id);
44 void netconfig_stop_timer(guint *timer_id);
45
46 void netconfig_wifi_enable_device_picker_test(void);
47 void netconfig_wifi_device_picker_service_start(void);
48 void netconfig_wifi_device_picker_service_stop(void);
49
50 gboolean netconfig_is_wifi_direct_on(void);
51 gboolean netconfig_is_wifi_tethering_on(void);
52
53 gboolean netconfig_interface_up(const char *ifname);
54 gboolean netconfig_interface_down(const char *ifname);
55 int __netconfig_get_interface_index(const char *interface_name);
56
57 int netconfig_execute_cmd(const char *cmd);
58 int netconfig_execute_file(const char *file_path, char *const args[], char *const env[]);
59 int netconfig_execute_file_no_wait(const char *file_path,
60                 char *const args[]);
61 int netconfig_execute_clatd(const char *file_path, char *const args[]);
62 int netconfig_add_route_ipv6(gchar *ip_addr, gchar *interface, gchar *gateway, unsigned char prefix_len);
63 int netconfig_del_route_ipv6(gchar *ip_addr, gchar *interface, gchar *gateway, unsigned char prefix_len);
64 int netconfig_add_route_ipv4(gchar *ip_addr, gchar *subnet, gchar *interface, gint address_family);
65 int netconfig_del_route_ipv4(gchar *ip_addr, gchar *subnet, gchar *interface, gint address_family);
66
67 gboolean handle_launch_direct(Wifi *wifi, GDBusMethodInvocation *context);
68 gboolean handle_launch_mdns(Network *object, GDBusMethodInvocation *context,
69                                                         gchar *name);
70
71 gboolean netconfig_send_notification_to_net_popup(const char * noti, const char * data);
72 int netconfig_send_message_to_net_popup(const char *title,
73                 const char *content, const char *type, const char *ssid);
74 int netconfig_send_restriction_to_net_popup(const char *title,
75                 const char *type, const char *restriction);
76 void netconfig_set_system_event(int sys_evt, int evt_key, int evt_val);
77 void netconfig_set_vconf_int(const char * key, int value);
78 void netconfig_set_vconf_str(const char * key, const char * value);
79 int netconfig_vconf_get_int(const char * key, int *value);
80 int netconfig_vconf_get_bool(const char * key, int *value);
81 char* netconfig_get_env(const char *key);
82 void netconfig_set_mac_address_from_file(void);
83 void __netconfig_pop_wifi_connected_poppup(const char *ssid);
84
85 void netconfig_get_telephony_network_type(int *svctype, int *pstype);
86 gboolean __netconfig_wifi_get_sim_imsi(Wifi *wifi, GDBusMethodInvocation *context);
87 netconfig_error_e __netconfig_wifi_req_aka_auth(GArray *rand_data, GArray *autn_data,
88                 GDBusMethodInvocation *context, struct wifi_authentication_data **data);
89 gboolean __netconfig_wifi_req_sim_auth(GArray *rand_data,
90                 GDBusMethodInvocation *context, struct wifi_authentication_data **data);
91 gboolean netconfig_tapi_check_sim_state(void);
92 gboolean __netconfig_wifi_get_aka_authdata(Wifi *wifi,
93                 GDBusMethodInvocation *context, struct wifi_authentication_data **data);
94 gboolean __netconfig_wifi_get_sim_authdata(Wifi *wifi,
95                 GDBusMethodInvocation *context, struct wifi_authentication_data **data);
96
97 void netconfig_plugin_init();
98 void netconfig_plugin_deinit();
99 gboolean netconfig_get_headed_plugin_flag();
100 gboolean netconfig_get_telephony_plugin_flag();
101
102 #ifdef __cplusplus
103 }
104 #endif
105
106 typedef enum {
107         TIZEN_PROFILE_UNKNOWN = 0,
108         TIZEN_PROFILE_MOBILE = 0x1,
109         TIZEN_PROFILE_WEARABLE = 0x2,
110         TIZEN_PROFILE_TV = 0x4,
111         TIZEN_PROFILE_IVI = 0x8,
112         TIZEN_PROFILE_COMMON = 0x10,
113 } tizen_profile_t;
114 extern tizen_profile_t _get_tizen_profile();
115
116 #define TIZEN_TELEPHONY_ENABLE (_get_tizen_profile() == TIZEN_PROFILE_MOBILE)
117 #define TIZEN_WLAN_BOARD_SPRD (_get_tizen_profile() == TIZEN_PROFILE_MOBILE)
118 #define TIZEN_TV (_get_tizen_profile() == TIZEN_PROFILE_TV)
119 #define TIZEN_NTP_ENABLE 1 /* 1: enable, 0: disable */
120
121 #endif /* __NETCONFIG_UTIL_H__ */