* @exception E_ILLEGAL_ACCESS Either of the following conditions has occurred: @n
* - Access is denied due to insufficient permission.
* - The application using this method is not signed with the same certificate of provider application. @b Since: @b 2.1
- * @exception E_MAX_EXCEEDED Either of the following conditions has occurred:
+ * @exception E_MAX_EXCEEDED Either of the following conditions has occurred:
* - The size of sending buffer has exceeded the maximum limit.
* - The number of sending requests has exceeded the maximum limit.
* @exception E_SYSTEM A system error has occurred.
* @exception E_ILLEGAL_ACCESS Either of the following conditions has occurred: @n
* - Access is denied due to insufficient permission.
* - The application using this method is not signed with the same certificate of provider application. @b Since: @b 2.1
- * @exception E_MAX_EXCEEDED Either of the following conditions has occurred:
+ * @exception E_MAX_EXCEEDED Either of the following conditions has occurred:
* - The size of sending buffer has exceeded the maximum limit.
* - The number of sending requests has exceeded the maximum limit.
* @exception E_SYSTEM A system error has occurred.
* @remarks If the value specified in the @c insertMap is string, the value must be wrapped in
* single quotes. Otherwise it is not needed to wrap the numeric value in single quotes.
* For more information on the SQL statement, see SQLite SQL documents.
- * @remarks The recommended data size is under 16KB because severe system performance degradation may occur for large messages. @c E_MAX_EXCEEDED may be returned for messages over 16KB size.
+ * @remarks The recommended data size is under 1MB because severe system performance degradation may occur for large messages. @c E_MAX_EXCEEDED may be returned for messages over 1MB size.
*/
result Insert(const Tizen::Base::String& dataId, const Tizen::Base::Collection::IMap& insertMap, RequestId& reqId);
* @exception E_ILLEGAL_ACCESS Either of the following conditions has occurred: @n
* - Access is denied due to insufficient permission.
* - The application using this method is not signed with the same certificate of provider application. @b Since: @b 2.1
- * @exception E_MAX_EXCEEDED Either of the following conditions has occurred:
+ * @exception E_MAX_EXCEEDED Either of the following conditions has occurred:
* - The size of sending buffer has exceeded the maximum limit.
* - The number of sending requests has exceeded the maximum limit.
* @exception E_SYSTEM A system error has occurred.
* @remarks If the value specified in the @c pWhere or @c updateMap is string, the value must be wrapped in
* single quotes. Otherwise it is not needed to wrap the numeric value in single quotes.
* For more information on the SQL statement, see SQLITE SQL documents.
- * @remarks The recommended data size is under 16KB because severe system performance degradation may occur for large messages. @c E_MAX_EXCEEDED may be returned for messages over 16KB size.
+ * @remarks The recommended data size is under 1MB because severe system performance degradation may occur for large messages. @c E_MAX_EXCEEDED may be returned for messages over 1MB size.
*/
result Update(const Tizen::Base::String& dataId, const Tizen::Base::Collection::IMap& updateMap,
const Tizen::Base::String* pWhere, RequestId& reqId);
* @exception E_ILLEGAL_ACCESS Either of the following conditions has occurred: @n
* - Access is denied due to insufficient permission.
* - The application using this method is not signed with the same certificate of provider application. @b Since: @b 2.1
- * @exception E_MAX_EXCEEDED Either of the following conditions has occurred:
+ * @exception E_MAX_EXCEEDED Either of the following conditions has occurred:
* - The size of sending buffer has exceeded the maximum limit.
* - The number of sending requests has exceeded the maximum limit.
* @exception E_SYSTEM A system error has occurred.
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_1[] = "ver_2.1.0.1";
+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_";
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<char[]> pProvider(_StringConverter::CopyToCharArrayN(dc.__providerId));
if (pProvider)
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_1);
+ bundle_add(b, OSP_K_DATACONTROL_PROTOCOL_VERSION, OSP_V_VERSION_2_1_0_2);
std::unique_ptr<char[]> pProvider(_StringConverter::CopyToCharArrayN(dc.__providerId));
if (pProvider)
using namespace Tizen::Base::Utility;
using namespace Tizen::Io;
-//extern const char* _DATACONTROL_RESULTSET_DIR;
-
namespace Tizen { namespace App
{
String appId;
String reqType;
String providerId;
+ String version;
String* pDataId = null;
String callerReqId;
String* pColumnCount = null;
String* pErrorMsg = null;
String* pNo = null;
String* pCount = null;
+ String* pTmpPath = null;
String empty(L"NULL");
_AppArg resultArg;
int type = 0;
Integer::Parse(reqType, type);
requestType = static_cast< _DataControlRequestType >(type);
+ version = arg.GetValue(OSP_K_DATACONTROL_PROTOCOL_VERSION);
callerReqId = arg.GetValue(OSP_K_REQUEST_ID);
providerId = arg.GetValue(OSP_K_DATACONTROL_PROVIDER);
case _DATACONTROL_REQUEST_TYPE_SQL_INSERT:
SysLog(NID_APP, "[DC_PROV_RECV] SqlDataControl INSERT");
- // request list[1]: insert column count
+ // request list[1]: inserted column count
pColumnCount = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_COLUMNCOUNT));
SysTryCatch(NID_APP, pColumnCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
SysTryReturnVoidResult(NID_APP, pInsertMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
pInsertMap->Construct();
- i = 0;
- index = 0;
- while (i < columnCount * 2) // request list[2]: column-value pairs
+ SysLog(NID_APP, "[DC_PROV_RECV] version: %ls", version.GetPointer());
+ if (version == L"ver_2.1.0.2")
{
- pColumn = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_INSERTMAP + i++));
- SysTryCatch(NID_APP, pColumn != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
- SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %ls", index, pColumn->GetPointer());
+ pTmpPath = dynamic_cast< String* >(pList->GetAt(2)); // request list[2]: path
+ SysTryCatch(NID_APP, pTmpPath != null, , E_SYSTEM, "[E_SYSTEM] invalid request");
+ SysLog(NID_APP, "[DC_PROV_RECV] request: %ls", pTmpPath->GetPointer());
- pValue = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_INSERTMAP + i++));
- SysTryCatch(NID_APP, pValue != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
- SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %ls", index, pValue->GetPointer());
+ File request;
+ r = request.Construct(*pTmpPath, "r");
+ SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM, "[%s] Failed to open request (%ls).",
+ GetErrorMessage(r), pTmpPath->GetPointer());
- pInsertMap->Add(*(new String(*pColumn)), *(new String(*pValue)));
- index++;
+ for (i = 0; i < columnCount; ++i) // column-value pairs
+ {
+ int length = -1;
+ int ret = request.Read(&length, sizeof(int));
+ SysTryCatch(NID_APP, ret > 0, , E_SYSTEM, "[%s] Failed to receive request.",
+ GetErrorMessage(GetLastResult()));
+
+ char* pColumn = new (std::nothrow) char[length + 1];
+ ret = request.Read(pColumn, length);
+ SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
+ GetErrorMessage(GetLastResult()));
+ pColumn[length] = '\0';
+ SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %s", i, pColumn);
+
+ ret = request.Read(&length, sizeof(int));
+ SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
+ GetErrorMessage(GetLastResult()));
+
+ char* pValue = new (std::nothrow) char[length + 1];
+ ret = request.Read(pValue, length);
+ if (ret == 0)
+ {
+ SysLogException(NID_APP, E_SYSTEM, "[%s] Failed to receive request.", GetErrorMessage(GetLastResult()));
+ delete pColumn;
+ delete pValue;
+ }
+ pValue[length] = '\0';
+ SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %s", i, pValue);
+
+ pInsertMap->Add(new (std::nothrow) String(pColumn), new (std::nothrow) String(pValue));
+ delete pColumn;
+ delete pValue;
+ }
+ }
+ else
+ {
+ i = 0;
+ index = 0;
+ while (i < columnCount * 2) // request list: column-value pairs
+ {
+ pColumn = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_INSERTMAP + i++));
+ SysTryCatch(NID_APP, pColumn != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
+ SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %ls", index, pColumn->GetPointer());
+
+ pValue = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_INSERTMAP + i++));
+ SysTryCatch(NID_APP, pValue != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
+ SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %ls", index, pValue->GetPointer());
+
+ pInsertMap->Add(new (std::nothrow) String(*pColumn), new (std::nothrow) String(*pValue));
+ index++;
+ }
+ }
+
+ if (pTmpPath)
+ {
+ r = File::Remove(*pTmpPath);
+ SysTryLog(NID_APP, !IsFailed(r), "Failed to remove result: %ls", pTmpPath->GetPointer());
}
pSqlListener->OnSqlDataControlInsertRequestReceived(reqId, providerId, *pDataId, *pInsertMap);
SysTryReturnVoidResult(NID_APP, pUpdateMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
pUpdateMap->Construct();
- i = 0;
- index = 0;
- while (i < columnCount * 2) // request list[2]: column-value pairs
+ SysLog(NID_APP, "[DC_PROV_RECV] version: %ls", version.GetPointer());
+ if (version == L"ver_2.1.0.2")
{
- pColumn = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_UPDATEMAP + i++));
- SysTryCatch(NID_APP, pColumn != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
- SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %ls", index, pColumn->GetPointer());
+ pTmpPath = dynamic_cast< String* >(pList->GetAt(2)); // request list[2]: path
+ SysTryCatch(NID_APP, pTmpPath != null, , E_SYSTEM, "[E_SYSTEM] invalid request");
+ SysLog(NID_APP, "[DC_PROV_RECV] request: %ls", pTmpPath->GetPointer());
+
+ File request;
+ r = request.Construct(*pTmpPath, "r");
+ SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM, "[%s] Failed to open request (%ls).",
+ GetErrorMessage(r), pTmpPath->GetPointer());
- pValue = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_UPDATEMAP + i++));
- SysTryCatch(NID_APP, pValue != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
- SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %ls", index, pValue->GetPointer());
+ for (i = 0; i < columnCount; ++i) // column-value pairs
+ {
+ int length = -1;
+ int ret = request.Read(&length, sizeof(int));
+ SysTryCatch(NID_APP, ret > 0, , E_SYSTEM, "[%s] Failed to receive request.",
+ GetErrorMessage(GetLastResult()));
+
+ char* pColumn = new (std::nothrow) char[length + 1];
+ ret = request.Read(pColumn, length);
+ SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
+ GetErrorMessage(GetLastResult()));
+ pColumn[length] = '\0';
+ SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %s", i, pColumn);
+
+ ret = request.Read(&length, sizeof(int));
+ SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
+ GetErrorMessage(GetLastResult()));
+
+ char* pValue = new (std::nothrow) char[length + 1];
+ ret = request.Read(pValue, length);
+ if (ret == 0)
+ {
+ SysLogException(NID_APP, E_SYSTEM, "[%s] Failed to receive request.", GetErrorMessage(GetLastResult()));
+ delete pColumn;
+ delete pValue;
+ }
+ pValue[length] = '\0';
+ SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %s", i, pValue);
+
+ pUpdateMap->Add(new (std::nothrow) String(pColumn), new (std::nothrow) String(pValue));
+ delete pColumn;
+ delete pValue;
+ }
- pUpdateMap->Add(*(new String(*pColumn)), *(new String(*pValue)));
- index++;
+ // request list: where clause
+ pWhere = dynamic_cast< String* >(pList->GetAt(3));
+ SysTryCatch(NID_APP, pWhere != null, , E_SYSTEM, "[E_SYSTEM] invalid request");
}
+ else
+ {
+ i = 0;
+ index = 0;
+ while (i < columnCount * 2) // request list: column-value pairs
+ {
+ pColumn = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_UPDATEMAP + i++));
+ SysTryCatch(NID_APP, pColumn != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
+ SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %ls", index, pColumn->GetPointer());
- // request list: where clause
- pWhere = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_UPDATEMAP + i));
- SysTryCatch(NID_APP, pWhere, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
+ pValue = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_UPDATEMAP + i++));
+ SysTryCatch(NID_APP, pValue != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
+ SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %ls", index, pValue->GetPointer());
+
+ pUpdateMap->Add(new (std::nothrow) String(*pColumn), new (std::nothrow) String(*pValue));
+ index++;
+ }
+
+ // request list: where clause
+ pWhere = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_UPDATEMAP + i));
+ SysTryCatch(NID_APP, pWhere, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
+ }
if (pWhere->Equals(empty) == true)
{
SysLog(NID_APP, "[DC_PROV_RECV] pWhere: %ls", pWhere->GetPointer());
}
+ if (pTmpPath)
+ {
+ r = File::Remove(*pTmpPath);
+ SysTryLog(NID_APP, !IsFailed(r), "Failed to remove result: %ls", pTmpPath->GetPointer());
+ }
+
pSqlListener->OnSqlDataControlUpdateRequestReceived(reqId, providerId, *pDataId, *pUpdateMap, pWhere);
SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, pUpdateMap: 0x%x, pWhere: 0x%x",
using namespace Tizen::Base::Utility;
using namespace Tizen::Io;
-//extern const char* _DATACONTROL_RESULTSET_DIR;
-
namespace
{
#include <cstdlib>
#include <pthread.h>
#include <typeinfo>
+#include <glib.h>
#include <FBaseInteger.h>
#include <FBaseSysLog.h>
_DataControlManager::_DataControlManager(void)
: __pDataControlRequestList(null)
+ , __uniqueId(-1)
{
__pDataControlRequestList = new (std::nothrow) HashMap(SingleObjectDeleter);
SysTryReturnVoidResult(NID_APP, __pDataControlRequestList != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
__pDataControlRequestList->Remove(reqId);
}
+int
+_DataControlManager::GetUniqueId(void)
+{
+ //++__uniqueId;
+ //__sync_fetch_and_add(&__uniqueId, 1);
+ g_atomic_int_inc(&__uniqueId);
+ return __uniqueId;
+}
+
}} // Tizen::App
void RemoveRequestInfo(Tizen::Base::Integer& reqId);
+ int GetUniqueId(void);
+
private:
_DataControlManager(void);
private:
static _DataControlManager* __pDataControlManagerInstance;
Tizen::Base::Collection::HashMap* __pDataControlRequestList;
+ int __uniqueId;
}; // _DataControlManager
using namespace Tizen::Base::Collection;
using namespace Tizen::Io;
-extern const char* _DATACONTROL_RESULTSET_DIR;
+extern const char* _DATACONTROL_RESULT_DIR;
namespace Tizen { namespace App
{
SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM,
"[E_SYSTEM] The method cannot proceed due to a severe system error.");
- String tempFilePath(_DATACONTROL_RESULTSET_DIR);
+ String tempFilePath(_DATACONTROL_RESULT_DIR);
tempFilePath.Append(callerAppId);
tempFilePath.Append(callerReqId);
pTempFilePath = new (std::nothrow) String(tempFilePath);
long long argSize = 0;
if (addItemCount > 0)
{
- if (version == L"ver_2.1.0.1")
+ if (version == L"ver_2.1.0.1" || version == L"ver_2.1.0.2")
{
- String tempFilePath(_DATACONTROL_RESULTSET_DIR);
+ String tempFilePath(_DATACONTROL_RESULT_DIR);
tempFilePath.Append(callerAppId);
tempFilePath.Append(callerReqId);
pTempFilePath = new (std::nothrow) String(tempFilePath);
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);
+ int length = strlen(pData.get());
+ r = pFile->Write(&length, sizeof(int)); // data length
+ SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM, "[%s] Failed to send result.", GetErrorMessage(r));
+
+ r = pFile->Write(pData.get(), length); // data
+ SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM, "[%s] Failed to send result.", GetErrorMessage(r));
}
pFile->Flush();
}
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);
}
}
- 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);
}
break;
}
if (resultCount > 0)
{
- if (version == L"ver_2.1.0.1")
+ if (version == L"ver_2.1.0.1" || version == L"ver_2.1.0.2")
{
pPath = dynamic_cast< String* >(pResultList->GetAt(3)); // result list[3]
SysTryCatch(NID_APP, pPath, delete pResultValueList, E_SYSTEM, "[E_SYSTEM] invalid result");
#include <FBaseColIMap.h>
#include <FBaseColIMapEnumerator.h>
#include <FBaseRtIEventArg.h>
+#include <FBaseSysLog.h>
#include <FIoFile.h>
+#include <FAppApp.h>
#include <FAppSqlDataControl.h>
#include <FAppISqlDataControlResponseListener.h>
-#include <FBaseSysLog.h>
-
+#include <FBase_StringConverter.h>
#include <FIo_DataControlResultSetEnumerator.h>
#include "FApp_AppControlManager.h"
#include "FApp_AppArg.h"
#include "FApp_DataControlManager.h"
+#define DATACONTROL_PROTOCOL_VER_2_1_0_2 // ver_2.1.0.2
+
using namespace std;
using namespace Tizen::Base;
static const int MAX_REQUEST_COUNT = 128;
static const int _MAX_ARGUMENT_SIZE = 16384; // 16KB
+static const int _MAX_REQUEST_ARGUMENT_SIZE = 1048576; // 1MB
+static const char* _DATACONTROL_REQUEST_DIR = "/tmp/osp/DataControlRequest/\0";
class _SqlDataControlEventArg
: public IEventArg
int columnCount = 0;
int id = 0;
int i = 0;
+ int uniqueId = -1;
+ File request;
+ IMapEnumerator* pMapEnum = null;
result r = E_SUCCESS;
SysLog(NID_APP, "[DC_CALLER_SEND] SqlDataControl INSERT");
columnCount = insertMap.GetCount();
SysTryReturnResult(NID_APP, columnCount > 0, E_INVALID_ARG, "The specified insertMap parameter is empty.");
- ArrayList* pArgList = new ArrayList();
+ ArrayList* pArgList = new (std::nothrow) ArrayList();
pArgList->Construct();
- pArgList->Add(*(new String(dataId))); // list(0): data ID
+ pArgList->Add(new (std::nothrow) String(dataId)); // list[0]: data ID
long long argSize = dataId.GetLength() * sizeof(wchar_t);
- pArgList->Add(*(new String(Integer::ToString(columnCount)))); // list(1): inserted column count
+ pArgList->Add(new (std::nothrow) String(Integer::ToString(columnCount))); // list[1]: inserted column count
SysLog(NID_APP, "[DC_CALLER_SEND] inserted column count: %d", columnCount);
- IMapEnumerator* pMapEnum = const_cast< IMap* >(&insertMap)->GetMapEnumeratorN();
- while (pMapEnum->MoveNext() == E_SUCCESS) // list(2): column-value pairs
+#ifdef DATACONTROL_PROTOCOL_VER_2_1_0_2
+ String tmpPath(_DATACONTROL_REQUEST_DIR);
+ tmpPath.Append(App::GetInstance()->GetAppId());
+
+ _DataControlManager* pDcMgr = _DataControlManager::GetInstance();
+ SysTryCatch(NID_APP, pDcMgr, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to get _DataControlManager instance.");
+ uniqueId = pDcMgr->GetUniqueId();
+
+ tmpPath.Append(uniqueId);
+ SysLog(NID_APP, "[DC_CALLER_SEND] request: %ls", tmpPath.GetPointer());
+
+ r = request.Construct(tmpPath, L"w+", true);
+ SysTryCatch(NID_APP, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[%s] Failed to create request (%ls).",
+ GetErrorMessage(r), tmpPath.GetPointer());
+
+ pArgList->Add(new (std::nothrow) String(tmpPath)); // list[2]: path
+#endif
+
+ pMapEnum = const_cast< IMap* >(&insertMap)->GetMapEnumeratorN();
+ while (pMapEnum->MoveNext() == E_SUCCESS) // list: column-value pairs
{
+#ifdef DATACONTROL_PROTOCOL_VER_2_1_0_2
+ int length = 0;
+ String* pColumn = null;
+ String* pValue = null;
+ unique_ptr< char[] > pData(null);
+
+ pColumn = dynamic_cast< String* >(pMapEnum->GetKey());
+ SysTryCatch(NID_APP, pColumn != null, r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The object is not String class.");
+
+ pData.reset(_StringConverter::CopyToCharArrayN(*pColumn));
+ SysTryCatch(NID_APP, pData != null, r = GetLastResult(), GetLastResult(), "[%s] Invalid request value",
+ GetErrorMessage(GetLastResult()));
+
+ length = strlen(pData.get());
+ r = request.Write(&length, sizeof(int)); // data length
+ SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM, "[%s] Failed to send request.", GetErrorMessage(r));
+
+ r = request.Write(pData.get(), length); // data
+ SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM, "[%s] Failed to send request.", GetErrorMessage(r));
+
+ pValue = dynamic_cast< String* >(pMapEnum->GetValue());
+ SysTryCatch(NID_APP, pValue != null, r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The object is not String class.");
+
+ pData.reset(_StringConverter::CopyToCharArrayN(*pValue));
+ SysTryCatch(NID_APP, pData != null, r = GetLastResult(), GetLastResult(), "[%s] Invalid request value",
+ GetErrorMessage(GetLastResult()));
+
+ length = strlen(pData.get());
+ r = request.Write(&length, sizeof(int)); // data length
+ SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM, "[%s] Failed to send request.", GetErrorMessage(r));
+
+ r = request.Write(pData.get(), length); // data
+ SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM, "[%s] Failed to send request.", GetErrorMessage(r));
+
+ argSize += pColumn->GetLength() * sizeof(wchar_t);
+ argSize += pValue->GetLength() * sizeof(wchar_t);
+#else
String* pColumn = dynamic_cast< String* >(pMapEnum->GetKey());
SysTryCatch(NID_APP, pColumn != null, r = E_INVALID_ARG, E_INVALID_ARG,
"[E_INVALID_ARG] The object is not String class.");
argSize += pColumn->GetLength() * sizeof(wchar_t);
argSize += pValue->GetLength() * sizeof(wchar_t);
i++;
+#endif
}
- SysTryCatch(NID_APP, argSize <= _MAX_ARGUMENT_SIZE, r = E_MAX_EXCEEDED, E_MAX_EXCEEDED,
+ SysTryCatch(NID_APP, argSize <= _MAX_REQUEST_ARGUMENT_SIZE, r = E_MAX_EXCEEDED, E_MAX_EXCEEDED,
"[E_MAX_EXCEEDED] The size of sending argument (%d) exceeds the maximum limit.", argSize);
+#ifdef DATACONTROL_PROTOCOL_VER_2_1_0_2
+ request.Flush();
+#endif
+
r = StartSqlDataControl(_DATACONTROL_REQUEST_TYPE_SQL_INSERT, pArgList, &id);
SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating to caller...", GetErrorMessage(r));
int columnCount = 0;
int id = 0;
int i = 0;
+ int uniqueId = -1;
+ File request;
+ IMapEnumerator* pMapEnum = null;
result r = E_SUCCESS;
SysLog(NID_APP, "[DC_CALLER_SEND] SqlDataControl UPDATE");
ArrayList* pArgList = new ArrayList();
pArgList->Construct();
- pArgList->Add(*(new String(dataId))); // list(0): data ID
+ pArgList->Add(new (std::nothrow) String(dataId)); // list[0]: data ID
long long argSize = dataId.GetLength() * sizeof(wchar_t);
- pArgList->Add(*(new String(Integer::ToString(columnCount)))); // list(1): updated column count
+ pArgList->Add(new (std::nothrow) String(Integer::ToString(columnCount))); // list[1]: updated column count
SysLog(NID_APP, "[DC_CALLER_SEND] updated column count: %d", columnCount);
- IMapEnumerator* pMapEnum = const_cast< IMap* >(&updateMap)->GetMapEnumeratorN();
- while (pMapEnum->MoveNext() == E_SUCCESS) // list(2): column-value pairs
+#ifdef DATACONTROL_PROTOCOL_VER_2_1_0_2
+ String tmpPath(_DATACONTROL_REQUEST_DIR);
+ tmpPath.Append(App::GetInstance()->GetAppId());
+
+ _DataControlManager* pDcMgr = _DataControlManager::GetInstance();
+ SysTryCatch(NID_APP, pDcMgr, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to get _DataControlManager instance.");
+ uniqueId = pDcMgr->GetUniqueId();
+
+ tmpPath.Append(uniqueId);
+ SysLog(NID_APP, "[DC_CALLER_SEND] request: %ls", tmpPath.GetPointer());
+
+ r = request.Construct(tmpPath, L"w+", true);
+ SysTryCatch(NID_APP, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[%s] Failed to create request (%ls).",
+ GetErrorMessage(r), tmpPath.GetPointer());
+
+ pArgList->Add(new (std::nothrow) String(tmpPath)); // list[2]: path
+#endif
+
+ pMapEnum = const_cast< IMap* >(&updateMap)->GetMapEnumeratorN();
+ while (pMapEnum->MoveNext() == E_SUCCESS) // list: column-value pairs
{
+#ifdef DATACONTROL_PROTOCOL_VER_2_1_0_2
+ int length = 0;
+ String* pColumn = null;
+ String* pValue = null;
+ unique_ptr< char[] > pData(null);
+
+ pColumn = dynamic_cast< String* >(pMapEnum->GetKey());
+ SysTryCatch(NID_APP, pColumn != null, r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The object is not String class.");
+
+ pData.reset(_StringConverter::CopyToCharArrayN(*pColumn));
+ SysTryCatch(NID_APP, pData != null, r = GetLastResult(), GetLastResult(), "[%s] Invalid request value",
+ GetErrorMessage(GetLastResult()));
+
+ length = strlen(pData.get());
+ r = request.Write(&length, sizeof(int)); // data length
+ SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM, "[%s] Failed to send request.", GetErrorMessage(r));
+
+ r = request.Write(pData.get(), length); // data
+ SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM, "[%s] Failed to send request.", GetErrorMessage(r));
+
+ pValue = dynamic_cast< String* >(pMapEnum->GetValue());
+ SysTryCatch(NID_APP, pValue != null, r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The object is not String class.");
+
+ pData.reset(_StringConverter::CopyToCharArrayN(*pValue));
+ SysTryCatch(NID_APP, pData != null, r = GetLastResult(), GetLastResult(), "[%s] Invalid request value",
+ GetErrorMessage(GetLastResult()));
+
+ length = strlen(pData.get());
+ r = request.Write(&length, sizeof(int)); // data length
+ SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM, "[%s] Failed to send request.", GetErrorMessage(r));
+
+ r = request.Write(pData.get(), length); // data
+ SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM, "[%s] Failed to send request.", GetErrorMessage(r));
+
+ argSize += pColumn->GetLength() * sizeof(wchar_t);
+ argSize += pValue->GetLength() * sizeof(wchar_t);
+#else
String* pColumn = dynamic_cast< String* >(pMapEnum->GetKey());
SysTryCatch(NID_APP, pColumn != null, r = E_INVALID_ARG, E_INVALID_ARG,
"[E_INVALID_ARG] The object is not String class.");
argSize += pColumn->GetLength() * sizeof(wchar_t);
argSize += pValue->GetLength() * sizeof(wchar_t);
i++;
+#endif
}
- if (pWhere != null) // list(3): where clause
+#ifdef DATACONTROL_PROTOCOL_VER_2_1_0_2
+ request.Flush();
+#endif
+
+ if (pWhere != null) // list: where clause
{
- pArgList->Add(*(new String(*pWhere)));
+ pArgList->Add(new (std::nothrow) String(*pWhere));
argSize += pWhere->GetLength() * sizeof(wchar_t);
SysLog(NID_APP, "[DC_CALLER_SEND] pWhere: %ls", pWhere->GetPointer());
}
else
{
- pArgList->Add(*(new String(L"NULL")));
+ pArgList->Add(new (std::nothrow) String(L"NULL"));
}
- SysTryCatch(NID_APP, argSize <= _MAX_ARGUMENT_SIZE, r = E_MAX_EXCEEDED, E_MAX_EXCEEDED,
+ SysTryCatch(NID_APP, argSize <= _MAX_REQUEST_ARGUMENT_SIZE, r = E_MAX_EXCEEDED, E_MAX_EXCEEDED,
"[E_MAX_EXCEEDED] The size of sending argument (%d) exceeds the maximum limit.", argSize);
r = StartSqlDataControl(_DATACONTROL_REQUEST_TYPE_SQL_UPDATE, pArgList, &id);
using namespace Tizen::Base::Collection;
using namespace Tizen::App;
-const char* _DATACONTROL_RESULTSET_DIR = "/tmp/osp/DataControlResultSet/\0";
+const char* _DATACONTROL_RESULT_DIR = "/tmp/osp/DataControlResult/\0";
namespace Tizen { namespace Io
{
result
_DataControlResultSetImpl::FillWith(IDbEnumerator* pDbEnum)
{
- String tempFilePath(_DATACONTROL_RESULTSET_DIR);
+ String tempFilePath(_DATACONTROL_RESULT_DIR);
String columnName;
String appId;
String reqType;