2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/input/ubuntu-x11/autofill-manager-impl-x.h>
22 #include <dali/public-api/object/type-registry.h>
23 #include <dali/devel-api/common/singleton-service.h>
24 #include <dali/integration-api/debug.h>
27 #include <dali/internal/adaptor/common/adaptor-impl.h>
40 #if defined(DEBUG_ENABLED)
41 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_AUTOFILL");
45 const char* const SIGNAL_AUTHENTICATION_RECEIVED = "authenticationReceived";
46 const char* const SIGNAL_FILL_RESPONSE_RECEIVED = "fillResponseReceived";
47 const char* const SIGNAL_LIST_RECEIVED = "listReceived";
51 return Dali::AutofillManager::Get();
54 Dali::TypeRegistration typeRegistration( typeid(Dali::AutofillManager), typeid(Dali::BaseHandle), Create );
56 Dali::SignalConnectorType signalConnector1( typeRegistration, SIGNAL_AUTHENTICATION_RECEIVED, Dali::Internal::Adaptor::AutofillManagerX::DoConnectSignal );
57 Dali::SignalConnectorType signalConnector2( typeRegistration, SIGNAL_FILL_RESPONSE_RECEIVED, Dali::Internal::Adaptor::AutofillManagerX::DoConnectSignal );
58 Dali::SignalConnectorType signalConnector3( typeRegistration, SIGNAL_LIST_RECEIVED, Dali::Internal::Adaptor::AutofillManagerX::DoConnectSignal );
60 } // unnamed namespace
64 Dali::AutofillManager AutofillManagerX::Get()
66 Dali::AutofillManager autofill;
67 AutofillManagerX *autofillPtr = NULL;
69 Dali::SingletonService service( SingletonService::Get() );
72 // Check whether the singleton is already created
73 Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::AutofillManager ) );
76 // If so, downcast the handle
77 autofillPtr = dynamic_cast< AutofillManagerX* >( handle.GetObjectPtr() );
78 autofill = Dali::AutofillManager( autofillPtr );
80 else if( Adaptor::IsAvailable() )
82 // Create instance and register singleton only if the adaptor is available
83 autofillPtr = new AutofillManagerX();
84 autofill = Dali::AutofillManager( autofillPtr );
85 service.Register( typeid( autofill ), autofill );
92 AutofillManagerX::AutofillManagerX()
94 mAuthenticationServiceName(""),
95 mAuthenticationServiceMessage(""),
96 mAuthenticationServiceImagePath(""),
98 mFillItemPresentationText(""),
100 mIsDataPresent( false ),
101 mIsAuthNeeded( false )
105 AutofillManagerX::~AutofillManagerX()
110 void AutofillManagerX::ConnectCallbacks()
114 void AutofillManagerX::CreateContext()
118 void AutofillManagerX::DeleteContext()
120 DALI_LOG_INFO( gLogFilter, Debug::General, "AutofillManagerX::DeleteContext\n" );
125 /////////////////////////////////////////////// Autofill Item and Group ///////////////////////////////////////////////
127 Dali::AutofillItem AutofillManagerX::CreateAutofillItem( const std::string& id, const std::string& label, Dali::AutofillItem::Hint hint, bool isSensitive )
129 DALI_LOG_INFO( gLogFilter, Debug::General, "AutofillManagerX::CreateAutofillItem \n" );
131 Dali::AutofillItem item = AutofillItem::New( id, label, hint, isSensitive );
132 mAutofillItemList.push_back( item );
134 return mAutofillItemList.back();
137 Dali::AutofillGroup AutofillManagerX::CreateAutofillGroup( const std::string& groupId )
139 DALI_LOG_INFO( gLogFilter, Debug::General, "AutofillManagerX::CreateAutofillGroup \n" );
141 Dali::AutofillGroup group = AutofillGroup::New( groupId );
142 mAutofillGroupList.push_back( group );
144 return mAutofillGroupList.back();
148 /////////////////////////////////////////////// Autofill Authentication Information ///////////////////////////////////////////////
150 bool AutofillManagerX::IsAutofillDataPresent() const
152 return mIsDataPresent;
155 bool AutofillManagerX::IsAuthenticationNeeded() const
157 return mIsAuthNeeded;
160 const std::string& AutofillManagerX::GetAuthenticationServiceName() const
162 return mAuthenticationServiceName;
165 const std::string& AutofillManagerX::GetAuthenticationServiceMessage() const
167 return mAuthenticationServiceMessage;
170 const std::string& AutofillManagerX::GetAuthenticationServiceImagePath() const
172 return mAuthenticationServiceImagePath;
176 /////////////////////////////////////////////// Autofill Fill Response ///////////////////////////////////////////////
178 const std::string& AutofillManagerX::GetFillItemId() const
183 const std::string& AutofillManagerX::GetFillItemPresentationText() const
185 return mFillItemPresentationText;
188 const std::string& AutofillManagerX::GetFillItemValue() const
190 return mFillItemValue;
193 void AutofillManagerX::SaveAutofillData( Dali::AutofillGroup group )
195 DALI_LOG_INFO( gLogFilter, Debug::General, "AutofillManagerX::SaveAutofillData\n" );
200 AutofillManagerX::AuthSignalType& AutofillManagerX::AuthenticationReceivedSignal()
202 return mAuthReceivedSignal;
205 AutofillManagerX::FillSignalType& AutofillManagerX::FillResponseReceivedSignal()
207 return mFillReceivedSignal;
210 AutofillManagerX::ListSignalType& AutofillManagerX::ListEventSignal()
212 return mListReceivedSignal;
215 bool AutofillManagerX::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
217 Dali::BaseHandle handle( object );
219 bool connected( true );
220 AutofillManagerX* manager = dynamic_cast< AutofillManagerX* >( object );
224 if( 0 == signalName.compare( SIGNAL_AUTHENTICATION_RECEIVED ) )
226 manager->AuthenticationReceivedSignal().Connect( tracker, functor );
228 else if( 0 == signalName.compare( SIGNAL_FILL_RESPONSE_RECEIVED ) )
230 manager->FillResponseReceivedSignal().Connect( tracker, functor );
232 else if( 0 == signalName.compare( SIGNAL_LIST_RECEIVED ) )
234 manager->ListEventSignal().Connect( tracker, functor );
238 // signalName does not match any signal