Update change log and spec for wrt-plugins-tizen_0.4.59
[framework/web/wrt-plugins-tizen.git] / src / Contact / JSContactManager.cpp
index e33fce5..601d06d 100755 (executable)
@@ -47,6 +47,7 @@
 #include <TimeTracer.h>
 #include <Logger.h>
 #include <Export.h>
+#include "ContactUtility.h"
 
 namespace DeviceAPI {
 namespace Contact {
@@ -477,12 +478,6 @@ JSValueRef JSContactManager::get(JSContextRef context,
        AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_CONTACT_MANAGER_GET);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       if (argumentCount < 1) {
-               /* 1st Argument must be string. */
-               LoggerE("1st argument must not be undefined.");
-               return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_FOUND_ERROR, "No id 'undefined'");
-       }
-
        std::string id;
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
@@ -499,6 +494,9 @@ JSValueRef JSContactManager::get(JSContextRef context,
                return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
        }
 
+       if(!ContactUtility::checkStrIsUInt(id))
+               return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "");
+
        EventContactManagerGetPtr dplEvent(new EventContactManagerGet());
 
        dplEvent->setId(id);
@@ -767,6 +765,8 @@ JSValueRef JSContactManager::remove(JSContextRef context,
        } catch(const NullPointerException& err) {
                return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
        }
+       if(!ContactUtility::checkStrIsUInt(personId))
+               return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "");
 
        EventContactManagerRemovePtr dplEvent(new EventContactManagerRemove());
 
@@ -1187,9 +1187,12 @@ JSValueRef JSContactManager::removeChangeListener(JSContextRef context,
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
 
        long watchId = 0;
+       std::string id;
+
        try {
                ArgumentValidator validator(context, argumentCount, arguments);
                watchId = validator.toLong(0, false, 0);
+               id = validator.toString(0, false);
        } catch (const TypeMismatchException& err ) {
                return JSWebAPIErrorFactory::postException(context, exception, err);
        } catch(const BasePlatformException& err) {
@@ -1199,6 +1202,8 @@ JSValueRef JSContactManager::removeChangeListener(JSContextRef context,
        } catch(const NullPointerException& err) {
                return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
        }
+       if(!ContactUtility::checkStrIsUInt(id))
+               return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "");
 
        EventContactManagerRemoveChangeListenerPtr dplEvent(new EventContactManagerRemoveChangeListener());