From dc16a7412180b8f0649bd02738162940a4f782a3 Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Thu, 16 Mar 2017 17:03:52 +0900 Subject: [PATCH] Update ContentFilter class Separate collationType by order and condition Change-Id: I32ae6da990eec8c17bbcaefecccba6d0b497fdb1 Signed-off-by: Minje Ahn --- .../Tizen.Content.MediaContent/ContentFilter.cs | 133 ++++++++++++--------- packaging/csapi-media-content.spec | 2 +- 2 files changed, 78 insertions(+), 57 deletions(-) diff --git a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentFilter.cs b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentFilter.cs index 9f4d848..de26f7c 100755 --- a/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentFilter.cs +++ b/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentFilter.cs @@ -101,11 +101,21 @@ namespace Tizen.Content.MediaContent { private IntPtr _filterHandle = IntPtr.Zero; private bool _disposedValue = false; + private ContentCollation _conditionCollate = ContentCollation.Default; + private ContentCollation _orderCollate = ContentCollation.Default; + private ContentOrder _orderType = ContentOrder.Asc; + private string _orderKeyword = null; + private string _conditionMsg = null; internal IntPtr Handle { get { + if (_filterHandle == IntPtr.Zero) + { + throw new ObjectDisposedException(nameof(ContentFilter)); + } + return _filterHandle; } } @@ -120,7 +130,7 @@ namespace Tizen.Content.MediaContent int offset; int count; MediaContentValidator.ThrowIfError( - Interop.Filter.GetOffset(_filterHandle, out offset, out count), "Failed to get offset"); + Interop.Filter.GetOffset(Handle, out offset, out count), "Failed to get offset"); return offset; } @@ -128,7 +138,7 @@ namespace Tizen.Content.MediaContent set { MediaContentValidator.ThrowIfError( - Interop.Filter.SetOffset(_filterHandle, value, this.Count), "Failed to set offset"); + Interop.Filter.SetOffset(Handle, value, this.Count), "Failed to set offset"); } } @@ -148,7 +158,7 @@ namespace Tizen.Content.MediaContent int offset; int count; MediaContentValidator.ThrowIfError( - Interop.Filter.GetOffset(_filterHandle, out offset, out count), "Failed to get count"); + Interop.Filter.GetOffset(Handle, out offset, out count), "Failed to get count"); return count; } @@ -156,7 +166,7 @@ namespace Tizen.Content.MediaContent set { MediaContentValidator.ThrowIfError( - Interop.Filter.SetOffset(_filterHandle, this.Offset, value), "Failed to set count"); + Interop.Filter.SetOffset(Handle, this.Offset, value), "Failed to set count"); } } @@ -167,38 +177,37 @@ namespace Tizen.Content.MediaContent { get { - ContentOrder order; - IntPtr val = IntPtr.Zero; - ContentCollation collate; - try - { - MediaContentValidator.ThrowIfError( - Interop.Filter.GetOrder(_filterHandle, out order, out val, out collate), "Failed to get order"); + return _orderType; + } - return order; - } - finally + set + { + if (_orderKeyword != null) { - Interop.Libc.Free(val); + MediaContentValidator.ThrowIfError( + Interop.Filter.SetOrder(Handle, value, _orderKeyword, _orderCollate), "Failed to set order"); } + + _orderType = value; } } /// - /// The collate type for comparing two strings + /// The search order keyword /// - public ContentCollation CollationType + public string OrderKey { get { + ContentOrder order; IntPtr val = IntPtr.Zero; ContentCollation type; try { MediaContentValidator.ThrowIfError( - Interop.Filter.GetCondition(_filterHandle, out val, out type), "Failed to get collation"); + Interop.Filter.GetOrder(Handle, out order, out val, out type), "Failed to GetOrder for OrderKey"); - return type; + return Marshal.PtrToStringAnsi(val); } finally { @@ -209,7 +218,31 @@ namespace Tizen.Content.MediaContent set { MediaContentValidator.ThrowIfError( - Interop.Filter.SetCondition(_filterHandle, this.Condition, value), "Failed to set collation"); + Interop.Filter.SetOrder(Handle, _orderType, value, _orderCollate), "Failed to set OrderKey"); + + _orderKeyword = value; + } + } + + /// + /// The collate type for comparing two strings + /// + public ContentCollation OrderCollationType + { + get + { + return _orderCollate; + } + + set + { + if (_orderKeyword != null) + { + MediaContentValidator.ThrowIfError( + Interop.Filter.SetOrder(Handle, _orderType, _orderKeyword, value), "Failed to set collation"); + } + + _orderCollate = value; } } @@ -225,7 +258,7 @@ namespace Tizen.Content.MediaContent try { MediaContentValidator.ThrowIfError( - Interop.Filter.GetCondition(_filterHandle, out val, out type), "Failed to get condition"); + Interop.Filter.GetCondition(Handle, out val, out type), "Failed to get condition"); return Marshal.PtrToStringAnsi(val); } @@ -238,53 +271,47 @@ namespace Tizen.Content.MediaContent set { MediaContentValidator.ThrowIfError( - Interop.Filter.SetCondition(_filterHandle, value, this.CollationType), "Failed to set condition"); + Interop.Filter.SetCondition(Handle, value, _conditionCollate), "Failed to set condition"); + + _conditionMsg = value; } } /// - /// Sets the storage id for the given filter. - /// You can use this property when you want to search items only in the specific storage + /// The collate type for comparing two strings /// - public string StorageId + public ContentCollation ConditionCollationType { get { - IntPtr val = IntPtr.Zero; - try - { - MediaContentValidator.ThrowIfError( - Interop.Filter.GetStorage(_filterHandle, out val), "Failed to get condition"); - - return Marshal.PtrToStringAnsi(val); - } - finally - { - Interop.Libc.Free(val); - } + return _conditionCollate; } set { - MediaContentValidator.ThrowIfError( - Interop.Filter.SetStorage(_filterHandle, value), "Failed to set condition"); + if (_conditionMsg != null) + { + MediaContentValidator.ThrowIfError( + Interop.Filter.SetCondition(Handle, _conditionMsg, value), "Failed to set collation"); + } + + _conditionCollate = value; } } /// - /// The search order keyword + /// Sets the storage id for the given filter. + /// You can use this property when you want to search items only in the specific storage /// - public string OrderKey + public string StorageId { get { - ContentOrder order; IntPtr val = IntPtr.Zero; - ContentCollation type; try { MediaContentValidator.ThrowIfError( - Interop.Filter.GetOrder(_filterHandle, out order, out val, out type), "Failed to GetOrder for OrderKey"); + Interop.Filter.GetStorage(Handle, out val), "Failed to get condition"); return Marshal.PtrToStringAnsi(val); } @@ -293,6 +320,12 @@ namespace Tizen.Content.MediaContent Interop.Libc.Free(val); } } + + set + { + MediaContentValidator.ThrowIfError( + Interop.Filter.SetStorage(Handle, value), "Failed to set condition"); + } } /// @@ -301,18 +334,6 @@ namespace Tizen.Content.MediaContent public MediaGroupType GroupType { get; set; } /// - /// SetOrderProperties like OrderType and OrderKey. - /// - /// ordering type - /// Keywords to sort - public void SetOrderProperties(ContentOrder order, string oderKey) - { - MediaContentValidator.ThrowIfError( - Interop.Filter.SetOrder(_filterHandle, order, oderKey, CollationType), "Failed to set order"); - } - - - /// /// Dispose API for closing the internal resources. /// This function can be used to stop all effects started by Vibrate(). /// diff --git a/packaging/csapi-media-content.spec b/packaging/csapi-media-content.spec index 1d0ba47..74088c5 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.9 +Version: 1.0.10 Release: 1 Group: Development/Libraries License: Apache-2.0 -- 2.7.4