From: Minje Ahn Date: Mon, 5 Oct 2015 05:33:38 +0000 (+0900) Subject: Add new notification for update db X-Git-Tag: accepted/tizen/mobile/20151005.232346^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F05%2F49005%2F1;p=platform%2Fcore%2Fapi%2Fmedia-content.git Add new notification for update db Change-Id: Ib5a1bcfd201a91c9f98e66f25fb203d7cf39d554 Signed-off-by: Minje Ahn --- diff --git a/include/media_content_internal.h b/include/media_content_internal.h index 3d2578b..0921dae 100755 --- a/include/media_content_internal.h +++ b/include/media_content_internal.h @@ -496,6 +496,53 @@ int media_info_set_storage_id(media_info_h media, const char *storage_id); */ int media_storage_get_scan_status(const char *storage_uuid, media_storage_scan_status_e *scan_status); +/* Handle for dbus notification to use multiple callback */ +typedef void *media_content_noti_h; + +/** + * @brief Subscribes notifications of the media DB change. + * @details This function subscribes notifications of the media DB change which are published by the media server or other apps. + * media_content_db_update_cb() function will be called when notification of the media DB change is subscribed. + * + * @since_tizen 2.4 + * + * @param[in] callback The callback to be invoked when the scanning is finished + * @param[in] user_data The user data to be passed to the callback function + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid operation + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied + * + * @see media_content_db_update_cb() + * @see media_content_unset_db_updated_cb_v2() + */ +int media_content_set_db_updated_cb_v2(media_content_noti_h *noti_handle, media_content_db_update_cb callback, void *user_data); + + +/** + * @brief Unsubscribes notifications of the media DB change. + * @details This function unsubscribes notifications of the media DB change which are published by the media server or other apps. + * + * @since_tizen 2.4 + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied + * + * @pre media_content_set_db_updated_cb_v2() + * + * @see media_content_set_db_updated_cb_v2() + */ +int media_content_unset_db_updated_cb_v2(media_content_noti_h noti_handle); + + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/src/media_content.c b/src/media_content.c index 7ba9e05..a980345 100755 --- a/src/media_content.c +++ b/src/media_content.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -1072,3 +1073,51 @@ int media_content_unset_db_updated_cb(void) return _content_error_capi(MEDIA_REGISTER_TYPE, ret); } + +int media_content_set_db_updated_cb_v2(media_content_noti_h *noti_handle, media_content_db_update_cb callback, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_noti_cb_s *noti_info = NULL; + + if (noti_handle == NULL) { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + if (callback == NULL) { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + noti_info = (media_noti_cb_s*)calloc(1, sizeof(media_noti_cb_s)); + if (noti_info == NULL) { + media_content_error("Failed to create noti info"); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + noti_info->update_noti_cb = callback; + noti_info->user_data = user_data; + + ret = media_db_update_subscribe_internal((MediaNotiHandle*)noti_handle, _media_content_db_update_noti_cb, (void *)noti_info); + + return _content_error_capi(MEDIA_REGISTER_TYPE, ret); +} + +void __media_content_clear_user_data(void *user_data) +{ + media_noti_cb_s *noti_info = user_data; + + SAFE_FREE(noti_info); + + return; +} + +int media_content_unset_db_updated_cb_v2(media_content_noti_h noti_handle) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_db_update_unsubscribe_internal((MediaNotiHandle)noti_handle, __media_content_clear_user_data); + + return _content_error_capi(MEDIA_REGISTER_TYPE, ret); +} +