//
-// Open Service Platform
// Copyright (c) 2012 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the License);
#include <appsvc/appsvc.h>
+#include <FBaseColHashMap.h>
+#include <FBaseSysLog.h>
#include <FAppAppControl.h>
#include <FAppAppManager.h>
#include <FAppPkgPackageAppInfo.h>
#include <FAppIAppControlEventListener.h>
#include <FAppIAppControlResponseListener.h>
-#include <FBaseColHashMap.h>
-#include <FBaseSysLog.h>
-
-#include <FBaseRt_LibraryImpl.h>
-#include <FIo_DirectoryImpl.h>
#include "FApp_AppControlImpl.h"
#include "FApp_AppControlManager.h"
+#include "FApp_IAppControlPluginProvider.h"
#include "FApp_AppArg.h"
-#include "FApp_AppImpl.h"
#include "FApp_AppControlRegistry.h"
#include "FApp_AppMessageImpl.h"
#include "FApp_AppInfo.h"
namespace
{
-static const int _REQ_ID_INVALID = -1;
+const wchar_t ACTL_IMPLICIT_PLUGIN[] = L"libosp-ac-implicit.so";
+const wchar_t TIZEN_ALIAS_APPID_PREFIX[] = L"tizen.";
}
namespace Tizen { namespace App
{
-const wchar_t TIZEN_OPERATION_MAIN[] = L"http://tizen.org/appcontrol/operation/main";
-const char TIZEN_APPCONTROL_DATA_LEGACY[] = "http://tizen.org/appcontrol/data/legacyresult";
-
_AppControlImpl::_AppControlImpl(const AppControl& value)
: _appControl(value)
- , _reqId(_REQ_ID_INVALID)
+ , _reqId(APPCONTROL_REQUEST_ID_INVALID)
, _property(_APPCONTROL_PROPERTY_NONE)
- , _processId(_REQ_ID_INVALID)
+ , _processId(APPCONTROL_REQUEST_ID_INVALID)
{
__appControlResponseEventList.Construct();
}
}
AppControl*
-_AppControlImpl::CreateN(const String& path, const String& aId, const String& oId, const String& name, int prop)
+_AppControlImpl::CreateN(const String& path, const String& aId, const String& oId, int prop)
{
SysTryReturn(NID_APP, !path.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] Path is empty.");
SysTryReturn(NID_APP, !aId.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] Provider Id is empty.");
- SysTryReturn(NID_APP, !oId.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] Operation Id is empty.");
-
- AppControl* pAc = new (std::nothrow) AppControl;
- SysTryReturn(NID_APP, pAc != null, null, E_OUT_OF_MEMORY, "AppControl allocation failure.");
-
- _AppControlImpl* pImpl = pAc->__pAppControlImpl;
- SysTryReturn(NID_APP, pImpl != null, null, E_OUT_OF_MEMORY, "AppControlImpl instance must not be null.");
- pImpl->_path = path;
- pImpl->_provider = aId;
- pImpl->_opId = oId;
- // [FIXME] Proper App name setting
- pImpl->_appName = name;
- pImpl->_property = prop;
+ String actualAppId = aId;
+ if (aId.StartsWith(TIZEN_ALIAS_APPID_PREFIX, 0))
+ {
+ // little bit of performance tweak
+ actualAppId = _AppControlRegistry::GetInstance()->GetAliasAppId(aId);
+ }
- return pAc;
-}
+ const bool isInstalled = _Aul::IsInstalled(actualAppId);
+ SysTryReturn(NID_APP, isInstalled, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] %ls not installed.", actualAppId.GetPointer());
-AppControl*
-_AppControlImpl::CreateN(const AppId& appId, const String& operationId, bool changeAppId)
-{
- SysTryReturn(NID_APP, !appId.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] appId is empty.");
AppControl* pAc = new (std::nothrow) AppControl;
SysTryReturn(NID_APP, pAc != null, null, E_OUT_OF_MEMORY, "AppControl allocation failure.");
_AppControlImpl* pImpl = pAc->__pAppControlImpl;
SysTryReturn(NID_APP, pImpl != null, null, E_OUT_OF_MEMORY, "AppControlImpl instance must not be null.");
- pImpl->_path = appId;
- pImpl->_provider = appId;
- pImpl->_opId = operationId;
- //pImpl->_appName = appId;
- pImpl->_property |= (_APPCONTROL_PROPERTY_OSP | _APPCONTROL_PROPERTY_PUBLIC);
-
- if (changeAppId)
- {
- pImpl->_property |= _APPCONTROL_PROPERTY_APPID_CHANGE;
- }
+ pImpl->_path = path;
+ pImpl->_appId = aId;
+ pImpl->_opId = (oId.IsEmpty()) ? TIZEN_OPERATION_MAIN : oId;
+ pImpl->_property = prop;
return pAc;
}
-AppControl*
-_AppControlImpl::CreateN(const AppControl& ac)
-{
- const _AppControlImpl* pImpl = GetInstance(ac);
- SysTryReturn(NID_APP, pImpl != null, null, E_INVALID_STATE, "AppControlImpl instance must not be null.");
-
- return CreateN(pImpl->_path, pImpl->_provider, pImpl->_opId, pImpl->_appName, pImpl->_property);
-}
-
-const _AppControlImpl*
-_AppControlImpl::GetInstance(const AppControl& ac)
-{
- return ac.__pAppControlImpl;
-}
-_AppControlImpl*
-_AppControlImpl::GetInstance(AppControl& ac)
+_IAppControlPluginProvider*
+_AppControlImpl::GetAppControlPluginProvider(const String& path)
{
- return ac.__pAppControlImpl;
-}
+ _LibraryImpl lib;
+ lib.Construct(path, _LIBRARY_OPTION);
-result
-_AppControlImpl::Start(const IList* pDataList, IAppControlEventListener* pListener)
-{
- SysLog(NID_APP, "Enter");
- result r = E_SYSTEM;
+ APP_CONTROL_PROVIDER_GET_FN pProvider = reinterpret_cast<APP_CONTROL_PROVIDER_GET_FN>(lib.GetProcAddress(L"GetAppControlProviderPlugin"));
- if (_property & _APPCONTROL_PROPERTY_SLP)
+ if (!pProvider)
{
- r = StartNative(pDataList, pListener);
+ SysLogException(NID_APP, E_SYSTEM, "Cannot load plugin properly for %ls.", path.GetPointer());
+ return null;
}
- else if (_property & _APPCONTROL_PROPERTY_OSP)
- {
- r = StartOsp(pDataList, pListener);
- }
- else
- {
- SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] Invalid AppControl type(property %d)", _property);
- }
- SysLog(NID_APP, "Exit");
- return r;
+ return (*pProvider)();
}
-result
-_AppControlImpl::Start(const String* pUriData, const String* pDataType, const IMap* pExtraData, IAppControlResponseListener* pListener)
-{
- SysLog(NID_APP, "Enter");
- result r = E_SYSTEM;
-
- if (_property & _APPCONTROL_PROPERTY_SLP)
- {
- r = StartNative(pUriData, pDataType, pExtraData, pListener);
- }
- else if (_property & _APPCONTROL_PROPERTY_OSP)
- {
- r = StartOsp(pUriData, pDataType, pExtraData, pListener);
- }
- else
- {
- SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] Invalid AppControl type(property %d)", _property);
- }
- SysLog(NID_APP, "Exit");
-
- return r;
-}
result
_AppControlImpl::FindAndStart(const String& operationId, const String* pUriPattern, const String* pDataType, const String* pCategory, const IMap* pExtraData, IAppControlResponseListener* pListener)
if (pDataType)
{
- String mimeType = *pDataType;
-
- if ((*pDataType)[0] == L'.')
- {
- SysLog(NID_APP, "Extension to MIME conversion for %ls", pDataType->GetPointer());
-
-#if 0
- String ext;
- pDataType->SubString(1, ext);
-
- result r = _AppControlManager::GetMimeFromExt(ext, mimeType);
-
- SysTryReturn(NID_APP, !IsFailed(r), null, r, "[%s] MIME type conversion failure for %ls.", GetErrorMessage(r), ext.GetPointer());
-
- pMimeType = &mimeType;
-
- SysLog(NID_APP, "Conversion : %ls -> %ls.", pDataType->GetPointer(), pMimeType->GetPointer());
-#endif
- }
+ const String& mimeType = _AppControlManager::GetMimeTypeFromDataType(*pDataType);
_AppMessageImpl::SetMime(pBundle.get(), mimeType);
}
return StartImplicit(pBundle.get(), pExtraData, pListener);
}
-result
-_AppControlImpl::StartOsp(const IList* pDataList, IAppControlEventListener* pListener)
-{
- SysLog(NID_APP, "Enter");
- result r = E_SUCCESS;
-
- _AppArg* pArg = new (std::nothrow) _AppArg;
- SysTryReturnResult(NID_APP, pArg != null, E_OUT_OF_MEMORY, "Argument allocation failure.");
-
- pArg->Construct(*this, pDataList);
-
- _AppControlManager* pImpl = _AppControlManager::GetInstance();
- int req = _REQ_ID_INVALID;
-
- if (pListener)
- {
- _AppControlManager::_RequestGuard reqObj = _AppControlManager::_RequestGuard(*pImpl, pArg, AppControlCbLegacy, pListener, _property);
- req = reqObj.GetRequestNumber();
-
- _processId = pImpl->Launch(_path, pArg, req);
-
- if (_processId < 0)
- {
- reqObj.Invalidate();
- r = GetLastResult();
- SysLog(NID_APP, "[%s]Launching(%ls) is failed" , GetErrorMessage(r), _path.GetPointer());
- return r;
- }
- }
- else
- {
- _processId = pImpl->Launch(_path, pArg);
- delete pArg;
- SysTryReturnResult(NID_APP, _processId >= 0, GetLastResult(), "Launching(%ls) is failed", _path.GetPointer());
- }
- SysLog(NID_APP, "Exit");
-
- return r;
-}
-
-result
-_AppControlImpl::StartOsp(const String* pUriData, const String* pMimeType, const IMap* pDataList, IAppControlResponseListener* pListener)
-{
- SysLog(NID_APP, "Enter");
- result r = E_SUCCESS;
-
- _AppArg* pArg = new (std::nothrow) _AppArg;
- SysTryReturnResult(NID_APP, pArg != null, E_OUT_OF_MEMORY, "Argument allocation failure.");
-
- pArg->Construct(*this, pUriData, pMimeType, pDataList);
-
- _AppControlManager* pImpl = _AppControlManager::GetInstance();
- int req = _REQ_ID_INVALID;
-
- if (pListener)
- {
- _AppControlManager::_RequestGuard reqObj = _AppControlManager::_RequestGuard(*pImpl, pArg, AppControlCb, pListener, _property);
- req = reqObj.GetRequestNumber();
-
- if (_ThreadImpl::GetCurrentThreadImpl()->GetThreadType() == THREAD_TYPE_EVENT_DRIVEN)
- {
- _AppControlResponseEvent* pAppControlResponseEvent = new (std::nothrow) _AppControlResponseEvent();
- if (pAppControlResponseEvent != null)
- {
- r = pAppControlResponseEvent->Construct();
- SysTryLog(NID_APP, r == E_SUCCESS, "[%s]_AppControlResponseEvent::Construct() is failed", GetErrorMessage(r));
-
- r = pAppControlResponseEvent->AddListener(*this, true);
- SysTryLog(NID_APP, r == E_SUCCESS, "[%s]_AppControlResponseEvent::AddListener() is failed", GetErrorMessage(r));
-
- IMapT<int, _AppControlResponseEvent*>* pResponseEventContainer = pImpl->GetAppControlResponseEventContainer();
- if (pResponseEventContainer != null)
- {
- pResponseEventContainer->Add(req, pAppControlResponseEvent);
- __appControlResponseEventList.Add(req);
- SysLog(NID_APP, "pResponseEvent gets added. reqId(%d)", req);
- }
- }
- }
-
- _processId = pImpl->Launch(_path, pArg, req);
- if (_processId < 0)
- {
- reqObj.Invalidate();
- r = GetLastResult();
- SysLog(NID_APP, "[%s]Launching(%ls) is failed" , GetErrorMessage(r), _path.GetPointer());
- return r;
- }
- }
- else
- {
- _processId = pImpl->Launch(_path, pArg);
- delete pArg;
- SysTryReturnResult(NID_APP, _processId >= 0, GetLastResult(), "Launching(%ls) is failed", _path.GetPointer());
- }
- SysLog(NID_APP, "Exit");
-
- return r;
-}
result
-_AppControlImpl::StartImplicit(bundle* pBundle, const IList* pDataList, IAppControlEventListener* pListener)
+_AppControlImpl::StartImplicit(const _AppMessageImpl& msg, IEventListener* pListener, bool isLegacy)
{
SysLog(NID_APP, "Enter");
- result r = E_SUCCESS;
-
- _AppArg* pArg = new (std::nothrow) _AppArg;
- SysTryReturnResult(NID_APP, pArg != null, E_OUT_OF_MEMORY, "Argument allocation failure.");
-
- pArg->Construct(pBundle);
-
- _AppMessageImpl::AddData(pArg->GetBundle(), pDataList);
+ int req = APPCONTROL_REQUEST_ID_INVALID;
- _AppControlManager* pImpl = _AppControlManager::GetInstance();
- int req = _REQ_ID_INVALID;
-
- if (pListener)
- {
- _AppControlManager::_RequestGuard reqObj = _AppControlManager::_RequestGuard(*pImpl, pArg, AppControlCbLegacy, pListener, _APPCONTROL_PROPERTY_NONE);
- req = reqObj.GetRequestNumber();
-
- r = pImpl->LaunchAppImplicit(pArg, req);
- SysTryCatch(NID_APP, r == E_SUCCESS, reqObj.Invalidate(), r, "[%s] Propagating." , GetErrorMessage(r));
- }
- else
+ _IAppControlPluginProvider* pProvider = GetAppControlPluginProvider(ACTL_IMPLICIT_PLUGIN);
+ if (pProvider == null)
{
- r = pImpl->LaunchAppImplicit(pArg, -1);
- delete pArg;
+ SysPropagate(NID_APP, E_OBJ_NOT_FOUND);
+ return E_OBJ_NOT_FOUND;
}
- // [FIXME] launch registration is not working correctly
- SysLog(NID_APP, "Exit");
-
-CATCH:
- return r;
-}
-
-result
-_AppControlImpl::StartImplicit(bundle* pBundle, const IMap* pData, IAppControlResponseListener* pListener)
-{
- SysLog(NID_APP, "Enter");
- result r = E_SUCCESS;
-
- _AppArg* pArg = new (std::nothrow) _AppArg;
- SysTryReturnResult(NID_APP, pArg != null, E_OUT_OF_MEMORY, "Argument allocation failure.");
-
- pArg->Construct(pBundle);
-
- _AppArg::AddStrMap(pArg->GetBundle(), pData);
-
- _AppControlManager* pImpl = _AppControlManager::GetInstance();
- int req = _REQ_ID_INVALID;
-
if (pListener)
{
- _AppControlManager::_RequestGuard reqObj = _AppControlManager::_RequestGuard(*pImpl, pArg, AppControlCb, pListener, _APPCONTROL_PROPERTY_NONE);
- req = reqObj.GetRequestNumber();
-
- if (_ThreadImpl::GetCurrentThreadImpl()->GetThreadType() == THREAD_TYPE_EVENT_DRIVEN)
+ _InProcessInfo* pItem = new (std::nothrow) _InProcessInfo(isLegacy, pProvider, pListener);
+ if (pItem)
{
- _AppControlResponseEvent* pAppControlResponseEvent = new (std::nothrow) _AppControlResponseEvent();
-
- if (pAppControlResponseEvent != null)
- {
- r = pAppControlResponseEvent->Construct();
- SysTryLog(NID_APP, r == E_SUCCESS, "[%s]_AppControlResponseEvent::Construct() is failed", GetErrorMessage(r));
-
- r = pAppControlResponseEvent->AddListener(*pImpl, true);
- SysTryLog(NID_APP, r == E_SUCCESS, "[%s]_AppControlResponseEvent::AddListener() is failed", GetErrorMessage(r));
-
- IMapT<int, _AppControlResponseEvent*>* pResponseEventContainer = pImpl->GetAppControlResponseEventContainer();
- if (pResponseEventContainer != null)
- {
- pResponseEventContainer->Add(req, pAppControlResponseEvent);
- SysLog(NID_APP, "pResponseEvent gets added. reqId(%d)", req);
- }
- }
+ req = _AppControlManager::GetInstance()->__inAppManager.InsertItem(pItem);
}
- r = pImpl->LaunchAppImplicit(pArg, req);
- SysTryCatch(NID_APP, r == E_SUCCESS, reqObj.Invalidate(), r, "[%s] Propagating." , GetErrorMessage(r));
- }
- else
- {
- r = pImpl->LaunchAppImplicit(pArg, -1);
- delete pArg;
- }
- SysLog(NID_APP, "Exit");
-
- // [FIXME] launch registration is not working correctly
-
-CATCH:
-
- return r;
-}
-
-result
-_AppControlImpl::AppControlCbLegacy(void* data, _AppArg* pArg, _AppArg* pResArg, service_result_e res, int prop, int reqId)
-{
- SysLog(NID_APP, "Result value %d", res);
-
- SysTryReturnResult(NID_APP, data && pResArg && pArg, E_SYSTEM, "Invalid result (callback, result, arg) = (0x%x, 0x%x, 0x%x).",
- data, pResArg,
- pArg);
-
- bundle* b = pResArg->GetBundle();
- SysTryReturnResult(NID_APP, b != NULL, E_SYSTEM, "Invalid result bundle.");
-
- IAppControlEventListener* pListener = static_cast<IAppControlEventListener*>(data);
- SysTryReturnResult(NID_APP, typeid(pListener) == typeid(IAppControlEventListener*), E_SYSTEM, "Invalid result callback");
-
- bundle* inb = pArg->GetBundle();
- SysTryReturnResult(NID_APP, inb != NULL, E_SYSTEM, "Empty caller bundle.");
-
- String oId;
-
- AppId provider = pResArg->GetCalleeAppId();
-
- const char* p = appsvc_get_operation(inb);
- if (p)
- {
- oId = p;
}
- SysLog(NID_APP, "Invoking callback with (%ls, %ls)", provider.GetPointer(), oId.GetPointer());
+ result r = InvokeStartAppControl(pProvider, req, L"", msg);
- if (prop & _APPCONTROL_PROPERTY_ALIAS)
+ if (pListener == null)
{
- const _AppControlRegistry::_AppControlAliasEntry* pEntry = null;
- pEntry = _AppControlRegistry::GetInstance()->GetReverseAppControlAliasEntry(provider, oId);
- if (pEntry)
- {
- provider = pEntry->provider;
- oId = pEntry->operation;
-
- SysLog(NID_APP, "Legacy AppControl name (%ls, %ls).", provider.GetPointer(), oId.GetPointer());
- }
+ pProvider->Release();
}
- if (prop & _APPCONTROL_PROPERTY_APPID_CHANGE)
+ // after acquring request number, pLib should be managed from the list, not CATCH
+ if (IsFailed(r))
{
- String tmp = _AppControlRegistry::GetInstance()->GetReverseAliasAppId(provider);
- if (!tmp.IsEmpty())
- {
- SysLog(NID_APP, "AppId change (%ls -> %ls).", provider.GetPointer(), tmp.GetPointer());
+ _AppControlManager::GetInstance()->__inAppManager.RemoveItem(req);
+ SysLog(NID_APP, "[%s] A system error has occurred.", GetErrorMessage(r));
- provider = tmp;
- }
+ return r;
}
- std::unique_ptr<HashMap> pMap(pResArg->GetArgMapN());
-
- ArrayList list(SingleObjectDeleter);
- _AppArg::FillLegacyAppControlResult(list, res, pMap.get(), provider);
-
- // proper callback invokation
- pListener->OnAppControlCompleted(provider, oId, &list);
-
+ SysLog(NID_APP, "Exit %d", req);
return E_SUCCESS;
}
+
result
-_AppControlImpl::AppControlCb(void* data, _AppArg* pArg, _AppArg* pResArg, service_result_e res, int prop, int reqId)
+_AppControlImpl::StartImplicit(bundle* pBundle, const IList* pDataList, IAppControlEventListener* pListener)
{
- SysLog(NID_APP, "Result value : %d, property : 0x%x", res, prop);
-
- SysTryReturnResult(NID_APP, data && pResArg && pArg, E_SYSTEM, "Invalid result (callback, result, arg) = (0x%x, 0x%x, 0x%x).",
- data, pResArg,
- pArg);
-
- bundle* b = pResArg->GetBundle();
- SysTryReturnResult(NID_APP, b != NULL, E_SYSTEM, "Invalid result bundle.");
-
- IAppControlResponseListener* pListener = static_cast<IAppControlResponseListener*>(data);
- SysTryReturnResult(NID_APP, typeid(pListener) == typeid(IAppControlResponseListener*), E_SYSTEM, "Invalid result callback");
-
- bundle* inb = pArg->GetBundle();
- SysTryReturnResult(NID_APP, inb != NULL, E_SYSTEM, "Empty caller bundle.");
-
- String oId;
-
- AppId provider = pResArg->GetCalleeAppId();
-
- const char* p = appsvc_get_operation(inb);
- if (p)
- {
- oId = p;
- }
-
- SysLog(NID_APP, "Invoking callback with (%ls, %ls)", provider.GetPointer(), oId.GetPointer());
-
- if (prop & _APPCONTROL_PROPERTY_ALIAS)
- {
- SysLog(NID_APP, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
- const _AppControlRegistry::_AppControlAliasEntry* pEntry = null;
- pEntry = _AppControlRegistry::GetInstance()->GetReverseRuntimeAliasEntry(provider, oId);
- if (pEntry)
- {
- provider = pEntry->provider;
- oId = pEntry->operation;
-
- SysLog(NID_APP, "Original AppControl name (%ls, %ls).", provider.GetPointer(), oId.GetPointer());
- }
- SysLog(NID_APP, "CCCCCCCCCCCCCCCCCCCCCCCCCCCCC 0x%x", pEntry);
- }
-
- if (prop & _APPCONTROL_PROPERTY_APPID_CHANGE)
- {
- String tmp = _AppControlRegistry::GetInstance()->GetReverseAliasAppId(provider);
- if (!tmp.IsEmpty())
- {
- SysLog(NID_APP, "AppId change (%ls -> %ls).", provider.GetPointer(), tmp.GetPointer());
+ _AppMessageImpl msg(pBundle);
+ msg.AddData(pDataList);
- provider = tmp;
- }
- }
-
- std::unique_ptr<HashMap> pMap(pResArg->GetArgMapN());
-
- AppCtrlResult ret = APP_CTRL_RESULT_FAILED;
- // to prevent enum overflow;
- int resCode = res;
- switch(resCode)
- {
- case SERVICE_RESULT_SUCCEEDED:
- ret = APP_CTRL_RESULT_SUCCEEDED;
- break;
- case SERVICE_RESULT_FAILED:
- ret = APP_CTRL_RESULT_CANCELED;
- break;
- case SERVICE_RESULT_CANCELED:
- ret = APP_CTRL_RESULT_ABORTED;
- break;
- case APPSVC_OSP_RES_FAIL:
- ret = APP_CTRL_RESULT_FAILED;
- break;
- case APPSVC_OSP_RES_TERMINATE:
- ret = APP_CTRL_RESULT_TERMINATED;
- break;
- default:
- ret = APP_CTRL_RESULT_FAILED;
- break;
- }
-
- SysLog(NID_APP, "Result code : 0x%x.", ret);
+ return StartImplicit(msg, pListener, true);
+}
- // proper callback invokation
- _AppControlResponseEvent* pResponseEvent = null;
- _AppControlManager::GetInstance()->GetAppControlResponseEventContainer()->GetValue(reqId, pResponseEvent);
- if (pResponseEvent != null)
- {
- _AppControlResponseEventArg* pResponseEventArg = new (std::nothrow) _AppControlResponseEventArg(pListener, _APPCONTROL_RESPONSETYPE_COMPLETE, provider, oId, E_SUCCESS, ret, pMap.get(), reqId);
- pResponseEvent->Fire(*pResponseEventArg);
- SysLog(NID_APP, "OnAppControlCompleteResponseReceived, pResponseEvent is Fired");
- }
- else
- {
- pListener->OnAppControlCompleteResponseReceived(provider, oId, ret, pMap.get());
- SysLog(NID_APP, "OnAppControlCompleteResponseReceived, Called");
- }
+result
+_AppControlImpl::StartImplicit(bundle* pBundle, const IMap* pData, IAppControlResponseListener* pListener)
+{
+ _AppMessageImpl msg(pBundle);
+ _AppArg::AddStrMap(msg.GetBundle(), pData);
- return E_SUCCESS;
+ return StartImplicit(msg, pListener, false);
}
+
result
-_AppControlImpl::StartNative(const IList* pDataList, IAppControlEventListener* pListener)
+_AppControlImpl::Start(const IList* pDataList, IAppControlEventListener* pListener)
{
SysLog(NID_APP, "Enter");
_InProcessInfo* pInfo = _AppControlManager::GetInstance()->__inAppManager.FindItem(_reqId);
SysTryReturnResult(NID_APP, pInfo == null, E_IN_PROGRESS, "Request ID %d is already in progress.", _reqId);
- int req = _REQ_ID_INVALID;
- _LibraryImpl* pLib = null;
+ int req = APPCONTROL_REQUEST_ID_INVALID;
- pLib = new (std::nothrow) _LibraryImpl;
- SysTryReturnResult(NID_APP, pLib != null, E_OUT_OF_MEMORY, "Failed to allocate libraryimpl.");
-
- unsigned long option = _LIBRARY_LOAD_OPTION_LAZY;
- option |= _LIBRARY_LOAD_OPTION_NODELETE;
-
- result r = pLib->Construct(_path, option);
- SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
+ _IAppControlPluginProvider* pProvider = GetAppControlPluginProvider(_path);
+ if (pProvider == null)
+ {
+ SysPropagate(NID_APP, E_OBJ_NOT_FOUND);
+ return E_OBJ_NOT_FOUND;
+ }
if (pListener)
{
- _InProcessInfo* pItem = new (std::nothrow) _InProcessInfo(_provider, _opId, _property, true, *pLib, pListener);
+ _InProcessInfo* pItem = new (std::nothrow) _InProcessInfo(_appId, _opId, _property, true, pProvider, pListener);
if (pItem)
{
req = _AppControlManager::GetInstance()->__inAppManager.InsertItem(pItem);
}
}
- r = InvokeStartAppControl(*pLib, req, _provider, _opId, pDataList);
+
+ result r = InvokeStartAppControl(pProvider, req, _appId, _opId, pDataList);
if (pListener == null)
{
- delete pLib;
+ pProvider->Release();
}
- // after acquring request number, pLib should be managed from the list, not CATCH
if (IsFailed(r))
{
- SetLastResult(E_SYSTEM);
_AppControlManager::GetInstance()->__inAppManager.RemoveItem(req);
- SysLog(NID_APP, "[E_SYSTEM] A system error has occurred with %s.", GetErrorMessage(r));
+ SysLog(NID_APP, "[%s] A system error has occurred.", GetErrorMessage(r));
- return E_SYSTEM;
+ return r;
}
_reqId = req;
- SysLog(NID_APP, "Exit");
+ SysLog(NID_APP, "Exit %d", req);
return E_SUCCESS;
-
-CATCH:
- delete pLib;
-
- switch (r)
- {
- case E_LIBRARY_NOT_FOUND:
- r = E_OBJ_NOT_FOUND;
- break;
- default:
- r = E_SYSTEM;
- break;
- }
-
- return r;
}
result
-_AppControlImpl::StartNative(const String* pUriData, const String* pMimeType, const IMap* pDataList, IAppControlResponseListener* pListener)
+_AppControlImpl::Start(const String* pUriData, const String* pMimeType, const IMap* pDataList, IAppControlResponseListener* pListener)
{
SysLog(NID_APP, "Enter");
_InProcessInfo* pInfo = _AppControlManager::GetInstance()->__inAppManager.FindItem(_reqId);
SysTryReturnResult(NID_APP, pInfo == null, E_IN_PROGRESS, "Request ID %d is already in progress.", _reqId);
- int req = _REQ_ID_INVALID;
- _LibraryImpl* pLib = null;
-
- pLib = new (std::nothrow) _LibraryImpl;
- SysTryReturnResult(NID_APP, pLib != null, E_OUT_OF_MEMORY, "Failed to allocate libraryimpl.");
-
- unsigned long option = _LIBRARY_LOAD_OPTION_LAZY;
- option |= _LIBRARY_LOAD_OPTION_NODELETE;
-
- result r = pLib->Construct(_path, option);
+ int req = APPCONTROL_REQUEST_ID_INVALID;
+ result r = E_SUCCESS;
- SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
+ _IAppControlPluginProvider* pProvider = GetAppControlPluginProvider(_path);
+ if (pProvider == null)
+ {
+ SysPropagate(NID_APP, E_OBJ_NOT_FOUND);
+ return E_OBJ_NOT_FOUND;
+ }
if (pListener)
{
- _InProcessInfo* pItem = new (std::nothrow) _InProcessInfo(_provider, _opId, _property, false, *pLib, pListener);
+ _InProcessInfo* pItem = new (std::nothrow) _InProcessInfo(_appId, _opId, _property, false, pProvider, pListener);
if (pItem)
{
req = _AppControlManager::GetInstance()->__inAppManager.InsertItem(pItem);
}
- if (_ThreadImpl::GetCurrentThreadImpl()->GetThreadType() == THREAD_TYPE_EVENT_DRIVEN)
+ const _ThreadImpl* pThreadImpl = _ThreadImpl::GetCurrentThreadImpl();
+ if (pThreadImpl && pThreadImpl->GetThreadType() == THREAD_TYPE_EVENT_DRIVEN)
{
_AppControlResponseEvent* pAppControlResponseEvent = new (std::nothrow) _AppControlResponseEvent();
}
}
}
- r = InvokeStartAppControl(*pLib, req, _provider, _opId, pUriData, pMimeType, pDataList);
+ r = InvokeStartAppControl(pProvider, req, _appId, _opId, pUriData, pMimeType, pDataList);
if (pListener == null)
{
- delete pLib;
+ pProvider->Release();
}
- // after acquring request number, pLib should be managed from the list, not CATCH
if (IsFailed(r))
{
- SetLastResult(E_SYSTEM);
_AppControlManager::GetInstance()->__inAppManager.RemoveItem(req);
- SysLog(NID_APP, "[E_SYSTEM] A system error has occurred with %s.", GetErrorMessage(r));
+ SysLog(NID_APP, "[%s] A system error has occurred.", GetErrorMessage(r));
- return E_SYSTEM;
+ return r;
}
_reqId = req;
- SysLog(NID_APP, "Exit");
+ SysLog(NID_APP, "Exit %d", req);
return E_SUCCESS;
-
-CATCH:
- delete pLib;
-
- switch (r)
- {
- case E_LIBRARY_NOT_FOUND:
- r = E_OBJ_NOT_FOUND;
- break;
- default:
- r = E_SYSTEM;
- break;
- }
-
- return r;
}
result
-_AppControlImpl::InvokeStartAppControl(_LibraryImpl& lib, int req, const String& appId, const String& oId, const IList* pList)
+_AppControlImpl::InvokeStartAppControl(_IAppControlPluginProvider* pProvider, int req, const String& appId, const String& oId, const IList* pList)
{
SysLog(NID_APP, "Legacy stuff for converting argument");
pMap = ↦
}
- return InvokeStartAppControl(lib, req, appId, oId, null, null, pMap);
+ return InvokeStartAppControl(pProvider, req, appId, oId, null, null, pMap);
}
result
-_AppControlImpl::InvokeStartAppControl(_LibraryImpl& lib, int req, const String& appId, const String& oId, const String* pUri, const String* pMime, const IMap* pMap)
+_AppControlImpl::InvokeStartAppControl(_IAppControlPluginProvider* pProvider, int req, const String& appId, const String& oId, const String* pUri, const String* pMime, const IMap* pMap)
{
- result (*pFunc)(int req, const String&, const String&, const String*, const String*, const IMap*) = null;
+ String data;
- pFunc =
- reinterpret_cast<result (*)(int, const String&, const String&, const String*, const String*, const IMap*)>(lib.GetProcAddress(L"StartAppControl"));
- SysTryReturnResult(NID_APP, pFunc != null, E_OBJ_NOT_FOUND, "Entry \"StartAppControl\" not found for %ls", appId.GetPointer());
+ if (pMime)
+ {
+ data = _AppControlManager::GetMimeTypeFromDataType(*pMime);
+ }
+
+ _AppMessageImpl msg(appId, oId, pUri, &data, pMap);
- const String* pActualUri = (pUri && !(pUri->IsEmpty())) ? pUri : null;
- const String* pActualMime = (pMime && !(pMime->IsEmpty())) ? pMime : null;
- return (*pFunc)(req, appId, oId, pActualUri, pActualMime, pMap);
+ return InvokeStartAppControl(pProvider, req, appId, msg);
}
-static bool
-IsValidAppControl(const String& appcontrolID)
+
+result
+_AppControlImpl::InvokeStartAppControl(_IAppControlPluginProvider* pProvider, int req, const String& appId, const _AppMessageImpl& message)
{
- return ((appcontrolID == L"osp.appcontrol.provider.audio")
- || (appcontrolID == L"osp.appcontrol.provider.bluetooth")
- || (appcontrolID == L"osp.appcontrol.provider.calendar")
- || (appcontrolID == L"osp.appcontrol.provider.camera")
- || (appcontrolID == L"osp.appcontrol.provider.contact")
- || (appcontrolID == L"osp.appcontrol.provider.certificatemanager")
- || (appcontrolID == L"osp.appcontrol.provider.email")
- || (appcontrolID == L"osp.appcontrol.provider.image")
- || (appcontrolID == L"osp.appcontrol.provider.media")
- || (appcontrolID == L"osp.appcontrol.provider.message")
- || (appcontrolID == L"osp.appcontrol.provider.video")
- || (appcontrolID == L"osp.appcontrol.provider.imageeditor")
- || (appcontrolID == L"osp.appcontrol.provider.allshare")
- || (appcontrolID == L"tizen.filemanager")
- || (appcontrolID == L"tizen.camera")
- || (appcontrolID == L"tizen.gallery")
- || (appcontrolID == L"tizen.imageviewer")
- || (appcontrolID == L"tizen.videoplayer")
- || (appcontrolID == L"tizen.memo")
- || (appcontrolID == L"tizen.contacts")
- || (appcontrolID == L"tizen.calendar")
- || (appcontrolID == L"tizen.events")
- || (appcontrolID == L"tizen.email")
- || (appcontrolID == L"tizen.settings")
- || (appcontrolID == L"tizen.messages")
- || (appcontrolID == L"tizen.musicplayer")
- || (appcontrolID == L"tizen.bluetooth")
- || (appcontrolID == L"samsung.snote")
- || (appcontrolID == L"0pnxz8hbsr.MyFiles")
- || (appcontrolID == L"hdufar9ycj.Camera")
- || (appcontrolID == L"ijudt7w61q.Gallery")
- || (appcontrolID == L"jysyv9o1dc.ImageViewer")
- || (appcontrolID == L"npwf0scb88.VideoPlayer")
- || (appcontrolID == L"zunqjlsnce.Memo")
- || (appcontrolID == L"f9uev8hsyo.Contacts")
- || (appcontrolID == L"ph1vq2phrp.Calendar")
- || (appcontrolID == L"vxqbrefica.Email")
- || (appcontrolID == L"kto5jikgul.Settings")
- || (appcontrolID == L"8r4r5ddzzn.Messages")
- || (appcontrolID == L"dhrul6qzj3.MusicPlayer")
- || (appcontrolID == L"smemo-efl"));
+ SysTryReturnResult(NID_APP, pProvider != null, E_SYSTEM, "Wrong AppControl provider plugin for %ls(%d).", appId.GetPointer(), req);
+
+ return pProvider->StartAppControlPlugin(req, appId, message, null);
}
+
result
_AppControlImpl::Stop(void)
{
- const String appcontrolID(GetAppControlProviderId());
- SysTryReturnResult(NID_APP, IsValidAppControl(appcontrolID), E_INVALID_OPERATION, "Invalid appcontrolID(%ls)", appcontrolID.GetPointer());
-
- if (_property & _APPCONTROL_PROPERTY_SLP)
- {
- SysTryReturnResult(NID_APP, _reqId != _REQ_ID_INVALID, E_INVALID_OPERATION, "Invalid request ID .");
+ result r = E_SUCCESS;
+ result (*pStop)(int req) = null;
+ if (_reqId != APPCONTROL_REQUEST_ID_INVALID)
+ {
_InProcessInfo* pInfo = _AppControlManager::GetInstance()->__inAppManager.FindItem(_reqId);
SysTryReturnResult(NID_APP, pInfo != null, E_INVALID_OPERATION, "Request ID %d is not found.", _reqId);
-
- result (*pStop)(int req) = null;
- pStop = reinterpret_cast<result (*)(int)>(pInfo->pLib->GetProcAddress(L"TerminateAppControl"));
- SysTryReturnResult(NID_APP, pStop != null, E_SYSTEM, "No TerminateAppControl() function.");
-
- (*pStop)(_reqId);
-
+
+ if (pInfo->pProvider)
+ {
+ r = pInfo->pProvider->StopAppControlPlugin(_reqId);
+ }
+
_AppControlManager::GetInstance()->__inAppManager.RemoveItem(_reqId);
-
- _reqId = _REQ_ID_INVALID;
+
+ _reqId = APPCONTROL_REQUEST_ID_INVALID;
}
- else if (_property & _APPCONTROL_PROPERTY_OSP)
+ else
{
- _Aul::TerminateApplicationByPid(_processId);
+ _IAppControlPluginProvider* pProvider = GetAppControlPluginProvider(_path);
+ if (pProvider)
+ {
+ r = pProvider->StopAppControlPlugin(-1);
+
+ pProvider->Release();
+ }
}
- return E_SUCCESS;
+ SysLog(NID_APP, "[%s] Request is stopped.", GetErrorMessage(r));
+
+ return r;
}
String
-_AppControlImpl::GetAppName(void)
+_AppControlImpl::GetAppName(void) const
{
- if ((_property & _APPCONTROL_PROPERTY_OSP) && _appName.IsEmpty())
+ if (_appName.IsEmpty())
{
- const AppId& appId = _path;
+ AppId appId = GetAppId();
+ const AppId& aliasAppId = _AppControlRegistry::GetInstance()->GetAliasAppId(appId);
+ if (!aliasAppId.IsEmpty())
+ {
+ appId = aliasAppId;
+ }
- std::unique_ptr<PackageAppInfo> pInfo(_PackageManagerImpl::GetInstance()->GetPackageAppInfoN(appId));
+ appId = _Aul::GetRealAppId(appId);
+ std::unique_ptr<PackageAppInfo> pInfo(_PackageManagerImpl::GetInstance()->GetPackageAppInfoN(appId));
if (pInfo.get())
{
- const String& name = pInfo->GetAppName();
- if (name == L"_AppControl")
- {
- // workaround for special case: requery with actual appId
- const PackageId& packageId = _PackageManagerImpl::GetPackageIdByAppId(appId);
- const String& defaultName = _PackageManagerImpl::GetInstance()->GetDefaultAppExecutableName(packageId);
-
- const String& convertedAppId = packageId + L'.' + defaultName;
-
- std::unique_ptr<PackageAppInfo> pNewInfo(_PackageManagerImpl::GetInstance()->GetPackageAppInfoN(convertedAppId));
-
- if (pNewInfo.get())
- {
- _appName = pNewInfo->GetAppDisplayName();
- }
- else
- {
- SysLog(NID_APP, "No default applicaiton information, possible database error.");
- }
- }
- else
- {
- _appName = pInfo->GetAppDisplayName();
- }
- SysLog(NID_APP, "Initializing AppName(%ls) for %ls.", _appName.GetPointer(), appId.GetPointer());
+ SysLog(NID_APP, "PackageInfo of [%ls] exists.", appId.GetPointer());
+ _appName = pInfo->GetAppDisplayName();
+ }
+ else
+ {
+ SysLog(NID_APP, "PackageInfo of [%ls] does not exist.", appId.GetPointer());
}
}
return _appName;
}
-String
-_AppControlImpl::GetAppId(void) const
-{
- return (_property & _APPCONTROL_PROPERTY_OSP) ? _path : _provider;
-}
-
-const String&
-_AppControlImpl::GetAppControlProviderId(void) const
-{
- return _provider;
-}
-
-const String&
-_AppControlImpl::GetOperationId(void) const
-{
- return _opId;
-}
IList*
_AppControlImpl::GetCategoryListN(void) const
{
- const AppId& appId = GetAppId();
+ AppId appId = GetAppId();
SysTryReturn(NID_APP, !appId.IsEmpty(), null, E_SYSTEM, "[E_SYSTEM] Empty appId.");
- SysLog(NID_APP, "Acquiring category for appId %ls.", appId.GetPointer());
+ const AppId& aliasAppId = _AppControlRegistry::GetInstance()->GetAliasAppId(appId);
+ if (!aliasAppId.IsEmpty())
+ {
+ appId = aliasAppId;
+ }
+
+ SysLog(NID_APP, "Acquiring category for app %ls.", appId.GetPointer());
std::unique_ptr<PackageAppInfo> pAppInfo(_PackageManagerImpl::GetInstance()->GetPackageAppInfoN(appId));
SysTryReturn(NID_APP, pAppInfo.get() != null, null, E_SYSTEM, "[E_SYSTEM] Getting PackageAppInfo failed.");
void
_AppControlImpl::StopAppControlResponseListener(IAppControlResponseListener* pListener)
{
- _AppControlManager::GetInstance()->__listenerList.Add(pListener);
+ _AppControlManager::GetInstance()->StopAppControlResponseListener(pListener);
}
void
{
if(pEventArg->GetType() == _APPCONTROL_RESPONSETYPE_COMPLETE)
{
- pResponseListener->OnAppControlCompleteResponseReceived(pEventArg->GetAppId(), pEventArg->GetOperationId(), pEventArg->GetAppControlResult(), pEventArg->GetExtraData());
- SysLog(NID_APP, "OnAppControlCompleteResponseReceived called");
+ _AppControlManager::InvokeAppControlCompleteListener(*pResponseListener, pEventArg->GetAppId(), pEventArg->GetOperationId(), pEventArg->GetAppControlResult(), pEventArg->GetExtraData(), pEventArg->IsRaiseMode());
_AppControlResponseEvent* pResponseEvent = null;
_AppControlManager::GetInstance()->GetAppControlResponseEventContainer()->GetValue(pEventArg->GetRequestId(), pResponseEvent);