Update change log and spec for wrt-plugins-tizen_0.4.66
authorDongjin Choi <milkelf.choi@samsung.com>
Wed, 11 Sep 2013 09:44:29 +0000 (18:44 +0900)
committerDongjin Choi <milkelf.choi@samsung.com>
Wed, 11 Sep 2013 09:44:29 +0000 (18:44 +0900)
[model] REDWOOD
[binary_type] PDA
[customer] OPEN

[Issue] N/A
[Problem] removeMessages with empty message crash
[Cause] get Message type without check message array length
[Solution] check message array length

[Issue#] redmine #1541
[Problem] problem with filter
[Cause] internal bug
[Solution] modify source code

[DataControl] move common code to DataControlCallback.h, cpp
[DataControl] gathering pending event class.
[DataControl] makes callback & userdata as one common callback & userdata.

[Issue#] PLM P130829-05706
[Problem] callback invocation with unordered req id due to platform bug.
[Cause] there is no work queue to prevent platform bug.
[Solution] work queue implementation.

[Issue#] TTS-1973
[Problem] When listen api is registered callback is not invoked.
[Cause] N/A
[Solution] Modify code.

[team] WebAPI
[request] N/A
[horizontal_expansion] N/A

UnitTC passed.

15 files changed:
packaging/wrt-plugins-tizen.spec
src/Callhistory/CallHistoryFilter.cpp
src/DataControl/CMakeLists.txt
src/DataControl/DataControlAsyncCallbackManager.h
src/DataControl/DataControlCallback.cpp [new file with mode: 0644]
src/DataControl/DataControlCallback.h [new file with mode: 0755]
src/DataControl/DataControlPendingEvent.h [new file with mode: 0755]
src/DataControl/DataType.h
src/DataControl/MappedDataControlConsumer.cpp
src/DataControl/MappedDataControlConsumer.h
src/DataControl/SqlDataControlConsumer.cpp
src/DataControl/SqlDataControlConsumer.h
src/Messaging/ReqReceiverMessage.cpp
src/Power/CMakeLists.txt
src/Systeminfo/EventWatchSysteminfo.cpp

index c5ba5cb..cd8c69c 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       wrt-plugins-tizen
 Summary:    JavaScript plugins for WebRuntime
-Version:    0.4.65
+Version:    0.4.66
 Release:    0
 Group:      Development/Libraries
 License:    Apache License, Version 2.0
index 4b5b2c7..91ea74e 100755 (executable)
@@ -19,6 +19,7 @@
 #include "CallHistoryDefine.h"
 #include "CallHistoryFilter.h"
 #include <Logger.h>
+#include <sstream>
 
 using namespace std;
 using namespace DeviceAPI::Tizen;
@@ -85,26 +86,26 @@ void CallHistoryFilter::visitAttribute(std::string& attrName, MatchFlag& matchFl
        contacts_filter_create(_contacts_phone_log._uri, &subFilter);
 
        switch (matchFlag) {
-       case MATCH_EXACTLY:
-               mFlag = CONTACTS_MATCH_EXACTLY;
-               break;
-       case MATCH_FULLSTRING:
-               mFlag = CONTACTS_MATCH_FULLSTRING;
-               break;
-       case MATCH_CONTAINS:
-               mFlag = CONTACTS_MATCH_CONTAINS;
-               break;
-       case MATCH_STARTSWITH:
-               mFlag = CONTACTS_MATCH_STARTSWITH;
-               break;
-       case MATCH_ENDSWITH:
-               mFlag = CONTACTS_MATCH_ENDSWITH;
-               break;
-       case MATCH_EXISTS:
-               mFlag = CONTACTS_MATCH_EXISTS;
-               break;
-       default:
-               mFlag = CONTACTS_MATCH_EXACTLY;
+               case MATCH_EXACTLY:
+                       mFlag = CONTACTS_MATCH_EXACTLY;
+                       break;
+               case MATCH_FULLSTRING:
+                       mFlag = CONTACTS_MATCH_FULLSTRING;
+                       break;
+               case MATCH_CONTAINS:
+                       mFlag = CONTACTS_MATCH_CONTAINS;
+                       break;
+               case MATCH_STARTSWITH:
+                       mFlag = CONTACTS_MATCH_STARTSWITH;
+                       break;
+               case MATCH_ENDSWITH:
+                       mFlag = CONTACTS_MATCH_ENDSWITH;
+                       break;
+               case MATCH_EXISTS:
+                       mFlag = CONTACTS_MATCH_EXISTS;
+                       break;
+               default:
+                       mFlag = CONTACTS_MATCH_EXACTLY;
        }
 
        if (attrName.compare(STR_DIRECTION) == 0) {
@@ -196,7 +197,11 @@ void CallHistoryFilter::visitAttribute(std::string& attrName, MatchFlag& matchFl
                        contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_NONE);
                }
        } else if (attrName.compare(STR_ENTRY_ID) == 0) {
-               contacts_filter_add_str(filter, _contacts_phone_log.id, mFlag, matchValue->getString().c_str());
+               int result = 0;
+               istringstream iss(matchValue->getString());
+               iss >> result;
+
+               contacts_filter_add_int(filter, _contacts_phone_log.id, CONTACTS_MATCH_EQUAL, result);
        } else {
                contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_NONE);
        }
@@ -210,7 +215,7 @@ void CallHistoryFilter::visitAttributeRange(std::string& attrName, AnyPtr& initi
                return;
 
        contacts_filter_h filter = m_filterStack.top();
-       
+
        unsigned int propertyId = 0;
        int iValue = 0;
        int eValue = 0;
@@ -220,7 +225,7 @@ void CallHistoryFilter::visitAttributeRange(std::string& attrName, AnyPtr& initi
        } else if (attrName.compare(STR_RP_PERSONID) == 0) {
                propertyId = _contacts_phone_log.person_id;
        } else if (attrName.compare(STR_START_TIME) == 0) {
-               propertyId = _contacts_phone_log.log_time;      
+               propertyId = _contacts_phone_log.log_time;
        } else if (attrName.compare(STR_DURATION) == 0) {
                propertyId = _contacts_phone_log.extra_data1;
        } else if (attrName.compare(STR_ENTRY_ID) == 0) {
index 19726f7..77135fc 100755 (executable)
@@ -20,6 +20,7 @@ SET(SRCS_IMPL
        IMappedDataControlConsumer.cpp
        ISqlDataControlConsumer.cpp
        ISelectDataObject.cpp
+       DataControlCallback.cpp
        MappedDataControlConsumer.cpp
        SelectDataObject.cpp
        SqlDataControlConsumer.cpp
index b052814..0cb5e78 100755 (executable)
@@ -21,7 +21,8 @@
 #include <dpl/singleton.h>
 #include <AsyncCallbackManager.h>
 #include <dpl/mutex.h>
-#include "SqlDataControlConsumer.h"
+#include "DataControlPendingEvent.h"
+
 
 namespace DeviceAPI {
 namespace DataControl {
@@ -35,106 +36,86 @@ public:
 
        virtual ~DataControlAsyncCallbackManager()
        {
-               cleanupSQLUserData();
+               cleanupUserData();
        }
        
-       bool isSQLDataControlGC(void* address) 
+       bool isDataControlGC(void* address) 
        { 
                LoggerD(address);
 
-               if (m_sqlDataControlGCMap.find(address) == m_sqlDataControlGCMap.end())
+               if (m_dataControlGCMap.find(address) == m_dataControlGCMap.end())
                {
                        return true;
                }
 
-               return m_sqlDataControlGCMap[address];
+               return m_dataControlGCMap[address];
        }
-       bool isMappedDataControlGC(void* address) 
-       { 
-               LoggerD(address);
 
-               if (m_mappedDataControlGCMap.find(address) == m_mappedDataControlGCMap.end())
-               {
-                       return true;
-               }
-
-               return m_mappedDataControlGCMap[address];
-       }
-       void setSQLDataControlGC(void* address, bool gc) 
+       void setDataControlGC(void* address, bool gc) 
        { 
                LoggerD(address);
                        
                DPL::Mutex::ScopedLock lock(&m_mutex);                  
-               if (gc && m_sqlDataControlGCMap.find(address) != m_sqlDataControlGCMap.end())
+               if (gc && m_dataControlGCMap.find(address) != m_dataControlGCMap.end())
                {
-                       m_mappedDataControlGCMap.erase(address);
+                       m_dataControlGCMap.erase(address);
                }
-               m_sqlDataControlGCMap[address] = gc;
+               m_dataControlGCMap[address] = gc;
        }
 
-       void setMappedDataControlGC(void* address, bool gc) 
-       { 
-               LoggerD(address);
-               
-               DPL::Mutex::ScopedLock lock(&m_mutex);                  
-               if (gc && m_mappedDataControlGCMap.find(address) != m_mappedDataControlGCMap.end())
-               {
-                       m_mappedDataControlGCMap.erase(address);
-               }
-               m_mappedDataControlGCMap[address] = gc;
-       }
 
-       bool checkDoSQLOperation()
+       bool checkRequestIpcOperation()
        {
-//             return m_callbackSQLUserDataMap.empty();        
+//             return m_callbackUserDataMap.empty();   
                // limitation 128
-               if (m_callbackSQLUserDataMap.size() < 128)
+               if (m_callbackUserDataMap.size() < 128)
                        return true;
                else
                        return false;
        }
 
-       void* getRemainingSQLOperation()
+       void* getRemainingIpcOperation()
        {
                LoggerD("OK");
                void *retPtr = NULL;
 
-               if (m_callbackSQLUserDataMap.empty() == false)
+               if (m_callbackUserDataMap.empty() == false)
                {
-                       std::string key = m_sqlReqIdVector[0];
-                       retPtr = m_callbackSQLUserDataMap[key];
+                       std::string key = m_reqIdVector[0];
+                       retPtr = m_callbackUserDataMap[key];
                }
                return retPtr;  
        }
        
        bool checkReqIdUnique(std::string key) 
        {
-               if (m_callbackSQLUserDataMap.find(key) == m_callbackSQLUserDataMap.end())
+               if (m_callbackUserDataMap.find(key) == m_callbackUserDataMap.end())
                {
                        return true;
                }
                return false;
        }
+
        
        void addSQLUserData(std::string key, void* data) 
        { 
-               if (m_callbackSQLUserDataMap.find(key) != m_callbackSQLUserDataMap.end())
+               if (m_callbackUserDataMap.find(key) != m_callbackUserDataMap.end())
                {
                        ThrowMsg(WrtDeviceApis::Commons::PlatformException, "same id exist");
                }
 
-               m_sqlReqIdVector.push_back(key);
+               m_reqIdVector.push_back(key);
 
                LoggerD("Add OK ReqId : " << key);
 
                DPL::Mutex::ScopedLock lock(&m_mutex);          
-               m_callbackSQLUserDataMap[key] = data;
+               m_callbackUserDataMap[key] = data;
        }
        
        void* removeSQLUserData(std::string key) 
        {
                size_t index = 0;
-               if (m_callbackSQLUserDataMap.find(key) == m_callbackSQLUserDataMap.end())
+               if (m_callbackUserDataMap.find(key) == m_callbackUserDataMap.end())
                {
                        LoggerD("Fail ReqId : " << key);
                        ThrowMsg(WrtDeviceApis::Commons::PlatformException, "there is no key");
@@ -142,17 +123,17 @@ public:
                
 
                DPL::Mutex::ScopedLock lock(&m_mutex);                  
-               void* data = m_callbackSQLUserDataMap[key];
+               void* data = m_callbackUserDataMap[key];
                
        //      LoggerD(key << " : " << std::hex << data);
 
-               m_callbackSQLUserDataMap.erase(key);
+               m_callbackUserDataMap.erase(key);
 
-               for (index = 0; index < m_sqlReqIdVector.size(); index++)
+               for (index = 0; index < m_reqIdVector.size(); index++)
                {
-                       if (m_sqlReqIdVector[index] == key)
+                       if (m_reqIdVector[index] == key)
                        {
-                               m_sqlReqIdVector.erase(m_sqlReqIdVector.begin() + index);                               
+                               m_reqIdVector.erase(m_reqIdVector.begin() + index);                             
                                break;
                        }
                }
@@ -164,10 +145,10 @@ public:
        friend class DPL::Singleton<DataControlAsyncCallbackManager>;
        
 private:
-       void cleanupSQLUserData() 
+       void cleanupUserData() 
        {       
-               for (std::map<std::string, void*>::iterator it = m_callbackSQLUserDataMap.begin();
-                       it != m_callbackSQLUserDataMap.end(); ++it)
+               for (std::map<std::string, void*>::iterator it = m_callbackUserDataMap.begin();
+                       it != m_callbackUserDataMap.end(); ++it)
                {
                        CommonPendingEvent *event = (CommonPendingEvent*)it->second;
                        
@@ -206,13 +187,48 @@ private:
                                LoggerD("free delete");
                                delete deleteEvent;
                        }
+                       
+                       EventAddValuePendingEvent *addValueEvent = dynamic_cast<EventAddValuePendingEvent*>(event);
+               
+                       if (addValueEvent)
+                       {
+                               LoggerD("free addValue");
+                               delete addValueEvent;
+                               continue;
+                       }
+               
+                       
+                       EventGetValuePendingEvent *getValueEvent = dynamic_cast<EventGetValuePendingEvent*>(event);
+               
+                       if (getValueEvent) 
+                       {
+                               LoggerD("free getValue");
+                               delete getValueEvent;
+                               continue;
+                       }
+               
+                       EventUpdateValuePendingEvent *updateValueEvent = dynamic_cast<EventUpdateValuePendingEvent*>(event);
+               
+                       if (updateValueEvent) 
+                       {
+                               LoggerD("free updateValue");
+                               delete updateValueEvent;
+                               continue;
+                       }
+               
+                       EventRemoveValuePendingEvent *removeValueEvent = dynamic_cast<EventRemoveValuePendingEvent*>(event);
+                       
+                       if (removeValueEvent) 
+                       {
+                               LoggerD("free removeValue");
+                               delete removeValueEvent;
+                       }
                }
        }
        DPL::Mutex m_mutex;
-       std::map<void*, bool> m_sqlDataControlGCMap;
-       std::map<void*, bool> m_mappedDataControlGCMap;
-       std::map<std::string, void*> m_callbackSQLUserDataMap;
-       std::vector<std::string> m_sqlReqIdVector;
+       std::map<void*, bool> m_dataControlGCMap;
+       std::map<std::string, void*> m_callbackUserDataMap;
+       std::vector<std::string> m_reqIdVector;
        
 };
 
diff --git a/src/DataControl/DataControlCallback.cpp b/src/DataControl/DataControlCallback.cpp
new file mode 100644 (file)
index 0000000..3a2a0e5
--- /dev/null
@@ -0,0 +1,1381 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#include <Commons/Exception.h>
+#include <Logger.h>
+#include <app.h>
+#include <app_info.h>
+#include <app_manager.h>
+#include <package-manager.h>
+#include <aul/aul.h>
+#include <unistd.h>
+#include "DataControlCallback.h"
+#include "SqlDataControlConsumer.h"
+#include "MappedDataControlConsumer.h"
+#include "DataType.h"
+#include "DataControlAsyncCallbackManager.h"
+
+#include "EventDelete.h"
+#include "EventInsert.h"
+#include "EventSelect.h"
+#include "EventUpdate.h"
+#include "EventRemoveValue.h"
+#include "EventAddValue.h"
+#include "EventGetValue.h"
+#include "EventUpdateValue.h"
+
+
+using namespace WrtDeviceApis::Commons;
+
+namespace DeviceAPI {
+namespace DataControl {
+
+// utils for common usage
+std::vector<std::string> getDataArrayFromBundle(bundle *b, std::string key)
+{
+       std::vector<std::string> result;
+       const char **array;
+       int length = 0;
+       int index = 0;
+       
+       array = appsvc_get_data_array(b, key.c_str(), &length);
+
+       if (array == NULL || length == 0)
+       {
+               ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result data fail from datacontrol provider");
+       }
+       
+       for (index = 0; index < length; index++)
+       {
+               result.push_back(array[index]);
+       }
+
+       return result;
+}
+
+std::string getProviderApplicationId(const std::string type, const std::string& provId)
+{
+       std::string appIdStr = "";
+
+       char* appId = NULL;
+       char* access = NULL;
+       const char *passId = provId.c_str();
+
+       if( pkgmgr_datacontrol_get_info(passId, type.c_str(), &appId, &access) < 0)
+       {
+               ThrowMsg(WrtDeviceApis::Commons::PlatformException, "get appId error");
+       }
+               
+       if (appId)
+       {
+               appIdStr = appId;
+               free(appId);
+       }
+
+       if (access)
+       {
+               free(access);
+       }
+               
+       return appIdStr;
+}
+
+std::string getCurrentApplicationId()
+{
+       char *app_id = NULL;
+       std::string appId = "";
+       int parent_pid = getppid();
+       LoggerD("parent pid : " << parent_pid); 
+       int ret = app_manager_get_app_id(parent_pid, &app_id);  
+
+       if((ret != APP_ERROR_NONE) || (app_id == NULL))
+       {
+               LoggerE("Can not get app id from current pid (" << ret << ")");
+               ThrowMsg(WrtDeviceApis::Commons::PlatformException, "could not get information about application");
+       }
+       appId = app_id;
+       free(app_id);
+       return appId;           
+}
+
+std::string getProviderPkgId(const std::string& appId)
+{
+       char* pkgId = NULL;
+       std::string pkgIdStr = "";
+       app_info_h handle = NULL;
+
+       int ret = app_manager_get_app_info(appId.c_str(), &handle);
+
+       if (ret != APP_ERROR_NONE) 
+       {
+               LoggerD("Fail to get appinfo");
+               ThrowMsg(WrtDeviceApis::Commons::PlatformException, "get appId error");
+       }
+
+       ret = app_info_get_package(handle, &pkgId);
+
+       if ((ret != APP_ERROR_NONE) || (pkgId == NULL)) 
+       {
+               LoggerD("Fail to get pkg_name");
+               ThrowMsg(WrtDeviceApis::Commons::PlatformException, "get pkdid error");
+       }
+       pkgIdStr = pkgId;
+       app_info_destroy(handle);
+       free(pkgId);
+       return pkgIdStr;
+}
+
+std::string convertIntToString(unsigned int data)
+{
+       std::stringstream ssbuffer;
+
+       ssbuffer.str("");
+       ssbuffer << data;
+       return ssbuffer.str();
+}
+
+std::string generateFileName(unsigned int reqId, const std::string currentAppId)
+{
+       std::stringstream ssdata;
+       ssdata.str("");
+       ssdata << reqId;
+       std::string parent = DATACONTROL_PROTOCOL_DIR;
+       std::string filename = parent  + "/" + currentAppId + ssdata.str();
+       return filename;
+}
+
+void addArrayToBundle(bundle* passData, std::vector<std::string>& array)
+{
+       size_t arraySize = array.size();
+
+       if (arraySize == 0)
+       {
+               ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "size = 0");
+       }
+       
+       const char** arr = NULL;
+       arr = (const char**)calloc(sizeof(char*), arraySize);
+
+       if (arr == NULL)
+       {
+               ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "null");
+       }
+
+       for (size_t index = 0; index < arraySize; index++) 
+       {
+               arr[index] = array[index].c_str();
+       }
+
+       
+       bundle_add_str_array(passData, OSP_K_ARG, arr, arraySize);
+
+       free(arr);
+       arr = NULL;
+
+}
+void handleRemainingPendingEvent() 
+{
+       CommonPendingEvent* userData = NULL;
+       unsigned short currentJob = 0;
+       SQLDataControlConsumer *sqlConsumer = NULL;
+       MappedDataControlConsumer *mapConsumer = NULL;  
+
+       try 
+       {
+               userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingIpcOperation();
+
+               if (userData)
+               {
+                       SendAppControlLaunchToProvider(userData, currentJob);
+               }
+       }
+       catch (const WrtDeviceApis::Commons::Exception& ex) 
+       {
+               if (userData)
+               {
+                       switch(currentJob)
+                       {               
+                       case _DATACONTROL_REQUEST_TYPE_SQL_QUERY:
+                       case _DATACONTROL_REQUEST_TYPE_SQL_INSERT:
+                       case _DATACONTROL_REQUEST_TYPE_SQL_DELETE:
+                       case _DATACONTROL_REQUEST_TYPE_SQL_UPDATE:
+                       {
+                               sqlConsumer = (SQLDataControlConsumer *)userData->getThisObject();
+                               sqlConsumer->handleCommonErrorEvent(userData, ex.getCode(), ex.GetMessage());
+                       }
+                               break;
+                       case _DATACONTROL_REQUEST_TYPE_MAP_QUERY:
+                       case _DATACONTROL_REQUEST_TYPE_MAP_INSERT:
+                       case _DATACONTROL_REQUEST_TYPE_MAP_UPDATE:
+                       case _DATACONTROL_REQUEST_TYPE_MAP_DELETE:
+                       {
+                               mapConsumer = (MappedDataControlConsumer *)userData->getThisObject();
+                               mapConsumer->handleCommonErrorEvent(userData, ex.getCode(), ex.GetMessage());
+
+                       }
+                               break;                  
+                       default:
+                               LoggerD("Unknown Request");
+                       }
+               }
+       }
+}
+
+
+void SendAppControlLaunchToProvider(void* event, unsigned short& currentJob)
+{
+       LoggerD("OK");
+       bundle* passData = NULL;
+       std::vector<std::string> queryItem;
+       std::stringstream ssBuffer;
+       std::string stringBuffer;
+       CommonPendingEvent* pEvent = (CommonPendingEvent*)(event);
+       std::string ipcFilename;
+       std::string where;
+       unsigned int reqId = 0;
+       unsigned int columnSize = 0;
+       currentJob = _DATACONTROL_REQUEST_TYPE_UNDEFINED;
+
+       try 
+       {
+               passData = bundle_create();
+               
+               if (passData == NULL)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "ipc memory allocation fail");
+               }
+
+               if (pEvent == NULL)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "event null");              
+               }
+
+               appsvc_set_operation(passData, APPSVC_OPERATION_DEFAULT);               
+               appsvc_set_appid(passData, pEvent->getProviderAppId().c_str());
+
+               bundle_add(passData, OSP_K_CALLER_TYPE, OSP_V_CALLER_TYPE_OSP);
+               bundle_add(passData, OSP_K_LAUNCH_TYPE, OSP_V_LAUNCH_TYPE_DATACONTROL);
+               bundle_add(passData, OSP_K_DATACONTROL_PROVIDER, pEvent->getProviderId().c_str());
+               bundle_add(passData, OSP_K_DATACONTROL_PROTOCOL_VERSION, OSP_K_DATACONTROL_PROTOCOL_VERSION_VALUE); // version
+               bundle_add(passData, AUL_K_CALLER_APPID, pEvent->getCurrentAppId().c_str());
+
+               if (dynamic_cast<EventInsertPendingEvent*>(pEvent) != NULL)
+               {
+               
+                       currentJob = _DATACONTROL_REQUEST_TYPE_SQL_INSERT;
+                       
+                       EventInsertPendingEvent* pendingInsertEvent = (EventInsertPendingEvent*)pEvent;
+                       EventInsertPtr insertEvent = pendingInsertEvent->getEvent();
+                       
+                       reqId = insertEvent->getReqId();
+                       columnSize = insertEvent->getColumnSize();
+
+                       stringBuffer = convertIntToString(reqId);
+                       bundle_add(passData, OSP_K_REQUEST_ID, stringBuffer.c_str());   
+
+                       ipcFilename = generateFileName(reqId, pendingInsertEvent->getCurrentAppId().c_str());   
+                       stringBuffer = convertIntToString(columnSize);
+                       
+                       queryItem.push_back(pendingInsertEvent->getDataId()); 
+                       queryItem.push_back(stringBuffer); 
+                       queryItem.push_back(ipcFilename); 
+
+                       stringBuffer = convertIntToString(_DATACONTROL_REQUEST_TYPE_SQL_INSERT);
+                       bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, stringBuffer.c_str());
+                               
+                       addArrayToBundle(passData, queryItem);
+               }
+               else if (dynamic_cast<EventUpdatePendingEvent*>(pEvent) != NULL)
+               {
+               
+                       currentJob = _DATACONTROL_REQUEST_TYPE_SQL_UPDATE;
+
+                       EventUpdatePendingEvent* pendingUpdateEvent = (EventUpdatePendingEvent*)pEvent;
+                       EventUpdatePtr updateEvent = pendingUpdateEvent->getEvent();
+                       
+                       reqId = updateEvent->getReqId();
+                       columnSize = updateEvent->getColumnSize();
+                       where = updateEvent->getWhere();
+                       
+                       stringBuffer = convertIntToString(reqId);
+                       bundle_add(passData, OSP_K_REQUEST_ID, stringBuffer.c_str());   
+
+                       stringBuffer = convertIntToString(_DATACONTROL_REQUEST_TYPE_SQL_UPDATE);
+                       bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, stringBuffer.c_str());
+
+                       ipcFilename = generateFileName(reqId, pendingUpdateEvent->getCurrentAppId().c_str());   
+                       stringBuffer = convertIntToString(columnSize);
+
+                       queryItem.push_back(pendingUpdateEvent->getDataId()); 
+                       queryItem.push_back(stringBuffer); 
+                       queryItem.push_back(ipcFilename); 
+
+                       if (where.size() == 0)  // where
+                       {
+                               queryItem.push_back("NULL");
+                       }
+                       else 
+                       {
+                               queryItem.push_back(where);
+                       }
+               
+                       addArrayToBundle(passData, queryItem);
+
+               }
+               else if (dynamic_cast<EventSelectPendingEvent*>(pEvent) != NULL)
+               {
+
+                       currentJob = _DATACONTROL_REQUEST_TYPE_SQL_QUERY;
+               
+                       EventSelectPendingEvent* pendingSelectEvent = (EventSelectPendingEvent*)pEvent;
+                       EventSelectPtr selectEvent = pendingSelectEvent->getEvent();
+                       
+                       reqId = selectEvent->getReqId();
+                       std::vector<std::string> columns = selectEvent->getColumns();
+                       columnSize = columns.size();            
+                       where = selectEvent->getWhere();
+                       std::string order = selectEvent->getOrder();
+                       std::string page = selectEvent->getPage();
+                       std::string numberPerPage = selectEvent->getNumerPerPage();
+
+                       stringBuffer = convertIntToString(reqId);
+                       bundle_add(passData, OSP_K_REQUEST_ID, stringBuffer.c_str());   
+
+                       stringBuffer = convertIntToString(_DATACONTROL_REQUEST_TYPE_SQL_QUERY);
+                       bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, stringBuffer.c_str());
+
+                       queryItem.push_back(pendingSelectEvent->getDataId()); 
+
+                       if (columnSize == 0)
+                       {
+                               queryItem.push_back("NULL");
+                       }
+                       else 
+                       {
+                               stringBuffer = convertIntToString(columnSize);
+                               queryItem.push_back(stringBuffer);
+
+                               for (size_t index = 0; index < columnSize; index++)
+                               {
+                                       queryItem.push_back(columns[index]);
+                               }
+                       }
+
+                       if (where.size() == 0) 
+                       {
+                               queryItem.push_back("NULL");
+                       }
+                       else 
+                       {
+                               queryItem.push_back(where);
+                       }
+
+                       if (order.size() == 0)
+                       {
+                               queryItem.push_back("NULL"); 
+                       }
+                       else
+                       {
+                               queryItem.push_back(order);
+                       }
+
+                       if (page.size() == 0) // page
+                       {
+                               queryItem.push_back("1"); 
+                       }
+                       else
+                       {
+                               queryItem.push_back(page);
+                       }
+
+                       if (numberPerPage.size() == 0) // numberOfPage
+                       {
+                               queryItem.push_back("20");
+                       }
+                       else
+                       {
+                               queryItem.push_back(numberPerPage);
+                       }
+
+                       addArrayToBundle(passData, queryItem);
+               }
+               else if (dynamic_cast<EventDeletePendingEvent*>(pEvent) != NULL)
+               {
+                       currentJob = _DATACONTROL_REQUEST_TYPE_SQL_DELETE;
+
+                       EventDeletePendingEvent* pendingDeleteEvent = (EventDeletePendingEvent*)pEvent;
+                       EventDeletePtr deleteEvent = pendingDeleteEvent->getEvent();
+                       reqId = deleteEvent->getReqId();
+                       stringBuffer = convertIntToString(reqId);
+                       bundle_add(passData, OSP_K_REQUEST_ID, stringBuffer.c_str());   
+
+                       stringBuffer = convertIntToString(_DATACONTROL_REQUEST_TYPE_SQL_DELETE);
+                       bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, stringBuffer.c_str());
+
+                       queryItem.push_back(pendingDeleteEvent->getDataId()); // dataid
+                       where = deleteEvent->getWhere();
+
+                       if (where.size() == 0)  // where
+                       {
+                               queryItem.push_back("NULL");
+                       }
+                       else 
+                       {
+                               queryItem.push_back(where);
+                       }
+                       
+                       addArrayToBundle(passData, queryItem);
+               }
+               else if (dynamic_cast<EventAddValuePendingEvent*>(pEvent) != NULL)
+               {
+               
+                       currentJob = _DATACONTROL_REQUEST_TYPE_MAP_INSERT;
+                       
+                       EventAddValuePendingEvent* pendingAddValueEvent = (EventAddValuePendingEvent*)pEvent;
+                       EventAddValuePtr addValueEvent = pendingAddValueEvent->getEvent();
+                       reqId = addValueEvent->getReqId();
+                       stringBuffer = convertIntToString(reqId);
+                       bundle_add(passData, OSP_K_REQUEST_ID, stringBuffer.c_str());   
+
+                       stringBuffer = convertIntToString(_DATACONTROL_REQUEST_TYPE_MAP_INSERT);
+                       bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, stringBuffer.c_str());     
+               
+                       queryItem.push_back(pendingAddValueEvent->getDataId());
+                       queryItem.push_back(addValueEvent->getKey()); 
+                       queryItem.push_back(addValueEvent->getValue());
+
+                       addArrayToBundle(passData, queryItem);
+               }
+               else if (dynamic_cast<EventUpdateValuePendingEvent*>(pEvent) != NULL)
+               {
+               
+                       currentJob = _DATACONTROL_REQUEST_TYPE_MAP_UPDATE;
+                       
+                       EventUpdateValuePendingEvent* pendingUpdateValueEvent = (EventUpdateValuePendingEvent*)pEvent;
+                       EventUpdateValuePtr updateValueEvent = pendingUpdateValueEvent->getEvent();
+                       reqId = updateValueEvent->getReqId();
+                       stringBuffer = convertIntToString(reqId);
+                       bundle_add(passData, OSP_K_REQUEST_ID, stringBuffer.c_str());   
+
+                       stringBuffer = convertIntToString(_DATACONTROL_REQUEST_TYPE_MAP_UPDATE);
+                       bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, stringBuffer.c_str());     
+               
+                       queryItem.push_back(pendingUpdateValueEvent->getDataId());
+                       queryItem.push_back(updateValueEvent->getKey()); 
+                       queryItem.push_back(updateValueEvent->getOldValue());
+                       queryItem.push_back(updateValueEvent->getNewValue());
+                       
+
+                       addArrayToBundle(passData, queryItem);
+               }
+               else if (dynamic_cast<EventGetValuePendingEvent*>(pEvent) != NULL)
+               {
+               
+                       currentJob = _DATACONTROL_REQUEST_TYPE_MAP_QUERY;
+                       
+                       EventGetValuePendingEvent* pendingGetValueEvent = (EventGetValuePendingEvent*)pEvent;
+                       EventGetValuePtr getValueEvent = pendingGetValueEvent->getEvent();
+                       reqId = getValueEvent->getReqId();
+                       stringBuffer = convertIntToString(reqId);
+                       bundle_add(passData, OSP_K_REQUEST_ID, stringBuffer.c_str());   
+
+                       stringBuffer = convertIntToString(_DATACONTROL_REQUEST_TYPE_MAP_QUERY);
+                       bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, stringBuffer.c_str());     
+               
+                       queryItem.push_back(pendingGetValueEvent->getDataId());
+                       queryItem.push_back(getValueEvent->getKey()); 
+                       queryItem.push_back("1");
+                       queryItem.push_back("100");     //default num per a page // consider this in 3.0 as a spec
+
+                       addArrayToBundle(passData, queryItem);
+
+               }
+               else if (dynamic_cast<EventRemoveValuePendingEvent*>(pEvent) != NULL)
+               {
+               
+                       currentJob = _DATACONTROL_REQUEST_TYPE_MAP_DELETE;
+                       
+                       EventRemoveValuePendingEvent* pendingRemoveValueEvent = (EventRemoveValuePendingEvent*)pEvent;
+                       EventRemoveValuePtr removeValueEvent = pendingRemoveValueEvent->getEvent();
+                       reqId = removeValueEvent->getReqId();
+                       stringBuffer = convertIntToString(reqId);
+                       bundle_add(passData, OSP_K_REQUEST_ID, stringBuffer.c_str());   
+
+                       stringBuffer = convertIntToString(_DATACONTROL_REQUEST_TYPE_MAP_DELETE);
+                       bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, stringBuffer.c_str());     
+               
+                       queryItem.push_back(pendingRemoveValueEvent->getDataId());
+                       queryItem.push_back(removeValueEvent->getKey()); 
+                       queryItem.push_back(removeValueEvent->getValue());
+
+                       addArrayToBundle(passData, queryItem);
+               }
+               else 
+               {
+                       // never happen
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "no type request type");            
+               }
+
+               int pid = 0;
+
+               for (int index = 0; index < 3; index++)
+               {
+                       pid = appsvc_run_service(passData, reqId, dataControlCommonCallback, (void*)NULL);
+                       
+                       if (pid >= 0) 
+                               break;
+
+                       usleep(300 * 1000);
+                       LoggerD("Launch Retry" << (index + 1));
+               }
+
+
+               if (pid < 0) 
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Launch Error");
+               }
+
+               LoggerD("Launch OK : pid(" << pid << "), reqid : (" << reqId << ")");
+       }
+       catch (const WrtDeviceApis::Commons::Exception& ex) 
+       {       
+               LoggerE("Exception: " << ex.GetMessage());
+               if (passData)
+               {
+                       bundle_free(passData);
+                       passData = NULL;
+               }
+               ThrowMsg(WrtDeviceApis::Commons::PlatformException, ex.GetMessage());
+
+       }
+
+       if (passData)
+       {
+               bundle_free(passData);
+               passData = NULL;
+       }
+       
+}
+
+
+// callbacks for sqldatacontrol
+void sqldataControlSelectCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
+{
+       LoggerD("Enter");
+       
+       EventSelectPendingEvent *pendingEvent = NULL;
+       SQLDataControlConsumer *consumer = NULL;
+       EventSelectPtr event;
+       const char *bundleKey = NULL;
+       
+       try 
+       {
+               if (b == NULL)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
+               }
+               
+        bundleKey = appsvc_get_data(b, OSP_K_REQUEST_ID);
+
+               if (bundleKey == NULL)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get key fail from datacontrol provider");
+               }
+
+               pendingEvent = (EventSelectPendingEvent *)DataControlAsyncCallbackManagerSingleton::Instance().removeSQLUserData(bundleKey);
+               consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
+
+               if (DataControlAsyncCallbackManagerSingleton::Instance().isDataControlGC((void*)consumer))
+               {
+                       LoggerD("private object is garbage collected");
+                       delete pendingEvent;
+                       return;
+               }
+               event = pendingEvent->getEvent();
+               
+               std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
+
+               for (size_t index = 0; index < result.size(); index++)
+               {
+                       LoggerD(result[index]);
+               }
+
+               if (result.size() < 3)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid result from datacontrol provider");
+               }
+               
+               // 0 : result true or false??
+               if (RESULT_TRUE_FROM_OSP != result[0])
+               {
+                       // 1 : error msg 
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, result[1]);
+               }
+
+               event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
+               // 2 : result set file path
+               event->setResultSetPath(result[2]);
+               
+       }
+       catch (const WrtDeviceApis::Commons::Exception& ex) 
+       {
+               LoggerE("Exception: " << ex.GetMessage());
+               
+               if (event.Get() == NULL)
+               {
+                       LoggerD("event removed, invalid cb");
+                       return;
+               }
+
+               event->setExceptionCode(ex.getCode());
+               event->setErrorMsg(ex.GetMessage());            
+       }
+       consumer->handlePendingEvent(event);
+
+       if (pendingEvent)
+       {
+               delete pendingEvent;
+       }
+
+}
+
+void sqldataControlInsertCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
+{
+       LoggerD("Enter");
+
+       
+       EventInsertPendingEvent *pendingEvent = NULL;
+       SQLDataControlConsumer *consumer = NULL;
+       EventInsertPtr event;
+       const char *bundleKey = NULL;
+
+       try 
+       {
+               if (b == NULL)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
+               }
+
+        bundleKey = appsvc_get_data(b, OSP_K_REQUEST_ID);
+
+               if (bundleKey == NULL)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get key fail from datacontrol provider");
+               }
+
+               pendingEvent = (EventInsertPendingEvent *)DataControlAsyncCallbackManagerSingleton::Instance().removeSQLUserData(bundleKey);
+               consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
+
+               if (DataControlAsyncCallbackManagerSingleton::Instance().isDataControlGC((void*)consumer))
+               {
+                       LoggerD("private object is garbage collected");
+                       delete pendingEvent;
+                       return;
+               }
+               
+               event = pendingEvent->getEvent();
+
+               std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
+
+               for (size_t index = 0; index < result.size(); index++)
+               {
+                       LoggerD(result[index]);
+               }
+
+               if (result.size() < 2)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid result from datacontrol provider");
+               }
+               
+               // 0 : result true or false??
+               if (RESULT_TRUE_FROM_OSP != result[0])
+               {
+                       // 1 : error msg 
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, result[1]);
+               }
+
+               // 2 : insertrowid
+               std::stringstream sstr(result[2]);
+               long insertRowid = 0;
+               sstr >> insertRowid;
+               LoggerD(result[2] << insertRowid);
+               event->setRowId(insertRowid);                   
+               event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
+               
+       }
+       catch (const WrtDeviceApis::Commons::Exception& ex) 
+       {
+               LoggerE("Exception: " << ex.GetMessage());
+
+               if (event.Get() == NULL)
+               {
+                       LoggerD("event removed, invalid cb");
+                       return;
+               }
+                       
+               event->setExceptionCode(ex.getCode());
+               event->setErrorMsg(ex.GetMessage());            
+       }
+       consumer->handlePendingEvent(event);
+
+       if (pendingEvent)
+       {
+               delete pendingEvent;
+       }
+
+}
+
+void sqldataControlDeleteCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
+{
+       LoggerD("Enter");
+
+       EventDeletePendingEvent* pendingEvent = NULL;
+       SQLDataControlConsumer *consumer = NULL;
+       EventDeletePtr event;
+       const char* bundleKey = NULL;
+       
+       try 
+       {
+               if (b == NULL)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
+               }
+
+        bundleKey = appsvc_get_data(b, OSP_K_REQUEST_ID);
+
+               if (bundleKey == NULL)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get key fail from datacontrol provider");
+               }
+
+               pendingEvent = (EventDeletePendingEvent *)DataControlAsyncCallbackManagerSingleton::Instance().removeSQLUserData(bundleKey);
+               consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
+
+               if (DataControlAsyncCallbackManagerSingleton::Instance().isDataControlGC((void*)consumer))
+               {
+                       LoggerD("private object is garbage collected");
+                       delete pendingEvent;
+                       return;
+               }
+
+               event = pendingEvent->getEvent();
+
+               std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
+
+               for (size_t index = 0; index < result.size(); index++)
+               {
+                       LoggerD(result[index]);
+               }
+
+               if (result.size() < 2)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid result from datacontrol provider");
+               }
+               
+               // 0 : result true or false??
+               if (RESULT_TRUE_FROM_OSP != result[0])
+               {
+                       // 1 : error msg 
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, result[1]);
+               }
+
+               event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
+
+               
+       }
+       catch (const WrtDeviceApis::Commons::Exception& ex) 
+       {
+               LoggerE("Exception: " << ex.GetMessage());
+
+               if (event.Get() == NULL)
+               {
+                       LoggerD("event removed, invalid cb");
+                       return;
+               }
+               
+               event->setExceptionCode(ex.getCode());
+               event->setErrorMsg(ex.GetMessage());            
+       }
+       consumer->handlePendingEvent(event);
+
+       if (pendingEvent)
+       {
+               delete pendingEvent;
+       }
+}
+
+void sqldataControlUpdateCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
+{
+       LoggerD("Enter");
+
+       EventUpdatePendingEvent* pendingEvent = NULL;
+       SQLDataControlConsumer *consumer = NULL;
+       EventUpdatePtr event;
+       const char *bundleKey = NULL;
+       
+       try 
+       {
+               if (b == NULL)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
+               }
+
+        bundleKey = appsvc_get_data(b, OSP_K_REQUEST_ID);
+
+               if (bundleKey == NULL)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get key fail from datacontrol provider");
+               }
+
+               pendingEvent = (EventUpdatePendingEvent *)DataControlAsyncCallbackManagerSingleton::Instance().removeSQLUserData(bundleKey);    
+               consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
+
+               if (DataControlAsyncCallbackManagerSingleton::Instance().isDataControlGC((void*)consumer))
+               {
+                       LoggerD("private object is garbage collected");
+                       delete pendingEvent;
+                       return;
+               }
+               
+               event = pendingEvent->getEvent();
+
+               std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
+
+               for (size_t index = 0; index < result.size(); index++)
+               {
+                       LoggerD(result[index]);
+               }
+
+               if (result.size() < 2)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid result from datacontrol provider");
+               }
+               
+               // 0 : result true or false??
+               if (RESULT_TRUE_FROM_OSP != result[0])
+               {
+                       // 1 : error msg 
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, result[1]);
+               }
+
+               event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
+               
+       }
+       catch (const WrtDeviceApis::Commons::Exception& ex) 
+       {
+               LoggerE("Exception: " << ex.GetMessage());
+
+               if (event.Get() == NULL)
+               {
+                       LoggerD("event removed, invalid cb");
+                       return;
+               }
+                               
+               event->setExceptionCode(ex.getCode());
+               event->setErrorMsg(ex.GetMessage());            
+       }
+       consumer->handlePendingEvent(event);
+
+       if (pendingEvent)
+       {
+               delete pendingEvent;
+       }
+}
+
+void dataControlCommonCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
+{
+       LoggerD("Enter");
+
+       if (b == NULL)
+       {
+               LoggerD("Bundle null, Error");
+               return;         
+       }
+
+       const char *reqType = appsvc_get_data(b, OSP_K_DATACONTROL_REQUEST_TYPE);
+       
+       if (reqType == NULL)
+       {
+               LoggerD("UnkownRequest");
+               return;
+       }
+
+       std::istringstream buffer(reqType);
+       int reqTypeInt = 0;
+
+       buffer >> reqTypeInt;
+
+
+       LoggerD(reqTypeInt);
+       
+       switch (reqTypeInt)
+       {
+               case _DATACONTROL_REQUEST_TYPE_SQL_QUERY:
+                       sqldataControlSelectCallback(b, request_code, res, data);
+                       break;
+               case _DATACONTROL_REQUEST_TYPE_SQL_INSERT:
+                       sqldataControlInsertCallback(b, request_code, res, data);
+                       break;
+               case _DATACONTROL_REQUEST_TYPE_SQL_DELETE:
+                       sqldataControlDeleteCallback(b, request_code, res, data);
+                       break;
+               case _DATACONTROL_REQUEST_TYPE_SQL_UPDATE:
+                       sqldataControlUpdateCallback(b, request_code, res, data);
+                       break;
+               case _DATACONTROL_REQUEST_TYPE_MAP_QUERY:
+                       MappedDataControlGetValueCallback(b, request_code, res, data);
+                       break;
+               case _DATACONTROL_REQUEST_TYPE_MAP_INSERT:
+                       MappedDataControlAddValueCallback(b, request_code, res, data);
+                       break;
+               case _DATACONTROL_REQUEST_TYPE_MAP_UPDATE:
+                       MappedDataControlUpdateValueCallback(b, request_code, res, data);
+                       break;
+               case _DATACONTROL_REQUEST_TYPE_MAP_DELETE:
+                       MappedDataControlRemoveValueCallback(b, request_code, res, data);
+                       break;                  
+               default:
+                       LoggerD("Unknown Request");
+       }
+}
+
+// callbacks for mapped datacontrol
+void MappedDataControlGetValueCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
+{
+       LoggerD("Enter");
+       
+       EventGetValuePendingEvent *pendingEvent = NULL;
+       MappedDataControlConsumer *consumer = NULL;
+       EventGetValuePtr event;
+       size_t count = 0;
+       size_t index = 0;
+       std::ifstream getValueStream;
+       std::string getValueFilePath;
+       const char *bundleKey = NULL;
+       
+       try 
+       {
+               if (b == NULL)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
+               }
+
+        bundleKey = appsvc_get_data(b, OSP_K_REQUEST_ID);
+
+               if (bundleKey == NULL)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get key fail from datacontrol provider");
+               }
+
+               pendingEvent = (EventGetValuePendingEvent *)DataControlAsyncCallbackManagerSingleton::Instance().removeSQLUserData(bundleKey);
+               consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
+
+
+               if (DataControlAsyncCallbackManagerSingleton::Instance().isDataControlGC((void*)consumer))
+               {
+                       LoggerD("private object is garbage collected");
+                       delete pendingEvent;
+                       return;
+               }
+               
+               event = pendingEvent->getEvent();
+
+               if (b == NULL)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
+               }
+               std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
+
+               for (index = 0; index < result.size(); index++)
+               {
+                       LoggerD(result[index]);
+               }
+
+               if (result.size() < 2)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid result from datacontrol provider");
+               }
+               
+               // 0 : result true or false??
+               if (RESULT_TRUE_FROM_OSP != result[0])
+               {
+                       // 1 : error msg 
+                       if (result[1].find("E_KEY_NOT_FOUND") != std::string::npos)
+                       {
+                               ThrowMsg(WrtDeviceApis::Commons::NotFoundException, result[1]);
+                       }
+                       else
+                       {
+                               ThrowMsg(WrtDeviceApis::Commons::PlatformException, result[1]);
+                       }
+               }
+
+               event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
+               // 2 : value count
+               
+               std::istringstream str(result[2]);
+               str >> count;
+
+               // 3 ~ value...
+               if (count > 0)
+               {
+                       getValueFilePath = result[3];
+                       getValueStream.open(getValueFilePath.c_str(), std::ios::binary);
+                       int memorizedSize = 255;
+                       int size = 0;
+                       char *buf =  NULL;
+                       buf = new char[memorizedSize + 1];
+
+                       if (getValueStream.is_open()) 
+                       {
+                               LoggerD("open ok");
+                       }
+                       else
+                       {
+                               LoggerD("fail open" << getValueFilePath);
+                               ThrowMsg(WrtDeviceApis::Commons::PlatformException, "get value error");
+                       }
+                       
+                       for (index = 0; index < count; index++)
+                       {
+                               getValueStream.read((char*)&size, sizeof(int)); // read size
+                               //LoggerD(size);
+
+                               if (memorizedSize < size)
+                               {
+                                       memorizedSize = size;
+
+                                       if (buf)
+                                       {
+                                               delete[] buf;
+                                       }
+
+                                       buf = new char[memorizedSize + 1];
+                               }
+
+                               if (buf == NULL)
+                               {
+                                       ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Out of memory");
+                               }
+                               memset(buf, 0, memorizedSize + 1);
+                               getValueStream.read((char*)buf, size);
+                               buf[size] = '\0';
+                               
+                               event->addResultValue(buf);
+                       }
+
+               }
+               
+       }
+       catch (const WrtDeviceApis::Commons::Exception& ex) 
+       {
+               LoggerE("Exception: " << ex.GetMessage());
+               
+               if (event.Get() == NULL)
+               {
+                       LoggerD("event removed, invalid cb");
+                       return;
+               }
+               
+               event->setExceptionCode(ex.getCode());
+               event->setErrorMsg(ex.GetMessage());            
+       }
+       getValueStream.close();
+       if (unlink(getValueFilePath.c_str()) != 0) 
+       {
+               LoggerE("Error while removing SelectDataObject.");
+       }
+       
+       consumer->handlePendingEvent(event);
+
+       if (pendingEvent)
+       {
+               delete pendingEvent;
+       }
+       handleRemainingPendingEvent();
+}
+
+void MappedDataControlAddValueCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
+{
+       LoggerD("Enter");
+
+       
+       EventAddValuePendingEvent *pendingEvent = NULL;
+       MappedDataControlConsumer *consumer = NULL;
+       EventAddValuePtr event;
+       const char *bundleKey = NULL;
+
+       try 
+       {
+               if (b == NULL)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
+               }
+
+        bundleKey = appsvc_get_data(b, OSP_K_REQUEST_ID);
+
+               if (bundleKey == NULL)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get key fail from datacontrol provider");
+               }
+
+               pendingEvent = (EventAddValuePendingEvent *)DataControlAsyncCallbackManagerSingleton::Instance().removeSQLUserData(bundleKey);
+               consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
+               
+
+               if (DataControlAsyncCallbackManagerSingleton::Instance().isDataControlGC((void*)consumer))
+               {
+                       LoggerD("private object is garbage collected");
+                       delete pendingEvent;
+                       return;
+               }
+               
+               event = pendingEvent->getEvent();
+
+               std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
+
+               for (size_t index = 0; index < result.size(); index++)
+               {
+                       LoggerD(result[index]);
+               }
+
+               if (result.size() < 2)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid result from datacontrol provider");
+               }
+               
+               // 0 : result true or false??
+               if (RESULT_TRUE_FROM_OSP != result[0])
+               {
+                       // 1 : error msg 
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, result[1]);
+               }
+
+               event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
+               
+       }
+       catch (const WrtDeviceApis::Commons::Exception& ex) 
+       {
+               LoggerE("Exception: " << ex.GetMessage());
+               
+               if (event.Get() == NULL)
+               {
+                       LoggerD("event removed, invalid cb");
+                       return;
+               }
+               
+               LoggerE("Exception: " << ex.GetMessage());
+               event->setExceptionCode(ex.getCode());
+               event->setErrorMsg(ex.GetMessage());            
+       }
+       consumer->handlePendingEvent(event);
+
+       if (pendingEvent)
+       {
+               delete pendingEvent;
+       }
+       handleRemainingPendingEvent();
+
+}
+
+void MappedDataControlRemoveValueCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
+{
+       LoggerD("Enter");
+
+       EventRemoveValuePendingEvent* pendingEvent = NULL;
+       MappedDataControlConsumer *consumer = NULL;
+       EventRemoveValuePtr event;
+       const char *bundleKey = NULL;
+       
+       try 
+       {
+               if (b == NULL)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
+               }
+
+        bundleKey = appsvc_get_data(b, OSP_K_REQUEST_ID);
+
+               if (bundleKey == NULL)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get key fail from datacontrol provider");
+               }
+
+               pendingEvent = (EventRemoveValuePendingEvent *)DataControlAsyncCallbackManagerSingleton::Instance().removeSQLUserData(bundleKey);
+               consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
+
+               
+               if (DataControlAsyncCallbackManagerSingleton::Instance().isDataControlGC((void*)consumer))
+               {
+                       LoggerD("private object is garbage collected");
+                       delete pendingEvent;
+                       return;
+               }
+               
+               event = pendingEvent->getEvent();
+
+               if (b == NULL)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
+               }
+               std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
+
+               for (size_t index = 0; index < result.size(); index++)
+               {
+                       LoggerD(result[index]);
+               }
+
+               if (result.size() < 2)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid result from datacontrol provider");
+               }
+               
+               // 0 : result true or false??
+               if (RESULT_TRUE_FROM_OSP != result[0])
+               {
+                       // 1 : error msg 
+                       if (result[1].find("E_KEY_NOT_FOUND") != std::string::npos)
+                       {
+                               ThrowMsg(WrtDeviceApis::Commons::NotFoundException, result[1]);
+                       }
+                       else
+                       {
+                               ThrowMsg(WrtDeviceApis::Commons::PlatformException, result[1]);
+                       }
+               }
+
+               event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
+
+               
+       }
+       catch (const WrtDeviceApis::Commons::Exception& ex) 
+       {
+               LoggerE("Exception: " << ex.GetMessage());
+
+               if (event.Get() == NULL)
+               {
+                       LoggerD("event removed, invalid cb");
+                       return;
+               }
+
+               event->setExceptionCode(ex.getCode());
+               event->setErrorMsg(ex.GetMessage());            
+       }
+       consumer->handlePendingEvent(event);
+
+       if (pendingEvent)
+       {
+               delete pendingEvent;
+       }
+       handleRemainingPendingEvent();
+}
+
+void MappedDataControlUpdateValueCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
+{
+       LoggerD("Enter");
+
+       EventUpdateValuePendingEvent* pendingEvent = NULL;
+       MappedDataControlConsumer *consumer = NULL;
+       EventUpdateValuePtr event;
+       const char *bundleKey = NULL;
+
+       try 
+       {
+               if (b == NULL)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
+               }
+
+        bundleKey = appsvc_get_data(b, OSP_K_REQUEST_ID);
+
+               if (bundleKey == NULL)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get key fail from datacontrol provider");
+               }
+
+               pendingEvent = (EventUpdateValuePendingEvent *)DataControlAsyncCallbackManagerSingleton::Instance().removeSQLUserData(bundleKey);
+               consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
+
+               
+               if (DataControlAsyncCallbackManagerSingleton::Instance().isDataControlGC((void*)consumer))
+               {
+                       LoggerD("private object is garbage collected");
+                       delete pendingEvent;
+                       return;
+               }
+                               
+               event = pendingEvent->getEvent();
+
+               if (b == NULL)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
+               }
+               std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
+
+               for (size_t index = 0; index < result.size(); index++)
+               {
+                       LoggerD(result[index]);
+               }
+
+               if (result.size() < 2)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid result from datacontrol provider");
+               }
+               
+               // 0 : result true or false??
+               if (RESULT_TRUE_FROM_OSP != result[0])
+               {
+                       // 1 : error msg 
+                       if (result[1].find("E_KEY_NOT_FOUND") != std::string::npos)
+                       {
+                               ThrowMsg(WrtDeviceApis::Commons::NotFoundException, result[1]);
+                       }
+                       else
+                       {
+                               ThrowMsg(WrtDeviceApis::Commons::PlatformException, result[1]);
+                       }
+               }
+
+               event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
+               
+       }
+       catch (const WrtDeviceApis::Commons::Exception& ex) 
+       {
+       
+               LoggerE("Exception: " << ex.GetMessage());
+               
+               if (event.Get() == NULL)
+               {
+                       LoggerD("event removed, invalid cb");
+                       return;
+               }
+
+
+               event->setExceptionCode(ex.getCode());
+               event->setErrorMsg(ex.GetMessage());            
+       }
+       consumer->handlePendingEvent(event);
+
+       if (pendingEvent)
+       {
+               delete pendingEvent;
+       }
+       handleRemainingPendingEvent();
+}
+
+}
+}
+
diff --git a/src/DataControl/DataControlCallback.h b/src/DataControl/DataControlCallback.h
new file mode 100755 (executable)
index 0000000..97f93b8
--- /dev/null
@@ -0,0 +1,61 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+
+#ifndef TIZENAPIS_TIZEN_DATACONTROL_CALLBACK_H_
+#define TIZENAPIS_TIZEN_DATACONTROL_CALLBACK_H_
+
+#include <map>
+#include <vector>
+#include <string>
+#include <app.h>
+#include <appsvc/appsvc.h>
+
+namespace DeviceAPI {
+namespace DataControl {
+
+// utils for common usage
+std::vector<std::string> getDataArrayFromBundle(bundle *b, std::string key);
+std::string getProviderApplicationId(const std::string type, const std::string& provId);
+std::string getCurrentApplicationId();
+std::string getProviderPkgId(const std::string& appId);
+void SendAppControlLaunchToProvider(void* event, unsigned short& currentJob);
+void handleRemainingPendingEvent();
+std::string convertIntToString(unsigned int data);
+void addArrayToBundle(bundle* passData, std::vector<std::string>& array);
+std::string generateFileName(unsigned int reqId, const std::string currentAppId);
+
+void dataControlCommonCallback(bundle* b, int request_code, appsvc_result_val res, void* data);
+
+// callbacks for sqldatacontrol
+void sqldataControlSelectCallback(bundle* b, int request_code, appsvc_result_val res, void* data);
+void sqldataControlInsertCallback(bundle* b, int request_code, appsvc_result_val res, void* data);
+void sqldataControlDeleteCallback(bundle* b, int request_code, appsvc_result_val res, void* data);
+void sqldataControlUpdateCallback(bundle* b, int request_code, appsvc_result_val res, void* data);
+// callbacks for mapped datacontrol
+void MappedDataControlGetValueCallback(bundle* b, int request_code, appsvc_result_val res, void* data);
+void MappedDataControlAddValueCallback(bundle* b, int request_code, appsvc_result_val res, void* data);
+void MappedDataControlRemoveValueCallback(bundle* b, int request_code, appsvc_result_val res, void* data);
+void MappedDataControlUpdateValueCallback(bundle* b, int request_code, appsvc_result_val res, void* data);
+
+
+
+}
+}
+
+#endif
+
diff --git a/src/DataControl/DataControlPendingEvent.h b/src/DataControl/DataControlPendingEvent.h
new file mode 100755 (executable)
index 0000000..f9e9c9e
--- /dev/null
@@ -0,0 +1,207 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+
+#ifndef TIZENAPIS_TIZEN_DATACONTROL_PENDING_EVENT_H_
+#define TIZENAPIS_TIZEN_DATACONTROL_PENDING_EVENT_H_
+
+#include "EventRemoveValue.h"
+#include "EventAddValue.h"
+#include "EventGetValue.h"
+#include "EventUpdateValue.h"
+#include "EventDelete.h"
+#include "EventInsert.h"
+#include "EventSelect.h"
+#include "EventUpdate.h"
+
+namespace DeviceAPI {
+namespace DataControl {
+       
+class CommonPendingEvent
+{
+public: 
+       CommonPendingEvent(void *thisObject, std::string dataId, 
+               std::string pAppId, std::string proivderId, std::string cAppId) : 
+               m_dataId(dataId), m_providerAppId(pAppId), 
+               m_providerId(proivderId), m_currentAppId(cAppId), m_thisObject(thisObject) {}
+       virtual ~CommonPendingEvent() {}
+       void* getThisObject() const { return m_thisObject; }
+       std::string getDataId() const { return m_dataId;}
+       std::string getProviderId() const { return m_providerId;}
+       std::string getProviderAppId() const { return m_providerAppId;}
+       std::string getCurrentAppId()  const { return m_currentAppId;}
+       
+protected:     
+       std::string m_dataId;   
+       std::string m_providerAppId;
+       std::string m_providerId;
+       std::string m_currentAppId;
+       void *m_thisObject;
+};
+
+class EventInsertPendingEvent : public CommonPendingEvent
+{
+public:
+       EventInsertPendingEvent(void *thisObject, std::string dataId, 
+               std::string pAppId, std::string proivderId, 
+               std::string cAppId, const  EventInsertPtr &event) :
+               CommonPendingEvent(thisObject, dataId, pAppId, proivderId, cAppId), m_event(event)
+       {
+       }
+
+       virtual ~EventInsertPendingEvent()
+       {
+       }
+       EventInsertPtr getEvent() const { return m_event; }
+private:
+       EventInsertPtr m_event;
+};
+
+class EventDeletePendingEvent : public CommonPendingEvent
+{
+public:
+       EventDeletePendingEvent(void *thisObject, std::string dataId, 
+               std::string pAppId, std::string proivderId, 
+               std::string cAppId, const  EventDeletePtr &event) :
+               CommonPendingEvent(thisObject, dataId, pAppId, proivderId, cAppId), m_event(event)
+       {
+       }
+
+       virtual ~EventDeletePendingEvent()
+       {
+       }
+       EventDeletePtr getEvent() const { return m_event; }
+private:
+       EventDeletePtr m_event;
+};
+
+class EventUpdatePendingEvent : public CommonPendingEvent
+{
+public:
+       EventUpdatePendingEvent(void *thisObject, std::string dataId, 
+               std::string pAppId, std::string proivderId, 
+               std::string cAppId, const  EventUpdatePtr &event) :
+               CommonPendingEvent(thisObject, dataId, pAppId, proivderId, cAppId), m_event(event)
+       {
+       }
+
+       virtual ~EventUpdatePendingEvent()
+       {
+       }
+       EventUpdatePtr getEvent() const { return m_event; }
+private:
+       EventUpdatePtr m_event;
+};
+
+class EventSelectPendingEvent : public CommonPendingEvent
+{
+public:
+       EventSelectPendingEvent(void *thisObject, std::string dataId, 
+               std::string pAppId, std::string proivderId, 
+               std::string cAppId, const  EventSelectPtr &event) :
+               CommonPendingEvent(thisObject, dataId, pAppId, proivderId, cAppId), m_event(event)
+       {
+       }
+
+       virtual ~EventSelectPendingEvent()
+       {
+       }
+       EventSelectPtr getEvent() const { return m_event; }
+private:
+       EventSelectPtr m_event;
+};
+
+
+class EventAddValuePendingEvent : public CommonPendingEvent
+{
+public:
+       EventAddValuePendingEvent(void *thisObject, std::string dataId, 
+               std::string pAppId, std::string proivderId, 
+               std::string cAppId, const  EventAddValuePtr &event) :
+               CommonPendingEvent(thisObject, dataId, pAppId, proivderId, cAppId), m_event(event)
+       {
+       }
+
+       virtual ~EventAddValuePendingEvent()
+       {
+       }
+       EventAddValuePtr getEvent() const { return m_event; }
+private:
+       EventAddValuePtr m_event;
+};
+
+class EventRemoveValuePendingEvent : public CommonPendingEvent
+{
+public:
+       EventRemoveValuePendingEvent(void *thisObject, std::string dataId, 
+               std::string pAppId, std::string proivderId, 
+               std::string cAppId, const  EventRemoveValuePtr &event) :
+               CommonPendingEvent(thisObject, dataId, pAppId, proivderId, cAppId), m_event(event)
+       {
+       }
+
+       virtual ~EventRemoveValuePendingEvent()
+       {
+       }
+       void* getThisObject() const { return m_thisObject; }
+       EventRemoveValuePtr getEvent() const { return m_event; }
+private:
+       EventRemoveValuePtr m_event;
+};
+
+class EventUpdateValuePendingEvent: public CommonPendingEvent
+{
+public:
+       EventUpdateValuePendingEvent(void *thisObject, std::string dataId, 
+               std::string pAppId, std::string proivderId, 
+               std::string cAppId, const  EventUpdateValuePtr &event) :
+               CommonPendingEvent(thisObject, dataId, pAppId, proivderId, cAppId), m_event(event)
+       {
+       }
+
+       virtual ~EventUpdateValuePendingEvent()
+       {
+       }
+       EventUpdateValuePtr getEvent() const { return m_event; }
+private:
+       EventUpdateValuePtr m_event;
+};
+
+class EventGetValuePendingEvent : public CommonPendingEvent
+{
+public:
+       EventGetValuePendingEvent(void *thisObject, std::string dataId, 
+               std::string pAppId, std::string proivderId, 
+               std::string cAppId, const  EventGetValuePtr &event) :
+               CommonPendingEvent(thisObject, dataId, pAppId, proivderId, cAppId), m_event(event)
+       {
+       }
+
+       virtual ~EventGetValuePendingEvent()
+       {
+       }
+       EventGetValuePtr getEvent() const { return m_event; }
+private:
+       void *m_thisObject;
+       EventGetValuePtr m_event;
+};
+
+}
+}
+
+#endif
+
index 565e674..b1239b1 100644 (file)
 #define PROTOCOL_DATA_MAX 16 * 1024
 #define ROW_DATA_MAX 1024 * 1024
 
