2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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.
19 #include "tethering_private.h"
21 API int tethering_client_clone(tethering_client_h *dest, tethering_client_h origin)
23 CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
25 _retvm_if(dest == NULL, TETHERING_ERROR_INVALID_PARAMETER,
26 "Parameter(dest) is NULL\n");
27 _retvm_if(origin == NULL, TETHERING_ERROR_INVALID_PARAMETER,
28 "Parameter(origin) is NULL\n");
30 __tethering_client_h *si = NULL;
31 __tethering_client_h *source = NULL;
33 source = (__tethering_client_h *)origin;
35 si = malloc(sizeof(__tethering_client_h));
37 ERR("malloc is failed\n");
38 return TETHERING_ERROR_OUT_OF_MEMORY;
41 memcpy(si, source, sizeof(__tethering_client_h));
42 si->hostname = g_strdup(source->hostname);
43 if (si->hostname == NULL) {
44 ERR("malloc is failed\n");
46 return TETHERING_ERROR_OUT_OF_MEMORY;
49 *dest = (tethering_client_h)si;
51 return TETHERING_ERROR_NONE;
54 API int tethering_client_destroy(tethering_client_h client)
56 CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
58 _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
59 "Parameter(client) is NULL\n");
61 __tethering_client_h *si = NULL;
63 si = (__tethering_client_h *)client;
69 return TETHERING_ERROR_NONE;
72 API int tethering_client_get_tethering_type(tethering_client_h client, tethering_type_e *type)
74 CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
76 _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
77 "Parameter(client) is NULL\n");
78 _retvm_if(type == NULL, TETHERING_ERROR_INVALID_PARAMETER,
79 "Parameter(type) is NULL\n");
81 __tethering_client_h *si = (__tethering_client_h *)client;
83 *type = si->interface;
85 return TETHERING_ERROR_NONE;
88 API int tethering_client_get_tethering_band(tethering_client_h client, tethering_band_e *band)
90 CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
92 _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
93 "Parameter(client) is NULL\n");
94 _retvm_if(band == NULL, TETHERING_ERROR_INVALID_PARAMETER,
95 "Parameter(band) is NULL\n");
97 __tethering_client_h *si = (__tethering_client_h *)client;
101 return TETHERING_ERROR_NONE;
104 API int tethering_client_get_name(tethering_client_h client, char **name)
106 CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
108 _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
109 "Parameter(client) is NULL\n");
110 _retvm_if(name == NULL, TETHERING_ERROR_INVALID_PARAMETER,
111 "Parameter(name) is NULL\n");
113 __tethering_client_h *si = (__tethering_client_h *)client;
115 *name = strdup(si->hostname);
117 ERR("strdup is failed\n");
118 return TETHERING_ERROR_OUT_OF_MEMORY;
121 return TETHERING_ERROR_NONE;
124 API int tethering_client_get_ip_address(tethering_client_h client, tethering_address_family_e address_family, char **ip_address)
126 CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
128 _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
129 "Parameter(client) is NULL\n");
130 _retvm_if(ip_address == NULL, TETHERING_ERROR_INVALID_PARAMETER,
131 "Parameter(ip_address) is NULL\n");
133 __tethering_client_h *si = (__tethering_client_h *)client;
135 *ip_address = strdup(si->ip);
136 if (*ip_address == NULL) {
137 ERR("strdup is failed\n");
138 return TETHERING_ERROR_OUT_OF_MEMORY;
141 return TETHERING_ERROR_NONE;
144 API int tethering_client_get_mac_address(tethering_client_h client, char **mac_address)
146 CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
148 _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
149 "Parameter(client) is NULL\n");
150 _retvm_if(mac_address == NULL, TETHERING_ERROR_INVALID_PARAMETER,
151 "Parameter(mac_address) is NULL\n");
153 __tethering_client_h *si = (__tethering_client_h *)client;
155 *mac_address = strdup(si->mac);
156 if (*mac_address == NULL) {
157 ERR("strdup is failed\n");
158 return TETHERING_ERROR_OUT_OF_MEMORY;
161 return TETHERING_ERROR_NONE;
164 API int tethering_client_get_time(tethering_client_h client, time_t *timestamp)
166 CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
168 _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
169 "Parameter(client) is NULL\n");
170 _retvm_if(timestamp == NULL, TETHERING_ERROR_INVALID_PARAMETER,
171 "Parameter(timestamp) is NULL\n");
174 __tethering_client_h *si = (__tethering_client_h *)client;
178 return TETHERING_ERROR_NONE;