- while(m_property[index].name != NULL) {
- // if property name matches
- if(JSStringIsEqualToUTF8CString(propertyName,m_property[index].name)) {
- if(m_property[index].setProperty != NULL) {
- // if setProperty() function exists - call it
- return m_property[index].setProperty(context, object, propertyName, value, exception);
- } else {
- // otherwise return true (lack of function - readonly attribute)
- return true;
+ try{
+ while(m_property[index].name != NULL) {
+ // if property name matches
+ if(JSStringIsEqualToUTF8CString(propertyName,m_property[index].name)) {
+ if(m_property[index].setProperty != NULL) {
+ if (JSStringIsEqualToUTF8CString(propertyName, MESSAGE_ATTRIBUTE_TO)){
+ if (JSValueIsNull(context, value))
+ {
+ throw TypeMismatchException("Value is null");
+ }
+ JSUtil::JSArrayToStringVector(context, value);
+ }
+ if (JSStringIsEqualToUTF8CString(propertyName, MESSAGE_ATTRIBUTE_CC)){
+ if (JSValueIsNull(context, value))
+ {
+ throw TypeMismatchException("Value is null");
+ }
+ JSUtil::JSArrayToStringVector(context, value);
+ }
+ if (JSStringIsEqualToUTF8CString(propertyName, MESSAGE_ATTRIBUTE_BCC)){
+ if (JSValueIsNull(context, value))
+ {
+ throw TypeMismatchException("Value is null");
+ }
+ JSUtil::JSArrayToStringVector(context, value);
+ }
+ if (JSStringIsEqualToUTF8CString(propertyName, MESSAGE_ATTRIBUTE_BODY)){
+ if (!JSValueIsNull(context, value)) {
+ if (!JSValueIsObject(context, value)) {
+ throw TypeMismatchException("Value is not Object");
+ }
+ JSUtil::JSValueToObject(context, value);
+ }
+ }
+ if (JSStringIsEqualToUTF8CString(propertyName, MESSAGE_ATTRIBUTE_IS_READ)){
+ JSUtil::JSValueToBoolean(context, value);
+ }
+ if (JSStringIsEqualToUTF8CString(propertyName, MESSAGE_ATTRIBUTE_IS_HIGH_PRIORITY)){
+ JSUtil::JSValueToBoolean(context, value);
+ }
+ if (JSStringIsEqualToUTF8CString(propertyName, MESSAGE_ATTRIBUTE_SUBJECT)){
+ JSUtil::JSValueToString(context, value);
+ }
+ if (JSStringIsEqualToUTF8CString(propertyName, MESSAGE_ATTRIBUTE_ATTACHMENTS)){
+ if (!JSValueIsNull(context, value)) {
+ if (!JSValueIsObject(context, value)) {
+ throw TypeMismatchException("Value is not Object");
+ }
+ JSUtil::JSValueToObject(context, value);
+ }
+ }
+ // if setProperty() function exists - call it
+ return m_property[index].setProperty(context, object, propertyName, value, exception);
+ } else {
+ // otherwise return true (lack of function - readonly attribute)
+ return true;
+ }