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 #include "utc-connection-common.h"
19 GMainLoop *g_pMainLoop;
24 bool telephony_supported;
25 bool bt_tethering_supported;
26 bool ethernet_supported;
28 bool all_features_not_supported;
30 connection_profile_h profile_cellular;
31 connection_profile_h profile_wifi;
32 connection_profile_h profile_temp;
33 connection_h connection;
35 gboolean test_connection_timeout_callback(gpointer data)
37 g_CallbackRet = CONNECTION_ERROR_OPERATION_FAILED;
38 PRINT_RETURN("test_connection_timeout_callback", g_CallbackRet);
43 const char *connection_get_error(connection_error_e error)
46 case CONNECTION_ERROR_NONE:
47 return "CONNECTION_ERROR_NONE";
48 case CONNECTION_ERROR_INVALID_PARAMETER:
49 return "CONNECTION_ERROR_INVALID_PARAMETER";
50 case CONNECTION_ERROR_OUT_OF_MEMORY:
51 return "CONNECTION_ERROR_OUT_OF_MEMORY";
52 case CONNECTION_ERROR_INVALID_OPERATION:
53 return "CONNECTION_ERROR_INVALID_OPERATION";
54 case CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
55 return "CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED";
56 case CONNECTION_ERROR_OPERATION_FAILED:
57 return "CONNECTION_ERROR_OPERATION_FAILED";
58 case CONNECTION_ERROR_ITERATOR_END:
59 return "CONNECTION_ERROR_ITERATOR_END";
60 case CONNECTION_ERROR_NO_CONNECTION:
61 return "CONNECTION_ERROR_NO_CONNECTION";
62 case CONNECTION_ERROR_NOW_IN_PROGRESS:
63 return "CONNECTION_ERROR_NOW_IN_PROGRESS";
64 case CONNECTION_ERROR_ALREADY_EXISTS:
65 return "CONNECTION_ERROR_ALREADY_EXISTS";
66 case CONNECTION_ERROR_OPERATION_ABORTED:
67 return "CONNECTION_ERROR_OPERATION_ABORTED";
68 case CONNECTION_ERROR_DHCP_FAILED:
69 return "CONNECTION_ERROR_DHCP_FAILED";
70 case CONNECTION_ERROR_INVALID_KEY:
71 return "CONNECTION_ERROR_INVALID_KEY";
72 case CONNECTION_ERROR_NO_REPLY:
73 return "CONNECTION_ERROR_NO_REPLY";
74 case CONNECTION_ERROR_PERMISSION_DENIED:
75 return "CONNECTION_ERROR_PERMISSION_DENIED";
76 case CONNECTION_ERROR_NOT_SUPPORTED:
77 return "CONNECTION_ERROR_NOT_SUPPORTED";
78 case CONNECTION_ERROR_ALREADY_INITIALIZED:
79 return "CONNECTION_ERROR_ALREADY_INITIALIZED";
80 case CONNECTION_ERROR_NOT_INITIALIZED:
81 return "CONNECTION_ERROR_NOT_INITIALIZED";
83 return "CONNECTION_ERROR_UNKNOWN";
87 bool connection_check_feature_supported(char *key)
90 int ret = system_info_get_platform_bool(key, &value);
91 if (ret != SYSTEM_INFO_ERROR_NONE)
96 int test_get_any_profile(connection_profile_h *profile)
98 connection_profile_h profile_h;
99 connection_profile_iterator_h profile_iter;
101 int rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_REGISTERED, &profile_iter);
102 PRINT_RETURN("connection_get_profile_iterator", rv);
103 if (CONNECTION_ERROR_NONE != rv)
106 rv = connection_profile_iterator_next(profile_iter, &profile_h);
107 PRINT_RETURN("connection_profile_iterator_next", rv);
108 if (CONNECTION_ERROR_NONE != rv)
111 rv = connection_profile_clone(profile, profile_h);
112 PRINT_RETURN("connection_profile_clone", rv);
113 if (CONNECTION_ERROR_NONE != rv)
119 int test_get_profile_by_type(connection_profile_h *profile, connection_profile_type_e type)
121 connection_profile_h profile_h;
122 connection_profile_iterator_h profile_iter;
123 connection_profile_type_e profile_type;
125 int rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_REGISTERED, &profile_iter);
126 CHECK_RETURN("connection_get_profile_iterator", rv, CONNECTION_ERROR_NONE);
128 while (connection_profile_iterator_has_next(profile_iter)) {
129 rv = connection_profile_iterator_next(profile_iter, &profile_h);
130 CHECK_RETURN("connection_profile_iterator_next", rv, CONNECTION_ERROR_NONE);
132 rv = connection_profile_get_type(profile_h, &profile_type);
133 CHECK_RETURN("connection_profile_get_type", rv, CONNECTION_ERROR_NONE);
135 if (profile_type == type) {
136 rv = connection_profile_clone(profile, profile_h);
137 CHECK_RETURN("connection_profile_clone", rv, CONNECTION_ERROR_NONE);
138 return CONNECTION_ERROR_NONE;
142 return CONNECTION_ERROR_NONE;