[Tizen] Add AutofillContainer class and autofill implementation
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / controls / text-controls / autofill-container.h
1 #ifndef DALI_TOOLKIT_AUTO_FILL_CONTAINER_H
2 #define DALI_TOOLKIT_AUTO_FILL_CONTAINER_H
3
4 /*
5  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/devel-api/adaptor-framework/autofill-item.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/public-api/controls/control.h>
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 namespace Internal DALI_INTERNAL
34 {
35 class AutofillContainer;
36 }
37
38 /**
39  * @brief AutofillContainer controls several text input boxes (Dali::Toolkit::TextField and Dali::Toolkit::TextEditor).
40  *
41  * It can make these editors a group of text boxes.
42  */
43 class DALI_TOOLKIT_API AutofillContainer : public BaseHandle
44 {
45 public:
46
47   // TODO : Need to update parameter and return value according to each Signal
48   typedef Signal< void (AutofillContainer&) > AuthenticationSignalType;  ///< Authentication Signal Type
49   typedef Signal< void (Control&) > ListShownSignalType;                 ///<  List Shown Signal Type
50
51 public:
52
53   /**
54    * @brief Creates the AutofillContainer.
55    *
56    * @param[in] name The AutofillContainer name
57    * @return A handle to the AutofillContainer
58    */
59   static AutofillContainer New( const std::string& name );
60
61   /**
62    * @brief Creates an empty handle.
63    */
64   AutofillContainer();
65
66   /**
67    * @brief Copy constructor.
68    *
69    * @param[in] handle The handle to copy from
70    */
71   AutofillContainer( const AutofillContainer& handle );
72
73   /**
74    * @brief Assignment operator.
75    *
76    * @param[in] handle The handle to copy from
77    * @return A reference to this
78    */
79   AutofillContainer& operator=( const AutofillContainer& handle );
80
81   /**
82    * @brief Destructor.
83    *
84    * This is non-virtual since derived Handle types must not contain data or virtual methods.
85    */
86   ~AutofillContainer();
87
88   /**
89    * @brief Downcasts a handle to AutofillContainer.
90    *
91    * If the BaseHandle points is a AutofillContainer, the downcast returns a valid handle.
92    * If not, the returned handle is left empty.
93    *
94    * @param[in] handle Handle to an object
95    * @return Handle to a AutofillContainer or an empty handle
96    */
97   static AutofillContainer DownCast( BaseHandle handle );
98
99   /**
100    * @brief Adds Control and AutofillItem information to Autofill Container.
101    *
102    * @param[in] control The control to be added to Autofill Container
103    * @param[in] propertyIndex The Property to be filled automatically of each Control
104    * @param[in] id A unique ID that does not always change on each launching
105    * @param[in] label An auxiliary means to guess heuristically what data is
106    * @param[in] hint The Hint - id (username), name, password, phone, credit card number, organization, and so on
107    * @param[in] isSensitive Whether this information is a sensitive data or not
108    */
109   void AddAutofillItem( Control control, Property::Index propertyIndex, const std::string& id, const std::string& label, Dali::AutofillItem::Hint hint, bool isSensitive );
110
111   /**
112    * @brief Removes Control and its AutofillItem information to Autofill Container.
113    *
114    * @param[in] control The control to be removed
115    */
116   void RemoveAutofillItem( Control control );
117
118   /**
119    * @brief Sets that a control is focused.
120    *
121    * @param focused The focused control
122    */
123   void SetFocusedControl( Toolkit::Control focused );
124
125   /**
126    * @brief Gets the focused control.
127    *
128    * @return The focused control
129    */
130   Toolkit::Control GetFocusedControl();
131
132   /**
133    * @brief Stores autofill data.
134    */
135   void SaveAutofillData();
136
137   /**
138    * @brief Sends a request for filling the data.
139    */
140   void RequestFillData();
141
142   /**
143    * @brief Gets the Autofill Service Name.
144    *
145    * @return Autofill Service Name
146    */
147   const std::string& GetAutofillServiceName() const;
148
149   /**
150    * @brief Gets the Autofill Service Message.
151    *
152    * @return Autofill Service Message
153    */
154   const std::string& GetAutofillServiceMessage() const;
155
156   /**
157    * @brief Gets the Autofill Service Image Path.
158    *
159    * @return Autofill Service Image Path
160    */
161   const std::string& GetAutofillServiceImagePath() const;
162
163   /**
164    * @brief Gets the number of list items. (The presentation text of Autofill)
165    *
166    * @return The number of list items
167    */
168   unsigned int GetListCount();
169
170   /**
171    * @brief Gets the list item of the index.
172    *
173    * @param[in] index The index for the list
174    * @return The list item of the index
175    */
176   const std::string& GetListItem( unsigned int index ) const;
177
178   /**
179    * @brief Sets the selected item to fill out.
180    *
181    * @param[in] selected The selected item
182    */
183   void SetSelectedItem( const std::string& selected );
184
185 public:
186   // Signals
187
188   /**
189    * @brief AutofillServiceShownSignal
190    *
191    * @return The signal containing the received data
192    */
193   AuthenticationSignalType& AutofillServiceShownSignal();
194
195   /**
196    * @brief AutofillListShownSignal
197    *
198    * @return The signal containing the received data
199    */
200   ListShownSignalType& AutofillListShownSignal();
201
202
203 public: // Not intended for application developers
204
205   /**
206    * @brief Creates a handle using the Toolkit::Internal implementation.
207    *
208    * @param[in] implementation The Control implementation
209    */
210   DALI_INTERNAL AutofillContainer( Internal::AutofillContainer* implementation );
211
212 };
213
214
215 } // namespace Toolkit
216
217 } // namespace Dali
218
219 #endif // DALI_TOOLKIT_AUTO_FILL_CONTAINER_H