2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 #include <Commons/Exception.h>
21 #include "SqlDataControlConsumer.h"
22 #include <appsvc/appsvc.h>
27 #include <package-manager.h>
31 namespace DataControl {
36 static const char OSP_V_CALLER_TYPE_OSP[] = "osp";
37 static const char OSP_V_LAUNCH_TYPE_LAUNCH[] = "launch";
38 static const char OSP_V_LAUNCH_TYPE_APPCONTROL[] = "appcontrol";
39 static const char OSP_V_LAUNCH_TYPE_DATACONTROL[] = "datacontrol";
40 static const char OSP_V_LAUNCH_TYPE_CONDTION[] = "condition";
41 static const char OSP_V_REQUEST_TYPE_SQL_QUERY[] = "sql_query";
42 static const char OSP_V_REQUEST_TYPE_SQL_INSERT[] = "sql_insert";
43 static const char OSP_V_REQUEST_TYPE_SQL_UPDATE[] = "sql_update";
44 static const char OSP_V_REQUEST_TYPE_SQL_DELETE[] = "sql_delete";
45 static const char OSP_V_REQUEST_TYPE_MAP_QEURY[] = "map_query";
46 static const char OSP_V_REQUEST_TYPE_MAP_INSERT[] = "map_insert";
47 static const char OSP_V_REQUEST_TYPE_MAP_UPDATE[] = "map_update";
48 static const char OSP_V_REQUEST_TYPE_MAP_DELETE[] = "map_delete";
49 static const char BUNDLE_KEY_WINDOW[] = "__APP_SVC_K_WIN_ID__";
52 #define OSP_K_CALLER_TYPE "__OSP_CALLER_TYPE__"
53 #define OSP_K_LAUNCH_TYPE "__OSP_LAUNCH_TYPE__"
54 #define OSP_K_ARG "__OSP_ARGS__"
55 #define OSP_K_COND "__OSP_COND_NAME__"
56 #define OSP_K_APPID "__OSP_APPID__"
57 #define OSP_K_REQUEST_ID "__OSP_REQUEST_ID__"
58 #define OSP_K_APPCONTROL_PROVIDER "__OSP_APPCONTROL_PROVIDER__"
59 #define OSP_K_APPCONTROL_OPERATION "__OSP_APPCONTROL_OPERATION__"
60 #define OSP_K_APPCONTROL_CATEGORY "__OSP_APPCONTROL_CATEGORY__"
61 #define OSP_K_APPCONTROL_MIME "__OSP_APPCONTROL_MIME__"
62 #define OSP_K_APPCONTROL_URI "__OSP_APPCONTROL_URI__"
63 #define OSP_K_DATACONTROL_PROVIDER "__OSP_DATACONTROL_PROVIDER__"
64 #define OSP_K_DATACONTROL_REQUEST_TYPE "__OSP_DATACONTROL_REQUEST_TYPE__"
66 #define RESULT_TRUE_FROM_OSP "1"
67 #define RESULT_FALSE_FROM_OSP "0"
71 static std::vector<std::string> getDataArrayFromBundle(bundle *b, std::string key)
73 std::vector<std::string> result;
78 array = appsvc_get_data_array(b, key.c_str(), &length);
80 if (array == NULL || length == 0)
82 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result data fail from datacontrol provider");
85 for (index = 0; index < length; index++)
87 result.push_back(array[index]);
94 static void sqldataControlSelectCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
98 EventSelectPendingEvent *pendingEvent = NULL;
99 SQLDataControlConsumer *consumer = NULL;
100 EventSelectPtr event;
106 LogDebug("data null, can not send result to JS Layer");
110 pendingEvent = (EventSelectPendingEvent *)data;
111 consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
112 event = pendingEvent->getEvent();
116 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
118 std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
120 for (size_t index = 0; index < result.size(); index++)
122 LogDebug(result[index]);
125 if (result.size() < 3)
127 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid result from datacontrol provider");
130 // 0 : result true or false??
131 if (RESULT_TRUE_FROM_OSP != result[0])
134 ThrowMsg(WrtDeviceApis::Commons::PlatformException, result[1]);
137 event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
138 // 2 : result set file path
139 event->setResultSetPath(result[2]);
142 catch (const WrtDeviceApis::Commons::Exception& ex)
144 LogError("Exception: " << ex.GetMessage());
145 event->setExceptionCode(ex.getCode());
146 event->setErrorMsg(ex.GetMessage());
148 consumer->handlePendingEvent(event);
157 static void sqldataControlInsertCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
162 EventInsertPendingEvent *pendingEvent = NULL;
163 SQLDataControlConsumer *consumer = NULL;
164 EventInsertPtr event;
170 LogDebug("data null, can not send result to JS Layer");
174 pendingEvent = (EventInsertPendingEvent *)data;
175 consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
176 event = pendingEvent->getEvent();
180 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
182 std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
184 for (size_t index = 0; index < result.size(); index++)
186 LogDebug(result[index]);
189 if (result.size() < 2)
191 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid result from datacontrol provider");
194 // 0 : result true or false??
195 if (RESULT_TRUE_FROM_OSP != result[0])
198 ThrowMsg(WrtDeviceApis::Commons::PlatformException, result[1]);
202 std::stringstream sstr(result[2]);
203 long insertRowid = 0;
205 LogDebug(result[2] << insertRowid);
206 event->setRowId(insertRowid);
207 event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
210 catch (const WrtDeviceApis::Commons::Exception& ex)
212 LogError("Exception: " << ex.GetMessage());
213 event->setExceptionCode(ex.getCode());
214 event->setErrorMsg(ex.GetMessage());
216 consumer->handlePendingEvent(event);
225 static void sqldataControlDeleteCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
231 LogDebug("Data or Bundle error");
235 EventDeletePendingEvent* pendingEvent = NULL;
236 SQLDataControlConsumer *consumer = NULL;
237 EventDeletePtr event;
243 LogDebug("data null, can not send result to JS Layer");
247 pendingEvent = (EventDeletePendingEvent *)data;
248 consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
249 event = pendingEvent->getEvent();
253 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
255 std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
257 for (size_t index = 0; index < result.size(); index++)
259 LogDebug(result[index]);
262 if (result.size() < 2)
264 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid result from datacontrol provider");
267 // 0 : result true or false??
268 if (RESULT_TRUE_FROM_OSP != result[0])
271 ThrowMsg(WrtDeviceApis::Commons::PlatformException, result[1]);
274 event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
278 catch (const WrtDeviceApis::Commons::Exception& ex)
280 LogError("Exception: " << ex.GetMessage());
281 event->setExceptionCode(ex.getCode());
282 event->setErrorMsg(ex.GetMessage());
284 consumer->handlePendingEvent(event);
292 static void sqldataControlUpdateCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
296 EventUpdatePendingEvent* pendingEvent = NULL;
297 SQLDataControlConsumer *consumer = NULL;
298 EventUpdatePtr event;
304 LogDebug("data null, can not send result to JS Layer");
308 pendingEvent = (EventUpdatePendingEvent *)data;
309 consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
310 event = pendingEvent->getEvent();
314 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
316 std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
318 for (size_t index = 0; index < result.size(); index++)
320 LogDebug(result[index]);
323 if (result.size() < 2)
325 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid result from datacontrol provider");
328 // 0 : result true or false??
329 if (RESULT_TRUE_FROM_OSP != result[0])
332 ThrowMsg(WrtDeviceApis::Commons::PlatformException, result[1]);
335 event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
338 catch (const WrtDeviceApis::Commons::Exception& ex)
340 LogError("Exception: " << ex.GetMessage());
341 event->setExceptionCode(ex.getCode());
342 event->setErrorMsg(ex.GetMessage());
344 consumer->handlePendingEvent(event);
353 SQLDataControlConsumer::SQLDataControlConsumer()
365 SQLDataControlConsumer::~SQLDataControlConsumer()
370 DPL::Mutex SQLDataControlConsumer::m_mutex;
373 void SQLDataControlConsumer::setType(std::string& type)
375 if (type != MAP_DATA_CONTROL && type != SQL_DATA_CONTROL)
376 ThrowMsg(WrtDeviceApis::Commons::ConversionException, "type mismatch");
381 void SQLDataControlConsumer::setProviderId(const std::string& id )
386 void SQLDataControlConsumer::setDataId(const std::string& id )
391 void SQLDataControlConsumer::removeReqId(unsigned int reqId)
395 std::vector<unsigned int>::iterator it, found;
397 for (it = m_currentReqIds.begin(); it != m_currentReqIds.end(); ++it)
408 DPL::Mutex::ScopedLock lock(&m_mutex);
409 m_currentReqIds.erase(found);
413 bool SQLDataControlConsumer::checkReqIdUniqueness(unsigned int reqId)
417 for (index = 0; index < m_currentReqIds.size(); index++)
419 if (m_currentReqIds[index] == reqId)
427 std::string SQLDataControlConsumer::getDataId()
432 std::string SQLDataControlConsumer::getProviderId()
437 std::string SQLDataControlConsumer::getType()
443 std::string SQLDataControlConsumer::getApplicationId(const std::string& provId)
445 std::string appIdStr = "";
449 const char *passId = provId.c_str();
451 if (m_appId.length() == 0)
454 LogDebug("need " << passId);
456 if( pkgmgr_datacontrol_get_info(passId, OSP_PKGINFO_SQL_TYPE, &appId, &access) < 0)
458 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "get appId error");
483 void SQLDataControlConsumer::addArrayToBundle(bundle* passData, std::vector<std::string>& array)
485 size_t arraySize = array.size();
489 ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "size = 0");
492 const char** arr = NULL;
493 arr = (const char**)calloc(sizeof(char*), arraySize);
497 ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "null");
500 for (size_t index = 0; index < arraySize; index++)
502 arr[index] = array[index].c_str();
506 bundle_add_str_array(passData, OSP_K_ARG, arr, arraySize);
513 void SQLDataControlConsumer::handlePendingEvent(const EventInsertPtr& event)
515 WrtDeviceApis::Commons::EventRequestReceiver<EventInsert>::ManualAnswer(event);
516 removeReqId(event->getReqId());
518 void SQLDataControlConsumer::handlePendingEvent(const EventDeletePtr& event)
520 WrtDeviceApis::Commons::EventRequestReceiver<EventDelete>::ManualAnswer(event);
521 removeReqId(event->getReqId());
523 void SQLDataControlConsumer::handlePendingEvent(const EventSelectPtr& event)
525 WrtDeviceApis::Commons::EventRequestReceiver<EventSelect>::ManualAnswer(event);
526 removeReqId(event->getReqId());
529 void SQLDataControlConsumer::handlePendingEvent(const EventUpdatePtr& event)
531 WrtDeviceApis::Commons::EventRequestReceiver<EventUpdate>::ManualAnswer(event);
532 removeReqId(event->getReqId());
536 void SQLDataControlConsumer::insertData(const EventInsertPtr& event)
538 WrtDeviceApis::Commons::EventRequestReceiver<EventInsert>::PostRequest(event);
541 void SQLDataControlConsumer::deleteData(const EventDeletePtr& event)
543 WrtDeviceApis::Commons::EventRequestReceiver<EventDelete>::PostRequest(event);
546 void SQLDataControlConsumer::selectData(const EventSelectPtr& event)
548 WrtDeviceApis::Commons::EventRequestReceiver<EventSelect>::PostRequest(event);
551 void SQLDataControlConsumer::updateData(const EventUpdatePtr& event)
553 WrtDeviceApis::Commons::EventRequestReceiver<EventUpdate>::PostRequest(event);
556 void SQLDataControlConsumer::OnRequestReceived(const EventInsertPtr& event)
559 bundle* passData = NULL;
563 std::string dataId = getDataId();
564 RowDataPtr rowData = event->getRowData();
565 unsigned int reqId = event->getReqId();
566 std::stringstream ss, ssreqtype;
567 std::string reqIdStr, reqtypestr;
568 std::vector<std::string> queryItem;
570 int columnSize = rowData->m_Data.size();
571 std::stringstream counts;
572 std::string countStr;
574 if (checkReqIdUniqueness(reqId) == false)
576 ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
581 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "No insertion data");
584 counts << columnSize;
585 countStr = counts.str();
591 ssreqtype << _DATACONTROL_REQUEST_TYPE_SQL_INSERT;
592 reqtypestr = ssreqtype.str();
595 // qi993y8s4e.DataControlProviderService
596 std::string appId = getApplicationId(m_providerId);
597 //.DataControlProviderService";
599 passData = bundle_create();
601 if (passData == NULL)
603 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "ipc memory allocation fail");
606 appsvc_set_operation(passData, APPSVC_OPERATION_DEFAULT);
608 appsvc_set_appid(passData, appId.c_str());
610 bundle_add(passData, OSP_K_REQUEST_ID, reqIdStr.c_str());
611 bundle_add(passData, OSP_K_CALLER_TYPE, OSP_V_CALLER_TYPE_OSP);
612 bundle_add(passData, OSP_K_LAUNCH_TYPE, OSP_V_LAUNCH_TYPE_DATACONTROL);
613 bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, reqtypestr.c_str());
614 bundle_add(passData, OSP_K_DATACONTROL_PROVIDER, m_providerId.c_str());
616 queryItem.push_back(dataId); // dataid
617 queryItem.push_back(countStr);
619 std::map<std::string, std::string>::iterator it;
621 for (it = rowData->m_Data.begin(); it != rowData->m_Data.end(); ++it)
623 queryItem.push_back(it->first);
624 queryItem.push_back(it->second);
627 addArrayToBundle(passData, queryItem);
630 // reqid sholud be known
631 EventInsertPendingEvent* pendingEvent = new EventInsertPendingEvent((void*)this, event);
632 int pid = appsvc_run_service(passData, reqId, sqldataControlInsertCallback, (void*)pendingEvent);
636 ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Error");
639 event->switchToManualAnswer();
641 DPL::Mutex::ScopedLock lock(&m_mutex);
642 m_currentReqIds.push_back(reqId);
645 catch (const WrtDeviceApis::Commons::Exception& ex)
647 event->setExceptionCode(ex.getCode());
648 event->setErrorMsg(ex.GetMessage());
649 LogError("Exception: " << ex.GetMessage());
656 bundle_free(passData);
662 void SQLDataControlConsumer::OnRequestReceived(const EventDeletePtr& event)
665 bundle* passData = NULL;
669 std::string dataId = getDataId();
670 std::string where = event->getWhere();
671 std::vector<std::string> queryItem;
673 unsigned int reqId = event->getReqId();
674 std::stringstream ss, ssreqtype;
675 std::string reqIdStr, reqtypestr;
680 if (checkReqIdUniqueness(reqId) == false)
682 ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
686 ssreqtype << _DATACONTROL_REQUEST_TYPE_SQL_DELETE;
687 reqtypestr = ssreqtype.str();
689 std::string appId = getApplicationId(m_providerId);
691 passData = bundle_create();
694 if (passData == NULL)
696 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "ipc memory allocation fail");
699 appsvc_set_operation(passData, APPSVC_OPERATION_DEFAULT);
700 appsvc_set_appid(passData, appId.c_str());
702 bundle_add(passData, OSP_K_REQUEST_ID, reqIdStr.c_str());
703 bundle_add(passData, OSP_K_CALLER_TYPE, OSP_V_CALLER_TYPE_OSP);
704 bundle_add(passData, OSP_K_LAUNCH_TYPE, OSP_V_LAUNCH_TYPE_DATACONTROL);
705 bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, reqtypestr.c_str());
706 bundle_add(passData, OSP_K_DATACONTROL_PROVIDER, m_providerId.c_str());
708 queryItem.push_back(dataId); // dataid
710 if (where.size() == 0) // where
712 queryItem.push_back("NULL");
716 queryItem.push_back(where);
719 addArrayToBundle(passData, queryItem);
720 EventDeletePendingEvent* pendingEvent = new EventDeletePendingEvent(this, event);
722 int pid = appsvc_run_service(passData, reqId, sqldataControlDeleteCallback, (void*)pendingEvent);
726 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "dataconstrol request fail.(can not launch)");
729 event->switchToManualAnswer();
731 DPL::Mutex::ScopedLock lock(&m_mutex);
732 m_currentReqIds.push_back(reqId);
734 catch (const WrtDeviceApis::Commons::Exception& ex)
736 LogError("Exception: " << ex.GetMessage());
737 event->setExceptionCode(ex.getCode());
738 event->setErrorMsg(ex.GetMessage());
743 bundle_free(passData);
751 void SQLDataControlConsumer::OnRequestReceived(const EventSelectPtr& event)
754 bundle* passData = NULL;
758 std::string dataId = getDataId();
759 std::string where = event->getWhere();
760 std::vector<std::string> columns = event->getColumns();
761 std::vector<std::string> queryItem;
762 std::string order = event->getOrder();
763 std::string page = event->getPage();
764 std::string numberPerPage = event->getNumerPerPage();
766 unsigned int reqId = event->getReqId();
767 int columnSize = columns.size();
768 std::stringstream ss, ssreqtype;
769 std::string reqIdStr, reqtypestr;
771 if (checkReqIdUniqueness(reqId) == false)
773 ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
780 ssreqtype << _DATACONTROL_REQUEST_TYPE_SQL_QUERY;
781 reqtypestr = ssreqtype.str();
783 std::string appId = getApplicationId(m_providerId);
785 passData = bundle_create();
787 if (passData == NULL)
789 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "ipc memory allocation fail");
792 appsvc_set_operation(passData, APPSVC_OPERATION_DEFAULT);
793 appsvc_set_appid(passData, appId.c_str());
795 bundle_add(passData, OSP_K_REQUEST_ID, reqIdStr.c_str());
796 bundle_add(passData, OSP_K_CALLER_TYPE, OSP_V_CALLER_TYPE_OSP);
797 bundle_add(passData, OSP_K_LAUNCH_TYPE, OSP_V_LAUNCH_TYPE_DATACONTROL);
798 bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, reqtypestr.c_str());
799 bundle_add(passData, OSP_K_DATACONTROL_PROVIDER, m_providerId.c_str());
801 queryItem.push_back(dataId); // dataid
805 queryItem.push_back("NULL"); // column
810 std::stringstream counts;
811 std::string countStr;
813 counts << columnSize;
814 countStr = counts.str();
815 queryItem.push_back(countStr);
818 for (int index = 0; index < columnSize; index++)
820 queryItem.push_back(columns[index]);
824 if (where.size() == 0) // where
826 queryItem.push_back("NULL");
830 queryItem.push_back(where);
833 if (order.size() == 0) // order
835 queryItem.push_back("NULL");
839 queryItem.push_back(order);
842 if (page.size() == 0) // page
844 queryItem.push_back("1");
848 queryItem.push_back(page);
851 if (numberPerPage.size() == 0) // numberOfPage
853 queryItem.push_back("20");
857 queryItem.push_back(numberPerPage);
860 addArrayToBundle(passData, queryItem);
861 EventSelectPendingEvent* pendingEvent = new EventSelectPendingEvent(this, event);
863 int pid = appsvc_run_service(passData, reqId, sqldataControlSelectCallback, (void*)pendingEvent);
867 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "dataconstrol request fail.(can not launch)");
870 event->switchToManualAnswer();
872 DPL::Mutex::ScopedLock lock(&m_mutex);
873 m_currentReqIds.push_back(reqId);
875 catch (const WrtDeviceApis::Commons::Exception& ex)
877 LogError("Exception: " << ex.GetMessage());
878 event->setExceptionCode(ex.getCode());
879 event->setErrorMsg(ex.GetMessage());
884 bundle_free(passData);
890 void SQLDataControlConsumer::OnRequestReceived(const EventUpdatePtr& event)
893 bundle* passData = NULL;
897 std::string dataId = getDataId();
898 std::string where = event->getWhere();
899 RowDataPtr rowData = event->getRowData();
900 std::vector<std::string> queryItem;
902 unsigned int reqId = event->getReqId();
903 int columnSize = rowData->m_Data.size();
904 std::stringstream ss, ssreqtype;
905 std::string reqIdStr, reqtypestr;
908 if (checkReqIdUniqueness(reqId) == false)
910 ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
913 std::string appId = getApplicationId(m_providerId);
915 passData = bundle_create();
917 if (passData == NULL)
919 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "ipc memory allocation fail");
922 appsvc_set_operation(passData, APPSVC_OPERATION_DEFAULT);
923 appsvc_set_appid(passData, appId.c_str());
928 ssreqtype << _DATACONTROL_REQUEST_TYPE_SQL_UPDATE;
929 reqtypestr = ssreqtype.str();
932 bundle_add(passData, OSP_K_REQUEST_ID, reqIdStr.c_str());
933 bundle_add(passData, OSP_K_CALLER_TYPE, OSP_V_CALLER_TYPE_OSP);
934 bundle_add(passData, OSP_K_LAUNCH_TYPE, OSP_V_LAUNCH_TYPE_DATACONTROL);
935 bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, reqtypestr.c_str());
936 bundle_add(passData, OSP_K_DATACONTROL_PROVIDER, m_providerId.c_str());
938 queryItem.push_back(dataId); // dataid
942 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "should not be update data as 0");
947 std::stringstream counts;
948 std::string countStr;
950 counts << columnSize;
951 countStr = counts.str();
952 queryItem.push_back(countStr);
954 for (std::map<std::string, std::string>::iterator it= rowData->m_Data.begin();
955 it != rowData->m_Data.end(); ++it)
957 queryItem.push_back((*it).first); // key - column
958 queryItem.push_back((*it).second); // value
963 if (where.size() == 0) // where
965 queryItem.push_back("NULL");
969 queryItem.push_back(where);
972 addArrayToBundle(passData, queryItem);
973 EventUpdatePendingEvent* pendingEvent = new EventUpdatePendingEvent(this, event);
975 int pid = appsvc_run_service(passData, reqId, sqldataControlUpdateCallback, (void*)pendingEvent);
979 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "dataconstrol request fail.(can not launch)");
982 event->switchToManualAnswer();
984 DPL::Mutex::ScopedLock lock(&m_mutex);
985 m_currentReqIds.push_back(reqId);
987 catch (const WrtDeviceApis::Commons::Exception& ex)
989 LogError("Exception: " << ex.GetMessage());
990 event->setExceptionCode(ex.getCode());
991 event->setErrorMsg(ex.GetMessage());
996 bundle_free(passData);