2 * Copyright (c) 2016 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.
19 namespace Tizen.Content.MediaContent
22 /// Provides commands to manage face information in the database.
24 /// <seealso cref="Album"/>
25 /// <since_tizen> 4 </since_tizen>
26 [Obsolete("Deprecated since API11. Will be removed in API13.")]
27 public class FaceInfoCommand : MediaCommand
30 /// Initializes a new instance of the <see cref="FaceInfoCommand"/> class with the specified <see cref="MediaDatabase"/>.
32 /// <param name="database">The <see cref="MediaDatabase"/> that the commands run on.</param>
33 /// <exception cref="ArgumentNullException"><paramref name="database"/> is null.</exception>
34 /// <exception cref="ObjectDisposedException"><paramref name="database"/> has already been disposed.</exception>
35 /// <since_tizen> 4 </since_tizen>
36 [Obsolete("Deprecated since API11. Will be removed in API13.")]
37 public FaceInfoCommand(MediaDatabase database) : base(database)
42 /// Deletes the face information from the database.
44 /// <privilege>http://tizen.org/privilege/content.write</privilege>
45 /// <param name="faceInfoId">The face information ID to delete.</param>
46 /// <returns>true if the matched record was found and deleted, otherwise false.</returns>
47 /// <exception cref="InvalidOperationException">The <see cref="MediaDatabase"/> is disconnected.</exception>
48 /// <exception cref="ObjectDisposedException">The <see cref="MediaDatabase"/> has already been disposed.</exception>
49 /// <exception cref="MediaDatabaseException">An error occurred while executing the command.</exception>
50 /// <exception cref="ArgumentNullException"><paramref name="faceInfoId"/> is null.</exception>
51 /// <exception cref="ArgumentException"><paramref name="faceInfoId"/> is a zero-length string, contains only white space.</exception>
52 /// <exception cref="UnauthorizedAccessException">The caller has no required privilege.</exception>
53 /// <since_tizen> 4 </since_tizen>
54 [Obsolete("Deprecated since API11. Will be removed in API13.")]
55 public bool Delete(string faceInfoId)
59 ValidationUtil.ValidateNotNullOrEmpty(faceInfoId, nameof(faceInfoId));
61 var reader = Select(new SelectArguments { FilterExpression = $"{FaceInfoColumns.Id}='{faceInfoId}'" });
63 if (reader.Read() == false)
68 CommandHelper.Delete(Interop.Face.DeleteFromDb, faceInfoId);
73 /// Retrieves the face information.
75 /// <returns>The <see cref="MediaDataReader{TRecord}"/> containing the results.</returns>
76 /// <exception cref="InvalidOperationException">The <see cref="MediaDatabase"/> is disconnected.</exception>
77 /// <exception cref="ObjectDisposedException">The <see cref="MediaDatabase"/> has already been disposed.</exception>
78 /// <exception cref="MediaDatabaseException">An error occurred while executing the command.</exception>
79 /// <since_tizen> 4 </since_tizen>
80 [Obsolete("Deprecated since API11. Will be removed in API13.")]
81 public MediaDataReader<FaceInfo> Select()
87 /// Retrieves the face information with the <see cref="SelectArguments"/>.
89 /// <param name="filter">The criteria to use to filter. This value can be null.</param>
90 /// <returns>The <see cref="MediaDataReader{TRecord}"/> containing the results.</returns>
91 /// <exception cref="InvalidOperationException">The <see cref="MediaDatabase"/> is disconnected.</exception>
92 /// <exception cref="ObjectDisposedException">The <see cref="MediaDatabase"/> has already been disposed.</exception>
93 /// <exception cref="MediaDatabaseException">An error occurred while executing the command.</exception>
94 /// <since_tizen> 4 </since_tizen>
95 [Obsolete("Deprecated since API11. Will be removed in API13.")]
96 public MediaDataReader<FaceInfo> Select(SelectArguments filter)
100 return CommandHelper.Select(filter, Interop.Face.ForeachFromDb, FaceInfo.FromHandle);
104 /// Updates a tag with the specified tag.
106 /// <privilege>http://tizen.org/privilege/content.write</privilege>
107 /// <param name="faceInfoId">The face information ID to update.</param>
108 /// <param name="tag">The tag value for update.</param>
109 /// <returns>true if the matched record was found and updated, otherwise false.</returns>
110 /// <exception cref="InvalidOperationException">The <see cref="MediaDatabase"/> is disconnected.</exception>
111 /// <exception cref="ObjectDisposedException">The <see cref="MediaDatabase"/> has already been disposed.</exception>
112 /// <exception cref="MediaDatabaseException">An error occurred while executing the command.</exception>
113 /// <exception cref="ArgumentNullException"><paramref name="faceInfoId"/> is null.</exception>
114 /// <exception cref="ArgumentException"><paramref name="faceInfoId"/> is a zero-length string, contains only white space.</exception>
115 /// <exception cref="UnauthorizedAccessException">The caller has no required privilege.</exception>
116 /// <since_tizen> 4 </since_tizen>
117 [Obsolete("Deprecated since API11. Will be removed in API13.")]
118 public bool UpdateTag(string faceInfoId, string tag)
122 ValidationUtil.ValidateNotNullOrEmpty(faceInfoId, nameof(faceInfoId));
126 throw new ArgumentNullException(nameof(tag));
129 var handle = CommandHelper.SelectScalar(Interop.Face.ForeachFromDb, $"{FaceInfoColumns.Id}='{faceInfoId}'",
132 if (handle == IntPtr.Zero)
139 Interop.Face.SetTag(handle, tag).ThrowIfError("Failed to update(setting tag)");
141 Interop.Face.Update(handle).ThrowIfError("Failed to update(executing query)");
146 Interop.Face.Destroy(handle);
151 /// Inserts new face information to the database with the specified media ID, area, orientation.
153 /// <privilege>http://tizen.org/privilege/content.write</privilege>
154 /// <param name="mediaId">The media ID to be associated with the face.</param>
155 /// <param name="area">The region of face in the media.</param>
156 /// <param name="orientation">The orientation of the specified media.</param>
157 /// <returns>The <see cref="FaceInfo"/> containing the results.</returns>
158 /// <exception cref="InvalidOperationException">The <see cref="MediaDatabase"/> is disconnected.</exception>
159 /// <exception cref="ObjectDisposedException">The <see cref="MediaDatabase"/> has already been disposed.</exception>
160 /// <exception cref="MediaDatabaseException">An error occurred while executing the command.</exception>
161 /// <exception cref="ArgumentNullException"><paramref name="mediaId"/> is null. </exception>
162 /// <exception cref="ArgumentException">
163 /// <paramref name="mediaId"/> is a zero-length string, contains only white space.<br/>
165 /// <paramref name="orientation"/> is not valid enumeration.
167 /// <exception cref="UnauthorizedAccessException">The caller has no required privilege.</exception>
168 /// <since_tizen> 6 </since_tizen>
169 [Obsolete("Deprecated since API11. Will be removed in API13.")]
170 public FaceInfo Insert(string mediaId, Rectangle area, Orientation orientation)
172 return Insert(mediaId, area, orientation, null);
176 /// Inserts new face information to the database with the specified media ID, area, orientation, and tag.
178 /// <privilege>http://tizen.org/privilege/content.write</privilege>
179 /// <param name="mediaId">The media ID to be associated with the face.</param>
180 /// <param name="area">The region of face in the media.</param>
181 /// <param name="orientation">The orientation of specified media.</param>
182 /// <param name="tag">The tag value.</param>
183 /// <returns>The <see cref="FaceInfo"/> containing the results.</returns>
184 /// <exception cref="InvalidOperationException">The <see cref="MediaDatabase"/> is disconnected.</exception>
185 /// <exception cref="ObjectDisposedException">The <see cref="MediaDatabase"/> has already been disposed.</exception>
186 /// <exception cref="MediaDatabaseException">An error occurred while executing the command.</exception>
187 /// <exception cref="ArgumentNullException"><paramref name="mediaId"/> is null. </exception>
188 /// <exception cref="ArgumentException">
189 /// <paramref name="mediaId"/> is a zero-length string, contains only white space.<br/>
191 /// <paramref name="orientation"/> is not valid enumeration.
193 /// <exception cref="UnauthorizedAccessException">The caller has no required privilege.</exception>
194 /// <since_tizen> 6 </since_tizen>
195 [Obsolete("Deprecated since API11. Will be removed in API13.")]
196 public FaceInfo Insert(string mediaId, Rectangle area, Orientation orientation, string tag)
200 ValidationUtil.ValidateNotNullOrEmpty(mediaId, nameof(mediaId));
201 ValidationUtil.ValidateEnum(typeof(Orientation), orientation, nameof(orientation));
203 Interop.Face.Create(mediaId, out IntPtr handle).ThrowIfError("Failed to create face handle");
207 Interop.Face.SetFaceRect(handle, area.X, area.Y, area.Width, area.Height).
208 ThrowIfError("Failed to set face area");
210 Interop.Face.SetOrientation(handle, orientation).ThrowIfError("Failed to set face orientation");
214 Interop.Face.SetTag(handle, tag).ThrowIfError("Failed to set face tag");
217 Interop.Face.Insert(handle).ThrowIfError("Failed to insert face information");
219 return new FaceInfo(handle);
223 Interop.Face.Destroy(handle).ThrowIfError("Failed to destroy face handle");