// AppControl event handling is expected to be performed in the main thread.
__appControlEvent.Construct();
__appControlEvent.AddListener(*dynamic_cast<_IAppControlSysEventListener*>(this));
+ __listenerList.Construct();
}
_AppControlManager::~_AppControlManager(void)
if (pInfo->magic == LAUNCH_INFO_MAGIC)
{
SysLog(NID_APP, "Invoking callback 0x%x", pInfo->launchCb);
+ //pAppArg->Print();
- (*pInfo->launchCb)(pInfo->pUserData, pInfo->pArg, pAppArg, static_cast<service_result_e>(res), pInfo->property);
+ if (pInfo->pUserData && (!__listenerList.Contains(pInfo->pUserData)))
+ {
+ (*pInfo->launchCb)(pInfo->pUserData, pInfo->pArg, pAppArg, static_cast<service_result_e>(res), pInfo->property);
+ }
}
else
{
else
{
IAppControlResponseListener* pListener = dynamic_cast<IAppControlResponseListener*>(pInfo->pListener);
- if (pListener)
+ if (pListener && (!__listenerList.Contains(pInfo->pListener)))
{
+ SysLog(NID_APP, "OSP_AC OnAppControlCompleteResponseReceived");
pListener->OnAppControlCompleteResponseReceived(aId, oId, static_cast<AppCtrlResult>(res), pArgs);
}
else
appsvc_set_uri(kb, uri);
}
- const long handle = _AppImpl::GetInstance()->GetWindowHandle();
- _AppArg::UpdateWindowHandle(kb, handle);
+ if (_AppImpl::GetInstance() != null)
+ {
+ const long handle = _AppImpl::GetInstance()->GetWindowHandle();
+ _AppArg::UpdateWindowHandle(kb, handle);
+ }
SysLog(NID_APP, "MIME(%s), URI(%s).", appsvc_get_mime(kb), appsvc_get_uri(kb));
int pid = appsvc_run_service(kb, 0, reinterpret_cast<appsvc_res_fn>(pCb), this);
- SysTryReturnResult(NID_APP, pid >= 0, E_SYSTEM, "Launching service %s failure with %d", pkg_name, pid);
+ result r = E_SUCCESS;
+ if (pid < 0)
+ {
+ switch (pid)
+ {
+ case APPSVC_RET_EILLACC:
+ r = E_ILLEGAL_ACCESS;
+ break;
+ default:
+ r = E_SYSTEM;
+ break;
+ }
+ SysLog(NID_APP, "[%s]Launching service %s failure", GetErrorMessage(r), pkg_name);
+ }
- return E_SUCCESS;
+ return r;
}
int
_AppControlManager::Launch(_AppMessageImpl& msg, const char* pkg_name, const char* op, const char* mime, const char* uri, AppSvcResFn pCb, void* data)
appsvc_set_uri(kb, uri);
}
- const long handle = _AppImpl::GetInstance()->GetWindowHandle();
- _AppArg::UpdateWindowHandle(kb, handle);
+ if (_AppImpl::GetInstance() != null)
+ {
+ const long handle = _AppImpl::GetInstance()->GetWindowHandle();
+ _AppArg::UpdateWindowHandle(kb, handle);
+ }
SysLog(NID_APP, "MIME(%s), URI(%s).", appsvc_get_mime(kb), appsvc_get_uri(kb));
int pid = appsvc_run_service(kb, 0, reinterpret_cast<appsvc_res_fn>(pCb), this);
- SysTryReturn(NID_APP, pid >= 0, -1, E_SYSTEM, "Launching service %s failure with %d", pkg_name, pid);
+ result r = E_SUCCESS;
+ if (pid < 0)
+ {
+ switch (pid)
+ {
+ case APPSVC_RET_EILLACC:
+ r = E_ILLEGAL_ACCESS;
+ break;
+ default:
+ r = E_SYSTEM;
+ break;
+ }
+ SysLog(NID_APP, "[%s]Launching service %s failure", GetErrorMessage(r), pkg_name);
+ }
+ SetLastResult(r);
return pid;
}
}
result
-_AppControlManager::LaunchAppWithCondition(const AppId& appId, const String& executableName, const String& condition, IList* pArrayArgs)
+_AppControlManager::LaunchAppWithCondition(const AppId& appId, const String& condition, IList* pArrayArgs)
{
result r = E_SUCCESS;
- const String& actualAppId = appId + L'.' + executableName;
_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(actualAppId, pArg);
-
+ r = _AppControlManager::LaunchApp(appId, pArg);
CATCH:
delete pArg;
return r;
pArg->UpdateRequestId(req);
- const long handle = _AppImpl::GetInstance()->GetWindowHandle();
- pArg->UpdateWindowHandle(handle);
+ if (_AppImpl::GetInstance() != null)
+ {
+ const long handle = _AppImpl::GetInstance()->GetWindowHandle();
+ pArg->UpdateWindowHandle(handle);
+ }
int pid = -1;
bundle* kb = NULL;
}
while (count < TRY_COUNT);
- SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] Launching service failure for %ls with %d", appId.GetPointer(), pid);
+ result r = E_SUCCESS;
+ switch (pid)
+ {
+ case APPSVC_RET_EILLACC:
+ r = E_ILLEGAL_ACCESS;
+ break;
+ default:
+ r = E_SYSTEM;
+ break;
+ }
+
+ SysLogException(NID_APP, r, "[%s] Launching service failure for %ls", GetErrorMessage(r), appId.GetPointer());
- return E_SYSTEM;
+ return r;
}
int
pArg->UpdateRequestId(req);
- const long handle = _AppImpl::GetInstance()->GetWindowHandle();
- pArg->UpdateWindowHandle(handle);
+ if (_AppImpl::GetInstance() != null)
+ {
+ const long handle = _AppImpl::GetInstance()->GetWindowHandle();
+ pArg->UpdateWindowHandle(handle);
+ }
int pid = -1;
bundle* kb = NULL;
}
while (count < TRY_COUNT);
- SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] Launching service failure for %ls with %d", appId.GetPointer(), pid);
+ result r = E_SUCCESS;
+ switch (pid)
+ {
+ case APPSVC_RET_EILLACC:
+ r = E_ILLEGAL_ACCESS;
+ break;
+ default:
+ r = E_SYSTEM;
+ break;
+ }
+
+ SysLogException(NID_APP, r, "[%s] Launching service failure for %ls", GetErrorMessage(r), appId.GetPointer());
+
+ SetLastResult(r);
return pid;
}
}
int pid = appsvc_run_service(kb, req, LaunchResultCb, this);
- switch (pid)
+ if (pid > 0)
{
- case APPSVC_RET_EINVAL:
- r = E_OBJ_NOT_FOUND;
- break;
- case APPSVC_RET_ENOMATCH:
- r = E_OBJ_NOT_FOUND;
- break;
- case APPSVC_RET_ERROR:
- // fall through
- case APPSVC_RET_ELAUNCH:
- r = E_SYSTEM;
- break;
- default:
- break;
+ char pkgname[255] = {0, };
+ aul_app_get_pkgname_bypid(pid, pkgname, 255);
+
+ if (strncmp(pkgname, APP_SELECTOR, strlen(APP_SELECTOR)) != 0)
+ {
+ const char* pOperation = appsvc_get_operation(kb);
+
+ SysLog(NID_APP, "Starting application without selector : (%s, %s).", pkgname, pOperation);
+
+ SendAppControlStartResponse(req, pkgname, pOperation);
+ }
+ }
+ else
+ {
+ switch (pid)
+ {
+ case APPSVC_RET_EINVAL:
+ r = E_OBJ_NOT_FOUND;
+ break;
+ case APPSVC_RET_ENOMATCH:
+ r = E_OBJ_NOT_FOUND;
+ break;
+ case APPSVC_RET_EILLACC:
+ r = E_ILLEGAL_ACCESS;
+ break;
+ case APPSVC_RET_ERROR:
+ // fall through
+ case APPSVC_RET_ELAUNCH:
+ // fall through
+ default:
+ r = E_SYSTEM;
+ break;
+ }
}
SysLog(NID_APP, "[%s] Application(%d) launched with reqId(%d) and arg(0x%x).", GetErrorMessage(r), pid, req, pArg);
{
__launchManager.RemoveItem(req);
}
+int
+_AppControlManager::GetLaunchRequestCount(void)
+{
+ return __launchManager.GetCount();
+}
result
_AppControlManager::RegisterRequest(service_s* service, int& req, _AppHandler& handler)