--- /dev/null
+/*
+ * Copyright (c) 2021 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.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using Tizen.Content.MediaContent;
+
+internal static partial class Interop
+{
+ internal static partial class BookInfo
+ {
+ [DllImport(Libraries.MediaContent, EntryPoint = "book_meta_destroy")]
+ internal static extern MediaContentError Destroy(IntPtr handle);
+
+ [DllImport(Libraries.MediaContent, EntryPoint = "book_meta_get_media_id")]
+ internal static extern MediaContentError GetMediaId(IntPtr handle, out IntPtr mediaId);
+
+ [DllImport(Libraries.MediaContent, EntryPoint = "book_meta_get_subject")]
+ internal static extern MediaContentError GetSubject(IntPtr handle, out IntPtr subject);
+
+ [DllImport(Libraries.MediaContent, EntryPoint = "book_meta_get_author")]
+ internal static extern MediaContentError GetAuthor(IntPtr handle, out IntPtr author);
+
+ [DllImport(Libraries.MediaContent, EntryPoint = "book_meta_get_date")]
+ internal static extern MediaContentError GetDate(IntPtr handle, out IntPtr date);
+
+ [DllImport(Libraries.MediaContent, EntryPoint = "book_meta_get_publisher")]
+ internal static extern MediaContentError GetPublisher(IntPtr handle, out IntPtr publisher);
+
+ [DllImport(Libraries.MediaContent, EntryPoint = "book_meta_get_path_with_keyword")]
+ internal static extern MediaContentError GetPathByKeyword(string keyword, out IntPtr path, out uint length);
+ }
+}
[DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_audio")]
internal static extern MediaContentError GetAudio(MediaInfoHandle handle, out IntPtr audioHandle);
+ [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_book")]
+ internal static extern MediaContentError GetBook(MediaInfoHandle handle, out IntPtr bookHandle);
+
[DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_media_id")]
internal static extern MediaContentError GetMediaId(MediaInfoHandle mediaInformationHandle, out IntPtr mediaId);
</PropertyGroup>
<ItemGroup>
+ <ProjectReference Include="..\Tizen.Multimedia\Tizen.Multimedia.csproj" />
<ProjectReference Include="..\Tizen.System.Storage\Tizen.System.Storage.csproj" />
<ProjectReference Include="..\Tizen\Tizen.csproj" />
<ProjectReference Include="..\Tizen.Log\Tizen.Log.csproj" />
--- /dev/null
+/*
+ * Copyright (c) 2021 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.
+ */
+
+using System;
+using System.Diagnostics;
+
+namespace Tizen.Content.MediaContent
+{
+ /// <summary>
+ /// Represents the book information for the media.
+ /// </summary>
+ /// <since_tizen> 9 </since_tizen>
+ public class BookInfo : MediaInfo
+ {
+ internal BookInfo(Interop.MediaInfoHandle handle) : base(handle)
+ {
+ IntPtr bookHandle = IntPtr.Zero;
+
+ try
+ {
+ Interop.MediaInfo.GetBook(handle, out bookHandle).ThrowIfError("Failed to retrieve data");
+
+ Debug.Assert(bookHandle != IntPtr.Zero);
+
+ Subject = InteropHelper.GetString(bookHandle, Interop.BookInfo.GetSubject);
+ Author = InteropHelper.GetString(bookHandle, Interop.BookInfo.GetAuthor);
+ DatePublished = InteropHelper.GetString(bookHandle, Interop.BookInfo.GetDate);
+ Publisher = InteropHelper.GetString(bookHandle, Interop.BookInfo.GetPublisher);
+ }
+ finally
+ {
+ Interop.BookInfo.Destroy(bookHandle).ThrowIfError("Failed to destroy book handle");
+ }
+ }
+
+ /// <summary>
+ /// Gets the subject of the book.
+ /// </summary>
+ /// <value>The subject.</value>
+ /// <since_tizen> 9 </since_tizen>
+ public string Subject { get; }
+
+ /// <summary>
+ /// Gets the author of the book.
+ /// </summary>
+ /// <value>The author.</value>
+ /// <since_tizen> 9 </since_tizen>
+ public string Author { get; }
+
+ /// <summary>
+ /// Gets the published date, formatted as a string.
+ /// </summary>
+ /// <value>The published date.</value>
+ /// <since_tizen> 9 </since_tizen>
+ public string DatePublished { get; }
+
+ /// <summary>
+ /// Gets the publisher of the book.
+ /// </summary>
+ /// <value>The publisher.</value>
+ /// <since_tizen> 9 </since_tizen>
+ public string Publisher { get; }
+ }
+}
/// <summary>
/// The type of other.
/// </summary>
- Other = 4
+ Other = 4,
+
+ /// <summary>
+ /// The type of book.
+ /// </summary>
+ /// <seealso cref="BookInfo"/>
+ /// <since_tizen> 9 </since_tizen>
+ Book = 5
}
/// <summary>
case MediaType.Video:
return new VideoInfo(handle);
+
+ case MediaType.Book:
+ return new BookInfo(handle);
}
return new MediaInfo(handle);
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Tizen.System;
}
/// <summary>
+ /// Retrieves all matched ebook paths with given <paramref name="keyword"/>.
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/mediastorage</privilege>
+ /// <privilege>http://tizen.org/privilege/externalstorage</privilege>
+ /// <param name="keyword">The keyword to search.</param>
+ /// <returns>A list of ebook paths which contain <paramref name="keyword"/>.</returns>
+ /// <exception cref="ArgumentNullException"><paramref name="keyword"/> is null.</exception>
+ /// <exception cref="InvalidOperationException">The <see cref="MediaDatabase"/> is disconnected.</exception>
+ /// <exception cref="ObjectDisposedException">The <see cref="MediaDatabase"/> has already been disposed.</exception>
+ /// <exception cref="MediaDatabaseException">An error occurred while executing the command.</exception>
+ /// <exception cref="UnauthorizedAccessException">The caller has no required privilege.</exception>
+ /// <since_tizen> 9 </since_tizen>
+ public MediaDataReader<string> SelectEbookPath(string keyword)
+ {
+ ValidateDatabase();
+
+ IntPtr path = IntPtr.Zero;
+ uint length = 0;
+
+ ValidationUtil.ValidateNotNullOrEmpty(keyword, nameof(keyword));
+
+ try
+ {
+ Interop.BookInfo.GetPathByKeyword(keyword, out path, out length).
+ ThrowIfError("Failed to get path by keyword");
+
+ var list = new List<string>();
+ var current = path;
+ for (int i = 0; i < length; i++)
+ {
+ list.Add(Marshal.PtrToStringAnsi(Marshal.ReadIntPtr(current)));
+ current = (IntPtr)((long)current + Marshal.SizeOf(typeof(IntPtr)));
+ }
+
+ return new MediaDataReader<string>(list);
+ }
+ finally
+ {
+ var current = path;
+ for (int i = 0; i < length; i++)
+ {
+ Tizen.Multimedia.LibcSupport.Free(Marshal.ReadIntPtr(current));
+ current = (IntPtr)((long)current + Marshal.SizeOf(typeof(IntPtr)));
+ }
+ }
+ }
+
+ /// <summary>
/// Deletes the media from the database.
/// </summary>
/// <privilege>http://tizen.org/privilege/content.write</privilege>
using System.Runtime.CompilerServices;
+[assembly: InternalsVisibleTo("Tizen.Content.MediaContent, " + PublicKey.Value)]
+
[assembly: InternalsVisibleTo("Tizen.Multimedia.AudioIO, " + PublicKey.Value)]
[assembly: InternalsVisibleTo("Tizen.Multimedia.Camera, " + PublicKey.Value)]