Merge remote-tracking branch 'origin/API4' into tizen_4.0
authorTizenAPI-Bot <tizenapi@samsung.com>
Wed, 2 May 2018 01:11:17 +0000 (10:11 +0900)
committerTizenAPI-Bot <tizenapi@samsung.com>
Wed, 2 May 2018 01:11:17 +0000 (10:11 +0900)
src/ElmSharp/ElmSharp/EvasObject.cs
src/ElmSharp/ElmSharp/ItemObject.cs
src/ElmSharp/ElmSharp/Layout.cs
src/ElmSharp/ElmSharp/Popup.cs
src/ElmSharp/Interop/Interop.Elementary.Item.cs
src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs
src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfileManager.cs
src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAP.cs
src/Tizen.System.Information/RuntimeInfo/TvProductHelper.cs
test/ElmSharp.Test/TC/ItemEvasObjectTest.cs [new file with mode: 0644]

index 7769a9a..f3ceb30 100644 (file)
@@ -1099,6 +1099,7 @@ namespace ElmSharp
                 (Parent as Window)?.RemoveChild(this);
 
                 Interop.Evas.evas_object_del(toBeDeleted);
+                Deleted?.Invoke(this, EventArgs.Empty);
                 Parent = null;
             }
         }
@@ -1139,4 +1140,4 @@ namespace ElmSharp
             _eventStore.Add(item);
         }
     }
-}
\ No newline at end of file
+}
index 6a6342c..ea16c8d 100644 (file)
@@ -81,8 +81,10 @@ namespace ElmSharp
         {
             get
             {
-                if (_trackObject == null)
+                if (_trackObject == null || Interop.Elementary.elm_object_item_track_get(Handle) == 0)
+                {
                     _trackObject = new ItemEvasObject(Handle);
+                }
                 return _trackObject;
             }
         }
@@ -392,7 +394,7 @@ namespace ElmSharp
 
         class ItemEvasObject : EvasObject
         {
-            IntPtr _parent = IntPtr.Zero;
+            IntPtr _trackHandle = IntPtr.Zero;
 
             /// <summary>
             /// Creates and initializes a new instance of the ItemEvasObject class.
@@ -400,8 +402,11 @@ namespace ElmSharp
             /// <param name="parent">IntPtr</param>
             public ItemEvasObject(IntPtr parent) : base()
             {
-                _parent = parent;
-                Realize(null);
+                _trackHandle = Interop.Elementary.elm_object_item_track(parent);
+                if (_trackHandle != IntPtr.Zero)
+                {
+                    Realize(null);
+                }
             }
 
             /// <summary>
@@ -411,7 +416,7 @@ namespace ElmSharp
             /// <returns>Handle IntPtr.</returns>
             protected override IntPtr CreateHandle(EvasObject parent)
             {
-                return Interop.Elementary.elm_object_item_track(_parent);
+                return _trackHandle;
             }
         }
     }
index b2c6f8e..7b129ab 100644 (file)
@@ -179,6 +179,9 @@ namespace ElmSharp
         /// Once the object is appended, it will become a child of the layout.
         /// Its lifetime will be bound to the layout. Whenever the layout dies, the child will be deleted automatically.
         /// </summary>
+        /// <remarks>
+        /// This will only work if the layout edc have box part.
+        /// </remarks>
         /// <param name="part">The part.</param>
         /// <param name="child">The object to append.</param>
         /// <returns>Success is true.</returns>
@@ -194,6 +197,9 @@ namespace ElmSharp
         /// Once the object is prepended, it will become a child of the layout.
         /// Its lifetime will be bound to the layout. Whenever the layout dies, the child will be deleted automatically.
         /// </summary>
+        /// <remarks>
+        /// This will only work if the layout edc have box part.
+        /// </remarks>
         /// <param name="part">The part.</param>
         /// <param name="child">The object to prepend.</param>
         /// <returns>Success is true.</returns>
@@ -208,6 +214,9 @@ namespace ElmSharp
         /// Removes a child from the given part box.
         /// The object will be removed from the box part and its lifetime will not be handled by the layout anymore.
         /// </summary>
+        /// <remarks>
+        /// This will only work if the layout edc have box part.
+        /// </remarks>
         /// <param name="part">The part.</param>
         /// <param name="child">The object to remove.</param>
         /// <returns>Success if true</returns>
