Update change log and spec for wrt-plugins-tizen_0.4.66
[framework/web/wrt-plugins-tizen.git] / src / DataControl / MappedDataControlConsumer.cpp
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 #include <cassert>
19 #include <Commons/Exception.h>
20 #include "DataType.h"
21 #include "MappedDataControlConsumer.h"
22 #include <appsvc/appsvc.h>
23 #include <string>
24 #include <vector>
25 #include <aul/aul.h>
26 #include <sstream>
27 #include <iostream>
28 #include <package-manager.h>
29 #include <security-server.h>
30
31 #include "DataControlAsyncCallbackManager.h"
32 #include "DataControlCallback.h"
33
34 #include "DataType.h"
35
36
37 namespace DeviceAPI {
38 namespace DataControl {
39
40 MappedDataControlConsumer::MappedDataControlConsumer(std::string& provId, std::string& dataId, std::string& type) 
41 {
42         LoggerD("Enter");
43
44         
45         m_type = type;;
46         m_dataId = dataId;
47         m_providerId = provId;
48
49         m_appId = getProviderApplicationId(OSP_PKGINFO_MAP_TYPE, provId);
50         m_ProviderPkgId = getProviderPkgId(m_appId);
51         security_server_app_give_access(m_ProviderPkgId.c_str(), -1);
52         
53         m_currentAppId = getCurrentApplicationId();
54
55         DataControlAsyncCallbackManagerSingleton::Instance().setDataControlGC((void*)this, false);
56
57 }
58
59 MappedDataControlConsumer::~MappedDataControlConsumer() 
60 {
61         LoggerD("Enter");
62         DataControlAsyncCallbackManagerSingleton::Instance().setDataControlGC((void*)this, true);
63         
64 }
65
66 DPL::Mutex MappedDataControlConsumer::m_mutex;
67
68
69
70 std::string MappedDataControlConsumer::getDataId()
71 {
72         return m_dataId;
73 }
74
75 std::string MappedDataControlConsumer::getProviderId()
76 {
77         return m_providerId;
78 }
79
80 std::string MappedDataControlConsumer::getType()
81 {
82         return m_type;
83 }
84
85 void MappedDataControlConsumer::handleCommonErrorEvent(void* userData, unsigned int code, std::string msg)
86 {
87         if (userData == NULL)
88         {
89                 LoggerD("userData null");
90                 return;
91         }
92         
93         CommonPendingEvent* pEvent = (CommonPendingEvent*)userData;
94         
95         try 
96         {
97                 if (dynamic_cast<EventAddValuePendingEvent*>(pEvent) != NULL)
98                 {
99                         EventAddValuePendingEvent* pendingAddValueEvent = (EventAddValuePendingEvent*)pEvent;
100                         EventAddValuePtr addValueEvent = pendingAddValueEvent->getEvent();
101                         addValueEvent->setExceptionCode((WrtDeviceApis::Commons::ExceptionCodes::Enumeration)code);
102                         addValueEvent->setErrorMsg(msg);                
103                 
104                         WrtDeviceApis::Commons::EventRequestReceiver<EventAddValue>::ManualAnswer(addValueEvent); 
105                 }
106                 else if (dynamic_cast<EventUpdateValuePendingEvent*>(pEvent) != NULL)
107                 {
108                         EventUpdateValuePendingEvent* pendingUpdateValueEvent = (EventUpdateValuePendingEvent*)pEvent;
109                         EventUpdateValuePtr updateValueEvent = pendingUpdateValueEvent->getEvent();
110                         updateValueEvent->setExceptionCode((WrtDeviceApis::Commons::ExceptionCodes::Enumeration)code);
111                         updateValueEvent->setErrorMsg(msg);             
112                         
113                         WrtDeviceApis::Commons::EventRequestReceiver<EventUpdateValue>::ManualAnswer(updateValueEvent); 
114                 }
115                 else if (dynamic_cast<EventGetValuePendingEvent*>(pEvent) != NULL)
116                 {
117                         EventGetValuePendingEvent* pendingGetValueEvent = (EventGetValuePendingEvent*)pEvent;
118                         EventGetValuePtr getValueEvent = pendingGetValueEvent->getEvent();
119                         getValueEvent->setExceptionCode((WrtDeviceApis::Commons::ExceptionCodes::Enumeration)code);
120                         getValueEvent->setErrorMsg(msg);
121                         
122                         WrtDeviceApis::Commons::EventRequestReceiver<EventGetValue>::ManualAnswer(getValueEvent); 
123                 }
124                 else if (dynamic_cast<EventRemoveValuePendingEvent*>(pEvent) != NULL)
125                 {
126                         EventRemoveValuePendingEvent* pendingRemoveEvent = (EventRemoveValuePendingEvent*)pEvent;
127                         EventRemoveValuePtr deleteEvent = pendingRemoveEvent->getEvent();
128                         deleteEvent->setExceptionCode((WrtDeviceApis::Commons::ExceptionCodes::Enumeration)code);
129                         deleteEvent->setErrorMsg(msg);
130                         
131                         WrtDeviceApis::Commons::EventRequestReceiver<EventRemoveValue>::ManualAnswer(deleteEvent); 
132                 }       
133         }
134         catch (const WrtDeviceApis::Commons::Exception& ex) 
135         {
136                 LoggerE("Exception: " << ex.GetMessage());
137         }
138
139 }
140
141
142 void MappedDataControlConsumer::handlePendingEvent(const EventAddValuePtr& event)
143 {
144         WrtDeviceApis::Commons::EventRequestReceiver<EventAddValue>::ManualAnswer(event);       
145 }
146
147 void MappedDataControlConsumer::handlePendingEvent(const EventRemoveValuePtr& event)
148 {
149         WrtDeviceApis::Commons::EventRequestReceiver<EventRemoveValue>::ManualAnswer(event); 
150 }
151
152 void MappedDataControlConsumer::handlePendingEvent(const EventGetValuePtr& event)
153 {
154         WrtDeviceApis::Commons::EventRequestReceiver<EventGetValue>::ManualAnswer(event);
155 }
156
157 void MappedDataControlConsumer::handlePendingEvent(const EventUpdateValuePtr& event)
158 {
159         WrtDeviceApis::Commons::EventRequestReceiver<EventUpdateValue>::ManualAnswer(event); 
160 }
161
162
163 void MappedDataControlConsumer::addValue(const EventAddValuePtr& event)
164 {
165         WrtDeviceApis::Commons::EventRequestReceiver<EventAddValue>::PostRequest(event);
166 }
167
168 void MappedDataControlConsumer::removeValue(const EventRemoveValuePtr& event)
169 {
170         WrtDeviceApis::Commons::EventRequestReceiver<EventRemoveValue>::PostRequest(event);
171 }
172
173 void MappedDataControlConsumer::getValue(const EventGetValuePtr& event)
174 {
175         WrtDeviceApis::Commons::EventRequestReceiver<EventGetValue>::PostRequest(event);
176 }
177
178 void MappedDataControlConsumer::updateValue(const EventUpdateValuePtr& event)
179 {
180         WrtDeviceApis::Commons::EventRequestReceiver<EventUpdateValue>::PostRequest(event);
181 }
182
183 bool MappedDataControlConsumer::checkReqIdUniqueness(unsigned int reqId)
184 {
185         std::string reqIdStr;
186         std::stringstream ssReqId;
187
188         ssReqId << reqId;
189         reqIdStr = ssReqId.str();
190         return DataControlAsyncCallbackManagerSingleton::Instance().checkReqIdUnique(reqIdStr);
191 }
192
193 void MappedDataControlConsumer::OnRequestReceived(const EventAddValuePtr& event)
194 {
195         LoggerD("Enter");
196
197         try 
198         {
199                 unsigned short currentJob = 0;
200                 unsigned int reqId = event->getReqId();
201                 std::string reqIdStr = convertIntToString(reqId);
202                 
203                 if (checkReqIdUniqueness(reqId) == false)
204                 {
205                         ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
206                 }
207                 
208                 EventAddValuePendingEvent* pendingEvent = new EventAddValuePendingEvent(this, m_dataId, m_appId, m_providerId,  m_currentAppId, event);
209                 
210                 if (DataControlAsyncCallbackManagerSingleton::Instance().checkRequestIpcOperation())
211                 {
212                         SendAppControlLaunchToProvider(pendingEvent, currentJob);
213                 }
214                 event->switchToManualAnswer();
215                 DataControlAsyncCallbackManagerSingleton::Instance().addSQLUserData(reqIdStr, (void*)pendingEvent);
216         }       
217         catch (const WrtDeviceApis::Commons::Exception& ex) 
218         {
219                 event->setExceptionCode(ex.getCode());
220                 event->setErrorMsg(ex.GetMessage());
221                 LoggerE("Exception: " << ex.GetMessage());
222         }
223
224 }
225
226 #if 0
227 void MappedDataControlConsumer::OnRequestReceived(const EventAddValuePtr& event)
228 {
229         LoggerD("Enter");
230         bundle* passData = NULL;
231
232         try 
233         {
234                 std::string dataId = getDataId();
235                 unsigned int reqId = event->getReqId();
236                 std::string key = event->getKey();
237                 std::string value = event->getValue();
238
239                 std::stringstream ss, ssreqtype;
240                 std::string reqIdStr, reqtypestr;
241                 std::vector<std::string> queryItem;
242
243                 if (checkReqIdUniqueness(reqId) == false)
244                 {
245                         ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
246                 }
247
248
249                 // conversion
250                 ss << reqId;
251                 reqIdStr = ss.str();
252
253                 ssreqtype << _DATACONTROL_REQUEST_TYPE_MAP_INSERT;
254                 reqtypestr = ssreqtype.str();
255
256                 passData = bundle_create();
257                 
258                 if (passData == NULL)
259                 {
260                         ThrowMsg(WrtDeviceApis::Commons::PlatformException, "ipc memory allocation fail");
261                 }
262
263                 appsvc_set_operation(passData, APPSVC_OPERATION_DEFAULT);
264
265                 appsvc_set_appid(passData, m_appId.c_str());
266
267                 bundle_add(passData, OSP_K_REQUEST_ID, reqIdStr.c_str());
268                 bundle_add(passData, OSP_K_CALLER_TYPE, OSP_V_CALLER_TYPE_OSP);
269                 bundle_add(passData, OSP_K_LAUNCH_TYPE, OSP_V_LAUNCH_TYPE_DATACONTROL);
270                 bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, reqtypestr.c_str());
271                 bundle_add(passData, OSP_K_DATACONTROL_PROVIDER, m_providerId.c_str());
272                 bundle_add(passData, OSP_K_DATACONTROL_PROTOCOL_VERSION, OSP_K_DATACONTROL_PROTOCOL_VERSION_VALUE); // version
273
274                 queryItem.push_back(dataId); // dataid
275                 queryItem.push_back(key); // key
276                 queryItem.push_back(value); // value
277
278                 addArrayToBundle(passData, queryItem);
279
280                 // FIXEME
281                 // reqid sholud be known
282                 EventAddValuePendingEvent* pendingEvent = new EventAddValuePendingEvent((void*)this, dataId, m_appId, m_providerId,  "", event);
283                 int pid = appsvc_run_service(passData, reqId, dataControlCommonCallback, (void*)pendingEvent);
284
285                 if (pid < 0) 
286                 {
287                         ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Error");
288                 }
289
290                 event->switchToManualAnswer();
291
292                 DPL::Mutex::ScopedLock lock(&m_mutex);
293         }       
294         catch (const WrtDeviceApis::Commons::Exception& ex) 
295         {
296                 event->setExceptionCode(ex.getCode());
297                 event->setErrorMsg(ex.GetMessage());
298                 LoggerE("Exception: " << ex.GetMessage());
299                 
300                 
301         }
302         
303         if (passData)
304         {
305                 bundle_free(passData);
306                 passData = NULL;
307         }
308
309 }
310 #endif
311
312 void MappedDataControlConsumer::OnRequestReceived(const EventRemoveValuePtr& event)
313 {
314         LoggerD("Enter");
315
316         try 
317         {
318                 unsigned short currentJob = 0;
319                 unsigned int reqId = event->getReqId();
320                 std::string reqIdStr = convertIntToString(reqId);
321                 
322                 if (checkReqIdUniqueness(reqId) == false)
323                 {
324                         ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
325                 }
326                 
327                 EventRemoveValuePendingEvent* pendingEvent = new EventRemoveValuePendingEvent(this, m_dataId, m_appId, m_providerId,  m_currentAppId, event);
328                 
329                 if (DataControlAsyncCallbackManagerSingleton::Instance().checkRequestIpcOperation())
330                 {
331                         SendAppControlLaunchToProvider(pendingEvent, currentJob);
332                 }
333                 event->switchToManualAnswer();
334                 DataControlAsyncCallbackManagerSingleton::Instance().addSQLUserData(reqIdStr, (void*)pendingEvent);
335         }       
336         catch (const WrtDeviceApis::Commons::Exception& ex) 
337         {
338                 event->setExceptionCode(ex.getCode());
339                 event->setErrorMsg(ex.GetMessage());
340                 LoggerE("Exception: " << ex.GetMessage());
341         }
342 }
343 #if 0
344 void MappedDataControlConsumer::OnRequestReceived(const EventRemoveValuePtr& event)
345 {
346         LoggerD("Enter");
347         bundle* passData = NULL;
348         
349         try 
350         {
351                 std::string dataId = getDataId();
352                 std::vector<std::string> queryItem;
353                 std::string key = event->getKey();
354                 std::string value = event->getValue();
355                 
356                 unsigned int reqId = event->getReqId();
357                 std::stringstream ss, ssreqtype;
358                 std::string reqIdStr, reqtypestr;
359
360                 ss << reqId;
361                 reqIdStr = ss.str();
362
363                 ssreqtype << _DATACONTROL_REQUEST_TYPE_MAP_DELETE;
364                 reqtypestr = ssreqtype.str();
365
366                 if (checkReqIdUniqueness(reqId) == false)
367                 {
368                         ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
369                 }
370
371                 passData = bundle_create();
372
373                 if (passData == NULL)
374                 {
375                         ThrowMsg(WrtDeviceApis::Commons::PlatformException, "ipc memory allocation fail");
376                 }
377
378                 appsvc_set_operation(passData, APPSVC_OPERATION_DEFAULT);
379                 appsvc_set_appid(passData, m_appId.c_str());
380
381                 bundle_add(passData, OSP_K_REQUEST_ID, reqIdStr.c_str());
382                 bundle_add(passData, OSP_K_CALLER_TYPE, OSP_V_CALLER_TYPE_OSP);
383                 bundle_add(passData, OSP_K_LAUNCH_TYPE, OSP_V_LAUNCH_TYPE_DATACONTROL);
384                 bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, reqtypestr.c_str());
385                 bundle_add(passData, OSP_K_DATACONTROL_PROVIDER, m_providerId.c_str());
386                 bundle_add(passData, OSP_K_DATACONTROL_PROTOCOL_VERSION, OSP_K_DATACONTROL_PROTOCOL_VERSION_VALUE); // version
387
388
389                 queryItem.push_back(dataId); // dataid
390                 queryItem.push_back(key);
391                 queryItem.push_back(value);
392                 
393
394                 addArrayToBundle(passData, queryItem);
395                 EventRemoveValuePendingEvent* pendingEvent = new EventRemoveValuePendingEvent(this, dataId, m_appId, m_providerId,  "", event);
396
397                 int pid = appsvc_run_service(passData, reqId, dataControlCommonCallback, (void*)pendingEvent);
398
399                 if (pid < 0) 
400                 {
401                         ThrowMsg(WrtDeviceApis::Commons::PlatformException, "dataconstrol request fail.(can not launch)");
402                 }
403
404                 event->switchToManualAnswer();
405
406                 DPL::Mutex::ScopedLock lock(&m_mutex);
407         }       
408         catch (const WrtDeviceApis::Commons::Exception& ex) 
409         {
410                 LoggerE("Exception: " << ex.GetMessage());
411                 event->setExceptionCode(ex.getCode());
412                 event->setErrorMsg(ex.GetMessage());
413         }
414         
415         if (passData)
416         {
417                 bundle_free(passData);
418                 passData = NULL;
419         }
420
421 }
422 #endif
423
424 void MappedDataControlConsumer::OnRequestReceived(const EventGetValuePtr& event)
425 {
426         LoggerD("Enter");
427
428         try 
429         {
430                 unsigned short currentJob = 0;
431                 unsigned int reqId = event->getReqId();
432                 std::string reqIdStr = convertIntToString(reqId);
433                 
434                 if (checkReqIdUniqueness(reqId) == false)
435                 {
436                         ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
437                 }
438                 
439                 EventGetValuePendingEvent* pendingEvent = new EventGetValuePendingEvent(this, m_dataId, m_appId, m_providerId,  m_currentAppId, event);
440                 
441                 if (DataControlAsyncCallbackManagerSingleton::Instance().checkRequestIpcOperation())
442                 {
443                         SendAppControlLaunchToProvider(pendingEvent, currentJob);
444                 }
445                 event->switchToManualAnswer();
446                 DataControlAsyncCallbackManagerSingleton::Instance().addSQLUserData(reqIdStr, (void*)pendingEvent);
447         }       
448         catch (const WrtDeviceApis::Commons::Exception& ex) 
449         {
450                 event->setExceptionCode(ex.getCode());
451                 event->setErrorMsg(ex.GetMessage());
452                 LoggerE("Exception: " << ex.GetMessage());
453         }
454
455 }
456
457
458 #if 0
459 void MappedDataControlConsumer::OnRequestReceived(const EventGetValuePtr& event)
460 {
461         LoggerD("Enter");
462         bundle* passData = NULL;
463         
464         try 
465         {
466                 std::string dataId = getDataId();
467                 std::vector<std::string> queryItem;
468                 
469                 unsigned int reqId = event->getReqId();
470                 std::stringstream ss, ssreqtype;
471                 std::string reqIdStr, reqtypestr;
472                 std::string key = event->getKey();
473
474                 if (checkReqIdUniqueness(reqId) == false)
475                 {
476                         ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
477                 }
478                 
479
480                 ss << reqId;
481                 reqIdStr = ss.str();
482
483                 ssreqtype << _DATACONTROL_REQUEST_TYPE_MAP_QUERY;
484                 reqtypestr = ssreqtype.str();
485
486                 passData = bundle_create();
487
488                 if (passData == NULL)
489                 {
490                         ThrowMsg(WrtDeviceApis::Commons::PlatformException, "ipc memory allocation fail");
491                 }
492
493                 appsvc_set_operation(passData, APPSVC_OPERATION_DEFAULT);
494                 appsvc_set_appid(passData, m_appId.c_str());
495
496                 bundle_add(passData, OSP_K_REQUEST_ID, reqIdStr.c_str());
497                 bundle_add(passData, OSP_K_CALLER_TYPE, OSP_V_CALLER_TYPE_OSP);
498                 bundle_add(passData, OSP_K_LAUNCH_TYPE, OSP_V_LAUNCH_TYPE_DATACONTROL);
499                 bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, reqtypestr.c_str());
500                 bundle_add(passData, OSP_K_DATACONTROL_PROVIDER, m_providerId.c_str());
501                 bundle_add(passData, OSP_K_DATACONTROL_PROTOCOL_VERSION, OSP_K_DATACONTROL_PROTOCOL_VERSION_VALUE); // version
502
503
504
505                 queryItem.push_back(dataId); // dataid
506                 queryItem.push_back(key);
507                 queryItem.push_back("1");
508                 queryItem.push_back("1");
509                 
510                 addArrayToBundle(passData, queryItem);
511                 EventGetValuePendingEvent* pendingEvent = new EventGetValuePendingEvent(this, dataId, m_appId, m_providerId,  "", event);
512                 
513                 int pid = appsvc_run_service(passData, reqId, dataControlCommonCallback, (void*)pendingEvent);
514
515                 if (pid < 0) 
516                 {
517                         ThrowMsg(WrtDeviceApis::Commons::PlatformException, "dataconstrol request fail.(can not launch)");
518                 }
519
520                 event->switchToManualAnswer();
521
522                 DPL::Mutex::ScopedLock lock(&m_mutex);          
523         }       
524         catch (const WrtDeviceApis::Commons::Exception& ex) 
525         {
526                 LoggerE("Exception: " << ex.GetMessage());
527                 event->setExceptionCode(ex.getCode());
528                 event->setErrorMsg(ex.GetMessage());
529         }
530
531         if (passData)
532         {
533                 bundle_free(passData);
534                 passData = NULL;
535         }
536                 
537 }       
538 #endif
539
540 void MappedDataControlConsumer::OnRequestReceived(const EventUpdateValuePtr& event)
541 {
542         LoggerD("Enter");
543
544         try 
545         {
546                 unsigned short currentJob = 0;
547                 unsigned int reqId = event->getReqId();
548                 std::string reqIdStr = convertIntToString(reqId);
549                 
550                 if (checkReqIdUniqueness(reqId) == false)
551                 {
552                         ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
553                 }
554                 
555                 EventUpdateValuePendingEvent* pendingEvent = new EventUpdateValuePendingEvent(this, m_dataId, m_appId, m_providerId,  m_currentAppId, event);
556                 
557                 if (DataControlAsyncCallbackManagerSingleton::Instance().checkRequestIpcOperation())
558                 {
559                         SendAppControlLaunchToProvider(pendingEvent, currentJob);
560                 }
561                 event->switchToManualAnswer();
562                 DataControlAsyncCallbackManagerSingleton::Instance().addSQLUserData(reqIdStr, (void*)pendingEvent);
563         }       
564         catch (const WrtDeviceApis::Commons::Exception& ex) 
565         {
566                 event->setExceptionCode(ex.getCode());
567                 event->setErrorMsg(ex.GetMessage());
568                 LoggerE("Exception: " << ex.GetMessage());
569         }
570 }
571
572 #if 0
573 void MappedDataControlConsumer::OnRequestReceived(const EventUpdateValuePtr& event)
574 {
575         LoggerD("Enter");
576         bundle* passData = NULL;
577         
578         try 
579         {
580                 std::string dataId = getDataId();
581                 std::vector<std::string> queryItem;
582                 
583                 unsigned int reqId = event->getReqId();
584                 std::stringstream ss, ssreqtype;
585                 std::string reqIdStr, reqtypestr;
586                 std::string key = event->getKey();
587                 std::string oldValue = event->getOldValue();
588                 std::string newValue = event->getNewValue();
589
590                 if (checkReqIdUniqueness(reqId) == false)
591                 {
592                         ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
593                 }
594                                 
595                 passData = bundle_create();
596
597                 if (passData == NULL)
598                 {
599                         ThrowMsg(WrtDeviceApis::Commons::PlatformException, "ipc memory allocation fail");
600                 }
601
602                 appsvc_set_operation(passData, APPSVC_OPERATION_DEFAULT);
603                 appsvc_set_appid(passData, m_appId.c_str());
604
605                 ss << reqId;
606                 reqIdStr = ss.str();
607
608                 ssreqtype << _DATACONTROL_REQUEST_TYPE_MAP_UPDATE;
609                 reqtypestr = ssreqtype.str();
610                 
611
612                 bundle_add(passData, OSP_K_REQUEST_ID, reqIdStr.c_str());
613                 bundle_add(passData, OSP_K_CALLER_TYPE, OSP_V_CALLER_TYPE_OSP);
614                 bundle_add(passData, OSP_K_LAUNCH_TYPE, OSP_V_LAUNCH_TYPE_DATACONTROL);
615                 bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, reqtypestr.c_str());
616                 bundle_add(passData, OSP_K_DATACONTROL_PROVIDER, m_providerId.c_str());
617                 bundle_add(passData, OSP_K_DATACONTROL_PROTOCOL_VERSION, OSP_K_DATACONTROL_PROTOCOL_VERSION_VALUE); // version
618
619
620                 queryItem.push_back(dataId); // dataid
621                 queryItem.push_back(key);
622                 queryItem.push_back(oldValue);
623                 queryItem.push_back(newValue);
624
625                 addArrayToBundle(passData, queryItem);
626                 EventUpdateValuePendingEvent* pendingEvent = new EventUpdateValuePendingEvent(this, dataId, m_appId, m_providerId,  "",  event);
627
628                 int pid = appsvc_run_service(passData, reqId, dataControlCommonCallback, (void*)pendingEvent);
629
630                 if (pid < 0) 
631                 {
632                         ThrowMsg(WrtDeviceApis::Commons::PlatformException, "dataconstrol request fail.(can not launch)");
633                 }
634
635                 event->switchToManualAnswer();
636
637                 DPL::Mutex::ScopedLock lock(&m_mutex);          
638         }       
639         catch (const WrtDeviceApis::Commons::Exception& ex) 
640         {
641                 LoggerE("Exception: " << ex.GetMessage());
642                 event->setExceptionCode(ex.getCode());
643                 event->setErrorMsg(ex.GetMessage());
644         }
645
646         if (passData)
647         {
648                 bundle_free(passData);
649                 passData = NULL;
650         }
651
652
653 }
654 #endif
655
656
657 }
658 }
659
660