From 9f9cb2e82051f643354936b74fa4853955b38b5f Mon Sep 17 00:00:00 2001 From: "jungmin76.park" Date: Tue, 19 Mar 2013 21:12:01 +0900 Subject: [PATCH] fix problem that not showing slp livebox. Change-Id: I40e45c47e7b6805eb05609ed7c44c534b28881d9 Signed-off-by: jungmin76.park --- src/FShell_AppWidgetManagerImpl.cpp | 125 ++++++++----------------------- src/FShell_AppWidgetProviderInfoImpl.cpp | 2 +- src/FShell_AppWidgetViewModel.cpp | 20 +---- 3 files changed, 36 insertions(+), 111 deletions(-) diff --git a/src/FShell_AppWidgetManagerImpl.cpp b/src/FShell_AppWidgetManagerImpl.cpp index c112e80..f05b1bb 100644 --- a/src/FShell_AppWidgetManagerImpl.cpp +++ b/src/FShell_AppWidgetManagerImpl.cpp @@ -98,9 +98,9 @@ _AppWidgetManagerImpl::Construct() } // c style callback for livebox_service_get_pkglist -int GetAppWidgetProviderInfoCallback(const char *packageId, const char *pProviderId, int is_prime, void *data) +int GetAppWidgetProviderInfoCallback(const char *pPackageId, const char *pProviderId, int is_prime, void *data) { - SysLog(NID_APP, "%s, %s", packageId, pProviderId); + SysLog(NID_APP, "%s, %s", pPackageId, pProviderId); IList* pAppWidgetProviderInfos = static_cast(data); SysTryReturn(NID_APP, pAppWidgetProviderInfos, 0, E_SYSTEM, "[E_SYSTEM] system error."); @@ -143,85 +143,26 @@ _AppWidgetManagerImpl::GetAppWidgetProviderInfoN(const Tizen::App::AppId& appId, return _AppWidgetProviderInfoImpl::GetAppWidgetProviderInfoN(appId, providerName); } -const int PROVIDER_NAME_MAX = 256; -char __tempDefaultProviderResult[PROVIDER_NAME_MAX]; - -// c style callback for livebox_service_get_pkglist -int GetDefaultAppWidgetProviderInfoCallback(const char *packageId, const char *pProviderId, int is_prime, void *data) -{ - SysLog(NID_APP, "%s, %s", packageId, pProviderId); - char* pInputProviderId = static_cast(data); - SysTryReturn(NID_APP, pInputProviderId, 0, E_SYSTEM, "[E_SYSTEM] system error."); - - if( strncmp(packageId, pInputProviderId, PROVIDER_NAME_MAX) == 0) - { - strncpy(__tempDefaultProviderResult, pProviderId, PROVIDER_NAME_MAX); - return -1; - } - - return 0; -} - AppWidgetProviderInfo* _AppWidgetManagerImpl::GetDefaultAppWidgetProviderInfoN(const Tizen::App::PackageId& packageId) { - memset(__tempDefaultProviderResult, 0, sizeof(__tempDefaultProviderResult)); - - AppWidgetProviderInfo* pInfo = null; - std::unique_ptr pPackageId(_StringConverter::CopyToCharArrayN(packageId)); - - int ret = livebox_service_get_pkglist(GetDefaultAppWidgetProviderInfoCallback, pPackageId.get()); - if (ret < 0) - { - SysLog(NID_APP, "There is no AppWidget provider specifed, or It's failed to invoke livebox_service_get_pkglist, ret (%d)", ret); - return null; - } - - String defaultProvider(__tempDefaultProviderResult); - if( !defaultProvider.IsEmpty()) - { - String appId; - String providerName; - _AppWidgetManagerImpl::ExtractAppIdAndProviderName(__tempDefaultProviderResult, appId, providerName); - - pInfo = _AppWidgetProviderInfoImpl::GetAppWidgetProviderInfoN(appId, providerName, true); - } - return pInfo; -} - - -bool __isDefault; -// c style callback for livebox_service_get_pkglist -int IsAppWidgetProviderDefaultInfoCallback(const char *packageId, const char *pProviderId, int is_prime, void *data) -{ - __isDefault = false; - SysLog(NID_APP, "%s, %s", packageId, pProviderId); - char* pInputProviderId = static_cast(data); - SysTryReturn(NID_APP, pInputProviderId, 0, E_SYSTEM, "[E_SYSTEM] system error."); + std::unique_ptr pPackageId(_StringConverter::CopyToCharArrayN(packageId) ); + std::unique_ptr pDefaultProviderId(livebox_service_pkgname(pPackageId.get()) ); + SysTryReturn(NID_APP, pDefaultProviderId.get(), null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND]"); - if( strncmp(packageId, pInputProviderId, 256) == 0) - { - __isDefault = is_prime; - return -1; - } + String providerId(pDefaultProviderId.get()); + String appId; + String providerName; + _AppWidgetManagerImpl::ExtractAppIdAndProviderName(providerId, appId, providerName); - return 0; + return _AppWidgetProviderInfoImpl::GetAppWidgetProviderInfoN(appId, providerName, true); } bool _AppWidgetManagerImpl::IsAppWidgetProviderDefault(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName) { - __isDefault = false; - - std::unique_ptr pPackageId(_StringConverter::CopyToCharArrayN(_AppWidgetManagerImpl::MakeProviderName(appId, providerName))); - - int ret = livebox_service_get_pkglist(IsAppWidgetProviderDefaultInfoCallback, pPackageId.get()); - if (ret < 0) - { - SysLog(NID_APP, "Failed to invoke livebox_service_get_pkglist, ret (%d)", ret); - } - - return __isDefault; + std::unique_ptr pProviderId(_StringConverter::CopyToCharArrayN(_AppWidgetManagerImpl::MakeProviderName(appId, providerName))); + return livebox_service_is_primary(pProviderId.get()); } // c - style callback for shortcut_set_request_cb @@ -264,16 +205,23 @@ _AppWidgetManagerImpl::GetAddRequestListener() result _AppWidgetManagerImpl::ExtractAppIdAndProviderName(const Tizen::Base::String& providerId, Tizen::App::AppId& appId, Tizen::Base::String& providerName) { - if( providerId.StartsWith("com.samsung", 0) == true)// for core livebox (plugin) + int index = 0; + + if( providerId.StartsWith("com.samsung.", 0) == true)// for core livebox (plugin) { - appId = providerId; - providerName = L""; + if( providerId.IndexOf(".", 13, index) == E_SUCCESS)//"com.samsung._" + { + providerId.SubString(0, index, appId); + providerId.SubString(index+1, providerName); + } + else + { + appId = providerId; + } } else { - int index = 0; - - providerId.IndexOf(".", 11, index); + providerId.IndexOf(".", 12, index);//"1234567890._" providerId.SubString(0, index, appId); providerId.SubString(index+1, providerName); } @@ -284,26 +232,19 @@ _AppWidgetManagerImpl::ExtractAppIdAndProviderName(const Tizen::Base::String& pr String _AppWidgetManagerImpl::MakeProviderName(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName) { - String providerId; - - if( appId.StartsWith("com.samsung", 0) == true)// for core livebox (plugin) + if( providerName.IsEmpty() ) { - // or providerName.IsEmpty() - providerId = appId; + return appId;// some of core appwidget } - else + + if (appId.IsEmpty()) { - // for web - if (appId.IsEmpty()) - { - providerId.Format(128, L"%ls", providerName.GetPointer() ); - } - else - { - providerId.Format(128, L"%ls.%ls", appId.GetPointer(), providerName.GetPointer() ); - } + return providerName;// web appwidget } + String providerId; + providerId.Format(128, L"%ls.%ls", appId.GetPointer(), providerName.GetPointer() );// native appwidget + return providerId; } diff --git a/src/FShell_AppWidgetProviderInfoImpl.cpp b/src/FShell_AppWidgetProviderInfoImpl.cpp index 320a1d5..bb83a85 100644 --- a/src/FShell_AppWidgetProviderInfoImpl.cpp +++ b/src/FShell_AppWidgetProviderInfoImpl.cpp @@ -50,7 +50,7 @@ _AppWidgetProviderInfoImpl::_AppWidgetProviderInfoImpl(const Tizen::App::AppId& __displayName = livebox_service_i18n_name(pProviderId.get(), null); __configurationAppControlAppId = livebox_service_setup_appid(pProviderId.get()); - SysLog(NID_APP, "%ls.%ls, displayName(%ls), configuration(%ls)", appId.GetPointer(), name.GetPointer(), __displayName.GetPointer(), __configurationAppControlAppId.GetPointer() ); + SysLog(NID_APP, "appId(%ls), name(%ls), providerId(%ls), displayName(%ls), configuration(%ls)", appId.GetPointer(), name.GetPointer(), __providerId.GetPointer(), __displayName.GetPointer(), __configurationAppControlAppId.GetPointer() ); } /*_AppWidgetProviderInfoImpl::_AppWidgetProviderInfoImpl(const _AppWidgetProviderInfoImpl& rhs) diff --git a/src/FShell_AppWidgetViewModel.cpp b/src/FShell_AppWidgetViewModel.cpp index 91b616e..8ed7a41 100644 --- a/src/FShell_AppWidgetViewModel.cpp +++ b/src/FShell_AppWidgetViewModel.cpp @@ -24,6 +24,7 @@ #include #include #include "FShell_AppWidgetViewModel.h" +#include "FShell_AppWidgetManagerImpl.h" using namespace std; using namespace Tizen::App; @@ -45,23 +46,7 @@ _AppWidgetViewModel::Initialize(const AppId& appId, const Tizen::Base::String& p { __appId = appId; __providerName = providerName; - - // todo : _AppWidgetManagerImpl::MakeProviderName - if (providerName.IsEmpty()) - { - __appwidgetId = __appId; - } - else - { - if (appId.IsEmpty()) - { - __appwidgetId = providerName; - } - else - { - __appwidgetId = appId + L"." + providerName; - } - } + __appwidgetId = _AppWidgetManagerImpl::MakeProviderName(appId, providerName); SysLog(NID_UI_CTRL, "(%ls %ls %ls)", __appId.GetPointer(), __providerName.GetPointer(), __appwidgetId.GetPointer()); @@ -74,7 +59,6 @@ _AppWidgetViewModel::Initialize(const AppId& appId, const Tizen::Base::String& p SysLog(NID_UI_CTRL, "ProviderInfo(%ls %ls %ls %ls)", __pAppWidgetProviderInfo->GetName().GetPointer(), __pAppWidgetProviderInfo->GetDisplayName().GetPointer(), __pAppWidgetProviderInfo->GetIconPath().GetPointer(), __pAppWidgetProviderInfo->GetConfigurationAppControlAppId().GetPointer()); - } AppId -- 2.7.4