Add C# binding for web view lite.
[platform/core/csapi/nui.git] / Tizen.NUI / src / internal / WebViewLiteSignal.cs
1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16
17 namespace Tizen.NUI {
18
19 public class WebViewLiteSignal : global::System.IDisposable {
20   private global::System.Runtime.InteropServices.HandleRef swigCPtr;
21   protected bool swigCMemOwn;
22
23   internal WebViewLiteSignal(global::System.IntPtr cPtr, bool cMemoryOwn) {
24     swigCMemOwn = cMemoryOwn;
25     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
26   }
27
28   internal static global::System.Runtime.InteropServices.HandleRef getCPtr(WebViewLiteSignal obj) {
29     return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
30   }
31
32   //A Flag to check who called Dispose(). (By User or DisposeQueue)
33   private bool isDisposeQueued = false;
34   //A Flat to check if it is already disposed.
35   protected bool disposed = false;
36
37   ~WebViewLiteSignal()
38   {
39       if (!isDisposeQueued)
40       {
41           isDisposeQueued = true;
42           DisposeQueue.Instance.Add(this);
43       }
44   }
45
46   public void Dispose()
47   {
48       //Throw excpetion if Dispose() is called in separate thread.
49       if (!Window.IsInstalled())
50       {
51           throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
52       }
53
54       if (isDisposeQueued)
55       {
56           Dispose(DisposeTypes.Implicit);
57       }
58       else
59       {
60           Dispose(DisposeTypes.Explicit);
61           System.GC.SuppressFinalize(this);
62       }
63   }
64
65   protected virtual void Dispose(DisposeTypes type)
66   {
67       if (disposed)
68       {
69           return;
70       }
71
72       if (type == DisposeTypes.Explicit)
73       {
74           //Called by User
75           //Release your own managed resources here.
76           //You should release all of your own disposable objects here.
77
78       }
79
80       //Release your own unmanaged resources here.
81       //You should not access any managed member here except static instance.
82       //because the execution order of Finalizes is non-deterministic.
83
84       if (swigCPtr.Handle != global::System.IntPtr.Zero)
85       {
86           if (swigCMemOwn)
87           {
88               swigCMemOwn = false;
89               NDalicPINVOKE.delete_WebViewLiteSignal(swigCPtr);
90           }
91           swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
92       }
93
94       disposed = true;
95   }
96
97
98   public bool Empty() {
99     bool ret = NDalicPINVOKE.WebViewLiteSignal_Empty(swigCPtr);
100     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
101     return ret;
102   }
103
104   public uint GetConnectionCount() {
105     uint ret = NDalicPINVOKE.WebViewLiteSignal_GetConnectionCount(swigCPtr);
106     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
107     return ret;
108   }
109
110   public void Connect(System.Delegate func) {
111 System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func);
112     {
113       NDalicPINVOKE.WebViewLiteSignal_Connect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
114       if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
115     }
116   }
117
118   public void Disconnect(System.Delegate func) {
119 System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func);
120     {
121       NDalicPINVOKE.WebViewLiteSignal_Disconnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
122       if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
123     }
124   }
125
126   public void Emit(WebViewLite arg) {
127     NDalicPINVOKE.WebViewLiteSignal_Emit(swigCPtr, WebViewLite.getCPtr(arg));
128     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
129   }
130
131   public WebViewLiteSignal() : this(NDalicPINVOKE.new_WebViewLiteSignal(), true) {
132     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
133   }
134
135 }
136
137 }