X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fapi_new%2Fcore_module.cpp;h=d5c07dea5382782acfbcf36828758d109ff48ef5;hb=ec05fc226317abd133fccf67dd6086fc34e0edee;hp=454b895536317707e0697a8723204ddc3c2619ae;hpb=4455b839fc1a0afff89bccb223cd0a24aa0dc923;p=platform%2Fframework%2Fweb%2Fwrt.git diff --git a/src/api_new/core_module.cpp b/src/api_new/core_module.cpp index 454b895..d5c07de 100644 --- a/src/api_new/core_module.cpp +++ b/src/api_new/core_module.cpp @@ -25,26 +25,23 @@ #include "runnable_widget_object.h" #include #include -#include #include #include #include -#include #include -#include +#include #include "localization_setting.h" #include #include #include #include - -#include +#include IMPLEMENT_SINGLETON(WRT::CoreModule) -namespace { //Anonymous - -const char * const bundlePath = "/usr/lib/wrt-wk2-bundles/libwrt-wk2-bundle.so"; +namespace { +const char* const TEXT_DOMAIN = "wrt"; +const char* const TEXT_LOCALE_PATH = "/usr/share/wrt-engine/locale"; std::string cutOffFileName(const std::string& path) { @@ -73,49 +70,31 @@ bool checkPaths() bool if_ok = true; if_ok &= (isDir(cutOffFileName(GetWrtDatabaseFilePath()))); - if (!if_ok) { - LogError("Path <" << GetWrtDatabaseFilePath() << "> does not exist."); - } - if_ok &= (isDir(GetDevicePluginPath())); - if (!if_ok) { - LogError("Path <" << GetDevicePluginPath() << "> does not exist."); - } - - if_ok &= (isDir(GetFactoryInstalledWidgetPath())); - if (!if_ok) { - LogError("Path <" << GetFactoryInstalledWidgetPath() << - "> does not exist."); - } - if_ok &= (isDir(GetUserInstalledWidgetPath())); - if (!if_ok) { - LogError("Path <" << GetUserInstalledWidgetPath() << - "> does not exist."); - } return if_ok; } -}// namespace anonymous +} // namespace anonymous namespace WRT { - class CoreModuleImpl { -public: + public: - CoreModuleImpl() : m_initialized(false), m_ewkContext(NULL) + CoreModuleImpl() : m_initialized(false) { LogDebug("enter"); } ~CoreModuleImpl() { - LogError("Core module implementation destroyed"); + LogDebug("Core module implementation destroyed"); } bool Init() { if (!m_initialized) { + ADD_PROFILING_POINT("CoreModule::Init", "point"); DPL::Log::LogSystemSingleton::Instance().SetTag("WRT"); LogDebug("Initialize"); if (!checkPaths()) { @@ -124,41 +103,9 @@ public: } Try { - GlobalContext::TouchArchitecture(); - ADD_PROFILING_POINT("attach databases", "start"); MainThreadSingleton::Instance().AttachDatabases(); ADD_PROFILING_POINT("attach databases", "stop"); - - ADD_PROFILING_POINT("xml_parser_init", "start"); - xmlInitParser(); - ADD_PROFILING_POINT("xml_parser_init", "stop"); - - // Initialize popup manager - ADD_PROFILING_POINT("popup_manager_init", "start"); - DPL::Popup::PopupManagerSingleton::Instance().Initialize( - DPL::Popup::PopupRendererPtr(new DPL::Popup::PopupRenderer)); - ADD_PROFILING_POINT("popup_manager_init", "stop"); - - // Initialize Language Subtag registry - ADD_PROFILING_POINT("language_rst_init", "start"); - LocalizationSetting::SetLocalization(); - ADD_PROFILING_POINT("language_rst_init", "stop"); - - - // Needed settings for WKContext are located here - // create Ewk_Context - Ewk_Context* newEwkContext = - ewk_context_new_with_injected_bundle_path(bundlePath); - if (!newEwkContext) { - LogError("Failed to create Ewk_Context"); - ThrowMsg(DPL::Exception, "Failed to create ewk context"); - } - // cache model setting - ewk_context_cache_model_set(newEwkContext, - EWK_CACHE_MODEL_PRIMARY_WEBBROWSER); - m_ewkContext = newEwkContext; - LogDebug("Initialize finished"); } catch (const DPL::Exception& ex) { LogError("Internal Error during screen preparation:"); @@ -166,9 +113,10 @@ public: /* TODO: * Do deinitialization: check on which step exception occured * and deinitialize only initialized parts. - */ + */ return false; } + bindtextdomain(TEXT_DOMAIN, TEXT_LOCALE_PATH); m_initialized = true; } return true; @@ -176,42 +124,68 @@ public: void Terminate() { - if (m_ewkContext) { - LogInfo("finalizeEwkContext called"); - ewk_context_delete(m_ewkContext); - m_ewkContext = 0; - } MainThreadSingleton::Instance().DetachDatabases(); - // Deinitialize popup manager - DPL::Popup::PopupManagerSingleton::Instance().Deinitialize(); - - LogInfo("Cleanup libxml2 global values."); - xmlCleanupParser(); m_initialized = false; } - RunnableWidgetObjectPtr getRunnableWidgetObject(const WidgetHandle& handle) + RunnableWidgetObjectPtr getRunnableWidgetObject( + const std::string& tizenId) + { + try { + RunnableWidgetObjectPtr runnable; + WidgetModelPtr model = + Domain::deserializeWidgetModel(tizenId); + if (!!model) { + runnable.reset(new RunnableWidgetObject(model)); + } + return runnable; + } catch (WrtDB::WidgetDAOReadOnly::Exception::WidgetNotExist) { + LogDebug("Widget not found."); + return RunnableWidgetObjectPtr(); + } + } + + CoreModule::NetworkAccessMode homeNetworkAccess() + { + switch (WrtDB::GlobalDAOReadOnly::GetHomeNetworkDataUsage()) { + case WrtDB::GlobalDAOReadOnly::NEVER_CONNECT: + return CoreModule::NEVER_CONNECT; + case WrtDB::GlobalDAOReadOnly::ALWAYS_ASK: + return CoreModule::ALWAYS_ASK; + case WrtDB::GlobalDAOReadOnly::CONNECT_AUTOMATICALLY: + return CoreModule::CONNECT_AUTOMATICALLY; + default: + break; + } + LogWarning("using default value"); + return CoreModule::ALWAYS_ASK; + } + + CoreModule::NetworkAccessMode roamingNetworkAccess() { - RunnableWidgetObjectPtr runnable; - WidgetModelPtr model = Domain::deserializeWidgetModel(handle); - if (!!model) { - runnable.reset(new RunnableWidgetObject(model, m_ewkContext)); + switch (WrtDB::GlobalDAOReadOnly::GetRoamingDataUsage()) { + case WrtDB::GlobalDAOReadOnly::NEVER_CONNECT: + return CoreModule::NEVER_CONNECT; + case WrtDB::GlobalDAOReadOnly::ALWAYS_ASK: + return CoreModule::ALWAYS_ASK; + case WrtDB::GlobalDAOReadOnly::CONNECT_AUTOMATICALLY: + return CoreModule::CONNECT_AUTOMATICALLY; + default: + break; } - return runnable; + LogWarning("using default value"); + return CoreModule::ALWAYS_ASK; } -private: + private: bool m_initialized; - Ewk_Context* m_ewkContext; }; CoreModule::CoreModule() : m_impl(new CoreModuleImpl()) -{ -} +{} CoreModule::~CoreModule() -{ -} +{} bool CoreModule::Init() { @@ -223,21 +197,20 @@ void CoreModule::Terminate() return m_impl->Terminate(); } -RunnableWidgetObjectPtr CoreModule::getRunnableWidgetObject(const WidgetHandle& handle) +RunnableWidgetObjectPtr CoreModule::getRunnableWidgetObject( + const std::string& tizenId) { - return m_impl->getRunnableWidgetObject(handle); + return m_impl->getRunnableWidgetObject(tizenId); } -RunnableWidgetObjectPtr CoreModule::getRunnableWidgetObject(const std::string& packageName) +CoreModule::NetworkAccessMode CoreModule::homeNetworkAccess() { - DPL::OptionalString pkgName(DPL::FromUTF8String(packageName)); - try { - return m_impl->getRunnableWidgetObject( - WrtDB::WidgetDAOReadOnly::getHandle(*pkgName)); - } catch (WrtDB::WidgetDAOReadOnly::Exception::WidgetNotExist) { - LogDebug("Widget not found."); - return RunnableWidgetObjectPtr(); - } + return m_impl->homeNetworkAccess(); +} + +CoreModule::NetworkAccessMode CoreModule::roamingNetworkAccess() +{ + return m_impl->roamingNetworkAccess(); } } /* namespace WRT */