+#define OSP_V_CALLER_TYPE_OSP "osp"
+#define OSP_V_LAUNCH_TYPE_LAUNCH  "launch"
+#define OSP_V_LAUNCH_TYPE_APPCONTROL  "appcontrol"
+#define OSP_V_LAUNCH_TYPE_DATACONTROL  "datacontrol"
+#define OSP_V_LAUNCH_TYPE_CONDTION  "condition"
+#define OSP_V_REQUEST_TYPE_SQL_QUERY  "sql_query"
+#define OSP_V_REQUEST_TYPE_SQL_INSERT  "sql_insert"
+#define OSP_V_REQUEST_TYPE_SQL_UPDATE  "sql_update"
+#define OSP_V_REQUEST_TYPE_SQL_DELETE  "sql_delete"
+#define OSP_V_REQUEST_TYPE_MAP_QEURY  "map_query"
+#define OSP_V_REQUEST_TYPE_MAP_INSERT  "map_insert"
+#define OSP_V_REQUEST_TYPE_MAP_UPDATE  "map_update"
+#define OSP_V_REQUEST_TYPE_MAP_DELETE  "map_delete"
+
+#define OSP_K_CALLER_TYPE   "__OSP_CALLER_TYPE__"
+#define OSP_K_LAUNCH_TYPE   "__OSP_LAUNCH_TYPE__"
+#define OSP_K_ARG           "__OSP_ARGS__"
+#define OSP_K_COND          "__OSP_COND_NAME__"
+#define OSP_K_APPID         "__OSP_APPID__"
+#define OSP_K_REQUEST_ID    "__OSP_REQUEST_ID__"
+#define OSP_K_APPCONTROL_PROVIDER   "__OSP_APPCONTROL_PROVIDER__"
+#define OSP_K_APPCONTROL_OPERATION  "__OSP_APPCONTROL_OPERATION__"
+#define OSP_K_APPCONTROL_CATEGORY   "__OSP_APPCONTROL_CATEGORY__"
+#define OSP_K_APPCONTROL_MIME       "__OSP_APPCONTROL_MIME__"
+#define OSP_K_APPCONTROL_URI        "__OSP_APPCONTROL_URI__"
+#define OSP_K_DATACONTROL_PROVIDER      "__OSP_DATACONTROL_PROVIDER__"
+#define OSP_K_DATACONTROL_REQUEST_TYPE  "__OSP_DATACONTROL_REQUEST_TYPE__"
+#define RESULT_TRUE_FROM_OSP "1"
+#define RESULT_FALSE_FROM_OSP "0"
+#define OSP_K_DATACONTROL_PROTOCOL_VERSION  "__OSP_DATACONTROL_PROTOCOL_VERSION__"
+#define OSP_K_DATACONTROL_PROTOCOL_VERSION_VALUE "ver_2.1.0.3"
+
+#define DATACONTROL_PROTOCOL_DIR_TOP  "/tmp/osp"
+#define DATACONTROL_PROTOCOL_DIR_MIDDLE  "/tmp/osp/data-control"
+#define DATACONTROL_PROTOCOL_DIR  "/tmp/osp/data-control/request"
+
 enum _DataControlRequestType
 {
        _DATACONTROL_REQUEST_TYPE_UNDEFINED = 0,
index cb39fa1..229bc1a 100644 (file)
 #include <sstream>
 #include <iostream>
 #include <package-manager.h>
+#include <security-server.h>
+
 #include "DataControlAsyncCallbackManager.h"
+#include "DataControlCallback.h"
+
+#include "DataType.h"
 
 
 namespace DeviceAPI {
 namespace DataControl {
 
-
-namespace {
-
-static const char OSP_V_CALLER_TYPE_OSP[] = "osp";
-static const char OSP_V_LAUNCH_TYPE_LAUNCH[] = "launch";
-static const char OSP_V_LAUNCH_TYPE_APPCONTROL[] = "appcontrol";
-static const char OSP_V_LAUNCH_TYPE_DATACONTROL[] = "datacontrol";
-static const char OSP_V_LAUNCH_TYPE_CONDTION[] = "condition";
-static const char OSP_V_REQUEST_TYPE_SQL_QUERY[] = "sql_query";
-static const char OSP_V_REQUEST_TYPE_SQL_INSERT[] = "sql_insert";
-static const char OSP_V_REQUEST_TYPE_SQL_UPDATE[] = "sql_update";
-static const char OSP_V_REQUEST_TYPE_SQL_DELETE[] = "sql_delete";
-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 BUNDLE_KEY_WINDOW[] = "__APP_SVC_K_WIN_ID__";
-
-
-#define OSP_K_CALLER_TYPE   "__OSP_CALLER_TYPE__"
-#define OSP_K_LAUNCH_TYPE   "__OSP_LAUNCH_TYPE__"
-#define OSP_K_ARG           "__OSP_ARGS__"
-#define OSP_K_COND          "__OSP_COND_NAME__"
-#define OSP_K_APPID         "__OSP_APPID__"
-#define OSP_K_REQUEST_ID    "__OSP_REQUEST_ID__"
-#define OSP_K_APPCONTROL_PROVIDER   "__OSP_APPCONTROL_PROVIDER__"
-#define OSP_K_APPCONTROL_OPERATION  "__OSP_APPCONTROL_OPERATION__"
-#define OSP_K_APPCONTROL_CATEGORY   "__OSP_APPCONTROL_CATEGORY__"
-#define OSP_K_APPCONTROL_MIME       "__OSP_APPCONTROL_MIME__"
-#define OSP_K_APPCONTROL_URI        "__OSP_APPCONTROL_URI__"
-#define OSP_K_DATACONTROL_PROVIDER      "__OSP_DATACONTROL_PROVIDER__"
-#define OSP_K_DATACONTROL_REQUEST_TYPE  "__OSP_DATACONTROL_REQUEST_TYPE__"
-#define OSP_K_DATACONTROL_PROTOCOL_VERSION  "__OSP_DATACONTROL_PROTOCOL_VERSION__"
-#define OSP_K_DATACONTROL_PROTOCOL_VERSION_VALUE "ver_2.1.0.3"
-
-
-#define RESULT_TRUE_FROM_OSP "1"
-#define RESULT_FALSE_FROM_OSP "0"
-
-static std::vector<std::string> getDataArrayFromBundle(bundle *b, std::string key)
-{
-       std::vector<std::string> result;
-       const char **array;
-       int length = 0;
-       int index = 0;
-       
-       array = appsvc_get_data_array(b, key.c_str(), &length);
-
-       if (array == NULL || length == 0)
-       {
-               ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result data fail from datacontrol provider");
-       }
-       
-       for (index = 0; index < length; index++)
-       {
-               result.push_back(array[index]);
-       }
-
-       return result;
-}
-
-
-
-static void MappedDataControlGetValueCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
-{
-       LoggerD("Enter");
-       
-       EventGetValuePendingEvent *pendingEvent = NULL;
-       MappedDataControlConsumer *consumer = NULL;
-       EventGetValuePtr event;
-       size_t count = 0;
-       size_t index = 0;
-       std::ifstream getValueStream;
-       std::string getValueFilePath;
-       
-       try 
-       {
-               if (data == NULL)
-               {
-                       LoggerD("data null, can not send result to JS Layer");
-                       return;
-               }
-
-               pendingEvent = (EventGetValuePendingEvent *)data;
-               consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
-
-               if (DataControlAsyncCallbackManagerSingleton::Instance().isMappedDataControlGC((void*)consumer))
-               {
-                       LoggerD("private object is garbage collected");
-                       delete pendingEvent;
-                       return;
-               }
-               
-               event = pendingEvent->getEvent();
-
-               if (b == NULL)
-               {
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
-               }
-               std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
-
-               for (index = 0; index < result.size(); index++)
-               {
-                       LoggerD(result[index]);
-               }
-
-               if (result.size() < 2)
-               {
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid result from datacontrol provider");
-               }
-               
-               // 0 : result true or false??
-               if (RESULT_TRUE_FROM_OSP != result[0])
-               {
-                       // 1 : error msg 
-                       if (result[1].find("E_KEY_NOT_FOUND") != std::string::npos)
-                       {
-                               ThrowMsg(WrtDeviceApis::Commons::NotFoundException, result[1]);
-                       }
-                       else
-                       {
-                               ThrowMsg(WrtDeviceApis::Commons::PlatformException, result[1]);
-                       }
-               }
-
-               event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
-               // 2 : value count
-               
-               std::istringstream str(result[2]);
-               str >> count;
-
-               // 3 ~ value...
-               if (count > 0)
-               {
-                       getValueFilePath = result[3];
-                       getValueStream.open(getValueFilePath.c_str(), std::ios::binary);
-                       int memorizedSize = 255;
-                       int size = 0;
-                       char *buf =  NULL;
-                       buf = new char[memorizedSize + 1];
-
-                       if (getValueStream.is_open()) 
-                       {
-                               LoggerD("open ok");
-                       }
-                       else
-                       {
-                               LoggerD("fail open" << getValueFilePath);
-                               ThrowMsg(WrtDeviceApis::Commons::PlatformException, "get value error");
-                       }
-                       
-                       for (index = 0; index < count; index++)
-                       {
-                               getValueStream.read((char*)&size, sizeof(int)); // read size
-                               //LoggerD(size);
-
-                               if (memorizedSize < size)
-                               {
-                                       memorizedSize = size;
-
-                                       if (buf)
-                                       {
-                                               delete[] buf;
-                                       }
-
-                                       buf = new char[memorizedSize + 1];
-                               }
-
-                               if (buf == NULL)
-                               {
-                                       ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Out of memory");
-                               }
-                               memset(buf, 0, memorizedSize + 1);
-                               getValueStream.read((char*)buf, size);
-                               buf[size] = '\0';
-                               
-                               //LoggerD(buf);
-                               
-                               event->addResultValue(buf);
-                       }
-
-
-/*                     for (index = 3; index < result.size(); index++)
-                       {
-                               event->addResultValue(result[index]);
-                       }
-*/
-               }
-               
-       }
-       catch (const WrtDeviceApis::Commons::Exception& ex) 
-       {
-               LoggerE("Exception: " << ex.GetMessage());
-               event->setExceptionCode(ex.getCode());
-               event->setErrorMsg(ex.GetMessage());            
-       }
-       getValueStream.close();
-       if (unlink(getValueFilePath.c_str()) != 0) 
-       {
-               LoggerE("Error while removing SelectDataObject.");
-       }
-
-       consumer->handlePendingEvent(event);
-
-       if (pendingEvent)
-       {
-               delete pendingEvent;
-       }
-
-}
-
-static void MappedDataControlAddValueCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
-{
-       LoggerD("Enter");
-
-       
-       EventAddValuePendingEvent *pendingEvent = NULL;
-       MappedDataControlConsumer *consumer = NULL;
-       EventAddValuePtr event;
-
-       try 
-       {
-               if (data == NULL)
-               {
-                       LoggerD("data null, can not send result to JS Layer");
-                       return;
-               }
-
-               pendingEvent = (EventAddValuePendingEvent *)data;
-               consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
-
-               if (DataControlAsyncCallbackManagerSingleton::Instance().isMappedDataControlGC((void*)consumer))
-               {
-                       LoggerD("private object is garbage collected");
-                       delete pendingEvent;
-                       return;
-               }
-               
-               event = pendingEvent->getEvent();
-
-               if (b == NULL)
-               {
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
-               }
-               std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
-
-               for (size_t index = 0; index < result.size(); index++)
-               {
-                       LoggerD(result[index]);
-               }
-
-               if (result.size() < 2)
-               {
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid result from datacontrol provider");
-               }
-               
-               // 0 : result true or false??
-               if (RESULT_TRUE_FROM_OSP != result[0])
-               {
-                       // 1 : error msg 
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, result[1]);
-               }
-
-               event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
-               
-       }
-       catch (const WrtDeviceApis::Commons::Exception& ex) 
-       {
-               LoggerE("Exception: " << ex.GetMessage());
-               event->setExceptionCode(ex.getCode());
-               event->setErrorMsg(ex.GetMessage());            
-       }
-       consumer->handlePendingEvent(event);
-
-       if (pendingEvent)
-       {
-               delete pendingEvent;
-       }
-
-}
-
-static void MappedDataControlRemoveValueCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
-{
-       LoggerD("Enter");
-
-       if (data == NULL)
-       {
-               LoggerD("Data or Bundle error");
-               return;
-       }
-
-       EventRemoveValuePendingEvent* pendingEvent = NULL;
-       MappedDataControlConsumer *consumer = NULL;
-       EventRemoveValuePtr event;
-       
-       try 
-       {
-               if (data == NULL)
-               {
-                       LoggerD("data null, can not send result to JS Layer");
-                       return;
-               }
-
-               pendingEvent = (EventRemoveValuePendingEvent *)data;
-               consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
-               
-               if (DataControlAsyncCallbackManagerSingleton::Instance().isMappedDataControlGC((void*)consumer))
-               {
-                       LoggerD("private object is garbage collected");
-                       delete pendingEvent;
-                       return;
-               }
-               
-               event = pendingEvent->getEvent();
-
-               if (b == NULL)
-               {
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
-               }
-               std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
-
-               for (size_t index = 0; index < result.size(); index++)
-               {
-                       LoggerD(result[index]);
-               }
-
-               if (result.size() < 2)
-               {
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid result from datacontrol provider");
-               }
-               
-               // 0 : result true or false??
-               if (RESULT_TRUE_FROM_OSP != result[0])
-               {
-                       // 1 : error msg 
-                       if (result[1].find("E_KEY_NOT_FOUND") != std::string::npos)
-                       {
-                               ThrowMsg(WrtDeviceApis::Commons::NotFoundException, result[1]);
-                       }
-                       else
-                       {
-                               ThrowMsg(WrtDeviceApis::Commons::PlatformException, result[1]);
-                       }
-               }
-
-               event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
-
-               
-       }
-       catch (const WrtDeviceApis::Commons::Exception& ex) 
-       {
-               LoggerE("Exception: " << ex.GetMessage());
-               event->setExceptionCode(ex.getCode());
-               event->setErrorMsg(ex.GetMessage());            
-       }
-       consumer->handlePendingEvent(event);
-
-       if (pendingEvent)
-       {
-               delete pendingEvent;
-       }
-}
-
-static void MappedDataControlUpdateValueCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
-{
-       LoggerD("Enter");
-
-       EventUpdateValuePendingEvent* pendingEvent = NULL;
-       MappedDataControlConsumer *consumer = NULL;
-       EventUpdateValuePtr event;
-       
-       try 
-       {
-               if (data == NULL)
-               {
-                       LoggerD("data null, can not send result to JS Layer");
-                       return;
-               }
-               
-               pendingEvent = (EventUpdateValuePendingEvent *)data;
-               consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
-               
-               if (DataControlAsyncCallbackManagerSingleton::Instance().isMappedDataControlGC((void*)consumer))
-               {
-                       LoggerD("private object is garbage collected");
-                       delete pendingEvent;
-                       return;
-               }
-                               
-               event = pendingEvent->getEvent();
-
-               if (b == NULL)
-               {
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
-               }
-               std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
-
-               for (size_t index = 0; index < result.size(); index++)
-               {
-                       LoggerD(result[index]);
-               }
-
-               if (result.size() < 2)
-               {
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid result from datacontrol provider");
-               }
-               
-               // 0 : result true or false??
-               if (RESULT_TRUE_FROM_OSP != result[0])
-               {
-                       // 1 : error msg 
-                       if (result[1].find("E_KEY_NOT_FOUND") != std::string::npos)
-                       {
-                               ThrowMsg(WrtDeviceApis::Commons::NotFoundException, result[1]);
-                       }
-                       else
-                       {
-                               ThrowMsg(WrtDeviceApis::Commons::PlatformException, result[1]);
-                       }
-               }
-
-               event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
-               
-       }
-       catch (const WrtDeviceApis::Commons::Exception& ex) 
-       {
-               LoggerE("Exception: " << ex.GetMessage());
-               event->setExceptionCode(ex.getCode());
-               event->setErrorMsg(ex.GetMessage());            
-       }
-       consumer->handlePendingEvent(event);
-
-       if (pendingEvent)
-       {
-               delete pendingEvent;
-       }
-
-}
-
-static void MappedDataControlCommonCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
-{
-       LoggerD("Enter");
-
-       if (b == NULL)
-       {
-               LoggerD("Bundle null, Error");
-               return;         
-       }
-       
-
-       const char *reqType = appsvc_get_data(b, OSP_K_DATACONTROL_REQUEST_TYPE);
-       
-       if (reqType == NULL)
-       {
-               LoggerD("UnkownRequest");
-               return;
-       }
-
-       std::istringstream buffer(reqType);
-       int reqTypeInt = 0;
-
-       buffer >> reqTypeInt;
-
-
-       LoggerD(reqTypeInt);
-       
-
-       switch (reqTypeInt)
-       {
-               case _DATACONTROL_REQUEST_TYPE_MAP_QUERY:
-                       MappedDataControlGetValueCallback(b, request_code, res, data);
-                       break;
-               case _DATACONTROL_REQUEST_TYPE_MAP_INSERT:
-                       MappedDataControlAddValueCallback(b, request_code, res, data);
-                       break;
-               case _DATACONTROL_REQUEST_TYPE_MAP_UPDATE:
-                       MappedDataControlUpdateValueCallback(b, request_code, res, data);
-                       break;
-               case _DATACONTROL_REQUEST_TYPE_MAP_DELETE:
-                       MappedDataControlRemoveValueCallback(b, request_code, res, data);
-                       break;
-               default:
-                       LoggerD("Unknown Request");
-       }
-
-}
-
-}
 MappedDataControlConsumer::MappedDataControlConsumer(std::string& provId, std::string& dataId, std::string& type) 
 {
        LoggerD("Enter");
 
-       m_appId = getApplicationId(provId);
+       
        m_type = type;;
        m_dataId = dataId;
        m_providerId = provId;
-       DataControlAsyncCallbackManagerSingleton::Instance().setMappedDataControlGC((void*)this, false);
+
+       m_appId = getProviderApplicationId(OSP_PKGINFO_MAP_TYPE, provId);
+       m_ProviderPkgId = getProviderPkgId(m_appId);
+       security_server_app_give_access(m_ProviderPkgId.c_str(), -1);
+       
+       m_currentAppId = getCurrentApplicationId();
+
+       DataControlAsyncCallbackManagerSingleton::Instance().setDataControlGC((void*)this, false);
 
 }
 
 MappedDataControlConsumer::~MappedDataControlConsumer() 
 {
        LoggerD("Enter");
-       DataControlAsyncCallbackManagerSingleton::Instance().setMappedDataControlGC((void*)this, true);
+       DataControlAsyncCallbackManagerSingleton::Instance().setDataControlGC((void*)this, true);
        
 }
 
@@ -558,96 +82,81 @@ std::string MappedDataControlConsumer::getType()
        return m_type;
 }
 
-
-
-
-std::string MappedDataControlConsumer::getApplicationId(const std::string& provId)
+void MappedDataControlConsumer::handleCommonErrorEvent(void* userData, unsigned int code, std::string msg)
 {
-       std::string appIdStr = "";
-
-       char* appId = NULL;
-       char* access = NULL;
-       const char *passId = provId.c_str();
-       
-       if (m_appId.length() == 0)
+       if (userData == NULL)
        {
+               LoggerD("userData null");
+               return;
+       }
+       
+       CommonPendingEvent* pEvent = (CommonPendingEvent*)userData;
        
-               if(     pkgmgr_datacontrol_get_info(passId, OSP_PKGINFO_MAP_TYPE, &appId, &access) < 0)
+       try 
+       {
+               if (dynamic_cast<EventAddValuePendingEvent*>(pEvent) != NULL)
                {
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "get appId error");
-               }
+                       EventAddValuePendingEvent* pendingAddValueEvent = (EventAddValuePendingEvent*)pEvent;
+                       EventAddValuePtr addValueEvent = pendingAddValueEvent->getEvent();
+                       addValueEvent->setExceptionCode((WrtDeviceApis::Commons::ExceptionCodes::Enumeration)code);
+                       addValueEvent->setErrorMsg(msg);                
                
-
-               if (appId)
+                       WrtDeviceApis::Commons::EventRequestReceiver<EventAddValue>::ManualAnswer(addValueEvent); 
+               }
+               else if (dynamic_cast<EventUpdateValuePendingEvent*>(pEvent) != NULL)
                {
-                       appIdStr = appId;
-                       free(appId);
+                       EventUpdateValuePendingEvent* pendingUpdateValueEvent = (EventUpdateValuePendingEvent*)pEvent;
+                       EventUpdateValuePtr updateValueEvent = pendingUpdateValueEvent->getEvent();
+                       updateValueEvent->setExceptionCode((WrtDeviceApis::Commons::ExceptionCodes::Enumeration)code);
+                       updateValueEvent->setErrorMsg(msg);             
+                       
+                       WrtDeviceApis::Commons::EventRequestReceiver<EventUpdateValue>::ManualAnswer(updateValueEvent); 
                }
-
-               if (access)
+               else if (dynamic_cast<EventGetValuePendingEvent*>(pEvent) != NULL)
                {
-                       free(access);
+                       EventGetValuePendingEvent* pendingGetValueEvent = (EventGetValuePendingEvent*)pEvent;
+                       EventGetValuePtr getValueEvent = pendingGetValueEvent->getEvent();
+                       getValueEvent->setExceptionCode((WrtDeviceApis::Commons::ExceptionCodes::Enumeration)code);
+                       getValueEvent->setErrorMsg(msg);
+                       
+                       WrtDeviceApis::Commons::EventRequestReceiver<EventGetValue>::ManualAnswer(getValueEvent); 
                }
-               
-               m_appId = appIdStr;
-
-
-       }
-       return m_appId;
-
-}
-
-void MappedDataControlConsumer::addArrayToBundle(bundle* passData, std::vector<std::string>& array)
-{
-       size_t arraySize = array.size();
-
-       if (arraySize == 0)
-       {
-               ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "size = 0");
-       }
-       
-       const char** arr = NULL;
-       arr = (const char**)calloc(sizeof(char*), arraySize);
-
-       if (arr == NULL)
-       {
-               ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "null");
+               else if (dynamic_cast<EventRemoveValuePendingEvent*>(pEvent) != NULL)
+               {
+                       EventRemoveValuePendingEvent* pendingRemoveEvent = (EventRemoveValuePendingEvent*)pEvent;
+                       EventRemoveValuePtr deleteEvent = pendingRemoveEvent->getEvent();
+                       deleteEvent->setExceptionCode((WrtDeviceApis::Commons::ExceptionCodes::Enumeration)code);
+                       deleteEvent->setErrorMsg(msg);
+                       
+                       WrtDeviceApis::Commons::EventRequestReceiver<EventRemoveValue>::ManualAnswer(deleteEvent); 
+               }       
        }
