Increase SqlDataControl request buffer size
authorHyunbin Lee <hyunbin.lee@samsung.com>
Sat, 20 Apr 2013 03:04:03 +0000 (12:04 +0900)
committerHyunbin Lee <hyunbin.lee@samsung.com>
Wed, 24 Apr 2013 01:46:20 +0000 (10:46 +0900)
Change-Id: I07494bbe429c04710b44bb96fba626e205367e05
Signed-off-by: Hyunbin Lee <hyunbin.lee@samsung.com>
inc/FAppSqlDataControl.h
src/app/FApp_AppArg.cpp
src/app/FApp_AppControlManager.cpp
src/app/FApp_AppImpl.cpp
src/app/FApp_AppManagerImpl.cpp
src/app/FApp_DataControlManager.cpp
src/app/FApp_DataControlManager.h
src/app/FApp_DataControlProviderManagerImpl.cpp
src/app/FApp_MapDataControlImpl.cpp
src/app/FApp_SqlDataControlImpl.cpp
src/io/FIo_DataControlResultSetImpl.cpp

index bcf2b0a..f9df5d2 100755 (executable)
@@ -156,7 +156,7 @@ public:
        * @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.
@@ -192,14 +192,14 @@ public:
        * @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);
 
@@ -229,14 +229,14 @@ public:
        * @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);
@@ -265,7 +265,7 @@ public:
        * @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.
index 4e9f09a..330f733 100644 (file)
@@ -71,7 +71,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_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_";
@@ -1007,6 +1007,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<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)
@@ -1031,7 +1032,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_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)
index e1aa16f..985a0d1 100755 (executable)
@@ -76,8 +76,6 @@ using namespace Tizen::Base::Runtime;
 using namespace Tizen::Base::Utility;
 using namespace Tizen::Io;
 
-//extern const char* _DATACONTROL_RESULTSET_DIR;
-
 namespace Tizen { namespace App
 {
 
index 6ec5cf5..da2f2f2 100644 (file)
@@ -732,6 +732,7 @@ _AppImpl::OnDataControlRequestReceived(const _AppArg& arg, RequestId reqId)
        String appId;
        String reqType;
        String providerId;
+       String version;
        String* pDataId = null;
        String callerReqId;
        String* pColumnCount = null;
@@ -742,6 +743,7 @@ _AppImpl::OnDataControlRequestReceived(const _AppArg& arg, RequestId reqId)
        String* pErrorMsg = null;
        String* pNo = null;
        String* pCount = null;
+       String* pTmpPath = null;
        String empty(L"NULL");
        _AppArg resultArg;
        int type = 0;
@@ -768,6 +770,7 @@ _AppImpl::OnDataControlRequestReceived(const _AppArg& arg, RequestId reqId)
        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);
 
@@ -876,7 +879,7 @@ _AppImpl::OnDataControlRequestReceived(const _AppArg& arg, RequestId reqId)
        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");
 
@@ -887,20 +890,75 @@ _AppImpl::OnDataControlRequestReceived(const _AppArg& arg, RequestId reqId)
                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);
@@ -923,25 +981,78 @@ _AppImpl::OnDataControlRequestReceived(const _AppArg& arg, RequestId reqId)
                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)
                {
@@ -952,6 +1063,12 @@ _AppImpl::OnDataControlRequestReceived(const _AppArg& arg, RequestId reqId)
                        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",
index 9227eb7..e9c7092 100755 (executable)
@@ -76,8 +76,6 @@ using namespace Tizen::Base::Runtime;
 using namespace Tizen::Base::Utility;
 using namespace Tizen::Io;
 
-//extern const char* _DATACONTROL_RESULTSET_DIR;
-
 namespace
 {
 
index b485314..9def7f0 100644 (file)
@@ -24,6 +24,7 @@
 #include <cstdlib>
 #include <pthread.h>
 #include <typeinfo>
+#include <glib.h>
 
 #include <FBaseInteger.h>
 #include <FBaseSysLog.h>
@@ -40,6 +41,7 @@ _DataControlManager* _DataControlManager::__pDataControlManagerInstance = null;
 
 _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.");
@@ -117,5 +119,14 @@ _DataControlManager::RemoveRequestInfo(Integer& reqId)
        __pDataControlRequestList->Remove(reqId);
 }
 
+int
+_DataControlManager::GetUniqueId(void)
+{
+       //++__uniqueId;
+       //__sync_fetch_and_add(&__uniqueId, 1);
+       g_atomic_int_inc(&__uniqueId);
+       return __uniqueId;
+}
+
 }} // Tizen::App
 
index 9d1e232..c48810c 100644 (file)
@@ -68,6 +68,8 @@ public:
 
        void RemoveRequestInfo(Tizen::Base::Integer& reqId);
 
+       int GetUniqueId(void);
+
 private:
        _DataControlManager(void);
 
@@ -80,6 +82,7 @@ private:
 private:
        static _DataControlManager* __pDataControlManagerInstance;
        Tizen::Base::Collection::HashMap* __pDataControlRequestList;
+       int __uniqueId;
 
 }; // _DataControlManager
 
index 97bfedd..61cfff7 100644 (file)
@@ -54,7 +54,7 @@ using namespace Tizen::Base;
 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
 {
@@ -190,7 +190,7 @@ _DataControlProviderManagerImpl::SendDataControlResult(RequestId reqId, _DataCon
                        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);
@@ -248,9 +248,9 @@ _DataControlProviderManagerImpl::SendDataControlResult(RequestId reqId, _DataCon
                        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);
@@ -270,17 +270,16 @@ _DataControlProviderManagerImpl::SendDataControlResult(RequestId reqId, _DataCon
                                                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();
                                }
@@ -299,10 +298,10 @@ _DataControlProviderManagerImpl::SendDataControlResult(RequestId reqId, _DataCon
                                                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;
        }
index 862fa0e..69e01c8 100755 (executable)
@@ -384,7 +384,7 @@ _MapDataControlImpl::MapDataControlCallback(void* data, _AppArg* pArg, _AppArg*
 
                                        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");
index bfeea90..8157004 100755 (executable)
 #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"
@@ -46,6 +47,8 @@
 #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;
@@ -59,6 +62,8 @@ namespace Tizen { namespace App
 
 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
@@ -520,24 +525,84 @@ _SqlDataControlImpl::Insert(const String& dataId, const IMap& insertMap, Request
        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.");
@@ -555,10 +620,15 @@ _SqlDataControlImpl::Insert(const String& dataId, const IMap& insertMap, Request
                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));
 
@@ -584,6 +654,9 @@ _SqlDataControlImpl::Update(const String& dataId, const IMap& updateMap, const S
        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");
 
@@ -593,15 +666,72 @@ _SqlDataControlImpl::Update(const String& dataId, const IMap& updateMap, const S
        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.");
@@ -619,19 +749,24 @@ _SqlDataControlImpl::Update(const String& dataId, const IMap& updateMap, const S
                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);
index b4a71f7..14fe8b0 100644 (file)
@@ -50,7 +50,7 @@ using namespace Tizen::Base::Utility;
 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
 {
@@ -88,7 +88,7 @@ _DataControlResultSetImpl::~_DataControlResultSetImpl(void)
 result
 _DataControlResultSetImpl::FillWith(IDbEnumerator* pDbEnum)
 {
-       String tempFilePath(_DATACONTROL_RESULTSET_DIR);
+       String tempFilePath(_DATACONTROL_RESULT_DIR);
        String columnName;
        String appId;
        String reqType;