2 // Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 #ifndef _CONNECTION_COMMON_H_
18 #define _CONNECTION_COMMON_H_
20 #include <tct_common.h>
21 #include <system_info.h>
26 #include <net_connection.h>
28 #include "assert_local.h"
31 #define COMMON_DEBUG 1
33 #define COMMON_DEBUG 0
36 #define GMAINTIMEOUT 20000
37 #define CUSTOM_PROFILE_NAME "Net"
39 #define FEATURE_WIFI "http://tizen.org/feature/network.wifi"
40 #define FEATURE_ETHERNET "http://tizen.org/feature/network.ethernet"
41 #define FEATURE_TELEPHONY "http://tizen.org/feature/network.telephony"
42 #define FEATURE_BT_TETHERING "http://tizen.org/feature/network.tethering.bluetooth"
43 #define FEATURE_ROUTE "http://tizen.org/feature/network.route"
44 #define CALLBACK_RETURN "callback return"
46 extern GMainLoop *g_pMainLoop;
47 extern guint g_nTimeoutId;
48 extern int g_CallbackRet;
50 extern bool wifi_supported;
51 extern bool telephony_supported;
52 extern bool bt_tethering_supported;
53 extern bool ethernet_supported;
54 extern bool route_supported;
55 extern bool all_features_not_supported;
57 extern connection_profile_h profile_cellular;
58 extern connection_profile_h profile_wifi;
59 extern connection_profile_h profile_temp;
60 extern connection_h connection;
62 #define RUN_GMAIN_LOOP { \
63 g_pMainLoop = g_main_loop_new(NULL, false); \
64 g_nTimeoutId = g_timeout_add(GMAINTIMEOUT, test_connection_timeout_callback, g_pMainLoop); \
66 PRINT_LOG(DLOG_INFO, "NativeTCT", "[Line:%5d][%s] Run mainloop [%p]", \
67 __LINE__, __FUNCTION__, g_pMainLoop); \
69 g_main_loop_run(g_pMainLoop); \
70 g_source_remove(g_nTimeoutId); \
74 #define QUIT_GMAIN_LOOP { \
77 PRINT_LOG(DLOG_INFO, "NativeTCT", "[Line:%5d][%s] Quit mainloop [%p]", \
78 __LINE__, __FUNCTION__, g_pMainLoop); \
80 g_main_loop_quit(g_pMainLoop); \
84 #define FREE_RESOURCE(var) { \
91 #define PRINT_RETURN(api, ret) { \
93 PRINT_LOG(DLOG_INFO, "NativeTCT", "[Line:%5d][%s] %s returned = %s", \
94 __LINE__, __FUNCTION__, api, connection_get_error(ret)); \
98 #define CHECK_RETURN(api, ret, val) ({ \
100 if (COMMON_DEBUG) { \
101 PRINT_LOG(DLOG_INFO, "NativeTCT", "[Line:%5d][%s] %s failed, error returned = %s", \
102 __LINE__, __FUNCTION__, api, connection_get_error(ret)); \
106 if (COMMON_DEBUG) { \
107 PRINT_LOG(DLOG_INFO, "NativeTCT", "[Line:%5d][%s] %s", \
108 __LINE__, __FUNCTION__, api); \
113 #define DEBUG_LOG { \
114 PRINT_LOG(DLOG_INFO, "NativeTCT", "[Line:%5d][%s] ***** DEBUG *****", __LINE__, __FUNCTION__); \
117 gboolean test_connection_timeout_callback(gpointer data);
118 const char *connection_get_error(connection_error_e error);
119 bool connection_check_feature_supported(char *key);
120 int test_get_any_profile(connection_profile_h *profile);
121 int test_get_profile_by_type(connection_profile_h *profile, connection_profile_type_e type);
123 #endif /* _CONNECTION_COMMON_H_ */