summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyunho Kang <hhstark.kang@samsung.com>2017-03-20 13:32:27 +0900
committerSemun Lee <sm79.lee@samsung.com>2017-03-21 10:25:20 +0900
commit4783b9a2a943a67f5c38188adcdd8eccade845b2 (patch)
tree8166227f18be2c96a8980968d2ab75d7cc7f92ed
parent65d0ebdb2e9c56d53349da7b5f08b50f24d63e27 (diff)
downloadapplication-4783b9a2a943a67f5c38188adcdd8eccade845b2.tar.gz
application-4783b9a2a943a67f5c38188adcdd8eccade845b2.tar.bz2
application-4783b9a2a943a67f5c38188adcdd8eccade845b2.zip
- Encode - Decode Change-Id: I16dfe77cde61e9bf7624dfa4cc126200b6520a4f Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
-rwxr-xr-xTizen.Applications.Common/Interop/Interop.Bundle.cs6
-rwxr-xr-xTizen.Applications.Common/Tizen.Applications/Bundle.cs47
2 files changed, 53 insertions, 0 deletions
diff --git a/Tizen.Applications.Common/Interop/Interop.Bundle.cs b/Tizen.Applications.Common/Interop/Interop.Bundle.cs
index ab996f0..65c314a 100755
--- a/Tizen.Applications.Common/Interop/Interop.Bundle.cs
+++ b/Tizen.Applications.Common/Interop/Interop.Bundle.cs
@@ -59,6 +59,12 @@ internal static partial class Interop
[DllImport(Libraries.Bundle, EntryPoint = "bundle_foreach")]
internal static extern void Foreach(SafeBundleHandle handle, Iterator iterator, IntPtr userData);
+ [DllImport(Libraries.Bundle, EntryPoint = "bundle_encode")]
+ internal static extern void BundleEncode(SafeBundleHandle handle, out string str, out int len);
+
+ [DllImport(Libraries.Bundle, EntryPoint = "bundle_decode")]
+ internal static extern SafeBundleHandle BundleDecode(string bundleRaw, int len);
+
[DllImport(Libraries.Bundle, EntryPoint = "bundle_dup")]
internal static extern SafeBundleHandle DangerousClone(IntPtr handle);
diff --git a/Tizen.Applications.Common/Tizen.Applications/Bundle.cs b/Tizen.Applications.Common/Tizen.Applications/Bundle.cs
index eafb307..1b56e8e 100755
--- a/Tizen.Applications.Common/Tizen.Applications/Bundle.cs
+++ b/Tizen.Applications.Common/Tizen.Applications/Bundle.cs
@@ -586,6 +586,53 @@ namespace Tizen.Applications
}
/// <summary>
+ /// Decodes an encoded bundle data.
+ /// </summary>
+ /// <param name="bundleRaw">The encoded bundle data. bundleRaw should be return value of Tizen.Applications.Bundle.Encode, otherwise this method will not succeed</param>
+ /// <returns>Decoded Bundle object.</returns>
+ /// <exception cref="System.ArgumentException">Thrown when there is an invalid parameter.</exception>
+ /// <code>
+ /// Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
+ /// string bundleRaw = bundle.Encode();
+ /// Bundle data = bundle.Decode(bundleRaw);
+ /// </code>
+ public static Bundle Decode(string bundleRaw)
+ {
+ SafeBundleHandle handle;
+
+ handle = Interop.Bundle.BundleDecode(bundleRaw, bundleRaw.Length);
+ if (ErrorFacts.GetLastResult() == (int)BundleErrorFactory.BundleError.InvalidParameter)
+ {
+ throw new ArgumentException("Invalid bundle raw");
+ }
+
+ return new Bundle(handle);
+ }
+
+ /// <summary>
+ /// Encodes bundle to string.
+ /// </summary>
+ /// <returns>Encoded Bundle data in string.</returns>
+ /// <exception cref="System.InvalidOperationException">Thrown when out of memory or when the Bundle instance has been disposed.</exception>
+ /// <code>
+ /// Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
+ /// string bundleRaw = bundle.Encode();
+ /// </code>
+ public string Encode()
+ {
+ string bundleRaw;
+ int len;
+
+ Interop.Bundle.BundleEncode(_handle, out bundleRaw, out len);
+ if (ErrorFacts.GetLastResult() == (int)BundleErrorFactory.BundleError.InvalidParameter)
+ {
+ throw new InvalidOperationException("Invalid bundle");
+ }
+
+ return bundleRaw;
+ }
+
+ /// <summary>
/// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
/// </summary>
/// <param name="disposing">If true, disposes any disposable objects. If false, does not dispose disposable objects.</param>