AppControl caller/callee appId handling refactoring
authorYoung Ik Cho <youngik.cho@samsung.com>
Fri, 5 Apr 2013 11:53:59 +0000 (20:53 +0900)
committerYoung Ik Cho <youngik.cho@samsung.com>
Fri, 5 Apr 2013 11:53:59 +0000 (20:53 +0900)
Change-Id: Ibd4bdf14bb2f6e363d934baa2c6471f94140b585
Signed-off-by: Young Ik Cho <youngik.cho@samsung.com>
src/app/FApp_AppArg.cpp
src/app/FApp_AppControlImpl.cpp
src/app/FApp_AppControlManager.cpp
src/app/FApp_AppEntry.cpp
src/app/inc/FApp_AppArg.h

index 806bdb5..40567ac 100755 (executable)
@@ -30,6 +30,7 @@
 #include <aul.h>
 #include <app.h>
 #include <appsvc/appsvc.h>
+#include <Ecore_X.h>
 
 #include <FBaseInteger.h>
 #include <FBaseColArrayList.h>
@@ -52,6 +53,9 @@ using namespace Tizen::Base::Collection;
 using namespace Tizen::Base::Utility;
 using namespace Tizen::App::Package;
 
+
+extern "C" int appsvc_allow_transient_app(bundle*, Ecore_X_Window);
+
 namespace Tizen { namespace App
 {
 
@@ -67,7 +71,6 @@ static const char OSP_V_REQUEST_TYPE_MAP_QEURY[] = "map_query";
 static const char OSP_V_REQUEST_TYPE_MAP_INSERT[] = "map_insert";
 static const char OSP_V_REQUEST_TYPE_MAP_UPDATE[] = "map_update";
 static const char OSP_V_REQUEST_TYPE_MAP_DELETE[] = "map_delete";
-static const char BUNDLE_KEY_WINDOW[] = "__APP_SVC_K_WIN_ID__";
 static const char BUNDLE_KEY_PREFIX_AUL[] = "__AUL_";
 static const char BUNDLE_KEY_PREFIX_SERVICE[] = "__APP_SVC_";
 static const char BUNDLE_KEY_PREFIX_OSP[] = "__OSP_";
@@ -572,31 +575,20 @@ _AppArg::GetCallerPid(bundle* pBundle)
 AppId
 _AppArg::GetCallerAppId(void) const
 {
-       pid_t callerPid = GetCallerPid();
-       SysTryReturn(NID_APP, callerPid > 0, L"", E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Wrong process id: %d.", callerPid);
+       const char* pBundleValue = bundle_get_val(__pBundle, AUL_K_CALLER_APPID);
 
-       char appId[PATH_MAX] = {0, };
-       SysTryReturn(NID_APP, aul_app_get_appid_bypid(callerPid, appId, sizeof(appId)) == AUL_R_OK, L"", E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Object not found for %d.", callerPid);
-
-       return String(appId);
+       return String(pBundleValue);
 }
 
 
 AppId
 _AppArg::GetCalleeAppId(void) const
 {
-       const char* pBundleValue = bundle_get_val(__pBundle, AUL_K_CALLEE_PID);
-
-       SysTryReturn(NID_APP, pBundleValue != null, L"", E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Object not found.");
+       const char* pBundleValue = bundle_get_val(__pBundle, AUL_K_CALLEE_APPID);
 
-       pid_t calleePid = atoi(pBundleValue);
-       SysTryReturn(NID_APP, calleePid > 0, L"", E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Wrong process id: %d.", calleePid);
-
-       char appId[PATH_MAX] = {0, };
-       SysTryReturn(NID_APP, aul_app_get_appid_bypid(calleePid, appId, sizeof(appId)) == AUL_R_OK, L"", E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Object not found for %d.", calleePid);
+       String retVal = pBundleValue;
 
        String temp;
-       String retVal = appId;
        // [INFO] ugly code for submode callee
        retVal.SubString(11, temp);
        if (temp == L"_AppControl")
@@ -614,17 +606,6 @@ _AppArg::GetCalleeAppId(void) const
 
 
 void
-_AppArg::SaveCalleeAppId(void)
-{
-       const AppId& appId = GetCalleeAppId();
-
-       std::unique_ptr<char[]> pVal(_StringConverter::CopyToCharArrayN(appId));
-
-       appsvc_add_data(__pBundle, OSP_K_CALLEE_APPID, pVal.get());
-}
-
-
-void
 _AppArg::AddListFromBundle(ArrayList* pList, bundle* bk, const char* key)
 {
        bundle* pBundle = bk;
@@ -1180,16 +1161,8 @@ _AppArg::GetRequestIdFromBundle(bundle* pBundle)
 result
 _AppArg::UpdateWindowHandle(bundle* pBundle, long handle)
 {
-       if (handle == -1)
-       {
-               SysLog(NID_APP, "Invalid window handle.");
-               return E_SUCCESS;
-       }
-
-       char handleName[32] = {0, };
-       snprintf(handleName, 32, "%ld", handle);
+       appsvc_allow_transient_app(pBundle, handle);
 
-       bundle_add(pBundle, BUNDLE_KEY_WINDOW, handleName);
        SysLog(NID_APP, "Window Handle 0x%x added.", handle);
 
        return E_SUCCESS;
index 13078df..dfeb082 100755 (executable)
@@ -404,7 +404,7 @@ _AppControlImpl::AppControlCbLegacy(void* data, _AppArg* pArg, _AppArg* pResArg,
 
        String oId;
 
-       AppId provider = pResArg->GetValue(OSP_K_CALLEE_APPID);
+       AppId provider = pResArg->GetCalleeAppId();
 
        const char* p = appsvc_get_operation(inb);
        if (p)
@@ -469,7 +469,7 @@ _AppControlImpl::AppControlCb(void* data, _AppArg* pArg, _AppArg* pResArg, servi
 
        String oId;
 
-       AppId provider = pResArg->GetValue(OSP_K_CALLEE_APPID);
+       AppId provider = pResArg->GetCalleeAppId();
 
        const char* p = appsvc_get_operation(inb);
        if (p)
index de50e3f..3d48a30 100755 (executable)
@@ -311,9 +311,6 @@ LaunchResultCb(bundle* b, int request_code, appsvc_result_val res, void* data)
        result r = pAppArg->Construct(b);
        SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] AppControl event argument creation failure.", GetErrorMessage(r));
 
-       // save callee appId ASAP
-       pAppArg->SaveCalleeAppId();
-
        pArg = new (std::nothrow) _AppControlEventArg(request_code, pAppArg, res);
        SysTryCatch(NID_APP, pArg != null, r = E_OUT_OF_MEMORY, r, "[E_OUT_OF_MEMORY] AppControl event argument creation failure.");
 
index 88a0482..338c5be 100644 (file)
@@ -44,7 +44,7 @@
 #include <FOspConfig.h>
 
 
-#define LOG_IO_TAG  "IO_LOG"
+#define LOG_IO_TAG  "LOADER"
 #define MAX_APPID   20
 #define MAX_APP_EXECUTABLE_NAME        230
 #define MAX_PACKAGE_NAME       100
@@ -466,7 +466,7 @@ main(int argc, char* pArgv[])
        int fd = GetDirFdFromPath(pArgv[0]);
        if (fd == -1)
        {
-               LOG(LOG_DEBUG, LOG_IO_TAG, "Tizen::Io, %s, %d > Failed to open path.", __func__, __LINE__);
+               LOG(LOG_DEBUG, LOG_IO_TAG, "Tizen::Io, %s, %d > Failed to open path [%d][%s].", __func__, __LINE__, getpid(), strerror(errno));
                return -1;
        }
 
index f834edd..8753d82 100755 (executable)
@@ -58,7 +58,6 @@ enum _DataControlRequestType
        _DATACONTROL_REQUEST_TYPE_MAP_DELETE
 };
 
-#define OSP_K_CALLER_TYPE   "__OSP_CALLER_TYPE__"
 #define OSP_K_LAUNCH_TYPE   "__OSP_LAUNCH_TYPE__"
 #define OSP_K_ARG           "__OSP_ARGS__"
 #define OSP_K_COND          "__OSP_COND_NAME__"
@@ -67,7 +66,6 @@ enum _DataControlRequestType
 #define OSP_K_APPCONTROL_INTERNAL_OPERATION "__OSP_APPCONTROL_INTERNAL_INTERNAL_OPERATION__"
 #define OSP_K_DATACONTROL_PROVIDER      "__OSP_DATACONTROL_PROVIDER__"
 #define OSP_K_DATACONTROL_REQUEST_TYPE  "__OSP_DATACONTROL_REQUEST_TYPE__"
-#define OSP_K_CALLEE_APPID     "__OSP_CALLEE_APPID__"
 
 /**
  * @class       _AppArg
@@ -131,8 +129,6 @@ public:
 
        AppId GetCalleeAppId(void) const;
 
-       void SaveCalleeAppId(void);
-
        void Print() const
        {
                Print(__pBundle);