Update change log and spec for wrt-plugins-tizen_0.4.29
[framework/web/wrt-plugins-tizen.git] / src / SecureElement / JSSESession.cpp
index 29cae58..409dca4 100644 (file)
 #include <CommonsJavaScript/JSUtils.h>
 #include <CommonsJavaScript/JSCallbackManager.h>
 #include <CommonsJavaScript/Utils.h>
-#include <JSTizenExceptionFactory.h>
-#include <JSTizenException.h>
+#include <JSWebAPIErrorFactory.h>
 #include <SecurityExceptions.h>
 #include <ArgumentValidator.h>
-#include <JSWebAPIException.h>
 #include "SEFactory.h"
 #include "SEResponseDispatcher.h"
 #include "JSSESession.h"
@@ -178,7 +176,7 @@ JSValueRef JSSESession::getATR(JSContextRef context,
                SESessionPrivObject* privateObject = static_cast<SESessionPrivObject*>(JSObjectGetPrivate(thisObject));
                if (NULL == privateObject) {
                        LoggerE("private object is null");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+                       return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
                }
 
                ISESessionPtr seSession(privateObject->getObject());
@@ -187,7 +185,7 @@ JSValueRef JSSESession::getATR(JSContextRef context,
        } Catch (WrtDeviceApis::Commons::Exception) {
                LoggerE("Exception: " << _rethrown_exception.GetMessage());
        }
-       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
 }
 
 JSValueRef JSSESession::close(JSContextRef context,
@@ -204,7 +202,7 @@ JSValueRef JSSESession::close(JSContextRef context,
                SESessionPrivObject* privateObject = static_cast<SESessionPrivObject*>(JSObjectGetPrivate(thisObject));
                if (NULL == privateObject) {
                        LoggerE("private object is null");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+                       return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
                }
 
                ISESessionPtr seSession(privateObject->getObject());
@@ -213,7 +211,7 @@ JSValueRef JSSESession::close(JSContextRef context,
        } Catch (WrtDeviceApis::Commons::Exception) {
                LoggerE("Exception: " << _rethrown_exception.GetMessage());
        }
-       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
 }
 
 JSValueRef JSSESession::closeChannels(JSContextRef context,
@@ -230,7 +228,7 @@ JSValueRef JSSESession::closeChannels(JSContextRef context,
                SESessionPrivObject* privateObject = static_cast<SESessionPrivObject*>(JSObjectGetPrivate(thisObject));
                if (NULL == privateObject) {
                        LoggerE("private object is null");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+                       return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
                }
 
                ISESessionPtr seSession(privateObject->getObject());
@@ -239,7 +237,7 @@ JSValueRef JSSESession::closeChannels(JSContextRef context,
        } Catch (WrtDeviceApis::Commons::Exception) {
                LoggerE("Exception: " << _rethrown_exception.GetMessage());
        }
-       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
 }
 
 JSValueRef JSSESession::openBasicChannel(JSContextRef context,
@@ -257,7 +255,7 @@ JSValueRef JSSESession::openBasicChannel(JSContextRef context,
        if ((argumentCount < 2) || JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !JSIsArrayValue(context, arguments[0])) {
                /* 1st argument is mandatory. And 1st argument must be Array. */
                LoggerE("AID TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
 
        JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
@@ -275,13 +273,13 @@ JSValueRef JSSESession::openBasicChannel(JSContextRef context,
                }
        } catch (const BasePlatformException &err) {
         LoggerE(err.getName() << ": " << err.getMessage());
-        return JSWebAPIException::throwException(context, exception, err);
+        return JSWebAPIErrorFactory::postException(context, exception, err);
     }
 
        SESessionPrivObject* privateObject = static_cast<SESessionPrivObject*>(JSObjectGetPrivate(thisObject));
        if (NULL == privateObject) {
                LoggerE("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
 
        ISESessionPtr seSession(privateObject->getObject());
@@ -291,7 +289,7 @@ JSValueRef JSSESession::openBasicChannel(JSContextRef context,
                std::vector<unsigned char> aid = convert.toVectorOfUChars(arguments[0]);
                if ((aid.size() < 5) || (aid.size() > 16)) {
                        LoggerE("wrong aid length : " << aid.size());
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Wrong AID length");
+                       return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Wrong AID length");
                }
                EventSEOpenChannelPtr event(new EventSEOpenChannel(aid, true));
                event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
@@ -304,14 +302,14 @@ JSValueRef JSSESession::openBasicChannel(JSContextRef context,
                return JSValueMakeUndefined(context);
        } Catch (ConversionException) {
                LoggerE("ConversionException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (WrtDeviceApis::Commons::UnknownException) {
                LoggerE("UnknownException: " << _rethrown_exception.GetMessage());
        } Catch (WrtDeviceApis::Commons::Exception) {
                LoggerE("Exception: " << _rethrown_exception.GetMessage());
        }
 
-       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
+       callbackManager->callOnError(JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR,"Unknown Error"));
        return JSValueMakeUndefined(context);
 }
 
@@ -330,7 +328,7 @@ JSValueRef JSSESession::openLogicalChannel(JSContextRef context,
        if ((argumentCount < 2) || JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !JSIsArrayValue(context, arguments[0])) {
                /* 1st argument is mandatory. And 1st argument must be Array. */
                LoggerE("AID TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
 
        JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
@@ -348,13 +346,13 @@ JSValueRef JSSESession::openLogicalChannel(JSContextRef context,
                }
        } catch (const BasePlatformException &err) {
         LoggerE(err.getName() << ": " << err.getMessage());
-        return JSWebAPIException::throwException(context, exception, err);
+        return JSWebAPIErrorFactory::postException(context, exception, err);
     }
 
        SESessionPrivObject* privateObject = static_cast<SESessionPrivObject*>(JSObjectGetPrivate(thisObject));
        if (NULL == privateObject) {
                LoggerE("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
 
        ISESessionPtr seSession(privateObject->getObject());
@@ -364,7 +362,7 @@ JSValueRef JSSESession::openLogicalChannel(JSContextRef context,
                std::vector<unsigned char> aid = convert.toVectorOfUChars(arguments[0]);
                if ((aid.size() < 5) || (aid.size() > 16)) {
                        LoggerE("wrong aid length : " << aid.size());
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Wrong AID length");
+                       return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Wrong AID length");
                }
                EventSEOpenChannelPtr event(new EventSEOpenChannel(aid, false));
                event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
@@ -377,14 +375,14 @@ JSValueRef JSSESession::openLogicalChannel(JSContextRef context,
                return JSValueMakeUndefined(context);
        } Catch (ConversionException) {
                LoggerE("ConversionException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (WrtDeviceApis::Commons::UnknownException) {
                LoggerE("UnknownException: " << _rethrown_exception.GetMessage());
        } Catch (WrtDeviceApis::Commons::Exception) {
                LoggerE("Exception: " << _rethrown_exception.GetMessage());
        }
 
-       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
+       callbackManager->callOnError(JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR,"Unknown Error"));
        return JSValueMakeUndefined(context);
 }