@@ -215,13 +224,16 @@ namespace ElmSharp
         public bool BoxRemove(string part, EvasObject child)
         {
             RemoveChild(child);
-            return Interop.Elementary.elm_layout_box_remove(RealHandle, part, child.Handle) != null;
+            return Interop.Elementary.elm_layout_box_remove(RealHandle, part, child.Handle) != IntPtr.Zero;
         }
 
         /// <summary>
         /// Removes all the children from the given part box.
         /// The objects will be removed from the box part and their lifetime will not be handled by the layout anymore.
         /// </summary>
+        /// <remarks>
+        /// This will only work if the layout edc have box part.
+        /// </remarks>
         /// <param name="part">The part.</param>
         /// <param name="clear">If true, then all the objects will be deleted as well, otherwise they will just be removed and will be dangling on the canvas.</param>
         /// <returns>Success if true.</returns>
@@ -237,6 +249,9 @@ namespace ElmSharp
         /// Once the object is inserted, it will become a child of the layout.
         /// Its lifetime will be bound to the layout. Whenever the layout dies, the child will be deleted automatically.
         /// </summary>
+        /// <remarks>
+        /// This will only work if the layout edc have box part.
+        /// </remarks>
         /// <param name="part">The part.</param>
         /// <param name="child">The child object to insert into the box.</param>
         /// <param name="position">The numeric position >=0 to insert the child.</param>
@@ -253,6 +268,9 @@ namespace ElmSharp
         /// Once the object is inserted, it will become child of the layout.
         /// Its lifetime will be bound to the layout. Whenever the layout dies, the child will be deleted automatically.
         /// </summary>
+        /// <remarks>
+        /// This will only work if the layout edc have box part.
+        /// </remarks>
         /// <param name="part">The part.</param>
         /// <param name="child">The child object to insert into the box.</param>
         /// <param name="reference">Another reference object to insert before the box.</param>
@@ -393,4 +411,4 @@ namespace ElmSharp
             return Interop.Elementary.elm_layout_add(parent.Handle);
         }
     }
-}
\ No newline at end of file
+}
index 5372526..0defeed 100755 (executable)
@@ -151,6 +151,9 @@ namespace ElmSharp
         /// <summary>
         /// Sets or gets the wrapping type of content text packed in the content area of Popup widget.
         /// </summary>
+        /// <remarks>
+        /// Popup need to wrap the content text, so not allowing WrapType.None.
+        /// </remarks>
         /// <since_tizen> preview </since_tizen>
         public WrapType ContentTextWrapType
         {
@@ -311,4 +314,4 @@ namespace ElmSharp
             _children.Remove((PopupItem)sender);
         }
     }
-}
\ No newline at end of file
+}
index c0e4f3f..88ae655 100644 (file)
@@ -85,6 +85,9 @@ internal static partial class Interop
         internal static extern IntPtr elm_object_item_track(IntPtr obj);
 
         [DllImport(Libraries.Elementary)]
+        internal static extern int elm_object_item_track_get(IntPtr obj);
+
+        [DllImport(Libraries.Elementary)]
         internal static extern void elm_object_item_untrack(IntPtr obj);
 
         [DllImport(Libraries.Elementary)]
index 5ab232c..16b3aeb 100755 (executable)
@@ -62,7 +62,14 @@ namespace Tizen.Network.Connection
                 {
                     if (_ProfileStateChanged == null)
                     {
-                        ProfileStateChangedStart();
+                        try
+                        {
+                            ProfileStateChangedStart();
+                        } catch (Exception e)
+                        {
+                            Log.Error(Globals.LogTag, "Exception on adding ProfileStateChanged\n" + e.ToString());
+                            return;
+                        }
                     }
                     _ProfileStateChanged += value;
                 }, null);
@@ -75,7 +82,14 @@ namespace Tizen.Network.Connection
                     _ProfileStateChanged -= value;
                     if (_ProfileStateChanged == null)
                     {
-                        ProfileStateChangedStop();
+                        try
+                        {
+                            ProfileStateChangedStop();
+                        }
+                        catch (Exception e)
+                        {
+                            Log.Error(Globals.LogTag, "Exception on removing ProfileStateChanged\n" + e.ToString());
+                        }
                     }
                 }, null);
             }
