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