/* * Copyright (c) 2016 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; namespace Tizen.Content.MediaContent { /// /// Provides commands to manage folders and query related media items in the database. /// /// 4 public class FolderCommand : MediaCommand { /// /// Initializes a new instance of the class with the specified . /// /// The that the commands run on. /// is null. /// has already been disposed. /// 4 public FolderCommand(MediaDatabase database) : base(database) { } /// /// Retrieves the number of folders. /// /// The number of folders. /// The is disconnected. /// The has already been disposed. /// An error occurred while executing the command. /// 4 public int Count() { return Count(null); } /// /// Retrieves the number of folders with the . /// /// The criteria to use to filter. This value can be null. /// The number of folders. /// The is disconnected. /// The has already been disposed. /// An error occurred while executing the command. /// 4 public int Count(CountArguments arguments) { ValidateDatabase(); return CommandHelper.Count(Interop.Folder.GetFolderCountFromDb, arguments); } /// /// Retrieves the folders. /// /// The containing the results. /// The is disconnected. /// The has already been disposed. /// An error occurred while executing the command. /// 4 public MediaDataReader Select() { return Select(arguments: null); } /// /// Retrieves the folders with the . /// /// The criteria to use to filter. This value can be null. /// The containing the results. /// The is disconnected. /// The has already been disposed. /// An error occurred while executing the command. /// 4 public MediaDataReader Select(SelectArguments arguments) { ValidateDatabase(); return CommandHelper.Select(arguments, Interop.Folder.ForeachFolderFromDb, Folder.FromHandle); } /// /// Retrieves the folder. /// /// The folder ID to query with. /// The instance if the matched record was found in the database, otherwise null. /// The is disconnected. /// The has already been disposed. /// An error occurred while executing the command. /// is null. /// is a zero-length string, contains only white space. /// 4 public Folder Select(string folderId) { ValidateDatabase(); ValidationUtil.ValidateNotNullOrEmpty(folderId, nameof(folderId)); Interop.Folder.GetFolderFromDb(folderId, out var handle).ThrowIfError("Failed to query"); if (handle == IntPtr.Zero) { return null; } try { return new Folder(handle); } finally { Interop.Folder.Destroy(handle); } } /// /// Retrieves the number of media information under the folder. /// /// The ID of the folder to count media in the folder. /// The number of media information. /// The is disconnected. /// The has already been disposed. /// An error occurred while executing the command. /// is null. /// is a zero-length string, contains only white space. /// 4 public int CountMedia(string folderId) { return CountMedia(folderId, null); } /// /// Retrieves the number of media information under the folder with the . /// /// The ID of the folder to count media in the folder. /// The criteria to use to filter. This value can be null. /// The number of media information. /// The is disconnected. /// The has already been disposed. /// An error occurred while executing the command. /// is null. /// is a zero-length string, contains only white space. /// 4 public int CountMedia(string folderId, CountArguments arguments) { ValidateDatabase(); ValidationUtil.ValidateNotNullOrEmpty(folderId, nameof(folderId)); return CommandHelper.Count(Interop.Folder.GetMediaCountFromDb, folderId, arguments); } /// /// Retrieves the media information under the folder. /// /// The ID of the folder to select media in the folder. /// The containing the results. /// The is disconnected. /// The has already been disposed. /// An error occurred while executing the command. /// is null. /// is a zero-length string, contains only white space. /// 4 public MediaDataReader SelectMedia(string folderId) { return SelectMedia(folderId, null); } /// /// Retrieves the media information under the folder with the . /// /// The ID of the folder to select media in the folder. /// The criteria to use to filter. This value can be null. /// The containing the results. /// The is disconnected. /// The has already been disposed. /// An error occurred while executing the command. /// is null. /// is a zero-length string, contains only white space. /// 4 public MediaDataReader SelectMedia(string folderId, SelectArguments filter) { ValidateDatabase(); ValidationUtil.ValidateNotNullOrEmpty(folderId, nameof(folderId)); return CommandHelper.SelectMedia(Interop.Folder.ForeachMediaFromDb, folderId, filter); } } }