From: Minje Ahn Date: Wed, 5 Apr 2017 01:26:15 +0000 (+0900) Subject: Open some APIs X-Git-Tag: submit/trunk/20170823.075128~100^2~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6a79cbe9e86edcd919c011aae530ef80f2b6fa93;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git Open some APIs Open Connect/Disconnect API. Change-Id: I8d7f6569e8bd0030d1be9a4af5d5cb077776b961 Signed-off-by: Minje Ahn --- diff --git a/packaging/csapi-media-content.spec b/packaging/csapi-media-content.spec index ef2815d..0902377 100755 --- a/packaging/csapi-media-content.spec +++ b/packaging/csapi-media-content.spec @@ -1,6 +1,6 @@ Name: csapi-media-content Summary: Tizen Media Content API for C# -Version: 1.0.15 +Version: 1.0.16 Release: 1 Group: Development/Libraries License: Apache-2.0 diff --git a/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentDatabase.cs b/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentDatabase.cs index 02b077a..7e9d548 100755 --- a/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentDatabase.cs +++ b/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentDatabase.cs @@ -43,29 +43,23 @@ namespace Tizen.Content.MediaContent /// public class ContentDatabase { - private bool _isConnected = false; - internal ContentDatabase() - { - } - - internal void ConnectToDB() + /// + /// Connect to the media database to search, insert, remove or modify media information. + /// + /// + /// For information security, disconnect() after use media database. + /// + public static void Connect() { - if (!_isConnected) - { - MediaContentValidator.ThrowIfError(Interop.Content.Connect(), "Connect failed"); - - _isConnected = true; - } + MediaContentValidator.ThrowIfError(Interop.Content.Connect(), "Connect failed"); } - private void DisconnectFromDB() + /// + /// Disconnect from the media database. + /// + public static void Disconnect() { - if (_isConnected) - { - MediaContentValidator.ThrowIfError(Interop.Content.Disconnect(), "Disconnect failed"); - - _isConnected = false; - } + MediaContentValidator.ThrowIfError(Interop.Content.Disconnect(), "Disconnect failed"); } private static readonly Interop.Content.MediaContentDBUpdatedCallback s_contentUpdatedCallback = ( @@ -128,8 +122,6 @@ namespace Tizen.Content.MediaContent groupType = filter.GroupType; } - ConnectToDB(); - if (typeof(T) == typeof(MediaInformation)) { MediaContentValidator.ThrowIfError( @@ -185,7 +177,6 @@ namespace Tizen.Content.MediaContent /// MediaInformation instance for the associated id.It throws Exception for invalid Id. public MediaInformation Select(string id) { - ConnectToDB(); Interop.MediaInformation.SafeMediaInformationHandle mediaHandle; MediaContentValidator.ThrowIfError( Interop.MediaInformation.GetMediaFromDB(id, out mediaHandle), "Failed to get information"); @@ -233,7 +224,6 @@ namespace Tizen.Content.MediaContent /// ContentCollection instance for the associated id.It throws Exception for invalid Id. public T Select(string id) where T : ContentCollection { - ConnectToDB(); ContentCollection result = null; IntPtr handle = IntPtr.Zero; @@ -273,7 +263,6 @@ namespace Tizen.Content.MediaContent /// ContentCollection instance for the associated id.It throws Exception for invalid Id. public T Select(int id) where T : ContentCollection { - ConnectToDB(); ContentCollection result = null; IntPtr handle = IntPtr.Zero; @@ -448,7 +437,6 @@ namespace Tizen.Content.MediaContent /// public IEnumerable SelectAll(ContentFilter filter) { - ConnectToDB(); if (typeof(T) == typeof(MediaInformation)) { IEnumerable mediaList = GetMediaInformations(filter); @@ -496,7 +484,6 @@ namespace Tizen.Content.MediaContent /// List of media private IEnumerable GetMediaInformations(ContentFilter filter) { - ConnectToDB(); IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; List mediaInformationList = new List(); Interop.MediaInformation.MediaInformationCallback callback = (IntPtr mediaHandle, IntPtr userData) => @@ -550,7 +537,6 @@ namespace Tizen.Content.MediaContent /// The MediaInformation to be deleted public void Delete(MediaInformation mediaInfo) { - ConnectToDB(); MediaContentValidator.ThrowIfError( Interop.MediaInformation.Delete(mediaInfo.MediaId), "Failed to remove information"); } @@ -564,7 +550,6 @@ namespace Tizen.Content.MediaContent /// The ContentCollection instance to be deleted public void Delete(ContentCollection contentcollection) { - ConnectToDB(); Type type = contentcollection.GetType(); if (type == typeof(Tag)) @@ -585,14 +570,12 @@ namespace Tizen.Content.MediaContent internal void Delete(MediaBookmark bookmark) { - ConnectToDB(); MediaContentValidator.ThrowIfError( Interop.MediaBookmark.DeleteFromDb(bookmark.Id), "Failed to remove information"); } internal void Delete(MediaFace face) { - ConnectToDB(); MediaContentValidator.ThrowIfError( Interop.Face.DeleteFromDb(face.Id), "Failed to remove face information"); } @@ -604,7 +587,6 @@ namespace Tizen.Content.MediaContent /// The content collection to be updated public void Update(ContentCollection contentCollection) { - ConnectToDB(); Type type = contentCollection.GetType(); if (type == typeof(Tag)) { @@ -633,7 +615,6 @@ namespace Tizen.Content.MediaContent /// The MediaInformation object to be updated public void Update(MediaInformation mediaInfo) { - ConnectToDB(); Type type = mediaInfo.GetType(); if (type == typeof(ImageInformation)) { @@ -672,7 +653,6 @@ namespace Tizen.Content.MediaContent internal void Update(MediaFace face) { - ConnectToDB(); MediaContentValidator.ThrowIfError(Interop.Face.UpdateToDb(face.Handle), "Failed to update DB"); } @@ -683,7 +663,6 @@ namespace Tizen.Content.MediaContent /// The content collection to be inserted public void Insert(ContentCollection contentCollection) { - ConnectToDB(); Type type = contentCollection.GetType(); IntPtr handle = IntPtr.Zero; if (type == typeof(Tag)) @@ -706,14 +685,12 @@ namespace Tizen.Content.MediaContent internal void Insert(string mediaId, uint offset, string thumbnailPath) { - ConnectToDB(); MediaContentValidator.ThrowIfError( Interop.MediaBookmark.InsertToDb(mediaId, offset, thumbnailPath), "Failed to insert information"); } internal void Insert(MediaFace face) { - ConnectToDB(); MediaContentValidator.ThrowIfError( Interop.Face.InsertToDb(((MediaFace)face).Handle), "Failed to insert information"); } diff --git a/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentManager.cs b/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentManager.cs index 44a8a22..acb313b 100755 --- a/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentManager.cs +++ b/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentManager.cs @@ -71,7 +71,6 @@ namespace Tizen.Content.MediaContent /// public static void Scan(string filePath) { - Database.ConnectToDB(); MediaContentValidator.ThrowIfError(Interop.Content.ScanFile(filePath), "Failed scan"); } @@ -82,7 +81,6 @@ namespace Tizen.Content.MediaContent /// the MediaInformation instance about added media path public static MediaInformation AddMediaInformation(string filePath) { - Database.ConnectToDB(); Interop.MediaInformation.SafeMediaInformationHandle mediaInformationHandle; MediaContentValidator.ThrowIfError( Interop.MediaInformation.Insert(filePath, out mediaInformationHandle), "Failed to Insert MediaInformation to DB"); @@ -211,7 +209,6 @@ namespace Tizen.Content.MediaContent /// public static Task AddMediaInformationBatchAsync(IEnumerable filePaths) { - Database.ConnectToDB(); var task = new TaskCompletionSource(); string[] paths = ((List)filePaths).ToArray(); Interop.MediaInformation.MediaInsertCompletedCallback callback = (MediaContentError error, IntPtr userData) => @@ -234,7 +231,6 @@ namespace Tizen.Content.MediaContent /// public static Task AddBurstShotImagesAsync(IEnumerable filePaths) { - Database.ConnectToDB(); var task = new TaskCompletionSource(); string[] paths = ((List)filePaths).ToArray(); Interop.MediaInformation.MediaInsertBurstShotCompletedCallback callback = (MediaContentError error, IntPtr userData) => @@ -256,7 +252,6 @@ namespace Tizen.Content.MediaContent /// The content filter to which media will be matched public static void RemoveMediaInformationBatch(ContentFilter filter) { - Database.ConnectToDB(); IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; MediaContentValidator.ThrowIfError( Interop.MediaInformation.BatchDelete(handle), "Failed to remove items");