[NUI] Change all CallingConvention to `Cdecl`
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Input / AutofillContainer.cs
1 /*
2  * Copyright(c) 2021 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
18 using System;
19 using System.Runtime.InteropServices;
20 using System.ComponentModel;
21
22 namespace Tizen.NUI
23 {
24     /// <summary>
25     /// AutofillContainer controls several text input boxes.
26     /// </summary>
27     /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
28     [EditorBrowsable(EditorBrowsableState.Never)]
29     public class AutofillContainer : BaseHandle
30     {
31         private AuthenticationEventCallbackType authenticationCallback;
32         private ListEventCallbackType listCallback;
33
34         private event EventHandler<AuthenticationEventArgs> authenticationEventHandler;
35         private event EventHandler<ListEventArgs> listEventHandler;
36
37         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
38         private delegate void AuthenticationEventCallbackType(IntPtr autofillContainer);
39         private delegate void ListEventCallbackType(IntPtr control);
40
41         /// <summary>
42         /// AutofillContainer Authentication Service Event.
43         /// </summary>
44         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
45         [EditorBrowsable(EditorBrowsableState.Never)]
46         public event EventHandler<AuthenticationEventArgs> ServiceEvent
47         {
48             add
49             {
50                 if (authenticationEventHandler == null)
51                 {
52                     authenticationCallback = OnServiceEvent;
53                     AutofillServiceEventSignal().Connect(authenticationCallback);
54                 }
55
56                 authenticationEventHandler += value;
57             }
58             remove
59             {
60                 authenticationEventHandler -= value;
61
62                 if (authenticationEventHandler == null && authenticationCallback != null)
63                 {
64                     AutofillServiceEventSignal().Disconnect(authenticationCallback);
65                 }
66             }
67         }
68
69         /// <summary>
70         /// AutofillContainer Fill List Event.
71         /// </summary>
72         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
73         [EditorBrowsable(EditorBrowsableState.Never)]
74         public event EventHandler<ListEventArgs> ListEvent
75         {
76             add
77             {
78                 if (listEventHandler == null)
79                 {
80                     listCallback = OnListEvent;
81                     AutofillListEventSignal().Connect(listCallback);
82                 }
83
84                 listEventHandler += value;
85             }
86             remove
87             {
88                 listEventHandler -= value;
89
90                 if (listEventHandler == null && listCallback != null)
91                 {
92                     AutofillListEventSignal().Disconnect(listCallback);
93                 }
94             }
95         }
96
97         /// <summary>
98         /// Constructor.
99         /// </summary>
100         /// <param name="name"> The AutofillContainer name</param>
101         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
102         [EditorBrowsable(EditorBrowsableState.Never)]
103         public AutofillContainer(string name) : this(Interop.AutofillContainer.New(name), true)
104         {
105             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
106         }
107
108         internal AutofillContainer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
109         {
110         }
111
112         internal AutofillContainer(AutofillContainer autofillContainer) : this(Interop.AutofillContainer.NewAutofillContainer(AutofillContainer.getCPtr(autofillContainer)), true)
113         {
114             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
115         }
116
117         internal AutofillContainer Assign(AutofillContainer autofillContainer)
118         {
119             AutofillContainer ret = new AutofillContainer(Interop.AutofillContainer.Assign(SwigCPtr, AutofillContainer.getCPtr(autofillContainer)), false);
120             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
121             return ret;
122         }
123
124         internal static AutofillContainer DownCast(BaseHandle handle)
125         {
126             AutofillContainer ret = new AutofillContainer(Interop.AutofillContainer.DownCast(BaseHandle.getCPtr(handle)), true);
127             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
128             return ret;
129         }
130
131         /// <summary>
132         /// Adds View and its Autofill item information to Autofill Container.
133         /// </summary>
134         /// <param name="view"> The view to be added to Autofill Container</param>
135         /// <param name="propertyIndex">The Property to be filled automatically of each View</param>
136         /// <param name="id"> A unique ID that does not always change on each launching</param>
137         /// <param name="label"> An auxiliary means to guess heuristically what data is</param>
138         /// <param name="hint"> The Hint - id (username), name, password, phone, credit card number, organization, and so on</param>
139         /// <param name="isSensitive"> Whether this information is a sensitive data or not</param>
140         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
141         [EditorBrowsable(EditorBrowsableState.Never)]
142         public void AddAutofillView(BaseComponents.View view, int propertyIndex, string id, string label, AutofillContainer.ItemHint hint, bool isSensitive)
143         {
144             Interop.AutofillContainer.AddAutofillView(SwigCPtr, BaseComponents.View.getCPtr(view), propertyIndex, id, label, (uint)hint, isSensitive);
145             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
146         }
147
148         /// <summary>
149         /// Removes View and its AutofillItem information to Autofill Container.
150         /// </summary>
151         /// <param name="view"> The view to be removed to Autofill Container</param>
152         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
153         [EditorBrowsable(EditorBrowsableState.Never)]
154         public void RemoveAutofillItem(BaseComponents.View view)
155         {
156             Interop.AutofillContainer.RemoveAutofillItem(SwigCPtr, BaseComponents.View.getCPtr(view));
157             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
158         }
159
160         /// <summary>
161         /// Stores autofill data.
162         /// </summary>
163         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
164         [EditorBrowsable(EditorBrowsableState.Never)]
165         public void SaveAutofillData()
166         {
167             Interop.AutofillContainer.SaveAutofillData(SwigCPtr);
168             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
169         }
170
171         /// <summary>
172         /// Sends a request for filling the data.
173         /// </summary>
174         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
175         [EditorBrowsable(EditorBrowsableState.Never)]
176         public void RequestFillData()
177         {
178             Interop.AutofillContainer.RequestFillData(SwigCPtr);
179             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
180         }
181
182         /// <summary>
183         /// Gets the Autofill Service Name.
184         /// </summary>
185         /// <returns>Autofill Service Name</returns>
186         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
187         [EditorBrowsable(EditorBrowsableState.Never)]
188         public string GetAutofillServiceName()
189         {
190             string ret = Interop.AutofillContainer.GetAutofillServiceName(SwigCPtr);
191             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
192             return ret;
193         }
194
195         /// <summary>
196         /// Gets the Autofill Service Message.
197         /// </summary>
198         /// <returns>Autofill Service Message</returns>
199         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
200         [EditorBrowsable(EditorBrowsableState.Never)]
201         public string GetAutofillServiceMessage()
202         {
203             string ret = Interop.AutofillContainer.GetAutofillServiceMessage(SwigCPtr);
204             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
205             return ret;
206         }
207
208         /// <summary>
209         /// Gets the Autofill Service Image Path.
210         /// </summary>
211         /// <returns>Autofill Service Image Path</returns>
212         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
213         [EditorBrowsable(EditorBrowsableState.Never)]
214         public string GetAutofillServiceImagePath()
215         {
216             string ret = Interop.AutofillContainer.GetAutofillServiceImagePath(SwigCPtr);
217             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
218             return ret;
219         }
220
221         /// <summary>
222         /// Gets the number of list items. (The presentation text of Autofill)
223         /// </summary>
224         /// <returns>The number of list items</returns>
225         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
226         [EditorBrowsable(EditorBrowsableState.Never)]
227         public uint GetListItemCount()
228         {
229             uint ret = Interop.AutofillContainer.GetListItemCount(SwigCPtr);
230             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
231             return ret;
232         }
233
234         /// <summary>
235         /// Gets the list item of the index.
236         /// </summary>
237         /// <param name="index">The index for the list</param>
238         /// <returns>The list item of the index</returns>
239         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
240         [EditorBrowsable(EditorBrowsableState.Never)]
241         public string GetListItem(uint index)
242         {
243             string ret = Interop.AutofillContainer.GetListItem(SwigCPtr, index);
244             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
245             return ret;
246         }
247
248         /// <summary>
249         /// Sets the selected item to fill out.
250         /// </summary>
251         /// <param name="selected">The selected item</param>
252         /// <since_tizen> 5 </since_tizen>
253         public void SetSelectedItem(string selected)
254         {
255             Interop.AutofillContainer.SetSelectedItem(SwigCPtr, selected);
256             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
257         }
258
259         internal AuthenticationSignalType AutofillServiceEventSignal()
260         {
261
262             AuthenticationSignalType ret = new AuthenticationSignalType(Interop.AutofillContainer.AutofillServiceEventSignal(SwigCPtr), false);
263             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
264             return ret;
265         }
266
267         internal ListEventSignalType AutofillListEventSignal()
268         {
269             ListEventSignalType ret = new ListEventSignalType(Interop.AutofillContainer.AutofillListEventSignal(SwigCPtr), false);
270             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
271             return ret;
272         }
273
274         /// <summary>
275         /// Dispose.
276         /// </summary>
277         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
278         [EditorBrowsable(EditorBrowsableState.Never)]
279         protected override void Dispose(DisposeTypes type)
280         {
281             if (disposed)
282             {
283                 return;
284             }
285
286             //Release your own unmanaged resources here.
287             //You should not access any managed member here except static instance.
288             //because the execution order of Finalizes is non-deterministic.
289             if (this != null)
290             {
291                 if (authenticationCallback != null)
292                 {
293                     AutofillServiceEventSignal().Disconnect(authenticationCallback);
294                 }
295
296                 if (listCallback != null)
297                 {
298                     AutofillListEventSignal().Disconnect(listCallback);
299                 }
300             }
301
302             base.Dispose(type);
303         }
304
305         /// This will not be public opened.
306         [EditorBrowsable(EditorBrowsableState.Never)]
307         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
308         {
309             Interop.AutofillContainer.DeleteAutofillContainer(swigCPtr);
310         }
311
312         private void OnServiceEvent(IntPtr autofillContainer)
313         {
314             AuthenticationEventArgs e = new AuthenticationEventArgs();
315             e.AutofillContainer = Registry.GetManagedBaseHandleFromNativePtr(autofillContainer) as AutofillContainer;
316
317             if (authenticationEventHandler != null)
318             {
319                 authenticationEventHandler(this, e);
320             }
321         }
322
323         private void OnListEvent(IntPtr control)
324         {
325             ListEventArgs e = new ListEventArgs();
326             e.Control = Registry.GetManagedBaseHandleFromNativePtr(control) as BaseComponents.View;
327
328             if (listEventHandler != null)
329             {
330                 listEventHandler(this, e);
331             }
332         }
333
334         /// <summary>
335         /// Event arguments that passed via the Authentication event.
336         /// </summary>
337         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
338         [EditorBrowsable(EditorBrowsableState.Never)]
339         public class AuthenticationEventArgs : EventArgs
340         {
341             /// <summary>
342             /// The instance of AutofillContainer
343             /// </summary>
344             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
345             [EditorBrowsable(EditorBrowsableState.Never)]
346             public AutofillContainer AutofillContainer
347             {
348                 get;
349                 set;
350             }
351         }
352
353         /// <summary>
354         /// AutofillContainer list event arguments.
355         /// </summary>
356         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
357         [EditorBrowsable(EditorBrowsableState.Never)]
358         public class ListEventArgs : EventArgs
359         {
360             /// <summary>
361             /// The instance of AutofillContainer
362             /// </summary>
363             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
364             [EditorBrowsable(EditorBrowsableState.Never)]
365             public BaseComponents.View Control
366             {
367                 get;
368                 set;
369             }
370
371         }
372
373         /// <summary>
374         /// Enumeration for hint of the autofill item.
375         /// </summary>
376         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
377         [EditorBrowsable(EditorBrowsableState.Never)]
378         public enum ItemHint
379         {
380             /// <summary>
381             /// Autofill hint for a credit card expiration date
382             /// </summary>
383             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
384             [EditorBrowsable(EditorBrowsableState.Never)]
385             CreditCardExpirationData,
386             /// <summary>
387             /// Autofill hint for a credit card expiration day
388             /// </summary>
389             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
390             [EditorBrowsable(EditorBrowsableState.Never)]
391             CreditCardExpirationDay,
392             /// <summary>
393             /// Autofill hint for a credit card expiration month
394             /// </summary>
395             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
396             [EditorBrowsable(EditorBrowsableState.Never)]
397             CreditCardExpirationMonth,
398             /// <summary>
399             /// Autofill hint for a credit card expiration year
400             /// </summary>
401             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
402             [EditorBrowsable(EditorBrowsableState.Never)]
403             CreditCardExpirationYear,
404             /// <summary>
405             /// Autofill hint for a credit card number
406             /// </summary>
407             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
408             [EditorBrowsable(EditorBrowsableState.Never)]
409             CreditCardNumber,
410             /// <summary>
411             /// Autofill hint for an email address
412             /// </summary>
413             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
414             [EditorBrowsable(EditorBrowsableState.Never)]
415             EmailAddress,
416             /// <summary>
417             /// Autofill hint for a user's real name
418             /// </summary>
419             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
420             [EditorBrowsable(EditorBrowsableState.Never)]
421             Name,
422             /// <summary>
423             /// Autofill hint for a phone number
424             /// </summary>
425             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
426             [EditorBrowsable(EditorBrowsableState.Never)]
427             Phone,
428             /// <summary>
429             /// Autofill hint for a postal address
430             /// </summary>
431             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
432             [EditorBrowsable(EditorBrowsableState.Never)]
433             PostalAddress,
434             /// <summary>
435             /// Autofill hint for a postal code
436             /// </summary>
437             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
438             [EditorBrowsable(EditorBrowsableState.Never)]
439             PostalCode,
440             /// <summary>
441             /// Autofill hint for a user's ID
442             /// </summary>
443             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
444             [EditorBrowsable(EditorBrowsableState.Never)]
445             Id,
446             /// <summary>
447             /// Autofill hint for password
448             /// </summary>
449             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
450             [EditorBrowsable(EditorBrowsableState.Never)]
451             Password,
452             /// <summary>
453             /// Autofill hint for a credit card security code
454             /// </summary>
455             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
456             [EditorBrowsable(EditorBrowsableState.Never)]
457             CreditCardSecurityCode
458         }
459     }
460 }