#include <new>
#include <unique_ptr.h>
-#include <app.h>
#include <bundle.h>
+#include <appsvc.h>
+#include <new>
#include <FBaseErrors.h>
#include <FBaseSysLog.h>
#include <FBase_StringConverter.h>
#include <FIo_RegistryImpl.h>
-#include "FAppPkg_PackageManagerImpl.h"
#include "FApp_AppControlImpl.h"
-#include "FApp_Aul.h"
#include "FApp_AppControlRegistry.h"
#include "FApp_AppMessageImpl.h"
#include "FApp_TemplateUtil.h"
-using namespace Tizen::App::Package;
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
using namespace Tizen::Io;
const wchar_t ACTL_DEFAULT_FILE[] = L"/usr/etc/app-control-info.ini";
const wchar_t ACTL_LEGACY_FILE[] = L"/usr/etc/app-control-alias.ini";
-const wchar_t ACTL_ALIAS_FILE[] = L"/usr/etc/app-control-appid.ini";
+const wchar_t ACTL_DEFAULT_PLUGIN[] = L"libosp-ac-platform.so";
const wchar_t TIZEN_ALIAS_APPID_PREFIX[] = L"tizen.";
__tizenList.Construct();
__aliasList.Construct();
-
- __aliasAppId.Construct();
-
- __runtimeAlias.Construct();
}
_AppControlRegistry::~_AppControlRegistry(void)
{
_DeleteCollectionMapValue<String, _AppControlAliasEntry>(__aliasList);
-
- _DeleteCollection<_AppControlAliasEntry>(__runtimeAlias);
}
_AppControlRegistry*
__pSelf->LoadTizenAppControlRegistry();
__pSelf->LoadLegacyList();
-
- __pSelf->LoadAliasList();
}
return __pSelf;
return E_SUCCESS;
}
-result
-_AppControlRegistry::LoadAliasList(void)
-{
- _RegistryImpl reg;
-
- const String regPath = ACTL_ALIAS_FILE;
-
- result r = reg.Construct(regPath, REG_OPEN_READ_ONLY, null);
- SysTryReturn(NID_APP, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
-
- HashMap* pMap = null;
- r = reg.GetEntryListN(L"Alias", &pMap);
- if (r != E_SUCCESS)
- {
- SysLog(NID_APP, "[%s] Propagating.", GetErrorMessage(r));
- pMap->RemoveAll(true);
- delete pMap;
- return r;
- }
-
- String* pKey = null;
- String* pVal = null;
- std::unique_ptr<IMapEnumerator> pEnum(pMap->GetMapEnumeratorN());
- SysTryCatch(NID_APP, pEnum.get(), r = E_OUT_OF_MEMORY , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory error.");
-
- while(pEnum->MoveNext() == E_SUCCESS)
- {
- pKey = static_cast<String*>(pEnum->GetKey());
- pVal = static_cast<String*>(pEnum->GetValue());
-
- __aliasAppId.Add(*pKey, *pVal);
- //SysLog(NID_APP, "(%ls, %ls)", pKey->GetPointer(), pVal->GetPointer());
- }
-
- SysLog(NID_APP, "Loading %d alias sections", __aliasAppId.GetCount());
-
-CATCH:
- pMap->RemoveAll(true);
- delete pMap;
-
- return r;
-}
-
AppControl*
_AppControlRegistry::GetTizenAppControlN(const String& aId, const String& oId) const
int count = 0;
const String* pAppId = &aId;
const String* pOperation = &oId;
+
+ // legacy check first
do
{
const _AppControlAliasEntry* const pEntry = GetAppControlAliasEntry(*pAppId, *pOperation);
SysLog(NID_APP, "Found matching AppControl (%ls, %ls)", pAppId->GetPointer(), pOperation->GetPointer());
const String& soName = GetTizenAppControlProvider(*pAppId, *pOperation);
+ SysAssert(!soName.IsEmpty());
- if (soName.IsEmpty())
- {
- AppControl* pAc = GetAppControlN(*pAppId, *pOperation);
- if (pAc)
- {
- _AppControlImpl* pImpl = _AppControlImpl::GetInstance(*pAc);
- pImpl->SetProperty(_APPCONTROL_PROPERTY_ALIAS);
-
- const _AppControlAliasEntry* pLookupEntry = GetReverseRuntimeAliasEntry(*pAppId, *pOperation);
- if (pLookupEntry == null)
- {
- // no entry found : add new one
- _AppControlAliasEntry* pEntry = new (std::nothrow) _AppControlAliasEntry(aId, oId, *pAppId, *pOperation);
- if (pEntry)
- {
- // may fail
- __runtimeAlias.Add(pEntry);
- SysLog(NID_APP, "Setting alias app (%ls -> %ls).", aId.GetPointer(), pAppId->GetPointer());
- }
- }
- }
- else
- {
- SysLog(NID_APP, "No AppControl instance for (%ls, %ls)", pAppId->GetPointer(), pOperation->GetPointer());
- }
- return pAc;
- }
-
- return _AppControlImpl::CreateN(soName, *pAppId, *pOperation, L"", _APPCONTROL_PROPERTY_PUBLIC | _APPCONTROL_PROPERTY_SLP);
+ return _AppControlImpl::CreateN(soName, *pAppId, *pOperation, _APPCONTROL_PROPERTY_PUBLIC);
}
return val;
}
- SysLog(NID_APP, "No platform AppControl and use custom AppControl instead.");
- return L"";
+ SysLog(NID_APP, "Default platform AppControl %ls is used.", ACTL_DEFAULT_PLUGIN);
+ return String(ACTL_DEFAULT_PLUGIN);
}
struct AppSvcIterData
{
public:
- AppSvcIterData(ArrayList* pArr, const String& op) : pArray(pArr), operation(op) {}
+ AppSvcIterData(const _AppControlRegistry* pRegs, ArrayList* pArr, const String& op) : pThis(pRegs), pArray(pArr), operation(op) {}
+ const _AppControlRegistry* pThis;
ArrayList* pArray;
const String& operation;
};
AppSvcIterData* pAppSvcIterData = static_cast<AppSvcIterData*>(pData);
ArrayList* pList = pAppSvcIterData->pArray;
SysAssert(pList != null);
+ const _AppControlRegistry* pThis = pAppSvcIterData->pThis;
+ SysAssert(pThis != null);
const String& operation = pAppSvcIterData->operation;
if (pAppId == NULL)
}
String appId = pAppId;
- AppControl* pAc = _AppControlImpl::CreateN(appId, operation, false);
+ AppControl* pAc = pThis->GetTizenAppControlN(appId, operation);
if (pAc == null)
{
SysLog(NID_APP, "AppControl allocation failure for %ls.", appId.GetPointer());
SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] ArrayList creation failure.");
pList->Construct();
- AppSvcIterData data(pList, operation);
+ AppSvcIterData data(this, pList, operation);
appsvc_get_list(pBundle.get(), AppSvcIterFnCb, reinterpret_cast<void*>(&data));
}
-const _AppControlRegistry::_AppControlAliasEntry*
-_AppControlRegistry::GetReverseAppControlAliasEntry(const String& aId, const String& oId) const
-{
- std::unique_ptr< IMapEnumeratorT<String, _AppControlAliasEntry*> > pEnum(__aliasList.GetMapEnumeratorN());
-
- while (pEnum->MoveNext() == E_SUCCESS)
- {
- _AppControlAliasEntry* pEntry = null;
- pEnum->GetValue(pEntry);
- if (pEntry->provider2 == aId && pEntry->operation2 == oId)
- {
- SysLog(NID_APP, "Found matching AppControl (%ls, %ls)<-(%ls, %ls)", aId.GetPointer(), oId.GetPointer(), pEntry->provider.GetPointer(), pEntry->operation.GetPointer());
-
- return pEntry;
- }
- }
-
- return null;
-}
-
-
-const _AppControlRegistry::_AppControlAliasEntry*
-_AppControlRegistry::GetReverseRuntimeAliasEntry(const String& aId, const String& oId) const
-{
- std::unique_ptr< IEnumeratorT<_AppControlAliasEntry*> > pEnum(__runtimeAlias.GetEnumeratorN());
-
- while (pEnum->MoveNext() == E_SUCCESS)
- {
- _AppControlAliasEntry* pEntry = null;
- pEnum->GetCurrent(pEntry);
- if (pEntry->provider2 == aId && pEntry->operation2 == oId)
- {
- SysLog(NID_APP, "Found matching AppControl (%ls, %ls)->(%ls, %ls)", aId.GetPointer(), oId.GetPointer(), pEntry->provider2.GetPointer(), pEntry->operation2.GetPointer());
-
- return pEntry;
- }
- }
-
- return null;
-}
-
-
-AppControl*
-_AppControlRegistry::GetAppControlN(const String& appId, const String& operationId) const
-{
- bool changeAppId = false;
-
- String actualAppId = appId;
- if (appId.StartsWith(TIZEN_ALIAS_APPID_PREFIX, 0))
- {
- const String& tmp = GetAliasAppId(appId);
-
- if (!tmp.IsEmpty())
- {
- actualAppId = tmp;
- SysLog(NID_APP, "Found alias app (%ls -> %ls).", appId.GetPointer(), tmp.GetPointer());
-
- changeAppId = true;
- }
- }
-
- bool b = _Aul::IsInstalled(actualAppId);
- SysTryReturn(NID_APP, b == true, null, E_APP_NOT_INSTALLED, "[E_APP_NOT_INSTALLED] %ls not installed.", actualAppId.GetPointer());
-
- return _AppControlImpl::CreateN(actualAppId, operationId, changeAppId);
-}
-
-
AppId
_AppControlRegistry::GetAliasAppId(const AppId& appId) const
{
- String tmp;
- result r = __aliasAppId.GetValue(appId, tmp);
- if (r != E_SUCCESS)
- {
- tmp.Clear();
- }
-
- return tmp;
-}
+ std::unique_ptr<bundle, BundleDeleter> pBundle(bundle_create());
+ if (pBundle.get())
+ {
+ std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId));
-AppId
-_AppControlRegistry::GetReverseAliasAppId(const AppId& appId) const
-{
- std::unique_ptr< IMapEnumeratorT<String, String> > pEnum(__aliasAppId.GetMapEnumeratorN());
+ // appsvc_set_appid() lookup for actual app ID internally
+ appsvc_set_appid(pBundle.get(), pAppId.get());
+ const char* pTmp = appsvc_get_appid(pBundle.get());
- String key;
- String value;
- while (pEnum->MoveNext() == E_SUCCESS)
- {
- pEnum->GetKey(key);
- pEnum->GetValue(value);
- if (value == appId)
+ if (pTmp)
{
- return key;
+ return String(pTmp);
}
}
- SysLog(NID_APP, "No entry found for %ls", appId.GetPointer());
- return L"";
+ return String();
}
-
} } // Tizen::App