AppControl launch logic refactoring
authorYoung Ik Cho <youngik.cho@samsung.com>
Wed, 2 Oct 2013 10:32:50 +0000 (19:32 +0900)
committerYoung Ik Cho <youngik.cho@samsung.com>
Wed, 2 Oct 2013 10:32:50 +0000 (19:32 +0900)
Change-Id: I2d1f4ad3c4d6d68a6dca4969fed2f7207b248f4d
Signed-off-by: Young Ik Cho <youngik.cho@samsung.com>
12 files changed:
src/app/FApp_AppArg.cpp
src/app/FApp_AppControlImpl.cpp
src/app/FApp_AppControlManager.cpp
src/app/FApp_AppMessageImpl.cpp
src/app/FApp_RequestManagerT.cpp
src/app/inc/FApp_AppArg.h
src/app/inc/FApp_AppControlImpl.h
src/app/inc/FApp_AppControlManager.h
src/app/inc/FApp_AppMessageImpl.h
src/app/inc/FApp_IAppControlPluginProvider.h [new file with mode: 0644]
src/app/inc/FApp_LaunchInfo.h
src/app/inc/FApp_RequestManagerT.h

index 67ffb46..96c0ae3 100644 (file)
@@ -140,16 +140,6 @@ _AppArg::Construct(const _AppControlImpl& ac, const String* pUri, const String*
 
 
 result
-_AppArg::Construct(const _AppMessageImpl& msg, const String& oId, const String* pUri, const String* pMime)
-{
-       __pBundle = bundle_dup(const_cast<bundle*>(msg.GetBundle()));
-       SysTryReturnResult(NID_APP, __pBundle != null, E_OUT_OF_MEMORY, "Bundle creation failure.");
-
-       return CreateAppControlArg(__pBundle, oId, pUri, pMime, null);
-}
-
-
-result
 _AppArg::Construct(const _SqlDataControlImpl& dc, _DataControlRequestType requestType, const IList* pList)
 {
        __pBundle = bundle_create();
@@ -190,9 +180,9 @@ _AppArg::ConstructResult(const _AppArg& arg, const IMap* pMap)
 
 
 result
-_AppArg::Construct(bundle* b)
+_AppArg::Construct(const bundle* b)
 {
-       __pBundle = bundle_dup(b);
+       __pBundle = bundle_dup(const_cast<bundle*>(b));
        SysTryReturnResult(NID_APP, __pBundle != null, E_INVALID_STATE, "Bundle creatioin from service handle failure.");
 
        return E_SUCCESS;
index 376b58e..0b5961a 100644 (file)
@@ -37,6 +37,7 @@
 
 #include "FApp_AppControlImpl.h"
 #include "FApp_AppControlManager.h"
+#include "FApp_IAppControlPluginProvider.h"
 #include "FApp_AppArg.h"
 #include "FApp_AppControlRegistry.h"
 #include "FApp_AppMessageImpl.h"
@@ -170,6 +171,23 @@ _AppControlImpl::GetInstance(AppControl& ac)
        return ac.__pAppControlImpl;
 }
 
+_IAppControlPluginProvider*
+_AppControlImpl::GetAppControlPluginProvider(const String& path)
+{
+       _LibraryImpl lib;
+       lib.Construct(path, _LIBRARY_OPTION);
+
+       APP_CONTROL_PROVIDER_GET_FN pProvider = reinterpret_cast<APP_CONTROL_PROVIDER_GET_FN>(lib.GetProcAddress(L"GetAppControlProviderPlugin"));
+
+       if (!pProvider)
+       {
+               SysLogException(NID_APP, E_SYSTEM, "Cannot load plugin properly for %ls.", path.GetPointer());
+               return null;
+       }
+
+       return (*pProvider)();
+}
+
 result
 _AppControlImpl::Start(const IList* pDataList, IAppControlEventListener* pListener)
 {
@@ -616,27 +634,24 @@ _AppControlImpl::StartNative(const IList* pDataList, IAppControlEventListener* p
        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.");
-
-       result r = pLib->Construct(_path, _LIBRARY_OPTION);
-       SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
+       _IAppControlPluginProvider* pProvider = GetAppControlPluginProvider(_path);
+       SysTryReturnResult(NID_APP, pProvider != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Propagating.");
 
        if (pListener)
        {
-               _InProcessInfo* pItem = new (std::nothrow) _InProcessInfo(_provider, _opId, _property, true, *pLib, pListener);
+               _InProcessInfo* pItem = new (std::nothrow) _InProcessInfo(_provider, _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, _provider, _opId, pDataList);
 
        if (pListener == null)
        {
-               delete pLib;
+               pProvider->Release();
        }
 
        // after acquring request number, pLib should be managed from the list, not CATCH
@@ -652,21 +667,6 @@ _AppControlImpl::StartNative(const IList* pDataList, IAppControlEventListener* p
 
        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
@@ -677,18 +677,14 @@ _AppControlImpl::StartNative(const String* pUriData, const String* pMimeType, co
        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.");
-
-       result r = pLib->Construct(_path, _LIBRARY_OPTION);
+       result r = E_SUCCESS;
 
-       SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
+       _IAppControlPluginProvider* pProvider = GetAppControlPluginProvider(_path);
+       SysTryReturnResult(NID_APP, pProvider != null, E_OBJ_NOT_FOUND, "Propagating.");
 
        if (pListener)
        {
-               _InProcessInfo* pItem = new (std::nothrow) _InProcessInfo(_provider, _opId, _property, false, *pLib, pListener);
+               _InProcessInfo* pItem = new (std::nothrow) _InProcessInfo(_provider, _opId, _property, false, pProvider, pListener);
                if (pItem)
                {
                        req = _AppControlManager::GetInstance()->__inAppManager.InsertItem(pItem);
@@ -717,11 +713,11 @@ _AppControlImpl::StartNative(const String* pUriData, const String* pMimeType, co
                        }
                }
        }
-       r = InvokeStartAppControl(*pLib, req, _provider, _opId, pUriData, pMimeType, pDataList);
+       r = InvokeStartAppControl(pProvider, req, _provider, _opId, pUriData, pMimeType, pDataList);
 
        if (pListener == null)
        {
-               delete pLib;
+               pProvider->Release();
        }
 
        // after acquring request number, pLib should be managed from the list, not CATCH
@@ -737,25 +733,10 @@ _AppControlImpl::StartNative(const String* pUriData, const String* pMimeType, co
        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");
 
@@ -770,22 +751,17 @@ _AppControlImpl::InvokeStartAppControl(_LibraryImpl& lib, int req, const String&
                pMap = &map;
        }
 
-       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;
-
-       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());
+       SysTryReturnResult(NID_APP, pProvider != null, E_SYSTEM, "Wrong AppControl provider plugin for %ls, %ls (%d).", appId.GetPointer(), oId.GetPointer(), req);
 
-       const String* pActualUri = (pUri && !(pUri->IsEmpty())) ? pUri : null;
-       const String* pActualMime = (pMime && !(pMime->IsEmpty())) ? pMime : null;
-       return (*pFunc)(req, appId, oId, pActualUri, pActualMime, pMap);
+       _AppMessageImpl msg(appId, oId, pUri, pMime, pMap);
+       return pProvider->StartAppControlPlugin(req, appId, msg, null);
 }
 
 static bool
@@ -849,10 +825,10 @@ _AppControlImpl::Stop(void)
                        _InProcessInfo* pInfo = _AppControlManager::GetInstance()->__inAppManager.FindItem(_reqId);
                        SysTryReturnResult(NID_APP, pInfo != null, E_INVALID_OPERATION, "Request ID %d is not found.", _reqId);
 
-                       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)
+                       {
+                               pInfo->pProvider->StopAppControlPlugin(_reqId);
+                       }
 
                        _AppControlManager::GetInstance()->__inAppManager.RemoveItem(_reqId);
 
@@ -860,14 +836,13 @@ _AppControlImpl::Stop(void)
                }
                else
                {
-                       _LibraryImpl lib;
-                       result r = lib.Construct(_path, _LIBRARY_OPTION);
-                       if (r == E_SUCCESS)
+                       _IAppControlPluginProvider* pProvider = GetAppControlPluginProvider(_path);
+                       if (pProvider)
                        {
-                               pStop = reinterpret_cast<result (*)(int)>(lib.GetProcAddress(L"TerminateAppControl"));
-                               SysTryReturnResult(NID_APP, pStop != null, E_SYSTEM, "No TerminateAppControl() function.");
+                               pProvider->StopAppControlPlugin(_reqId);
+                               SysLog(NID_APP, "Request %d is stopped.", _reqId);
 
-                               (*pStop)(_reqId);
+                               pProvider->Release();
                        }
                }
        }
@@ -970,7 +945,7 @@ _AppControlImpl::GetCategoryListN(void) const
 void
 _AppControlImpl::StopAppControlResponseListener(IAppControlResponseListener* pListener)
 {
-       _AppControlManager::GetInstance()->__listenerList.Add(pListener);
+       _AppControlManager::GetInstance()->StopAppControlResponseListener(pListener);
 }
 
 void
index a0cbc28..7fa2684 100644 (file)
@@ -46,7 +46,6 @@
 
 #include <FBaseSysLog.h>
 #include <FBase_StringConverter.h>
-#include <FBaseRt_LibraryImpl.h>
 #include <FIo_DataControlResultSetImpl.h>
 
 #include "FApp_AppArg.h"
@@ -66,6 +65,8 @@
 #include "FApp_AppMessageImpl.h"
 #include "FApp_AppManagerImpl.h"
 #include "FApp_AppControlResponseEvent.h"
+#include "FApp_IAppControlPluginProvider.h"
+
 
 using namespace Tizen::App::Package;
 using namespace Tizen::Base;
@@ -91,7 +92,6 @@ _AppControlManager::_AppControlManager(void)
        // AppControl event handling is expected to be performed in the main thread.
        __appControlEvent.Construct();
        __appControlEvent.AddListener(*dynamic_cast<_IAppControlSysEventListener*>(this));
-       __listenerList.Construct();
        __appControlResponseEventContainer.Construct();
        __appControlResponseEventList.Construct();
 }
@@ -163,7 +163,7 @@ _AppControlManager::OnAppControlEventReceivedN(int reqId, _AppArg* pAppArg, int
                        SysLog(NID_APP, "Invoking callback 0x%x", pInfo->launchCb);
                        //pAppArg->Print();
 
-                       if (pInfo->pUserData && (!__listenerList.Contains(pInfo->pUserData)))
+                       if (pInfo->pUserData)
                        {
                                (*pInfo->launchCb)(pInfo->pUserData, pInfo->pArg, pAppArg, static_cast<service_result_e>(res), pInfo->property, reqId);
                        }
@@ -270,7 +270,7 @@ _AppControlManager::OnAppControlEventReceivedN(int reqId, int res, const IMap* p
        SysTryReturnVoidResult(NID_APP, pInfo != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] request Id %d not found with args 0x%x", reqId,
                                        pArgs);
 
-       if (pInfo->pListener && (!__listenerList.Contains(pInfo->pListener)))
+       if (pInfo->pListener)
        {
                String aId = pInfo->providerId;
                String oId = pInfo->operationId;
@@ -345,15 +345,10 @@ _AppControlManager::OnAppControlEventReceivedN(int reqId, int res, const IMap* p
        }
 
        // call TerminateAppControl
-       result (* pFunc)(int req) = null;
-       pFunc = reinterpret_cast<result (*)(int)>(pInfo->pLib->GetProcAddress(L"TerminateAppControl"));
-       if (pFunc)
-       {
-               (*pFunc)(pInfo->reqId);
-       }
-       else
+       if (pInfo->pProvider)
        {
-               SysLogException(NID_APP, E_SYSTEM, "No TerminateAppControl() function.");
+               pInfo->pProvider->StopAppControlPlugin(pInfo->reqId);
+               SysLog(NID_APP, "AppControl stopped for req %d.", pInfo->reqId);
        }
 
        // remove from list and unload dll
@@ -374,6 +369,39 @@ _AppControlManager::GetAppControlResponseEventContainer(void)
 }
 
 
+static bool
+IsMatchingProcListener(const _InProcessInfo& info, IEventListener* pListener)
+{
+       return (info.pListener == pListener);
+}
+
+static bool
+IsMatchingLaunchListener(const _LaunchInfo& info, IEventListener* pListener)
+{
+       return (info.pUserData == pListener);
+}
+
+void
+_AppControlManager::StopAppControlResponseListener(IAppControlResponseListener* pListener)
+{
+       // __inAppManager, __launchManager
+       _InProcessInfo* pProcInfo = __inAppManager.FindItemWithListener(IsMatchingProcListener, pListener);
+       if (pProcInfo)
+       {
+               __inAppManager.RemoveItem(pProcInfo);
+               SysLog(NID_APP, "Listener 0x%x is removed from in-process stub list.", pListener);
+       }
+
+       _LaunchInfo* pLaunchInfo = __launchManager.FindItemWithListener(IsMatchingLaunchListener, pListener);
+       if (pLaunchInfo)
+       {
+               __launchManager.RemoveItem(pLaunchInfo);
+               SysLog(NID_APP, "Listener 0x%x is removed from launch request list.", pListener);
+       }
+
+}
+
+
 // generic launch callback
 static void
 LaunchResultCb(bundle* b, int request_code, appsvc_result_val res, void* data)
@@ -528,6 +556,43 @@ _AppControlManager::Launch(_AppMessageImpl& msg, const char* pkg_name, const cha
 
 
 int
+_AppControlManager::LaunchPkg(_AppMessageImpl& msg, AppSvcResFn pCb, void* data)
+{
+       bundle* kb = msg.GetBundle();
+       SysTryReturn(NID_APP, kb != NULL, -1, E_OUT_OF_MEMORY, "Bundle allocation failure.");
+
+       if (_AppImpl::GetInstance() != null)
+       {
+               const long handle = _AppImpl::GetInstance()->GetWindowHandle();
+               _AppArg::UpdateWindowHandle(kb, handle);
+       }
+
+       int pid = appsvc_run_service(kb, 0, reinterpret_cast<appsvc_res_fn>(pCb), this);
+
+       result r = E_SUCCESS;
+       if (pid < 0)
+       {
+               switch (pid)
+               {
+               case APPSVC_RET_EILLACC:
+                       r = E_ILLEGAL_ACCESS;
+                       break;
+               case APPSVC_RET_EINVAL:
+                       r = E_MAX_EXCEEDED;
+                       break;
+               default:
+                       r = E_SYSTEM;
+                       break;
+               }
+               SysLog(NID_APP, "[%s] Launching service %s failure", GetErrorMessage(r), appsvc_get_appid(kb));
+       }
+       SetLastResult(r);
+
+       return pid;
+}
+
+
+int
 _AppControlManager::LaunchPkg(_AppMessageImpl& msg, const AppId& appId, const String& opId, const String* pUri, const String* pMime, AppSvcResFn pCb, void* data)
 {
        std::unique_ptr<char[]> pPackage(_StringConverter::CopyToCharArrayN(appId));
@@ -695,26 +760,21 @@ _IsDefaultApplication(const AppId& packageId, const String& appId)
 
 
 int
-_AppControlManager::Launch(const _AppMessageImpl& msg, const AppId& aId, const String& oId, const String* pUriData, const String* pMimeType, AppSvcResFn pCb, void* pData)
+_AppControlManager::Launch(const AppId& appId, _AppArg* pArg, int req)
 {
-       SysLog(NID_APP, "Enter");
-
-       _AppArg arg;
-       arg.Construct(msg, oId, pUriData, pMimeType);
-
-       int pid = Launch(aId, &arg, pCb, pData, -1); 
-       SysTryReturn(NID_APP, pid >= 0, -1, GetLastResult(), "Launching(%ls) is failed", aId.GetPointer());
-
-       SysLog(NID_APP, "Exit");
-
-       return pid;
+       return Launch(appId, pArg, reinterpret_cast<AppSvcResFn>(LaunchResultCb), this, req);
 }
 
 
 int
-_AppControlManager::Launch(const AppId& appId, _AppArg* pArg, int req)
+_AppControlManager::Launch(const _AppMessageImpl& msg, AppSvcResFn pCb, void* pData)
 {
-       return Launch(appId, pArg, reinterpret_cast<AppSvcResFn>(LaunchResultCb), this, req);
+       const bundle* pBundle = msg.GetBundle();
+
+       _AppArg arg;
+       arg.Construct(pBundle);
+
+       return Launch(_AppMessageImpl::GetApplicationId(pBundle), &arg, pCb, pData, -1);
 }
 
 
@@ -967,22 +1027,6 @@ CATCH:
 }
 
 
-bool
-_AppControlManager::IsAllowedAppControl(const char aTable[][2][96], int count, const String& aId, const String& oId)
-{
-       for (int i = 0; i < count; i++)
-       {
-               if (aId == aTable[i][0] && oId == aTable[i][1])
-               {
-                       SysLog(NID_APP, "Found entry (%s, %s)", aTable[i][0], aTable[i][1]);
-                       return true;
-               }
-       }
-
-       return false;
-}
-
-
 AppCtrlResult
 _AppControlManager::ConvertAppControlResultCode(int resCode)
 {
@@ -1054,10 +1098,4 @@ _AppControlManager::OnAppControlResponseEventReceivedN(const Tizen::Base::Runtim
        }
 }
 
-AppId
-_AppControlManager::GetAliasAppId(const AppId& appId)
-{
-       return _AppControlRegistry::GetInstance()->GetAliasAppId(appId);
-}
-
 }} // Tizen::App
index 659ad7f..56d22d6 100644 (file)
@@ -53,9 +53,30 @@ _AppMessageImpl::_AppMessageImpl(const _AppMessageImpl&rhs)
        SysAssert(__pBundle != NULL);
 }
 
-_AppMessageImpl::~_AppMessageImpl(void)
+_AppMessageImpl::_AppMessageImpl(const String& appId, const String& oId, const String* pUri, const String* pMime, const IMap* pMap)
+: __pBundle(bundle_create())
 {
        SysAssert(__pBundle != NULL);
+
+       SetApplicationId(__pBundle, appId);
+
+       SetOperation(__pBundle, oId);
+
+       if (pUri)
+       {
+               SetUri(__pBundle, *pUri);
+       }
+
+       if (pMime)
+       {
+               SetMime(__pBundle, *pMime);
+       }
+
+       AddData(pMap);
+}
+
+_AppMessageImpl::~_AppMessageImpl(void)
+{
        bundle_free(__pBundle);
 }
 
@@ -130,14 +151,49 @@ _AppMessageImpl::RemoveData(bundle* pBundle, const String& key)
        return E_SUCCESS;
 }
 
+String
+_AppMessageImpl::GetApplicationId(const bundle* pBundle)
+{
+       return String(appsvc_get_appid(const_cast<bundle*>(pBundle)));
+}
+
+result
+_AppMessageImpl::SetApplicationId(bundle* pBundle, const String& appId)
+{
+       std::unique_ptr<char[]> pVal(_StringConverter::CopyToCharArrayN(appId));
+
+       // alias appid handling is done internally
+       appsvc_set_appid(pBundle, pVal.get());
+
+       return E_SUCCESS;
+}
+
+String
+_AppMessageImpl::GetOperation(const bundle* pBundle)
+{
+       return String(appsvc_get_operation(const_cast<bundle*>(pBundle)));
+}
+
+result
+_AppMessageImpl::SetOperation(bundle* pBundle, const char* pOperation)
+{
+       appsvc_set_operation(pBundle, pOperation);
+
+       return E_SUCCESS;
+}
+
 result
 _AppMessageImpl::SetOperation(bundle* pBundle, const String& operation)
 {
        std::unique_ptr<char[]> pVal(_StringConverter::CopyToCharArrayN(operation));
 
-       appsvc_set_operation(pBundle, pVal.get());
+       return SetOperation(pBundle, pVal.get());
+}
 
-       return E_SUCCESS;
+String
+_AppMessageImpl::GetUri(const bundle* pBundle)
+{
+       return String(appsvc_get_uri(const_cast<bundle*>(pBundle)));
 }
 
 result
@@ -150,6 +206,12 @@ _AppMessageImpl::SetUri(bundle* pBundle, const String& uri)
        return E_SUCCESS;
 }
 
