const wchar_t TIZEN_ALIAS_APPID_PREFIX[] = L"tizen.";
-const String ACTL_REGISTRY_OP_NUM = L"OPID_Count";
const String ACTL_REGISTRY_PUBLIC = L"Public";
const String ACTL_REGISTRY_PATH = L"Path";
-const String ACTL_REGISTRY_TITLE = L"Title";
const String ACTL_REGISTRY_ALIAS_PROVIDER = L"PROVIDER_ALIAS";
-const int PKG_CATEGORY_LEN = 256;
const int PKG_APPID_LEN = 256;
const int REG_VALUE_BUFFER_LEN = 256;
_AppControlRegistry::_AppControlRegistry(void)
{
- __nativeList.Construct();
-
__tizenList.Construct();
__aliasList.Construct();
__aliasAppId.Construct();
+
+ __runtimeAlias.Construct();
}
_AppControlRegistry::~_AppControlRegistry(void)
{
- _DeleteCollection<AppControl>(__nativeList);
-
_DeleteCollectionMapValue<String, _AppControlAliasEntry>(__aliasList);
+
+ _DeleteCollection<_AppControlAliasEntry>(__runtimeAlias);
}
_AppControlRegistry*
SysTryReturn(NID_APP, __pSelf != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
SysAssertf(__pSelf != null, "AppControl registry instance creation failure");
- __pSelf->LoadRegistry();
-
__pSelf->LoadTizenAppControlRegistry();
__pSelf->LoadLegacyList();
return __pSelf;
}
-result
-_AppControlRegistry::LoadRegistry(void)
-{
- _RegistryImpl reg;
-
- const String regPath = ACTL_DEFAULT_FILE;
-
- result r = reg.Construct(regPath, REG_OPEN_READ_ONLY, null);
- SysTryReturn(NID_APP, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
-
- const int sec_count = reg.GetAllSectionCount();
- SysTryReturnResult(NID_APP, !(sec_count <= 0), E_OBJ_NOT_FOUND, "Registry contains no data.");
-
- SysLog(NID_APP, "Loading %d sections from %ls", sec_count, regPath.GetPointer());
-
- int index = 0;
- int size = 0;
- int num = 0;
- String actl_path;
- String actl_name;
-
-
- // actual parameter manipulation
- for (int i = 0; i < sec_count; i++)
- {
- ///////////////////////////////////////////////////////////////////////
- // appcontrol Id
- String sec_name(reg.GetSectionName(i));
- sec_name.Trim();
-
- if (sec_name.IsEmpty())
- {
- continue;
- }
-
- int public_open = 0;
-
- ///////////////////////////////////////////////////////////////////////
- // Plubic
- index = reg.GetEntryIndex(i, ACTL_REGISTRY_PUBLIC);
- if (index >= 0)
- {
- size = sizeof(size);
- num = 0;
-
- reg.GetEntryValue(i, index, REG_VALUE_TYPE_INT, &num, &size);
- if (num == 1)
- {
- // public
- public_open = 1;
- }
- }
-
- ///////////////////////////////////////////////////////////////////////
- // Path
- index = reg.GetEntryIndex(i, ACTL_REGISTRY_PATH);
- if (index >= 0)
- {
- size = REG_VALUE_BUFFER_LEN;
- reg.GetEntryValue(i, index, REG_VALUE_TYPE_STRING, &actl_path, &size);
- }
-
- ///////////////////////////////////////////////////////////////////////
- // Name
- // [FIXME] SLP localized name here
- index = reg.GetEntryIndex(i, ACTL_REGISTRY_TITLE);
- if (index >= 0)
- {
- size = REG_VALUE_BUFFER_LEN;
- reg.GetEntryValue(i, index, REG_VALUE_TYPE_STRING, &actl_name, &size);
- }
-
- //SysLog(NID_APP, "%dth iteration : %ls", i, sec_name.GetPointer());
-
- ///////////////////////////////////////////////////////////////////////
- // Number of operation Id
- index = reg.GetEntryIndex(i, ACTL_REGISTRY_OP_NUM);
- if (index >= 0)
- {
- size = sizeof(size);
- reg.GetEntryValue(i, index, REG_VALUE_TYPE_INT, &num, &size);
-
- String tagName;
- String actl_opId;
-
- //SysLog(NID_APP, "number of operation %d for index %d", num, index);
-
- for (int j = 0; j < num; j++)
- {
- size = REG_VALUE_BUFFER_LEN;
-
- ///////////////////////////////////////////////////////////////
- // operation Id
- tagName.Format(10, L"OPID_%d", j);
-
- index = reg.GetEntryIndex(i, tagName);
- if (index >= 0)
- {
- reg.GetEntryValue(i, index, REG_VALUE_TYPE_STRING, &actl_opId, &size);
- actl_opId.Trim();
- }
- //SysLog(NID_APP, "Operation(%d) %ls", index, actl_opId.GetPointer());
-
- ///////////////////////////////////////////////////////////////
- // AppControl allocation
-
- int prop = 0;
- if (public_open == 1)
- {
- prop |= _APPCONTROL_PROPERTY_PUBLIC;
- }
-
- prop |= _APPCONTROL_PROPERTY_SLP;
-
- //SysLog(NID_APP, "(%ls, %ls)", sec_name.GetPointer(), actl_opId.GetPointer());
- AppControl* pAc = _AppControlImpl::CreateN(actl_path, sec_name, actl_opId, actl_name, prop);
-
- if (pAc)
- {
- __nativeList.Add(pAc);
- }
- else
- {
- SysLog(NID_APP, "Failed to create AppControl instance (%ls, %ls, %d)",
- sec_name.GetPointer(), actl_opId.GetPointer(), public_open);
- }
- }
- }
-
- }
-
- SysLog(NID_APP, "Finished loading %d entries", __nativeList.GetCount());
-
- return E_SUCCESS;
-}
result
_AppControlRegistry::LoadTizenAppControlRegistry(void)
if (r != E_SUCCESS)
{
SysLog(NID_APP, "[%s] Propagating.", GetErrorMessage(r));
+ pMap->RemoveAll(true);
delete pMap;
return r;
}
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
+_AppControlRegistry::GetTizenAppControlN(const String& aId, const String& oId)
{
- const _AppControlAliasEntry* pEntry = null;
int count = 0;
-
+ const String* pAppId = &aId;
+ const String* pOperation = &oId;
do
{
- const _AppControlAliasEntry* pTempEntry = GetAppControlAliasEntry(aId, oId);
+ const _AppControlAliasEntry* const pEntry = GetAppControlAliasEntry(*pAppId, *pOperation);
// number does not matter
- if (count >= 5 || pTempEntry == null)
+ if (count >= 5 || pEntry == null)
{
break;
}
- pEntry = pTempEntry;
+ pAppId = &pEntry->provider2;
+ pOperation = &pEntry->operation2;
count++;
}
while (true);
- const String* pAppId = null;
- const String* pOperation = null;
-
- if (count == 0)
- {
- // if count is 0, then no alias is found
- pAppId = &aId;
- pOperation = &oId;
- }
- else if (pEntry == null)
- {
- // no "TIZEN" AppControl
- return null;
- }
- else
- {
- pAppId = &pEntry->provider2;
- pOperation = &pEntry->operation2;
- }
-
SysAssert(pAppId != null);
SysAssert(pOperation != null);
if (soName.IsEmpty())
{
- SysLog(NID_APP, "No AppControl stub found for (%ls, %ls)", pAppId->GetPointer(), pOperation->GetPointer());
- return null;
+ 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);
}
-AppControl*
-_AppControlRegistry::GetNativeAppControlN(const String& aId, const String& oId) const
-{
- std::unique_ptr< IEnumeratorT<AppControl*> > pEnum(__nativeList.GetEnumeratorN());
-
- while (pEnum->MoveNext() == E_SUCCESS)
- {
- AppControl* pAc = null;
- pEnum->GetCurrent(pAc);
-
- if (pAc->GetAppControlProviderId() == aId && pAc->GetOperationId() == oId)
- {
- SysLog(NID_APP, "Found matching AppControl (%ls, %ls)", aId.GetPointer(), oId.GetPointer());
- return _AppControlImpl::CreateN(*pAc);
- }
- }
-
- SysLog(NID_APP, "No matching AppControl (%ls, %ls)", aId.GetPointer(), oId.GetPointer());
-
- return null;
-}
-
//
-// data structure for _AppControlRegistry::GetAppControlListN() only
-//
+// data structure for _AppControlRegistry::FindAppControlListN() only
+//
struct AppSvcIterData
{
public:
};
//
-// callback function for _AppControlRegistry::GetAppControlListN()
+// callback function for _AppControlRegistry::FindAppControlListN()
//
static int
AppSvcIterFnCb(const char* pAppId, void* pData)
return null;
}
+
const _AppControlRegistry::_AppControlAliasEntry*
_AppControlRegistry::GetReverseAppControlAliasEntry(const String& aId, const String& oId) const
{
return null;
}
-AppControl*
-_AppControlRegistry::GetAliasAppControlN(const String& aId, const String& oId) const
+
+const _AppControlRegistry::_AppControlAliasEntry*
+_AppControlRegistry::GetReverseRuntimeAliasEntry(const String& aId, const String& oId) const
{
- const _AppControlAliasEntry* pEntry = GetAppControlAliasEntry(aId, oId);
+ std::unique_ptr< IEnumeratorT<_AppControlAliasEntry*> > pEnum(__runtimeAlias.GetEnumeratorN());
- if (pEntry)
+ while (pEnum->MoveNext() == E_SUCCESS)
{
- AppControl* pAc = GetNativeAppControlN(pEntry->provider2, pEntry->operation2);
- if (pAc)
- {
- _AppControlImpl* pImpl = _AppControlImpl::GetInstance(*pAc);
- pImpl->SetProperty(_APPCONTROL_PROPERTY_ALIAS);
- }
- else
+ _AppControlAliasEntry* pEntry = null;
+ pEnum->GetCurrent(pEntry);
+ if (pEntry->provider2 == aId && pEntry->operation2 == oId)
{
- pAc = GetAppControlN(pEntry->provider2, pEntry->operation2);
- if (pAc)
- {
- _AppControlImpl* pImpl = _AppControlImpl::GetInstance(*pAc);
- pImpl->SetProperty(_APPCONTROL_PROPERTY_ALIAS);
- }
- else
- {
- SysLog(NID_APP, "No matching AppControl found.");
- }
- }
+ SysLog(NID_APP, "Found matching AppControl (%ls, %ls)->(%ls, %ls)", aId.GetPointer(), oId.GetPointer(), pEntry->provider2.GetPointer(), pEntry->operation2.GetPointer());
- return pAc;
+ return pEntry;
+ }
}
- SysLog(NID_APP, "No matching AppControl found.");
return null;
}
+
AppControl*
_AppControlRegistry::GetAppControlN(const String& appId, const String& operationId) const
{
{
const String& tmp = GetAliasAppId(appId);
- if (tmp.IsEmpty())
+ if (!tmp.IsEmpty())
{
actualAppId = tmp;
- SysLog(NID_APP, "Found alias appId (%ls -> %ls).", appId.GetPointer(), tmp.GetPointer());
+ SysLog(NID_APP, "Found alias app (%ls -> %ls).", appId.GetPointer(), tmp.GetPointer());
changeAppId = true;
}
return L"";
}
+
} } // Tizen::App