X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fapp%2FFApp_AppArg.cpp;h=918376083e31d42d073aa8a05be5b5267d3ae083;hb=27f1388665067f69d5eb64e0cae6bb5f4250beec;hp=40567ac8d6c1b82bb5d90f28741f393642803134;hpb=f35aaec65fcf10d247f9b1bb74c36e75f7cf2fa7;p=platform%2Fframework%2Fnative%2Fappfw.git diff --git a/src/app/FApp_AppArg.cpp b/src/app/FApp_AppArg.cpp old mode 100644 new mode 100755 index 40567ac..9183760 --- a/src/app/FApp_AppArg.cpp +++ b/src/app/FApp_AppArg.cpp @@ -1,5 +1,4 @@ // -// Open Service Platform // Copyright (c) 2012 Samsung Electronics Co., Ltd. // // Licensed under the Apache License, Version 2.0 (the License); @@ -71,6 +70,7 @@ 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 OSP_V_VERSION_2_1_0_2[] = "ver_2.1.0.2"; 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_"; @@ -140,6 +140,16 @@ _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(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(); @@ -331,7 +341,7 @@ _AppArg::GetArgMapN(void) const return null; } - ArrayList* pList = _AppMessageImpl::GetValueArray(__pBundle, OSP_K_ARG); + ArrayList* pList = _AppMessageImpl::GetValueArrayN(__pBundle, OSP_K_ARG); if (pList) { pHashMap->Add(new (std::nothrow) String(TIZEN_APPCONTROL_DATA_LEGACY), pList); @@ -420,6 +430,26 @@ BundleIterFnCb(const char* pKey, const int type, const bundle_keyval_t* pVal, vo } } break; + case BUNDLE_TYPE_BYTE: + bundle_keyval_get_basic_val(const_cast(pVal), reinterpret_cast(&pStr), &size); + + SysLog(NID_IO, "Bundle byte value = %s, size = %d", pStr, size); + + if (pStr) + { + ByteBuffer* pBuffer = new (std::nothrow) ByteBuffer(); + SysTryLog(NID_IO, pBuffer != null, "The memory is insufficient."); + result r = pBuffer->Construct(size); + SysTryLog(NID_IO, r == E_SUCCESS, "Constructing pBuffer is failed."); + + r = pBuffer->SetArray((const byte*)pStr, 0, size); + SysTryLog(NID_IO, r == E_SUCCESS, "SetArray()for ByteBuffer is failed."); + + pBuffer->Flip(); + + pMap->Add(new (std::nothrow) String(pKey), pBuffer); + } + break; default: SysLog(NID_APP, "Invalid type for %s : %d", pKey, type); break; @@ -691,6 +721,10 @@ _AppArg::AddStrMap(bundle* b, const IMap* pMap) else if (typeid(*pObj) == typeid(const ByteBuffer)) { SysLog(NID_APP, "ByteBuffer type"); + const ByteBuffer* pBuffer = static_cast(pObj); + + std::unique_ptr pBundleKey(_StringConverter::CopyToCharArrayN(*pKey)); + bundle_add_byte(b, pBundleKey.get(), pBuffer->GetPointer(), pBuffer->GetLimit()); } } } @@ -936,13 +970,20 @@ _AppArg::CreateAppControlArg(bundle* b, const _AppControlImpl& ac, const IList* result -_AppArg::CreateAppControlArg(bundle* b, const _AppControlImpl& ac, const String* pUriData, const String* pMimeType, const IMap* pList) +_AppArg::CreateAppControlArg(bundle* b, const _AppControlImpl& ac, const String* pUriData, const String* pMimeType, const IMap* pMap) +{ + return CreateAppControlArg(b, ac._opId, pUriData, pMimeType, pMap); +} + + +result +_AppArg::CreateAppControlArg(bundle* b, const String& oId, const String* pUriData, const String* pMimeType, const IMap* pMap) { SysAssertf(b != null, "Valid bundle should be supplied"); bundle* pb = b; - std::unique_ptr pOperation(_StringConverter::CopyToCharArrayN(ac._opId)); + std::unique_ptr pOperation(_StringConverter::CopyToCharArrayN(oId)); if (pOperation.get()) { appsvc_set_operation(pb, pOperation.get()); @@ -966,7 +1007,7 @@ _AppArg::CreateAppControlArg(bundle* b, const _AppControlImpl& ac, const String* } } - AddStrMap(pb, pList); + AddStrMap(pb, pMap); bundle_add(pb, OSP_K_LAUNCH_TYPE, OSP_V_LAUNCH_TYPE_APPCONTROL); @@ -989,6 +1030,7 @@ _AppArg::CreateSqlDataControlArg(bundle* b, const _SqlDataControlImpl& dc, _Data char dataControlRequestType[MAX_LEN_DATA_CONTROL_REQ_TYPE] = {0, }; snprintf(dataControlRequestType, MAX_LEN_DATA_CONTROL_REQ_TYPE, "%d", static_cast(requestType)); bundle_add(b, OSP_K_DATACONTROL_REQUEST_TYPE, dataControlRequestType); + bundle_add(b, OSP_K_DATACONTROL_PROTOCOL_VERSION, OSP_V_VERSION_2_1_0_2); std::unique_ptr pProvider(_StringConverter::CopyToCharArrayN(dc.__providerId)); if (pProvider) @@ -1013,6 +1055,7 @@ _AppArg::CreateMapDataControlArg(bundle* b, const _MapDataControlImpl& dc, _Data char dataControlRequestType[MAX_LEN_DATA_CONTROL_REQ_TYPE] = {0, }; snprintf(dataControlRequestType, MAX_LEN_DATA_CONTROL_REQ_TYPE, "%d", static_cast < int >(requestType)); bundle_add(b, OSP_K_DATACONTROL_REQUEST_TYPE, dataControlRequestType); + bundle_add(b, OSP_K_DATACONTROL_PROTOCOL_VERSION, OSP_V_VERSION_2_1_0_2); std::unique_ptr pProvider(_StringConverter::CopyToCharArrayN(dc.__providerId)); if (pProvider) @@ -1121,7 +1164,12 @@ _AppArg::UpdateAppId(bundle* b, const AppId& appId) std::unique_ptr pId(_StringConverter::CopyToCharArrayN(appId)); SysTryReturnVoidResult(NID_APP, pId != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Converting %ls failed.", appId.GetPointer()); - bundle_add(b, OSP_K_APPID, pId.get()); + int res = bundle_add(b, OSP_K_APPID, pId.get()); + if (res < 0 && errno == EPERM) // key exists + { + bundle_del(b, OSP_K_APPID); + bundle_add(b, OSP_K_APPID, pId.get()); + } appsvc_set_appid(b, pId.get()); } @@ -1140,9 +1188,28 @@ _AppArg::UpdateRequestId(bundle* pBundle, int reqId) char buffer[32] = {0, }; snprintf(buffer, 32, "%d", reqId); - bundle_add(pBundle, OSP_K_REQUEST_ID, buffer); + int res = bundle_add(pBundle, OSP_K_REQUEST_ID, buffer); + if (res < 0 && errno == EPERM) // key exists + { + bundle_del(pBundle, OSP_K_REQUEST_ID); + bundle_add(pBundle, OSP_K_REQUEST_ID, buffer); + } } +void +_AppArg::UpdateKeyValue(bundle* pBundle, const char* pKey, const String& value) +{ + SysTryReturnVoidResult(NID_APP, pBundle != null, E_INVALID_STATE, "[E_INVALID_STATE] Improper bundle state."); + + char pBuffer[128] = {0, }; + snprintf(pBuffer, 128, "%ls", value.GetPointer()); + int res = bundle_add(pBundle, pKey, pBuffer); + if (res < 0 && errno == EPERM) // key exists + { + bundle_del(pBundle, pKey); + bundle_add(pBundle, pKey, pBuffer); + } +} int _AppArg::GetRequestIdFromBundle(bundle* pBundle) @@ -1196,7 +1263,7 @@ BundlePrintIterFnCb(const char* pKey, const int type, const bundle_keyval_t* pVa bundle_keyval_get_basic_val(const_cast(pVal), reinterpret_cast(&pStr), &size); if (pStr) { - SysLog(NID_APP, "(%s, %s)", pKey, pStr); + SysSecureLog(NID_APP, "(%s, %s)", pKey, pStr); } break; default: