2 * Copyright (c) 2021 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 book_meta_destroy(book_meta_h book)
22 book_meta_s *_book = (book_meta_s *)book;
24 content_retip_if_fail(book);
26 g_free(_book->media_id);
27 g_free(_book->author);
28 g_free(_book->publisher);
29 g_free(_book->subject);
33 return MEDIA_CONTENT_ERROR_NONE;
36 int book_meta_clone(book_meta_h *dst, book_meta_h src)
38 book_meta_s *_src = (book_meta_s *)src;
40 content_retip_if_fail(dst);
41 content_retip_if_fail(src);
43 book_meta_s *_dst = g_new0(book_meta_s, 1);
45 _dst->media_id = g_strdup(_src->media_id);
46 _dst->author = g_strdup(_src->author);
47 _dst->date = g_strdup(_src->date);
48 _dst->publisher = g_strdup(_src->publisher);
49 _dst->subject = g_strdup(_src->subject);
51 *dst = (book_meta_h)_dst;
53 return MEDIA_CONTENT_ERROR_NONE;
56 int book_meta_get_media_id(book_meta_h book, char **media_id)
58 book_meta_s *_book = (book_meta_s *)book;
60 content_retip_if_fail(book);
61 content_retip_if_fail(media_id);
63 *media_id = g_strdup(_book->media_id);
65 return MEDIA_CONTENT_ERROR_NONE;
68 int book_meta_get_subject(book_meta_h book, char **subject)
70 book_meta_s *_book = (book_meta_s *)book;
72 content_retip_if_fail(book);
73 content_retip_if_fail(subject);
75 *subject = g_strdup(_book->subject);
77 return MEDIA_CONTENT_ERROR_NONE;
80 int book_meta_get_author(book_meta_h book, char **author)
82 book_meta_s *_book = (book_meta_s *)book;
84 content_retip_if_fail(book);
85 content_retip_if_fail(author);
87 *author = g_strdup(_book->author);
89 return MEDIA_CONTENT_ERROR_NONE;
92 int book_meta_get_date(book_meta_h book, char **date)
94 book_meta_s *_book = (book_meta_s *)book;
96 content_retip_if_fail(book);
97 content_retip_if_fail(date);
99 *date = g_strdup(_book->date);
101 return MEDIA_CONTENT_ERROR_NONE;
104 int book_meta_get_publisher(book_meta_h book, char **publisher)
106 book_meta_s *_book = (book_meta_s *)book;
108 content_retip_if_fail(book);
109 content_retip_if_fail(publisher);
111 *publisher = g_strdup(_book->publisher);
113 return MEDIA_CONTENT_ERROR_NONE;
116 int book_meta_get_path_with_keyword(const char *keyword, char ***path_list, unsigned int *len)
118 int ret = MEDIA_CONTENT_ERROR_NONE;
119 GList *book_list = NULL;
123 content_retip_if_fail(keyword);
124 content_retip_if_fail(path_list);
125 content_retip_if_fail(len);
127 ret = media_svc_get_book_by_keyword(_content_get_db_handle(), keyword, _content_get_uid(), &book_list);
128 content_retv_if(ret != MS_MEDIA_ERR_NONE, _content_error_capi(ret));
130 result_len = g_list_length(book_list);
131 if (result_len == 0) {
132 content_info("There is no corresponding eBook");
133 return MEDIA_CONTENT_ERROR_NONE;
136 *path_list = g_new0(char *, result_len);
138 for (i = 0; i < result_len; i++)
139 (*path_list)[i] = g_strdup((const gchar *)g_list_nth_data(book_list, i));
141 g_list_free_full(book_list, g_free);
145 return MEDIA_CONTENT_ERROR_NONE;