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