bb36e082d4b5c1fccdf4a90a5ddff66f31c1bdbd
[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.StdCall)]
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
113         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(AutofillContainer obj)
114         {
115             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
116         }
117
118         internal AutofillContainer(AutofillContainer autofillContainer) : this(Interop.AutofillContainer.NewAutofillContainer(AutofillContainer.getCPtr(autofillContainer)), true)
119         {
120             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
121         }
122
123         internal AutofillContainer Assign(AutofillContainer autofillContainer)
124         {
125             AutofillContainer ret = new AutofillContainer(Interop.AutofillContainer.Assign(SwigCPtr, AutofillContainer.getCPtr(autofillContainer)), false);
126             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
127             return ret;
128         }
129
130         internal static AutofillContainer DownCast(BaseHandle handle)
131         {
132             AutofillContainer ret = new AutofillContainer(Interop.AutofillContainer.DownCast(BaseHandle.getCPtr(handle)), true);
133             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
134             return ret;
135         }
136
137         /// <summary>
138         /// Adds View and its Autofill item information to Autofill Container.
139         /// </summary>
140         /// <param name="view"> The view to be added to Autofill Container</param>
141         /// <param name="propertyIndex">The Property to be filled automatically of each View</param>
142         /// <param name="id"> A unique ID that does not always change on each launching</param>
143         /// <param name="label"> An auxiliary means to guess heuristically what data is</param>
144         /// <param name="hint"> The Hint - id (username), name, password, phone, credit card number, organization, and so on</param>
145         /// <param name="isSensitive"> Whether this information is a sensitive data or not</param>
146         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
147         [EditorBrowsable(EditorBrowsableState.Never)]
148         public void AddAutofillView(BaseComponents.View view, int propertyIndex, string id, string label, AutofillContainer.ItemHint hint, bool isSensitive)
149         {
150             Interop.AutofillContainer.AddAutofillView(SwigCPtr, BaseComponents.View.getCPtr(view), propertyIndex, id, label, (uint)hint, isSensitive);
151             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
152         }
153
154         /// <summary>
155         /// Removes View and its AutofillItem information to Autofill Container.
156         /// </summary>
157         /// <param name="view"> The view to be removed to Autofill Container</param>
158         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
159         [EditorBrowsable(EditorBrowsableState.Never)]
160         public void RemoveAutofillItem(BaseComponents.View view)
161         {
162             Interop.AutofillContainer.RemoveAutofillItem(SwigCPtr, BaseComponents.View.getCPtr(view));
163             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
164         }
165
166         /// <summary>
167         /// Stores autofill data.
168         /// </summary>
169         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
170         [EditorBrowsable(EditorBrowsableState.Never)]
171         public void SaveAutofillData()
172         {
173             Interop.AutofillContainer.SaveAutofillData(SwigCPtr);
174             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
175         }
176
177         /// <summary>
178         /// Sends a request for filling the data.
179         /// </summary>
180         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
181         [EditorBrowsable(EditorBrowsableState.Never)]
182         public void RequestFillData()
183         {
184             Interop.AutofillContainer.RequestFillData(SwigCPtr);
185             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
186         }
187
188         /// <summary>
189         /// Gets the Autofill Service Name.
190         /// </summary>
191         /// <returns>Autofill Service Name</returns>
192         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
193         [EditorBrowsable(EditorBrowsableState.Never)]
194         public string GetAutofillServiceName()
195         {
196             string ret = Interop.AutofillContainer.GetAutofillServiceName(SwigCPtr);
197             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
198             return ret;
199         }
200
201         /// <summary>
202         /// Gets the Autofill Service Message.
203         /// </summary>
204         /// <returns>Autofill Service Message</returns>
205         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
206         [EditorBrowsable(EditorBrowsableState.Never)]
207         public string GetAutofillServiceMessage()
208         {
209             string ret = Interop.AutofillContainer.GetAutofillServiceMessage(SwigCPtr);
210             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
211             return ret;
212         }
213
214         /// <summary>
215         /// Gets the Autofill Service Image Path.
216         /// </summary>
217         /// <returns>Autofill Service Image Path</returns>
218         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
219         [EditorBrowsable(EditorBrowsableState.Never)]
220         public string GetAutofillServiceImagePath()
221         {
222             string ret = Interop.AutofillContainer.GetAutofillServiceImagePath(SwigCPtr);
223             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
224             return ret;
225         }
226
227         /// <summary>
228         /// Gets the number of list items. (The presentation text of Autofill)
229         /// </summary>
230         /// <returns>The number of list items</returns>
231         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
232         [EditorBrowsable(EditorBrowsableState.Never)]
233         public uint GetListItemCount()
234         {
235             uint ret = Interop.AutofillContainer.GetListItemCount(SwigCPtr);
236             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
237             return ret;
238         }
239
240         /// <summary>
241         /// Gets the list item of the index.
242         /// </summary>
243         /// <param name="index">The index for the list</param>
244         /// <returns>The list item of the index</returns>
245         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
246         [EditorBrowsable(EditorBrowsableState.Never)]
247         public string GetListItem(uint index)
248         {
249             string ret = Interop.AutofillContainer.GetListItem(SwigCPtr, index);
250             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
251             return ret;
252         }
253
254         /// <summary>
255         /// Sets the selected item to fill out.
256         /// </summary>
257         /// <param name="selected">The selected item</param>
258         /// <since_tizen> 5 </since_tizen>
259         public void SetSelectedItem(string selected)
260         {
261             Interop.AutofillContainer.SetSelectedItem(SwigCPtr, selected);
262             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
263         }
264
265         internal AuthenticationSignalType AutofillServiceEventSignal()
266         {
267
268             AuthenticationSignalType ret = new AuthenticationSignalType(Interop.AutofillContainer.AutofillServiceEventSignal(SwigCPtr), false);
269             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
270             return ret;
271         }
272
273         internal ListEventSignalType AutofillListEventSignal()
274         {
275             ListEventSignalType ret = new ListEventSignalType(Interop.AutofillContainer.AutofillListEventSignal(SwigCPtr), false);
276             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
277             return ret;
278         }
279
280         /// <summary>
281         /// Dispose.
282         /// </summary>
283         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
284         [EditorBrowsable(EditorBrowsableState.Never)]
285         protected override void Dispose(DisposeTypes type)
286         {
287             if (disposed)
288             {
289                 return;
290             }
291
292             //Release your own unmanaged resources here.
293             //You should not access any managed member here except static instance.
294             //because the execution order of Finalizes is non-deterministic.
295             if (this != null)
296             {
297                 if (authenticationCallback != null)
298                 {
299                     AutofillServiceEventSignal().Disconnect(authenticationCallback);
300                 }
301
302                 if (listCallback != null)
303                 {
304                     AutofillListEventSignal().Disconnect(listCallback);
305                 }
306             }
307
308             base.Dispose(type);
309         }
310
311         /// This will not be public opened.
312         [EditorBrowsable(EditorBrowsableState.Never)]
313         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
314         {
315             Interop.AutofillContainer.DeleteAutofillContainer(swigCPtr);
316         }
317
318         private void OnServiceEvent(IntPtr autofillContainer)
319         {
320             AuthenticationEventArgs e = new AuthenticationEventArgs();
321             e.AutofillContainer = Registry.GetManagedBaseHandleFromNativePtr(autofillContainer) as AutofillContainer;
322
323             if (authenticationEventHandler != null)
324             {
325                 authenticationEventHandler(this, e);
326             }
327         }
328
329         private void OnListEvent(IntPtr control)
330         {
331             ListEventArgs e = new ListEventArgs();
332             e.Control = Registry.GetManagedBaseHandleFromNativePtr(control) as BaseComponents.View;
333
334             if (listEventHandler != null)
335             {
336                 listEventHandler(this, e);
337             }
338         }
339
340         /// <summary>
341         /// Event arguments that passed via the Authentication event.
342         /// </summary>
343         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
344         [EditorBrowsable(EditorBrowsableState.Never)]
345         public class AuthenticationEventArgs : EventArgs
346         {
347             /// <summary>
348             /// The instance of AutofillContainer
349             /// </summary>
350             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
351             [EditorBrowsable(EditorBrowsableState.Never)]
352             public AutofillContainer AutofillContainer
353             {
354                 get;
355                 set;
356             }
357         }
358
359         /// <summary>
360         /// AutofillContainer list event arguments.
361         /// </summary>
362         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
363         [EditorBrowsable(EditorBrowsableState.Never)]
364         public class ListEventArgs : EventArgs
365         {
366             /// <summary>
367             /// The instance of AutofillContainer
368             /// </summary>
369             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
370             [EditorBrowsable(EditorBrowsableState.Never)]
371             public BaseComponents.View Control
372             {
373                 get;
374                 set;
375             }
376
377         }
378
379         /// <summary>
380         /// Enumeration for hint of the autofill item.
381         /// </summary>
382         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
383         [EditorBrowsable(EditorBrowsableState.Never)]
384         public enum ItemHint
385         {
386             /// <summary>
387             /// Autofill hint for a credit card expiration date
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             CreditCardExpirationData,
392             /// <summary>
393             /// Autofill hint for a credit card expiration day
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             CreditCardExpirationDay,
398             /// <summary>
399             /// Autofill hint for a credit card expiration month
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             CreditCardExpirationMonth,
404             /// <summary>
405             /// Autofill hint for a credit card expiration year
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             CreditCardExpirationYear,
410             /// <summary>
411             /// Autofill hint for a credit card number
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             CreditCardNumber,
416             /// <summary>
417             /// Autofill hint for an email address
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             EmailAddress,
422             /// <summary>
423             /// Autofill hint for a user's real name
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             Name,
428             /// <summary>
429             /// Autofill hint for a phone number
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             Phone,
434             /// <summary>
435             /// Autofill hint for a postal address
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             PostalAddress,
440             /// <summary>
441             /// Autofill hint for a postal code
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             PostalCode,
446             /// <summary>
447             /// Autofill hint for a user's ID
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             Id,
452             /// <summary>
453             /// Autofill hint for password
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             Password,
458             /// <summary>
459             /// Autofill hint for a credit card security code
460             /// </summary>
461             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
462             [EditorBrowsable(EditorBrowsableState.Never)]
463             CreditCardSecurityCode
464         }
465     }
466 }