namespace Tizen { namespace Shell
{
+AppWidgetProviderManager* AppWidgetProviderManager::__pTheInstance = null;
+
AppWidgetProviderManager::AppWidgetProviderManager()
:__pAppWidgetProviderManagerImpl(null)
{
SysLog(NID_SHELL, "AppWidgetProviderManager is destroyed.");
}
+void
+AppWidgetProviderManager::InitSingleton(void)
+{
+ std::unique_ptr<AppWidgetProviderManager> pInst(new (std::nothrow) AppWidgetProviderManager());
+ SysTryReturnVoidResult(NID_SHELL, pInst, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ result r = pInst->Construct();
+ SysTryReturnVoidResult(NID_SHELL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ __pTheInstance = pInst.release();
+ std::atexit(DestroySingleton);
+}
+
+void
+AppWidgetProviderManager::DestroySingleton(void)
+{
+ delete __pTheInstance;
+}
+
AppWidgetProviderManager*
AppWidgetProviderManager::GetInstance()
{
- static AppWidgetProviderManager* pAppWidgetManager = null;
- if( pAppWidgetManager == null)
+ static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+ if (__pTheInstance == null)
{
- pAppWidgetManager = new (std::nothrow) AppWidgetProviderManager;
- SysTryReturn(NID_SHELL, pAppWidgetManager, null, E_OUT_OF_MEMORY, "E_OUT_OF_MEMORY" );
-
- result r = pAppWidgetManager->Construct();
-// SysTryReturn(NID_SHELL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
- SysAssertf(!IsFailed(r), "Failed to construct AppWidgetProviderManager!!");
+ ClearLastResult();
+ pthread_once(&onceBlock, InitSingleton);
+ result r = GetLastResult();
+ if (IsFailed(r))
+ {
+ onceBlock = PTHREAD_ONCE_INIT;
+ }
}
-
- return pAppWidgetManager;
+ return __pTheInstance;
}
result
namespace Tizen { namespace Shell
{
+ShortcutManager* ShortcutManager::__pTheInstance = null;
+
ShortcutManager::ShortcutManager()
:__pShortcutManagerImpl(null)
{
{
}
+void
+ShortcutManager::InitSingleton(void)
+{
+ std::unique_ptr<ShortcutManager> pInst(new (std::nothrow) ShortcutManager());
+ SysTryReturnVoidResult(NID_SHELL, pInst, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ result r = pInst->Construct();
+ SysTryReturnVoidResult(NID_SHELL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ __pTheInstance = pInst.release();
+ std::atexit(DestroySingleton);
+}
+
+void
+ShortcutManager::DestroySingleton(void)
+{
+ delete __pTheInstance;
+}
+
ShortcutManager*
ShortcutManager::GetInstance()
{
- static ShortcutManager* pShortcutManager = null;
- if( pShortcutManager == null)
+ static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+ if (__pTheInstance == null)
{
- pShortcutManager = new (std::nothrow) ShortcutManager;
- SysTryReturn(NID_SHELL, pShortcutManager, null, E_OUT_OF_MEMORY, "E_OUT_OF_MEMORY" );
-
- result r = pShortcutManager->Construct();
-// SysTryReturn(NID_SHELL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
- SysAssertf(!IsFailed(r), "Failed to construct ShortcutManager!!");
+ ClearLastResult();
+ pthread_once(&onceBlock, InitSingleton);
+ result r = GetLastResult();
+ if (IsFailed(r))
+ {
+ onceBlock = PTHREAD_ONCE_INIT;
+ }
}
-
- return pShortcutManager;
+ return __pTheInstance;
}
result
result r = _AccessController::CheckUserPrivilege(_PRV_SHORTCUT_INSTALL);
SysTryReturnResult(NID_SHELL, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
- std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId));
- std::unique_ptr<char[]> pIcon(_StringConverter::CopyToCharArrayN(iconFilePath));
- std::unique_ptr<char[]> pName(_StringConverter::CopyToCharArrayN(displayName));
- std::unique_ptr<char[]> pUriData(_StringConverter::CopyToCharArrayN(uriData));
- int type = (uriData.IsEmpty())? LAUNCH_BY_PACKAGE : LAUNCH_BY_URI;
-
- int ret = add_to_home_shortcut(pAppId.get(), pName.get(), type, pUriData.get(), pIcon.get(), allowDuplication, NULL, this);
- SysTryReturnResult(NID_SHELL, ret != SHORTCUT_ERROR_COMM, E_SUCCESS, "It's failed to add_to_home_shortcut, but regarded as success.");
- SysTryReturnResult(NID_SHELL, ret != SHORTCUT_ERROR_MEMORY, E_OUT_OF_MEMORY, "It's failed to add_to_home_shortcut.");
- SysTryReturnResult(NID_SHELL, ret == SHORTCUT_SUCCESS, E_SYSTEM, "Failed to add_to_home_shortcut");
-
- return E_SUCCESS;
+ return __pShortcutManagerImpl->AddShortcut(appId, displayName, iconFilePath, uriData, allowDuplication);
}
result
result r = _AccessController::CheckUserPrivilege(_PRV_SHORTCUT_INSTALL);
SysTryReturnResult(NID_SHELL, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
- std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId));
- std::unique_ptr<char[]> pName(_StringConverter::CopyToCharArrayN(displayName));
-
- int ret = add_to_home_remove_shortcut(pAppId.get(), pName.get(), "", null, this);
- SysTryReturnResult(NID_SHELL, ret != SHORTCUT_ERROR_COMM, E_SUCCESS, "It's failed to add_to_home_remove_shortcut, but regarded as success.");
- SysTryReturnResult(NID_SHELL, ret != SHORTCUT_ERROR_MEMORY, E_OUT_OF_MEMORY, "It's failed to add_to_home_remove_shortcut.");
- SysTryReturnResult(NID_SHELL, ret == SHORTCUT_SUCCESS, E_SYSTEM, "It's failed to add_to_home_remove_shortcut, with reason (%d)");
-
- return E_SUCCESS;
+ return __pShortcutManagerImpl->RemoveShortcut(appId, displayName);
}
result
#include <shortcut.h>
#include <FBaseSysLog.h>
#include <FBase.h>
+#include <FBase_StringConverter.h>
#include <FApp.h>
#include "FShell_ShortcutManagerImpl.h"
+
namespace Tizen { namespace Shell
{
}
result
+_ShortcutManagerImpl::AddShortcut(const AppId& appId, const String& displayName, const String& iconFilePath, const String& uriData, bool allowDuplication)
+{
+ SysLog(NID_SHELL, "_ShortcutManagerImpl::AddShortcut enters.");
+ std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId));
+ std::unique_ptr<char[]> pIcon(_StringConverter::CopyToCharArrayN(iconFilePath));
+ std::unique_ptr<char[]> pName(_StringConverter::CopyToCharArrayN(displayName));
+ std::unique_ptr<char[]> pUriData(_StringConverter::CopyToCharArrayN(uriData));
+ int type = (uriData.IsEmpty())? LAUNCH_BY_PACKAGE : LAUNCH_BY_URI;
+
+ int ret = add_to_home_shortcut(pAppId.get(), pName.get(), type, pUriData.get(), pIcon.get(), allowDuplication, NULL, this);
+ SysTryReturnResult(NID_SHELL, ret != SHORTCUT_ERROR_COMM, E_SUCCESS, "It's failed to add_to_home_shortcut, but regarded as success.");
+ SysTryReturnResult(NID_SHELL, ret != SHORTCUT_ERROR_MEMORY, E_OUT_OF_MEMORY, "It's failed to add_to_home_shortcut.");
+ SysTryReturnResult(NID_SHELL, ret == SHORTCUT_SUCCESS, E_SYSTEM, "Failed to add_to_home_shortcut");
+ SysLog(NID_SHELL, "_ShortcutManagerImpl::AddShortcut exits.");
+ return E_SUCCESS;
+}
+
+result
+_ShortcutManagerImpl::RemoveShortcut(const Tizen::App::AppId& appId, const Tizen::Base::String& displayName)
+{
+ std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId));
+ std::unique_ptr<char[]> pName(_StringConverter::CopyToCharArrayN(displayName));
+
+ int ret = add_to_home_remove_shortcut(pAppId.get(), pName.get(), "", null, this);
+ SysTryReturnResult(NID_SHELL, ret != SHORTCUT_ERROR_COMM, E_SUCCESS, "It's failed to add_to_home_remove_shortcut, but regarded as success.");
+ SysTryReturnResult(NID_SHELL, ret != SHORTCUT_ERROR_MEMORY, E_OUT_OF_MEMORY, "It's failed to add_to_home_remove_shortcut.");
+ SysTryReturnResult(NID_SHELL, ret == SHORTCUT_SUCCESS, E_SYSTEM, "It's failed to add_to_home_remove_shortcut, with reason (%d)");
+
+ return E_SUCCESS;
+}
+
+result
_ShortcutManagerImpl::AddShortcutRequestListener(IShortcutRequestListener& listener)
{
SysTryReturnResult(NID_SHELL, !__shortcutRequestListenerList.Contains(&listener), E_OBJ_ALREADY_EXIST, "The listener is already added.");