[NUI.WindowSystem] Add new API GetSourceMimetypes of KVMService
authorJunseok Kim <juns.kim@samsung.com>
Fri, 26 Jan 2024 13:35:11 +0000 (22:35 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Mon, 5 Feb 2024 04:08:45 +0000 (13:08 +0900)
KVMService.GetSourceMimetypes() returns mimetype list that current drag source offered.

src/Tizen.NUI.WindowSystem/src/internal/Interop/Interop.KVMService.cs
src/Tizen.NUI.WindowSystem/src/public/KVMService.cs
test/NUIWindowKVMSample/NUIWindowKVMSample.cs

index 4fc52fd..1429838 100644 (file)
@@ -25,6 +25,12 @@ namespace Tizen.NUI.WindowSystem.Shell
             [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_receive_drag_data")]
             internal static extern int ReceiveDragData(IntPtr kvmService, string mimeType);
 
+            [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_get_source_mimetypes")]
+            internal static extern int GetSourceMimetypes(
+                IntPtr kvmService,
+                out string[] mimeTypes,
+                out int count);
+
             [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_secondary_selection_set")]
             internal static extern int SetSecondarySelection(IntPtr kvmService);
 
index ba94e05..d67b516 100644 (file)
@@ -17,6 +17,7 @@
 
 using System;
 using System.ComponentModel;
+using System.Collections.Generic;
 
 namespace Tizen.NUI.WindowSystem.Shell
 {
@@ -209,6 +210,23 @@ namespace Tizen.NUI.WindowSystem.Shell
         }
 
         /// <summary>
+        /// Requests to receive the mimetype list of drag source.
+        /// </summary>
+        /// <returns>
+        /// The list of mimetype.
+        /// If there are no mimetype, returns null.
+        /// </returns>
+        /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
+        public List<string> GetSourceMimetypes()
+        {
+            int res = Interop.KVMService.GetSourceMimetypes(_kvmService, out string[] mimetypes, out int mimeTypeCount);
+            _tzsh.ErrorCodeThrow(res);
+
+            if (mimetypes == null) return null;
+            return new List<string>(mimetypes);
+        }
+
+        /// <summary>
         /// Requests to set KVM window as secondary selection window.
         /// The request name has typo and will remove soon.
         /// Please use SetSecondarySelection.
index 176cd66..52cdb4c 100644 (file)
@@ -148,9 +148,17 @@ namespace NUIWindowKVMSample
         {
             Log.Debug("KVMSample", "Tizen KVM: Drag started");
 
+            List<string> mimeTypes;
+            mimeTypes = kvmService.GetSourceMimetypes();
+            if (mimeTypes == null)
+                Log.Debug("KVMSample", "Tizen KVM: There're no Source mimetypes");
+            else
+                Log.Debug("KVMSample", "Tizen KVM: Source mimetypes: " + string.Join(", ", mimeTypes));
+            string mimeType = mimeTypes[0];
+
             // Request the drag data to the Display server.
             // The drag data can get at DnD Listener (OnDnDEvent function)
-            kvmService.ReceiveDragData("text/plain");
+            kvmService.ReceiveDragData(mimeType);
         }
 
         private void OnDragEnded(object sender, EventArgs e)