--- /dev/null
+/*
+ * Copyright(c) 2024 Samsung Electronics Co., Ltd.
+ *
+ * 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 global::System.Runtime.InteropServices;
+
+namespace Tizen.NUI
+{
+ internal static partial class Interop
+ {
+ internal static partial class WebDeviceList
+ {
+ [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_DeviceListGet")]
+ public static extern void Delete(HandleRef obj);
+
+ [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_DeviceListGet_GetTypeAndConnect")]
+ public static extern void GetTypeAndConnect(HandleRef obj, out int type, out bool connect, int idx);
+
+ [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_DeviceListGet_GetDeviceId")]
+ public static extern string GetDeviceId(HandleRef obj, int idx);
+
+ [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_DeviceListGet_GetDeviceLabel")]
+ public static extern string GetDeviceLabel(HandleRef obj, int idx);
+ }
+ }
+}
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebSettings_IsExtraFeatureEnabled")]
[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)]
public static extern bool IsExtraFeatureEnabled(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebSettings_SetDefaultAudioInputDevice")]
+ public static extern void SetDefaultAudioInputDevice(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2);
}
}
}
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_FeedMouseWheel")]
public static extern void FeedMouseWheel(global::System.Runtime.InteropServices.HandleRef webViewRef, bool yDirection, int step, int x, int y);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_RegisterDeviceConnectionChangedCallback")]
+ public static extern void RegisterDeviceConnectionChangedCallback(global::System.Runtime.InteropServices.HandleRef webViewRef, global::System.Runtime.InteropServices.HandleRef callbackRef);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_RegisterDeviceListGetCallback")]
+ public static extern void RegisterDeviceListGetCallback(global::System.Runtime.InteropServices.HandleRef webViewRef, global::System.Runtime.InteropServices.HandleRef callbackRef);
}
}
}
--- /dev/null
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ *
+ * 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 System.ComponentModel;
+using System.Collections.Generic;
+
+namespace Tizen.NUI
+{
+ /// <summary>
+ /// WebDeviceList.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class WebDeviceList : Disposable
+ {
+ internal WebDeviceList(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
+ {
+ }
+
+ /// This will not be public opened.
+ /// <param name="swigCPtr"></param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
+ {
+ Interop.WebDeviceList.Delete(swigCPtr);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal void GetTypeAndConnect(out int type, out bool connect, int idx)
+ {
+ Interop.WebDeviceList.GetTypeAndConnect(SwigCPtr, out type, out connect, idx);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal string GetDeviceId(int idx)
+ {
+ string ret = Interop.WebDeviceList.GetDeviceId(SwigCPtr, idx);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal string GetDeviceLabel(int idx)
+ {
+ string ret = Interop.WebDeviceList.GetDeviceLabel(SwigCPtr, idx);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public List<WebDeviceListItem> Get(int size)
+ {
+ List<WebDeviceListItem> ret = new List<WebDeviceListItem>();
+
+ for (int i = 0; i < size; i++)
+ {
+ WebDeviceListItem item = new WebDeviceListItem();
+ item.Id = GetDeviceId(i);
+ item.Label = GetDeviceLabel(i);
+
+ int type = -1;
+ bool connect = false;
+ GetTypeAndConnect(out type, out connect, i);
+ item.Type = (WebMediaDeviceType)type;
+ item.Connected = connect;
+ Tizen.Log.Fatal("NT", $"@@@ [{i}] id={item.Id}, label={item.Label}, type={item.Type}, conn={item.Connected}");
+ ret.Add(item);
+ }
+
+ Tizen.Log.Fatal("NT", $"list size={ret.Count}");
+ return ret;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public struct WebDeviceListItem
+ {
+ public string Id;
+ public string Label;
+ public WebMediaDeviceType Type;
+ public bool Connected;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public enum WebMediaDeviceType
+ {
+ Unknown = -1,
+ AudioInput = 0,
+ VideoInput,
+ AudioOutput,
+ }
+}
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SetDefaultAudioInputDevice(string deviceId)
+ {
+ Interop.WebSettings.SetDefaultAudioInputDevice(SwigCPtr, deviceId);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
}
}
--- /dev/null
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ *
+ * 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 System.ComponentModel;
+
+namespace Tizen.NUI
+{
+ /// <summary>
+ /// Event arguments that DeviceConnectionChanged.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class WebViewDeviceConnectionChangedEventArgs : EventArgs
+ {
+ internal WebViewDeviceConnectionChangedEventArgs(int deviceType)
+ {
+ DeviceType = deviceType;
+ }
+
+ /// <summary>
+ /// Gets Device Type.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public int DeviceType { get; }
+ }
+}
private WebContext webContext = null;
private WebCookieManager webCookieManager = null;
+ private EventHandler<WebViewDeviceConnectionChangedEventArgs> deviceConnectionChangedEventHandler;
+ private webViewDeviceConnectionChangedCallback deviceConnectionChangedCallback;
+
/// <summary>
/// Default constructor to create a WebView.
/// </summary>
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void WebViewUserMediaPermissionRequestCallback(IntPtr permission, string message);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ private delegate void webViewDeviceConnectionChangedCallback(int deviceType);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ private delegate void internalWebViewDeviceListGetCallback(IntPtr list, int size);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ public delegate void WebViewDeviceListGetCallback(WebDeviceList list, int size);
+ private WebViewDeviceListGetCallback deviceListGetCallbackForUser;
/// <summary>
/// Event for the PageLoadStarted signal which can be used to subscribe or unsubscribe the event handler.<br />
}
}
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler<WebViewDeviceConnectionChangedEventArgs> DeviceConnectionChanged
+ {
+ add
+ {
+ if (deviceConnectionChangedEventHandler == null)
+ {
+ deviceConnectionChangedCallback = OnDeviceConnectionChanged;
+ IntPtr ip = Marshal.GetFunctionPointerForDelegate(deviceConnectionChangedCallback);
+ Interop.WebView.RegisterDeviceConnectionChangedCallback(SwigCPtr, new HandleRef(this, ip));
+ }
+ deviceConnectionChangedEventHandler += value;
+ }
+ remove
+ {
+ deviceConnectionChangedEventHandler -= value;
+ if (deviceConnectionChangedEventHandler == null)
+ {
+ IntPtr ip = IntPtr.Zero;
+ Interop.WebView.RegisterUserMediaPermissionRequestCallback(SwigCPtr, new HandleRef(this, ip));
+ }
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SetDeviceListGetCallback(WebViewDeviceListGetCallback callback)
+ {
+ deviceListGetCallbackForUser = callback;
+
+ internalWebViewDeviceListGetCallback cb = deviceListGet;
+ IntPtr ip = Marshal.GetFunctionPointerForDelegate(cb);
+ Interop.WebView.RegisterDeviceListGetCallback(SwigCPtr, new HandleRef(this, ip));
+ }
+
+ private void deviceListGet(IntPtr list, int size)
+ {
+ deviceListGetCallbackForUser?.Invoke(new WebDeviceList(list, true), size);
+ }
/// <summary>
/// Options for searching texts.
userMediaPermissionRequestEventHandler?.Invoke(this, new WebViewUserMediaPermissionRequestEventArgs(new WebUserMediaPermissionRequest(permission, true), message));
}
+ private void OnDeviceConnectionChanged(int deviceType)
+ {
+ deviceConnectionChangedEventHandler?.Invoke(this, new WebViewDeviceConnectionChangedEventArgs(deviceType));
+ }
+
}
}