-
-       for (size_t index = 0; index < arraySize; index++) 
+       catch (const WrtDeviceApis::Commons::Exception& ex) 
        {
-               arr[index] = array[index].c_str();
+               LoggerE("Exception: " << ex.GetMessage());
        }
 
-       
-       bundle_add_str_array(passData, OSP_K_ARG, arr, arraySize);
-
-       free(arr);
-       arr = NULL;
-       
 }
 
 
 void MappedDataControlConsumer::handlePendingEvent(const EventAddValuePtr& event)
 {
        WrtDeviceApis::Commons::EventRequestReceiver<EventAddValue>::ManualAnswer(event);       
-       removeReqId(event->getReqId());
 }
+
 void MappedDataControlConsumer::handlePendingEvent(const EventRemoveValuePtr& event)
 {
        WrtDeviceApis::Commons::EventRequestReceiver<EventRemoveValue>::ManualAnswer(event); 
-       removeReqId(event->getReqId());
 }
+
 void MappedDataControlConsumer::handlePendingEvent(const EventGetValuePtr& event)
 {
        WrtDeviceApis::Commons::EventRequestReceiver<EventGetValue>::ManualAnswer(event);
-       removeReqId(event->getReqId());
 }
 
 void MappedDataControlConsumer::handlePendingEvent(const EventUpdateValuePtr& event)
 {
        WrtDeviceApis::Commons::EventRequestReceiver<EventUpdateValue>::ManualAnswer(event); 
-       removeReqId(event->getReqId());
 }
 
 
