/* * Copyright(c) 2019 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ using System; using System.Runtime.InteropServices; using System.ComponentModel; namespace Tizen.NUI { /// /// AutofillContainer controls several text input boxes. /// /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public class AutofillContainer : BaseHandle { private AuthenticationEventCallbackType _authenticationCallback; private ListEventCallbackType _listCallback; private event EventHandler _authenticationEventHandler; private event EventHandler _listEventHandler; [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate void AuthenticationEventCallbackType(IntPtr autofillContainer); private delegate void ListEventCallbackType(IntPtr control); /// /// AutofillContainer Authentication Service Event. /// /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public event EventHandler ServiceEvent { add { if (_authenticationEventHandler == null) { _authenticationCallback = OnServiceEvent; AutofillServiceEventSignal().Connect(_authenticationCallback); } _authenticationEventHandler += value; } remove { _authenticationEventHandler -= value; if (_authenticationEventHandler == null && _authenticationCallback != null) { AutofillServiceEventSignal().Disconnect(_authenticationCallback); } } } /// /// AutofillContainer Fill List Event. /// /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public event EventHandler ListEvent { add { if (_listEventHandler == null) { _listCallback = OnListEvent; AutofillListEventSignal().Connect(_listCallback); } _listEventHandler += value; } remove { _listEventHandler -= value; if (_listEventHandler == null && _listCallback != null) { AutofillListEventSignal().Disconnect(_listCallback); } } } /// /// Constructor. /// /// The AutofillContainer name /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public AutofillContainer(string name) : this(Interop.AutofillContainer.New(name), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal AutofillContainer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.AutofillContainer.Upcast(cPtr), cMemoryOwn) { } internal static global::System.Runtime.InteropServices.HandleRef getCPtr(AutofillContainer obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr; } internal AutofillContainer(AutofillContainer autofillContainer) : this(Interop.AutofillContainer.NewAutofillContainer(AutofillContainer.getCPtr(autofillContainer)), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal AutofillContainer Assign(AutofillContainer autofillContainer) { AutofillContainer ret = new AutofillContainer(Interop.AutofillContainer.Assign(SwigCPtr, AutofillContainer.getCPtr(autofillContainer)), false); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal static AutofillContainer DownCast(BaseHandle handle) { AutofillContainer ret = new AutofillContainer(Interop.AutofillContainer.DownCast(BaseHandle.getCPtr(handle)), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Adds View and its Autofill item information to Autofill Container. /// /// The view to be added to Autofill Container /// The Property to be filled automatically of each View /// A unique ID that does not always change on each launching /// An auxiliary means to guess heuristically what data is /// The Hint - id (username), name, password, phone, credit card number, organization, and so on /// Whether this information is a sensitive data or not /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public void AddAutofillView(BaseComponents.View view, int propertyIndex, string id, string label, AutofillContainer.ItemHint hint, bool isSensitive) { Interop.AutofillContainer.AddAutofillView(SwigCPtr, BaseComponents.View.getCPtr(view), propertyIndex, id, label, (uint)hint, isSensitive); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Removes View and its AutofillItem information to Autofill Container. /// /// The view to be removed to Autofill Container /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public void RemoveAutofillItem(BaseComponents.View view) { Interop.AutofillContainer.RemoveAutofillItem(SwigCPtr, BaseComponents.View.getCPtr(view)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Stores autofill data. /// /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public void SaveAutofillData() { Interop.AutofillContainer.SaveAutofillData(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Sends a request for filling the data. /// /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public void RequestFillData() { Interop.AutofillContainer.RequestFillData(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Gets the Autofill Service Name. /// /// Autofill Service Name /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public string GetAutofillServiceName() { string ret = Interop.AutofillContainer.GetAutofillServiceName(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Gets the Autofill Service Message. /// /// Autofill Service Message /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public string GetAutofillServiceMessage() { string ret = Interop.AutofillContainer.GetAutofillServiceMessage(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Gets the Autofill Service Image Path. /// /// Autofill Service Image Path /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public string GetAutofillServiceImagePath() { string ret = Interop.AutofillContainer.GetAutofillServiceImagePath(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Gets the number of list items. (The presentation text of Autofill) /// /// The number of list items /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public uint GetListItemCount() { uint ret = Interop.AutofillContainer.GetListItemCount(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Gets the list item of the index. /// /// The index for the list /// The list item of the index /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public string GetListItem(uint index) { string ret = Interop.AutofillContainer.GetListItem(SwigCPtr, index); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Sets the selected item to fill out. /// /// The selected item /// 5 public void SetSelectedItem(string selected) { Interop.AutofillContainer.SetSelectedItem(SwigCPtr, selected); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal AuthenticationSignalType AutofillServiceEventSignal() { AuthenticationSignalType ret = new AuthenticationSignalType(Interop.AutofillContainer.AutofillServiceEventSignal(SwigCPtr), false); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal ListEventSignalType AutofillListEventSignal() { ListEventSignalType ret = new ListEventSignalType(Interop.AutofillContainer.AutofillListEventSignal(SwigCPtr), false); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Dispose. /// /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] protected override void Dispose(DisposeTypes type) { if (disposed) { return; } //Release your own unmanaged resources here. //You should not access any managed member here except static instance. //because the execution order of Finalizes is non-deterministic. if (this != null) { if (_authenticationCallback != null) { AutofillServiceEventSignal().Disconnect(_authenticationCallback); } if (_listCallback != null) { AutofillListEventSignal().Disconnect(_listCallback); } } base.Dispose(type); } /// This will not be public opened. [EditorBrowsable(EditorBrowsableState.Never)] protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr) { Interop.AutofillContainer.DeleteAutofillContainer(swigCPtr); } private void OnServiceEvent(IntPtr autofillContainer) { AuthenticationEventArgs e = new AuthenticationEventArgs(); e.AutofillContainer = Registry.GetManagedBaseHandleFromNativePtr(autofillContainer) as AutofillContainer; if (_authenticationEventHandler != null) { _authenticationEventHandler(this, e); } } private void OnListEvent(IntPtr control) { ListEventArgs e = new ListEventArgs(); e.Control = Registry.GetManagedBaseHandleFromNativePtr(control) as BaseComponents.View; if (_listEventHandler != null) { _listEventHandler(this, e); } } /// /// Event arguments that passed via the Authentication event. /// /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public class AuthenticationEventArgs : EventArgs { /// /// The instance of AutofillContainer /// /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public AutofillContainer AutofillContainer { get; set; } } /// /// AutofillContainer list event arguments. /// /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public class ListEventArgs : EventArgs { /// /// The instance of AutofillContainer /// /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public BaseComponents.View Control { get; set; } } /// /// Enumeration for hint of the autofill item. /// /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public enum ItemHint { /// /// Autofill hint for a credit card expiration date /// /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] CreditCardExpirationData, /// /// Autofill hint for a credit card expiration day /// /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] CreditCardExpirationDay, /// /// Autofill hint for a credit card expiration month /// /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] CreditCardExpirationMonth, /// /// Autofill hint for a credit card expiration year /// /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] CreditCardExpirationYear, /// /// Autofill hint for a credit card number /// /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] CreditCardNumber, /// /// Autofill hint for an email address /// /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] EmailAddress, /// /// Autofill hint for a user's real name /// /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] Name, /// /// Autofill hint for a phone number /// /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] Phone, /// /// Autofill hint for a postal address /// /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] PostalAddress, /// /// Autofill hint for a postal code /// /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] PostalCode, /// /// Autofill hint for a user's ID /// /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] Id, /// /// Autofill hint for password /// /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] Password, /// /// Autofill hint for a credit card security code /// /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] CreditCardSecurityCode } } }