[Tizen] Add DALi Autofill implementation
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / autofill-manager.h
1 #ifndef DALI_AUTOFILL_MANAGER_H
2 #define DALI_AUTOFILL_MANAGER_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-handle.h>
23 #include <dali/public-api/signals/dali-signal.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/public-api/dali-adaptor-common.h>
27 #include <dali/devel-api/adaptor-framework/autofill-group.h>
28
29 namespace Dali
30 {
31
32 namespace Internal DALI_INTERNAL
33 {
34 namespace Adaptor
35 {
36 class AutofillManager;
37 }
38 }
39
40
41 /**
42  * @brief The AutofillManager class
43  *
44  * allows the application to fill out the user data, such as email, account and address previously saved.
45  * Currently, Autofill is limited to text input box. Later it can be ScrollView, etc.
46  *
47  * Signals
48  * | %Signal Name           | Method                              |
49  * |------------------------|-------------------------------------|
50  * | authenticationReceived | @ref AuthenticationReceivedSignal() |
51  * | fillResponseReceived   | @ref FillResponseReceivedSignal()   |
52  */
53 class DALI_ADAPTOR_API AutofillManager : public BaseHandle
54 {
55 public:
56
57
58   // TODO : Need to update parameter and return value according to each Signal
59   typedef Signal< void () > AuthSignalType;                ///< Authentication Received Signal
60   typedef Signal< void ( AutofillItem ) > FillSignalType;  ///< Fill Response Received Signal
61   typedef Signal< void () > ListSignalType;                ///< List Event Signal for multi-group
62
63 public:
64
65   /**
66    * @brief Retrieves a handle to the instance of AutofillManager.
67    *
68    * @return A handle to the AutofillManager.
69    */
70   static AutofillManager Get();
71
72
73   /////////////////////////////////////////////// Autofill Item and Group ///////////////////////////////////////////////
74
75   /**
76    * @brief Creates AutofillItem instance.
77    *
78    * @param[in] id A unique ID that does not always change on each launching
79    * @param[in] label An auxiliary means to guess heuristically what data is
80    * @param[in] hint The Hint - id (username), name, password, phone, credit card number, organization, and so on
81    * @param[in] isSensitive Whether this AutofillItem is a sensitive data or not
82    * @return A public handle to the newly allocated AutofillItem
83    */
84   Dali::AutofillItem CreateAutofillItem( const std::string& id, const std::string& label, Dali::AutofillItem::Hint hint, bool isSensitive );
85
86   /**
87    * @brief Creates AutofillGroup instance.
88    *
89    * @param[in] groupId A unique ID value of each AutofillGroup
90    * @return A public handle to the newly allocated AutofillGroup
91    */
92   Dali::AutofillGroup CreateAutofillGroup( const std::string& groupId );
93
94
95   /////////////////////////////////////////////// Autofill Authentication Information ///////////////////////////////////////////////
96
97   /**
98    * @brief Gets the 'autofill data present' attribute in autofill authentication information.
99    *
100    * @return True if Autofill data is present
101    */
102   bool IsAutofillDataPresent() const;
103
104   /**
105    * @brief Gets the 'authentication needed' attribute in autofill authentication information.
106    *
107    * @return True if the authentication is needed in the current Autofill process.
108    */
109   bool IsAuthenticationNeeded() const;
110
111   /**
112    * @brief Gets the service name in autofill authentication information.
113    *
114    * @return The autofill authentication service name
115    */
116   const std::string& GetAuthenticationServiceName() const;
117
118   /**
119    * @brief Gets the service message in autofill authentication information.
120    *
121    * @return The autofill authentication service message
122    */
123   const std::string& GetAuthenticationServiceMessage() const;
124
125   /**
126    * @brief Gets the service logo image path in autofill authentication information.
127    *
128    * @return The autofill authentication service logo image path
129    */
130   const std::string& GetAuthenticationServiceImagePath() const;
131
132
133   /////////////////////////////////////////////// Autofill Fill Response ///////////////////////////////////////////////
134
135   /**
136    * @brief Gets the autofill ID in an autofill fill response item.
137    *
138    * @return The autofill fill response item ID
139    */
140   const std::string& GetFillItemId() const;
141
142   /**
143    * @brief Gets the presentation text in an autofill fill response item.
144    *
145    * @return The presentation text
146    */
147   const std::string& GetFillItemPresentationText() const;
148
149   /**
150    * @brief Gets the autofill value in an autofill fill response item.
151    *
152    * @return The autofill fill response item value
153    */
154   const std::string& GetFillItemValue() const;
155
156   /**
157    * @brief Stores the current Autofill data.
158    *
159    * @param[in] group The AutofillGroup to store the data
160    */
161   void SaveAutofillData( Dali::AutofillGroup group );
162
163 public:
164   // Signals
165   /**
166    * @brief This is emitted when the authentication is needed and AutofillManager gets the information.
167    *
168    * @return The signal containing the received data
169    */
170   AuthSignalType& AuthenticationReceivedSignal();
171
172   /**
173    * @brief This is emitted when AutofillManager receives the fill response.
174    *
175    * @return The signal containing the received data
176    */
177   FillSignalType& FillResponseReceivedSignal();
178
179   /**
180    * @brief This is emitted when the list for multi fill response group is needed.
181    *
182    * @return The signal containing the received data
183    */
184   ListSignalType& ListEventSignal();
185
186   // Construction & Destruction
187   /**
188    * @brief Constructor.
189    *
190    * Create an uninitialized handle.
191    * This can be initialized by calling AutofillManager::Get().
192    */
193   AutofillManager();
194
195   /**
196    * @brief Destructor
197    *
198    * This is non-virtual since derived Handle types must not contain data or virtual methods.
199    */
200   ~AutofillManager();
201
202   /**
203    * @brief This constructor is used by AutofillManager::Get().
204    *
205    * @param[in] autofillManager A pointer to the AutofillManager.
206    */
207   explicit DALI_INTERNAL AutofillManager( Internal::Adaptor::AutofillManager* autofillManager );
208
209 };
210
211 } // namespace Dali
212
213 #endif // DALI_AUTOFILL_MANAGER_H