@@ -673,40 +182,48 @@ void MappedDataControlConsumer::updateValue(const EventUpdateValuePtr& event)
 
 bool MappedDataControlConsumer::checkReqIdUniqueness(unsigned int reqId)
 {
-       size_t index = 0; 
+       std::string reqIdStr;
+       std::stringstream ssReqId;
 
-       for (index = 0; index < m_currentReqIds.size(); index++)
-       {
-               if (m_currentReqIds[index] == reqId)
-                       return false;
-       }
-
-       return true;
+       ssReqId << reqId;
+       reqIdStr = ssReqId.str();
+       return DataControlAsyncCallbackManagerSingleton::Instance().checkReqIdUnique(reqIdStr);
 }
 
-void MappedDataControlConsumer::removeReqId(unsigned int reqId)
+void MappedDataControlConsumer::OnRequestReceived(const EventAddValuePtr& event)
 {
-       bool remove = false;
-       
-       std::vector<unsigned int>::iterator it, found;
-       
-       for (it = m_currentReqIds.begin(); it != m_currentReqIds.end(); ++it)
+       LoggerD("Enter");
+
+       try 
        {
-               if (*it == reqId)
+               unsigned short currentJob = 0;
+               unsigned int reqId = event->getReqId();
+               std::string reqIdStr = convertIntToString(reqId);
+               
+               if (checkReqIdUniqueness(reqId) == false)
                {
-                       found = it;     
-                       remove = true;
+                       ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
                }
-       }
-
-       if (remove)
+               
+               EventAddValuePendingEvent* pendingEvent = new EventAddValuePendingEvent(this, m_dataId, m_appId, m_providerId,  m_currentAppId, event);
+               
+               if (DataControlAsyncCallbackManagerSingleton::Instance().checkRequestIpcOperation())
+               {
+                       SendAppControlLaunchToProvider(pendingEvent, currentJob);
+               }
+               event->switchToManualAnswer();
+               DataControlAsyncCallbackManagerSingleton::Instance().addSQLUserData(reqIdStr, (void*)pendingEvent);
+       }       
+       catch (const WrtDeviceApis::Commons::Exception& ex) 
        {
-               DPL::Mutex::ScopedLock lock(&m_mutex);
-               m_currentReqIds.erase(found);
+               event->setExceptionCode(ex.getCode());
+               event->setErrorMsg(ex.GetMessage());
+               LoggerE("Exception: " << ex.GetMessage());
        }
