From: Yunhee Seo Date: Wed, 25 Sep 2024 08:12:42 +0000 (+0900) Subject: callback: Enhance API description X-Git-Tag: accepted/tizen/unified/20241006.053304~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F99%2F318299%2F1;p=platform%2Fcore%2Fapi%2Fdevice.git callback: Enhance API description To improve readability and facilitate comprehension, more detailed API descriptions are added. Change-Id: Idf217b7ec85cf2145de96ce32ab6bfeccbc8a8dc Signed-off-by: Yunhee Seo --- diff --git a/include/callback.h b/include/callback.h index afc8fee..29b1bc0 100644 --- a/include/callback.h +++ b/include/callback.h @@ -49,7 +49,7 @@ typedef enum { /** - * @brief Called when a device status is changed. + * @brief Called when a device status is changed (e.g., battery_capacity, display_state, etc). * @details Each device callback has a different output param type. \n * So you need to check below output param before using this function. \n * callback enum output type \n @@ -63,40 +63,84 @@ typedef enum { * @param[out] type The device type to monitor * @param[out] value The changed value * @param[out] user_data The user data passed from the callback registration function + * @see device_add_callback + * @see device_remove_callback */ typedef void (*device_changed_cb)(device_callback_e type, void *value, void *user_data); /** - * @brief Adds a callback to the observing device state. + * @brief Adds a callback to the observing device state (e.g., battery, display, etc). + * @details Registers a callback function to be invoked when a specified device status changes. \n + * When the device status changes, the registered callback function will be called with the new status value as an argument. * @since_tizen 2.3 * @remarks The following feature should be supported for #DEVICE_CALLBACK_DISPLAY_STATE: %http://tizen.org/feature/display. Otherwise #DEVICE_ERROR_NOT_SUPPORTED is returned. * @param[in] type The device type to monitor * @param[in] callback The callback function to add * @param[in] user_data The user data to be passed to the callback function - * @return @c 0 on success, - * otherwise a negative error value + * @return @c 0 on success, otherwise a negative error value * @retval #DEVICE_ERROR_NONE Successful * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter * @retval #DEVICE_ERROR_ALREADY_IN_PROGRESS Operation already * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device + * @code + * #include + * ... + * static void device_display_state_changed_cb(device_callback_e type, void *value, void *user_data) + * { + * int display_state = (int)((intptr_t) value); + * ... + * } + * ... + * int main(void) + * { + * int ret = 0; + * device_add_callback(DEVICE_CALLBACK_DISPLAY_STATE, device_display_state_changed_cb, NULL); + * ... + * } + * ... + * @endcode + * @see device_callback_e + * @see device_changed_cb + * @see device_remove_callback */ int device_add_callback(device_callback_e type, device_changed_cb callback, void *user_data); /** - * @brief Removes a device callback function. + * @brief Removes a device callback function that was added with device_add_callback(). + * @details After calling this, the specified callback function will no longer be called when the device status changes. * @since_tizen 2.3 * @remarks The following feature should be supported for #DEVICE_CALLBACK_DISPLAY_STATE: %http://tizen.org/feature/display. Otherwise #DEVICE_ERROR_NOT_SUPPORTED is returned. * @param[in] type The device type to monitor * @param[in] callback The callback function to remove - * @return @c 0 on success, - * otherwise a negative error value + * @return @c 0 on success, otherwise a negative error value * @retval #DEVICE_ERROR_NONE Successful * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device + * @code + * #include + * ... + * static void device_display_state_changed_cb(device_callback_e type, void *value, void *user_data) + * { + * int display_state = (int)((intptr_t) value); + * ... + * } + * ... + * int main(void) + * { + * int ret = 0; + * device_add_callback(DEVICE_CALLBACK_DISPLAY_STATE, device_display_state_changed_cb, NULL); + * ... + * device_remove_callback(DEVICE_CALLBACK_DISPLAY_STATE, device_display_state_changed_cb); + * } + * ... + * @endcode + * @see device_callback_e + * @see device_changed_cb + * @see device_add_callback */ int device_remove_callback(device_callback_e type, device_changed_cb callback);