#include <FAppSqlDataControl.h>
#include <FAppMapDataControl.h>
#include <FAppPkgPackageInfo.h>
+#include <FAppPkgPackageAppInfo.h>
#include <FBaseSysLog.h>
#include <FBase_StringConverter.h>
return E_SUCCESS;
}
+
+String
+_AppControlManager::GetMimeTypeFromDataType(const String& data)
+{
+ // Data type is either MIME type or .[extension]
+
+ if (data.IsEmpty() || data[0] != L'.')
+ {
+ return data;
+ }
+
+ // .[extension]
+ String ext;
+ data.SubString(1, ext);
+
+ String res;
+ result r = _AppControlManager::GetMimeFromExt(ext, res);
+ SysTryReturn(NID_APP, !IsFailed(r), L"", r, "[%s] MIME type conversion failed for %ls.", GetErrorMessage(r), ext.GetPointer());
+
+ SysLog(NID_APP, "Conversion from %ls into %ls.", data.GetPointer(), res.GetPointer());
+ return res;
+}
+
+
void
_AppControlManager::OnAppControlEventReceivedN(int reqId, _AppArg* pAppArg, int res)
{
SysLogException(NID_APP, E_SYSTEM, "Invalid AppControl listener.");
}
-#if 0
- // [FIXME] following logic is not needed.
- // call TerminateAppControl
- if (pInfo->pProvider)
- {
- pInfo->pProvider->StopAppControlPlugin(pInfo->reqId);
- SysLog(NID_APP, "AppControl stopped for req %d.", pInfo->reqId);
- }
-#endif
// remove from list and unload dll
__inAppManager.RemoveItem(reqId);
result
-_AppControlManager::LaunchPkg(const char* pkg_name, const char* op, const char* mime, const char* uri, AppSvcResFn pCb, void* data)
-{
- _AppMessageImpl msg;
-
- return LaunchPkg(msg, pkg_name, op, mime, uri, pCb, data);
-}
-
-result
-_AppControlManager::LaunchAppWithCondition(const AppId& appId, const String& condition, IList* pArrayArgs)
-{
- result r = E_SUCCESS;
- _AppArg * pArg = new (std::nothrow) _AppArg();
- SysTryCatch(NID_APP, pArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]");
-
- r = pArg->ConstructForAppLaunchCondition(condition, pArrayArgs);
- SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] ConstructForAppLaunchCondition(%ls, .. ) fails", GetErrorMessage(r), condition.GetPointer());
-
- r = _AppControlManager::LaunchApp(appId, pArg);
-CATCH:
- delete pArg;
- return r;
-}
-
-result
_AppControlManager::LaunchApp(const AppId& appId, _AppArg* pArg, int req)
{
SysTryReturnResult(NID_APP, pArg != null, E_INVALID_ARG, "Invalid launch argument");
SysLog(NID_APP, "App: %ls.", appId.GetPointer());
String actualAppId = appId;
+#if 0
+ // This logic is only for very old legacy code to support "pkgid" launch and should be removed
if (appId.GetLength() == 10)
{
const String& name = _PackageManagerImpl::GetInstance()->GetDefaultAppExecutableName(appId);
actualAppId.Append(name);
}
}
+#endif
pArg->UpdateRequestId(req);
int pid = -1;
bundle* kb = NULL;
- String tempId;
- actualAppId.SubString(0, 10, tempId);
- tempId += L'.';
- tempId += L"_AppControl";
- // [INFO] Ugly solution for submode support
- pArg->UpdateAppId(tempId);
- kb = pArg->GetBundle();
-
- pid = appsvc_run_service(kb, req, LaunchResultCb, this);
- if (pid >= 0)
- {
- SysLog(NID_APP, "Submode launch successful");
- return E_SUCCESS;
- }
- else if (pid == APPSVC_RET_EINVAL)
+ std::unique_ptr< PackageAppInfo > pAppInfo(_PackageManagerImpl::GetInstance()->GetPackageAppInfoN(appId));
+ SysTryReturn(NID_APP, pAppInfo != null, E_SYSTEM, GetLastResult(), "[%s] Getting AppInfo failed.", GetErrorMessage(GetLastResult()));
+ _PackageAppInfoImpl* pAppInfoImpl = _PackageAppInfoImpl::GetInstance(pAppInfo.get());
+ SysTryReturnResult(NID_APP, pAppInfoImpl != null , E_SYSTEM, "Severe system error");
+
+ if (pAppInfoImpl->IsServiceApp() == false)
{
- SysLog(NID_APP, "Argument overflow");
- return E_MAX_EXCEEDED;
+ String tempId;
+ actualAppId.SubString(0, 10, tempId);
+ tempId += L'.';
+ tempId += String(SUBMODE_NAME);
+
+ // [INFO] Ugly solution for submode support
+ pArg->UpdateAppId(tempId);
+ kb = pArg->GetBundle();
+
+ pid = appsvc_run_service(kb, req, LaunchResultCb, this);
+ if (pid >= 0)
+ {
+ SysLog(NID_APP, "Submode launch successful");
+ return E_SUCCESS;
+ }
+ else if (pid == APPSVC_RET_EINVAL)
+ {
+ SysLog(NID_APP, "Argument overflow");
+ return E_MAX_EXCEEDED;
+ }
}
pArg->UpdateAppId(actualAppId);
if ((!(type & _APP_TYPE_SERVICE_APP)) && _IsDefaultApplication(tempId, appId))
{
tempId += L'.';
- tempId += L"_AppControl";
+ tempId += String(SUBMODE_NAME);
// [INFO] Ugly solution for submode support
pArg->UpdateAppId(tempId);