-}
 
+}
 
+#if 0
 void MappedDataControlConsumer::OnRequestReceived(const EventAddValuePtr& event)
 {
        LoggerD("Enter");
@@ -762,8 +279,8 @@ void MappedDataControlConsumer::OnRequestReceived(const EventAddValuePtr& event)
 
                // FIXEME
                // reqid sholud be known
-               EventAddValuePendingEvent* pendingEvent = new EventAddValuePendingEvent((void*)this, event);
-               int pid = appsvc_run_service(passData, reqId, MappedDataControlCommonCallback, (void*)pendingEvent);
+               EventAddValuePendingEvent* pendingEvent = new EventAddValuePendingEvent((void*)this, dataId, m_appId, m_providerId,  "", event);
+               int pid = appsvc_run_service(passData, reqId, dataControlCommonCallback, (void*)pendingEvent);
 
                if (pid < 0) 
                {
@@ -773,7 +290,6 @@ void MappedDataControlConsumer::OnRequestReceived(const EventAddValuePtr& event)
                event->switchToManualAnswer();
 
                DPL::Mutex::ScopedLock lock(&m_mutex);
-               m_currentReqIds.push_back(reqId);
        }       
        catch (const WrtDeviceApis::Commons::Exception& ex) 
        {
@@ -791,10 +307,43 @@ void MappedDataControlConsumer::OnRequestReceived(const EventAddValuePtr& event)
        }
 
 }
