1 #pragma warning disable CS1591
3 using System.Runtime.InteropServices;
4 using System.Collections.Generic;
6 using System.ComponentModel;
7 namespace Efl { namespace Ui {
8 /// <summary>An off-screen window to be displayed in a remote process.
9 /// The window is rendered onto an image buffer to be displayed in another process' plug image object. No actual window is created for this type. The window contents can then be sent over a socket so that another process displays it inside a plug image.</summary>
10 [WinSocketNativeInherit]
11 public class WinSocket : Efl.Ui.Win, Efl.Eo.IWrapper
13 ///<summary>Pointer to the native class description.</summary>
14 public override System.IntPtr NativeClass {
16 if (((object)this).GetType() == typeof (WinSocket))
17 return Efl.Ui.WinSocketNativeInherit.GetEflClassStatic();
19 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
22 [System.Runtime.InteropServices.DllImport(efl.Libs.Elementary)] internal static extern System.IntPtr
23 efl_ui_win_socket_class_get();
24 ///<summary>Creates a new instance.</summary>
25 ///<param name="parent">Parent instance.</param>
26 ///<param name="style">The widget style to use. See <see cref="Efl.Ui.Widget.SetStyle"/></param>
27 ///<param name="winName">The window name. See <see cref="Efl.Ui.Win.SetWinName"/></param>
28 ///<param name="winType">The type of the window. See <see cref="Efl.Ui.Win.SetWinType"/></param>
29 ///<param name="accelPreference">The hardware acceleration preference for this window. See <see cref="Efl.Ui.Win.SetAccelPreference"/></param>
30 public WinSocket(Efl.Object parent
31 , System.String style = null, System.String winName = null, Efl.Ui.WinType? winType = null, System.String accelPreference = null) :
32 base(efl_ui_win_socket_class_get(), typeof(WinSocket), parent)
34 if (Efl.Eo.Globals.ParamHelperCheck(style))
35 SetStyle(Efl.Eo.Globals.GetParamHelper(style));
36 if (Efl.Eo.Globals.ParamHelperCheck(winName))
37 SetWinName(Efl.Eo.Globals.GetParamHelper(winName));
38 if (Efl.Eo.Globals.ParamHelperCheck(winType))
39 SetWinType(Efl.Eo.Globals.GetParamHelper(winType));
40 if (Efl.Eo.Globals.ParamHelperCheck(accelPreference))
41 SetAccelPreference(Efl.Eo.Globals.GetParamHelper(accelPreference));
42 FinishInstantiation();
44 ///<summary>Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.</summary>
45 protected WinSocket(System.IntPtr raw) : base(raw)
47 RegisterEventProxies();
49 ///<summary>Internal usage: Constructor to forward the wrapper initialization to the root class that interfaces with native code. Should not be used directly.</summary>
50 protected WinSocket(IntPtr base_klass, System.Type managed_type, Efl.Object parent) : base(base_klass, managed_type, parent) {}
51 ///<summary>Verifies if the given object is equal to this one.</summary>
52 public override bool Equals(object obj)
54 var other = obj as Efl.Object;
57 return this.NativeHandle == other.NativeHandle;
59 ///<summary>Gets the hash code for this object based on the native pointer it points to.</summary>
60 public override int GetHashCode()
62 return this.NativeHandle.ToInt32();
64 ///<summary>Turns the native pointer into a string representation.</summary>
65 public override String ToString()
67 return $"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]";
69 ///<summary>Register the Eo event wrappers making the bridge to C# events. Internal usage only.</summary>
70 protected override void RegisterEventProxies()
72 base.RegisterEventProxies();
74 /// <summary>Create a socket to provide the service for Plug widget.</summary>
75 /// <param name="svcname">The name of the service to be advertised. Ensure that it is unique (when combined with <c>svcnum</c>) otherwise creation may fail.</param>
76 /// <param name="svcnum">A number (any value, 0 being the common default) to differentiate multiple instances of services with the same name.</param>
77 /// <param name="svcsys">A boolean which when true specifies the creation of a system-wide service to which all users can connect, otherwise the service is private to the user id that created it.</param>
78 /// <returns><c>true</c> on success, <c>false</c> otherwise</returns>
79 virtual public bool SocketListen( System.String svcname, int svcnum, bool svcsys) {
80 var _ret_var = Efl.Ui.WinSocketNativeInherit.efl_ui_win_socket_listen_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle), svcname, svcnum, svcsys);
81 Eina.Error.RaiseIfUnhandledException();
84 private static IntPtr GetEflClassStatic()
86 return Efl.Ui.WinSocket.efl_ui_win_socket_class_get();
89 public class WinSocketNativeInherit : Efl.Ui.WinNativeInherit{
90 public new static Efl.Eo.NativeModule _Module = new Efl.Eo.NativeModule(efl.Libs.Elementary);
91 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
93 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
94 var methods = Efl.Eo.Globals.GetUserMethods(type);
95 if (efl_ui_win_socket_listen_static_delegate == null)
96 efl_ui_win_socket_listen_static_delegate = new efl_ui_win_socket_listen_delegate(socket_listen);
97 if (methods.FirstOrDefault(m => m.Name == "SocketListen") != null)
98 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(_Module.Module, "efl_ui_win_socket_listen"), func = Marshal.GetFunctionPointerForDelegate(efl_ui_win_socket_listen_static_delegate)});
99 descs.AddRange(base.GetEoOps(type));
102 public override IntPtr GetEflClass()
104 return Efl.Ui.WinSocket.efl_ui_win_socket_class_get();
106 public static new IntPtr GetEflClassStatic()
108 return Efl.Ui.WinSocket.efl_ui_win_socket_class_get();
112 [return: MarshalAs(UnmanagedType.U1)] private delegate bool efl_ui_win_socket_listen_delegate(System.IntPtr obj, System.IntPtr pd, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String svcname, int svcnum, [MarshalAs(UnmanagedType.U1)] bool svcsys);
115 [return: MarshalAs(UnmanagedType.U1)] public delegate bool efl_ui_win_socket_listen_api_delegate(System.IntPtr obj, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String svcname, int svcnum, [MarshalAs(UnmanagedType.U1)] bool svcsys);
116 public static Efl.Eo.FunctionWrapper<efl_ui_win_socket_listen_api_delegate> efl_ui_win_socket_listen_ptr = new Efl.Eo.FunctionWrapper<efl_ui_win_socket_listen_api_delegate>(_Module, "efl_ui_win_socket_listen");
117 private static bool socket_listen(System.IntPtr obj, System.IntPtr pd, System.String svcname, int svcnum, bool svcsys)
119 Eina.Log.Debug("function efl_ui_win_socket_listen was called");
120 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
121 if(wrapper != null) {
122 bool _ret_var = default(bool);
124 _ret_var = ((WinSocket)wrapper).SocketListen( svcname, svcnum, svcsys);
125 } catch (Exception e) {
126 Eina.Log.Warning($"Callback error: {e.ToString()}");
127 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
131 return efl_ui_win_socket_listen_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), svcname, svcnum, svcsys);
134 private static efl_ui_win_socket_listen_delegate efl_ui_win_socket_listen_static_delegate;