[Tizen] Add DALi Autofill implementation
[platform/core/uifw/dali-adaptor.git] / dali / internal / input / tizen-wayland / autofill-item-impl-ecore-wl.h
1 #ifndef DALI_INTERNAL_AUTOFILL_ITEM_IMPL_ECORE_WL_H
2 #define DALI_INTERNAL_AUTOFILL_ITEM_IMPL_ECORE_WL_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/public-api/object/base-object.h>
23 #ifdef CAPI_AUTOFILL_SUPPORT
24 #include <autofill.h>
25 #endif // CAPI_AUTOFILL_SUPPORT
26 #include <vector>
27
28 // INTERNAL INCLUDES
29 #include <dali/internal/input/common/autofill-item-impl.h>
30
31 namespace Dali
32 {
33
34 namespace Internal
35 {
36
37 namespace Adaptor
38 {
39
40
41 /**
42  * @brief This class is used to pass on data from the AutofillItem of control.
43  */
44 class AutofillItemEcorewWl : public Dali::Internal::Adaptor::AutofillItem
45 {
46
47 public:
48
49   /**
50    * @brief Constructor.
51    *
52    * @param[in] id A unique ID for this AutofillItem
53    * @param[in] label An auxiliary means to guess what data is
54    * @param[in] hint The hint - id (username), name, password, phone, credit card number, organization, and so on
55    * @param[in] sensitiveData Whether this AutofillItem is a sensitive data or not. (The default is false)
56    * @return A public handle to the newly allocated AutofillItem
57    */
58   static Dali::AutofillItem New( const std::string& id, const std::string& label, Dali::AutofillItem::Hint hint, bool sensitiveData );
59
60   /**
61    * @brief Initialize AutofillItem constructor.
62    */
63   void Initialize() override;
64
65   /**
66    * @copydoc Dali::AutofillItem::GetId()
67    */
68   const std::string& GetId() const override;
69
70   /**
71    * @copydoc Dali::AutofillItem::GetLabel()
72    */
73   const std::string& GetLabel() const override;
74
75   /**
76    * @copydoc Dali::AutofillItem::GetHint()
77    */
78   Dali::AutofillItem::Hint GetHint() const override;
79
80   /**
81    * @copydoc Dali::AutofillItem::IsSensitiveData()
82    */
83   bool IsSensitiveData() const override;
84
85   /**
86    * @copydoc Dali::AutofillItem::SetSaveValue()
87    */
88   void SetSaveValue( const std::string& value ) override;
89
90   /**
91    * @copydoc Dali::AutofillItem::GetSaveValue()
92    */
93   const std::string& GetSaveValue() const override;
94
95 #ifdef CAPI_AUTOFILL_SUPPORT
96   /**
97    * @brief Gets Autofill framework item handle
98    * @return Autofill framework item handle, which type is 'autofill_item_h'
99    */
100   autofill_item_h GetAutofillItemHandle();
101
102   /**
103    * @brief Gets Autofill framework save item handle
104    * @return Autofill framework save item handle, which type is 'autofill_save_item_h'
105    */
106   autofill_save_item_h GetAutofillSaveItemHandle();
107 #endif // CAPI_AUTOFILL_SUPPORT
108
109   /**
110    * @brief Adds the presentation text to fill out in the list.
111    *
112    * @param[in] presentationText The presentation text to fill out
113    */
114   void AddPresentationList( const std::string& presentationText ) override;
115
116   /**
117    * @brief Adds the value to fill out in the list.
118    *
119    * @param[in] fillValue The value to fill out
120    */
121   void AddFillValueList( const std::string& fillValue ) override;
122
123   /**
124    * @copydoc Dali::AutofillItem::GetPresentationText()
125    */
126   const std::string& GetPresentationText( int index ) const override;
127
128   /**
129    * @copydoc Dali::AutofillItem::GetFillValue()
130    */
131   const std::string& GetFillValue( int index ) const override;
132
133   /**
134    * @copydoc Dali::AutofillItem::ClearPresentationTextList()
135    */
136   void ClearPresentationTextList() override;
137
138   /**
139    * @copydoc Dali::AutofillItem::ClearFillValueList()
140    */
141   void ClearFillValueList() override;
142
143   /**
144    * @copydoc Dali::AutofillItem::GetFillValueCount()
145    */
146   unsigned int GetFillValueCount() override;
147
148 private:
149   /**
150    * Constructor.
151    */
152   explicit AutofillItemEcorewWl( const std::string& id, const std::string& label, Dali::AutofillItem::Hint hint, bool sensitiveData );
153
154 protected:
155   /**
156    * Destructor.
157    */
158   ~AutofillItemEcorewWl();
159
160 private:
161   // Undefined copy constructor
162   explicit AutofillItemEcorewWl( const AutofillItemEcorewWl& autofillItem ) = delete;
163
164   // Undefined assignment operator
165   AutofillItemEcorewWl& operator=( AutofillItemEcorewWl& autofillItem ) = delete;
166
167 private:
168 #ifdef CAPI_AUTOFILL_SUPPORT
169   autofill_item_h mAutofillItemHandle;          ///< The Autofill Framework item handle
170   autofill_save_item_h mAutofillSaveItemHandle; ///< The Autofill Framework save item handle for save
171 #endif // CAPI_AUTOFILL_SUPPORT
172
173 // Data
174 private:
175   std::string mId;                      ///< The AutofillItem ID
176   std::string mLabel;                   ///< The AutofillItem Label
177   Dali::AutofillItem::Hint mHint;       ///< The AutofillItem Hint (id (username), name, password, phone, credit card number, organization, so on)
178   bool mSensitiveData;                  ///< Whether the data is sensitive or not
179
180   std::string mValue;
181
182   std::vector<std::string> mPresentationTextList; ///< The list for the presentation text to fill out
183   std::vector<std::string> mValueList;            ///< The list for the value to fill out
184
185 };
186
187
188
189 } // namespace Adaptor
190
191 } // namespace Internal
192
193 } // namespace Dali
194
195 #endif // DALI_INTERNAL_AUTOFILL_ITEM_IMPL_ECORE_WL_H