+#endif
 
 void MappedDataControlConsumer::OnRequestReceived(const EventRemoveValuePtr& event)
 {
        LoggerD("Enter");
+
+       try 
+       {
+               unsigned short currentJob = 0;
+               unsigned int reqId = event->getReqId();
+               std::string reqIdStr = convertIntToString(reqId);
+               
+               if (checkReqIdUniqueness(reqId) == false)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
+               }
+               
+               EventRemoveValuePendingEvent* pendingEvent = new EventRemoveValuePendingEvent(this, m_dataId, m_appId, m_providerId,  m_currentAppId, event);
+               
+               if (DataControlAsyncCallbackManagerSingleton::Instance().checkRequestIpcOperation())
+               {
+                       SendAppControlLaunchToProvider(pendingEvent, currentJob);
+               }
+               event->switchToManualAnswer();
+               DataControlAsyncCallbackManagerSingleton::Instance().addSQLUserData(reqIdStr, (void*)pendingEvent);
+       }       
+       catch (const WrtDeviceApis::Commons::Exception& ex) 
+       {
+               event->setExceptionCode(ex.getCode());
+               event->setErrorMsg(ex.GetMessage());
+               LoggerE("Exception: " << ex.GetMessage());
+       }
+}
+#if 0
+void MappedDataControlConsumer::OnRequestReceived(const EventRemoveValuePtr& event)
+{
+       LoggerD("Enter");
        bundle* passData = NULL;
        
        try 
@@ -843,9 +392,9 @@ void MappedDataControlConsumer::OnRequestReceived(const EventRemoveValuePtr& eve
                
 
                addArrayToBundle(passData, queryItem);
-               EventRemoveValuePendingEvent* pendingEvent = new EventRemoveValuePendingEvent(this, event);
+               EventRemoveValuePendingEvent* pendingEvent = new EventRemoveValuePendingEvent(this, dataId, m_appId, m_providerId,  "", event);
 
-               int pid = appsvc_run_service(passData, reqId, MappedDataControlCommonCallback, (void*)pendingEvent);
+               int pid = appsvc_run_service(passData, reqId, dataControlCommonCallback, (void*)pendingEvent);
 
                if (pid < 0) 
                {
@@ -855,7 +404,6 @@ void MappedDataControlConsumer::OnRequestReceived(const EventRemoveValuePtr& eve
                event->switchToManualAnswer();
 
                DPL::Mutex::ScopedLock lock(&m_mutex);
-               m_currentReqIds.push_back(reqId);
        }       
        catch (const WrtDeviceApis::Commons::Exception& ex) 
        {
@@ -871,9 +419,43 @@ void MappedDataControlConsumer::OnRequestReceived(const EventRemoveValuePtr& eve
        }
 
 }
+#endif
+
+void MappedDataControlConsumer::OnRequestReceived(const EventGetValuePtr& event)
+{
+       LoggerD("Enter");
+
+       try 
+       {
+               unsigned short currentJob = 0;
+               unsigned int reqId = event->getReqId();
+               std::string reqIdStr = convertIntToString(reqId);
+               
+               if (checkReqIdUniqueness(reqId) == false)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
+               }
+               
+               EventGetValuePendingEvent* pendingEvent = new EventGetValuePendingEvent(this, m_dataId, m_appId, m_providerId,  m_currentAppId, event);
+               
+               if (DataControlAsyncCallbackManagerSingleton::Instance().checkRequestIpcOperation())
+               {
+                       SendAppControlLaunchToProvider(pendingEvent, currentJob);
+               }
+               event->switchToManualAnswer();
+               DataControlAsyncCallbackManagerSingleton::Instance().addSQLUserData(reqIdStr, (void*)pendingEvent);
+       }       
+       catch (const WrtDeviceApis::Commons::Exception& ex) 
+       {
+               event->setExceptionCode(ex.getCode());
+               event->setErrorMsg(ex.GetMessage());
+               LoggerE("Exception: " << ex.GetMessage());
+       }
 
+}
 
 
+#if 0
 void MappedDataControlConsumer::OnRequestReceived(const EventGetValuePtr& event)
 {
        LoggerD("Enter");
@@ -926,9 +508,9 @@ void MappedDataControlConsumer::OnRequestReceived(const EventGetValuePtr& event)
                queryItem.push_back("1");
                
                addArrayToBundle(passData, queryItem);
-               EventGetValuePendingEvent* pendingEvent = new EventGetValuePendingEvent(this, event);
+               EventGetValuePendingEvent* pendingEvent = new EventGetValuePendingEvent(this, dataId, m_appId, m_providerId,  "", event);
                
-               int pid = appsvc_run_service(passData, reqId, MappedDataControlCommonCallback, (void*)pendingEvent);
+               int pid = appsvc_run_service(passData, reqId, dataControlCommonCallback, (void*)pendingEvent);
 
                if (pid < 0) 
                {
@@ -938,7 +520,6 @@ void MappedDataControlConsumer::OnRequestReceived(const EventGetValuePtr& event)
                event->switchToManualAnswer();
 
                DPL::Mutex::ScopedLock lock(&m_mutex);          
-               m_currentReqIds.push_back(reqId);
        }       
        catch (const WrtDeviceApis::Commons::Exception& ex) 
        {
@@ -954,10 +535,44 @@ void MappedDataControlConsumer::OnRequestReceived(const EventGetValuePtr& event)
        }
                
 }      
+#endif
 
 void MappedDataControlConsumer::OnRequestReceived(const EventUpdateValuePtr& event)
 {
        LoggerD("Enter");
+
+       try 
+       {
+               unsigned short currentJob = 0;
+               unsigned int reqId = event->getReqId();
+               std::string reqIdStr = convertIntToString(reqId);
+               
+               if (checkReqIdUniqueness(reqId) == false)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
+               }
+               
+               EventUpdateValuePendingEvent* pendingEvent = new EventUpdateValuePendingEvent(this, m_dataId, m_appId, m_providerId,  m_currentAppId, event);
+               
+               if (DataControlAsyncCallbackManagerSingleton::Instance().checkRequestIpcOperation())
+               {
+                       SendAppControlLaunchToProvider(pendingEvent, currentJob);
+               }
+               event->switchToManualAnswer();
+               DataControlAsyncCallbackManagerSingleton::Instance().addSQLUserData(reqIdStr, (void*)pendingEvent);
+       }       
+       catch (const WrtDeviceApis::Commons::Exception& ex) 
+       {
+               event->setExceptionCode(ex.getCode());
+               event->setErrorMsg(ex.GetMessage());
+               LoggerE("Exception: " << ex.GetMessage());
+       }
+}
+
+#if 0
+void MappedDataControlConsumer::OnRequestReceived(const EventUpdateValuePtr& event)
+{
+       LoggerD("Enter");
        bundle* passData = NULL;
        
        try 
@@ -1008,9 +623,9 @@ void MappedDataControlConsumer::OnRequestReceived(const EventUpdateValuePtr& eve
                queryItem.push_back(newValue);
 
                addArrayToBundle(passData, queryItem);
-               EventUpdateValuePendingEvent* pendingEvent = new EventUpdateValuePendingEvent(this, event);
+               EventUpdateValuePendingEvent* pendingEvent = new EventUpdateValuePendingEvent(this, dataId, m_appId, m_providerId,  "",  event);
 
-               int pid = appsvc_run_service(passData, reqId, MappedDataControlCommonCallback, (void*)pendingEvent);
+               int pid = appsvc_run_service(passData, reqId, dataControlCommonCallback, (void*)pendingEvent);
 
                if (pid < 0) 
                {
@@ -1020,7 +635,6 @@ void MappedDataControlConsumer::OnRequestReceived(const EventUpdateValuePtr& eve
                event->switchToManualAnswer();
 
                DPL::Mutex::ScopedLock lock(&m_mutex);          
-               m_currentReqIds.push_back(reqId);
        }       
        catch (const WrtDeviceApis::Commons::Exception& ex) 
        {
@@ -1037,7 +651,7 @@ void MappedDataControlConsumer::OnRequestReceived(const EventUpdateValuePtr& eve
 
 
 }
-
+#endif
 
 
 }
index bdb82a3..8b88a92 100755 (executable)
@@ -50,21 +50,20 @@ public:
        void handlePendingEvent(const EventRemoveValuePtr& event);
        void handlePendingEvent(const EventGetValuePtr& event);
        void handlePendingEvent(const EventUpdateValuePtr& event);
-
+       void handleCommonErrorEvent(void* userData, unsigned int code, std::string msg);
 private:
        std::string m_type;
        std::string m_dataId;
        std::string m_providerId;
        std::string m_appId;
+       std::string m_ProviderPkgId;
+       std::string m_currentAppId;
        
-       std::string getApplicationId(const std::string& provId);
-       void addArrayToBundle(bundle* passData, std::vector<std::string>& array);
        bool checkReqIdUniqueness(unsigned int reqId);
-       void removeReqId(unsigned int reqId);
 
        static DPL::Mutex m_mutex;
-       std::vector<unsigned int> m_currentReqIds;
-       
+
+
 
 protected:
        MappedDataControlConsumer(std::string& provId, std::string& dataId, std::string& type);
@@ -82,81 +81,7 @@ private:
 };
 
 
-class EventAddValuePendingEvent
-{
-public:
-       EventAddValuePendingEvent(void *thisObject, const  EventAddValuePtr &event) :
-               m_thisObject(thisObject),
-               m_event(event)
-       {
-       }
-
-       virtual ~EventAddValuePendingEvent()
-       {
-       }
-       void* getThisObject() const { return m_thisObject; }
-       EventAddValuePtr getEvent() const { return m_event; }
-private:
-       void *m_thisObject;
-       EventAddValuePtr m_event;
-};
-
-class EventRemoveValuePendingEvent
-{
-public:
-       EventRemoveValuePendingEvent(void *thisObject, const  EventRemoveValuePtr &event) :
-               m_thisObject(thisObject),
-               m_event(event)
-       {
-       }
-
-       virtual ~EventRemoveValuePendingEvent()
-       {
-       }
-       void* getThisObject() const { return m_thisObject; }
-       EventRemoveValuePtr getEvent() const { return m_event; }
-private:
-       void *m_thisObject;
-       EventRemoveValuePtr m_event;
-};
-
-class EventUpdateValuePendingEvent
-{
-public:
-       EventUpdateValuePendingEvent(void *thisObject, const  EventUpdateValuePtr &event) :
-               m_thisObject(thisObject),
-               m_event(event)
-       {
-       }
-
-       virtual ~EventUpdateValuePendingEvent()
-       {
-       }
-       void* getThisObject() const { return m_thisObject; }
-       EventUpdateValuePtr getEvent() const { return m_event; }
-private:
-       void *m_thisObject;
-       EventUpdateValuePtr m_event;
-};
 
-class EventGetValuePendingEvent
-{
-public:
-       EventGetValuePendingEvent(void *thisObject, const  EventGetValuePtr &event) :
-               m_thisObject(thisObject),
-               m_event(event)
-       {
-       }
-
-       virtual ~EventGetValuePendingEvent()
-       {
-       }
-       void* getThisObject() const { return m_thisObject; }
-       EventGetValuePtr getEvent() const { return m_event; }
-private:
-       void *m_thisObject;
-       EventGetValuePtr m_event;
-};
 
 }
 }
index 1c30f06..eafb1c0 100644 (file)
 #include <vector>
 #include <aul/aul.h>
 #include <sstream>
-#include <package-manager.h>
 #include <app.h>
-// to get package name by appid
 #include <app_info.h>
-#include <app_manager.h>
 // To get ppid
 #include <unistd.h>
 #include <security-server.h>
 #include <sstream>
 #include "DataControlAsyncCallbackManager.h"
+#include "DataControlCallback.h"
+#include "DataControlPendingEvent.h"
 
 namespace DeviceAPI {
 namespace DataControl {
 
-
-namespace {
-
-static const char OSP_V_CALLER_TYPE_OSP[] = "osp";
-static const char OSP_V_LAUNCH_TYPE_LAUNCH[] = "launch";
-static const char OSP_V_LAUNCH_TYPE_APPCONTROL[] = "appcontrol";
-static const char OSP_V_LAUNCH_TYPE_DATACONTROL[] = "datacontrol";
-static const char OSP_V_LAUNCH_TYPE_CONDTION[] = "condition";
-static const char OSP_V_REQUEST_TYPE_SQL_QUERY[] = "sql_query";
-static const char OSP_V_REQUEST_TYPE_SQL_INSERT[] = "sql_insert";
-static const char OSP_V_REQUEST_TYPE_SQL_UPDATE[] = "sql_update";
-static const char OSP_V_REQUEST_TYPE_SQL_DELETE[] = "sql_delete";
-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 BUNDLE_KEY_WINDOW[] = "__APP_SVC_K_WIN_ID__";
-
-
-#define OSP_K_CALLER_TYPE   "__OSP_CALLER_TYPE__"
-#define OSP_K_LAUNCH_TYPE   "__OSP_LAUNCH_TYPE__"
-#define OSP_K_ARG           "__OSP_ARGS__"
-#define OSP_K_COND          "__OSP_COND_NAME__"
-#define OSP_K_APPID         "__OSP_APPID__"
-#define OSP_K_REQUEST_ID    "__OSP_REQUEST_ID__"
-#define OSP_K_APPCONTROL_PROVIDER   "__OSP_APPCONTROL_PROVIDER__"
-#define OSP_K_APPCONTROL_OPERATION  "__OSP_APPCONTROL_OPERATION__"
-#define OSP_K_APPCONTROL_CATEGORY   "__OSP_APPCONTROL_CATEGORY__"
-#define OSP_K_APPCONTROL_MIME       "__OSP_APPCONTROL_MIME__"
-#define OSP_K_APPCONTROL_URI        "__OSP_APPCONTROL_URI__"
-#define OSP_K_DATACONTROL_PROVIDER      "__OSP_DATACONTROL_PROVIDER__"
-#define OSP_K_DATACONTROL_REQUEST_TYPE  "__OSP_DATACONTROL_REQUEST_TYPE__"
-#define RESULT_TRUE_FROM_OSP "1"
-#define RESULT_FALSE_FROM_OSP "0"
-#define OSP_K_DATACONTROL_PROTOCOL_VERSION  "__OSP_DATACONTROL_PROTOCOL_VERSION__"
-#define OSP_K_DATACONTROL_PROTOCOL_VERSION_VALUE "ver_2.1.0.3"
-
-#define DATACONTROL_PROTOCOL_DIR_TOP  "/tmp/osp"
-#define DATACONTROL_PROTOCOL_DIR_MIDDLE  "/tmp/osp/data-control"
-#define DATACONTROL_PROTOCOL_DIR  "/tmp/osp/data-control/request"
-
-static std::vector<std::string> getDataArrayFromBundle(bundle *b, std::string key)
-{
-       std::vector<std::string> result;
-       const char **array;
-       int length = 0;
-       int index = 0;
-       
-       array = appsvc_get_data_array(b, key.c_str(), &length);
-
-       if (array == NULL || length == 0)
-       {
-               ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result data fail from datacontrol provider");
-       }
-       
-       for (index = 0; index < length; index++)
-       {
-               result.push_back(array[index]);
-       }
-
-       return result;
-}
-
-
-static void sqldataControlSelectCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
-{
-       LoggerD("Enter");
-       
-       EventSelectPendingEvent *pendingEvent = NULL;
-       SQLDataControlConsumer *consumer = NULL;
-       EventSelectPtr event;
-       const char *bundleKey = NULL;
-       
-       try 
-       {
-               if (b == NULL)
-               {
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
-               }
-               
-        bundleKey = appsvc_get_data(b, OSP_K_REQUEST_ID);
-
-               if (bundleKey == NULL)
-               {
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get key fail from datacontrol provider");
-               }
-
-               pendingEvent = (EventSelectPendingEvent *)DataControlAsyncCallbackManagerSingleton::Instance().removeSQLUserData(bundleKey);
-               consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
-
-               if (DataControlAsyncCallbackManagerSingleton::Instance().isSQLDataControlGC((void*)consumer))
-               {
-                       LoggerD("private object is garbage collected");
-                       delete pendingEvent;
-                       return;
-               }
-               event = pendingEvent->getEvent();
-               
-               std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
-
-               for (size_t index = 0; index < result.size(); index++)
-               {
-                       LoggerD(result[index]);
-               }
-
-               if (result.size() < 3)
-               {
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid result from datacontrol provider");
-               }
-               
-               // 0 : result true or false??
-               if (RESULT_TRUE_FROM_OSP != result[0])
-               {
-                       // 1 : error msg 
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, result[1]);
-               }
-
-               event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
-               // 2 : result set file path
-               event->setResultSetPath(result[2]);
-               
-       }
-       catch (const WrtDeviceApis::Commons::Exception& ex) 
-       {
-               LoggerE("Exception: " << ex.GetMessage());
-               
-               if (event.Get() == NULL)
-               {
-                       LoggerD("event removed, invalid cb");
-                       return;
-               }
-
-               event->setExceptionCode(ex.getCode());
-               event->setErrorMsg(ex.GetMessage());            
-       }
-       consumer->handlePendingEvent(event);
-
-       if (pendingEvent)
-       {
-               delete pendingEvent;
-       }
-
-}
-
-static void sqldataControlInsertCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
-{
-       LoggerD("Enter");
-
-       
-       EventInsertPendingEvent *pendingEvent = NULL;
-       SQLDataControlConsumer *consumer = NULL;
-       EventInsertPtr event;
-       const char *bundleKey = NULL;
-
-       try 
-       {
-               if (b == NULL)
-               {
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
-               }
-
-        bundleKey = appsvc_get_data(b, OSP_K_REQUEST_ID);
-
-               if (bundleKey == NULL)
-               {
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get key fail from datacontrol provider");
-               }
-
-               pendingEvent = (EventInsertPendingEvent *)DataControlAsyncCallbackManagerSingleton::Instance().removeSQLUserData(bundleKey);
-               consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
-
-               if (DataControlAsyncCallbackManagerSingleton::Instance().isSQLDataControlGC((void*)consumer))
-               {
-                       LoggerD("private object is garbage collected");
-                       delete pendingEvent;
-                       return;
-               }
-               
-               event = pendingEvent->getEvent();
-
-               std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
-
-               for (size_t index = 0; index < result.size(); index++)
-               {
-                       LoggerD(result[index]);
-               }
-
-               if (result.size() < 2)
-               {
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid result from datacontrol provider");
-               }
-               
-               // 0 : result true or false??
-               if (RESULT_TRUE_FROM_OSP != result[0])
-               {
-                       // 1 : error msg 
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, result[1]);
-               }
-
-               // 2 : insertrowid
-               std::stringstream sstr(result[2]);
-               long insertRowid = 0;
-               sstr >> insertRowid;
-               LoggerD(result[2] << insertRowid);
-               event->setRowId(insertRowid);                   
-               event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
-               
-       }
-       catch (const WrtDeviceApis::Commons::Exception& ex) 
-       {
-               LoggerE("Exception: " << ex.GetMessage());
-
-               if (event.Get() == NULL)
-               {
-                       LoggerD("event removed, invalid cb");
-                       return;
-               }
-                       
-               event->setExceptionCode(ex.getCode());
-               event->setErrorMsg(ex.GetMessage());            
-       }
-       consumer->handlePendingEvent(event);
-
-       if (pendingEvent)
-       {
-               delete pendingEvent;
-       }
-
-}
-
-static void sqldataControlDeleteCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
-{
-       LoggerD("Enter");
-
-       EventDeletePendingEvent* pendingEvent = NULL;
-       SQLDataControlConsumer *consumer = NULL;
-       EventDeletePtr event;
-       const char* bundleKey = NULL;
-       
-       try 
-       {
-               if (b == NULL)
-               {
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
-               }
-
-        bundleKey = appsvc_get_data(b, OSP_K_REQUEST_ID);
-
-               if (bundleKey == NULL)
-               {
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get key fail from datacontrol provider");
-               }
-
-               pendingEvent = (EventDeletePendingEvent *)DataControlAsyncCallbackManagerSingleton::Instance().removeSQLUserData(bundleKey);
-               consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
-
-               if (DataControlAsyncCallbackManagerSingleton::Instance().isSQLDataControlGC((void*)consumer))
-               {
-                       LoggerD("private object is garbage collected");
-                       delete pendingEvent;
-                       return;
-               }
-
-               event = pendingEvent->getEvent();
-
-               std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
-
-               for (size_t index = 0; index < result.size(); index++)
-               {
-                       LoggerD(result[index]);
-               }
-
-               if (result.size() < 2)
-               {
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid result from datacontrol provider");
-               }
-               
-               // 0 : result true or false??
-               if (RESULT_TRUE_FROM_OSP != result[0])
-               {
-                       // 1 : error msg 
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, result[1]);
-               }
-
-               event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
-
-               
-       }
-       catch (const WrtDeviceApis::Commons::Exception& ex) 
-       {
-               LoggerE("Exception: " << ex.GetMessage());
-
-               if (event.Get() == NULL)
-               {
-                       LoggerD("event removed, invalid cb");
-                       return;
-               }
-               
-               event->setExceptionCode(ex.getCode());
-               event->setErrorMsg(ex.GetMessage());            
-       }
-       consumer->handlePendingEvent(event);
-
-       if (pendingEvent)
-       {
-               delete pendingEvent;
-       }
-}
-
-static void sqldataControlUpdateCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
-{
-       LoggerD("Enter");
-
-       EventUpdatePendingEvent* pendingEvent = NULL;
-       SQLDataControlConsumer *consumer = NULL;
-       EventUpdatePtr event;
-       const char *bundleKey = NULL;
-       
-       try 
-       {
-               if (b == NULL)
-               {
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
-               }
-
-        bundleKey = appsvc_get_data(b, OSP_K_REQUEST_ID);
-
-               if (bundleKey == NULL)
-               {
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get key fail from datacontrol provider");
-               }
-
-               pendingEvent = (EventUpdatePendingEvent *)DataControlAsyncCallbackManagerSingleton::Instance().removeSQLUserData(bundleKey);    
-               consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
-
-               if (DataControlAsyncCallbackManagerSingleton::Instance().isSQLDataControlGC((void*)consumer))
-               {
-                       LoggerD("private object is garbage collected");
-                       delete pendingEvent;
-                       return;
-               }
-               
-               event = pendingEvent->getEvent();
-
-               std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
-
-               for (size_t index = 0; index < result.size(); index++)
-               {
-                       LoggerD(result[index]);
-               }
-
-               if (result.size() < 2)
-               {
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid result from datacontrol provider");
-               }
-               
-               // 0 : result true or false??
-               if (RESULT_TRUE_FROM_OSP != result[0])
-               {
-                       // 1 : error msg 
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, result[1]);
-               }
-
-               event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
-               
-       }
-       catch (const WrtDeviceApis::Commons::Exception& ex) 
-       {
-               LoggerE("Exception: " << ex.GetMessage());
-
-               if (event.Get() == NULL)
-               {
-                       LoggerD("event removed, invalid cb");
-                       return;
-               }
-                               
-               event->setExceptionCode(ex.getCode());
-               event->setErrorMsg(ex.GetMessage());            
-       }
-       consumer->handlePendingEvent(event);
-
-       if (pendingEvent)
-       {
-               delete pendingEvent;
-       }
-}
-
-static void sqldataControlCommonCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
-{
-       LoggerD("Enter");
-
-       if (b == NULL)
-       {
-               LoggerD("Bundle null, Error");
-               return;         
-       }
-
-       const char *reqType = appsvc_get_data(b, OSP_K_DATACONTROL_REQUEST_TYPE);
-       
-       if (reqType == NULL)
-       {
-               LoggerD("UnkownRequest");
-               return;
-       }
-
-       std::istringstream buffer(reqType);
-       int reqTypeInt = 0;
-
-       buffer >> reqTypeInt;
-
-
-       LoggerD(reqTypeInt);
-       
-       switch (reqTypeInt)
-       {
-               case _DATACONTROL_REQUEST_TYPE_SQL_QUERY:
-                       sqldataControlSelectCallback(b, request_code, res, data);
-                       break;
-               case _DATACONTROL_REQUEST_TYPE_SQL_INSERT:
-                       sqldataControlInsertCallback(b, request_code, res, data);
-                       break;
-               case _DATACONTROL_REQUEST_TYPE_SQL_DELETE:
-                       sqldataControlDeleteCallback(b, request_code, res, data);
-                       break;
-               case _DATACONTROL_REQUEST_TYPE_SQL_UPDATE:
-                       sqldataControlUpdateCallback(b, request_code, res, data);
-                       break;
-               default:
-                       LoggerD("Unknown Request");
-       }
-}
-
-}
-
 SQLDataControlConsumer::SQLDataControlConsumer(std::string& provId, std::string& dataId, std::string& type)
 {
        LoggerD("Enter");
@@ -480,63 +45,22 @@ SQLDataControlConsumer::SQLDataControlConsumer(std::string& provId, std::string&
        m_dataId = dataId;
        m_providerId = provId;
        
-       m_appId = getApplicationId(provId);     
+       m_appId = getProviderApplicationId(OSP_PKGINFO_SQL_TYPE, provId);       
        m_ProviderPkgId = getProviderPkgId(m_appId);
        security_server_app_give_access(m_ProviderPkgId.c_str(), -1);
 
        m_currentAppId = getCurrentApplicationId();
        createResultDir();
-       DataControlAsyncCallbackManagerSingleton::Instance().setSQLDataControlGC((void*)this, false);
+       DataControlAsyncCallbackManagerSingleton::Instance().setDataControlGC((void*)this, false);
 }
 
 SQLDataControlConsumer::~SQLDataControlConsumer() 
 {
        LoggerD("Enter");
-       DataControlAsyncCallbackManagerSingleton::Instance().setSQLDataControlGC((void*)this, true);
+       DataControlAsyncCallbackManagerSingleton::Instance().setDataControlGC((void*)this, true);
 }
 
 DPL::Mutex SQLDataControlConsumer::m_mutex;
-std::vector<unsigned int> SQLDataControlConsumer::m_currentReqIds;
-
-std::string SQLDataControlConsumer::getCurrentApplicationId()
-{
-       char *app_id = NULL;
-       std::string appId = "";
-       int parent_pid = getppid();
-       LoggerD("parent pid : " << parent_pid); 
-       int ret = app_manager_get_app_id(parent_pid, &app_id);  
-
-       if((ret != APP_ERROR_NONE) || (app_id == NULL))
-       {
-               LoggerE("Can not get app id from current pid (" << ret << ")");
-               ThrowMsg(WrtDeviceApis::Commons::PlatformException, "could not get information about application");
-       }
-       appId = app_id;
-       free(app_id);
-       return appId;           
-}
-
-void SQLDataControlConsumer::removeReqId(unsigned int reqId)
-{
-       bool remove = false;
-       
-       std::vector<unsigned int>::iterator it, found;
-       
-       for (it = m_currentReqIds.begin(); it != m_currentReqIds.end(); ++it)
-       {
-               if (*it == reqId)
-               {
-                       found = it;     
-                       remove = true;
-               }
-       }
-
-       if (remove)
-       {
-               DPL::Mutex::ScopedLock lock(&m_mutex);
-               m_currentReqIds.erase(found);
-       }
-}
 
 bool SQLDataControlConsumer::checkReqIdUniqueness(unsigned int reqId)
 {
@@ -564,81 +88,8 @@ std::string SQLDataControlConsumer::getType()
        return m_type;
 }
 
-std::string SQLDataControlConsumer::getProviderPkgId(const std::string& appId)
-{
-       char* pkgId = NULL;
-       app_info_h handle = NULL;
-
-       if (m_ProviderPkgId.length() != 0) 
-       {
-               return m_ProviderPkgId;
-       }
-       
-       int ret = app_manager_get_app_info(appId.c_str(), &handle);
-
-       if (ret != APP_ERROR_NONE) 
-       {
-               LoggerD("Fail to get appinfo");
-               ThrowMsg(WrtDeviceApis::Commons::PlatformException, "get appId error");
-       }
-
-       ret = app_info_get_package(handle, &pkgId);
-
-       if ((ret != APP_ERROR_NONE) || (pkgId == NULL)) 
-       {
-               LoggerD("Fail to get pkg_name");
-               ThrowMsg(WrtDeviceApis::Commons::PlatformException, "get pkdid error");
-       }
-       m_ProviderPkgId = pkgId;
-       app_info_destroy(handle);
-       free(pkgId);
-       return m_ProviderPkgId; 
-}
-
-std::string SQLDataControlConsumer::getApplicationId(const std::string& provId)
-{
-       std::string appIdStr = "";
-
-       char* appId = NULL;
-       char* access = NULL;
-       const char *passId = provId.c_str();
-       
-       if (m_appId.length() == 0)
-       {
-       
-               if(     pkgmgr_datacontrol_get_info(passId, OSP_PKGINFO_SQL_TYPE, &appId, &access) < 0)
-               {
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "get appId error");
-               }
-               
-               if (appId)
-               {
-                       appIdStr = appId;
-                       free(appId);
-               }
-
-               if (access)
-               {
-                       free(access);
-               }
-               
-               m_appId = appIdStr;
-
-
-       }
-       return m_appId;
 
-}
 
