#include <unique_ptr.h>
#include <livebox-service/livebox-service.h>
+#include <FApp.h>
#include <FBase.h>
#include <FBaseSysLog.h>
#include <FBase_StringConverter.h>
_AppWidgetProviderInfoImpl::_AppWidgetProviderInfoImpl(const Tizen::App::AppId& appId, const Tizen::Base::String& name)
:__appId(appId)
,__name(name)
+ ,__pDisplayName(null)
+ ,__pConfigurationAppControlAppId(null)
+ ,__pIconPath(null)
+ ,__pProviderId(null)
,__isDefault(false)
{
- __providerId = _AppWidgetManagerImpl::MakeProviderName(appId, name);
+ String providerId = _AppWidgetManagerImpl::MakeProviderName(appId, name);
+ __pProviderId = _StringConverter::CopyToCharArrayN(providerId);
- std::unique_ptr<char[]> pProviderId(_StringConverter::CopyToCharArrayN(__providerId));
-
- std::unique_ptr<char[]> pDisplayName(livebox_service_i18n_name(pProviderId.get(), null));
- SysTryReturnVoidResult(NID_SHELL, pDisplayName, E_SYSTEM, "[E_SYSTEM] Propagating.");
-
- std::unique_ptr<char[]> pSetUpAppId(livebox_service_setup_appid(pProviderId.get()));
-
- __displayName = pDisplayName.get();
- __configurationAppControlAppId = pSetUpAppId.get();
-
- SysSecureLog(NID_SHELL, "appId(%ls), name(%ls), providerId(%ls), displayName(%ls), configuration(%ls)", appId.GetPointer(), name.GetPointer(), __providerId.GetPointer(), __displayName.GetPointer(), __configurationAppControlAppId.GetPointer() );
+ SysSecureLog(NID_SHELL, "appId(%ls), name(%ls), providerId(%s)", appId.GetPointer(), name.GetPointer(), __pProviderId);
}
-/*_AppWidgetProviderInfoImpl::_AppWidgetProviderInfoImpl(const _AppWidgetProviderInfoImpl& rhs)
-{
- __appId = rhs.__appId;
- __name = rhs.__name;
- __providerId = rhs.__providerId;
-}
-
-_AppWidgetProviderInfoImpl&
-_AppWidgetProviderInfoImpl::operator =(const _AppWidgetProviderInfoImpl& rhs)
-{
- __appId = rhs.__appId;
- __name = rhs.__name;
- __providerId = rhs.__providerId;
-
- return *this;
-}*/
-
_AppWidgetProviderInfoImpl::~_AppWidgetProviderInfoImpl()
{
+ delete[] __pProviderId;
+ delete __pDisplayName;
+ delete __pConfigurationAppControlAppId;
+ delete __pIconPath;
}
Tizen::App::AppId
}
Tizen::Base::String
-_AppWidgetProviderInfoImpl::GetDisplayName() const
+_AppWidgetProviderInfoImpl::GetDisplayName()
{
- return __displayName;
+ if (__pDisplayName == null)
+ {
+ std::unique_ptr<char> pDisplayName(livebox_service_i18n_name(__pProviderId, null));
+ __pDisplayName = new(std::nothrow) String(pDisplayName.get());
+ }
+ return *__pDisplayName;
}
Tizen::Base::String
-_AppWidgetProviderInfoImpl::GetIconPath() const
+_AppWidgetProviderInfoImpl::GetIconPath()
{
- std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(__providerId));
- String iconPath = livebox_service_i18n_icon(pPackageId.get(), null);
+ if (__pIconPath == null)
+ {
+ std::unique_ptr<char> pIconPath(livebox_service_i18n_icon(__pProviderId, null) );
+ __pIconPath = new(std::nothrow) String(pIconPath.get());
+ }
- return iconPath;
+ return *__pIconPath;
}
Tizen::Base::String
-_AppWidgetProviderInfoImpl::GetConfigurationAppControlAppId() const
+_AppWidgetProviderInfoImpl::GetConfigurationAppControlAppId()
{
- return __configurationAppControlAppId;
+ if (__pConfigurationAppControlAppId == null)
+ {
+ std::unique_ptr<char> pSetUpAppId(livebox_service_setup_appid(__pProviderId));
+ __pConfigurationAppControlAppId = new(std::nothrow) String(pSetUpAppId.get());
+ }
+ return *__pConfigurationAppControlAppId;
}
bool
String pkgId = Package::_PackageManagerImpl::GetPackageIdByAppId(appId);
SysTryReturn(NID_APP, !pkgId.IsEmpty(), _API_VISIBILITY_PUBLIC, E_INVALID_STATE, "Invalid appId(%ls).", appId.GetPointer() );
- Package::PackageInfo* pInfo = pPkg->GetPackageInfoN(pkgId);
+ std::unique_ptr<Package::PackageInfo> pInfo (pPkg->GetPackageInfoN(pkgId) );
SysTryReturn(NID_APP, pInfo != null, _API_VISIBILITY_PUBLIC, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
- const Package::_PackageInfoImpl* pPkgInfo = Package::_PackageInfoImpl::GetInstance(pInfo);
+ const Package::_PackageInfoImpl* pPkgInfo = Package::_PackageInfoImpl::GetInstance(pInfo.get());
SysTryReturn(NID_APP, pPkgInfo != null, _API_VISIBILITY_PUBLIC, E_INVALID_STATE, "Invalid PackageInfo instance.");
return pPkgInfo->GetApiVisibility();
int widthArray[MAX_SUPPORTED_SIZE_TYPE];
int heightArray[MAX_SUPPORTED_SIZE_TYPE];
- std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(__providerId));
- livebox_service_get_supported_sizes(pPackageId.get(), &supportedSizeCount , widthArray, heightArray);
+ livebox_service_get_supported_sizes(__pProviderId, &supportedSizeCount , widthArray, heightArray);
- SysTryReturn(NID_SHELL, supportedSizeCount > 0, null, E_SYSTEM, "[E_SYSTEM] There is no appwidget of provider(%ls)",__providerId.GetPointer() );
+ SysTryReturn(NID_SHELL, supportedSizeCount > 0, null, E_SYSTEM, "[E_SYSTEM] There is no appwidget of provider(%s)",__pProviderId );
std::unique_ptr<ArrayList> pSizes(new (std::nothrow) ArrayList);
SysTryReturn(NID_SHELL, pSizes, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory for ArrayList." );
for(int i = 0; i < supportedSizeCount; i++)
{
size.SetSize(widthArray[i], heightArray[i]);
- previewImagePath = livebox_service_preview(pPackageId.get(), livebox_service_size_type(static_cast<int>(size.width), static_cast<int>(size.height) ) );
+ previewImagePath = livebox_service_preview(__pProviderId, livebox_service_size_type(static_cast<int>(size.width), static_cast<int>(size.height) ) );
if( IsValidSize(__appId, size.width, size.height) == false )
{
int sizeType = livebox_service_size_type(size.width, size.height);
SysAssertf(sizeType != LB_SIZE_TYPE_UNKNOWN, "Failed to invoke livebox_service_size_type(%d, %d)", size.width, size.height);
- bool useDecoration = livebox_service_need_frame(pPackageId.get(), sizeType);
+ bool useDecoration = livebox_service_need_frame(__pProviderId, sizeType);
std::unique_ptr<AppWidgetSizeInfo> pAppWidgetSizeInfo(_AppWidgetSizeInfoImpl::CreateAppWidgetSizeInfo(size, previewImagePath, useDecoration) );
SysTryReturn(NID_SHELL, pAppWidgetSizeInfo, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory for AppWidgetSizeInfo." );
SysTryReturn(NID_SHELL, Tizen::App::_Aul::IsInstalled(appId) == true, false, E_APP_NOT_INSTALLED, "The application(%ls) is not installed.", appId.GetPointer());
std::unique_ptr<char[]> pProviderId(_StringConverter::CopyToCharArrayN(_AppWidgetManagerImpl::MakeProviderName(appId, providerName)));
- std::unique_ptr<char[]> pPackageId(livebox_service_appid(pProviderId.get()));
+ std::unique_ptr<char> pPackageId( livebox_service_appid(pProviderId.get()) );
SysTryReturn(NID_SHELL, pPackageId.get(), false, E_APP_NOT_INSTALLED, "The application(%ls) is not installed.", appId.GetPointer());
return true;
*
* @return The display name of the Livbox
*/
- Tizen::Base::String GetDisplayName() const;
+ Tizen::Base::String GetDisplayName();
/**
* Gets the icon path of the application.
* @return The icon path of the application, @n
* An empty string is returned if there is no value.
*/
- Tizen::Base::String GetIconPath() const;
+ Tizen::Base::String GetIconPath();
- Tizen::Base::String GetConfigurationAppControlAppId() const;
+ Tizen::Base::String GetConfigurationAppControlAppId();
bool IsDefault() const;
*/
Tizen::Base::Collection::IList* GetSizeInfoListN() const;
-
// internal
static AppWidgetProviderInfo* GetAppWidgetProviderInfoN(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName);
static AppWidgetProviderInfo* GetAppWidgetProviderInfoN(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, bool isDefault);
private:
Tizen::Base::String __appId;
Tizen::Base::String __name;
+ Tizen::Base::String* __pDisplayName;
+ Tizen::Base::String* __pConfigurationAppControlAppId;
+ Tizen::Base::String* __pIconPath;
+ char* __pProviderId;
bool __isDefault;
- Tizen::Base::String __providerId;
- Tizen::Base::String __displayName; //TODO:temporary public
- Tizen::Base::String __configurationAppControlAppId; //TODO:temporary public
+
// Tizen::Base::String __iconPath;
Tizen::Base::Collection::ArrayList __sizeInfos;