[NUI] Add to set MIME type to the input panel and its callback (#935)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / ContentReceivedSignalType.cs
1 /*
2  * Copyright(c) 2019 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 using System;
18 using System.Runtime.InteropServices;
19 using System.ComponentModel;
20
21 namespace Tizen.NUI
22 {
23     internal class ContentReceivedSignalType : global::System.IDisposable
24     {
25         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
26         /// <summary>
27         /// ContentReceivedSignalType
28         /// </summary>
29         protected bool swigCMemOwn;
30
31         internal ContentReceivedSignalType(global::System.IntPtr cPtr, bool cMemoryOwn)
32         {
33             swigCMemOwn = cMemoryOwn;
34             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
35         }
36
37         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ContentReceivedSignalType obj)
38         {
39             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
40         }
41
42         //A Flag to check who called Dispose(). (By User or DisposeQueue)
43         private bool isDisposeQueued = false;
44         /// <summary>
45         /// A Flat to check if it is already disposed.
46         /// </summary>
47         protected bool disposed = false;
48
49         /// <summary>
50         /// Dispose
51         /// </summary>
52         ~ContentReceivedSignalType()
53         {
54             if (!isDisposeQueued)
55             {
56                 isDisposeQueued = true;
57                 DisposeQueue.Instance.Add(this);
58             }
59         }
60
61         /// <summary>
62         /// Dispose
63         /// </summary>
64         public void Dispose()
65         {
66             //Throw excpetion if Dispose() is called in separate thread.
67             if (!Window.IsInstalled())
68             {
69                 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
70             }
71
72             if (isDisposeQueued)
73             {
74                 Dispose(DisposeTypes.Implicit);
75             }
76             else
77             {
78                 Dispose(DisposeTypes.Explicit);
79                 System.GC.SuppressFinalize(this);
80             }
81         }
82
83         /// <summary>
84         /// Dispose
85         /// </summary>
86         protected virtual void Dispose(DisposeTypes type)
87         {
88             if (disposed)
89             {
90                 return;
91             }
92
93             if (type == DisposeTypes.Explicit)
94             {
95                 //Called by User
96                 //Release your own managed resources here.
97                 //You should release all of your own disposable objects here.
98
99             }
100
101             //Release your own unmanaged resources here.
102             //You should not access any managed member here except static instance.
103             //because the execution order of Finalizes is non-deterministic.
104             if (swigCPtr.Handle != global::System.IntPtr.Zero)
105             {
106                 if (swigCMemOwn)
107                 {
108                     swigCMemOwn = false;
109                     Interop.ContentReceivedSignalType.delete_ContentReceivedSignalType(swigCPtr);
110                 }
111                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
112             }
113
114             disposed = true;
115         }
116
117         /// <summary>
118         /// Queries whether there are any connected slots.
119         /// </summary>
120         /// <returns>True if there are any slots connected to the signal</returns>
121         public bool Empty()
122         {
123             bool ret = Interop.ContentReceivedSignalType.ContentReceivedSignalType_Empty(swigCPtr);
124             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
125             return ret;
126         }
127
128         /// <summary>
129         /// Queries the number of slots.
130         /// </summary>
131         /// <returns>The number of slots connected to this signal</returns>
132         public uint GetConnectionCount()
133         {
134             uint ret = Interop.ContentReceivedSignalType.ContentReceivedSignalType_GetConnectionCount(swigCPtr);
135             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
136             return ret;
137         }
138
139         /// <summary>
140         /// Connects a function.
141         /// </summary>
142         /// <param name="func">The function to connect</param>
143         public void Connect(System.Delegate func)
144         {
145             System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func);
146             {
147                 Interop.ContentReceivedSignalType.ContentReceivedSignalType_Connect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
148                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
149             }
150         }
151
152         /// <summary>
153         /// Disconnects a function.
154         /// </summary>
155         /// <param name="func">The function to disconnect</param>
156         public void Disconnect(System.Delegate func)
157         {
158             System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func);
159             {
160                 Interop.ContentReceivedSignalType.ContentReceivedSignalType_Disconnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
161                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
162             }
163         }
164
165         /// <summary>
166         /// Connects a member function.
167         /// </summary>
168         /// <param name="arg1">The member function to connect</param>
169         /// <param name="arg2">The member function to connect</param>
170         /// <param name="arg3">The member function to connect</param>
171         public void Emit(string arg1, string arg2, string arg3)
172         {
173             Interop.ContentReceivedSignalType.ContentReceivedSignalType_Emit(swigCPtr, arg1, arg2, arg3);
174             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
175         }
176
177         /// <summary>
178         /// The contructor.
179         /// </summary>
180         public ContentReceivedSignalType() : this(Interop.ContentReceivedSignalType.new_ContentReceivedSignalType(), true)
181         {
182             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
183         }
184
185     }
186
187 }