Beta merge 2
[profile/ivi/wrt-plugins-tizen.git] / src / standards / Tizen / Call / JSCallHistory.cpp
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License. 
15  */
16
17
18 #include <CommonsJavaScript/Validator.h>
19 #include <CommonsJavaScript/JSUtils.h>
20 #include <CommonsJavaScript/JSCallbackManager.h>
21 #include <CommonsJavaScript/Utils.h>
22 #include <Tizen/Tizen/FilterConverter.h>
23 #include <API/Call/EventFindCallHistory.h>
24 #include <API/Call/EventRemoveBatch.h>
25 #include <API/Call/EventRemoveAll.h>
26 #include <API/Call/EventCallHistoryListener.h>
27 #include <API/Call/CallHistoryFactory.h>
28 #include <API/Call/ICallHistory.h>
29 #include <Tizen/Common/JSTizenExceptionFactory.h>
30 #include <Tizen/Common/JSTizenException.h> 
31 #include <Tizen/Common/SecurityExceptions.h>
32
33 #include "JSCallHistoryEntry.h"
34 #include "JSCallHistory.h"
35 #include "CallStaticController.h"
36 #include "CallMultiCallback.h"
37 #include "ResponseDispatcher.h"
38 #include "Converter.h"
39 #include "plugin_config.h"
40
41 using namespace std;
42 using namespace DPL;
43 using namespace TizenApis::Api::Tizen;
44 using namespace TizenApis::Api::Call;
45 using namespace WrtDeviceApis::Commons;
46 using namespace WrtDeviceApis::CommonsJavaScript;
47 using namespace TizenApis::Tizen1_0::Tizen;
48 using namespace TizenApis::Commons;
49
50 namespace TizenApis {
51 namespace Tizen1_0 {
52
53 JSClassRef JSCallHistory::m_jsClassRef = NULL;
54
55 JSClassDefinition JSCallHistory::m_classInfo =
56 {
57         0,
58         kJSClassAttributeNone,
59         "callhistory",
60         NULL,
61         m_property,
62         m_function,
63         initialize,
64         finalize,
65         NULL,
66         NULL,
67         NULL,
68         NULL,
69         NULL,
70         NULL,
71         NULL,
72         hasInstance,
73         NULL
74 };
75
76 JSStaticValue JSCallHistory::m_property[] = {
77         { 0, 0, 0, 0 }
78 };
79
80 JSStaticFunction JSCallHistory::m_function[] =
81 {
82         { "find", JSCallHistory::find, kJSPropertyAttributeNone },
83         { "remove",      JSCallHistory::remove,      kJSPropertyAttributeNone },
84         { "removeBatch",      JSCallHistory::removeBatch,      kJSPropertyAttributeNone },
85         { "removeAll",      JSCallHistory::removeAll,      kJSPropertyAttributeNone },
86         { "deleteRecording",      JSCallHistory::deleteRecording,      kJSPropertyAttributeNone },
87         { "addListener",      JSCallHistory::addListener,      kJSPropertyAttributeNone },
88         { "removeListener",      JSCallHistory::removeListener,      kJSPropertyAttributeNone },
89         { 0, 0, 0 }
90 };
91
92 const JSClassRef JSCallHistory::getClassRef() {
93         if (!m_jsClassRef) {
94                 m_jsClassRef = JSClassCreate(&m_classInfo);
95         }
96         return m_jsClassRef;
97 }
98
99 const JSClassDefinition* JSCallHistory::getClassInfo(){
100         return &m_classInfo;
101 }
102
103 void JSCallHistory::initialize(JSContextRef context, JSObjectRef object) {
104         JSCallHistoryPriv* priv = static_cast<JSCallHistoryPriv*>(JSObjectGetPrivate(object));
105
106         if (priv == NULL) {
107                 ICallHistoryPtr CallHistory(CallHistoryFactory::getInstance().getCallHistoryObject());
108                 priv = new JSCallHistoryPriv(context, CallHistory);
109                 if(!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
110                         delete priv;
111                 }
112         }
113 }
114
115 void JSCallHistory::finalize(JSObjectRef object) {
116         JSCallHistoryPriv* priv = static_cast<JSCallHistoryPriv*>(JSObjectGetPrivate(object));
117         if (priv != NULL) {
118                 JSObjectSetPrivate(object, NULL);
119                 delete priv;
120         }
121 }
122
123 JSObjectRef JSCallHistory::createJSObject(JSContextRef context, JSObjectRef object)
124 {
125         ICallHistoryPtr CallHistory(CallHistoryFactory::getInstance().getCallHistoryObject());
126         JSCallHistoryPriv* priv = new JSCallHistoryPriv(context, CallHistory);
127
128         return JSObjectMake(context, getClassRef(), priv);
129 }
130
131 bool JSCallHistory::hasInstance(JSContextRef context, JSObjectRef constructor,
132         JSValueRef possibleInstance, JSValueRef* exception) {
133         return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
134 }
135
136 JSValueRef JSCallHistory::find(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
137         const JSValueRef arguments[], JSValueRef* exception) {
138
139         if (argumentCount < 1 || argumentCount > 6) {
140                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
141         }
142
143         JSCallHistoryPriv *priv = static_cast<JSCallHistoryPriv*> (JSObjectGetPrivate(thisObject));
144         JSContextRef gContext = priv->getContext();
145
146         assert(priv && "Invalid private pointer.");
147         WrtDeviceApis::CommonsJavaScript::Converter converter(context);
148         Validator check(context, exception);
149
150         try {
151                 FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
152
153                 JSCallbackManagerPtr cbm(JSCallbackManager::createObject(gContext));
154
155                 if (argumentCount >= 2) {
156                         if (!JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1])) {
157                                 if (!JSObjectIsFunction(context, converter.toJSObjectRef(arguments[1]))) {
158                                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : error callback ");
159                                 }
160                                 cbm->setOnError(arguments[1]);
161                         }
162                 }
163
164                 if (argumentCount >= 1) {
165                         if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])) {
166                                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error : success callback ");
167                         } else if (!JSObjectIsFunction(context, converter.toJSObjectRef(arguments[0]))) {
168                                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : success callback ");
169                         }
170                         cbm->setOnSuccess(arguments[0]);
171                 }
172
173                 if (argumentCount >= 3) {
174                         if (!JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2])) {
175                                 if (!JSValueIsObject(context, arguments[2])) {
176                                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : filter");
177                                 }
178                         }
179                 }
180
181                 AceSecurityStatus status = CALL_CHECK_ACCESS(
182                                 gContext,
183                                 CALL_HISTORY_FUNCTION_API_FIND);
184
185                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
186
187                 EventFindCallHistoryPtr event(new EventFindCallHistory());
188                 ICallHistoryPtr callHistory(priv->getObject());
189                 event->setPrivateData(StaticPointerCast<IEventPrivateData> (cbm));
190                 event->setForAsynchronousCall(&ResponseDispatcher::getInstance());
191
192                 if (argumentCount >= 3) {
193                         if (!check.isNullOrUndefined(arguments[2])) {
194                                 FilterPtr filter = filterConverter->toFilter(arguments[2]);
195                                 event ->setFilter(filter);
196                         }
197                 }
198
199                 if (argumentCount >= 4) {
200                         if (!check.isNullOrUndefined(arguments[3])) {
201                                 event->setSortMode(filterConverter->toSortMode(arguments[3]));
202                         }
203                 }
204
205                 if (argumentCount >= 5) {
206                         if (!check.isNullOrUndefined(arguments[4])) {
207                                 event->setLimit(converter.toULong(arguments[4]));
208                         }
209                 }
210
211                 if (argumentCount >= 6) {
212                         if (!check.isNullOrUndefined(arguments[5])) {
213                                 event->setOffset(converter.toULong(arguments[5]));
214                         }
215                 }
216
217                 callHistory->find(event);
218         } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
219                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
220         } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
221                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
222         } catch(const WrtDeviceApis::Commons::PlatformException& ex) {
223                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
224         } catch(const WrtDeviceApis::Commons::Exception& ex) {
225                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
226         }
227
228         return JSValueMakeUndefined(context);
229 }
230
231 JSValueRef JSCallHistory::remove(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
232         const JSValueRef arguments[], JSValueRef* exception) {
233
234         if (argumentCount < 1 || argumentCount > 1) {
235                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
236         }
237
238         JSCallHistoryPriv *priv = static_cast<JSCallHistoryPriv*> (JSObjectGetPrivate(thisObject));
239         JSContextRef gContext = priv->getContext();
240
241         assert(priv && "Invalid private pointer.");
242         Converter converter(context);
243         Validator check(context, exception);
244
245         if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])) {
246                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error : CallHistoryEntry");
247         } else if (!JSValueIsObject(context, arguments[0])) {
248                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : CallHistoryEntry");
249         }
250
251         try {
252                 AceSecurityStatus status = CALL_CHECK_ACCESS(
253                                 gContext,
254                                 CALL_HISTORY_FUNCTION_API_REMOVE);
255
256                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
257
258                 ICallHistoryPtr callHistory(priv->getObject());
259                 CallHistoryEntryPropertiesPtr entry = converter.toCallHistoryEntryProperties(arguments[0]);
260                 callHistory->remove(entry->getEntryId());
261         } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
262                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
263         } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
264                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
265         } catch(const WrtDeviceApis::Commons::PlatformException& ex) {
266                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
267         } catch(const WrtDeviceApis::Commons::Exception& ex) {
268                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
269         }
270
271         return JSValueMakeUndefined(context);
272 }
273
274 JSValueRef JSCallHistory::removeBatch(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
275         const JSValueRef arguments[], JSValueRef* exception) {
276
277         if (argumentCount < 1 || argumentCount > 3) {
278                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
279         }
280
281         JSCallHistoryPriv *priv = static_cast<JSCallHistoryPriv*> (JSObjectGetPrivate(thisObject));
282         JSContextRef gContext = priv->getContext();
283
284         assert(priv && "Invalid private pointer.");
285         Converter converter(context);
286         Validator check(context, exception);
287
288         if (!JSIsArrayValue(context, arguments[0])) {
289                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : CallHistoryEntry array");
290         }
291
292         try {
293                 JSCallbackManagerPtr cbm(JSCallbackManager::createObject(gContext));
294
295                 if (argumentCount >= 3) {
296                         if (!JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2])) {
297                                 if (!JSObjectIsFunction(context, converter.toJSObjectRef(arguments[2]))) {
298                                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : error callback");
299                                 }
300                                 cbm->setOnError(arguments[2]);
301                         }
302                 }
303
304                 if (argumentCount >= 2) {
305                         if (!JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1])) {
306                                 if (!JSObjectIsFunction(context, converter.toJSObjectRef(arguments[1]))) {
307                                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : success callback");
308                                 }
309                                 cbm->setOnSuccess(arguments[1]);
310                         }
311                 }
312
313                 AceSecurityStatus status = CALL_CHECK_ACCESS(
314                                 gContext,
315                                 CALL_HISTORY_FUNCTION_API_REMOVE_BATCH);
316
317                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
318
319                 EventRemoveBatchPtr event(new EventRemoveBatch());
320                 ICallHistoryPtr callHistory(priv->getObject());
321
322                 event->setPrivateData(StaticPointerCast<IEventPrivateData> (cbm));
323                 event->setForAsynchronousCall(&ResponseDispatcher::getInstance());
324
325                 CallHistoryEntryList entryList = converter.toVectorOfCallHistoryEntryProperties(arguments[0]);
326
327                 std::vector<unsigned long> entryIds;
328
329                 if (entryList.size() > 0) {
330                         for (unsigned int i = 0; i < entryList.size(); i++) {
331                                 entryIds.push_back(entryList[i]->getEntryId());
332                         }
333                         event->setEntryIds(entryIds);
334                         callHistory->removeBatch(event);
335                 } else {
336                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error : Entry array is null");
337                 }
338         } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
339                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
340         } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
341                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
342         } catch(const WrtDeviceApis::Commons::PlatformException& ex) {
343                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
344         } catch(const WrtDeviceApis::Commons::Exception& ex) {
345                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
346         }
347
348         return JSValueMakeUndefined(context);
349 }
350
351 JSValueRef JSCallHistory::removeAll(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
352         const JSValueRef arguments[], JSValueRef* exception) {
353
354         if (argumentCount > 2) {
355                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
356         }
357
358         JSCallHistoryPriv *priv = static_cast<JSCallHistoryPriv*> (JSObjectGetPrivate(thisObject));
359         JSContextRef gContext = priv->getContext();
360
361         assert(priv && "Invalid private pointer.");
362         Converter converter(context);
363         Validator check(context, exception);
364
365         try {
366                 JSCallbackManagerPtr cbm(JSCallbackManager::createObject(gContext));
367
368                 if (argumentCount >= 2) {
369                         if (!JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1])) {
370                                 if (!JSObjectIsFunction(context, converter.toJSObjectRef(arguments[1]))) {
371                                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : error callback");
372                                 }
373                                 cbm->setOnError(arguments[1]);
374                         }
375                 }
376
377                 if (argumentCount >= 1) {
378                         if (!JSValueIsNull(context, arguments[0]) && !JSValueIsUndefined(context, arguments[0])) {
379                                 if (!JSObjectIsFunction(context, converter.toJSObjectRef(arguments[0]))) {
380                                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : success callback");
381                                 }
382                                 cbm->setOnSuccess(arguments[0]);
383                         }
384                 }
385
386                 AceSecurityStatus status = CALL_CHECK_ACCESS(
387                                 gContext,
388                                 CALL_HISTORY_FUNCTION_API_REMOVE_ALL);
389
390                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
391
392                 EventRemoveAllPtr event(new EventRemoveAll());
393                 ICallHistoryPtr callHistory(priv->getObject());
394                 event->setPrivateData(StaticPointerCast<IEventPrivateData> (cbm));
395                 event->setForAsynchronousCall(&ResponseDispatcher::getInstance());
396
397                 callHistory->removeAll(event);
398         } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
399                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
400         } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
401                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
402         } catch(const WrtDeviceApis::Commons::PlatformException& ex) {
403                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
404         } catch(const WrtDeviceApis::Commons::Exception& ex) {
405                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
406         }
407
408         return JSValueMakeUndefined(context);
409 }
410
411 JSValueRef JSCallHistory::deleteRecording(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
412         const JSValueRef arguments[], JSValueRef* exception) {
413
414         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, "Not supported error : deleteRecording");
415 }
416
417 JSValueRef JSCallHistory::addListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
418         const JSValueRef arguments[], JSValueRef* exception) {
419
420         if (argumentCount < 1 || argumentCount > 1) {
421                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
422         }
423
424         JSCallHistoryPriv *priv = static_cast<JSCallHistoryPriv*> (JSObjectGetPrivate(thisObject));
425         JSContextRef gContext = priv->getContext();
426
427         assert(priv && "Invalid private pointer.");
428         Converter converter(context);
429         Validator check(context, exception);
430
431         try {
432                 EventCallHistoryListenerPrivateDataPtr privData(converter.toEventCallHistoryListenerPrivateData(arguments[0], gContext));
433
434                 AceSecurityStatus status = CALL_CHECK_ACCESS(
435                                 gContext,
436                                 CALL_HISTORY_FUNCTION_API_ADDLISTENER);
437
438                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
439
440                 Api::Call::EventCallHistoryListenerEmitterPtr emitter(new Api::Call::EventCallHistoryListenerEmitter);
441                 emitter->setListener(&CallStaticController::getInstance());
442                 emitter->setEventPrivateData(DPL::StaticPointerCast<Api::Call::EventCallHistoryListener::PrivateDataType>(privData));
443
444                 ICallHistoryPtr callHistory(priv->getObject());
445                 long id = callHistory->addListener(emitter);
446
447                 return converter.toJSValueRefLong(id);
448         } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
449                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
450         } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
451                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
452         } catch(const WrtDeviceApis::Commons::PlatformException& ex) {
453                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
454         } catch(const WrtDeviceApis::Commons::Exception& ex) {
455                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
456         }
457
458         return JSValueMakeUndefined(context);
459 }
460
461 JSValueRef JSCallHistory::removeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
462         const JSValueRef arguments[], JSValueRef* exception) {
463
464         if (argumentCount < 1 || argumentCount > 1) {
465                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
466         }
467
468         JSCallHistoryPriv *priv = static_cast<JSCallHistoryPriv*> (JSObjectGetPrivate(thisObject));
469         JSContextRef gContext = priv->getContext();
470
471         assert(priv && "Invalid private pointer.");
472         Converter converter(context);
473         Validator check(context, exception);
474
475         try {
476                 if (check.isNullOrUndefined(arguments[0])) {
477                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error : handle");
478                 }
479
480                 AceSecurityStatus status = CALL_CHECK_ACCESS(
481                                 gContext,
482                                 CALL_HISTORY_FUNCTION_API_REMOVELISTENER);
483
484                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
485
486                 long id = static_cast<long>(converter.toLong(arguments[0]));
487
488                 if (id >= 0) {
489                         ICallHistoryPtr callHistory(priv->getObject());
490                         callHistory->removeListener(id);
491                 }
492         } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
493                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
494         } catch(const WrtDeviceApis::Commons::PlatformException& ex) {
495                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
496         } catch(const WrtDeviceApis::Commons::Exception& ex) {
497                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
498         }
499
500         return JSValueMakeUndefined(context);
501 }
502
503 }
504 }
505