#include "MessagingListener.h"
#include "ReqReceiverMessage.h"
-#include <JSTizenExceptionFactory.h>
-#include <JSTizenException.h>
+#include <JSWebAPIErrorFactory.h>
#include <SecurityExceptions.h>
#include <CommonsJavaScript/ScopedJSStringRef.h>
// ==== new common headers
#include <GlobalContextManager.h>
#include <PlatformException.h>
-#include <JSWebAPIError.h>
-#include <JSWebAPIException.h>
#include <JSUtil.h>
+#include <Export.h>
#include <ArgumentValidator.h>
// ====
{ 0, 0, 0, 0 }
};
+JSClassRef JSMessage::jsInit(JSContextRef context)
+{
+ LoggerI("enter");
+ return JSClassCreate(&m_classInfo);
+}
+
+const JSClassDefinition* JSMessage::getClassInfo()
+{
+ LoggerI("enter");
+ return &(m_classInfo);
+}
+
+JSClassRef DLL_EXPORT JSMessage::getClassRef()
+{
+ LoggerI("enter");
+ if (!m_jsClassRef) {
+ m_jsClassRef = JSClassCreate(&m_classInfo);
+ }
+ return m_jsClassRef;
+}
JSValueRef JSMessage::createJSObject(JSContextRef context,
EmailAccountInfo& account,
const IMessagePtr& msg,
EventUpdateMessageAnswerReceiver* listener)
{
- JSClassRef jsClassRef = JSClassCreate(getClassInfo());
JSMessagePrivateObject* priv = new JSMessagePrivateObject(context, msg);
priv->setUpdateMsgReceiver(listener);
- JSObjectRef jsValueRef = JSObjectMake(context, jsClassRef, static_cast<void*>(priv));
- JSClassRelease(jsClassRef);
+ JSObjectRef jsValueRef = JSObjectMake(context, JSMessage::getClassRef(), static_cast<void*>(priv));
if (NULL == jsValueRef) {
LoggerE("object creation error");
return JSValueMakeUndefined(context);
const IMessagePtr& msg)
{
LoggerD("createJSObject");
- JSClassRef jsClassRef = JSClassCreate(getClassInfo());
- LoggerD("jsClassRef success");
JSMessagePrivateObject* priv = new JSMessagePrivateObject(context, msg);
LoggerD("priv success");
- JSObjectRef jsValueRef = JSObjectMake(context, jsClassRef, static_cast<void*>(priv));
+ JSObjectRef jsValueRef = JSObjectMake(context, JSMessage::getClassRef(), static_cast<void*>(priv));
LoggerD("JSObjectMake success");
- JSClassRelease(jsClassRef);
if (NULL == jsValueRef) {
LoggerE("object creation error");
return JSValueMakeUndefined(context);
return true;
}
-JSObjectRef JSMessage::constructor(JSContextRef context,
+JSObjectRef DLL_EXPORT JSMessage::constructor(JSContextRef context,
JSObjectRef constructor,
size_t argumentCount,
const JSValueRef arguments[],
}
catch(BasePlatformException &bex) {
LoggerE("Message creation failed: " << bex.getMessage());
- JSObjectRef error = JSWebAPIException::makeJSWebAPIException(context, bex);
- *exception = error;
- return error;
+ return JSWebAPIErrorFactory::postException(context, exception, bex);
}
catch(...) {
DeviceAPI::Common::UnknownException err("UnknownError in Message constructor.");
- JSObjectRef error = JSWebAPIException::makeJSWebAPIException(context, err);
- *exception = error;
- return error;
+ return JSWebAPIErrorFactory::postException(context, exception, err);
}
- return NULL;
+
+ return JSWebAPIErrorFactory::postException(context, exception,
+ DeviceAPI::Common::UnknownException("UnknownError in Message constructor."));
}
JSValueRef JSMessage::convertToType(JSContextRef context,
static_cast<JSMessagePrivateObject*>(JSObjectGetPrivate(object));
if (!priv) {
- return JSTizenExceptionFactory::postException(context, exception,
- JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+ return JSWebAPIErrorFactory::postException(context, exception,
+ JSWebAPIErrorFactory::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
}
}
Catch(WrtDeviceApis::Commons::NullPointerException) {
LoggerE("Error on pointer, null value");
- return JSTizenExceptionFactory::postException(context, exception,
- JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+ return JSWebAPIErrorFactory::postException(context, exception,
+ JSWebAPIErrorFactory::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
}
vector<string> attachments;
}
Catch(WrtDeviceApis::Commons::ConversionException) {
LoggerE("Error on conversion");
- return JSTizenExceptionFactory::postException(context, exception,
- JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+ return JSWebAPIErrorFactory::postException(context, exception,
+ JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
}
Catch(WrtDeviceApis::Commons::NullPointerException) {
LoggerE("Error on pointer, null value");
- return JSTizenExceptionFactory::postException(context, exception,
- JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+ return JSWebAPIErrorFactory::postException(context, exception,
+ JSWebAPIErrorFactory::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
}
Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
LoggerE("Invalid argument");
- return JSTizenExceptionFactory::postException(context, exception,
- JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+ return JSWebAPIErrorFactory::postException(context, exception,
+ JSWebAPIErrorFactory::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
}
return false;
}