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 "MappedDataControlConsumer.h"
22 #include <appsvc/appsvc.h>
28 #include <package-manager.h>
32 namespace DataControl {
37 static const char OSP_V_CALLER_TYPE_OSP[] = "osp";
38 static const char OSP_V_LAUNCH_TYPE_LAUNCH[] = "launch";
39 static const char OSP_V_LAUNCH_TYPE_APPCONTROL[] = "appcontrol";
40 static const char OSP_V_LAUNCH_TYPE_DATACONTROL[] = "datacontrol";
41 static const char OSP_V_LAUNCH_TYPE_CONDTION[] = "condition";
42 static const char OSP_V_REQUEST_TYPE_SQL_QUERY[] = "sql_query";
43 static const char OSP_V_REQUEST_TYPE_SQL_INSERT[] = "sql_insert";
44 static const char OSP_V_REQUEST_TYPE_SQL_UPDATE[] = "sql_update";
45 static const char OSP_V_REQUEST_TYPE_SQL_DELETE[] = "sql_delete";
46 static const char OSP_V_REQUEST_TYPE_MAP_QEURY[] = "map_query";
47 static const char OSP_V_REQUEST_TYPE_MAP_INSERT[] = "map_insert";
48 static const char OSP_V_REQUEST_TYPE_MAP_UPDATE[] = "map_update";
49 static const char OSP_V_REQUEST_TYPE_MAP_DELETE[] = "map_delete";
50 static const char BUNDLE_KEY_WINDOW[] = "__APP_SVC_K_WIN_ID__";
53 #define OSP_K_CALLER_TYPE "__OSP_CALLER_TYPE__"
54 #define OSP_K_LAUNCH_TYPE "__OSP_LAUNCH_TYPE__"
55 #define OSP_K_ARG "__OSP_ARGS__"
56 #define OSP_K_COND "__OSP_COND_NAME__"
57 #define OSP_K_APPID "__OSP_APPID__"
58 #define OSP_K_REQUEST_ID "__OSP_REQUEST_ID__"
59 #define OSP_K_APPCONTROL_PROVIDER "__OSP_APPCONTROL_PROVIDER__"
60 #define OSP_K_APPCONTROL_OPERATION "__OSP_APPCONTROL_OPERATION__"
61 #define OSP_K_APPCONTROL_CATEGORY "__OSP_APPCONTROL_CATEGORY__"
62 #define OSP_K_APPCONTROL_MIME "__OSP_APPCONTROL_MIME__"
63 #define OSP_K_APPCONTROL_URI "__OSP_APPCONTROL_URI__"
64 #define OSP_K_DATACONTROL_PROVIDER "__OSP_DATACONTROL_PROVIDER__"
65 #define OSP_K_DATACONTROL_REQUEST_TYPE "__OSP_DATACONTROL_REQUEST_TYPE__"
66 #define OSP_K_DATACONTROL_PROTOCOL_VERSION "__OSP_DATACONTROL_PROTOCOL_VERSION__"
69 #define RESULT_TRUE_FROM_OSP "1"
70 #define RESULT_FALSE_FROM_OSP "0"
72 static std::vector<std::string> getDataArrayFromBundle(bundle *b, std::string key)
74 std::vector<std::string> result;
79 array = appsvc_get_data_array(b, key.c_str(), &length);
81 if (array == NULL || length == 0)
83 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result data fail from datacontrol provider");
86 for (index = 0; index < length; index++)
88 result.push_back(array[index]);
95 static void MappedDataControlGetValueCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
99 EventGetValuePendingEvent *pendingEvent = NULL;
100 MappedDataControlConsumer *consumer = NULL;
101 EventGetValuePtr event;
104 std::ifstream getValueStream;
105 std::string getValueFilePath;
111 LoggerD("data null, can not send result to JS Layer");
115 pendingEvent = (EventGetValuePendingEvent *)data;
116 consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
117 event = pendingEvent->getEvent();
121 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
123 std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
125 for (index = 0; index < result.size(); index++)
127 LoggerD(result[index]);
130 if (result.size() < 2)
132 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid result from datacontrol provider");
135 // 0 : result true or false??
136 if (RESULT_TRUE_FROM_OSP != result[0])
139 if (result[1].find("E_KEY_NOT_FOUND") != std::string::npos)
141 ThrowMsg(WrtDeviceApis::Commons::NotFoundException, result[1]);
145 ThrowMsg(WrtDeviceApis::Commons::PlatformException, result[1]);
149 event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
152 std::istringstream str(result[2]);
158 getValueFilePath = result[3];
159 getValueStream.open(getValueFilePath.c_str(), std::ios::binary);
160 int memorizedSize = 255;
163 buf = new char[memorizedSize + 1];
165 if (getValueStream.is_open())
171 LoggerD("fail open" << getValueFilePath);
172 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "get value error");
175 for (index = 0; index < count; index++)
177 getValueStream.read((char*)&size, sizeof(int)); // read size
180 if (memorizedSize < size)
182 memorizedSize = size;
189 buf = new char[memorizedSize + 1];
194 ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Out of memory");
196 memset(buf, 0, memorizedSize + 1);
197 getValueStream.read((char*)buf, size);
202 event->addResultValue(buf);
206 /* for (index = 3; index < result.size(); index++)
208 event->addResultValue(result[index]);
214 catch (const WrtDeviceApis::Commons::Exception& ex)
216 LoggerE("Exception: " << ex.GetMessage());
217 event->setExceptionCode(ex.getCode());
218 event->setErrorMsg(ex.GetMessage());
220 getValueStream.close();
221 if (unlink(getValueFilePath.c_str()) != 0)
223 LoggerE("Error while removing SelectDataObject.");
226 consumer->handlePendingEvent(event);
235 static void MappedDataControlAddValueCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
240 EventAddValuePendingEvent *pendingEvent = NULL;
241 MappedDataControlConsumer *consumer = NULL;
242 EventAddValuePtr event;
248 LoggerD("data null, can not send result to JS Layer");
252 pendingEvent = (EventAddValuePendingEvent *)data;
253 consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
254 event = pendingEvent->getEvent();
258 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
260 std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
262 for (size_t index = 0; index < result.size(); index++)
264 LoggerD(result[index]);
267 if (result.size() < 2)
269 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid result from datacontrol provider");
272 // 0 : result true or false??
273 if (RESULT_TRUE_FROM_OSP != result[0])
276 ThrowMsg(WrtDeviceApis::Commons::PlatformException, result[1]);
279 event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
282 catch (const WrtDeviceApis::Commons::Exception& ex)
284 LoggerE("Exception: " << ex.GetMessage());
285 event->setExceptionCode(ex.getCode());
286 event->setErrorMsg(ex.GetMessage());
288 consumer->handlePendingEvent(event);
297 static void MappedDataControlRemoveValueCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
303 LoggerD("Data or Bundle error");
307 EventRemoveValuePendingEvent* pendingEvent = NULL;
308 MappedDataControlConsumer *consumer = NULL;
309 EventRemoveValuePtr event;
315 LoggerD("data null, can not send result to JS Layer");
319 pendingEvent = (EventRemoveValuePendingEvent *)data;
320 consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
321 event = pendingEvent->getEvent();
325 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
327 std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
329 for (size_t index = 0; index < result.size(); index++)
331 LoggerD(result[index]);
334 if (result.size() < 2)
336 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid result from datacontrol provider");
339 // 0 : result true or false??
340 if (RESULT_TRUE_FROM_OSP != result[0])
343 if (result[1].find("E_KEY_NOT_FOUND") != std::string::npos)
345 ThrowMsg(WrtDeviceApis::Commons::NotFoundException, result[1]);
349 ThrowMsg(WrtDeviceApis::Commons::PlatformException, result[1]);
353 event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
357 catch (const WrtDeviceApis::Commons::Exception& ex)
359 LoggerE("Exception: " << ex.GetMessage());
360 event->setExceptionCode(ex.getCode());
361 event->setErrorMsg(ex.GetMessage());
363 consumer->handlePendingEvent(event);
371 static void MappedDataControlUpdateValueCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
375 EventUpdateValuePendingEvent* pendingEvent = NULL;
376 MappedDataControlConsumer *consumer = NULL;
377 EventUpdateValuePtr event;
383 LoggerD("data null, can not send result to JS Layer");
387 pendingEvent = (EventUpdateValuePendingEvent *)data;
388 consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
389 event = pendingEvent->getEvent();
393 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Get result fail from datacontrol provider");
395 std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
397 for (size_t index = 0; index < result.size(); index++)
399 LoggerD(result[index]);
402 if (result.size() < 2)
404 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid result from datacontrol provider");
407 // 0 : result true or false??
408 if (RESULT_TRUE_FROM_OSP != result[0])
411 if (result[1].find("E_KEY_NOT_FOUND") != std::string::npos)
413 ThrowMsg(WrtDeviceApis::Commons::NotFoundException, result[1]);
417 ThrowMsg(WrtDeviceApis::Commons::PlatformException, result[1]);
421 event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
424 catch (const WrtDeviceApis::Commons::Exception& ex)
426 LoggerE("Exception: " << ex.GetMessage());
427 event->setExceptionCode(ex.getCode());
428 event->setErrorMsg(ex.GetMessage());
430 consumer->handlePendingEvent(event);
439 MappedDataControlConsumer::MappedDataControlConsumer()
450 MappedDataControlConsumer::~MappedDataControlConsumer()
455 DPL::Mutex MappedDataControlConsumer::m_mutex;
458 void MappedDataControlConsumer::setType(std::string& type)
460 if (type != MAP_DATA_CONTROL && type != SQL_DATA_CONTROL)
461 ThrowMsg(WrtDeviceApis::Commons::ConversionException, "type mismatch");
466 void MappedDataControlConsumer::setProviderId(const std::string& id )
471 void MappedDataControlConsumer::setDataId(const std::string& id )
477 std::string MappedDataControlConsumer::getDataId()
482 std::string MappedDataControlConsumer::getProviderId()
487 std::string MappedDataControlConsumer::getType()
495 std::string MappedDataControlConsumer::getApplicationId(const std::string& provId)
497 std::string appIdStr = "";
501 const char *passId = provId.c_str();
503 if (m_appId.length() == 0)
506 LoggerD("need " << passId);
508 if( pkgmgr_datacontrol_get_info(passId, OSP_PKGINFO_MAP_TYPE, &appId, &access) < 0)
510 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "get appId error");
535 void MappedDataControlConsumer::addArrayToBundle(bundle* passData, std::vector<std::string>& array)
537 size_t arraySize = array.size();
541 ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "size = 0");
544 const char** arr = NULL;
545 arr = (const char**)calloc(sizeof(char*), arraySize);
549 ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "null");
552 for (size_t index = 0; index < arraySize; index++)
554 arr[index] = array[index].c_str();
558 bundle_add_str_array(passData, OSP_K_ARG, arr, arraySize);
566 void MappedDataControlConsumer::handlePendingEvent(const EventAddValuePtr& event)
568 WrtDeviceApis::Commons::EventRequestReceiver<EventAddValue>::ManualAnswer(event);
569 removeReqId(event->getReqId());
571 void MappedDataControlConsumer::handlePendingEvent(const EventRemoveValuePtr& event)
573 WrtDeviceApis::Commons::EventRequestReceiver<EventRemoveValue>::ManualAnswer(event);
574 removeReqId(event->getReqId());
576 void MappedDataControlConsumer::handlePendingEvent(const EventGetValuePtr& event)
578 WrtDeviceApis::Commons::EventRequestReceiver<EventGetValue>::ManualAnswer(event);
579 removeReqId(event->getReqId());
582 void MappedDataControlConsumer::handlePendingEvent(const EventUpdateValuePtr& event)
584 WrtDeviceApis::Commons::EventRequestReceiver<EventUpdateValue>::ManualAnswer(event);
585 removeReqId(event->getReqId());
589 void MappedDataControlConsumer::addValue(const EventAddValuePtr& event)
591 WrtDeviceApis::Commons::EventRequestReceiver<EventAddValue>::PostRequest(event);
594 void MappedDataControlConsumer::removeValue(const EventRemoveValuePtr& event)
596 WrtDeviceApis::Commons::EventRequestReceiver<EventRemoveValue>::PostRequest(event);
599 void MappedDataControlConsumer::getValue(const EventGetValuePtr& event)
601 WrtDeviceApis::Commons::EventRequestReceiver<EventGetValue>::PostRequest(event);
604 void MappedDataControlConsumer::updateValue(const EventUpdateValuePtr& event)
606 WrtDeviceApis::Commons::EventRequestReceiver<EventUpdateValue>::PostRequest(event);
609 bool MappedDataControlConsumer::checkReqIdUniqueness(unsigned int reqId)
613 for (index = 0; index < m_currentReqIds.size(); index++)
615 if (m_currentReqIds[index] == reqId)
622 void MappedDataControlConsumer::removeReqId(unsigned int reqId)
626 std::vector<unsigned int>::iterator it, found;
628 for (it = m_currentReqIds.begin(); it != m_currentReqIds.end(); ++it)
639 DPL::Mutex::ScopedLock lock(&m_mutex);
640 m_currentReqIds.erase(found);
645 void MappedDataControlConsumer::OnRequestReceived(const EventAddValuePtr& event)
648 bundle* passData = NULL;
652 std::string dataId = getDataId();
653 unsigned int reqId = event->getReqId();
654 std::string key = event->getKey();
655 std::string value = event->getValue();
657 std::stringstream ss, ssreqtype;
658 std::string reqIdStr, reqtypestr;
659 std::vector<std::string> queryItem;
661 if (checkReqIdUniqueness(reqId) == false)
663 ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
671 ssreqtype << _DATACONTROL_REQUEST_TYPE_MAP_INSERT;
672 reqtypestr = ssreqtype.str();
675 // qi993y8s4e.DataControlProviderService
676 std::string appId = getApplicationId(m_providerId);
677 //.DataControlProviderService";
679 passData = bundle_create();
681 if (passData == NULL)
683 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "ipc memory allocation fail");
686 appsvc_set_operation(passData, APPSVC_OPERATION_DEFAULT);
688 appsvc_set_appid(passData, appId.c_str());
690 bundle_add(passData, OSP_K_REQUEST_ID, reqIdStr.c_str());
691 bundle_add(passData, OSP_K_CALLER_TYPE, OSP_V_CALLER_TYPE_OSP);
692 bundle_add(passData, OSP_K_LAUNCH_TYPE, OSP_V_LAUNCH_TYPE_DATACONTROL);
693 bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, reqtypestr.c_str());
694 bundle_add(passData, OSP_K_DATACONTROL_PROVIDER, m_providerId.c_str());
696 queryItem.push_back(dataId); // dataid
697 queryItem.push_back(key); // key
698 queryItem.push_back(value); // value
700 addArrayToBundle(passData, queryItem);
703 // reqid sholud be known
704 EventAddValuePendingEvent* pendingEvent = new EventAddValuePendingEvent((void*)this, event);
705 int pid = appsvc_run_service(passData, reqId, MappedDataControlAddValueCallback, (void*)pendingEvent);
709 ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Error");
712 event->switchToManualAnswer();
714 DPL::Mutex::ScopedLock lock(&m_mutex);
715 m_currentReqIds.push_back(reqId);
717 catch (const WrtDeviceApis::Commons::Exception& ex)
719 event->setExceptionCode(ex.getCode());
720 event->setErrorMsg(ex.GetMessage());
721 LoggerE("Exception: " << ex.GetMessage());
728 bundle_free(passData);
734 void MappedDataControlConsumer::OnRequestReceived(const EventRemoveValuePtr& event)
737 bundle* passData = NULL;
741 std::string dataId = getDataId();
742 std::vector<std::string> queryItem;
743 std::string key = event->getKey();
744 std::string value = event->getValue();
746 unsigned int reqId = event->getReqId();
747 std::stringstream ss, ssreqtype;
748 std::string reqIdStr, reqtypestr;
753 ssreqtype << _DATACONTROL_REQUEST_TYPE_MAP_DELETE;
754 reqtypestr = ssreqtype.str();
756 if (checkReqIdUniqueness(reqId) == false)
758 ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
762 std::string appId = getApplicationId(m_providerId);
763 passData = bundle_create();
765 if (passData == NULL)
767 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "ipc memory allocation fail");
770 appsvc_set_operation(passData, APPSVC_OPERATION_DEFAULT);
771 appsvc_set_appid(passData, appId.c_str());
773 bundle_add(passData, OSP_K_REQUEST_ID, reqIdStr.c_str());
774 bundle_add(passData, OSP_K_CALLER_TYPE, OSP_V_CALLER_TYPE_OSP);
775 bundle_add(passData, OSP_K_LAUNCH_TYPE, OSP_V_LAUNCH_TYPE_DATACONTROL);
776 bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, reqtypestr.c_str());
777 bundle_add(passData, OSP_K_DATACONTROL_PROVIDER, m_providerId.c_str());
779 queryItem.push_back(dataId); // dataid
780 queryItem.push_back(key);
781 queryItem.push_back(value);
784 addArrayToBundle(passData, queryItem);
785 EventRemoveValuePendingEvent* pendingEvent = new EventRemoveValuePendingEvent(this, event);
787 int pid = appsvc_run_service(passData, reqId, MappedDataControlRemoveValueCallback, (void*)pendingEvent);
791 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "dataconstrol request fail.(can not launch)");
794 event->switchToManualAnswer();
796 DPL::Mutex::ScopedLock lock(&m_mutex);
797 m_currentReqIds.push_back(reqId);
799 catch (const WrtDeviceApis::Commons::Exception& ex)
801 LoggerE("Exception: " << ex.GetMessage());
802 event->setExceptionCode(ex.getCode());
803 event->setErrorMsg(ex.GetMessage());
808 bundle_free(passData);
816 void MappedDataControlConsumer::OnRequestReceived(const EventGetValuePtr& event)
819 bundle* passData = NULL;
823 std::string dataId = getDataId();
824 std::vector<std::string> queryItem;
826 unsigned int reqId = event->getReqId();
827 std::stringstream ss, ssreqtype;
828 std::string reqIdStr, reqtypestr;
829 std::string key = event->getKey();
831 if (checkReqIdUniqueness(reqId) == false)
833 ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
840 ssreqtype << _DATACONTROL_REQUEST_TYPE_MAP_QUERY;
841 reqtypestr = ssreqtype.str();
843 std::string appId = getApplicationId(m_providerId);
845 passData = bundle_create();
847 if (passData == NULL)
849 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "ipc memory allocation fail");
852 appsvc_set_operation(passData, APPSVC_OPERATION_DEFAULT);
853 appsvc_set_appid(passData, appId.c_str());
855 bundle_add(passData, OSP_K_REQUEST_ID, reqIdStr.c_str());
856 bundle_add(passData, OSP_K_CALLER_TYPE, OSP_V_CALLER_TYPE_OSP);
857 bundle_add(passData, OSP_K_LAUNCH_TYPE, OSP_V_LAUNCH_TYPE_DATACONTROL);
858 bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, reqtypestr.c_str());
859 bundle_add(passData, OSP_K_DATACONTROL_PROVIDER, m_providerId.c_str());
860 bundle_add(passData, OSP_K_DATACONTROL_PROTOCOL_VERSION, "ver_2.1.0.1");
862 queryItem.push_back(dataId); // dataid
863 queryItem.push_back(key);
864 queryItem.push_back("1");
865 queryItem.push_back("1");
867 addArrayToBundle(passData, queryItem);
868 EventGetValuePendingEvent* pendingEvent = new EventGetValuePendingEvent(this, event);
870 int pid = appsvc_run_service(passData, reqId, MappedDataControlGetValueCallback, (void*)pendingEvent);
874 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "dataconstrol request fail.(can not launch)");
877 event->switchToManualAnswer();
879 DPL::Mutex::ScopedLock lock(&m_mutex);
880 m_currentReqIds.push_back(reqId);
882 catch (const WrtDeviceApis::Commons::Exception& ex)
884 LoggerE("Exception: " << ex.GetMessage());
885 event->setExceptionCode(ex.getCode());
886 event->setErrorMsg(ex.GetMessage());
891 bundle_free(passData);
897 void MappedDataControlConsumer::OnRequestReceived(const EventUpdateValuePtr& event)
900 bundle* passData = NULL;
904 std::string dataId = getDataId();
905 std::vector<std::string> queryItem;
907 unsigned int reqId = event->getReqId();
908 std::stringstream ss, ssreqtype;
909 std::string reqIdStr, reqtypestr;
910 std::string key = event->getKey();
911 std::string oldValue = event->getOldValue();
912 std::string newValue = event->getNewValue();
914 if (checkReqIdUniqueness(reqId) == false)
916 ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
919 std::string appId = getApplicationId(m_providerId);
920 passData = bundle_create();
922 if (passData == NULL)
924 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "ipc memory allocation fail");
927 appsvc_set_operation(passData, APPSVC_OPERATION_DEFAULT);
928 appsvc_set_appid(passData, appId.c_str());
933 ssreqtype << _DATACONTROL_REQUEST_TYPE_MAP_UPDATE;
934 reqtypestr = ssreqtype.str();
937 bundle_add(passData, OSP_K_REQUEST_ID, reqIdStr.c_str());
938 bundle_add(passData, OSP_K_CALLER_TYPE, OSP_V_CALLER_TYPE_OSP);
939 bundle_add(passData, OSP_K_LAUNCH_TYPE, OSP_V_LAUNCH_TYPE_DATACONTROL);
940 bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, reqtypestr.c_str());
941 bundle_add(passData, OSP_K_DATACONTROL_PROVIDER, m_providerId.c_str());
943 queryItem.push_back(dataId); // dataid
944 queryItem.push_back(key);
945 queryItem.push_back(oldValue);
946 queryItem.push_back(newValue);
948 addArrayToBundle(passData, queryItem);
949 EventUpdateValuePendingEvent* pendingEvent = new EventUpdateValuePendingEvent(this, event);
951 int pid = appsvc_run_service(passData, reqId, MappedDataControlUpdateValueCallback, (void*)pendingEvent);
955 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "dataconstrol request fail.(can not launch)");
958 event->switchToManualAnswer();
960 DPL::Mutex::ScopedLock lock(&m_mutex);
961 m_currentReqIds.push_back(reqId);
963 catch (const WrtDeviceApis::Commons::Exception& ex)
965 LoggerE("Exception: " << ex.GetMessage());
966 event->setExceptionCode(ex.getCode());
967 event->setErrorMsg(ex.GetMessage());
972 bundle_free(passData);