@@ -85,7 +99,6 @@ namespace Tizen.Network.Connection
         {
             _profileChangedCallback = (ProfileState state, IntPtr userData) =>
             {
-                Log.Info(Globals.LogTag, "***** MOON ProfileStateChanged occur");
                 if (_ProfileStateChanged != null)
                 {
                     _ProfileStateChanged(null, new ProfileStateEventArgs(state));
@@ -97,6 +110,7 @@ namespace Tizen.Network.Connection
             if ((ConnectionError)ret != ConnectionError.None)
             {
                 Log.Error(Globals.LogTag, "It failed to register callback for changing profile state, " + (ConnectionError)ret);
+                ConnectionErrorFactory.ThrowConnectionException(ret);
             }
         }
 
@@ -107,6 +121,7 @@ namespace Tizen.Network.Connection
             if ((ConnectionError)ret != ConnectionError.None)
             {
                 Log.Error(Globals.LogTag, "It failed to unregister callback for changing profile state, " + (ConnectionError)ret);
+                ConnectionErrorFactory.ThrowConnectionException(ret);
             }
         }
 
@@ -137,7 +152,6 @@ namespace Tizen.Network.Connection
 
         private void Dispose(bool disposing)
         {
-            Log.Debug(Globals.LogTag, ">>> ConnectionProfile Dispose with " + disposing);
             if (disposed)
                 return;
 
@@ -157,8 +171,12 @@ namespace Tizen.Network.Connection
 
         private void Destroy()
         {
-            Interop.ConnectionProfile.Destroy(ProfileHandle);
-            ProfileHandle = IntPtr.Zero;
+            int ret = Interop.ConnectionProfile.Destroy(ProfileHandle);
+            if ((ConnectionError)ret == ConnectionError.None)
+            {
+                ProfileHandle = IntPtr.Zero;
+            }
+            
         }
 
         internal void CheckDisposed()
index e205c48..a0d1ae6 100755 (executable)
@@ -80,6 +80,9 @@ namespace Tizen.Network.Connection
         /// <since_tizen> 3 </since_tizen>
         /// <param name="profile">The connection profile object.</param>
         /// <returns>A task indicates whether the ConnectProfileAsync method is done successfully or not.</returns>
+        /// <remarks>
+        /// This method must be called from MainThread.
+        /// </remarks>
         /// <privilege>http://tizen.org/privilege/network.get</privilege>
         /// <privilege>http://tizen.org/privilege/network.set</privilege>
         /// <feature>http://tizen.org/feature/network.telephony</feature>
@@ -104,6 +107,9 @@ namespace Tizen.Network.Connection
         /// <since_tizen> 3 </since_tizen>
         /// <param name="profile">The connection profile object.</param>
         /// <returns>A task indicates whether the DisconnectProfileAsync method is done successfully or not.</returns>
+        /// <remarks>
+        /// This method must be called from MainThread.
+        /// </remarks>
         /// <privilege>http://tizen.org/privilege/network.get</privilege>
         /// <privilege>http://tizen.org/privilege/network.set</privilege>
         /// <feature>http://tizen.org/feature/network.telephony</feature>
@@ -220,6 +226,9 @@ namespace Tizen.Network.Connection
         /// <param name="type">The cellular service type.</param>
         /// <param name="profile">The connection profile object.</param>
         /// <returns>A task indicates whether the SetDefaultCellularProfile method is done successfully or not.</returns>
+        /// <remarks>
+        /// This method must be called from MainThread.
+        /// </remarks>
         /// <privilege>http://tizen.org/privilege/network.get</privilege>
         /// <privilege>http://tizen.org/privilege/network.profile</privilege>
         /// <feature>http://tizen.org/feature/network.telephony</feature>
index cc72ad6..e034626 100755 (executable)
@@ -135,8 +135,12 @@ namespace Tizen.Network.WiFi
             if (_disposed)
                 return;
 
-            Interop.WiFi.AP.Destroy(_apHandle);
-            _apHandle = IntPtr.Zero;
+            Log.Info(Globals.LogTag, "WiFiAP Handle HashCode: " + _apHandle.GetHashCode());
+            int ret = Interop.WiFi.AP.Destroy(_apHandle);
+            if (ret == (int)WiFiError.None)
+            {
+                _apHandle = IntPtr.Zero;
+            }
             _disposed = true;
         }
 
@@ -203,6 +207,9 @@ namespace Tizen.Network.WiFi
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
         /// <returns> A task indicating whether the connect method is done or not.</returns>
+        /// <remarks>
+        /// This method must be called from MainThread.
+        /// </remarks>
         /// <feature>http://tizen.org/feature/network.wifi</feature>
         /// <privilege>http://tizen.org/privilege/network.set</privilege>
         /// <privilege>http://tizen.org/privilege/network.get</privilege>
@@ -214,7 +221,7 @@ namespace Tizen.Network.WiFi
         /// <exception cref="InvalidOperationException">Thrown when the method failed due to an invalid operation.</exception>
         public Task ConnectAsync()
         {
-            Log.Info(Globals.LogTag, "ConnectAsync");
+            Log.Info(Globals.LogTag, "ConnectAsync HashCode: " + _apHandle.GetHashCode());
             if (_disposed)
             {
                 throw new ObjectDisposedException("Invalid AP instance (Object may have been disposed or released)");
@@ -271,6 +278,9 @@ namespace Tizen.Network.WiFi
         /// <since_tizen> 3 </since_tizen>
         /// <param name="info">A WpsInfo instance which is type of WpsPbcInfo or WpsPinInfo.</param>
         /// <returns>A task indicating whether the ConnectWps method is done or not.</returns>
+        /// <remarks>
+        /// This method must be called from MainThread.
+        /// </remarks>
         /// <feature>http://tizen.org/feature/network.wifi</feature>
         /// <privilege>http://tizen.org/privilege/network.profile</privilege>
         /// <privilege>http://tizen.org/privilege/network.get</privilege>
@@ -363,7 +373,8 @@ namespace Tizen.Network.WiFi
         /// <param name="info">A WpsInfo instance which is of type WpsPbcInfo or WpsPinInfo.</param>
         /// <returns>A task which contains Connected access point information.</returns>
         /// <remarks>
-        /// If WpsPinInfo is used, its object has to be constructed with a pin which must be 4 or 8 characters long.
+        /// If WpsPinInfo is used, its object has to be constructed with a pin which must be 4 or 8 characters long. \n
+        /// This method must be called from MainThread.
         /// </remarks>
         /// <feature>http://tizen.org/feature/network.wifi</feature>
         /// <privilege>http://tizen.org/privilege/network.set</privilege>
@@ -452,6 +463,9 @@ namespace Tizen.Network.WiFi
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
         /// <returns> A task indicating whether the disconnect method is done or not.</returns>
+        /// <remarks>
+        /// This method must be called from MainThread.
+        /// </remarks>
         /// <feature>http://tizen.org/feature/network.wifi</feature>
         /// <privilege>http://tizen.org/privilege/network.set</privilege>
         /// <privilege>http://tizen.org/privilege/network.get</privilege>
index 78741eb..aa22978 100755 (executable)
@@ -39,7 +39,7 @@ namespace Tizen.System
             [RuntimeInfoKey.Charger] = 26,
             [RuntimeInfoKey.AutoRotation] = 28,
             [RuntimeInfoKey.Gps] = 21,
-            [RuntimeInfoKey.AudioJackConnector] = 20
+            [RuntimeInfoKey.AudioJackConnector] = 23
         };
 
         private static void CheckTvProduct()
diff --git a/test/ElmSharp.Test/TC/ItemEvasObjectTest.cs b/test/ElmSharp.Test/TC/ItemEvasObjectTest.cs
new file mode 100644 (file)
index 0000000..e485ddc
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * 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;
+using ElmSharp;
+
+namespace ElmSharp.Test
+{
+    class ItemEvasObjectTest : TestCaseBase
+    {
+        public override string TestName => "ItemEvasObjectTest";
+        public override string TestDescription => "To test basic operation of ItemEvasObject";
+
+        public override void Run(Window window)
+        {
+            Conformant conformant = new Conformant(window);
+            conformant.Show();
+
+            Box box = new Box(window)
+            {
+                AlignmentX = -1,
+                AlignmentY = -1,
+                WeightX = 1,
+                WeightY = 1
+            };
+            conformant.SetContent(box);
+            box.Show();
+
+            Label label = new Label(window)
+            {
+                AlignmentX = -1,
+                WeightX = 1,
+                BackgroundColor = Color.White,
+                Text = "Selected"
+            };
+
+            GenList list = new GenList(window)
+            {
+                Homogeneous = true,
+                AlignmentX = -1,
+                AlignmentY = -1,
+                WeightX = 1,
+                WeightY = 1
+            };
+
+            GenItemClass defaultClass = new GenItemClass("default")
+            {
+                GetTextHandler = (obj, part) =>
+                {
+                    return string.Format("{0} - {1}", (string)obj, part);
+                }
+            };
+
+            for (int i = 0; i < 100; i++)
+            {
+                list.Append(defaultClass, string.Format("{0} Item", i));
+            }
+            list.SelectionMode = GenItemSelectionMode.Always;
+            list.ItemSelected += (s, e) =>
+            {
+                Log.Debug((string)(e.Item.Data) + "item selected");
+                Log.Debug("Item Geometry: " + e.Item.TrackObject.Geometry.ToString());
+
+                label.Text = "selected Item Geometry: " + e.Item.TrackObject.Geometry.ToString();
+            };
+
+            label.Show();
+            list.Show();
+
+            box.PackEnd(label);
+            box.PackEnd(list);
+        }
+    }
+}