[MediaContent] Fix grammatical error in description (#943)
[platform/core/csapi/tizenfx.git] / src / Tizen.Content.MediaContent / Tizen.Content.MediaContent / FaceInfoCommand.cs
index 45b4ae2..05b8e84 100644 (file)
@@ -19,33 +19,36 @@ using System;
 namespace Tizen.Content.MediaContent
 {
     /// <summary>
-    /// Provides commands to manage face infos in the database.
+    /// Provides commands to manage face information in the database.
     /// </summary>
     /// <seealso cref="Album"/>
+    /// <since_tizen> 4 </since_tizen>
     public class FaceInfoCommand : MediaCommand
     {
         /// <summary>
         /// Initializes a new instance of the <see cref="FaceInfoCommand"/> class with the specified <see cref="MediaDatabase"/>.
         /// </summary>
-        /// <param name="database">A <see cref="MediaDatabase"/> that the commands run on.</param>
+        /// <param name="database">The <see cref="MediaDatabase"/> that the commands run on.</param>
         /// <exception cref="ArgumentNullException"><paramref name="database"/> is null.</exception>
-        /// <exception cref="ObjectDisposedException"><paramref name="database"/> has already been disposed of.</exception>
+        /// <exception cref="ObjectDisposedException"><paramref name="database"/> has already been disposed.</exception>
+        /// <since_tizen> 4 </since_tizen>
         public FaceInfoCommand(MediaDatabase database) : base(database)
         {
         }
 
         /// <summary>
-        /// Deletes a face info from the database.
+        /// Deletes the face information from the database.
         /// </summary>
         /// <privilege>http://tizen.org/privilege/content.write</privilege>
-        /// <param name="faceInfoId">The face info id to delete.</param>
+        /// <param name="faceInfoId">The face information ID to delete.</param>
         /// <returns>true if the matched record was found and deleted, otherwise false.</returns>
         /// <exception cref="InvalidOperationException">The <see cref="MediaDatabase"/> is disconnected.</exception>
-        /// <exception cref="ObjectDisposedException">The <see cref="MediaDatabase"/> has already been disposed of.</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="ArgumentNullException"><paramref name="faceInfoId"/> is null.</exception>
         /// <exception cref="ArgumentException"><paramref name="faceInfoId"/> is a zero-length string, contains only white space.</exception>
         /// <exception cref="UnauthorizedAccessException">The caller has no required privilege.</exception>
+        /// <since_tizen> 4 </since_tizen>
         public bool Delete(string faceInfoId)
         {
             ValidateDatabase();
@@ -64,25 +67,27 @@ namespace Tizen.Content.MediaContent
         }
 
         /// <summary>
-        /// Retrieves the face info.
+        /// Retrieves the face information.
         /// </summary>
         /// <returns>The <see cref="MediaDataReader{TRecord}"/> containing the results.</returns>
         /// <exception cref="InvalidOperationException">The <see cref="MediaDatabase"/> is disconnected.</exception>
-        /// <exception cref="ObjectDisposedException">The <see cref="MediaDatabase"/> has already been disposed of.</exception>
+        /// <exception cref="ObjectDisposedException">The <see cref="MediaDatabase"/> has already been disposed.</exception>
         /// <exception cref="MediaDatabaseException">An error occurred while executing the command.</exception>
+        /// <since_tizen> 4 </since_tizen>
         public MediaDataReader<FaceInfo> Select()
         {
             return Select(null);
         }
 
         /// <summary>
-        /// Retrieves the face info with <see cref="SelectArguments"/>.
+        /// Retrieves the face information with the <see cref="SelectArguments"/>.
         /// </summary>
         /// <param name="filter">The criteria to use to filter. This value can be null.</param>
         /// <returns>The <see cref="MediaDataReader{TRecord}"/> containing the results.</returns>
         /// <exception cref="InvalidOperationException">The <see cref="MediaDatabase"/> is disconnected.</exception>
-        /// <exception cref="ObjectDisposedException">The <see cref="MediaDatabase"/> has already been disposed of.</exception>
+        /// <exception cref="ObjectDisposedException">The <see cref="MediaDatabase"/> has already been disposed.</exception>
         /// <exception cref="MediaDatabaseException">An error occurred while executing the command.</exception>
+        /// <since_tizen> 4 </since_tizen>
         public MediaDataReader<FaceInfo> Select(SelectArguments filter)
         {
             ValidateDatabase();
@@ -94,16 +99,16 @@ namespace Tizen.Content.MediaContent
         /// Updates a tag with the specified tag.
         /// </summary>
         /// <privilege>http://tizen.org/privilege/content.write</privilege>
-        /// <param name="faceInfoId">The face info id to update.</param>
+        /// <param name="faceInfoId">The face information ID to update.</param>
         /// <param name="tag">The tag value for update.</param>
         /// <returns>true if the matched record was found and updated, otherwise false.</returns>
-        /// <remarks>Only values set in <see cref="PlaylistUpdateValues"/> are updated.</remarks>
         /// <exception cref="InvalidOperationException">The <see cref="MediaDatabase"/> is disconnected.</exception>
-        /// <exception cref="ObjectDisposedException">The <see cref="MediaDatabase"/> has already been disposed of.</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="ArgumentNullException"><paramref name="faceInfoId"/> is null.</exception>
         /// <exception cref="ArgumentException"><paramref name="faceInfoId"/> is a zero-length string, contains only white space.</exception>
         /// <exception cref="UnauthorizedAccessException">The caller has no required privilege.</exception>
+        /// <since_tizen> 4 </since_tizen>
         public bool UpdateTag(string faceInfoId, string tag)
         {
             ValidateDatabase();
@@ -135,5 +140,80 @@ namespace Tizen.Content.MediaContent
                 Interop.Face.Destroy(handle);
             }
         }
+
+        /// <summary>
+        /// Inserts new face information to the database with the specified media ID, area, orientation.
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/content.write</privilege>
+        /// <param name="mediaId">The media ID to be associated with the face.</param>
+        /// <param name="area">The region of face in the media.</param>
+        /// <param name="orientation">The orientation of the specified media.</param>
+        /// <returns>The <see cref="FaceInfo"/> containing the results.</returns>
+        /// <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="ArgumentNullException"><paramref name="mediaId"/> is null. </exception>
+        /// <exception cref="ArgumentException">
+        ///     <paramref name="mediaId"/> is a zero-length string, contains only white space.<br/>
+        ///     -or-<br/>
+        ///     <paramref name="orientation"/> is not valid enumeration.
+        /// </exception>
+        /// <exception cref="UnauthorizedAccessException">The caller has no required privilege.</exception>
+        /// <since_tizen> 6 </since_tizen>
+        public FaceInfo Insert(string mediaId, Rectangle area, Orientation orientation)
+        {
+            return Insert(mediaId, area, orientation, null);
+        }
+
+        /// <summary>
+        /// Inserts new face information to the database with the specified media ID, area, orientation, and tag.
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/content.write</privilege>
+        /// <param name="mediaId">The media ID to be associated with the face.</param>
+        /// <param name="area">The region of face in the media.</param>
+        /// <param name="orientation">The orientation of specified media.</param>
+        /// <param name="tag">The tag value.</param>
+        /// <returns>The <see cref="FaceInfo"/> containing the results.</returns>
+        /// <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="ArgumentNullException"><paramref name="mediaId"/> is null. </exception>
+        /// <exception cref="ArgumentException">
+        ///     <paramref name="mediaId"/> is a zero-length string, contains only white space.<br/>
+        ///     -or-<br/>
+        ///     <paramref name="orientation"/> is not valid enumeration.
+        /// </exception>
+        /// <exception cref="UnauthorizedAccessException">The caller has no required privilege.</exception>
+        /// <since_tizen> 6 </since_tizen>
+        public FaceInfo Insert(string mediaId, Rectangle area, Orientation orientation, string tag)
+        {
+            ValidateDatabase();
+
+            ValidationUtil.ValidateNotNullOrEmpty(mediaId, nameof(mediaId));
+            ValidationUtil.ValidateEnum(typeof(Orientation), orientation, nameof(orientation));
+
+            Interop.Face.Create(mediaId, out IntPtr handle).ThrowIfError("Failed to create face handle");
+
+            try
+            {
+                Interop.Face.SetFaceRect(handle, area.X, area.Y, area.Width, area.Height).
+                    ThrowIfError("Failed to set face area");
+
+                Interop.Face.SetOrientation(handle, orientation).ThrowIfError("Failed to set face orientation");
+
+                if (tag != null)
+                {
+                    Interop.Face.SetTag(handle, tag).ThrowIfError("Failed to set face tag");
+                }
+
+                Interop.Face.Insert(handle).ThrowIfError("Failed to insert face information");
+
+                return new FaceInfo(handle);
+            }
+            finally
+            {
+                Interop.Face.Destroy(handle).ThrowIfError("Failed to destroy face handle");
+            }
+        }
     }
 }