Bundle - Add Factory Method
authorSeungkeun Lee <sngn.lee@samsung.com>
Wed, 6 Apr 2016 06:54:08 +0000 (15:54 +0900)
committerSeungkeun Lee <sngn.lee@samsung.com>
Wed, 6 Apr 2016 06:54:08 +0000 (15:54 +0900)
 - Add Factory Method for Retained bundle
 - Add Constructor parameter for checking ownership

Change-Id: I365c7c18fca50eb2d29c3e65b800ad670f40b837

Tizen.Applications/Interop/Interop.Bundle.cs [changed mode: 0644->0755]
Tizen.Applications/Tizen.Applications.Messages/MessagePort.cs
Tizen.Applications/Tizen.Applications/Application.cs
Tizen.Applications/Tizen.Applications/Bundle.cs [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index cb8d11c..995442e
@@ -50,6 +50,9 @@ internal static partial class Interop
         [DllImport(Libraries.Bundle, EntryPoint = "bundle_foreach")]
         internal static extern void Foreach(IntPtr handle, Iterator iterator, IntPtr userData);
 
+        [DllImport(Libraries.Bundle, EntryPoint = "bundle_dup")]
+        internal static extern IntPtr Clone(IntPtr handle);
+
         internal static class UnsafeCode
         {
             internal static unsafe int AddItem(IntPtr handle, string key, byte[] value, int offset, int count)
index af25363..3d9563b 100755 (executable)
@@ -118,9 +118,8 @@ namespace Tizen.Applications.Messages
                 }
                 _messageCallBack = (int localPortId, string remoteAppId, string remotePortName, bool trusted, IntPtr message, IntPtr userData) =>
                 {
-                    MessageReceivedEventArgs args = new MessageReceivedEventArgs()
-                    {
-                        Message = new Bundle(message)
+                    MessageReceivedEventArgs args = new MessageReceivedEventArgs() {
+                        Message = Bundle.MakeRetainedBundle(message)
                     };
 
                     if (!String.IsNullOrEmpty(remotePortName) && !String.IsNullOrEmpty(remoteAppId))
index a9b653f..5bfdcf0 100755 (executable)
@@ -167,6 +167,7 @@ namespace Tizen.Applications
                 string value = b.GetItem<string>(Interop.AppEvent.EventKeys.LanguageSet);
                 OnLocaleChanged(new LocaleChangedEventArgs { Locale = value });
             }
+            b.Dispose();
         }
     }
 }
old mode 100644 (file)
new mode 100755 (executable)
index ec94b9c..4a3a614
@@ -35,12 +35,19 @@ namespace Tizen.Applications
             _keys = new HashSet<string>();
         }
 
-        internal Bundle(IntPtr handle)
+        static internal Bundle MakeRetainedBundle(IntPtr handle)
+        {
+            IntPtr clonedHandle = Interop.Bundle.Clone(handle);
+            return new Bundle(clonedHandle, true);
+        }
+
+        internal Bundle(IntPtr handle, bool ownership = false)
         {
             if (handle != IntPtr.Zero)
             {
                 _handle = handle;
-                _disposed = true;
+                if (!ownership)
+                    _disposed = true;
                 _keys = new HashSet<string>();
                 Interop.Bundle.Iterator iterator = (string key, int type, IntPtr keyval, IntPtr userData) =>
                 {