Fix the gcov build error
[platform/core/api/tethering.git] / src / tethering_client.c
old mode 100644 (file)
new mode 100755 (executable)
index c8a7cd9..ffbd882
 
 API int tethering_client_clone(tethering_client_h *dest, tethering_client_h origin)
 {
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
+
        _retvm_if(dest == NULL, TETHERING_ERROR_INVALID_PARAMETER,
                        "Parameter(dest) is NULL\n");
+       _retvm_if(origin == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "Parameter(origin) is NULL\n");
 
        __tethering_client_h *si = NULL;
+       __tethering_client_h *source = NULL;
+
+       source = (__tethering_client_h *)origin;
 
        si = malloc(sizeof(__tethering_client_h));
        if (si == NULL) {
@@ -31,8 +38,13 @@ API int tethering_client_clone(tethering_client_h *dest, tethering_client_h orig
                return TETHERING_ERROR_OUT_OF_MEMORY;
        }
 
-       memcpy(si, (__tethering_client_h *)origin,
-                       sizeof(__tethering_client_h));
+       memcpy(si, source, sizeof(__tethering_client_h));
+       si->hostname = g_strdup(source->hostname);
+       if (si->hostname == NULL) {
+               ERR("malloc is failed\n");
+               free(si);
+               return TETHERING_ERROR_OUT_OF_MEMORY;
+       }
 
        *dest = (tethering_client_h)si;
 
@@ -41,9 +53,17 @@ API int tethering_client_clone(tethering_client_h *dest, tethering_client_h orig
 
 API int tethering_client_destroy(tethering_client_h client)
 {
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
+
        _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
                        "Parameter(client) is NULL\n");
 
+       __tethering_client_h *si = NULL;
+
+       si = (__tethering_client_h *)client;
+
+       g_free(si->hostname);
+
        free(client);
 
        return TETHERING_ERROR_NONE;
@@ -51,6 +71,8 @@ API int tethering_client_destroy(tethering_client_h client)
 
 API int tethering_client_get_tethering_type(tethering_client_h client, tethering_type_e *type)
 {
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
+
        _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
                        "Parameter(client) is NULL\n");
        _retvm_if(type == NULL, TETHERING_ERROR_INVALID_PARAMETER,
@@ -63,8 +85,26 @@ API int tethering_client_get_tethering_type(tethering_client_h client, tethering
        return TETHERING_ERROR_NONE;
 }
 
+API int tethering_client_get_tethering_band(tethering_client_h client, tethering_band_e *band)
+{
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
+
+       _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "Parameter(client) is NULL\n");
+       _retvm_if(band == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "Parameter(band) is NULL\n");
+
+       __tethering_client_h *si = (__tethering_client_h *)client;
+
+       *band = si->band;
+
+       return TETHERING_ERROR_NONE;
+}
+
 API int tethering_client_get_name(tethering_client_h client, char **name)
 {
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
+
        _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
                        "Parameter(client) is NULL\n");
        _retvm_if(name == NULL, TETHERING_ERROR_INVALID_PARAMETER,
@@ -83,6 +123,8 @@ API int tethering_client_get_name(tethering_client_h client, char **name)
 
 API int tethering_client_get_ip_address(tethering_client_h client, tethering_address_family_e address_family, char **ip_address)
 {
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
+
        _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
                        "Parameter(client) is NULL\n");
        _retvm_if(ip_address == NULL, TETHERING_ERROR_INVALID_PARAMETER,
@@ -101,6 +143,8 @@ API int tethering_client_get_ip_address(tethering_client_h client, tethering_add
 
 API int tethering_client_get_mac_address(tethering_client_h client, char **mac_address)
 {
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
+
        _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
                        "Parameter(client) is NULL\n");
        _retvm_if(mac_address == NULL, TETHERING_ERROR_INVALID_PARAMETER,
@@ -119,8 +163,12 @@ API int tethering_client_get_mac_address(tethering_client_h client, char **mac_a
 
 API int tethering_client_get_time(tethering_client_h client, time_t *timestamp)
 {
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
+
        _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
                        "Parameter(client) is NULL\n");
+       _retvm_if(timestamp == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "Parameter(timestamp) is NULL\n");
 
 
        __tethering_client_h *si = (__tethering_client_h *)client;