2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file JSPluginTemplete.cpp
20 * @author Jaehyun Park (jaehyun77.park@samsung.com)
22 * @brief Implementation of the JSPluginTemplete class
25 #include "JSMessagingStorage.h"
26 #include "JSMessagingListener.h"
27 #include "ConverterMessage.h"
28 #include "MessagingStorageMultiCallback.h"
29 #include <API/Messaging/ReqReceiverMessage.h>
30 #include <API/Filter/SortMode.h>
32 #include <Tizen/Tizen/FilterConverter.h>
34 #include <CommonsJavaScript/Converter.h>
35 #include <CommonsJavaScript/Validator.h>
36 #include <CommonsJavaScript/JSUtils.h>
37 #include <CommonsJavaScript/JSCallbackManager.h>
38 #include <CommonsJavaScript/Utils.h>
39 #include <CommonsJavaScript/JSDOMExceptionFactory.h>
40 #include <CommonsJavaScript/SecurityExceptions.h>
42 #include <Tizen/Common/JSTizenExceptionFactory.h>
43 #include <Tizen/Common/JSTizenException.h>
44 #include <Tizen/Common/SecurityExceptions.h>
46 #include "MessagingErrorMsg.h"
47 #include "plugin_config.h"
52 using namespace WrtDeviceApis::Commons;
53 using namespace WrtDeviceApis::CommonsJavaScript;
54 using namespace TizenApis::Tizen1_0::Tizen;
55 using namespace TizenApis::Commons;
61 JSClassRef JSMessagingStorage::m_jsClassRef = NULL;
63 JSClassDefinition JSMessagingStorage::m_classInfo = {
65 kJSClassAttributeNone,
75 NULL, //deleteProperty,Geolocation
76 NULL, //getPropertyNames,
83 JSStaticFunction JSMessagingStorage::m_function[] = {
84 { "addDraftMessage", JSMessagingStorage::addDraftMessage, kJSPropertyAttributeNone },
85 { "findMessages", JSMessagingStorage::findMessages, kJSPropertyAttributeNone },
86 { "removeMessages", JSMessagingStorage::removeMessages, kJSPropertyAttributeNone },
87 { "updateMessages", JSMessagingStorage::updateMessages, kJSPropertyAttributeNone },
88 { "findConversations", JSMessagingStorage::findConversations, kJSPropertyAttributeNone },
89 { "removeConversations", JSMessagingStorage::removeConversations, kJSPropertyAttributeNone },
90 { "findFolders", JSMessagingStorage::findFolders, kJSPropertyAttributeNone },
91 { "addMessagesChangeListener", JSMessagingStorage::addMessagesChangeListener, kJSPropertyAttributeNone },
92 { "addConversationsChangeListener", JSMessagingStorage::addConversationsChangeListener, kJSPropertyAttributeNone },
93 { "addFoldersChangeListener", JSMessagingStorage::addFoldersChangeListener, kJSPropertyAttributeNone },
94 { "removeChangeListener", JSMessagingStorage::removeChangeListener, kJSPropertyAttributeNone },
98 const JSClassRef JSMessagingStorage::getClassRef() {
100 m_jsClassRef = JSClassCreate(&m_classInfo);
105 void JSMessagingStorage::initialize(JSContextRef context, JSObjectRef object) {
106 LogDebug("creation messaging instance");
108 JSMessagingListener* priv = new JSMessagingListener(context);
109 JSObjectSetPrivate(object, static_cast<void*>(priv));
110 LogDebug("global context=" << priv->getContext());
114 void JSMessagingStorage::finalize(JSObjectRef object) {
116 JSMessagingListener* priv =
117 static_cast<JSMessagingListener*>(JSObjectGetPrivate(object));
119 // deregister from incoming message notifications
120 priv->deregisterMessageReceivedEmitter();
122 LogDebug("deleting private object (messaging)");
123 // for messaging object, private object is shared pointer, so will be deleted automatically
125 // object will be deleted, but used to show that private object is deleted
126 JSObjectSetPrivate(object, NULL);
131 bool JSMessagingStorage::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
132 return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
135 JSValueRef JSMessagingStorage::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
138 JSValueRef retVal = NULL;
141 Converter convert(context);
142 if (JSStringIsEqualToUTF8CString(propertyName, "FOLDER_INBOX")) {
143 LogDebug("FOLDER_INBOX" << ":" << "1");
144 retVal = convert.toJSValueRef(Api::Messaging::INBOX);
145 } else if (JSStringIsEqualToUTF8CString(propertyName, "FOLDER_OUTBOX")) {
146 LogDebug("FOLDER_OUTBOX" << ":" << "2");
147 retVal = convert.toJSValueRef(Api::Messaging::OUTBOX);
148 } else if (JSStringIsEqualToUTF8CString(propertyName, "FOLDER_DRAFTS")) {
149 LogDebug("FOLDER_DRAFTS" << ":" << "3");
150 retVal = convert.toJSValueRef(Api::Messaging::DRAFTBOX);
151 } else if (JSStringIsEqualToUTF8CString(propertyName, "FOLDER_SENTBOX")) {
152 LogDebug("FOLDER_SENTBOX" << ":" << "4");
153 retVal = convert.toJSValueRef(Api::Messaging::SENTBOX);
155 retVal = JSValueMakeUndefined(context);
157 }Catch (WrtDeviceApis::Commons::Exception){
158 LogError("Exception: " << _rethrown_exception.GetMessage());
159 return JSTizenExceptionFactory::postException(context, exception,
160 JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
168 JSValueRef JSMessagingStorage::addDraftMessage(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
169 const JSValueRef arguments[], JSValueRef* exception) {
173 JSMessagingListener* priv = static_cast<JSMessagingListener*>
174 (JSObjectGetPrivate(thisObject));
177 LogError(">>> Null pointer");
178 return JSTizenExceptionFactory::postException(context, exception,
179 JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
183 JSContextRef globalContext = priv->getContext();
185 if (argumentCount < 1) {
186 LogError(">>> TypeMismatchException");
187 return JSTizenExceptionFactory::postException(context, exception,
188 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
192 WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(globalContext);
194 ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
198 AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
200 MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_DRAFT_MESSAGE]);
201 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
203 Api::Messaging::EventAddDraftMessagePtr event(new Api::Messaging::EventAddDraftMessage());
205 FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
207 if (argumentCount > 1) {
208 callbackManager->setOnSuccess(converter->toFunctionOrNull(arguments[1]));
211 if (argumentCount > 2) {
212 callbackManager->setOnError(converter->toFunctionOrNull(arguments[2]));
215 event->msg = converter->toIMessage(arguments[0]);
217 event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData >(
219 event->setForAsynchronousCall(priv);
221 Api::Messaging::ReqReceiverMessageSingleton::Instance().addDraftMessage(event);
223 return JSValueMakeNull(context);
224 }Catch(WrtDeviceApis::Commons::ConversionException) {
225 LogError(">>> TypeMismatchException");
226 return JSTizenExceptionFactory::postException(context, exception,
227 JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
228 }Catch(WrtDeviceApis::Commons::NullPointerException) {
229 LogError(">>> TypeMismatchException");
230 return JSTizenExceptionFactory::postException(context, exception,
231 JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
232 }Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
233 LogError(">>> InvalidValuesException");
234 if(argumentCount < 3)
236 return JSTizenExceptionFactory::postException(context, exception,
237 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
239 callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,
240 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
241 }Catch(WrtDeviceApis::Commons::PlatformException) {
242 LogError(">>> UnknownException");
243 return JSTizenExceptionFactory::postException(context, exception,
244 JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
247 LogError(">>> JSValueMakeNull");
248 return JSValueMakeNull(context);
253 JSValueRef JSMessagingStorage::findMessages(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
254 const JSValueRef arguments[], JSValueRef* exception) {
258 JSMessagingListener* priv = static_cast<JSMessagingListener*>
259 (JSObjectGetPrivate(thisObject));
262 LogError(">>> Null pointer");
263 return JSTizenExceptionFactory::postException(context, exception,
264 JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
268 JSContextRef globalContext = priv->getContext();
270 if (argumentCount < 2) {
271 LogError(">>> TypeMismatchException");
272 return JSTizenExceptionFactory::postException(context, exception,
273 JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
277 WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(globalContext);
279 ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
283 AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
285 MessagingExportedNames[MESSAGING_FUNCTION_API_FIND_MESSAGES]);
286 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
288 Api::Messaging::EventQueryMessagesPtr event(new Api::Messaging::EventQueryMessages());
290 FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
292 Api::Tizen::FilterPtr filter = filterConverter->toFilter(arguments[0]);
293 event->setFilter(filter);
295 callbackManager->setOnSuccess(converter->toFunction(arguments[1]));
297 if(argumentCount > 2)
299 callbackManager->setOnError(converter->toFunctionOrNull(arguments[2]));
302 if ((argumentCount >= 3) && !JSValueIsNull(context, arguments[0]) && !JSValueIsUndefined(context, arguments[0])) {
303 switch(argumentCount){
305 long offset = filterConverter->toLong(arguments[5]);
306 LogDebug("offset:" << offset);
307 event->setOffset(offset);
310 long limit = filterConverter->toLong(arguments[4]);
311 LogDebug("limit:" << limit);
312 event->setLimit(limit);
315 Api::Tizen::SortModePtr sortMode = filterConverter->toSortMode(arguments[3]);
316 event->setSortMode(sortMode);
322 event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData >(callbackManager));
323 event->setForAsynchronousCall(priv);
325 Api::Messaging::ReqReceiverMessageSingleton::Instance().queryMessages(event);
328 return JSValueMakeNull(context);
329 }Catch(WrtDeviceApis::Commons::ConversionException) {
330 LogError(">>> TypeMismatchException");
331 return JSTizenExceptionFactory::postException(context, exception,
332 JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
333 }Catch(WrtDeviceApis::Commons::NullPointerException) {
334 LogError(">>> TypeMismatchException");
335 return JSTizenExceptionFactory::postException(context, exception,
336 JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
337 }Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
338 LogError(">>> InvalidValuesException");
339 if(argumentCount < 3)
341 return JSTizenExceptionFactory::postException(context, exception,
342 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
344 callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,
345 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
346 }Catch(WrtDeviceApis::Commons::PlatformException) {
347 LogError(">>> UnknownException");
348 return JSTizenExceptionFactory::postException(context, exception,
349 JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
352 LogError(">>> JSValueMakeNull");
353 return JSValueMakeNull(context);
356 JSValueRef JSMessagingStorage::removeMessages(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
357 const JSValueRef arguments[], JSValueRef* exception) {
361 JSMessagingListener* priv = static_cast<JSMessagingListener*>
362 (JSObjectGetPrivate(thisObject));
365 LogError("Null pointer");
366 return JSTizenExceptionFactory::postException(context, exception,
367 JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
371 JSContextRef globalContext = priv->getContext();
373 if (argumentCount < 1) {
374 return JSTizenExceptionFactory::postException(context, exception,
375 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
378 WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(globalContext);
380 ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
384 AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
386 MessagingExportedNames[MESSAGING_FUNCTION_API_REMOVE_MESSAGES]);
387 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
389 Api::Messaging::EventDeleteMessagesPtr event(new Api::Messaging::EventDeleteMessages());
392 if (argumentCount > 1) {
393 callbackManager->setOnSuccess(converter->toFunctionOrNull(arguments[1]));
396 if (argumentCount > 2) {
397 callbackManager->setOnError(converter->toFunctionOrNull(arguments[2]));
400 std::vector<Api::Messaging::IMessagePtr> msgs;
402 JSObjectRef objArg = converter->toJSObjectRef(arguments[0]);
403 LogDebug("array length "<<JSGetArrayLength(context, objArg));
404 for (std::size_t i = 0; i < JSGetArrayLength(context, objArg); i++){
405 JSValueRef element = JSGetArrayElement(context, objArg, i);
406 JSObjectRef arg = JSValueToObject(context, element, NULL);
407 Api::Messaging::IMessagePtr msg = converter->toIMessage(arg);
410 event->msgArray = msgs;
412 event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData >(callbackManager));
413 event->setForAsynchronousCall(priv);
415 Api::Messaging::ReqReceiverMessageSingleton::Instance().deleteMessages(event);
417 return JSValueMakeNull(context);
418 }Catch(WrtDeviceApis::Commons::ConversionException) {
419 LogError(">>> TypeMismatchException");
420 return JSTizenExceptionFactory::postException(context, exception,
421 JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
422 }Catch(WrtDeviceApis::Commons::NullPointerException) {
423 LogError(">>> TypeMismatchException");
424 return JSTizenExceptionFactory::postException(context, exception,
425 JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
426 }Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
427 LogError(">>> InvalidValuesException");
428 if(argumentCount < 3)
430 return JSTizenExceptionFactory::postException(context, exception,
431 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
433 callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,
434 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
435 }Catch(WrtDeviceApis::Commons::PlatformException) {
436 LogError(">>> UnknownException");
437 return JSTizenExceptionFactory::postException(context, exception,
438 JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
441 return JSValueMakeNull(context);
444 JSValueRef JSMessagingStorage::updateMessages(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
445 const JSValueRef arguments[], JSValueRef* exception) {
449 JSMessagingListener* priv = static_cast<JSMessagingListener*>
450 (JSObjectGetPrivate(thisObject));
453 LogError("Null pointer");
454 return JSTizenExceptionFactory::postException(context, exception,
455 JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
459 JSContextRef globalContext = priv->getContext();
461 if (argumentCount < 1) {
462 return JSTizenExceptionFactory::postException(context, exception,
463 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
466 WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(
469 ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
474 AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
476 MessagingExportedNames[MESSAGING_FUNCTION_API_UPDATE_MESSAGES]);
477 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
479 Api::Messaging::EventUpdateMessagesPtr event(new Api::Messaging::EventUpdateMessages());
481 if (argumentCount > 1) {
482 callbackManager->setOnSuccess(converter->toFunctionOrNull(arguments[1]));
485 if (argumentCount > 2) {
486 callbackManager->setOnError(converter->toFunctionOrNull(arguments[2]));
490 std::vector<Api::Messaging::IMessagePtr> msgs;
492 JSObjectRef objArg = converter->toJSObjectRef(arguments[0]);
493 LogDebug("array length "<<JSGetArrayLength(context, objArg));
494 for (std::size_t i = 0; i < JSGetArrayLength(context, objArg); i++)
496 JSValueRef element = JSGetArrayElement(context, objArg, i);
497 JSObjectRef arg = JSValueToObject(context, element, NULL);
498 Api::Messaging::IMessagePtr msg = converter->toIMessage(arg);
501 event->msgArray = msgs;
503 event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData >(
505 event->setForAsynchronousCall(priv);
507 Api::Messaging::ReqReceiverMessageSingleton::Instance().updateMessages(event);
509 return JSValueMakeNull(context);
511 Catch(WrtDeviceApis::Commons::ConversionException) {
512 LogError(">>> TypeMismatchException");
513 return JSTizenExceptionFactory::postException(context, exception,
514 JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
515 }Catch(WrtDeviceApis::Commons::NullPointerException) {
516 LogError(">>> TypeMismatchException");
517 return JSTizenExceptionFactory::postException(context, exception,
518 JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
519 }Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
520 LogError(">>> InvalidValuesException");
521 if(argumentCount < 3)
523 return JSTizenExceptionFactory::postException(context, exception,
524 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
526 callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,
527 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
528 }Catch(WrtDeviceApis::Commons::PlatformException) {
529 LogError(">>> UnknownException");
530 return JSTizenExceptionFactory::postException(context, exception,
531 JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
534 return JSValueMakeNull(context);
537 JSValueRef JSMessagingStorage::findConversations(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
538 const JSValueRef arguments[], JSValueRef* exception)
543 JSMessagingListener* priv = static_cast<JSMessagingListener*>
544 (JSObjectGetPrivate(thisObject));
547 LogError(">>> Null pointer");
548 return JSTizenExceptionFactory::postException(context, exception,
549 JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
552 JSContextRef globalContext = priv->getContext();
554 if (argumentCount < 2) {
555 LogError(">>> TypeMismatchException");
556 return JSTizenExceptionFactory::postException(context, exception,
557 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
561 JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(globalContext);
563 ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
567 AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
569 MessagingExportedNames[MESSAGING_FUNCTION_API_FIND_CONVERSATIONS]);
570 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
572 Api::Messaging::EventQueryConversationsPtr event(new Api::Messaging::EventQueryConversations());
574 FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
576 Api::Tizen::FilterPtr filter = filterConverter->toFilter(arguments[0]);
577 event->setFilter(filter);
579 callbackManager->setOnSuccess(converter->toFunction(arguments[1]));
581 if (argumentCount > 2)
583 callbackManager->setOnError(converter->toFunctionOrNull(arguments[2]));
586 // setup message filter
587 if ((argumentCount >= 3) && !JSValueIsNull(context, arguments[0]) && !JSValueIsUndefined(context, arguments[0]))
589 switch(argumentCount)
593 long offset = filterConverter->toLong(arguments[5]);
594 LogDebug("offset:" << offset);
595 event->setOffset(offset);
599 long limit = filterConverter->toLong(arguments[4]);
600 LogDebug("limit:" << limit);
601 event->setLimit(limit);
605 Api::Tizen::SortModePtr sortMode = filterConverter->toSortMode(arguments[3]);
606 event->setSortMode(sortMode);
612 event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData >(callbackManager));
613 event->setForAsynchronousCall(priv);
615 Api::Messaging::ReqReceiverMessageSingleton::Instance().queryConversations(event);
617 return JSValueMakeNull(context);
619 Catch(WrtDeviceApis::Commons::ConversionException) {
620 LogError(">>> TypeMismatchException");
621 return JSTizenExceptionFactory::postException(context, exception,
622 JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
623 }Catch(WrtDeviceApis::Commons::NullPointerException) {
624 LogError(">>> TypeMismatchException");
625 return JSTizenExceptionFactory::postException(context, exception,
626 JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
627 }Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
628 LogError(">>> InvalidValuesException");
629 if(argumentCount < 3)
631 return JSTizenExceptionFactory::postException(context, exception,
632 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
634 callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,
635 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
636 }Catch(WrtDeviceApis::Commons::PlatformException) {
637 LogError(">>> UnknownException");
638 return JSTizenExceptionFactory::postException(context, exception,
639 JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
642 LogError(">>> JSValueMakeNull");
643 return JSValueMakeNull(context);
648 JSValueRef JSMessagingStorage::removeConversations(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
649 const JSValueRef arguments[], JSValueRef* exception)
653 JSMessagingListener* priv = static_cast<JSMessagingListener*>(JSObjectGetPrivate(thisObject));
656 LogError("Null pointer");
657 return JSTizenExceptionFactory::postException(context, exception,
658 JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
661 JSContextRef globalContext = priv->getContext();
663 if (argumentCount < 1) {
664 return JSTizenExceptionFactory::postException(context, exception,
665 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
668 WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(
671 ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
675 AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
677 MessagingExportedNames[MESSAGING_FUNCTION_API_REMOVE_CONVERSATIONS]);
678 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
680 Api::Messaging::EventDeleteConversationsPtr event(new Api::Messaging::EventDeleteConversations());
682 if (argumentCount > 1) {
683 callbackManager->setOnSuccess(converter->toFunctionOrNull(arguments[1]));
686 if (argumentCount > 2) {
687 callbackManager->setOnError(converter->toFunctionOrNull(arguments[2]));
691 std::vector<Api::Messaging::IConversationPtr> deleteConversationArray = converter->toVectorOfConversation(arguments[0]);
692 event->setConversations(deleteConversationArray);
693 event->setFilterUsing(false);
695 event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData >(callbackManager));
696 event->setForAsynchronousCall(priv);
698 Api::Messaging::ReqReceiverMessageSingleton::Instance().deleteConversations(event);
701 Catch(WrtDeviceApis::Commons::ConversionException) {
702 LogError(">>> TypeMismatchException");
703 return JSTizenExceptionFactory::postException(context, exception,
704 JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
705 }Catch(WrtDeviceApis::Commons::NullPointerException) {
706 LogError(">>> TypeMismatchException");
707 return JSTizenExceptionFactory::postException(context, exception,
708 JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
709 }Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
710 LogError(">>> InvalidValuesException");
711 if(argumentCount < 3)
713 return JSTizenExceptionFactory::postException(context, exception,
714 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
716 callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,
717 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
718 }Catch(WrtDeviceApis::Commons::PlatformException) {
719 LogError(">>> UnknownException");
720 return JSTizenExceptionFactory::postException(context, exception,
721 JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
723 return JSValueMakeNull(context);
726 JSValueRef JSMessagingStorage::findFolders(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
727 const JSValueRef arguments[], JSValueRef* exception)
732 JSMessagingListener* priv = static_cast<JSMessagingListener*>(JSObjectGetPrivate(thisObject));
735 LogError("Null pointer");
736 return JSTizenExceptionFactory::postException(context, exception,
737 JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
740 JSContextRef globalContext = priv->getContext();
742 if (argumentCount < 2) {
743 return JSTizenExceptionFactory::postException(context, exception,
744 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
747 WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(globalContext);
748 ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
750 // TODO : need to re-implement for supporting filter
753 AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
755 MessagingExportedNames[MESSAGING_FUNCTION_API_FIND_FOLDERS]);
756 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
758 Api::Messaging::EventQueryFoldersPtr event(new Api::Messaging::EventQueryFolders());
760 // setup message filter
761 FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
763 Api::Tizen::FilterPtr filter = filterConverter->toFilter(arguments[0]);
764 event->setFilter(filter);
766 callbackManager->setOnSuccess(converter->toFunction(arguments[1]));
768 if(argumentCount > 2)
770 callbackManager->setOnError(converter->toFunctionOrNull(arguments[2]));
773 event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData >(callbackManager));
774 event->setForAsynchronousCall(priv);
776 Api::Messaging::ReqReceiverMessageSingleton::Instance().queryFolders(event);
778 return JSValueMakeNull(context);
781 Catch(WrtDeviceApis::Commons::ConversionException) {
782 LogError(">>> TypeMismatchException");
783 return JSTizenExceptionFactory::postException(context, exception,
784 JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
785 }Catch(WrtDeviceApis::Commons::NullPointerException) {
786 LogError(">>> TypeMismatchException");
787 return JSTizenExceptionFactory::postException(context, exception,
788 JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
789 }Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
790 LogError(">>> InvalidValuesException");
791 if(argumentCount < 3)
793 return JSTizenExceptionFactory::postException(context, exception,
794 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
796 callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,
797 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
798 }Catch(WrtDeviceApis::Commons::PlatformException) {
799 LogError(">>> UnknownException");
800 return JSTizenExceptionFactory::postException(context, exception,
801 JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
804 return JSValueMakeNull(context);
807 JSValueRef JSMessagingStorage::addMessagesChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
808 const JSValueRef arguments[], JSValueRef* exception) {
811 LogDebug("arumentConunt:" << argumentCount);
813 JSMessagingListener* priv = static_cast<JSMessagingListener*>
814 (JSObjectGetPrivate(thisObject));
817 LogError("Null pointer");
818 return JSTizenExceptionFactory::postException(context, exception,
819 JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
822 if (argumentCount < 1 ||
823 JSValueIsUndefined(context, arguments[0]) ||
824 JSValueIsNull(context, arguments[0]))
826 LogError("bad argument");
827 return JSTizenExceptionFactory::postException(context, exception,
828 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
831 JSMessagingListener* listener =
832 static_cast<JSMessagingListener*>(JSObjectGetPrivate(thisObject));
834 LogError("no private object");
835 return JSValueMakeUndefined(context);
842 AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
844 MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_MESSAGES_CHANGE_LISTNER]);
846 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
848 ConverterMessageFactory::ConverterType converter =
849 ConverterMessageFactory::getConverter(context);
850 JSContextRef l_globalContext = converter->toJSGlobalContext(thisObject);
852 WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager =
853 WrtDeviceApis::CommonsJavaScript::JSCallbackManager::createObject(l_globalContext,
857 OnMessagesChanged result = converter->toMessageMultifunctions(arguments[0]);
858 int funtionIndex = result.functionIndex;
860 callbackManager->setOnSuccess(result.messagesAdded);
861 WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr messagesUpdatedCbm = JSCallbackManager::createObject(listener->getContext(), result.messagesUpdated, NULL);
862 WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr messagesRemovedCbm = JSCallbackManager::createObject(listener->getContext(), result.messagesRemoved, NULL);
865 EventOnMessagingStorageChangesPrivateDataPtr privData(
866 new EventOnMessagingStorageChangesPrivateData(callbackManager, messagesUpdatedCbm, messagesRemovedCbm, funtionIndex));
869 if ((argumentCount == 2) && !JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1]))
871 FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
872 privData->setFilter(filterConverter->toFilter(arguments[1]));
875 listener->registerMessageReceivedEmitter(privData);
877 // add to map and return index
878 return JSValueMakeNumber(context,
879 listener->addIncomingMsgCallback(callbackManager, funtionIndex));
882 Catch(WrtDeviceApis::Commons::ConversionException) {
883 LogError("Error on conversion");
884 return JSTizenExceptionFactory::postException(context, exception,
885 JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
887 Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
888 LogError("Invalid argument exception");
889 return JSTizenExceptionFactory::postException(context, exception,
890 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
892 Catch(WrtDeviceApis::Commons::UnsupportedException) {
893 LogError("Unsupported exception");
894 return JSTizenExceptionFactory::postException(context, exception,
895 JSTizenException::NOT_SUPPORTED_ERROR, JSMESSAGING_EXCEPTION_MSG_NOT_SUPPORTED); // unsupported type
897 Catch(WrtDeviceApis::Commons::AlreadyInUseException) {
898 LogError("Already in use exception");
900 Catch(WrtDeviceApis::Commons::PlatformException) {
901 LogError("not registered for incoming message notifications");
904 return JSValueMakeUndefined(context);
907 JSValueRef JSMessagingStorage::addConversationsChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
908 const JSValueRef arguments[], JSValueRef* exception) {
911 LogDebug("arumentConunt:" << argumentCount);
913 JSMessagingListener* priv = static_cast<JSMessagingListener*>
914 (JSObjectGetPrivate(thisObject));
917 LogError("Null pointer");
918 return JSTizenExceptionFactory::postException(context, exception,
919 JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
922 if (argumentCount < 1 ||
923 JSValueIsUndefined(context, arguments[0]) ||
924 JSValueIsNull(context, arguments[0]))
926 LogError("bad argument");
927 return JSTizenExceptionFactory::postException(context, exception,
928 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
931 JSMessagingListener* listener =
932 static_cast<JSMessagingListener*>(JSObjectGetPrivate(thisObject));
934 LogError("no private object");
935 return JSValueMakeUndefined(context);
942 AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
944 MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_CONVERSATIONS_CHANGE_LISTNER]);
946 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
948 ConverterMessageFactory::ConverterType converter =
949 ConverterMessageFactory::getConverter(context);
950 JSContextRef l_globalContext = converter->toJSGlobalContext(thisObject);
952 WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager =
953 WrtDeviceApis::CommonsJavaScript::JSCallbackManager::createObject(l_globalContext,
957 OnMessagesChanged result = converter->toMessageMultifunctions(arguments[0]);
958 int funtionIndex = result.functionIndex;
960 callbackManager->setOnSuccess(result.messagesAdded);
961 WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr messagesUpdatedCbm = JSCallbackManager::createObject(listener->getContext(), result.messagesUpdated, NULL);
962 WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr messagesRemovedCbm = JSCallbackManager::createObject(listener->getContext(), result.messagesRemoved, NULL);
965 EventOnMessagingStorageChangesPrivateDataPtr privData(
966 new EventOnMessagingStorageChangesPrivateData(callbackManager, messagesUpdatedCbm, messagesRemovedCbm, funtionIndex));
969 if ((argumentCount == 2) && !JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1]))
971 FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
972 privData->setFilter(filterConverter->toFilter(arguments[1]));
975 listener->registerMessageReceivedEmitter(privData);
977 // add to map and return index
978 return JSValueMakeNumber(context,
979 listener->addIncomingMsgCallback(callbackManager, funtionIndex));
982 Catch(WrtDeviceApis::Commons::ConversionException) {
983 LogError("Error on conversion");
984 return JSTizenExceptionFactory::postException(context, exception,
985 JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
987 Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
988 LogError("Invalid argument exception");
989 return JSTizenExceptionFactory::postException(context, exception,
990 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
992 Catch(WrtDeviceApis::Commons::UnsupportedException) {
993 LogError("Unsupported exception");
994 return JSTizenExceptionFactory::postException(context, exception,
995 JSTizenException::NOT_SUPPORTED_ERROR, JSMESSAGING_EXCEPTION_MSG_NOT_SUPPORTED); // unsupported type
997 Catch(WrtDeviceApis::Commons::AlreadyInUseException) {
998 LogError("Already in use exception");
1000 Catch(WrtDeviceApis::Commons::PlatformException) {
1001 LogError("not registered for incoming message notifications");
1004 return JSValueMakeUndefined(context);
1008 JSValueRef JSMessagingStorage::addFoldersChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
1009 const JSValueRef arguments[], JSValueRef* exception) {
1012 LogDebug("arumentConunt:" << argumentCount);
1014 JSMessagingListener* priv = static_cast<JSMessagingListener*>
1015 (JSObjectGetPrivate(thisObject));
1018 LogError("Null pointer");
1019 return JSTizenExceptionFactory::postException(context, exception,
1020 JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
1023 if (argumentCount < 1 ||
1024 JSValueIsUndefined(context, arguments[0]) ||
1025 JSValueIsNull(context, arguments[0]))
1027 LogError("bad argument");
1028 return JSTizenExceptionFactory::postException(context, exception,
1029 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
1032 JSMessagingListener* listener =
1033 static_cast<JSMessagingListener*>(JSObjectGetPrivate(thisObject));
1035 LogError("no private object");
1036 return JSValueMakeUndefined(context);
1043 AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
1045 MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_FOLDERS_CHANGE_LISTNER]);
1047 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1049 ConverterMessageFactory::ConverterType converter =
1050 ConverterMessageFactory::getConverter(context);
1051 JSContextRef l_globalContext = converter->toJSGlobalContext(thisObject);
1053 WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager =
1054 WrtDeviceApis::CommonsJavaScript::JSCallbackManager::createObject(l_globalContext,
1058 OnMessagesChanged result = converter->toMessageMultifunctions(arguments[0]);
1059 int funtionIndex = result.functionIndex;
1061 callbackManager->setOnSuccess(result.messagesAdded);
1062 WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr messagesUpdatedCbm = JSCallbackManager::createObject(listener->getContext(), result.messagesUpdated, NULL);
1063 WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr messagesRemovedCbm = JSCallbackManager::createObject(listener->getContext(), result.messagesRemoved, NULL);
1066 EventOnMessagingStorageChangesPrivateDataPtr privData(
1067 new EventOnMessagingStorageChangesPrivateData(callbackManager, messagesUpdatedCbm, messagesRemovedCbm, funtionIndex));
1070 if ((argumentCount == 2) && !JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1]))
1072 FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
1073 privData->setFilter(filterConverter->toFilter(arguments[1]));
1076 listener->registerMessageReceivedEmitter(privData);
1078 // add to map and return index
1079 return JSValueMakeNumber(context,
1080 listener->addIncomingMsgCallback(callbackManager, funtionIndex));
1083 Catch(WrtDeviceApis::Commons::ConversionException) {
1084 LogError("Error on conversion");
1085 return JSTizenExceptionFactory::postException(context, exception,
1086 JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
1088 Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
1089 LogError("Invalid argument exception");
1090 return JSTizenExceptionFactory::postException(context, exception,
1091 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
1093 Catch(WrtDeviceApis::Commons::UnsupportedException) {
1094 LogError("Unsupported exception");
1095 return JSTizenExceptionFactory::postException(context, exception,
1096 JSTizenException::NOT_SUPPORTED_ERROR, JSMESSAGING_EXCEPTION_MSG_NOT_SUPPORTED); // unsupported type
1098 Catch(WrtDeviceApis::Commons::AlreadyInUseException) {
1099 LogError("Already in use exception");
1101 Catch(WrtDeviceApis::Commons::PlatformException) {
1102 LogError("not registered for incoming message notifications");
1105 return JSValueMakeUndefined(context);
1108 JSValueRef JSMessagingStorage::removeChangeListener(JSContextRef context,
1109 JSObjectRef function,
1110 JSObjectRef thisObject,
1111 size_t argumentCount,
1112 const JSValueRef arguments[],
1113 JSValueRef* exception)
1117 JSMessagingListener* priv = static_cast<JSMessagingListener*>
1118 (JSObjectGetPrivate(thisObject));
1121 LogError("Null pointer");
1122 return JSTizenExceptionFactory::postException(context, exception,
1123 JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
1126 if (argumentCount < 1) {
1127 LogError("wrong argument count");
1128 return JSTizenExceptionFactory::postException(context, exception,
1129 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
1133 AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
1135 MessagingExportedNames[MESSAGING_FUNCTION_API_REMOVE_CHANGE_LISTENER]);
1137 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1140 JSMessagingListener* listener =
1141 static_cast<JSMessagingListener*>(JSObjectGetPrivate(thisObject));
1143 LogError("no private object");
1144 return JSValueMakeUndefined(context);
1147 WrtDeviceApis::CommonsJavaScript::Converter converter(context);
1149 double handler = converter.toDouble(arguments[0]);
1150 listener->removeIncomingMsgCallback(handler);
1152 Catch(WrtDeviceApis::Commons::ConversionException) {
1153 LogError("conversion error");
1154 return JSTizenExceptionFactory::postException(context, exception,
1155 JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
1158 return JSValueMakeUndefined(context);