summaryrefslogtreecommitdiff
path: root/src/media_bookmark.c
diff options
context:
space:
mode:
authorHyunjun Ko <zzoon.ko@samsung.com>2012-08-21 18:01:56 +0900
committerHyunjun Ko <zzoon.ko@samsung.com>2012-08-21 18:01:56 +0900
commit198987b2e1fcc91d4da409017f870801e0d06664 (patch)
tree744862158b748898c8305fa0ace85c70e8fa93a7 /src/media_bookmark.c
parentaaaa695e5509775ef100360642a02970af7f76a9 (diff)
downloadmedia-content-198987b2e1fcc91d4da409017f870801e0d06664.tar.gz
media-content-198987b2e1fcc91d4da409017f870801e0d06664.tar.bz2
media-content-198987b2e1fcc91d4da409017f870801e0d06664.zip
Tizen 2.0 beta
Diffstat (limited to 'src/media_bookmark.c')
-rwxr-xr-xsrc/media_bookmark.c267
1 files changed, 267 insertions, 0 deletions
diff --git a/src/media_bookmark.c b/src/media_bookmark.c
new file mode 100755
index 0000000..fc64e67
--- /dev/null
+++ b/src/media_bookmark.c
@@ -0,0 +1,267 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+#include <media_content.h>
+#include <media_info_private.h>
+#include <media-svc.h>
+
+int media_bookmark_foreach_bookmark_from_db (filter_h filter, media_bookmark_cb callback, void *user_data);
+int media_bookmark_get_media_id(media_bookmark_h bookmark, char **media_id);
+
+int media_bookmark_insert_to_db(const char *media_id, time_t time, const char *thumbnail_path)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ char *sql = NULL;
+
+ if(STRING_VALID(media_id))
+ {
+ sql = sqlite3_mprintf(INSERT_BOOKMARK_TO_BOOKMARK, media_id, time, thumbnail_path);
+ ret = _content_query_sql(sql);
+ sqlite3_free(sql);
+ }
+ else
+ {
+ media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
+
+ return ret;
+}
+
+int media_bookmark_delete_from_db(int bookmark_id)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ char *query_str = NULL;
+
+ if(bookmark_id < 0)
+ {
+ media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
+
+ query_str = sqlite3_mprintf(DELETE_BOOKMARK_FROM_BOOKMARK, bookmark_id);
+
+ ret = _content_query_sql(query_str);
+
+ sqlite3_free(query_str);
+
+ return ret;
+}
+
+int media_bookmark_get_bookmark_count_from_db(filter_h filter, int *bookmark_count)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+
+ media_content_debug_func();
+
+ ret = _media_db_get_group_count(filter, MEDIA_GROUP_BOOKMARK, bookmark_count);
+
+ return ret;
+}
+
+int media_bookmark_foreach_bookmark_from_db (filter_h filter, media_bookmark_cb callback, void *user_data)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+
+ media_content_debug_func();
+
+ if(callback == NULL)
+ {
+ media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = _media_db_get_bookmark(NULL, filter, callback, user_data);
+
+ return ret;
+}
+
+int media_bookmark_destroy(media_bookmark_h bookmark)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ media_bookmark_s *_bookmark = (media_bookmark_s*)bookmark;
+
+ if(_bookmark)
+ {
+ SAFE_FREE(_bookmark->media_id);
+ SAFE_FREE(_bookmark->thumbnail);
+ free(_bookmark);
+ ret = MEDIA_CONTENT_ERROR_NONE;
+ }
+ else
+ {
+ media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
+
+ return ret;
+}
+int media_bookmark_clone(media_bookmark_h *dst, media_bookmark_h src)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+
+ if((src != NULL))
+ {
+ media_bookmark_s *_src = (media_bookmark_s*)src;
+ media_bookmark_s *_dst = (media_bookmark_s*)calloc(1, sizeof(media_bookmark_s));
+
+ if(NULL == _dst)
+ {
+ media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+ return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+ }
+
+ _dst->bookmark_id = _src->bookmark_id;
+
+ if(STRING_VALID(_src->media_id))
+ {
+ _dst->media_id = (char*)strdup(_src->media_id);
+ if(_dst->media_id == NULL)
+ {
+ media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+ media_bookmark_destroy((media_bookmark_h)_dst);
+ return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+ }
+ }
+
+ _dst->marked_time = _src->marked_time;
+
+ if(STRING_VALID(_src->thumbnail))
+ {
+ _dst->thumbnail = (char*)strdup(_src->thumbnail);
+ if(_dst->thumbnail == NULL)
+ {
+ media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+ media_bookmark_destroy((media_bookmark_h)_dst);
+ return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+ }
+ }
+
+ *dst = (media_bookmark_h)_dst;
+
+ ret = MEDIA_CONTENT_ERROR_NONE;
+ }
+ else
+ {
+ media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
+
+ return ret;
+}
+
+int media_bookmark_get_bookmark_id(media_bookmark_h bookmark, int *bookmark_id)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ media_bookmark_s *_bookmark = (media_bookmark_s*)bookmark;
+
+ if(_bookmark)
+ {
+ *bookmark_id = _bookmark->bookmark_id;
+ ret = MEDIA_CONTENT_ERROR_NONE;
+ }
+ else
+ {
+ media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
+
+ return ret;
+}
+
+int media_bookmark_get_media_id(media_bookmark_h bookmark, char **media_id)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ media_bookmark_s *_bookmark = (media_bookmark_s*)bookmark;
+
+ if(_bookmark)
+ {
+ if(STRING_VALID(_bookmark->media_id))
+ {
+ *media_id = strdup(_bookmark->media_id);
+ if(*media_id == NULL)
+ {
+ media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+ return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+ }
+ }
+ else
+ {
+ *media_id = NULL;
+ }
+
+ ret = MEDIA_CONTENT_ERROR_NONE;
+ }
+ else
+ {
+ media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
+
+ return ret;
+}
+
+int media_bookmark_get_marked_time(media_bookmark_h bookmark, time_t* marked_time)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ media_bookmark_s *_bookmark = (media_bookmark_s*)bookmark;
+
+ if(_bookmark)
+ {
+ *marked_time = _bookmark->marked_time;
+ ret = MEDIA_CONTENT_ERROR_NONE;
+ }
+ else
+ {
+ media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
+
+ return ret;
+}
+
+int media_bookmark_get_thumbnail_path(media_bookmark_h bookmark, char **thumbnail)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ media_bookmark_s *_bookmark = (media_bookmark_s*)bookmark;
+
+ if(_bookmark)
+ {
+ if(STRING_VALID(_bookmark->thumbnail))
+ {
+ *thumbnail = strdup(_bookmark->thumbnail);
+ if(*thumbnail == NULL)
+ {
+ media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+ return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+ }
+ }
+ else
+ {
+ *thumbnail = NULL;
+ }
+
+ ret = MEDIA_CONTENT_ERROR_NONE;
+ }
+ else
+ {
+ media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
+
+ return ret;
+}