* @brief This is the implementation for the %_DataControlProviderManagerImpl class.
*/
+#include <new>
#include <unique_ptr.h>
#include <FBaseDataType.h>
#include <FBaseLongLong.h>
#include <FBaseColArrayList.h>
#include <FBaseColIList.h>
+#include <FBaseSysLog.h>
#include <FBaseErrors.h>
#include <FAppAppManager.h>
#include <FAppSqlDataControl.h>
#include <FAppMapDataControl.h>
#include <FAppDataControlProviderManager.h>
+#include <FIoFile.h>
-#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
#include <FIo_DataControlResultSetImpl.h>
#include "FApp_Aul.h"
#include "FApp_MapDataControlImpl.h"
#include "FApp_DataControlProviderManagerImpl.h"
+using namespace std;
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
using namespace Tizen::Io;
IDbEnumerator* pDbEnum, IList* pResultValueList, long long insertRowId, bool providerResult, const String* pErrorMsg)
{
ArrayList* pList = null;
- String appId;
+ String callerAppId;
+ int callerPid = -1;
+ String version;
String reqType;
int type = 0;
_DataControlRequestType requestType = _DATACONTROL_REQUEST_TYPE_UNDEFINED;
}
}
- appId = arg.GetCallerAppId();
+ callerAppId = arg.GetCallerAppId();
+ callerPid = arg.GetCallerPid();
+ version = arg.GetValue(OSP_K_DATACONTROL_PROTOCOL_VERSION);
callerReqId = arg.GetValue(OSP_K_REQUEST_ID);
providerId = arg.GetValue(OSP_K_DATACONTROL_PROVIDER);
pDataId = dynamic_cast< String* >(pList->GetAt(0)); // request list[0]
SysTryCatch(NID_APP, pDataId, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid result object");
- SysLog(NID_APP, "[DC_PROV_SEND] > app: %ls, requestType: %d, callerReq: %ls, provider: %ls, data: %ls",
- appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(), pDataId->GetPointer());
+ SysLog(NID_APP, "[DC_PROV_SEND] > caller app: %ls, caller proc: %d, version: %ls requestType: %d, callerReq: %ls, provider: %ls, data: %ls",
+ callerAppId.GetPointer(), callerPid, version.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(), pDataId->GetPointer());
// Serializes result
pResultArgList = new (std::nothrow) ArrayList();
{
if (pDbEnum)
{
- std::unique_ptr<_DataControlResultSetImpl> pResultSet(new (std::nothrow) _DataControlResultSetImpl(reqId));
+ unique_ptr<_DataControlResultSetImpl> pResultSet(new (std::nothrow) _DataControlResultSetImpl(reqId));
SysTryCatch(NID_APP, pResultSet, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] The memory is insufficient.");
"[E_SYSTEM] The method cannot proceed due to a severe system error.");
String tempFilePath(_DATACONTROL_RESULTSET_DIR);
- tempFilePath.Append(appId);
+ tempFilePath.Append(callerAppId);
tempFilePath.Append(callerReqId);
pTempFilePath = new (std::nothrow) String(tempFilePath);
}
SysTryCatch(NID_APP, pResultCount, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] The memory was insufficient.");
pResultArgList->Add(*pResultCount); // result list[2]
+ SysLog(NID_APP, "[DC_PROV_SEND] result count: %ls", resultCount.GetPointer());
long long argSize = 0;
- for (int i = currentoffset; i < num; i++)
+ if (addItemCount > 0)
{
- String* pTempValue = dynamic_cast< String* >(pResultValueList->GetAt(i));
- SysTryCatch(NID_APP, pTempValue != null, r = E_INVALID_ARG, E_INVALID_ARG,
- "[E_INVALID_ARG] The specified pResultValueList parameter should be String class.");
-
- pResultValue = new (std::nothrow) String(*pTempValue);
- SysTryCatch(NID_APP, pResultValue, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
- "[E_OUT_OF_MEMORY] The memory was insufficient.");
- pResultArgList->Add(*pResultValue); // list[3] ~
- argSize += pResultValue->GetLength() * sizeof(wchar_t);
+ if (version == L"ver_2.1.0.1")
+ {
+ String tempFilePath(_DATACONTROL_RESULTSET_DIR);
+ tempFilePath.Append(callerAppId);
+ tempFilePath.Append(callerReqId);
+ pTempFilePath = new (std::nothrow) String(tempFilePath);
+ pResultArgList->Add(*pTempFilePath); // result list[3]
+ SysLog(NID_APP, "[DC_PROV_SEND] protocol version: %ls, path: %ls", version.GetPointer(), pTempFilePath->GetPointer());
+
+ unique_ptr< File > pFile(new (std::nothrow) File());
+ SysTryCatch(NID_APP, pFile != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ r = pFile->Construct(*pTempFilePath, L"w+", true);
+ SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Failed to create temp file (%ls) for result set.",
+ GetErrorMessage(r), pTempFilePath->GetPointer());
+
+ for (int i = currentoffset; i < num; ++i)
+ {
+ String* pValue = dynamic_cast< String* >(pResultValueList->GetAt(i));
+ SysTryCatch(NID_APP, pValue != null, r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The specified pResultValueList parameter should be String class.");
+
+ int length = pValue->GetLength();
+ r = pFile->Write(&length, sizeof(int)); // data length
+ SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM, "[%s] Failed to write result.", GetErrorMessage(r));
+
+ unique_ptr< char[] > pData(_StringConverter::CopyToCharArrayN(*pValue));
+ SysTryCatch(NID_APP, pData != null, , GetLastResult(), "[%s] Invalid result value",
+ GetErrorMessage(GetLastResult()));
+
+ r = pFile->Write(pData.get(), strlen(pData.get())); // data
+ SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM, "[E_SYSTEM] Failed to write result.", GetErrorMessage(r));
+ argSize += pValue->GetLength() * sizeof(wchar_t);
+ }
+ pFile->Flush();
+ }
+ else
+ {
+ SysLog(NID_APP, "[DC_PROV_SEND] protocol version: none");
+ for (int i = currentoffset; i < num; ++i)
+ {
+ String* pValue = dynamic_cast< String* >(pResultValueList->GetAt(i));
+ SysTryCatch(NID_APP, pValue != null, r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The specified pResultValueList parameter should be String class.");
+
+ pResultValue = new (std::nothrow) String(*pValue);
+ SysTryCatch(NID_APP, pResultValue, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory was insufficient.");
+ pResultArgList->Add(*pResultValue); // list[3] ~
+ argSize += pValue->GetLength() * sizeof(wchar_t);
+ }
+ }
}
SysTryCatch(NID_APP, argSize <= _MAX_ARGUMENT_SIZE, r = E_MAX_EXCEEDED, E_MAX_EXCEEDED,
"[E_MAX_EXCEEDED] The size of sending argument (%d) exceeds the maximum limit.", argSize);
resultArg.UpdateKeyValue(OSP_K_DATACONTROL_REQUEST_TYPE, reqType);
resultArg.UpdateKeyValue(OSP_K_DATACONTROL_PROVIDER, providerId);
resultArg.UpdateKeyValue(OSP_K_DATACONTROL_DATA, *pDataId);
+ resultArg.UpdateKeyValue(OSP_K_DATACONTROL_PROTOCOL_VERSION, version);
//resultArg.Print();
r = _Aul::SendResult(resultArg.GetBundle(), static_cast< appsvc_result_val >(0));
#include <FBaseInteger.h>
#include <FBaseString.h>
#include <FBaseRtIEventArg.h>
+#include <FIoFile.h>
#include <FAppMapDataControl.h>
#include <FAppIMapDataControlResponseListener.h>
_MapDataControlImpl::MapDataControlCallback(void* data, _AppArg* pArg, _AppArg* pResArg, service_result_e res, int prop, int option)
{
ArrayList* pResultList = null;
+ String version;
String* pResult = null;
String* pProviderId = null;
String* pDataId = null;
String* pErrorMessage = null;
String* pErrorMsg = null;
String* pResultCount = null;
- String* pValue = null;
+ String* pPath = null;
ArrayList* pResultValueList = null;
int resultCount = 0;
int requestType = 0;
SysTryCatch(NID_APP, pDataId, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] The memory is insufficient.");
- SysLog(NID_APP, "[DC_CALLER_RECV] provider result: %ld, requestType: %d, req: %d, provider: %ls, data: %ls, errorMsg: %ls ",
- providerRes, requestType, reqId, pProviderId->GetPointer(), pDataId->GetPointer(), pErrorMsg->GetPointer());
+ version = pResArg->GetValue(OSP_K_DATACONTROL_PROTOCOL_VERSION);
+
+ SysLog(NID_APP, "[DC_CALLER_RECV] version: %ls, provider result: %ld, requestType: %d, req: %d, provider: %ls, data: %ls, errorMsg: %ls",
+ version.GetPointer(), providerRes, requestType, reqId, pProviderId->GetPointer(), pDataId->GetPointer(), pErrorMsg->GetPointer());
switch (static_cast< _DataControlRequestType >(requestType))
{
case _DATACONTROL_REQUEST_TYPE_MAP_QUERY:
{
- pResultValueList = new (std::nothrow) ArrayList();
+ pResultValueList = new (std::nothrow) ArrayList(SingleObjectDeleter);
SysTryCatch(NID_APP, pResultValueList, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] The memory is insufficient.");
if (providerResult == true)
{
pResultCount = dynamic_cast< String* >(pResultList->GetAt(2)); // result list[2]
- if (pResultCount == null)
- {
- SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] invalid result");
- pResultValueList->RemoveAll(true);
- delete pResultValueList;
- goto CATCH;
- }
+ SysTryCatch(NID_APP, pResultCount, delete pResultValueList, E_SYSTEM, "[E_SYSTEM] invalid result");
Integer::Parse(*pResultCount, resultCount);
+ SysLog(NID_APP, "[DC_CALLER_RECV] result count: %d", resultCount);
- int index = 3;
- while (resultCount)
+ if (resultCount > 0)
{
- pValue = dynamic_cast< String* >(pResultList->GetAt(index));
- if (pValue == null)
+ if (version == L"ver_2.1.0.1")
{
- SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] invalid result");
- pResultValueList->RemoveAll(true);
- delete pResultValueList;
- goto CATCH;
+ pPath = dynamic_cast< String* >(pResultList->GetAt(3)); // result list[3]
+ SysTryCatch(NID_APP, pPath, delete pResultValueList, E_SYSTEM, "[E_SYSTEM] invalid result");
+ SysLog(NID_APP, "[DC_CALLER_RECV] path: %ls", pPath->GetPointer());
+
+ unique_ptr< File > pFile(new (std::nothrow) File());
+ SysTryCatch(NID_APP, pFile, delete pResultValueList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ r = pFile->Construct(*pPath, "r");
+ SysTryCatch(NID_APP, !IsFailed(r), delete pResultValueList, r, "[%s] Failed to open result set (%ls)",
+ GetErrorMessage(r), pPath->GetPointer());
+
+ while (resultCount)
+ {
+ int length = 0;
+ int ret = pFile->Read(&length, sizeof(int));
+ SysTryCatch(NID_APP, ret, delete pResultValueList, E_SYSTEM,
+ "[E_SYSTEM] Failed to read data from the result set of data control provider.");
+
+ char* pValue = new (std::nothrow) char[length + 1];
+ SysTryCatch(NID_APP, pValue, delete pResultValueList, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ ret = pFile->Read(pValue, length);
+ if (ret == 0)
+ {
+ SysLogException(NID_APP, E_SYSTEM,
+ "[E_SYSTEM] Failed to read data from the result set of data control provider.");
+ delete pResultValueList;
+ delete[] pValue;
+ goto CATCH;
+ }
+ pValue[length] = '\0';
+
+ pResultValueList->Add(new (std::nothrow) String(pValue));
+ delete[] pValue;
+ --resultCount;
+ }
}
+ else
+ {
+ int index = 3;
+ while (resultCount)
+ {
+ String* pValue = dynamic_cast< String* >(pResultList->GetAt(index)); // result list[3] ~
+ SysTryCatch(NID_APP, pValue, delete pResultValueList, E_SYSTEM, "[E_SYSTEM] invalid result");
+
+ pResultValueList->Add((new (std::nothrow) String(*pValue)));
+ --resultCount;
+ ++index;
+ }
+ }
+ }
- pResultValueList->Add(*(new (std::nothrow) String(*pValue)));
- resultCount--;
- index++;
+ if (pPath)
+ {
+ r = File::Remove(*pPath);
+ SysTryLog(NID_APP, !IsFailed(r), "Failed to remove result: %ls", pPath->GetPointer());
}
}