+String
+_AppMessageImpl::GetMime(const bundle* pBundle)
+{
+       return String(appsvc_get_mime(const_cast<bundle*>(pBundle)));
+}
+
 result
 _AppMessageImpl::SetMime(bundle* pBundle, const String& mime)
 {
index 8d1ea46..9b03b53 100644 (file)
 
 #include <limits.h>
 
-#include <FBaseRt_LibraryImpl.h>
-
 #include "FApp_RequestManagerT.h"
 #include "FApp_LaunchInfo.h"
 #include "FApp_AppArg.h"
+#include "FApp_IAppControlPluginProvider.h"
+
 
 using namespace Tizen::Base::Runtime;
 
@@ -41,7 +41,10 @@ _ResultInfo::~_ResultInfo(void)
 
 _InProcessInfo::~_InProcessInfo(void)
 {
-       delete pLib;
+       if (pProvider)
+       {
+               pProvider->Release();
+       }
 }
 
 _LaunchInfo::~_LaunchInfo(void)
@@ -162,6 +165,32 @@ _RequestManagerT<T>::FindItem(int reqId) const
        return (r == E_SUCCESS) ? pItem : null;
 }
 
+template<typename T> T*
+_RequestManagerT<T>::FindItemWithListener(Pred pred, IEventListener* pListener) const
+{
+       RequestListEnumType* pIter = __requestList.GetMapEnumeratorN();
+       if (pIter == null)
+       {
+               return null;
+       }
+
+       while (pIter->MoveNext() == E_SUCCESS)
+       {
+               T* pInfo = null;
+               result r = pIter->GetValue(pInfo);
+
+               if (pInfo)
+               {
+                       if (pred(*pInfo, pListener))
+                       {
+                               return pInfo;
+                       }
+               }
+       }
+
+       return null;
+}
+
 
 // specialization
 template<>
index f61782d..2be9d68 100644 (file)
@@ -90,8 +90,6 @@ public:
 
        result Construct(const _AppControlImpl& ac, const Tizen::Base::String* pUri, const Tizen::Base::String* pMime, const Tizen::Base::Collection::IMap* pMap);
 
-       result Construct(const _AppMessageImpl& msg, const Tizen::Base::String& oId, const Tizen::Base::String* pUri, const Tizen::Base::String* pMime);
-
        result Construct(const _SqlDataControlImpl& dc, _DataControlRequestType requestType, const Tizen::Base::Collection::IList* pList);
 
        result Construct(const _MapDataControlImpl& dc, _DataControlRequestType requestType, const Tizen::Base::Collection::IList* pList);
@@ -100,7 +98,7 @@ public:
 
        result ConstructResult(const _AppArg& arg, const Tizen::Base::Collection::IMap* pMap);
 
-       result Construct(bundle* b);
+       result Construct(const bundle* b);
 
        result ConstructForAppLaunchCondition(const Tizen::Base::String& condition, const Tizen::Base::Collection::IList* pList);
        result ConstructForAppLaunchCondition(const Tizen::Base::String& condition, const Tizen::Base::Collection::IList* pList, const Tizen::Base::Collection::IMap* pMap);
index abee74d..8137caf 100644 (file)
@@ -47,6 +47,7 @@ namespace Tizen { namespace App
 class AppControl;
 class IAppControlEventListener;
 class IAppControlResponseListener;
+class _IAppControlPluginProvider;
 class _AppArg;
 
 enum _AppControlProperty
@@ -267,9 +268,11 @@ private:
 
        result StartNative(const Tizen::Base::String* pUriData, const Tizen::Base::String* pMimeType, const Tizen::Base::Collection::IMap* pExtraData, IAppControlResponseListener* pListener);
 
-       static result InvokeStartAppControl(Tizen::Base::Runtime::_LibraryImpl& lib, int req, const Tizen::Base::String& appId, const Tizen::Base::String& oId, const Tizen::Base::String* pUri, const Tizen::Base::String* pMime, const Tizen::Base::Collection::IMap* pMap);
+       static _IAppControlPluginProvider* GetAppControlPluginProvider(const Tizen::Base::String& path);
 
-       static result InvokeStartAppControl(Tizen::Base::Runtime::_LibraryImpl& lib, int req, const Tizen::Base::String& appId, const Tizen::Base::String& oId, const Tizen::Base::Collection::IList* pList);
+       static result InvokeStartAppControl(_IAppControlPluginProvider* pProvider, int req, const Tizen::Base::String& appId, const Tizen::Base::String& oId, const Tizen::Base::String* pUri, const Tizen::Base::String* pMime, const Tizen::Base::Collection::IMap* pMap);
+
+       static result InvokeStartAppControl(_IAppControlPluginProvider* pProvider, int req, const Tizen::Base::String& appId, const Tizen::Base::String& oId, const Tizen::Base::Collection::IList* pList);
 
        static result AppControlCbLegacy(void* data, _AppArg* pArg, _AppArg* pResArg, service_result_e res, int prop, int reqId);
 
index 1c229c8..dba96f6 100644 (file)
@@ -134,7 +134,7 @@ public:
        
        int Launch(const AppId& appId, _AppArg* pArg, AppSvcResFn pCb, void* pData, int req);
 
-       int Launch(const _AppMessageImpl& msg, const AppId& aId, const Tizen::Base::String& oId, const Tizen::Base::String* pUriData, const Tizen::Base::String* pMimeType, AppSvcResFn pCb, void* pData);
+       int Launch(const _AppMessageImpl& msg, AppSvcResFn pCb, void* pData);
 
        result LaunchAppImplicit(_AppArg* pArg, int req);
 
@@ -144,16 +144,14 @@ public:
 
        int LaunchPkg(_AppMessageImpl& msg, const AppId& appId, const Tizen::Base::String& opId, const Tizen::Base::String* pUri, const Tizen::Base::String* pMime, AppSvcResFn pCb, void* data);
 
+       int LaunchPkg(_AppMessageImpl& msg, AppSvcResFn pCb, void* data);
+
        int Launch(_AppMessageImpl& msg, const char* pkg_name, const char* op, const char* mime, const char* uri, AppSvcResFn pCb, void* data);
        
        result LaunchAppWithCondition(const AppId& appId, const Tizen::Base::String& condition, Tizen::Base::Collection::IList* pArgs);
 
        result SendAppControlStartResponse(int req, const char* pValue, const char* pOp);
 
-       static bool IsAllowedAppControl(const char aTable[][2][96], int count, const Tizen::Base::String& aId, const Tizen::Base::String& oId);
-
-       static AppId GetAliasAppId(const AppId& appId);
-
        static result GetMimeFromExt(const Tizen::Base::String& ext, Tizen::Base::String& out);
 
        void RemoveLaunchRequest(int req);
@@ -162,6 +160,8 @@ public:
 
        static AppCtrlResult ConvertAppControlResultCode(int res);
 
+       void StopAppControlResponseListener(IAppControlResponseListener* pLisetener);
+
        static void InvokeAppControlCompleteListener(IAppControlResponseListener& listener, const AppId& appId, const Tizen::Base::String& op, AppCtrlResult res, const Tizen::Base::Collection::IMap* pExtraData, bool noRaise);
 
        static void InvokeLegacyAppControlCompleteListener(IAppControlEventListener& listener, const AppId& appId, const Tizen::Base::String& op, const Tizen::Base::Collection::IList* pList, bool noRaise);
@@ -182,7 +182,6 @@ private:
        _RequestManagerT<_LaunchInfo> __launchManager;
        _RequestManagerT<_InProcessInfo> __inAppManager;
        _RequestManagerT<_ResultInfo> __resultManager;
-       Tizen::Base::Collection::ArrayListT<void*> __listenerList;
 
        Tizen::Base::Collection::HashMapT<int, _AppControlResponseEvent*> __appControlResponseEventContainer;
        Tizen::Base::Collection::ArrayListT<int> __appControlResponseEventList;
index c6f417d..aa97815 100644 (file)
@@ -45,11 +45,14 @@ namespace Tizen { namespace App
  *
  */
 class _OSP_EXPORT_ _AppMessageImpl
+       : public Tizen::Base::Object
 {
 public:
        _AppMessageImpl(void);
 
-       ~_AppMessageImpl(void);
+       _AppMessageImpl(const Tizen::Base::String& appId, const Tizen::Base::String& oId, const Tizen::Base::String* pUri, const Tizen::Base::String* pMime, const Tizen::Base::Collection::IMap* pMap);
+
+       virtual ~_AppMessageImpl(void);
 
        _AppMessageImpl(const _AppMessageImpl& rhs);
 
@@ -81,10 +84,43 @@ public:
 
        result RemoveData(const Tizen::Base::String& key);
 
+       Tizen::Base::String GetApplicationId(void) const { return GetApplicationId(GetBundle()); }
+
+       result SetApplicationId(const Tizen::Base::String& appId) { return SetApplicationId(GetBundle(), appId); }
+
+       Tizen::Base::String GetOperation(void) const { return GetOperation(GetBundle()); }
+
+       result SetOperation(const char* pOperation) { return SetOperation(GetBundle(), pOperation); }
+
+       result SetOperation(const Tizen::Base::String& operation) { return SetOperation(GetBundle(), operation); }
+
+       Tizen::Base::String GetUri(void) const { return GetUri(GetBundle()); }
+
+       result SetUri(const Tizen::Base::String& uri) { return SetUri(GetBundle(), uri); }
+
+       Tizen::Base::String GetMime(void) const { return GetMime(GetBundle()); }
+
+       result SetMime(const Tizen::Base::String& mime) { return SetMime(GetBundle(), mime); }
+
+       result SetCategory(const Tizen::Base::String& category) { return SetCategory(GetBundle(), category); }
+
+
+       static Tizen::Base::String GetApplicationId(const bundle* pBundle);
+
+       static result SetApplicationId(bundle* pBundle, const Tizen::Base::String& appId);
+
+       static Tizen::Base::String GetOperation(const bundle* pBundle);
+
+       static result SetOperation(bundle* pBundle, const char* pOperation);
+
        static result SetOperation(bundle* pBundle, const Tizen::Base::String& operation);
 
+       static Tizen::Base::String GetUri(const bundle* pBundle);
+
        static result SetUri(bundle* pBundle, const Tizen::Base::String& uri);
 
+       static Tizen::Base::String GetMime(const bundle* pBundle);
+
        static result SetMime(bundle* pBundle, const Tizen::Base::String& mime);
 
        static result SetCategory(bundle* pBundle, const Tizen::Base::String& category);
@@ -98,9 +134,11 @@ public:
        static result AddStringMap(bundle* pBundle,  const Tizen::Base::Collection::IMap* pMap);
 
        static Tizen::Base::Collection::ArrayList* GetValueArrayN(bundle* pBundle, const char* pKey);
+
        static Tizen::Base::Collection::ArrayList* GetValueArrayN(bundle* pBundle, const Tizen::Base::String& key);
 
        static result AddValueArray(bundle* pBundle, const char* pKey, const Tizen::Base::Collection::IList* pList);
+
        static result AddValueArray(bundle* pBundle, const Tizen::Base::String& key, const Tizen::Base::Collection::IList* pList);
 
 private:
diff --git a/src/app/inc/FApp_IAppControlPluginProvider.h b/src/app/inc/FApp_IAppControlPluginProvider.h
new file mode 100644 (file)
index 0000000..170ccdd
--- /dev/null
@@ -0,0 +1,78 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file       FApp_IAppControlPluginProvider.h
+ * @brief      This is the header file for _IAppControlPluginProvider class.
+ */
+
+#ifndef _FAPP_INTERNAL_IAPP_CONTROL_PLUGIN_PROVIDER_H_
+#define _FAPP_INTERNAL_IAPP_CONTROL_PLUGIN_PROVIDER_H_
+
+#include <FApp_Types.h>
+#include <FBaseRtIEventListener.h>
+
+namespace Tizen { namespace App {
+
+class _AppMessageImpl;
+
+/**
+* @interface _IAppControlPluginProvider
+* @brief This is a tagging interface that all event listeners must implement.
+*
+*/
+class _IAppControlPluginProvider
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+       /**
+        * This is the destructor for this class.
+        */
+       virtual ~_IAppControlPluginProvider(void) {}
+
+       /**
+        * This method is called when the AppControl is about to start.
+        *
+        * @return      An error code
+        * @param[in]   req     The request ID
+        * @param[in]   appId   Application ID
+        * @param[in]   message AppControl request detail
+        * @param[out]  pPid    Output process ID
+        */
+       virtual result StartAppControlPlugin(int req, const AppId& appId, const _AppMessageImpl& message, int* pPid) = 0;
+
+       /**
+        * This method is called when the AppControl is about to stop.
+        *
+        * @return      An error code
+        * @param[in]   req     The request ID
+        */
+       virtual result StopAppControlPlugin(int req) = 0;
+
+       /**
+        * Release the plugin instance itself
+        *
+        * @return      An error code
+        */
+       virtual result Release(void) =0;
+}; // _IAppControlPluginProvider
+
+typedef _IAppControlPluginProvider* (*APP_CONTROL_PROVIDER_GET_FN)(void);
+
+}} //Tizen::App
+
+#endif // _FAPP_INTERNAL_IAPP_CONTROL_PLUGIN_PROVIDER_H_
+
index 4fc6360..96493e8 100644 (file)
@@ -33,14 +33,13 @@ namespace Tizen { namespace Base
 {
 namespace Runtime
 {
-class _LibraryImpl;
 class IEventListener;
 }
 }}
 
 namespace Tizen { namespace App
 {
-
+class _IAppControlPluginProvider;
 class _AppArg;
 
 typedef result (*LaunchCbType)(void* data, _AppArg* pArg, _AppArg* pResArg, service_result_e res, int prop, int reqId);
@@ -86,12 +85,12 @@ public:
 struct _InProcessInfo
 {
 public:
-       _InProcessInfo(const Tizen::Base::String& aId, const Tizen::Base::String& oId, int prop, bool legacy, Tizen::Base::Runtime::_LibraryImpl& lib, Tizen::Base::Runtime::IEventListener* pListener)
+       _InProcessInfo(const Tizen::Base::String& aId, const Tizen::Base::String& oId, int prop, bool legacy, _IAppControlPluginProvider* pProvider, Tizen::Base::Runtime::IEventListener* pListener)
                : reqId(-1)
                , providerId(aId)
                , operationId(oId)
                , property(prop)
-               , pLib(&lib)
+               , pProvider(pProvider)
                , pListener(pListener)
                , isLegacy(legacy)
        {
@@ -108,7 +107,7 @@ public:
        const Tizen::Base::String providerId;
        const Tizen::Base::String operationId;
        const int property;
-       Tizen::Base::Runtime::_LibraryImpl* pLib;       // non-empty
+       _IAppControlPluginProvider* pProvider;
        Tizen::Base::Runtime::IEventListener* pListener;
        const bool isLegacy;
 }; // _InProcessInfo
index ff1e57a..34391e0 100644 (file)
 #include <FBaseColHashMapT.h>
 #include <FBaseSysLog.h>
 
+namespace Tizen { namespace Base { namespace Runtime
+{
+class IEventListener;
+}}}
+
 namespace Tizen { namespace App
 {
 
@@ -35,6 +40,7 @@ class _RequestManagerT
 public:
        typedef Tizen::Base::Collection::HashMapT<int, T*> RequestListType;
        typedef Tizen::Base::Collection::IMapEnumeratorT<int, T*> RequestListEnumType;
+       typedef bool (*Pred)(const T&, Tizen::Base::Runtime::IEventListener*);
 
        _RequestManagerT(void);
 
@@ -46,6 +52,8 @@ public:
 
        void RemoveItem(T* pItem);
 
+       T* FindItemWithListener(Pred, Tizen::Base::Runtime::IEventListener* pListener) const;
+
        T* FindItem(int reqId) const;
 
 private: