Add new APIs for ethernet cable and deprecate wrong APIs 14/119214/4
authorSeonah Moon <seonah1.moon@samsung.com>
Thu, 16 Mar 2017 04:32:38 +0000 (13:32 +0900)
committerseonah moon <seonah1.moon@samsung.com>
Wed, 22 Mar 2017 01:03:45 +0000 (18:03 -0700)
Some APIs have typo in name. It should be modified.
Therefore, new APIs are added and old API is deprecated.
Old APIs will be removed from next release.

Change-Id: I38e41fee9b9eef27ea52cd10ca58991b6245d67d
Signed-off-by: Seonah Moon <seonah1.moon@samsung.com>
CMakeLists.txt
include/net_connection.h
include/net_connection_private.h
src/connection.c

index 1dbc63c..7818ee4 100755 (executable)
@@ -25,7 +25,7 @@ FOREACH(flag ${${fw_name}_CFLAGS})
     SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
 
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -fvisibility=hidden")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -fvisibility=hidden -Wno-error=deprecated-declarations")
 SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
 
 IF("${ARCH}" STREQUAL "arm")
index 59198ac..930cfd3 100755 (executable)
@@ -419,6 +419,7 @@ int connection_get_ethernet_cable_state(connection_h connection, connection_ethe
 
 
 /**
+ * @deprecated Deprecated since 4.0. Use connection_ethernet_cable_state_changed_cb instead.
  * @brief Called when ethernet cable is plugged [in/out].
  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
  * @param[in] state The ethernet cable state (connection_ethernet_cable_state_e)
@@ -428,6 +429,7 @@ typedef void(*connection_ethernet_cable_state_chaged_cb)(connection_ethernet_cab
 
 
 /**
+ * @deprecated Deprecated since 4.0. Use connection_set_ethernet_cable_state_changed_cb() instead.
  * @brief Registers callback for ethernet cable is plugged [in/out] event.
  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
  * @param[in] connection  The handle of connection
@@ -440,10 +442,11 @@ typedef void(*connection_ethernet_cable_state_chaged_cb)(connection_ethernet_cab
  * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
  * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
  */
-int connection_set_ethernet_cable_state_chaged_cb(connection_h connection, connection_ethernet_cable_state_chaged_cb callback, void *user_data);
+int connection_set_ethernet_cable_state_chaged_cb(connection_h connection, connection_ethernet_cable_state_chaged_cb callback, void *user_data) TIZEN_DEPRECATED_API;
 
 
 /**
+ * @deprecated Deprecated since 4.0. Use connection_unset_ethernet_cable_state_changed_cb() instead.
  * @brief Unregisters callback for ethernet cable is plugged [in/out] event.
  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
  * @param[in] connection The handle of connection
@@ -454,7 +457,45 @@ int connection_set_ethernet_cable_state_chaged_cb(connection_h connection, conne
  * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
  * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
  */
-int connection_unset_ethernet_cable_state_chaged_cb(connection_h connection);
+int connection_unset_ethernet_cable_state_chaged_cb(connection_h connection) TIZEN_DEPRECATED_API;
+
+/**
+ * @brief Called when ethernet cable is plugged [in/out].
+ * @since_tizen 4.0
+ * @param[in] state The ethernet cable state (connection_ethernet_cable_state_e)
+ * @param[in] user_data The user data passed to callback registration function
+ */
+typedef void(*connection_ethernet_cable_state_changed_cb)(connection_ethernet_cable_state_e state, void* user_data);
+
+
+/**
+ * @brief Registers callback for ethernet cable is plugged [in/out] event.
+ * @since_tizen 4.0
+ * @param[in] connection  The handle of connection
+ * @param[in] callback  The callback function to be called
+ * @param[in] user_data The user data passed to the callback function
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
+ */
+int connection_set_ethernet_cable_state_changed_cb(connection_h connection, connection_ethernet_cable_state_changed_cb callback, void *user_data);
+
+
+/**
+ * @brief Unregisters callback for ethernet cable is plugged [in/out] event.
+ * @since_tizen 4.0
+ * @param[in] connection The handle of connection
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
+ */
+int connection_unset_ethernet_cable_state_changed_cb(connection_h connection);
 
 
 /**
index d22ea84..5e41cf5 100755 (executable)
@@ -63,6 +63,12 @@ typedef enum {
                        return rv; \
        } while (0)
 
+#define DEPRECATED_LOG(origin, substitution) \
+       do { \
+               LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed " \
+                               "from next release. Use %s() instead", origin, substitution); \
+       } while (0)
+
 #define CONNECTION_LOG(log_level, format, args...) \
        do { \
                switch (log_level) { \
@@ -98,7 +104,7 @@ typedef struct _connection_handle_s {
        connection_type_changed_cb type_changed_callback;
        connection_address_changed_cb ip_changed_callback;
        connection_address_changed_cb proxy_changed_callback;
-       connection_ethernet_cable_state_chaged_cb ethernet_cable_state_changed_callback;
+       connection_ethernet_cable_state_changed_cb ethernet_cable_state_changed_callback;
        void *type_changed_user_data;
        void *ip_changed_user_data;
        void *proxy_changed_user_data;
index d09cb00..0cf5532 100755 (executable)
@@ -375,7 +375,7 @@ static int __connection_set_proxy_changed_callback(connection_h connection,
 }
 
 static int __connection_set_ethernet_cable_state_changed_cb(connection_h connection,
-               connection_ethernet_cable_state_chaged_cb callback, void *user_data)
+               connection_ethernet_cable_state_changed_cb callback, void *user_data)
 {
        connection_handle_s *local_handle = (connection_handle_s *)connection;
 
@@ -763,6 +763,7 @@ EXPORT_API int connection_get_ethernet_cable_state(connection_h connection, conn
 EXPORT_API int connection_set_ethernet_cable_state_chaged_cb(connection_h connection,
                          connection_ethernet_cable_state_chaged_cb callback, void *user_data)
 {
+       DEPRECATED_LOG(__FUNCTION__, "connection_set_ethernet_cable_state_changed_cb");
        CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
 
        if (callback == NULL || !(__connection_check_handle_validity(connection))) {
@@ -770,12 +771,43 @@ EXPORT_API int connection_set_ethernet_cable_state_chaged_cb(connection_h connec
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
+       DEPRECATED_LOG("connection_ethernet_cable_state_chaged_cb",
+                       "connection_ethernet_cable_state_changed_cb");
+
        return __connection_set_ethernet_cable_state_changed_cb(connection,
-                                                       callback, user_data);
+                       (connection_ethernet_cable_state_changed_cb)callback, user_data);
 }
 
 EXPORT_API int connection_unset_ethernet_cable_state_chaged_cb(connection_h connection)
 {
+       DEPRECATED_LOG(__FUNCTION__, "connection_unset_ethernet_cable_state_changed_cb");
+       CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
+
+       if (!(__connection_check_handle_validity(connection))) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
+
+       return __connection_set_ethernet_cable_state_changed_cb(connection,
+                                                       NULL, NULL);
+}
+
+EXPORT_API int connection_set_ethernet_cable_state_changed_cb(connection_h connection,
+                         connection_ethernet_cable_state_changed_cb callback, void *user_data)
+{
+       CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
+
+       if (callback == NULL || !(__connection_check_handle_validity(connection))) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
+
+       return __connection_set_ethernet_cable_state_changed_cb(connection,
+                                                       callback, user_data);
+}
+
+EXPORT_API int connection_unset_ethernet_cable_state_changed_cb(connection_h connection)
+{
        CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
 
        if (!(__connection_check_handle_validity(connection))) {