2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <media_info_private.h>
21 int media_bookmark_insert_to_db(const char *media_id, time_t time, const char *thumbnail_path)
23 int ret = MEDIA_CONTENT_ERROR_NONE;
26 if (STRING_VALID(media_id)) {
27 sql = sqlite3_mprintf(INSERT_BOOKMARK_TO_BOOKMARK, media_id, time, thumbnail_path);
28 ret = _content_query_sql(sql);
29 SQLITE3_SAFE_FREE(sql);
31 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
32 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
38 int media_bookmark_delete_from_db(int bookmark_id)
40 int ret = MEDIA_CONTENT_ERROR_NONE;
41 char *query_str = NULL;
43 if (bookmark_id < 0) {
44 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
45 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
48 query_str = sqlite3_mprintf(DELETE_BOOKMARK_FROM_BOOKMARK, bookmark_id);
50 ret = _content_query_sql(query_str);
52 SQLITE3_SAFE_FREE(query_str);
57 int media_bookmark_get_bookmark_count_from_db(filter_h filter, int *bookmark_count)
59 int ret = MEDIA_CONTENT_ERROR_NONE;
61 if (bookmark_count == NULL) {
62 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
63 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
66 ret = _media_db_get_group_count(filter, MEDIA_GROUP_BOOKMARK, bookmark_count);
71 int media_bookmark_destroy(media_bookmark_h bookmark)
73 int ret = MEDIA_CONTENT_ERROR_NONE;
74 media_bookmark_s *_bookmark = (media_bookmark_s*)bookmark;
77 SAFE_FREE(_bookmark->media_id);
78 SAFE_FREE(_bookmark->thumbnail_path);
80 ret = MEDIA_CONTENT_ERROR_NONE;
82 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
83 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
88 int media_bookmark_clone(media_bookmark_h *dst, media_bookmark_h src)
90 int ret = MEDIA_CONTENT_ERROR_NONE;
93 media_bookmark_s *_src = (media_bookmark_s*)src;
94 media_bookmark_s *_dst = (media_bookmark_s*)calloc(1, sizeof(media_bookmark_s));
95 media_content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
97 _dst->bookmark_id = _src->bookmark_id;
99 if (STRING_VALID(_src->media_id)) {
100 _dst->media_id = (char *)strdup(_src->media_id);
101 if (_dst->media_id == NULL) {
102 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
103 media_bookmark_destroy((media_bookmark_h)_dst);
104 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
108 _dst->marked_time = _src->marked_time;
110 if (STRING_VALID(_src->thumbnail_path)) {
111 _dst->thumbnail_path = (char*)strdup(_src->thumbnail_path);
112 if (_dst->thumbnail_path == NULL) {
113 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
114 media_bookmark_destroy((media_bookmark_h)_dst);
115 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
119 *dst = (media_bookmark_h)_dst;
121 ret = MEDIA_CONTENT_ERROR_NONE;
123 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
124 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
130 int media_bookmark_get_bookmark_id(media_bookmark_h bookmark, int *bookmark_id)
132 int ret = MEDIA_CONTENT_ERROR_NONE;
133 media_bookmark_s *_bookmark = (media_bookmark_s*)bookmark;
136 *bookmark_id = _bookmark->bookmark_id;
137 ret = MEDIA_CONTENT_ERROR_NONE;
139 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
140 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
146 int media_bookmark_get_marked_time(media_bookmark_h bookmark, time_t* marked_time)
148 int ret = MEDIA_CONTENT_ERROR_NONE;
149 media_bookmark_s *_bookmark = (media_bookmark_s*)bookmark;
152 *marked_time = _bookmark->marked_time;
153 ret = MEDIA_CONTENT_ERROR_NONE;
155 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
156 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
162 int media_bookmark_get_thumbnail_path(media_bookmark_h bookmark, char **path)
164 int ret = MEDIA_CONTENT_ERROR_NONE;
165 media_bookmark_s *_bookmark = (media_bookmark_s*)bookmark;
168 if (STRING_VALID(_bookmark->thumbnail_path)) {
169 *path = strdup(_bookmark->thumbnail_path);
170 media_content_retvm_if(*path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
175 ret = MEDIA_CONTENT_ERROR_NONE;
177 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
178 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;