Add new notification for update db 05/49005/1 accepted/tizen/mobile/20151005.232346 accepted/tizen/tv/20151005.232356 accepted/tizen/wearable/20151005.232406 submit/tizen/20151005.055644
authorMinje Ahn <minje.ahn@samsung.com>
Mon, 5 Oct 2015 05:33:38 +0000 (14:33 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Mon, 5 Oct 2015 05:33:38 +0000 (14:33 +0900)
Change-Id: Ib5a1bcfd201a91c9f98e66f25fb203d7cf39d554
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
include/media_content_internal.h
src/media_content.c

index 3d2578b..0921dae 100755 (executable)
@@ -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 */
index 7ba9e05..a980345 100755 (executable)
@@ -18,6 +18,7 @@
 #include <media_content.h>
 #include <media_info_private.h>
 #include <media_util_private.h>
+#include <media_content_internal.h>
 
 #include <unicode/uscript.h>
 #include <unicode/uloc.h>
@@ -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);
+}
+