-std::string SQLDataControlConsumer::generateFileName(unsigned int reqId)
-{
-       std::stringstream ssdata;
-       ssdata.str("");
-       ssdata << reqId;
-       std::string parent = DATACONTROL_PROTOCOL_DIR;
-       std::string filename = parent  + "/" + m_currentAppId + ssdata.str();
-       return filename;
-}
 
 void SQLDataControlConsumer::saveArrayToFile(std::string filename, RowData *rowData)
 {
@@ -667,34 +118,7 @@ void SQLDataControlConsumer::saveArrayToFile(std::string filename, RowData *rowD
        insertUpdateFile.close();               
        
 }
-void SQLDataControlConsumer::addArrayToBundle(bundle* passData, std::vector<std::string>& array)
-{
-       size_t arraySize = array.size();
-
-       if (arraySize == 0)
-       {
-               ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "size = 0");
-       }
-       
-       const char** arr = NULL;
-       arr = (const char**)calloc(sizeof(char*), arraySize);
-
-       if (arr == NULL)
-       {
-               ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "null");
-       }
 
-       for (size_t index = 0; index < arraySize; index++) 
-       {
-               arr[index] = array[index].c_str();
-       }
-
-       
-       bundle_add_str_array(passData, OSP_K_ARG, arr, arraySize);
-
-       free(arr);
-       arr = NULL;
-}
 
 void SQLDataControlConsumer::handleCommonErrorEvent(void* userData, unsigned int code, std::string msg)
 {
@@ -716,6 +140,7 @@ void SQLDataControlConsumer::handleCommonErrorEvent(void* userData, unsigned int
                        insertEvent->setErrorMsg(msg);          
                
                        WrtDeviceApis::Commons::EventRequestReceiver<EventInsert>::ManualAnswer(insertEvent); 
+                       
                }
                else if (dynamic_cast<EventUpdatePendingEvent*>(pEvent) != NULL)
                {
@@ -751,18 +176,19 @@ void SQLDataControlConsumer::handleCommonErrorEvent(void* userData, unsigned int
        }
 
 }
+
 void SQLDataControlConsumer::handlePendingEvent(const EventInsertPtr& event)
 {
        LoggerD("OK");
        WrtDeviceApis::Commons::EventRequestReceiver<EventInsert>::ManualAnswer(event); 
        CommonPendingEvent* userData = NULL;
-       
+       unsigned short currentJob = 0;
        try {
-               userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingSQLOperation();
+               userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingIpcOperation();
 
                if (userData)
                {
-                       SendAppControlLaunchToProvider(userData);
+                       SendAppControlLaunchToProvider(userData, currentJob);
                }
        }
        catch (const WrtDeviceApis::Commons::Exception& ex) 
@@ -785,13 +211,14 @@ void SQLDataControlConsumer::handlePendingEvent(const EventDeletePtr& event)
 {
        WrtDeviceApis::Commons::EventRequestReceiver<EventDelete>::ManualAnswer(event); 
        CommonPendingEvent* userData = NULL;
+       unsigned short currentJob = 0;
 
        try {
-               userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingSQLOperation();
+               userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingIpcOperation();
 
                if (userData)
                {
-                       SendAppControlLaunchToProvider(userData);
+                       SendAppControlLaunchToProvider(userData, currentJob);
                }
        }
        catch (const WrtDeviceApis::Commons::Exception& ex) 
@@ -815,13 +242,14 @@ void SQLDataControlConsumer::handlePendingEvent(const EventSelectPtr& event)
 {
        WrtDeviceApis::Commons::EventRequestReceiver<EventSelect>::ManualAnswer(event);
        CommonPendingEvent* userData = NULL;
-       
+       unsigned short currentJob = 0;
+
        try {
-               userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingSQLOperation();
+               userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingIpcOperation();
 
                if (userData)
                {
-                       SendAppControlLaunchToProvider(userData);
+                       SendAppControlLaunchToProvider(userData, currentJob);
                }
        }
        catch (const WrtDeviceApis::Commons::Exception& ex) 
@@ -847,13 +275,14 @@ void SQLDataControlConsumer::handlePendingEvent(const EventUpdatePtr& event)
 {
        WrtDeviceApis::Commons::EventRequestReceiver<EventUpdate>::ManualAnswer(event); 
        CommonPendingEvent* userData = NULL;
-       
+       unsigned short currentJob = 0;
+
        try {
-               userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingSQLOperation();
+               userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingIpcOperation();
 
                if (userData)
                {
-                       SendAppControlLaunchToProvider(userData);
+                       SendAppControlLaunchToProvider(userData, currentJob);
                }
        }
        catch (const WrtDeviceApis::Commons::Exception& ex) 
@@ -941,255 +370,6 @@ void SQLDataControlConsumer::createResultDir()
     ThrowMsg(WrtDeviceApis::Commons::PlatformException, "result dir could be error during checking status");
 }
 
-std::string SQLDataControlConsumer::convertIntToString(unsigned int data)
-{
-       std::stringstream ssbuffer;
-
-       ssbuffer.str("");
-       ssbuffer << data;
-       return ssbuffer.str();
-}
-
-void SQLDataControlConsumer::SendAppControlLaunchToProvider(void* event)
-{
-       LoggerD("OK");
-       bundle* passData = NULL;
-       std::string dataId = getDataId();
-       std::vector<std::string> queryItem;
-       std::stringstream ssBuffer;
-       std::string stringBuffer;
-       CommonPendingEvent* pEvent = (CommonPendingEvent*)(event);
-       std::string ipcFilename;
-       std::string where;
-       unsigned int reqId = 0;
-       unsigned int columnSize = 0;
-
-       try 
-       {
-               passData = bundle_create();
-               
-               if (passData == NULL)
-               {
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "ipc memory allocation fail");
-               }
-
-               if (pEvent == NULL)
-               {
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "event null");              
-               }
-
-               appsvc_set_operation(passData, APPSVC_OPERATION_DEFAULT);               
-               appsvc_set_appid(passData, m_appId.c_str());
-
-               bundle_add(passData, OSP_K_CALLER_TYPE, OSP_V_CALLER_TYPE_OSP);
-               bundle_add(passData, OSP_K_LAUNCH_TYPE, OSP_V_LAUNCH_TYPE_DATACONTROL);
-               bundle_add(passData, OSP_K_DATACONTROL_PROVIDER, m_providerId.c_str());
-               bundle_add(passData, OSP_K_DATACONTROL_PROTOCOL_VERSION, OSP_K_DATACONTROL_PROTOCOL_VERSION_VALUE); // version
-               bundle_add(passData, AUL_K_CALLER_APPID, m_currentAppId.c_str());
-
-               if (dynamic_cast<EventInsertPendingEvent*>(pEvent) != NULL)
-               {
-                       EventInsertPendingEvent* pendingInsertEvent = (EventInsertPendingEvent*)pEvent;
-                       EventInsertPtr insertEvent = pendingInsertEvent->getEvent();
-                       
-                       reqId = insertEvent->getReqId();
-                       columnSize = insertEvent->getColumnSize();
-
-                       stringBuffer = convertIntToString(reqId);
-                       bundle_add(passData, OSP_K_REQUEST_ID, stringBuffer.c_str());   
-
-                       ipcFilename     = generateFileName(reqId);      
-                       stringBuffer = convertIntToString(columnSize);
-                       
-                       queryItem.push_back(dataId); 
-                       queryItem.push_back(stringBuffer); 
-                       queryItem.push_back(ipcFilename); 
-
-                       stringBuffer = convertIntToString(_DATACONTROL_REQUEST_TYPE_SQL_INSERT);
-                       bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, stringBuffer.c_str());
-                               
-                       addArrayToBundle(passData, queryItem);
-               }
-               else if (dynamic_cast<EventUpdatePendingEvent*>(pEvent) != NULL)
-               {
-                       EventUpdatePendingEvent* pendingUpdateEvent = (EventUpdatePendingEvent*)pEvent;
-                       EventUpdatePtr updateEvent = pendingUpdateEvent->getEvent();
-                       
-                       reqId = updateEvent->getReqId();
-                       columnSize = updateEvent->getColumnSize();
-                       where = updateEvent->getWhere();
-                       
-                       stringBuffer = convertIntToString(reqId);
-                       bundle_add(passData, OSP_K_REQUEST_ID, stringBuffer.c_str());   
-
-                       stringBuffer = convertIntToString(_DATACONTROL_REQUEST_TYPE_SQL_UPDATE);
-                       bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, stringBuffer.c_str());
-
-                       ipcFilename     = generateFileName(reqId);      
-                       stringBuffer = convertIntToString(columnSize);
-
-                       queryItem.push_back(dataId); 
-                       queryItem.push_back(stringBuffer); 
-                       queryItem.push_back(ipcFilename); 
-
-                       if (where.size() == 0)  // where
-                       {
-                               queryItem.push_back("NULL");
-                       }
-                       else 
-                       {
-                               queryItem.push_back(where);
-                       }
-               
-                       addArrayToBundle(passData, queryItem);
-
-               }
-               else if (dynamic_cast<EventSelectPendingEvent*>(pEvent) != NULL)
-               {
-                       EventSelectPendingEvent* pendingSelectEvent = (EventSelectPendingEvent*)pEvent;
-                       EventSelectPtr selectEvent = pendingSelectEvent->getEvent();
-                       
-                       reqId = selectEvent->getReqId();
-                       std::vector<std::string> columns = selectEvent->getColumns();
-                       columnSize = columns.size();            
-                       where = selectEvent->getWhere();
-                       std::string order = selectEvent->getOrder();
-                       std::string page = selectEvent->getPage();
-                       std::string numberPerPage = selectEvent->getNumerPerPage();
-
-                       stringBuffer = convertIntToString(reqId);
-                       bundle_add(passData, OSP_K_REQUEST_ID, stringBuffer.c_str());   
-
-                       stringBuffer = convertIntToString(_DATACONTROL_REQUEST_TYPE_SQL_QUERY);
-                       bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, stringBuffer.c_str());
-
-                       queryItem.push_back(dataId); 
-
-                       if (columnSize == 0)
-                       {
-                               queryItem.push_back("NULL");
-                       }
-                       else 
-                       {
-                               stringBuffer = convertIntToString(columnSize);
-                               queryItem.push_back(stringBuffer);
-
-                               for (size_t index = 0; index < columnSize; index++)
-                               {
-                                       queryItem.push_back(columns[index]);
-                               }
-                       }
-
-                       if (where.size() == 0) 
-                       {
-                               queryItem.push_back("NULL");
-                       }
-                       else 
-                       {
-                               queryItem.push_back(where);
-                       }
-
-                       if (order.size() == 0)
-                       {
-                               queryItem.push_back("NULL"); 
-                       }
-                       else
-                       {
-                               queryItem.push_back(order);
-                       }
-
-                       if (page.size() == 0) // page
-                       {
-                               queryItem.push_back("1"); 
-                       }
-                       else
-                       {
-                               queryItem.push_back(page);
-                       }
-
-                       if (numberPerPage.size() == 0) // numberOfPage
-                       {
-                               queryItem.push_back("20");
-                       }
-                       else
-                       {
-                               queryItem.push_back(numberPerPage);
-                       }
-
-                       addArrayToBundle(passData, queryItem);
-               }
-               else if (dynamic_cast<EventDeletePendingEvent*>(pEvent) != NULL)
-               {
-                       EventDeletePendingEvent* pendingDeleteEvent = (EventDeletePendingEvent*)pEvent;
-                       EventDeletePtr deleteEvent = pendingDeleteEvent->getEvent();
-                       reqId = deleteEvent->getReqId();
-                       stringBuffer = convertIntToString(reqId);
-                       bundle_add(passData, OSP_K_REQUEST_ID, stringBuffer.c_str());   
-
-                       stringBuffer = convertIntToString(_DATACONTROL_REQUEST_TYPE_SQL_DELETE);
-                       bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, stringBuffer.c_str());
-
-                       queryItem.push_back(dataId); // dataid
-                       where = deleteEvent->getWhere();
-
-                       if (where.size() == 0)  // where
-                       {
-                               queryItem.push_back("NULL");
-                       }
-                       else 
-                       {
-                               queryItem.push_back(where);
-                       }
-                       
-                       addArrayToBundle(passData, queryItem);
-               }
-               else 
-               {
-                       // never happen
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "no type request type");            
-               }
-
-               int pid = 0;
-
-               for (int index = 0; index < 3; index++)
-               {
-                       pid = appsvc_run_service(passData, reqId, sqldataControlCommonCallback, (void*)NULL);
-                       
-                       if (pid >= 0) 
-                               break;
-
-                       usleep(300 * 1000);
-                       LoggerD("Launch Retry" << (index + 1));
-               }
-
-
-               if (pid < 0) 
-               {
-                       ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Launch Error");
-               }
-
-               LoggerD("Launch OK : pid(" << pid << "), reqid : (" << reqId << ")");
-       }
-       catch (const WrtDeviceApis::Commons::Exception& ex) 
-       {       
-               LoggerE("Exception: " << ex.GetMessage());
-               if (passData)
-               {
-                       bundle_free(passData);
-                       passData = NULL;
-               }
-               ThrowMsg(WrtDeviceApis::Commons::PlatformException, ex.GetMessage());
-
-       }
-
-       if (passData)
-       {
-               bundle_free(passData);
-               passData = NULL;
-       }
-       
-}
-
 void SQLDataControlConsumer::OnRequestReceived(const EventInsertPtr& event)
 {
        LoggerD("Enter");
@@ -1198,9 +378,10 @@ void SQLDataControlConsumer::OnRequestReceived(const EventInsertPtr& event)
        {
                RowData* rowData = event->getRowData();
                unsigned int reqId = event->getReqId();
-               std::string ipcFilename = generateFileName(reqId);
+               std::string ipcFilename = generateFileName(reqId, m_currentAppId);
                std::string reqIdStr = convertIntToString(reqId);
-               
+               unsigned short currentJob = 0;
+
                if (checkReqIdUniqueness(reqId) == false)
                {
                        ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
@@ -1214,11 +395,13 @@ void SQLDataControlConsumer::OnRequestReceived(const EventInsertPtr& event)
                saveArrayToFile(ipcFilename, rowData);          
                delete rowData;
                
-               EventInsertPendingEvent* pendingEvent = new EventInsertPendingEvent((void*)this, event);
+               EventInsertPendingEvent* pendingEvent = new EventInsertPendingEvent((void*)this, m_dataId,
+                       m_appId, m_providerId, m_currentAppId, event);
                
-               if (DataControlAsyncCallbackManagerSingleton::Instance().checkDoSQLOperation())
+               
+               if (DataControlAsyncCallbackManagerSingleton::Instance().checkRequestIpcOperation())
                {
-                       SendAppControlLaunchToProvider(pendingEvent);
+                       SendAppControlLaunchToProvider(pendingEvent, currentJob);
                }
                event->switchToManualAnswer();
                DataControlAsyncCallbackManagerSingleton::Instance().addSQLUserData(reqIdStr, (void*)pendingEvent);
@@ -1243,17 +426,19 @@ void SQLDataControlConsumer::OnRequestReceived(const EventDeletePtr& event)
        {
                unsigned int reqId = event->getReqId();
                std::string reqIdStr = convertIntToString(reqId);
+               unsigned short currentJob = 0;
 
                if (checkReqIdUniqueness(reqId) == false)
                {
                        ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
                }
 
-               EventDeletePendingEvent* pendingEvent = new EventDeletePendingEvent(this, event);
+               EventDeletePendingEvent* pendingEvent = new EventDeletePendingEvent(this, m_dataId,
+                       m_appId, m_providerId, m_currentAppId, event);
                
-               if (DataControlAsyncCallbackManagerSingleton::Instance().checkDoSQLOperation())
+               if (DataControlAsyncCallbackManagerSingleton::Instance().checkRequestIpcOperation())
                {
-                       SendAppControlLaunchToProvider(pendingEvent);
+                       SendAppControlLaunchToProvider(pendingEvent, currentJob);
                }
                event->switchToManualAnswer();
                DataControlAsyncCallbackManagerSingleton::Instance().addSQLUserData(reqIdStr, (void*)pendingEvent);
@@ -1279,17 +464,19 @@ void SQLDataControlConsumer::OnRequestReceived(const EventSelectPtr& event)
        {
                unsigned int reqId = event->getReqId();
                std::string reqIdStr = convertIntToString(reqId);
+               unsigned short currentJob = 0;
 
                if (checkReqIdUniqueness(reqId) == false)
                {
                        ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
                }
-               
-               EventSelectPendingEvent* pendingEvent = new EventSelectPendingEvent(this, event);
 
-               if (DataControlAsyncCallbackManagerSingleton::Instance().checkDoSQLOperation())
+               EventSelectPendingEvent* pendingEvent = new EventSelectPendingEvent(this, m_dataId,
+                       m_appId, m_providerId, m_currentAppId, event);
+
+               if (DataControlAsyncCallbackManagerSingleton::Instance().checkRequestIpcOperation())
                {
-                       SendAppControlLaunchToProvider(pendingEvent);
+                       SendAppControlLaunchToProvider(pendingEvent, currentJob);
                }
                
                event->switchToManualAnswer();
@@ -1312,8 +499,9 @@ void SQLDataControlConsumer::OnRequestReceived(const EventUpdatePtr& event)
        {
                unsigned int reqId = event->getReqId();
                RowData* rowData = event->getRowData();
-               std::string ipcFilename = generateFileName(reqId);
+               std::string ipcFilename = generateFileName(reqId, m_currentAppId);
                std::stringstream ssReqId;
+               unsigned short currentJob = 0;
                ssReqId << reqId;
 
                if (checkReqIdUniqueness(reqId) == false)
@@ -1329,11 +517,12 @@ void SQLDataControlConsumer::OnRequestReceived(const EventUpdatePtr& event)
                saveArrayToFile(ipcFilename, rowData);
                delete rowData;
 
-               EventUpdatePendingEvent* pendingEvent = new EventUpdatePendingEvent(this, event);
+               EventUpdatePendingEvent* pendingEvent = new EventUpdatePendingEvent(this, m_dataId, 
+                       m_appId, m_providerId, m_currentAppId, event);
                
-               if (DataControlAsyncCallbackManagerSingleton::Instance().checkDoSQLOperation())
+               if (DataControlAsyncCallbackManagerSingleton::Instance().checkRequestIpcOperation())
                {
-                       SendAppControlLaunchToProvider(pendingEvent);
+                       SendAppControlLaunchToProvider(pendingEvent, currentJob);
                }
                event->switchToManualAnswer();
                DataControlAsyncCallbackManagerSingleton::Instance().addSQLUserData(ssReqId.str(), (void*)pendingEvent);
index 5fdcd81..bb08c08 100755 (executable)
@@ -49,31 +49,22 @@ public:
        std::string getDataId();
        std::string getProviderId();
        
-       void SendAppControlLaunchToProvider(void* event);
        void handlePendingEvent(const EventInsertPtr& event);
        void handlePendingEvent(const EventDeletePtr& event);
        void handlePendingEvent(const EventSelectPtr& event);
        void handlePendingEvent(const EventUpdatePtr& event);
+       void handleCommonErrorEvent(void* userData, unsigned int code, std::string msg);
 
 private:
        std::string m_type;
        std::string m_dataId;
        std::string m_providerId;
        std::string m_appId;
+       std::string m_currentAppId;
+       std::string m_ProviderPkgId;
        
-       std::string getApplicationId(const std::string& provId);
-       std::string getProviderPkgId(const std::string& appId);
-       std::string getCurrentApplicationId();
-       void addArrayToBundle(bundle* passData, std::vector<std::string>& array);
-       void handleCommonErrorEvent(void* userData, unsigned int code, std::string msg);
-
-       std::string convertIntToString(unsigned int data);
-       
-       static std::vector<unsigned int> m_currentReqIds;
        bool checkReqIdUniqueness(unsigned int reqId);
        
-       void removeReqId(unsigned int reqId);           
-       std::string generateFileName(unsigned int reqId);
        void saveArrayToFile(std::string filename, RowData* rowData);
        void createResultDir();
        static DPL::Mutex m_mutex;
@@ -84,100 +75,9 @@ protected:
        virtual void OnRequestReceived(const EventDeletePtr& event);
        virtual void OnRequestReceived(const EventSelectPtr& event);
        virtual void OnRequestReceived(const EventUpdatePtr& event);
-private:
-       std::string m_currentAppId;
-       std::string m_ProviderPkgId;
-
-
-};
-
-class CommonPendingEvent
-{
-public:        
-       CommonPendingEvent() {}
-       ~CommonPendingEvent() {}
-
-       virtual void* getThisObject() const = 0;
-};
-
-class EventInsertPendingEvent : public CommonPendingEvent
-{
-public:
-       EventInsertPendingEvent() {}
-       EventInsertPendingEvent(void *thisObject, const  EventInsertPtr &event) :
-               m_thisObject(thisObject),
-               m_event(event)
-       {
-       }
-
-       virtual ~EventInsertPendingEvent()
-       {
-       }
-       virtual void* getThisObject() const { return m_thisObject; }
-       EventInsertPtr getEvent() const { return m_event; }
-private:
-       void *m_thisObject;
-       EventInsertPtr m_event;
-};
-
-class EventDeletePendingEvent : public  CommonPendingEvent
-{
-public:
-       EventDeletePendingEvent() {}
-       EventDeletePendingEvent(void *thisObject, const  EventDeletePtr &event) :
-               m_thisObject(thisObject),
-               m_event(event)
-       {
-       }
-
-       virtual ~EventDeletePendingEvent()
-       {
-       }
-       virtual void* getThisObject() const { return m_thisObject; }
-       EventDeletePtr getEvent() const { return m_event; }
-private:
-       void *m_thisObject;
-       EventDeletePtr m_event;
-};
 
-class EventUpdatePendingEvent : public CommonPendingEvent
-{
-public:
-       EventUpdatePendingEvent() {}
-       EventUpdatePendingEvent(void *thisObject, const  EventUpdatePtr &event) :
-               m_thisObject(thisObject),
-               m_event(event)
-       {
-       }
 
-       virtual ~EventUpdatePendingEvent()
-       {
-       }
-       virtual void* getThisObject() const { return m_thisObject; }
-       EventUpdatePtr getEvent() const { return m_event; }
-private:
-       void *m_thisObject;
-       EventUpdatePtr m_event;
-};
 
-class EventSelectPendingEvent : public CommonPendingEvent
-{
-public:
-       EventSelectPendingEvent() {}
-       EventSelectPendingEvent(void *thisObject, const  EventSelectPtr &event) :
-               m_thisObject(thisObject),
-               m_event(event)
-       {
-       }
-
-       virtual ~EventSelectPendingEvent()
-       {
-       }
-       virtual void* getThisObject() const { return m_thisObject; }
-       EventSelectPtr getEvent() const { return m_event; }
-private:
-       void *m_thisObject;
-       EventSelectPtr m_event;
 };
 
 }
index 71ecb79..d4a6267 100644 (file)
@@ -304,6 +304,7 @@ void ReqReceiverMessage::OnRequestReceived(const EventDeleteMessagesPtr& event)
 
        Try {
                std::vector<IMessagePtr> msg = event->msgArray;
+               MessageType msgType = UNKNOWN;
 
                int vecSize = msg.size();
                for(int i=0; i < vecSize; i++){
@@ -312,7 +313,10 @@ void ReqReceiverMessage::OnRequestReceived(const EventDeleteMessagesPtr& event)
                        msg[i]->remove();
                }//for
 
-               MessageType msgType = msg[vecSize-1]->getMessageType();
+               if(vecSize > 0)
+               {
+                       msgType = msg[vecSize-1]->getMessageType();
+               }
 
                if (msgType == EMAIL)
                {
index 234836b..4587e88 100755 (executable)
@@ -46,4 +46,3 @@ INSTALL(
        FILES_MATCHING PATTERN "*.h" PATTERN "CMakeFiles" EXCLUDE
 )
 
-add_subdir(test)
index 1da11d0..66e2051 100755 (executable)
@@ -201,6 +201,7 @@ void EventWatchSysteminfo::processGetValue()
                 break;
         }
         m_setLastValue = true;
+        m_cbm->callOnSuccess(lastValue);
         return;
     }