2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FApp_AppControlImpl.cpp
20 * @brief This is the implementation for the Application Control class.
25 #include <unique_ptr.h>
27 #include <appsvc/appsvc.h>
29 #include <FAppAppControl.h>
30 #include <FAppAppManager.h>
31 #include <FAppPkgPackageAppInfo.h>
32 #include <FAppIAppControlEventListener.h>
33 #include <FAppIAppControlResponseListener.h>
34 #include <FBaseColHashMap.h>
35 #include <FBaseSysLog.h>
37 #include <FBaseRt_LibraryImpl.h>
38 #include <FIo_DirectoryImpl.h>
40 #include "FApp_AppControlImpl.h"
41 #include "FApp_AppControlManager.h"
42 #include "FApp_AppArg.h"
43 #include "FApp_AppImpl.h"
44 #include "FApp_AppControlRegistry.h"
45 #include "FApp_AppMessageImpl.h"
46 #include "FApp_AppInfo.h"
47 #include "FAppPkg_PackageManagerImpl.h"
50 using namespace Tizen::Base;
51 using namespace Tizen::Base::Collection;
52 using namespace Tizen::Base::Runtime;
53 using namespace Tizen::App;
54 using namespace Tizen::App::Package;
55 using namespace Tizen::Io;
60 static const int _REQ_ID_INVALID = -1;
64 namespace Tizen { namespace App
67 const wchar_t TIZEN_OPERATION_MAIN[] = L"http://tizen.org/appcontrol/operation/main";
68 const char TIZEN_APPCONTROL_DATA_LEGACY[] = "http://tizen.org/appcontrol/data/legacyresult";
70 _AppControlImpl::_AppControlImpl(const AppControl& value)
72 , _reqId(_REQ_ID_INVALID)
73 , _property(_APPCONTROL_PROPERTY_NONE)
74 , _processId(_REQ_ID_INVALID)
78 _AppControlImpl::~_AppControlImpl(void)
83 _AppControlImpl::CreateN(const String& path, const String& aId, const String& oId, const String& name, int prop)
85 SysTryReturn(NID_APP, !path.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] Path is empty.");
86 SysTryReturn(NID_APP, !aId.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] Provider Id is empty.");
87 SysTryReturn(NID_APP, !oId.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] Operation Id is empty.");
89 AppControl* pAc = new (std::nothrow) AppControl;
90 SysTryReturn(NID_APP, pAc != null, null, E_OUT_OF_MEMORY, "AppControl allocation failure.");
92 _AppControlImpl* pImpl = pAc->__pAppControlImpl;
93 SysTryReturn(NID_APP, pImpl != null, null, E_OUT_OF_MEMORY, "AppControlImpl instance must not be null.");
96 pImpl->_provider = aId;
98 // [FIXME] Proper App name setting
99 pImpl->_appName = name;
100 pImpl->_property = prop;
106 _AppControlImpl::CreateN(const AppId& appId, const String& operationId, bool changeAppId)
108 SysTryReturn(NID_APP, !appId.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] appId is empty.");
110 AppControl* pAc = new (std::nothrow) AppControl;
111 SysTryReturn(NID_APP, pAc != null, null, E_OUT_OF_MEMORY, "AppControl allocation failure.");
113 _AppControlImpl* pImpl = pAc->__pAppControlImpl;
114 SysTryReturn(NID_APP, pImpl != null, null, E_OUT_OF_MEMORY, "AppControlImpl instance must not be null.");
116 pImpl->_path = appId;
117 pImpl->_provider = appId;
118 pImpl->_opId = operationId;
119 //pImpl->_appName = appId;
120 pImpl->_property |= (_APPCONTROL_PROPERTY_OSP | _APPCONTROL_PROPERTY_PUBLIC);
124 pImpl->_property |= _APPCONTROL_PROPERTY_APPID_CHANGE;
131 _AppControlImpl::CreateN(const AppControl& ac)
133 const _AppControlImpl* pImpl = GetInstance(ac);
134 SysTryReturn(NID_APP, pImpl != null, null, E_INVALID_STATE, "AppControlImpl instance must not be null.");
136 return CreateN(pImpl->_path, pImpl->_provider, pImpl->_opId, pImpl->_appName, pImpl->_property);
139 const _AppControlImpl*
140 _AppControlImpl::GetInstance(const AppControl& ac)
142 return ac.__pAppControlImpl;
146 _AppControlImpl::GetInstance(AppControl& ac)
148 return ac.__pAppControlImpl;
152 _AppControlImpl::Start(const IList* pDataList, IAppControlEventListener* pListener)
156 if (_property & _APPCONTROL_PROPERTY_SLP)
158 r = StartNative(pDataList, pListener);
160 else if (_property & _APPCONTROL_PROPERTY_OSP)
162 r = StartOsp(pDataList, pListener);
166 SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] Invalid AppControl type(property %d)", _property);
173 _AppControlImpl::Start(const String* pUriData, const String* pDataType, const IMap* pExtraData, IAppControlResponseListener* pListener)
177 if (_property & _APPCONTROL_PROPERTY_SLP)
179 r = StartNative(pUriData, pDataType, pExtraData, pListener);
181 else if (_property & _APPCONTROL_PROPERTY_OSP)
183 r = StartOsp(pUriData, pDataType, pExtraData, pListener);
187 SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] Invalid AppControl type(property %d)", _property);
194 _AppControlImpl::FindAndStart(const String& operationId, const String* pUriPattern, const String* pDataType, const String* pCategory, const IMap* pExtraData, IAppControlResponseListener* pListener)
196 // [FIXME] valid argument size checking required
198 std::unique_ptr<bundle, BundleDeleter> pBundle(bundle_create());
199 SysTryReturnResult(NID_APP, pBundle.get(), E_OUT_OF_MEMORY, "Bundle creation failure.");
201 _AppMessageImpl::SetOperation(pBundle.get(), operationId);
205 _AppMessageImpl::SetUri(pBundle.get(), *pUriPattern);
210 String mimeType = *pDataType;
212 if ((*pDataType)[0] == L'.')
214 SysLog(NID_APP, "Extension to MIME conversion for %ls", pDataType->GetPointer());
218 pDataType->SubString(1, ext);
220 result r = _AppControlManager::GetMimeFromExt(ext, mimeType);
222 SysTryReturn(NID_APP, !IsFailed(r), null, r, "[%s] MIME type conversion failure for %ls.", GetErrorMessage(r), ext.GetPointer());
224 pMimeType = &mimeType;
226 SysLog(NID_APP, "Conversion : %ls -> %ls.", pDataType->GetPointer(), pMimeType->GetPointer());
230 _AppMessageImpl::SetMime(pBundle.get(), mimeType);
235 _AppMessageImpl::SetCategory(pBundle.get(), *pCategory);
238 return StartImplicit(pBundle.get(), pExtraData, pListener);
242 _AppControlImpl::StartOsp(const IList* pDataList, IAppControlEventListener* pListener)
244 result r = E_SUCCESS;
246 _AppArg* pArg = new (std::nothrow) _AppArg;
247 SysTryReturnResult(NID_APP, pArg != null, E_OUT_OF_MEMORY, "Argument allocation failure.");
249 pArg->Construct(*this, pDataList);
251 _AppControlManager* pImpl = _AppControlManager::GetInstance();
252 int req = _REQ_ID_INVALID;
256 _AppControlManager::_RequestGuard reqObj = _AppControlManager::_RequestGuard(*pImpl, pArg, AppControlCbLegacy, pListener, _property);
257 req = reqObj.GetRequestNumber();
259 _processId = pImpl->Launch(_path, pArg, req);
265 SysLog(NID_APP, "[%s]Launching(%ls) is failed" , GetErrorMessage(r), _path.GetPointer());
271 _processId = pImpl->Launch(_path, pArg);
273 SysTryReturnResult(NID_APP, _processId >= 0, GetLastResult(), "Launching(%ls) is failed", _path.GetPointer());
280 _AppControlImpl::StartOsp(const String* pUriData, const String* pMimeType, const IMap* pDataList, IAppControlResponseListener* pListener)
282 result r = E_SUCCESS;
284 _AppArg* pArg = new (std::nothrow) _AppArg;
285 SysTryReturnResult(NID_APP, pArg != null, E_OUT_OF_MEMORY, "Argument allocation failure.");
287 pArg->Construct(*this, pUriData, pMimeType, pDataList);
289 _AppControlManager* pImpl = _AppControlManager::GetInstance();
290 int req = _REQ_ID_INVALID;
294 _AppControlManager::_RequestGuard reqObj = _AppControlManager::_RequestGuard(*pImpl, pArg, AppControlCb, pListener, _property);
295 req = reqObj.GetRequestNumber();
297 _processId = pImpl->Launch(_path, pArg, req);
302 SysLog(NID_APP, "[%s]Launching(%ls) is failed" , GetErrorMessage(r), _path.GetPointer());
308 _processId = pImpl->Launch(_path, pArg);
310 SysTryReturnResult(NID_APP, _processId >= 0, GetLastResult(), "Launching(%ls) is failed", _path.GetPointer());
317 _AppControlImpl::StartImplicit(bundle* pBundle, const IList* pDataList, IAppControlEventListener* pListener)
319 result r = E_SUCCESS;
321 _AppArg* pArg = new (std::nothrow) _AppArg;
322 SysTryReturnResult(NID_APP, pArg != null, E_OUT_OF_MEMORY, "Argument allocation failure.");
324 pArg->Construct(pBundle);
326 _AppMessageImpl::AddData(pArg->GetBundle(), pDataList);
328 _AppControlManager* pImpl = _AppControlManager::GetInstance();
329 int req = _REQ_ID_INVALID;
333 _AppControlManager::_RequestGuard reqObj = _AppControlManager::_RequestGuard(*pImpl, pArg, AppControlCbLegacy, pListener, _APPCONTROL_PROPERTY_NONE);
334 req = reqObj.GetRequestNumber();
336 r = pImpl->LaunchAppImplicit(pArg, req);
337 SysTryCatch(NID_APP, r == E_SUCCESS, reqObj.Invalidate(), r, "[%s] Propagating." , GetErrorMessage(r));
341 r = pImpl->LaunchAppImplicit(pArg, -1);
345 // [FIXME] launch registration is not working correctly
352 _AppControlImpl::StartImplicit(bundle* pBundle, const IMap* pData, IAppControlResponseListener* pListener)
354 result r = E_SUCCESS;
356 _AppArg* pArg = new (std::nothrow) _AppArg;
357 SysTryReturnResult(NID_APP, pArg != null, E_OUT_OF_MEMORY, "Argument allocation failure.");
359 pArg->Construct(pBundle);
361 _AppArg::AddStrMap(pArg->GetBundle(), pData);
363 _AppControlManager* pImpl = _AppControlManager::GetInstance();
364 int req = _REQ_ID_INVALID;
368 _AppControlManager::_RequestGuard reqObj = _AppControlManager::_RequestGuard(*pImpl, pArg, AppControlCb, pListener, _APPCONTROL_PROPERTY_NONE);
369 req = reqObj.GetRequestNumber();
371 r = pImpl->LaunchAppImplicit(pArg, req);
372 SysTryCatch(NID_APP, r == E_SUCCESS, reqObj.Invalidate(), r, "[%s] Propagating." , GetErrorMessage(r));
376 r = pImpl->LaunchAppImplicit(pArg, -1);
380 // [FIXME] launch registration is not working correctly
388 _AppControlImpl::AppControlCbLegacy(void* data, _AppArg* pArg, _AppArg* pResArg, service_result_e res, int prop)
390 SysLog(NID_APP, "Result value %d", res);
392 SysTryReturnResult(NID_APP, data && pResArg && pArg, E_SYSTEM, "Invalid result (callback, result, arg) = (0x%x, 0x%x, 0x%x).",
396 bundle* b = pResArg->GetBundle();
397 SysTryReturnResult(NID_APP, b != NULL, E_SYSTEM, "Invalid result bundle.");
399 IAppControlEventListener* pListener = static_cast<IAppControlEventListener*>(data);
400 SysTryReturnResult(NID_APP, typeid(pListener) == typeid(IAppControlEventListener*), E_SYSTEM, "Invalid result callback");
402 bundle* inb = pArg->GetBundle();
403 SysTryReturnResult(NID_APP, inb != NULL, E_SYSTEM, "Empty caller bundle.");
407 AppId provider = pResArg->GetCalleeAppId();
409 const char* p = appsvc_get_operation(inb);
415 SysLog(NID_APP, "Invoking callback with (%ls, %ls)", provider.GetPointer(), oId.GetPointer());
417 if (prop & _APPCONTROL_PROPERTY_ALIAS)
419 _AppControlRegistry::_AppControlAliasEntry* pEntry = null;
420 pEntry = _AppControlRegistry::GetInstance()->GetReverseAppControlAliasEntry(provider, oId);
423 provider = pEntry->provider;
424 oId = pEntry->operation;
426 SysLog(NID_APP, "Legacy AppControl name (%ls, %ls).", provider.GetPointer(), oId.GetPointer());
430 if (prop & _APPCONTROL_PROPERTY_APPID_CHANGE)
432 String tmp = _AppControlRegistry::GetInstance()->GetReverseAliasAppId(provider);
435 SysLog(NID_APP, "AppId change (%ls -> %ls).", provider.GetPointer(), tmp.GetPointer());
441 std::unique_ptr<HashMap> pMap(pResArg->GetArgMapN());
443 ArrayList list(SingleObjectDeleter);
444 _AppArg::FillLegacyAppControlResult(list, res, pMap.get(), provider);
446 // proper callback invokation
447 pListener->OnAppControlCompleted(provider, oId, &list);
453 _AppControlImpl::AppControlCb(void* data, _AppArg* pArg, _AppArg* pResArg, service_result_e res, int prop)
455 SysLog(NID_APP, "Result value %d", res);
457 SysTryReturnResult(NID_APP, data && pResArg && pArg, E_SYSTEM, "Invalid result (callback, result, arg) = (0x%x, 0x%x, 0x%x).",
461 bundle* b = pResArg->GetBundle();
462 SysTryReturnResult(NID_APP, b != NULL, E_SYSTEM, "Invalid result bundle.");
464 IAppControlResponseListener* pListener = static_cast<IAppControlResponseListener*>(data);
465 SysTryReturnResult(NID_APP, typeid(pListener) == typeid(IAppControlResponseListener*), E_SYSTEM, "Invalid result callback");
467 bundle* inb = pArg->GetBundle();
468 SysTryReturnResult(NID_APP, inb != NULL, E_SYSTEM, "Empty caller bundle.");
472 AppId provider = pResArg->GetCalleeAppId();
474 const char* p = appsvc_get_operation(inb);
480 SysLog(NID_APP, "Invoking callback with (%ls, %ls)", provider.GetPointer(), oId.GetPointer());
482 if (prop & _APPCONTROL_PROPERTY_ALIAS)
484 _AppControlRegistry::_AppControlAliasEntry* pEntry = null;
485 pEntry = _AppControlRegistry::GetInstance()->GetReverseAppControlAliasEntry(provider, oId);
488 provider = pEntry->provider;
489 oId = pEntry->operation;
491 SysLog(NID_APP, "Legacy AppControl name (%ls, %ls).", provider.GetPointer(), oId.GetPointer());
495 if (prop & _APPCONTROL_PROPERTY_APPID_CHANGE)
497 String tmp = _AppControlRegistry::GetInstance()->GetReverseAliasAppId(provider);
500 SysLog(NID_APP, "AppId change (%ls -> %ls).", provider.GetPointer(), tmp.GetPointer());
506 std::unique_ptr<HashMap> pMap(pResArg->GetArgMapN());
508 AppCtrlResult ret = APP_CTRL_RESULT_FAILED;
509 // to prevent enum overflow;
513 case SERVICE_RESULT_SUCCEEDED:
514 ret = APP_CTRL_RESULT_SUCCEEDED;
516 case SERVICE_RESULT_FAILED:
517 ret = APP_CTRL_RESULT_CANCELED;
519 case SERVICE_RESULT_CANCELED:
520 ret = APP_CTRL_RESULT_ABORTED;
522 case APPSVC_OSP_RES_FAIL:
523 ret = APP_CTRL_RESULT_FAILED;
525 case APPSVC_OSP_RES_TERMINATE:
526 ret = APP_CTRL_RESULT_TERMINATED;
529 ret = APP_CTRL_RESULT_FAILED;
533 SysLog(NID_APP, "Result code : 0x%x.", ret);
535 // proper callback invokation
536 pListener->OnAppControlCompleteResponseReceived(provider, oId, ret, pMap.get());
542 _AppControlImpl::StartNative(const IList* pDataList, IAppControlEventListener* pListener)
544 _InProcessInfo* pInfo = _AppControlManager::GetInstance()->__inAppManager.FindItem(_reqId);
545 SysTryReturnResult(NID_APP, pInfo == null, E_IN_PROGRESS, "Request ID %d is already in progress.", _reqId);
547 int req = _REQ_ID_INVALID;
548 _LibraryImpl* pLib = null;
550 pLib = new (std::nothrow) _LibraryImpl;
551 SysTryReturnResult(NID_APP, pLib != null, E_OUT_OF_MEMORY, "Failed to allocate libraryimpl.");
553 unsigned long option = _LIBRARY_LOAD_OPTION_LAZY;
554 option |= _LIBRARY_LOAD_OPTION_NODELETE;
556 result r = pLib->Construct(_path, option);
557 SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
561 _InProcessInfo* pItem = new (std::nothrow) _InProcessInfo(_provider, _opId, _property, true, *pLib, pListener);
564 req = _AppControlManager::GetInstance()->__inAppManager.InsertItem(pItem);
567 r = InvokeStartAppControl(*pLib, req, _provider, _opId, pDataList);
569 if (pListener == null)
574 // after acquring request number, pLib should be managed from the list, not CATCH
577 SetLastResult(E_SYSTEM);
578 _AppControlManager::GetInstance()->__inAppManager.RemoveItem(req);
579 SysLog(NID_APP, "[E_SYSTEM] A system error has occurred with %s.", GetErrorMessage(r));
593 case E_LIBRARY_NOT_FOUND:
605 _AppControlImpl::StartNative(const String* pUriData, const String* pMimeType, const IMap* pDataList, IAppControlResponseListener* pListener)
607 _InProcessInfo* pInfo = _AppControlManager::GetInstance()->__inAppManager.FindItem(_reqId);
608 SysTryReturnResult(NID_APP, pInfo == null, E_IN_PROGRESS, "Request ID %d is already in progress.", _reqId);
610 int req = _REQ_ID_INVALID;
611 _LibraryImpl* pLib = null;
613 pLib = new (std::nothrow) _LibraryImpl;
614 SysTryReturnResult(NID_APP, pLib != null, E_OUT_OF_MEMORY, "Failed to allocate libraryimpl.");
616 unsigned long option = _LIBRARY_LOAD_OPTION_LAZY;
617 option |= _LIBRARY_LOAD_OPTION_NODELETE;
619 result r = pLib->Construct(_path, option);
621 SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
625 _InProcessInfo* pItem = new (std::nothrow) _InProcessInfo(_provider, _opId, _property, false, *pLib, pListener);
628 req = _AppControlManager::GetInstance()->__inAppManager.InsertItem(pItem);
631 r = InvokeStartAppControl(*pLib, req, _provider, _opId, null, null, pDataList);
633 if (pListener == null)
638 // after acquring request number, pLib should be managed from the list, not CATCH
641 SetLastResult(E_SYSTEM);
642 _AppControlManager::GetInstance()->__inAppManager.RemoveItem(req);
643 SysLog(NID_APP, "[E_SYSTEM] A system error has occurred with %s.", GetErrorMessage(r));
657 case E_LIBRARY_NOT_FOUND:
669 _AppControlImpl::InvokeStartAppControl(_LibraryImpl& lib, int req, const String& appId, const String& oId, const IList* pList)
671 SysLog(NID_APP, "Legacy stuff for converting argument");
673 HashMap map(SingleObjectDeleter);
674 HashMap* pMap = null;
679 _AppArg::FillMapFromList(&map, pList);
684 return InvokeStartAppControl(lib, req, appId, oId, null, null, pMap);
689 _AppControlImpl::InvokeStartAppControl(_LibraryImpl& lib, int req, const String& appId, const String& oId, const String* pUri, const String* pMime, const IMap* pMap)
691 result (*pFunc)(int req, const String&, const String&, const String*, const String*, const IMap*) = null;
694 reinterpret_cast<result (*)(int, const String&, const String&, const String*, const String*, const IMap*)>(lib.GetProcAddress(L"StartAppControl"));
695 SysTryReturnResult(NID_APP, pFunc != null, E_OBJ_NOT_FOUND, "Entry \"StartAppControl\" not found for %ls", appId.GetPointer());
696 return (*pFunc)(req, appId, oId, pUri, pMime, pMap);
700 IsValidAppControl(const String& appcontrolID)
702 return ((appcontrolID == L"osp.appcontrol.provider.audio")
703 || (appcontrolID == L"osp.appcontrol.provider.bluetooth")
704 || (appcontrolID == L"osp.appcontrol.provider.calendar")
705 || (appcontrolID == L"osp.appcontrol.provider.camera")
706 || (appcontrolID == L"osp.appcontrol.provider.contact")
707 || (appcontrolID == L"osp.appcontrol.provider.certificatemanager")
708 || (appcontrolID == L"osp.appcontrol.provider.email")
709 || (appcontrolID == L"osp.appcontrol.provider.image")
710 || (appcontrolID == L"osp.appcontrol.provider.media")
711 || (appcontrolID == L"osp.appcontrol.provider.message")
712 || (appcontrolID == L"osp.appcontrol.provider.video")
713 || (appcontrolID == L"osp.appcontrol.provider.imageeditor")
714 || (appcontrolID == L"osp.appcontrol.provider.allshare")
715 || (appcontrolID == L"tizen.filemanager")
716 || (appcontrolID == L"tizen.camera")
717 || (appcontrolID == L"tizen.gallery")
718 || (appcontrolID == L"tizen.imageviewer")
719 || (appcontrolID == L"tizen.videoplayer")
720 || (appcontrolID == L"tizen.memo")
721 || (appcontrolID == L"tizen.contacts")
722 || (appcontrolID == L"tizen.calendar")
723 || (appcontrolID == L"tizen.events")
724 || (appcontrolID == L"tizen.email")
725 || (appcontrolID == L"tizen.settings")
726 || (appcontrolID == L"tizen.messages")
727 || (appcontrolID == L"tizen.musicplayer")
728 || (appcontrolID == L"tizen.bluetooth")
729 || (appcontrolID == L"samsung.snote")
730 || (appcontrolID == L"0pnxz8hbsr.MyFiles")
731 || (appcontrolID == L"hdufar9ycj.Camera")
732 || (appcontrolID == L"ijudt7w61q.Gallery")
733 || (appcontrolID == L"jysyv9o1dc.ImageViewer")
734 || (appcontrolID == L"npwf0scb88.VideoPlayer")
735 || (appcontrolID == L"zunqjlsnce.Memo")
736 || (appcontrolID == L"f9uev8hsyo.Contacts")
737 || (appcontrolID == L"ph1vq2phrp.Calendar")
738 || (appcontrolID == L"vxqbrefica.Email")
739 || (appcontrolID == L"kto5jikgul.Settings")
740 || (appcontrolID == L"8r4r5ddzzn.Messages")
741 || (appcontrolID == L"dhrul6qzj3.MusicPlayer")
742 || (appcontrolID == L"smemo-efl"));
746 _AppControlImpl::Stop(void)
748 const String appcontrolID(GetAppControlProviderId());
749 SysTryReturnResult(NID_APP, IsValidAppControl(appcontrolID), E_INVALID_OPERATION, "Invalid appcontrolID(%ls)", appcontrolID.GetPointer());
751 if (_property & _APPCONTROL_PROPERTY_SLP)
753 SysTryReturnResult(NID_APP, _reqId != _REQ_ID_INVALID, E_INVALID_OPERATION, "Invalid request ID .");
755 _InProcessInfo* pInfo = _AppControlManager::GetInstance()->__inAppManager.FindItem(_reqId);
756 SysTryReturnResult(NID_APP, pInfo != null, E_INVALID_OPERATION, "Request ID %d is not found.", _reqId);
758 result (*pStop)(int req) = null;
759 pStop = reinterpret_cast<result (*)(int)>(pInfo->pLib->GetProcAddress(L"TerminateAppControl"));
760 SysTryReturnResult(NID_APP, pStop != null, E_SYSTEM, "No TerminateAppControl() function.");
764 _AppControlManager::GetInstance()->__inAppManager.RemoveItem(_reqId);
766 _reqId = _REQ_ID_INVALID;
768 else if (_property & _APPCONTROL_PROPERTY_OSP)
770 _Aul::TerminateApplicationByPid(_processId);
777 _AppControlImpl::GetAppName(void)
779 if ((_property & _APPCONTROL_PROPERTY_OSP) && _appName.IsEmpty())
781 const AppId& appId = _path;
783 std::unique_ptr<PackageAppInfo> pInfo(_PackageManagerImpl::GetInstance()->GetPackageAppInfoN(appId));
787 const String& name = pInfo->GetAppName();
788 if (name == L"_AppControl")
790 // workaround for special case: requery with actual appId
791 const PackageId& packageId = _PackageManagerImpl::GetPackageIdByAppId(appId);
792 const String& defaultName = _PackageManagerImpl::GetInstance()->GetDefaultAppExecutableName(packageId);
794 const String& convertedAppId = packageId + L'.' + defaultName;
796 std::unique_ptr<PackageAppInfo> pNewInfo(_PackageManagerImpl::GetInstance()->GetPackageAppInfoN(convertedAppId));
800 _appName = pNewInfo->GetAppName();
804 SysLog(NID_APP, "No default applicaiton information, possible database error.");
809 _appName = pInfo->GetAppName();
811 SysLog(NID_APP, "Initializing AppName(%ls) for %ls.", _appName.GetPointer(), appId.GetPointer());
819 _AppControlImpl::GetAppId(void) const
821 return (_property & _APPCONTROL_PROPERTY_OSP) ? _path : _provider;
825 _AppControlImpl::GetAppControlProviderId(void) const
831 _AppControlImpl::GetOperationId(void) const
837 _AppControlImpl::GetCategoryListN(void) const
839 const AppId& appId = GetAppId();
840 SysTryReturn(NID_APP, !appId.IsEmpty(), null, E_SYSTEM, "[E_SYSTEM] Empty appId.");
842 SysLog(NID_APP, "Acquiring category for appId %ls.", appId.GetPointer());
844 std::unique_ptr<PackageAppInfo> pAppInfo(_PackageManagerImpl::GetInstance()->GetPackageAppInfoN(appId));
845 SysTryReturn(NID_APP, pAppInfo.get() != null, null, E_SYSTEM, "[E_SYSTEM] Getting PackageAppInfo failed.");
847 return pAppInfo->GetAppCategoryListN();
851 _AppControlImpl::StopAppControlResponseListener(IAppControlResponseListener* pListener)
853 _AppControlManager::GetInstance()->__listenerList.Add(pListener);