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_name(tethering_client_h client, char **name)
90 CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
92 _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
93 "Parameter(client) is NULL\n");
94 _retvm_if(name == NULL, TETHERING_ERROR_INVALID_PARAMETER,
95 "Parameter(name) is NULL\n");
97 __tethering_client_h *si = (__tethering_client_h *)client;
99 *name = strdup(si->hostname);
101 ERR("strdup is failed\n");
102 return TETHERING_ERROR_OUT_OF_MEMORY;
105 return TETHERING_ERROR_NONE;
108 API int tethering_client_get_ip_address(tethering_client_h client, tethering_address_family_e address_family, char **ip_address)
110 CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
112 _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
113 "Parameter(client) is NULL\n");
114 _retvm_if(ip_address == NULL, TETHERING_ERROR_INVALID_PARAMETER,
115 "Parameter(ip_address) is NULL\n");
117 __tethering_client_h *si = (__tethering_client_h *)client;
119 *ip_address = strdup(si->ip);
120 if (*ip_address == NULL) {
121 ERR("strdup is failed\n");
122 return TETHERING_ERROR_OUT_OF_MEMORY;
125 return TETHERING_ERROR_NONE;
128 API int tethering_client_get_mac_address(tethering_client_h client, char **mac_address)
130 CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
132 _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
133 "Parameter(client) is NULL\n");
134 _retvm_if(mac_address == NULL, TETHERING_ERROR_INVALID_PARAMETER,
135 "Parameter(mac_address) is NULL\n");
137 __tethering_client_h *si = (__tethering_client_h *)client;
139 *mac_address = strdup(si->mac);
140 if (*mac_address == NULL) {
141 ERR("strdup is failed\n");
142 return TETHERING_ERROR_OUT_OF_MEMORY;
145 return TETHERING_ERROR_NONE;
148 API int tethering_client_get_time(tethering_client_h client, time_t *timestamp)
150 CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
152 _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
153 "Parameter(client) is NULL\n");
154 _retvm_if(timestamp == NULL, TETHERING_ERROR_INVALID_PARAMETER,
155 "Parameter(timestamp) is NULL\n");
158 __tethering_client_h *si = (__tethering_client_h *)client;
162 return TETHERING_ERROR_NONE;