[Tizen] Add DALi Autofill implementation
[platform/core/uifw/dali-adaptor.git] / dali / internal / input / tizen-wayland / autofill-manager-impl-ecore-wl.h
1 #ifndef DALI_INTERNAL_AUTOFILL_MANAGER_IMPL_ECORE_WL_H
2 #define DALI_INTERNAL_AUTOFILL_MANAGER_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-manager-impl.h>
30 #include <dali/internal/input/tizen-wayland/autofill-group-impl-ecore-wl.h>
31
32 namespace Dali
33 {
34
35 namespace Internal
36 {
37
38 namespace Adaptor
39 {
40
41 class AutofillManagerEcoreWl : public Dali::Internal::Adaptor::AutofillManager
42 {
43
44 public:
45
46   using AuthSignalType = Dali::AutofillManager::AuthSignalType;
47   using FillSignalType = Dali::AutofillManager::FillSignalType;
48   using ListSignalType = Dali::AutofillManager::ListSignalType;
49
50 public:
51
52   /**
53    * @brief Gets the AutofillManager instance
54    *
55    * It creates the instance if it has not already been created.
56    * Internally, a check should be made using IsAvailable() before this is called as we do not want
57    * to create an instance if not needed by applications.
58    * @see IsAvailable()
59    */
60   static Dali::AutofillManager Get();
61
62   /**
63    * @brief Connects Callbacks required for Autofill daemon.
64    */
65   void ConnectCallbacks() override;
66
67 #ifdef CAPI_AUTOFILL_SUPPORT
68
69   /**
70    * @brief Gets Autofill framework handle
71    * @return Autofill framework handle, which type is 'autofill_h"
72    */
73   autofill_h GetAutofillHandle();
74
75   /**
76    * @brief Implement to receives Autofill Authentication Information callback.
77    *
78    * In this method, gets authentication information and emits the signal to check the authentication.
79    * @param authInfoHandle The autofill authentication information handle
80    * @param data The data from authentication information callback
81    */
82   void ReceiveAuthInfo( autofill_auth_info_h authInfoHandle, void *data );
83
84   /**
85    * @brief Implement to fill out the data.
86    *
87    * This method would emit the signal to fill out the data.
88    * @param itemHandle The autofill fill response item handle
89    * @param userData The data from fill response callback
90    */
91   void FillGroupItem( autofill_fill_response_item_h itemHandle, void *userData );
92
93   /**
94    * @brief Implement to set multiple group information.
95    *
96    * This method would emit the signals to make lists and fill out the data.
97    * @param itemHandle The autofill fill response item handle
98    * @param userData The data from fill response callback
99    */
100   void FillMultipleGroupItem( autofill_fill_response_item_h itemHandle, void *userData );
101 #endif // CAPI_AUTOFILL_SUPPORT
102
103
104   /////////////////////////////////////////////// Autofill Item and Group ///////////////////////////////////////////////
105
106   /**
107    * @copydoc Dali::AutofillManager::CreateAutofillItem()
108    */
109   Dali::AutofillItem CreateAutofillItem( const std::string& id, const std::string& label, Dali::AutofillItem::Hint hint, bool isSensitive ) override;
110
111   /**
112    * @copydoc Dali::AutofillManager::CreateAutofillGroup()
113    */
114   Dali::AutofillGroup CreateAutofillGroup( const std::string& groupId ) override;
115
116
117   /////////////////////////////////////////////// Autofill Authentication Information ///////////////////////////////////////////////
118
119   /**
120    * @copydoc Dali::AutofillManager::IsAutofillDataPresent()
121    */
122   bool IsAutofillDataPresent() const override;
123
124   /**
125    * @copydoc Dali::AutofillManager::IsAuthenticationNeeded()
126    */
127   bool IsAuthenticationNeeded() const override;
128
129   /**
130    * @copydoc Dali::AutofillManager::GetAuthenticationServiceName()
131    */
132   const std::string& GetAuthenticationServiceName() const override;
133
134   /**
135    * @copydoc Dali::AutofillManager::GetAuthenticationServiceMessage()
136    */
137   const std::string& GetAuthenticationServiceMessage() const override;
138
139   /**
140    * @copydoc Dali::AutofillManager::GetAuthenticationServiceImagePath()
141    */
142   const std::string& GetAuthenticationServiceImagePath() const override;
143
144
145   /////////////////////////////////////////////// Autofill Fill Response ///////////////////////////////////////////////
146
147   /**
148    * @copydoc Dali::AutofillManager::GetFillItemId()
149    */
150   const std::string& GetFillItemId() const override;
151
152   /**
153    * @copydoc Dali::AutofillManager::GetFillItemPresentationText()
154    */
155   const std::string& GetFillItemPresentationText() const override;
156
157   /**
158    * @copydoc Dali::AutofillManager::GetFillItemValue()
159    */
160   const std::string& GetFillItemValue() const override;
161
162   /**
163    * @copydoc Dali::AutofillManager::SaveAutofillData()
164    */
165   void SaveAutofillData( Dali::AutofillGroup group ) override;
166
167 public: // Signals
168
169   /**
170    * @copydoc Dali::AutofillManager::AuthenticationReceivedSignal()
171    */
172   AuthSignalType& AuthenticationReceivedSignal() override;
173
174   /**
175    * @copydoc Dali::AutofillManager::FillResponseReceivedSignal()
176    */
177   FillSignalType& FillResponseReceivedSignal() override;
178
179   /**
180    * @copydoc Dali::AutofillManager::ListEventSignal()
181    */
182   ListSignalType& ListEventSignal() override;
183
184   /**
185    * Connects a callback function with the object's signals.
186    * @param[in] object The object providing the signal.
187    * @param[in] tracker Used to disconnect the signal.
188    * @param[in] signalName The signal to connect to.
189    * @param[in] functor A newly allocated FunctorDelegate.
190    * @return True if the signal was connected.
191    * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
192    */
193   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
194
195 private:
196   /**
197    * Context created the first time and kept until deleted.
198    */
199   void CreateContext() override;
200
201   /**
202    * Delete Autofill context.
203    */
204   void DeleteContext() override;
205
206 private:
207   /**
208    * Constructor.
209    */
210   explicit AutofillManagerEcoreWl();
211
212 protected:
213   /**
214    * Destructor.
215    */
216   ~AutofillManagerEcoreWl();
217
218 private:
219   // Undefined copy constructor
220   explicit AutofillManagerEcoreWl( const AutofillManagerEcoreWl& autofillManager ) = delete;
221
222   // Undefined assignment operator
223   AutofillManagerEcoreWl& operator=( AutofillManagerEcoreWl& autofillManager ) = delete;
224
225 private:
226 #ifdef CAPI_AUTOFILL_SUPPORT
227   autofill_h mAutofillHandle;        ///< The Autofill framework handle
228 #endif // CAPI_AUTOFILL_SUPPORT
229   Dali::AutofillGroup mAutofillGroup;
230
231   std::vector<Dali::AutofillGroup> mAutofillGroupList;     ///< The list to manage AutofillGroup
232   std::vector<Dali::AutofillItem> mAutofillItemList;       ///< The list to manage AutofillItem
233
234 private:
235   AuthSignalType mAuthReceivedSignal;                      ///< Authentication Received Signal
236   FillSignalType mFillReceivedSignal;                      ///< Fill Response Received Signal
237   ListSignalType mListReceivedSignal;                      ///< List Received Signal
238
239 private:
240   std::string mAuthenticationServiceName;                  ///< The autofill authentication service name
241   std::string mAuthenticationServiceMessage;               ///< The autofill authentication service message
242   std::string mAuthenticationServiceImagePath;             ///< The autofill authentication service logo image path
243   std::string mFillItemId;                                 ///< The autofill fill response item ID
244   std::string mFillItemPresentationText;                   ///< The autofill fill response item presentation text
245   std::string mFillItemValue;                              ///< The autofill fill response item value (input data)
246
247   bool mIsDataPresent;                                      ///< The autofill data presence
248   bool mIsAuthNeeded;                                       ///< The authentication need
249
250 };
251
252 } // namespace Adaptor
253
254 } // namespace Internal
255
256 } // namespace Dali
257
258 #endif // DALI_INTERNAL_AUTOFILL_MANAGER_IMPL_ECORE_WL_H