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/tizen-wayland/autofill-item-impl-ecore-wl.h>
22 #include <dali/public-api/object/type-registry.h>
23 #include <dali/integration-api/debug.h>
36 #if defined(DEBUG_ENABLED)
37 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_AUTOFILL");
42 return Dali::Internal::Adaptor::AutofillItem::New( "", "", Dali::AutofillItem::Hint::ID, false );
45 Dali::TypeRegistration type( typeid(Dali::AutofillItem), typeid(Dali::BaseHandle), Create );
47 } // unnamed namespace
50 AutofillItemEcorewWl::AutofillItemEcorewWl( const std::string& id, const std::string& label, Dali::AutofillItem::Hint hint, bool sensitiveData )
54 mSensitiveData( sensitiveData ),
56 mPresentationTextList(),
59 #ifdef CAPI_AUTOFILL_SUPPORT
60 mAutofillItemHandle = NULL;
61 mAutofillSaveItemHandle = NULL;
62 #endif // CAPI_AUTOFILL_SUPPORT
65 AutofillItemEcorewWl::~AutofillItemEcorewWl()
67 #ifdef CAPI_AUTOFILL_SUPPORT
68 if( mAutofillItemHandle )
70 autofill_item_destroy( mAutofillItemHandle );
71 mAutofillItemHandle = NULL;
74 if( mAutofillSaveItemHandle )
76 autofill_save_item_destroy( mAutofillSaveItemHandle );
77 mAutofillSaveItemHandle = NULL;
79 #endif // CAPI_AUTOFILL_SUPPORT
83 Dali::AutofillItem AutofillItemEcorewWl::New( const std::string& id, const std::string& label, Dali::AutofillItem::Hint hint, bool sensitiveData )
85 Dali::Internal::Adaptor::AutofillItem* item = new Dali::Internal::Adaptor::AutofillItemEcorewWl( id, label, hint, sensitiveData );
86 Dali::AutofillItem handle = Dali::AutofillItem( item );
92 void AutofillItemEcorewWl::Initialize()
94 #ifdef CAPI_AUTOFILL_SUPPORT
95 int ret = autofill_item_create( &mAutofillItemHandle );
96 if( ret != AUTOFILL_ERROR_NONE )
98 DALI_LOG_ERROR( "Failed to create autofill item handle : %d \n", ret );
102 autofill_item_set_id( mAutofillItemHandle, mId.c_str() );
103 autofill_item_set_label( mAutofillItemHandle, mLabel.c_str() );
104 autofill_item_set_sensitive_data( mAutofillItemHandle, mSensitiveData );
106 // Create autofill save item handle for save.
107 autofill_save_item_create( &mAutofillSaveItemHandle );
108 autofill_save_item_set_id( mAutofillSaveItemHandle, mId.c_str() );
109 autofill_save_item_set_label( mAutofillSaveItemHandle, mLabel.c_str() );
110 autofill_save_item_set_sensitive_data( mAutofillSaveItemHandle, mSensitiveData );
112 autofill_hint_e value = static_cast<autofill_hint_e>(mHint);
113 autofill_item_set_autofill_hint( mAutofillItemHandle, value );
114 autofill_save_item_set_autofill_hint( mAutofillSaveItemHandle, value);
115 #endif // CAPI_AUTOFILL_SUPPORT
118 const std::string& AutofillItemEcorewWl::GetId() const
120 DALI_LOG_INFO( gLogFilter, Debug::General, "AutofillItemEcorewWl::GetId \n" );
124 const std::string& AutofillItemEcorewWl::GetLabel() const
126 DALI_LOG_INFO( gLogFilter, Debug::General, "AutofillItemEcorewWl::GetLabel \n" );
131 Dali::AutofillItem::Hint AutofillItemEcorewWl::GetHint() const
133 DALI_LOG_INFO( gLogFilter, Debug::General, "AutofillItemEcorewWl::GetHint \n" );
137 bool AutofillItemEcorewWl::IsSensitiveData() const
139 DALI_LOG_INFO( gLogFilter, Debug::General, "AutofillItemEcorewWl::IsSensitiveData \n" );
140 return mSensitiveData;
143 void AutofillItemEcorewWl::SetSaveValue( const std::string& value )
146 #ifdef CAPI_AUTOFILL_SUPPORT
147 autofill_save_item_set_value( mAutofillSaveItemHandle, mValue.c_str() );
148 #endif // CAPI_AUTOFILL_SUPPORT
151 const std::string& AutofillItemEcorewWl::GetSaveValue() const
156 #ifdef CAPI_AUTOFILL_SUPPORT
157 autofill_item_h AutofillItemEcorewWl::GetAutofillItemHandle()
159 return mAutofillItemHandle;
162 autofill_save_item_h AutofillItemEcorewWl::GetAutofillSaveItemHandle()
164 return mAutofillSaveItemHandle;
166 #endif // CAPI_AUTOFILL_SUPPORT
168 void AutofillItemEcorewWl::AddPresentationList( const std::string& presentationText )
170 mPresentationTextList.push_back( presentationText );
173 void AutofillItemEcorewWl::AddFillValueList( const std::string& fillValue )
175 mValueList.push_back( fillValue );
178 const std::string& AutofillItemEcorewWl::GetPresentationText( int index ) const
180 return mPresentationTextList[index];
183 const std::string& AutofillItemEcorewWl::GetFillValue( int index ) const
185 return mValueList[index];
188 void AutofillItemEcorewWl::ClearPresentationTextList()
190 mPresentationTextList.clear();
193 void AutofillItemEcorewWl::ClearFillValueList()
198 unsigned int AutofillItemEcorewWl::GetFillValueCount()
200 return mValueList.size();