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))
28 sql = sqlite3_mprintf(INSERT_BOOKMARK_TO_BOOKMARK, media_id, time, thumbnail_path);
29 ret = _content_query_sql(sql);
34 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
35 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
41 int media_bookmark_delete_from_db(int bookmark_id)
43 int ret = MEDIA_CONTENT_ERROR_NONE;
44 char *query_str = NULL;
48 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
49 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
52 query_str = sqlite3_mprintf(DELETE_BOOKMARK_FROM_BOOKMARK, bookmark_id);
54 ret = _content_query_sql(query_str);
56 sqlite3_free(query_str);
61 int media_bookmark_get_bookmark_count_from_db(filter_h filter, int *bookmark_count)
63 int ret = MEDIA_CONTENT_ERROR_NONE;
65 if (bookmark_count == NULL)
67 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
68 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
71 ret = _media_db_get_group_count(filter, MEDIA_GROUP_BOOKMARK, bookmark_count);
76 int media_bookmark_destroy(media_bookmark_h bookmark)
78 int ret = MEDIA_CONTENT_ERROR_NONE;
79 media_bookmark_s *_bookmark = (media_bookmark_s*)bookmark;
83 SAFE_FREE(_bookmark->media_id);
84 SAFE_FREE(_bookmark->thumbnail_path);
86 ret = MEDIA_CONTENT_ERROR_NONE;
90 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
91 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
96 int media_bookmark_clone(media_bookmark_h *dst, media_bookmark_h src)
98 int ret = MEDIA_CONTENT_ERROR_NONE;
102 media_bookmark_s *_src = (media_bookmark_s*)src;
103 media_bookmark_s *_dst = (media_bookmark_s*)calloc(1, sizeof(media_bookmark_s));
104 media_content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
106 _dst->bookmark_id = _src->bookmark_id;
108 if(STRING_VALID(_src->media_id))
110 _dst->media_id = (char*)strdup(_src->media_id);
111 if(_dst->media_id == 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->marked_time = _src->marked_time;
121 if(STRING_VALID(_src->thumbnail_path))
123 _dst->thumbnail_path = (char*)strdup(_src->thumbnail_path);
124 if(_dst->thumbnail_path == NULL)
126 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
127 media_bookmark_destroy((media_bookmark_h)_dst);
128 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
132 *dst = (media_bookmark_h)_dst;
134 ret = MEDIA_CONTENT_ERROR_NONE;
138 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
139 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
145 int media_bookmark_get_bookmark_id(media_bookmark_h bookmark, int *bookmark_id)
147 int ret = MEDIA_CONTENT_ERROR_NONE;
148 media_bookmark_s *_bookmark = (media_bookmark_s*)bookmark;
152 *bookmark_id = _bookmark->bookmark_id;
153 ret = MEDIA_CONTENT_ERROR_NONE;
157 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
158 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
164 int media_bookmark_get_marked_time(media_bookmark_h bookmark, time_t* marked_time)
166 int ret = MEDIA_CONTENT_ERROR_NONE;
167 media_bookmark_s *_bookmark = (media_bookmark_s*)bookmark;
171 *marked_time = _bookmark->marked_time;
172 ret = MEDIA_CONTENT_ERROR_NONE;
176 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
177 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
183 int media_bookmark_get_thumbnail_path(media_bookmark_h bookmark, char **path)
185 int ret = MEDIA_CONTENT_ERROR_NONE;
186 media_bookmark_s *_bookmark = (media_bookmark_s*)bookmark;
190 if(STRING_VALID(_bookmark->thumbnail_path))
192 *path = strdup(_bookmark->thumbnail_path);
193 media_content_retvm_if(*path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
200 ret = MEDIA_CONTENT_ERROR_NONE;
204 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
205 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;