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>
20 int media_storage_get_storage_info_from_db(const char *storage_id, media_storage_h *storage)
22 int ret = MEDIA_CONTENT_ERROR_NONE;
23 content_warn("DEPRECATION WARNING: media_storage_get_storage_info_from_db() is deprecated and will be removed from next release.");
24 char select_query[DEFAULT_QUERY_SIZE] = {0, };
25 sqlite3_stmt *stmt = NULL;
26 media_storage_s *_storage = NULL;
28 content_retip_if_fail(STRING_VALID(storage_id));
29 content_retip_if_fail(storage);
31 snprintf(select_query, sizeof(select_query), SELECT_STORAGE_INFO_FROM_STORAGE, storage_id);
33 ret = _content_get_result(select_query, &stmt);
34 content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
36 if (sqlite3_step(stmt) == SQLITE_ROW) {
37 _storage = g_new0(media_storage_s, 1);
39 _storage->storage_id = g_strdup(storage_id);
40 _storage->storage_path = g_strdup((const char *)sqlite3_column_text(stmt, 0));
41 _storage->storage_type = (int)sqlite3_column_int(stmt, 1);
43 *storage = (media_storage_h)_storage;
45 content_error("Nonexistent storage id[%s]", storage_id);
46 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
49 SQLITE3_FINALIZE(stmt);
54 int media_storage_get_storage_count_from_db(filter_h filter, int *storage_count)
56 int ret = MEDIA_CONTENT_ERROR_NONE;
57 content_warn("DEPRECATION WARNING: media_storage_get_storage_count_from_db() is deprecated and will be removed from next release.");
60 ret = _media_db_get_group_count(filter, MEDIA_GROUP_STORAGE, storage_count);
62 content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
63 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
69 int media_storage_foreach_storage_from_db(filter_h filter, media_storage_cb callback, void *user_data)
71 int ret = MEDIA_CONTENT_ERROR_NONE;
72 content_warn("DEPRECATION WARNING: media_storage_foreach_storage_from_db() is deprecated and will be removed from next release.");
74 if (callback != NULL) {
76 g_mutex_lock(_content_get_db_mutex());
79 ret = _media_db_get_storage(filter, callback, user_data);
82 g_mutex_unlock(_content_get_db_mutex());
85 content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
86 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
92 int media_storage_get_media_count_from_db(const char *storage_id, filter_h filter, int *media_count)
94 int ret = MEDIA_CONTENT_ERROR_NONE;
95 content_warn("DEPRECATION WARNING: media_storage_get_media_count_from_db() is deprecated and will be removed from next release.");
97 if (STRING_VALID(storage_id) && media_count) {
98 ret = _media_db_get_group_item_count(storage_id, filter, MEDIA_GROUP_STORAGE, media_count);
100 content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
101 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
107 int media_storage_foreach_media_from_db(const char *storage_id, filter_h filter, media_info_cb callback, void *user_data)
109 int ret = MEDIA_CONTENT_ERROR_NONE;
110 content_warn("DEPRECATION WARNING: media_storage_foreach_media_from_db() is deprecated and will be removed from next release.");
112 if ((callback != NULL) && STRING_VALID(storage_id)) {
113 ret = _media_db_get_group_item(storage_id, filter, callback, user_data, MEDIA_GROUP_STORAGE);
115 content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
116 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
122 int media_storage_destroy(media_storage_h storage)
124 int ret = MEDIA_CONTENT_ERROR_NONE;
125 content_warn("DEPRECATION WARNING: media_storage_destroy() is deprecated and will be removed from next release.");
126 media_storage_s *_storage = (media_storage_s*)storage;
128 g_free(_storage->storage_id);
129 g_free(_storage->storage_path);
132 ret = MEDIA_CONTENT_ERROR_NONE;
134 content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
135 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
141 int media_storage_clone(media_storage_h *dst, media_storage_h src)
143 content_warn("DEPRECATION WARNING: media_storage_clone() is deprecated and will be removed from next release.");
144 media_storage_s *_src = (media_storage_s*)src;
146 content_retip_if_fail(dst);
147 content_retip_if_fail(src);
149 media_storage_s *_dst = g_new0(media_storage_s, 1);
151 _dst->storage_id = g_strdup(_src->storage_id);
152 _dst->storage_path = g_strdup(_src->storage_path);
153 _dst->storage_type = _src->storage_type;
155 *dst = (media_storage_h)_dst;
157 return MEDIA_CONTENT_ERROR_NONE;
160 int media_storage_get_id(media_storage_h storage, char **storage_id)
162 content_warn("DEPRECATION WARNING: media_storage_get_id() is deprecated and will be removed from next release.");
163 media_storage_s *_storage = (media_storage_s*)storage;
165 content_retip_if_fail(storage);
166 content_retip_if_fail(storage_id);
168 *storage_id = g_strdup(_storage->storage_id);
170 return MEDIA_CONTENT_ERROR_NONE;
173 int media_storage_get_path(media_storage_h storage, char **storage_path)
175 content_warn("DEPRECATION WARNING: media_storage_get_path() is deprecated and will be removed from next release.");
176 media_storage_s *_storage = (media_storage_s*)storage;
178 content_retip_if_fail(storage);
179 content_retip_if_fail(storage_path);
181 *storage_path = g_strdup(_storage->storage_path);
183 return MEDIA_CONTENT_ERROR_NONE;
186 int media_storage_get_type(media_storage_h storage, media_content_storage_e *storage_type)
188 int ret = MEDIA_CONTENT_ERROR_NONE;
189 content_warn("DEPRECATION WARNING: media_storage_get_type() is deprecated and will be removed from next release. Use storage_get_type_dev() instead.");
190 media_storage_s *_storage = (media_storage_s*)storage;
192 if (_storage && storage_type) {
193 *storage_type = _storage->storage_type;
194 ret = MEDIA_CONTENT_ERROR_NONE;
196 content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
197 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
203 #ifdef _USE_TVPD_MODE
204 int media_storage_get_scan_status(const char *storage_uuid, media_storage_scan_status_e *scan_status)
206 int ret = MEDIA_CONTENT_ERROR_NONE;
207 media_svc_scan_status_type_e status = MEDIA_STORAGE_SCAN_NONE;
209 if (STRING_VALID(storage_uuid)) {
210 ret = media_svc_get_storage_scan_status(_content_get_db_handle(), storage_uuid, &status);
211 if (ret != MS_MEDIA_ERR_NONE) {
212 content_error("media_svc_get_storage_scan_status failed");
213 ret = _content_error_capi(ret);
215 *scan_status = status;
218 content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
219 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;