[Bluetooth][Non-ACR] Fix no data exception issue (#787)
[platform/core/csapi/tizenfx.git] / internals / src / EflSharp / EflSharp / efl_ui_selection.eo.cs
1 #pragma warning disable CS1591
2 using System;
3 using System.Runtime.InteropServices;
4 using System.Collections.Generic;
5 using System.Linq;
6 using System.ComponentModel;
7 namespace Efl { namespace Ui { 
8 /// <summary>Efl Ui Selection class</summary>
9 [SelectionNativeInherit]
10 public interface Selection : 
11    Efl.Eo.IWrapper, IDisposable
12 {
13    /// <summary>Set the selection data to the object</summary>
14 /// <param name="type">Selection Type</param>
15 /// <param name="format">Selection Format</param>
16 /// <param name="data"></param>
17 /// <param name="seat">Specified seat for multiple seats case.</param>
18 /// <returns>Future for tracking when the selection is lost</returns>
19  Eina.Future SetSelection( Efl.Ui.SelectionType type,  Efl.Ui.SelectionFormat format,  Eina.Slice data,   uint seat);
20    /// <summary>Get the data from the object that has selection</summary>
21 /// <param name="type">Selection Type</param>
22 /// <param name="format">Selection Format</param>
23 /// <param name="data_func">Data ready function pointer</param>
24 /// <param name="seat">Specified seat for multiple seats case.</param>
25 /// <returns></returns>
26  void GetSelection( Efl.Ui.SelectionType type,  Efl.Ui.SelectionFormat format,  Efl.Ui.SelectionDataReady data_func,   uint seat);
27    /// <summary>Clear the selection data from the object</summary>
28 /// <param name="type">Selection Type</param>
29 /// <param name="seat">Specified seat for multiple seats case.</param>
30 /// <returns></returns>
31  void ClearSelection( Efl.Ui.SelectionType type,   uint seat);
32    /// <summary>Determine whether the selection data has owner</summary>
33 /// <param name="type">Selection type</param>
34 /// <param name="seat">Specified seat for multiple seats case.</param>
35 /// <returns>EINA_TRUE if there is object owns selection, otherwise EINA_FALSE</returns>
36 bool HasOwner( Efl.Ui.SelectionType type,   uint seat);
37       System.Threading.Tasks.Task<Eina.Value> SetSelectionAsync( Efl.Ui.SelectionType type, Efl.Ui.SelectionFormat format, Eina.Slice data,  uint seat, System.Threading.CancellationToken token=default(System.Threading.CancellationToken));
38             /// <summary>Called when display server&apos;s selection has changed</summary>
39    event EventHandler<Efl.Ui.SelectionSelectionChangedEvt_Args> SelectionChangedEvt;
40 }
41 ///<summary>Event argument wrapper for event <see cref="Efl.Ui.Selection.SelectionChangedEvt"/>.</summary>
42 public class SelectionSelectionChangedEvt_Args : EventArgs {
43    ///<summary>Actual event payload.</summary>
44    public Efl.Ui.SelectionChanged arg { get; set; }
45 }
46 /// <summary>Efl Ui Selection class</summary>
47 sealed public class SelectionConcrete : 
48
49 Selection
50    
51 {
52    ///<summary>Pointer to the native class description.</summary>
53    public System.IntPtr NativeClass {
54       get {
55          if (((object)this).GetType() == typeof (SelectionConcrete))
56             return Efl.Ui.SelectionNativeInherit.GetEflClassStatic();
57          else
58             return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
59       }
60    }
61    private EventHandlerList eventHandlers = new EventHandlerList();
62    private  System.IntPtr handle;
63    ///<summary>Pointer to the native instance.</summary>
64    public System.IntPtr NativeHandle {
65       get { return handle; }
66    }
67    [System.Runtime.InteropServices.DllImport(efl.Libs.Elementary)] internal static extern System.IntPtr
68       efl_ui_selection_mixin_get();
69    ///<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>
70    public SelectionConcrete(System.IntPtr raw)
71    {
72       handle = raw;
73       register_event_proxies();
74    }
75    ///<summary>Destructor.</summary>
76    ~SelectionConcrete()
77    {
78       Dispose(false);
79    }
80    ///<summary>Releases the underlying native instance.</summary>
81    void Dispose(bool disposing)
82    {
83       if (handle != System.IntPtr.Zero) {
84          Efl.Eo.Globals.efl_unref(handle);
85          handle = System.IntPtr.Zero;
86       }
87    }
88    ///<summary>Releases the underlying native instance.</summary>
89    public void Dispose()
90    {
91       Dispose(true);
92       GC.SuppressFinalize(this);
93    }
94    ///<summary>Casts obj into an instance of this type.</summary>
95    public static SelectionConcrete static_cast(Efl.Object obj)
96    {
97       if (obj == null)
98          throw new System.ArgumentNullException("obj");
99       return new SelectionConcrete(obj.NativeHandle);
100    }
101    ///<summary>Verifies if the given object is equal to this one.</summary>
102    public override bool Equals(object obj)
103    {
104       var other = obj as Efl.Object;
105       if (other == null)
106          return false;
107       return this.NativeHandle == other.NativeHandle;
108    }
109    ///<summary>Gets the hash code for this object based on the native pointer it points to.</summary>
110    public override int GetHashCode()
111    {
112       return this.NativeHandle.ToInt32();
113    }
114    ///<summary>Turns the native pointer into a string representation.</summary>
115    public override String ToString()
116    {
117       return $"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]";
118    }
119    private readonly object eventLock = new object();
120    private Dictionary<string, int> event_cb_count = new Dictionary<string, int>();
121    private bool add_cpp_event_handler(string lib, string key, Efl.EventCb evt_delegate) {
122       int event_count = 0;
123       if (!event_cb_count.TryGetValue(key, out event_count))
124          event_cb_count[key] = event_count;
125       if (event_count == 0) {
126          IntPtr desc = Efl.EventDescription.GetNative(lib, key);
127          if (desc == IntPtr.Zero) {
128             Eina.Log.Error($"Failed to get native event {key}");
129             return false;
130          }
131           bool result = Efl.Eo.Globals.efl_event_callback_priority_add(handle, desc, 0, evt_delegate, System.IntPtr.Zero);
132          if (!result) {
133             Eina.Log.Error($"Failed to add event proxy for event {key}");
134             return false;
135          }
136          Eina.Error.RaiseIfUnhandledException();
137       } 
138       event_cb_count[key]++;
139       return true;
140    }
141    private bool remove_cpp_event_handler(string key, Efl.EventCb evt_delegate) {
142       int event_count = 0;
143       if (!event_cb_count.TryGetValue(key, out event_count))
144          event_cb_count[key] = event_count;
145       if (event_count == 1) {
146          IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Elementary, key);
147          if (desc == IntPtr.Zero) {
148             Eina.Log.Error($"Failed to get native event {key}");
149             return false;
150          }
151          bool result = Efl.Eo.Globals.efl_event_callback_del(handle, desc, evt_delegate, System.IntPtr.Zero);
152          if (!result) {
153             Eina.Log.Error($"Failed to remove event proxy for event {key}");
154             return false;
155          }
156          Eina.Error.RaiseIfUnhandledException();
157       } else if (event_count == 0) {
158          Eina.Log.Error($"Trying to remove proxy for event {key} when there is nothing registered.");
159          return false;
160       } 
161       event_cb_count[key]--;
162       return true;
163    }
164 private static object SelectionChangedEvtKey = new object();
165    /// <summary>Called when display server&apos;s selection has changed</summary>
166    public event EventHandler<Efl.Ui.SelectionSelectionChangedEvt_Args> SelectionChangedEvt
167    {
168       add {
169          lock (eventLock) {
170             string key = "_EFL_UI_SELECTION_EVENT_SELECTION_CHANGED";
171             if (add_cpp_event_handler(efl.Libs.Elementary, key, this.evt_SelectionChangedEvt_delegate)) {
172                eventHandlers.AddHandler(SelectionChangedEvtKey , value);
173             } else
174                Eina.Log.Error($"Error adding proxy for event {key}");
175          }
176       }
177       remove {
178          lock (eventLock) {
179             string key = "_EFL_UI_SELECTION_EVENT_SELECTION_CHANGED";
180             if (remove_cpp_event_handler(key, this.evt_SelectionChangedEvt_delegate)) { 
181                eventHandlers.RemoveHandler(SelectionChangedEvtKey , value);
182             } else
183                Eina.Log.Error($"Error removing proxy for event {key}");
184          }
185       }
186    }
187    ///<summary>Method to raise event SelectionChangedEvt.</summary>
188    public void On_SelectionChangedEvt(Efl.Ui.SelectionSelectionChangedEvt_Args e)
189    {
190       EventHandler<Efl.Ui.SelectionSelectionChangedEvt_Args> evt;
191       lock (eventLock) {
192       evt = (EventHandler<Efl.Ui.SelectionSelectionChangedEvt_Args>)eventHandlers[SelectionChangedEvtKey];
193       }
194       evt?.Invoke(this, e);
195    }
196    Efl.EventCb evt_SelectionChangedEvt_delegate;
197    private void on_SelectionChangedEvt_NativeCallback(System.IntPtr data, ref Efl.Event_StructInternal evt)
198    {
199       Efl.Ui.SelectionSelectionChangedEvt_Args args = new Efl.Ui.SelectionSelectionChangedEvt_Args();
200       args.arg =  evt.Info;;
201       try {
202          On_SelectionChangedEvt(args);
203       } catch (Exception e) {
204          Eina.Log.Error(e.ToString());
205          Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
206       }
207    }
208
209     void register_event_proxies()
210    {
211       evt_SelectionChangedEvt_delegate = new Efl.EventCb(on_SelectionChangedEvt_NativeCallback);
212    }
213    /// <summary>Set the selection data to the object</summary>
214    /// <param name="type">Selection Type</param>
215    /// <param name="format">Selection Format</param>
216    /// <param name="data"></param>
217    /// <param name="seat">Specified seat for multiple seats case.</param>
218    /// <returns>Future for tracking when the selection is lost</returns>
219    public  Eina.Future SetSelection( Efl.Ui.SelectionType type,  Efl.Ui.SelectionFormat format,  Eina.Slice data,   uint seat) {
220                                                                                var _ret_var = Efl.Ui.SelectionNativeInherit.efl_ui_selection_set_ptr.Value.Delegate(this.NativeHandle, type,  format,  data,  seat);
221       Eina.Error.RaiseIfUnhandledException();
222                                                       return _ret_var;
223  }
224    /// <summary>Get the data from the object that has selection</summary>
225    /// <param name="type">Selection Type</param>
226    /// <param name="format">Selection Format</param>
227    /// <param name="data_func">Data ready function pointer</param>
228    /// <param name="seat">Specified seat for multiple seats case.</param>
229    /// <returns></returns>
230    public  void GetSelection( Efl.Ui.SelectionType type,  Efl.Ui.SelectionFormat format,  Efl.Ui.SelectionDataReady data_func,   uint seat) {
231                                                                    GCHandle data_func_handle = GCHandle.Alloc(data_func);
232             Efl.Ui.SelectionNativeInherit.efl_ui_selection_get_ptr.Value.Delegate(this.NativeHandle, type,  format, GCHandle.ToIntPtr(data_func_handle), Efl.Ui.SelectionDataReadyWrapper.Cb, Efl.Eo.Globals.free_gchandle,  seat);
233       Eina.Error.RaiseIfUnhandledException();
234                                                        }
235    /// <summary>Clear the selection data from the object</summary>
236    /// <param name="type">Selection Type</param>
237    /// <param name="seat">Specified seat for multiple seats case.</param>
238    /// <returns></returns>
239    public  void ClearSelection( Efl.Ui.SelectionType type,   uint seat) {
240                                            Efl.Ui.SelectionNativeInherit.efl_ui_selection_clear_ptr.Value.Delegate(this.NativeHandle, type,  seat);
241       Eina.Error.RaiseIfUnhandledException();
242                                }
243    /// <summary>Determine whether the selection data has owner</summary>
244    /// <param name="type">Selection type</param>
245    /// <param name="seat">Specified seat for multiple seats case.</param>
246    /// <returns>EINA_TRUE if there is object owns selection, otherwise EINA_FALSE</returns>
247    public bool HasOwner( Efl.Ui.SelectionType type,   uint seat) {
248                                            var _ret_var = Efl.Ui.SelectionNativeInherit.efl_ui_selection_has_owner_ptr.Value.Delegate(this.NativeHandle, type,  seat);
249       Eina.Error.RaiseIfUnhandledException();
250                               return _ret_var;
251  }
252    public System.Threading.Tasks.Task<Eina.Value> SetSelectionAsync( Efl.Ui.SelectionType type, Efl.Ui.SelectionFormat format, Eina.Slice data,  uint seat, System.Threading.CancellationToken token=default(System.Threading.CancellationToken))
253    {
254       Eina.Future future = SetSelection(  type,  format,  data,  seat);
255       return Efl.Eo.Globals.WrapAsync(future, token);
256    }
257 }
258 public class SelectionNativeInherit  : Efl.Eo.NativeClass{
259    public  static Efl.Eo.NativeModule _Module = new Efl.Eo.NativeModule(efl.Libs.Elementary);
260    public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
261    {
262       var descs = new System.Collections.Generic.List<Efl_Op_Description>();
263       if (efl_ui_selection_set_static_delegate == null)
264       efl_ui_selection_set_static_delegate = new efl_ui_selection_set_delegate(selection_set);
265       descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(_Module.Module, "efl_ui_selection_set"), func = Marshal.GetFunctionPointerForDelegate(efl_ui_selection_set_static_delegate)});
266       if (efl_ui_selection_get_static_delegate == null)
267       efl_ui_selection_get_static_delegate = new efl_ui_selection_get_delegate(selection_get);
268       descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(_Module.Module, "efl_ui_selection_get"), func = Marshal.GetFunctionPointerForDelegate(efl_ui_selection_get_static_delegate)});
269       if (efl_ui_selection_clear_static_delegate == null)
270       efl_ui_selection_clear_static_delegate = new efl_ui_selection_clear_delegate(selection_clear);
271       descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(_Module.Module, "efl_ui_selection_clear"), func = Marshal.GetFunctionPointerForDelegate(efl_ui_selection_clear_static_delegate)});
272       if (efl_ui_selection_has_owner_static_delegate == null)
273       efl_ui_selection_has_owner_static_delegate = new efl_ui_selection_has_owner_delegate(has_owner);
274       descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(_Module.Module, "efl_ui_selection_has_owner"), func = Marshal.GetFunctionPointerForDelegate(efl_ui_selection_has_owner_static_delegate)});
275       return descs;
276    }
277    public override IntPtr GetEflClass()
278    {
279       return Efl.Ui.SelectionConcrete.efl_ui_selection_mixin_get();
280    }
281    public static  IntPtr GetEflClassStatic()
282    {
283       return Efl.Ui.SelectionConcrete.efl_ui_selection_mixin_get();
284    }
285
286
287    [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.FutureMarshaler))] private delegate  Eina.Future efl_ui_selection_set_delegate(System.IntPtr obj, System.IntPtr pd,   Efl.Ui.SelectionType type,   Efl.Ui.SelectionFormat format,   Eina.Slice data,    uint seat);
288
289
290    [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.FutureMarshaler))] public delegate  Eina.Future efl_ui_selection_set_api_delegate(System.IntPtr obj,   Efl.Ui.SelectionType type,   Efl.Ui.SelectionFormat format,   Eina.Slice data,    uint seat);
291     public static Efl.Eo.FunctionWrapper<efl_ui_selection_set_api_delegate> efl_ui_selection_set_ptr = new Efl.Eo.FunctionWrapper<efl_ui_selection_set_api_delegate>(_Module, "efl_ui_selection_set");
292     private static  Eina.Future selection_set(System.IntPtr obj, System.IntPtr pd,  Efl.Ui.SelectionType type,  Efl.Ui.SelectionFormat format,  Eina.Slice data,   uint seat)
293    {
294       Eina.Log.Debug("function efl_ui_selection_set was called");
295       Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.data_get(pd);
296       if(wrapper != null) {
297                                                                                            Eina.Future _ret_var = default( Eina.Future);
298          try {
299             _ret_var = ((SelectionConcrete)wrapper).SetSelection( type,  format,  data,  seat);
300          } catch (Exception e) {
301             Eina.Log.Warning($"Callback error: {e.ToString()}");
302             Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
303          }
304                                                       return _ret_var;
305       } else {
306          return efl_ui_selection_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)),  type,  format,  data,  seat);
307       }
308    }
309    private static efl_ui_selection_set_delegate efl_ui_selection_set_static_delegate;
310
311
312     private delegate  void efl_ui_selection_get_delegate(System.IntPtr obj, System.IntPtr pd,   Efl.Ui.SelectionType type,   Efl.Ui.SelectionFormat format,  IntPtr data_func_data, Efl.Ui.SelectionDataReadyInternal data_func, EinaFreeCb data_func_free_cb,    uint seat);
313
314
315     public delegate  void efl_ui_selection_get_api_delegate(System.IntPtr obj,   Efl.Ui.SelectionType type,   Efl.Ui.SelectionFormat format,  IntPtr data_func_data, Efl.Ui.SelectionDataReadyInternal data_func, EinaFreeCb data_func_free_cb,    uint seat);
316     public static Efl.Eo.FunctionWrapper<efl_ui_selection_get_api_delegate> efl_ui_selection_get_ptr = new Efl.Eo.FunctionWrapper<efl_ui_selection_get_api_delegate>(_Module, "efl_ui_selection_get");
317     private static  void selection_get(System.IntPtr obj, System.IntPtr pd,  Efl.Ui.SelectionType type,  Efl.Ui.SelectionFormat format, IntPtr data_func_data, Efl.Ui.SelectionDataReadyInternal data_func, EinaFreeCb data_func_free_cb,   uint seat)
318    {
319       Eina.Log.Debug("function efl_ui_selection_get was called");
320       Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.data_get(pd);
321       if(wrapper != null) {
322                                                                               Efl.Ui.SelectionDataReadyWrapper data_func_wrapper = new Efl.Ui.SelectionDataReadyWrapper(data_func, data_func_data, data_func_free_cb);
323                
324          try {
325             ((SelectionConcrete)wrapper).GetSelection( type,  format,  data_func_wrapper.ManagedCb,  seat);
326          } catch (Exception e) {
327             Eina.Log.Warning($"Callback error: {e.ToString()}");
328             Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
329          }
330                                                             } else {
331          efl_ui_selection_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)),  type,  format, data_func_data, data_func, data_func_free_cb,  seat);
332       }
333    }
334    private static efl_ui_selection_get_delegate efl_ui_selection_get_static_delegate;
335
336
337     private delegate  void efl_ui_selection_clear_delegate(System.IntPtr obj, System.IntPtr pd,   Efl.Ui.SelectionType type,    uint seat);
338
339
340     public delegate  void efl_ui_selection_clear_api_delegate(System.IntPtr obj,   Efl.Ui.SelectionType type,    uint seat);
341     public static Efl.Eo.FunctionWrapper<efl_ui_selection_clear_api_delegate> efl_ui_selection_clear_ptr = new Efl.Eo.FunctionWrapper<efl_ui_selection_clear_api_delegate>(_Module, "efl_ui_selection_clear");
342     private static  void selection_clear(System.IntPtr obj, System.IntPtr pd,  Efl.Ui.SelectionType type,   uint seat)
343    {
344       Eina.Log.Debug("function efl_ui_selection_clear was called");
345       Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.data_get(pd);
346       if(wrapper != null) {
347                                                       
348          try {
349             ((SelectionConcrete)wrapper).ClearSelection( type,  seat);
350          } catch (Exception e) {
351             Eina.Log.Warning($"Callback error: {e.ToString()}");
352             Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
353          }
354                                     } else {
355          efl_ui_selection_clear_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)),  type,  seat);
356       }
357    }
358    private static efl_ui_selection_clear_delegate efl_ui_selection_clear_static_delegate;
359
360
361     [return: MarshalAs(UnmanagedType.U1)] private delegate bool efl_ui_selection_has_owner_delegate(System.IntPtr obj, System.IntPtr pd,   Efl.Ui.SelectionType type,    uint seat);
362
363
364     [return: MarshalAs(UnmanagedType.U1)] public delegate bool efl_ui_selection_has_owner_api_delegate(System.IntPtr obj,   Efl.Ui.SelectionType type,    uint seat);
365     public static Efl.Eo.FunctionWrapper<efl_ui_selection_has_owner_api_delegate> efl_ui_selection_has_owner_ptr = new Efl.Eo.FunctionWrapper<efl_ui_selection_has_owner_api_delegate>(_Module, "efl_ui_selection_has_owner");
366     private static bool has_owner(System.IntPtr obj, System.IntPtr pd,  Efl.Ui.SelectionType type,   uint seat)
367    {
368       Eina.Log.Debug("function efl_ui_selection_has_owner was called");
369       Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.data_get(pd);
370       if(wrapper != null) {
371                                                       bool _ret_var = default(bool);
372          try {
373             _ret_var = ((SelectionConcrete)wrapper).HasOwner( type,  seat);
374          } catch (Exception e) {
375             Eina.Log.Warning($"Callback error: {e.ToString()}");
376             Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
377          }
378                               return _ret_var;
379       } else {
380          return efl_ui_selection_has_owner_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)),  type,  seat);
381       }
382    }
383    private static efl_ui_selection_has_owner_delegate efl_ui_selection_has_owner_static_delegate;
384 }
385 } }