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_AppManagerProxy.h"
42 #include "FApp_AppControlManager.h"
43 #include "FApp_AppArg.h"
44 #include "FApp_AppImpl.h"
45 #include "FApp_AppControlRegistry.h"
46 #include "FApp_AppMessageImpl.h"
47 #include "FApp_AppInfo.h"
48 #include "FAppPkg_PackageManagerImpl.h"
51 using namespace Tizen::Base;
52 using namespace Tizen::Base::Collection;
53 using namespace Tizen::Base::Runtime;
54 using namespace Tizen::App;
55 using namespace Tizen::App::Package;
56 using namespace Tizen::Io;
61 static const int _REQ_ID_INVALID = -1;
65 namespace Tizen { namespace App
68 const wchar_t TIZEN_OPERATION_MAIN[] = L"http://tizen.org/appcontrol/operation/main";
69 const char TIZEN_APPCONTROL_DATA_LEGACY[] = "http://tizen.org/appcontrol/data/legacyresult";
71 _AppControlImpl::_AppControlImpl(const AppControl& value)
73 , _reqId(_REQ_ID_INVALID)
74 , _property(_APPCONTROL_PROPERTY_NONE)
75 , _processId(_REQ_ID_INVALID)
79 _AppControlImpl::~_AppControlImpl(void)
84 _AppControlImpl::CreateN(const String& path, const String& aId, const String& oId, const String& name, int prop)
86 SysTryReturn(NID_APP, !path.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] Path is empty.");
87 SysTryReturn(NID_APP, !aId.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] Provider Id is empty.");
88 SysTryReturn(NID_APP, !oId.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] Operation Id is empty.");
90 AppControl* pAc = new (std::nothrow) AppControl;
91 SysTryReturn(NID_APP, pAc != null, null, E_OUT_OF_MEMORY, "AppControl allocation failure.");
93 _AppControlImpl* pImpl = pAc->__pAppControlImpl;
94 SysTryReturn(NID_APP, pImpl != null, null, E_OUT_OF_MEMORY, "AppControlImpl instance must not be null.");
97 pImpl->_provider = aId;
99 // [FIXME] Proper App name setting
100 pImpl->_appName = name;
101 pImpl->_property = prop;
107 _AppControlImpl::CreateN(const AppId& appId, const String& operationId, bool changeAppId)
109 SysTryReturn(NID_APP, !appId.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] appId is empty.");
111 AppControl* pAc = new (std::nothrow) AppControl;
112 SysTryReturn(NID_APP, pAc != null, null, E_OUT_OF_MEMORY, "AppControl allocation failure.");
114 _AppControlImpl* pImpl = pAc->__pAppControlImpl;
115 SysTryReturn(NID_APP, pImpl != null, null, E_OUT_OF_MEMORY, "AppControlImpl instance must not be null.");
117 pImpl->_path = appId;
118 pImpl->_provider = appId;
119 pImpl->_opId = operationId;
120 //pImpl->_appName = appId;
121 pImpl->_property |= (_APPCONTROL_PROPERTY_OSP | _APPCONTROL_PROPERTY_PUBLIC);
125 pImpl->_property |= _APPCONTROL_PROPERTY_APPID_CHANGE;
132 _AppControlImpl::CreateN(const AppControl& ac)
134 const _AppControlImpl* pImpl = GetInstance(ac);
135 SysTryReturn(NID_APP, pImpl != null, null, E_INVALID_STATE, "AppControlImpl instance must not be null.");
137 return CreateN(pImpl->_path, pImpl->_provider, pImpl->_opId, pImpl->_appName, pImpl->_property);
140 const _AppControlImpl*
141 _AppControlImpl::GetInstance(const AppControl& ac)
143 return ac.__pAppControlImpl;
147 _AppControlImpl::GetInstance(AppControl& ac)
149 return ac.__pAppControlImpl;
153 _AppControlImpl::Start(const IList* pDataList, IAppControlEventListener* pListener)
157 if (_property & _APPCONTROL_PROPERTY_SLP)
159 r = StartNative(pDataList, pListener);
161 else if (_property & _APPCONTROL_PROPERTY_OSP)
163 r = StartOsp(pDataList, pListener);
167 SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] Invalid AppControl type(property %d)", _property);
174 _AppControlImpl::Start(const String* pUriData, const String* pDataType, const IMap* pExtraData, IAppControlResponseListener* pListener)
178 if (_property & _APPCONTROL_PROPERTY_SLP)
180 r = StartNative(pUriData, pDataType, pExtraData, pListener);
182 else if (_property & _APPCONTROL_PROPERTY_OSP)
184 r = StartOsp(pUriData, pDataType, pExtraData, pListener);
188 SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] Invalid AppControl type(property %d)", _property);
195 _AppControlImpl::FindAndStart(const String& operationId, const String* pUriPattern, const String* pDataType, const String* pCategory, const IMap* pExtraData, IAppControlResponseListener* pListener)
197 // [FIXME] valid argument size checking required
199 std::unique_ptr<bundle, BundleDeleter> pBundle(bundle_create());
200 SysTryReturnResult(NID_APP, pBundle.get(), E_OUT_OF_MEMORY, "Bundle creation failure.");
202 _AppMessageImpl::SetOperation(pBundle.get(), operationId);
206 _AppMessageImpl::SetUri(pBundle.get(), *pUriPattern);
211 String mimeType = *pDataType;
213 if ((*pDataType)[0] == L'.')
215 SysLog(NID_APP, "Extension to MIME conversion for %ls", pDataType->GetPointer());
219 pDataType->SubString(1, ext);
221 result r = _AppControlManager::GetMimeFromExt(ext, mimeType);
223 SysTryReturn(NID_APP, !IsFailed(r), null, r, "[%s] MIME type conversion failure for %ls.", GetErrorMessage(r), ext.GetPointer());
225 pMimeType = &mimeType;
227 SysLog(NID_APP, "Conversion : %ls -> %ls.", pDataType->GetPointer(), pMimeType->GetPointer());
231 _AppMessageImpl::SetMime(pBundle.get(), mimeType);
236 _AppMessageImpl::SetCategory(pBundle.get(), *pCategory);
239 return StartImplicit(pBundle.get(), pExtraData, pListener);
243 _AppControlImpl::StartOsp(const IList* pDataList, IAppControlEventListener* pListener)
245 result r = E_SUCCESS;
247 _AppArg* pArg = new (std::nothrow) _AppArg;
248 SysTryReturnResult(NID_APP, pArg != null, E_OUT_OF_MEMORY, "Argument allocation failure.");
250 pArg->Construct(*this, pDataList);
252 _AppControlManager* pImpl = _AppControlManager::GetInstance();
253 int req = _REQ_ID_INVALID;
257 _AppControlManager::_RequestGuard reqObj = _AppControlManager::_RequestGuard(*pImpl, pArg, AppControlCbLegacy, pListener, _property);
258 req = reqObj.GetRequestNumber();
260 _processId = pImpl->Launch(_path, pArg, req);
261 SysTryCatch(NID_APP, r == E_SUCCESS, reqObj.Invalidate(), r, "[%s] Propagating." , GetErrorMessage(r));
265 _processId = pImpl->Launch(_path, pArg);
270 // registers to server
271 _IAppManager* pMgr = _AppManagerProxy::GetService();
273 // actually register, not launch
276 const int MAX_PACKAGE_ID = 10;
280 r = _path.SubString(0, MAX_PACKAGE_ID, appId);
283 r = _path.SubString(MAX_PACKAGE_ID + 1, execName);
286 pMgr->LaunchApplication(appId, execName, req);
298 _AppControlImpl::StartOsp(const String* pUriData, const String* pMimeType, const IMap* pDataList, IAppControlResponseListener* pListener)
300 result r = E_SUCCESS;
302 _AppArg* pArg = new (std::nothrow) _AppArg;
303 SysTryReturnResult(NID_APP, pArg != null, E_OUT_OF_MEMORY, "Argument allocation failure.");
305 pArg->Construct(*this, pUriData, pMimeType, pDataList);
307 _AppControlManager* pImpl = _AppControlManager::GetInstance();
308 int req = _REQ_ID_INVALID;
312 _AppControlManager::_RequestGuard reqObj = _AppControlManager::_RequestGuard(*pImpl, pArg, AppControlCb, pListener, _property);
313 req = reqObj.GetRequestNumber();
315 _processId = pImpl->Launch(_path, pArg, req);
316 SysTryCatch(NID_APP, r == E_SUCCESS, reqObj.Invalidate(), r, "[%s] Propagating." , GetErrorMessage(r));
320 _processId = pImpl->Launch(_path, pArg);
325 // registers to server
326 _IAppManager* pMgr = _AppManagerProxy::GetService();
328 // actually register, not launch
331 const int MAX_PACKAGE_ID = 10;
335 r = _path.SubString(0, MAX_PACKAGE_ID, appId);
338 r = _path.SubString(MAX_PACKAGE_ID + 1, execName);
341 pMgr->LaunchApplication(appId, execName, req);
353 _AppControlImpl::StartImplicit(bundle* pBundle, const IList* pDataList, IAppControlEventListener* pListener)
355 result r = E_SUCCESS;
357 _AppArg* pArg = new (std::nothrow) _AppArg;
358 SysTryReturnResult(NID_APP, pArg != null, E_OUT_OF_MEMORY, "Argument allocation failure.");
360 pArg->Construct(pBundle);
362 _AppMessageImpl::AddData(pArg->GetBundle(), pDataList);
364 _AppControlManager* pImpl = _AppControlManager::GetInstance();
365 int req = _REQ_ID_INVALID;
369 _AppControlManager::_RequestGuard reqObj = _AppControlManager::_RequestGuard(*pImpl, pArg, AppControlCbLegacy, pListener, _APPCONTROL_PROPERTY_NONE);
370 req = reqObj.GetRequestNumber();
372 r = pImpl->LaunchAppImplicit(pArg, req);
373 SysTryCatch(NID_APP, r == E_SUCCESS, reqObj.Invalidate(), r, "[%s] Propagating." , GetErrorMessage(r));
377 r = pImpl->LaunchAppImplicit(pArg, -1);
381 // [FIXME] launch registration is not working correctly
389 _AppControlImpl::StartImplicit(bundle* pBundle, const IMap* pData, IAppControlResponseListener* pListener)
391 result r = E_SUCCESS;
393 _AppArg* pArg = new (std::nothrow) _AppArg;
394 SysTryReturnResult(NID_APP, pArg != null, E_OUT_OF_MEMORY, "Argument allocation failure.");
396 pArg->Construct(pBundle);
398 _AppArg::AddStrMap(pArg->GetBundle(), pData);
400 _AppControlManager* pImpl = _AppControlManager::GetInstance();
401 int req = _REQ_ID_INVALID;
405 _AppControlManager::_RequestGuard reqObj = _AppControlManager::_RequestGuard(*pImpl, pArg, AppControlCb, pListener, _APPCONTROL_PROPERTY_NONE);
406 req = reqObj.GetRequestNumber();
408 r = pImpl->LaunchAppImplicit(pArg, req);
409 SysTryCatch(NID_APP, r == E_SUCCESS, reqObj.Invalidate(), r, "[%s] Propagating." , GetErrorMessage(r));
413 r = pImpl->LaunchAppImplicit(pArg, -1);
417 // [FIXME] launch registration is not working correctly
425 _AppControlImpl::AppControlCbLegacy(void* data, _AppArg* pArg, _AppArg* pResArg, service_result_e res, int prop)
427 SysLog(NID_APP, "Result value %d", res);
429 SysTryReturnResult(NID_APP, data && pResArg && pArg, E_SYSTEM, "Invalid result (callback, result, arg) = (0x%x, 0x%x, 0x%x).",
433 bundle* b = pResArg->GetBundle();
434 SysTryReturnResult(NID_APP, b != NULL, E_SYSTEM, "Invalid result bundle.");
436 IAppControlEventListener* pListener = static_cast<IAppControlEventListener*>(data);
437 SysTryReturnResult(NID_APP, typeid(pListener) == typeid(IAppControlEventListener*), E_SYSTEM, "Invalid result callback");
439 bundle* inb = pArg->GetBundle();
440 SysTryReturnResult(NID_APP, inb != NULL, E_SYSTEM, "Empty caller bundle.");
444 AppId provider = pResArg->GetCalleeAppId();
446 const char* p = appsvc_get_operation(inb);
452 SysLog(NID_APP, "Invoking callback with (%ls, %ls)", provider.GetPointer(), oId.GetPointer());
454 if (prop & _APPCONTROL_PROPERTY_ALIAS)
456 _AppControlRegistry::_AppControlAliasEntry* pEntry = null;
457 pEntry = _AppControlRegistry::GetInstance()->GetReverseAppControlAliasEntry(provider, oId);
460 provider = pEntry->provider;
461 oId = pEntry->operation;
463 SysLog(NID_APP, "Legacy AppControl name (%ls, %ls).", provider.GetPointer(), oId.GetPointer());
467 if (prop & _APPCONTROL_PROPERTY_APPID_CHANGE)
469 String tmp = _AppControlRegistry::GetInstance()->GetReverseAliasAppId(provider);
472 SysLog(NID_APP, "AppId change (%ls -> %ls).", provider.GetPointer(), tmp.GetPointer());
478 std::unique_ptr<HashMap> pMap(pResArg->GetArgMapN());
480 ArrayList list(SingleObjectDeleter);
481 _AppArg::FillLegacyAppControlResult(list, res, pMap.get(), provider);
483 // proper callback invokation
484 pListener->OnAppControlCompleted(provider, oId, &list);
490 _AppControlImpl::AppControlCb(void* data, _AppArg* pArg, _AppArg* pResArg, service_result_e res, int prop)
492 SysLog(NID_APP, "Result value %d", res);
494 SysTryReturnResult(NID_APP, data && pResArg && pArg, E_SYSTEM, "Invalid result (callback, result, arg) = (0x%x, 0x%x, 0x%x).",
498 bundle* b = pResArg->GetBundle();
499 SysTryReturnResult(NID_APP, b != NULL, E_SYSTEM, "Invalid result bundle.");
501 IAppControlResponseListener* pListener = static_cast<IAppControlResponseListener*>(data);
502 SysTryReturnResult(NID_APP, typeid(pListener) == typeid(IAppControlResponseListener*), E_SYSTEM, "Invalid result callback");
504 bundle* inb = pArg->GetBundle();
505 SysTryReturnResult(NID_APP, inb != NULL, E_SYSTEM, "Empty caller bundle.");
509 AppId provider = pResArg->GetCalleeAppId();
511 const char* p = appsvc_get_operation(inb);
517 SysLog(NID_APP, "Invoking callback with (%ls, %ls)", provider.GetPointer(), oId.GetPointer());
519 if (prop & _APPCONTROL_PROPERTY_ALIAS)
521 _AppControlRegistry::_AppControlAliasEntry* pEntry = null;
522 pEntry = _AppControlRegistry::GetInstance()->GetReverseAppControlAliasEntry(provider, oId);
525 provider = pEntry->provider;
526 oId = pEntry->operation;
528 SysLog(NID_APP, "Legacy AppControl name (%ls, %ls).", provider.GetPointer(), oId.GetPointer());
532 if (prop & _APPCONTROL_PROPERTY_APPID_CHANGE)
534 String tmp = _AppControlRegistry::GetInstance()->GetReverseAliasAppId(provider);
537 SysLog(NID_APP, "AppId change (%ls -> %ls).", provider.GetPointer(), tmp.GetPointer());
543 std::unique_ptr<HashMap> pMap(pResArg->GetArgMapN());
545 AppCtrlResult ret = APP_CTRL_RESULT_FAILED;
546 // to prevent enum overflow;
550 case SERVICE_RESULT_SUCCEEDED:
551 ret = APP_CTRL_RESULT_SUCCEEDED;
553 case SERVICE_RESULT_FAILED:
554 ret = APP_CTRL_RESULT_CANCELED;
556 case SERVICE_RESULT_CANCELED:
557 ret = APP_CTRL_RESULT_ABORTED;
559 case APPSVC_OSP_RES_FAIL:
560 ret = APP_CTRL_RESULT_FAILED;
562 case APPSVC_OSP_RES_TERMINATE:
563 ret = APP_CTRL_RESULT_TERMINATED;
566 ret = APP_CTRL_RESULT_FAILED;
570 SysLog(NID_APP, "Result code : 0x%x.", ret);
572 // proper callback invokation
573 pListener->OnAppControlCompleteResponseReceived(provider, oId, ret, pMap.get());
579 _AppControlImpl::StartNative(const IList* pDataList, IAppControlEventListener* pListener)
581 _InProcessInfo* pInfo = _AppControlManager::GetInstance()->__inAppManager.FindItem(_reqId);
582 SysTryReturnResult(NID_APP, pInfo == null, E_IN_PROGRESS, "Request ID %d is already in progress.", _reqId);
584 int req = _REQ_ID_INVALID;
585 _LibraryImpl* pLib = null;
587 pLib = new (std::nothrow) _LibraryImpl;
588 SysTryReturnResult(NID_APP, pLib != null, E_OUT_OF_MEMORY, "Failed to allocate libraryimpl.");
590 result r = pLib->Construct(_path);
591 SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
595 _InProcessInfo* pItem = new (std::nothrow) _InProcessInfo(_provider, _opId, _property, true, *pLib, pListener);
598 req = _AppControlManager::GetInstance()->__inAppManager.InsertItem(pItem);
601 r = InvokeStartAppControl(*pLib, req, _provider, _opId, pDataList);
603 if (pListener == null)
608 // after acquring request number, pLib should be managed from the list, not CATCH
611 SetLastResult(E_SYSTEM);
612 _AppControlManager::GetInstance()->__inAppManager.RemoveItem(req);
613 SysLog(NID_APP, "[E_SYSTEM] A system error has occurred with %s.", GetErrorMessage(r));
627 case E_LIBRARY_NOT_FOUND:
639 _AppControlImpl::StartNative(const String* pUriData, const String* pMimeType, const IMap* pDataList, IAppControlResponseListener* pListener)
641 _InProcessInfo* pInfo = _AppControlManager::GetInstance()->__inAppManager.FindItem(_reqId);
642 SysTryReturnResult(NID_APP, pInfo == null, E_IN_PROGRESS, "Request ID %d is already in progress.", _reqId);
644 int req = _REQ_ID_INVALID;
645 _LibraryImpl* pLib = null;
647 pLib = new (std::nothrow) _LibraryImpl;
648 SysTryReturnResult(NID_APP, pLib != null, E_OUT_OF_MEMORY, "Failed to allocate libraryimpl.");
650 result r = pLib->Construct(_path);
651 SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
655 _InProcessInfo* pItem = new (std::nothrow) _InProcessInfo(_provider, _opId, _property, false, *pLib, pListener);
658 req = _AppControlManager::GetInstance()->__inAppManager.InsertItem(pItem);
661 r = InvokeStartAppControl(*pLib, req, _provider, _opId, null, null, pDataList);
663 if (pListener == null)
668 // after acquring request number, pLib should be managed from the list, not CATCH
671 SetLastResult(E_SYSTEM);
672 _AppControlManager::GetInstance()->__inAppManager.RemoveItem(req);
673 SysLog(NID_APP, "[E_SYSTEM] A system error has occurred with %s.", GetErrorMessage(r));
687 case E_LIBRARY_NOT_FOUND:
699 _AppControlImpl::InvokeStartAppControl(_LibraryImpl& lib, int req, const String& appId, const String& oId, const IList* pList)
701 SysLog(NID_APP, "Legacy stuff for converting argument");
703 HashMap map(SingleObjectDeleter);
704 HashMap* pMap = null;
709 _AppArg::FillMapFromList(&map, pList);
714 return InvokeStartAppControl(lib, req, appId, oId, null, null, pMap);
719 _AppControlImpl::InvokeStartAppControl(_LibraryImpl& lib, int req, const String& appId, const String& oId, const String* pUri, const String* pMime, const IMap* pMap)
721 result (*pFunc)(int req, const String&, const String&, const String*, const String*, const IMap*) = null;
724 reinterpret_cast<result (*)(int, const String&, const String&, const String*, const String*, const IMap*)>(lib.GetProcAddress(L"StartAppControl"));
725 SysTryReturnResult(NID_APP, pFunc != null, E_OBJ_NOT_FOUND, "Entry \"StartAppControl\" not found for %ls", appId.GetPointer());
726 return (*pFunc)(req, appId, oId, pUri, pMime, pMap);
730 IsValidAppControl(const String& appcontrolID)
732 return ((appcontrolID == L"osp.appcontrol.provider.audio")
733 || (appcontrolID == L"osp.appcontrol.provider.bluetooth")
734 || (appcontrolID == L"osp.appcontrol.provider.calendar")
735 || (appcontrolID == L"osp.appcontrol.provider.camera")
736 || (appcontrolID == L"osp.appcontrol.provider.contact")
737 || (appcontrolID == L"osp.appcontrol.provider.certificatemanager")
738 || (appcontrolID == L"osp.appcontrol.provider.email")
739 || (appcontrolID == L"osp.appcontrol.provider.image")
740 || (appcontrolID == L"osp.appcontrol.provider.media")
741 || (appcontrolID == L"osp.appcontrol.provider.message")
742 || (appcontrolID == L"osp.appcontrol.provider.video")
743 || (appcontrolID == L"osp.appcontrol.provider.imageeditor")
744 || (appcontrolID == L"osp.appcontrol.provider.allshare")
745 || (appcontrolID == L"tizen.filemanager")
746 || (appcontrolID == L"tizen.camera")
747 || (appcontrolID == L"tizen.gallery")
748 || (appcontrolID == L"tizen.imageviewer")
749 || (appcontrolID == L"tizen.videoplayer")
750 || (appcontrolID == L"tizen.memo")
751 || (appcontrolID == L"tizen.contacts")
752 || (appcontrolID == L"tizen.calendar")
753 || (appcontrolID == L"tizen.events")
754 || (appcontrolID == L"tizen.email")
755 || (appcontrolID == L"tizen.settings")
756 || (appcontrolID == L"tizen.messages")
757 || (appcontrolID == L"tizen.musicplayer")
758 || (appcontrolID == L"tizen.bluetooth")
759 || (appcontrolID == L"samsung.snote")
760 || (appcontrolID == L"0pnxz8hbsr.MyFiles")
761 || (appcontrolID == L"hdufar9ycj.Camera")
762 || (appcontrolID == L"ijudt7w61q.Gallery")
763 || (appcontrolID == L"jysyv9o1dc.ImageViewer")
764 || (appcontrolID == L"npwf0scb88.VideoPlayer")
765 || (appcontrolID == L"zunqjlsnce.Memo")
766 || (appcontrolID == L"f9uev8hsyo.Contacts")
767 || (appcontrolID == L"ph1vq2phrp.Calendar")
768 || (appcontrolID == L"vxqbrefica.Email")
769 || (appcontrolID == L"kto5jikgul.Settings")
770 || (appcontrolID == L"8r4r5ddzzn.Messages")
771 || (appcontrolID == L"dhrul6qzj3.MusicPlayer")
772 || (appcontrolID == L"smemo-efl"));
776 _AppControlImpl::Stop(void)
778 const String appcontrolID(GetAppControlProviderId());
779 SysTryReturnResult(NID_APP, IsValidAppControl(appcontrolID), E_INVALID_OPERATION, "Invalid appcontrolID(%ls)", appcontrolID.GetPointer());
781 if (_property & _APPCONTROL_PROPERTY_SLP)
783 SysTryReturnResult(NID_APP, _reqId != _REQ_ID_INVALID, E_INVALID_OPERATION, "Invalid request ID .");
785 _InProcessInfo* pInfo = _AppControlManager::GetInstance()->__inAppManager.FindItem(_reqId);
786 SysTryReturnResult(NID_APP, pInfo != null, E_INVALID_OPERATION, "Request ID %d is not found.", _reqId);
788 result (*pStop)(int req) = null;
789 pStop = reinterpret_cast<result (*)(int)>(pInfo->pLib->GetProcAddress(L"TerminateAppControl"));
790 SysTryReturnResult(NID_APP, pStop != null, E_SYSTEM, "No TerminateAppControl() function.");
794 _AppControlManager::GetInstance()->__inAppManager.RemoveItem(_reqId);
796 _reqId = _REQ_ID_INVALID;
798 else if (_property & _APPCONTROL_PROPERTY_OSP)
800 _Aul::TerminateApplicationByPid(_processId);
807 _AppControlImpl::GetAppName(void)
809 if ((_property & _APPCONTROL_PROPERTY_OSP) && _appName.IsEmpty())
811 const AppId& appId = _path;
813 std::unique_ptr<PackageAppInfo> pInfo(_PackageManagerImpl::GetInstance()->GetPackageAppInfoN(appId));
817 const String& name = pInfo->GetAppName();
818 if (name == L"_AppControl")
820 // workaround for special case: requery with actual appId
821 const PackageId& packageId = _PackageManagerImpl::GetPackageIdByAppId(appId);
822 const String& defaultName = _PackageManagerImpl::GetInstance()->GetDefaultAppExecutableName(packageId);
824 const String& convertedAppId = packageId + L'.' + defaultName;
826 std::unique_ptr<PackageAppInfo> pNewInfo(_PackageManagerImpl::GetInstance()->GetPackageAppInfoN(convertedAppId));
830 _appName = pNewInfo->GetAppName();
834 SysLog(NID_APP, "No default applicaiton information, possible database error.");
839 _appName = pInfo->GetAppName();
841 SysLog(NID_APP, "Initializing AppName(%ls) for %ls.", _appName.GetPointer(), appId.GetPointer());
849 _AppControlImpl::GetAppId(void) const
851 return (_property & _APPCONTROL_PROPERTY_OSP) ? _path : _provider;
855 _AppControlImpl::GetAppControlProviderId(void) const
861 _AppControlImpl::GetOperationId(void) const
867 _AppControlImpl::GetCategoryListN(void) const
869 const AppId& appId = GetAppId();
870 SysTryReturn(NID_APP, !appId.IsEmpty(), null, E_SYSTEM, "[E_SYSTEM] Empty appId.");
872 SysLog(NID_APP, "Acquiring category for appId %ls.", appId.GetPointer());
874 std::unique_ptr<PackageAppInfo> pAppInfo(_PackageManagerImpl::GetInstance()->GetPackageAppInfoN(appId));
875 SysTryReturn(NID_APP, pAppInfo.get() != null, null, E_SYSTEM, "[E_SYSTEM] Getting PackageAppInfo failed.");
877 return pAppInfo->GetAppCategoryListN();
881 _AppControlImpl::StopAppControlResponseListener(IAppControlResponseListener* pListener)