From: Marcin Kaminski Date: Wed, 7 Nov 2012 14:35:44 +0000 (+0100) Subject: localizeWidgetModel() removal X-Git-Tag: 2.1b_release~22^2~213 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=48548cd1a87af3f2858532d4b948415cfa8565ba;p=platform%2Fframework%2Fweb%2Fwrt.git localizeWidgetModel() removal New LanguageTagsPpovider API is used for default widget locales setting instead of calling deprecated localizeWidgetModel() [Issue#] N/A [Feature] Code refactoring & cleaning. [Cause] localizeWidgetModel() was the only method in file and did not do anymore what it's name suggest. [Solution] N/A [Verification] Successfull build. Change-Id: Ic11531d63b7f5bc77ff183d33fe29115b7ab2f65 --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2bdb064..4d3dc0d 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -30,7 +30,6 @@ SET(WRT_CORE_BASE_SOURCES ${WRT_SRC_DIR}/domain/global_context.cpp ${WRT_SRC_DIR}/domain/widget_data_types.cpp ${WRT_SRC_DIR}/domain/widget_deserialize_model.cpp - ${WRT_SRC_DIR}/domain/widget_localize_model.cpp ${WRT_SRC_DIR}/domain/localization_setting.cpp ${WRT_SRC_DIR}/domain/widget_model.cpp ${WRT_SRC_DIR}/domain/main_thread.cpp diff --git a/src/domain/widget_deserialize_model.cpp b/src/domain/widget_deserialize_model.cpp index 3e1e324..6c121d9 100644 --- a/src/domain/widget_deserialize_model.cpp +++ b/src/domain/widget_deserialize_model.cpp @@ -20,11 +20,13 @@ * @brief Widget deserialization creates WidgetModel from WidgetDAOReadOnly */ -#include "widget_localize_model.h" #include "widget_model.h" #include #include +// to apply widget default locales instead of calling localizeWidgetModel() +#include + namespace Domain { @@ -36,11 +38,12 @@ std::shared_ptr deserializeWidgetModel(const std::string& tizenId) LogDebug("Widget installed - creating model"); model.reset(new WidgetModel(tizenId)); - // Read DAO data WrtDB::WidgetDAOReadOnly dao(dplTizenId); - - // Set localized data - Domain::localizeWidgetModel(model->defaultlocale.Get()); + DPL::Optional defloc = model->defaultlocale.Get(); + if(!defloc.IsNull()) + { + LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(*defloc); + } WrtDB::WidgetAccessInfoList widgetAccessInfoList; // widgetAccessInfoList is output parameter diff --git a/src/domain/widget_localize_model.cpp b/src/domain/widget_localize_model.cpp deleted file mode 100644 index 241e626..0000000 --- a/src/domain/widget_localize_model.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file widget_localize_model.cpp - * @author Piotr Marcinkiewicz (p.marcinkiew@samsung.com) - * @version 1.0 - * @brief Widget localize localizes WidgetModel from system configuration - */ - -#include -#include -#include -#include - -namespace Domain { - -//TODO this should be moved and renamed in LanguageTagsProviderSingleton -void localizeWidgetModel(const DPL::OptionalString& defaultLocale) -{ - LogDebug("Default locale for widget: " << defaultLocale); - LanguageTags tags = LanguageTagsProviderSingleton::Instance().getLanguageTags(); - if (!!defaultLocale && - std::find(tags.begin(), tags.end(), *defaultLocale) == tags.end()) - { - if (tags.size() < 2) { - tags.push_front(*defaultLocale); - } else { - LanguageTags::iterator placeToInsert = tags.end(); - --placeToInsert; - if (*placeToInsert != L"") { ++placeToInsert; } - tags.insert(placeToInsert, *defaultLocale); - } - } - LogDebug("Setting runtime widget locale:"); - FOREACH(it, tags) { - LogDebug("Locale: " << *it); - } - LanguageTagsProviderSingleton::Instance().setLanguageTags(tags); -} - -} //Namespace Domain diff --git a/src/domain/widget_localize_model.h b/src/domain/widget_localize_model.h deleted file mode 100644 index 78e43fe..0000000 --- a/src/domain/widget_localize_model.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file widget_localize_model.h - * @author Piotr Marcinkiewicz (p.marcinkiew@samsung.com) - * @version 1.0 - * @brief Widget localization localizes WidgetModel from current settings - */ -#ifndef WRT_ENGINE_SRC_DOMAIN_WIDGET_LOCALIZE_MODEL_H_ -#define WRT_ENGINE_SRC_DOMAIN_WIDGET_LOCALIZE_MODEL_H_ - -#include - -namespace Domain { - -/** - * @brief Localize widget model - * - * Function is using localization utils and W3C file localization - * to process current language settingto enhance widget model with - * localized properties. - * - * @param[in] model - */ -void localizeWidgetModel(const DPL::OptionalString& defaultLocale); - -} //Namespace Domain - -#endif // ifndef WRT_ENGINE_SRC_DOMAIN_WIDGET_LOCALIZE_MODEL_H_ - diff --git a/src/view/webkit/bundles/wrt-wk2-bundle.cpp b/src/view/webkit/bundles/wrt-wk2-bundle.cpp index 1bc730f..7543851 100644 --- a/src/view/webkit/bundles/wrt-wk2-bundle.cpp +++ b/src/view/webkit/bundles/wrt-wk2-bundle.cpp @@ -231,25 +231,16 @@ void Bundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody) // reset language tags (create new tags based on system locales) LanguageTagsProviderSingleton::Instance().resetLanguageTags(); DPL::OptionalString defaultLocale = dao.getDefaultlocale(); - LanguageTags tags = LanguageTagsProviderSingleton::Instance().getLanguageTags(); - // check if default widget language exists in language's list - if (!!defaultLocale && - std::find(tags.begin(), tags.end(), *defaultLocale) == tags.end()) + if(!defaultLocale.IsNull()) { - if (tags.size() < 2) { - tags.push_front(*defaultLocale); - } else { - LanguageTags::iterator placeToInsert = tags.end(); - --placeToInsert; - if (*placeToInsert != L"") { ++placeToInsert; } - tags.insert(placeToInsert, *defaultLocale); - } + LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(*defaultLocale); } + LanguageTags tags = LanguageTagsProviderSingleton::Instance().getLanguageTags(); LogDebug("Current widget locales (language tags):"); FOREACH(it, tags) { LogDebug("Locale: " << *it); } - LanguageTagsProviderSingleton::Instance().setLanguageTags(tags); + // ** Language tags setting completed ** if (argScale != "null" && argScale[0] == '_') diff --git a/src/wrt-client/wrt-client.cpp b/src/wrt-client/wrt-client.cpp index 36d9668..2827a63 100755 --- a/src/wrt-client/wrt-client.cpp +++ b/src/wrt-client/wrt-client.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -464,10 +463,13 @@ void WrtClient::launchStep() return; } - ADD_PROFILING_POINT("localizeWidgetModel", "start"); m_dao.reset(new WrtDB::WidgetDAOReadOnly(DPL::FromASCIIString(m_tizenId))); - Domain::localizeWidgetModel(m_dao->getDefaultlocale()); - ADD_PROFILING_POINT("localizeWidgetModel", "stop"); + DPL::Optional defloc = m_dao->getDefaultlocale(); + if(!defloc.IsNull()) + { + LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(*defloc); + } + LocalizationSetting::SetLanguageChangedCallback( languageChangedCallback, this); @@ -701,22 +703,24 @@ void WrtClient::shutdownStep() int WrtClient::languageChangedCallback(void *data) { LogDebug("Language Changed"); + if(!data) + return 0; WrtClient* wrtClient = static_cast(data); + if(!(wrtClient->m_dao)) + return 0; - LanguageTags oldtags = LanguageTagsProviderSingleton::Instance().getLanguageTags(); // reset function fetches system locales and recreates language tags LanguageTagsProviderSingleton::Instance().resetLanguageTags(); - LanguageTags newtags = LanguageTagsProviderSingleton::Instance().getLanguageTags(); - - // check whether LanguageTags changed or not - if (oldtags != newtags) { - // update localized data - Domain::localizeWidgetModel(wrtClient->m_dao->getDefaultlocale()); + // widget default locales are added to language tags below + DPL::OptionalString defloc = wrtClient->m_dao->getDefaultlocale(); + if(!defloc.IsNull()) + { + LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(*defloc); + } - if (true == wrtClient->m_launched && - wrtClient->m_widgetState != WidgetState_Stopped) { - wrtClient->m_widget->ReloadStartPage(); - } + if (wrtClient->m_launched && + wrtClient->m_widgetState != WidgetState_Stopped) { + wrtClient->m_widget->ReloadStartPage(); } return 0; }