fix appcontrol result behavior from service callee
[platform/framework/native/appfw.git] / src / app / FApp_AppArg.cpp
index 9109aad..67ffb46 100644 (file)
 #include <FBaseInteger.h>
 #include <FBaseColArrayList.h>
 #include <FBaseColHashMap.h>
+#include <FBaseByteBuffer.h>
 #include <FBaseUtilStringTokenizer.h>
-
 #include <FBaseSysLog.h>
+
 #include <FBase_StringConverter.h>
 
 #include "FApp_MapDataControlImpl.h"
@@ -70,10 +71,15 @@ 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 OSP_V_VERSION_2_1_0_3[] = "ver_2.1.0.3";
+
 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_";
 static const char BUNDLE_KEY_PREFIX_UG[] = "__UG_";
+
+static const char OSP_K_SUBMODE_CALLEE[] = "__OSP_SUB_CALLEE__";
+static const char OSP_K_SERVICE_CALLEE[] = "__OSP_SERVICE_CALLEE__";
+
 const char TIZEN_NOTIFICATION_DATA[] = "http://tizen.org/appcontrol/data/notification";
 const wchar_t LEGACY_OPERATION_MAIN[] = L"osp.operation.MAIN";
 
@@ -1050,21 +1056,10 @@ _AppArg::CreateBundleFromSvc(void* svc)
 bundle*
 _AppArg::GetBundleFromSvc(void* svc)
 {
-       struct DummyS
-       {
-               int dummy1;
-               int dummy2;
-               bundle* pData;
-       };
+       bundle* pBundle = NULL;
+       int ret = service_to_bundle(static_cast<service_h>(svc), &pBundle);
 
-       DummyS* pDummy = static_cast<DummyS*>(svc);
-
-       if (pDummy && pDummy->pData)
-       {
-               return pDummy->pData;
-       }
-
-       return NULL;
+       return (ret == SERVICE_ERROR_NONE) ? pBundle : NULL;
 }
 
 
@@ -1160,12 +1155,22 @@ bool
 _AppArg::IsSubMode(bundle* pBundle)
 {
        const char* p = appsvc_get_data(pBundle, OSP_K_SUBMODE_CALLEE);
-       if (p && (strncmp(p, "1", sizeof(char)) == 0))
-       {
-               return true;
-       }
+       return (p && (strncmp(p, "1", sizeof(char)) == 0));
+}
 
-       return false;
+
+void
+_AppArg::UpdateServiceApp(bundle* pBundle)
+{
+       appsvc_add_data(pBundle, OSP_K_SERVICE_CALLEE, "1");
+}
+
+
+bool
+_AppArg::IsServiceApp(bundle* pBundle)
+{
+       const char* p = appsvc_get_data(pBundle, OSP_K_SERVICE_CALLEE);
+       return (p && (strncmp(p, "1", sizeof(char)) == 0));
 }