Name: wrt-plugins-tizen
Summary: JavaScript plugins for WebRuntime
-Version: 0.4.57
+Version: 0.4.58
Release: 0
Group: Development/Libraries
License: Apache License, Version 2.0
#include "ApplicationController.h"
#include "ApplicationConverter.h"
#include "plugin_config.h"
-#include "JSApplicationManager.h"
#include "JSApplication.h"
#include <TimeTracer.h>
#include <Export.h>
#include <Logger.h>
+#include <plugins-ipc-message/ipc_message_support.h>
+
namespace DeviceAPI {
namespace Application {
TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
try {
- JSApplicationManager::setTitleProperty(context, "tizen://exit");
+ IPCMessageSupport::sendAsyncMessageToUiProcess(IPCMessageSupport::TIZEN_EXIT, NULL, NULL, NULL);
TIME_TRACER_ITEM_END(__FUNCTION__, 0);
return JSValueMakeUndefined(context);
TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
try {
- JSApplicationManager::setTitleProperty(context, "tizen://hide");
+ IPCMessageSupport::sendAsyncMessageToUiProcess(IPCMessageSupport::TIZEN_HIDE, NULL, NULL, NULL);
TIME_TRACER_ITEM_END(__FUNCTION__, 0);
return JSValueMakeUndefined(context);
#include <Export.h>
#include <Logger.h>
+#include <plugins-ipc-message/ipc_message_support.h>
+
namespace DeviceAPI {
namespace Application {
std::string userAgent = validator.toString(0);
// perform
- std::string propertyValue = "tizen://changeUA?ua=" + userAgent;
- setTitleProperty(context, propertyValue);
+ IPCMessageSupport::sendAsyncMessageToUiProcess(IPCMessageSupport::TIZEN_CHANGE_USERAGENT, userAgent.c_str(), NULL, NULL);
+
TIME_TRACER_ITEM_END(__FUNCTION__, 0);
return JSValueMakeUndefined(context);
}
}
+
+/* scheme-callback using title is not working on iframe. So, use IPC API instead of below API.
void JSApplicationManager::setTitleProperty(JSContextRef context, std::string propertyValue){
WrtDeviceApis::CommonsJavaScript::Converter converter(context);
kJSPropertyAttributeNone,
NULL);
}
+*/
}
}
static const JSClassRef getClassRef();
- static void setTitleProperty(JSContextRef context, std::string propertyValue);
+ //static void setTitleProperty(JSContextRef context, std::string propertyValue);
private:
/**
result->setSubject(toString(summaryData));
}
- //It's important to set startTime before duration to set end date
if (!JSValueIsUndefined(m_context, startTimeData) && !JSValueIsNull(m_context, startTimeData)) {
result->setStartTime((long long int) (timeUtilConverter.getTimeInMilliseconds(startTimeData)/1000));
result->setTimeZone(timeUtilConverter.getPropertiesInTZDate(startTimeData).timezone);
} else if(valueString=="CONFIRMED") {
return CALENDAR_EVENT_STATUS_CONFIRMED;
} else if(valueString=="CANCELLED") {
- return CALENDAR_EVENT_STATUS_CANCELLED;
+ if(CalendarEvent::TASK_TYPE==m_type) {
+ return CALENDAR_TODO_STATUS_CANCELED;
+ } else {
+ return CALENDAR_EVENT_STATUS_CANCELLED;
+ }
} else if(valueString=="NEEDS_ACTION") {
return CALENDAR_TODO_STATUS_NEEDS_ACTION;
} else if(valueString=="IN_PROCESS") {
setDescriptionToPlatformEvent();
setSummaryToPlatformEvent();
setStartTimeToPlatformEvent();
- setEndTimeToPlatformEvent(); // replacement for duration
+ setEndTimeToPlatformEvent();
setLocationToPlatformEvent();
setCategoriesToPlatformEvent();
setStatusToPlatformEvent();
setDescriptionFromPlatformEvent();
setSummaryFromPlatformEvent();
setStartTimeFromPlatformEvent();
- setEndTimeFromPlatformEvent(); // replace for duration
+ setEndTimeFromPlatformEvent();
setLocationFromPlatformEvent();
setCategoriesFromPlatformEvent();
setStatusFromPlatformEvent();
if (argumentCount>=3) {
if (JSValueIsObject(context, arguments[2])) {
dplEvent->setGenericFilter(filterConverter->toFilter(arguments[2]));
- } else if (JSValueIsNull(context, arguments[2]) || JSValueIsUndefined(context, arguments[2])) {
+ } else if (JSValueIsNull(context, arguments[2])) {
LoggerD("Use default filter.");
} else {
ThrowMsg(ConversionException, "Wrong third parameter type.");
DeviceAPI::Tizen::SortModeArrayPtr sortModes(new DeviceAPI::Tizen::SortModeArray());
sortModes->push_back(filterConverter->toSortMode(arguments[3]));
dplEvent->setSortModes(sortModes);
- } else if (JSValueIsNull(context, arguments[3]) || JSValueIsUndefined(context, arguments[3])) {
+ } else if (JSValueIsNull(context, arguments[3])) {
LoggerD("Use default sort mode.");
} else {
ThrowMsg(ConversionException, "Wrong fourth parameter type.");
}
if (JSValueIsNull(context, value)) {
- EventRecurrenceRulePtr rrule(NULL);
- event->setRecurrenceRule(rrule);
- } else if (JSValueIsUndefined(context, value)) {
EventRecurrenceRulePtr rrule( new EventRecurrenceRule() );
event->setRecurrenceRule(rrule);
+ } else if (!JSValueIsObjectOfClass(context, value, JSCalendarRecurrenceRule::getClassRef())) {
+ ThrowMsg(ConversionException, "Wrong parameter type.");
} else {
event->setRecurrenceRule(JSCalendarRecurrenceRule::getPrivateObject(JSValueToObject(context, value, NULL)));
}
{
Try
{
- if (!JSValueIsObjectOfClass(context, value, JSTZDate::getClassRef())) {
- ThrowMsg(ConversionException, "Wrong parameter type.");
- }
-
CalendarEventPtr item = getPrivateObject(object);
+
+ if (JSValueIsNull(context, value)) {
+ item->setStartTime(UNDEFINED_TIME);
+ return true;
+ } else if (!JSValueIsObjectOfClass(context, value, JSTZDate::getClassRef())) {
+ ThrowMsg(ConversionException, "Wrong parameter type.");
+ }
+
TimeUtilConverter timeConverter(context);
long long int startTime = (long long int) (timeConverter.getTimeInMilliseconds(value)/1000);
{
CalendarEventPtr item = getPrivateObject(object);
- if (JSValueIsNull(context, value) || JSValueIsUndefined(context, value)) {
+ if (JSValueIsNull(context, value)) {
item->getGeolocation()->setLatitude(UNDEFINED_GEO);
item->getGeolocation()->setLongitude(UNDEFINED_GEO);
} else {
LoggerD("Duration length: "<<item->getDuration()->length<<", unit: "<<item->getDuration()->unit);
return JSTimeDuration::createJSObject(context, item->getDuration());
}
-
- // Alternatively generate the duration object using start/end time.
- if(UNDEFINED_TIME==item->getStartTime() || UNDEFINED_TIME==item->getEndTime()) {
- LoggerD("Start or end time is not defined.");
- return JSValueMakeUndefined(context);
- }
-
- long long length = item->getEndTime() - item->getStartTime(); // in seconds only
- LoggerD("item->getStartTime():"<< item->getStartTime() << ", length:" << length);
-
- DurationPropertiesPtr durationPtr(new DurationProperties());
- durationPtr->length = length;
- durationPtr->unit = SECONDS_UNIT;
- item->setDuration(durationPtr);
-
- return JSTimeDuration::createJSObject(context, durationPtr);
}
Catch(Exception)
{
Try
{
CalendarEventPtr item = getPrivateObject(object);
+
+ if (JSValueIsNull(context, value)) {
+ DurationPropertiesPtr duration(new DeviceAPI::Time::DurationProperties());
+ item->setDuration(duration);
+ item->setEndTime(UNDEFINED_TIME);
+ return true;
+ }
+
TimeUtilConverter timeUtilConverter(context);
DurationPropertiesPtr duration = timeUtilConverter.getDuration(value);
LoggerD("length: "<<length<< ", unit:" <<unit);
item->setDuration(duration);
- // Adjust the endDate because the endDate has priority over duration when saving the item.
- long long int endDate;
- if( DeviceAPI::Time::SECONDS_UNIT==unit ) {
- endDate = item->getStartTime() + length;
- } else if ( DeviceAPI::Time::MINUTES_UNIT==unit ) {
- endDate = item->getStartTime() + length*60;
- } else if ( DeviceAPI::Time::HOURS_UNIT==unit ) {
- endDate = item->getStartTime() + length*60*60;
- } else if ( DeviceAPI::Time::DAYS_UNIT==unit ) {
- endDate = item->getStartTime() + length*24*60*60;
- } else if ( DeviceAPI::Time::MSECS_UNIT==unit ) {
- endDate = item->getStartTime() + length/1000;
- } else {
- LoggerW("Wrong duration unit: "<<unit);
- return true;
- }
- item->setEndTime(endDate);
- LoggerD("Set the endDate from the duration: "<<endDate);
+ item->setEndTime(UNDEFINED_TIME);
return true;
}
if(CalendarEvent::TASK_TYPE != task->getCalendarType()) {
ThrowMsg(InvalidArgumentException, "Wrong type of calendar.");
}
- if (!JSValueIsObjectOfClass(context, value, JSTZDate::getClassRef())) {
+
+ if (JSValueIsNull(context, value)) {
+ task->setEndTime(UNDEFINED_TIME);
+ return true;
+ } else if (!JSValueIsObjectOfClass(context, value, JSTZDate::getClassRef())) {
ThrowMsg(ConversionException, "Wrong parameter type.");
}
task->setEndTime(dueDate);
+ DurationPropertiesPtr duration(new DeviceAPI::Time::DurationProperties());
+ task->setDuration(duration);
+
if( task->getTimeZone().empty() ) {
std::string timeZone = converter.getPropertiesInTZDate(value).timezone;
task->setTimeZone(timeZone);
if(CalendarEvent::EVENT_TYPE != event->getCalendarType()) {
ThrowMsg(InvalidArgumentException, "Wrong calendar type.");
}
- if (!JSValueIsObjectOfClass(context, value, JSTZDate::getClassRef())) {
+
+ if (JSValueIsNull(context, value)) {
+ event->setEndTime(UNDEFINED_TIME);
+ return true;
+ } else if (!JSValueIsObjectOfClass(context, value, JSTZDate::getClassRef())) {
ThrowMsg(ConversionException, "Wrong parameter type.");
}
event->setEndTime(endDate);
+ DurationPropertiesPtr duration(new DeviceAPI::Time::DurationProperties());
+ event->setDuration(duration);
+
if( event->getTimeZone().empty() ) {
std::string timeZone = converter.getPropertiesInTZDate(value).timezone;
event->setTimeZone(timeZone);
ThrowMsg(NullPointerException, "Task object is NULL.");
}
- if (!JSValueIsObjectOfClass(context, value, JSTZDate::getClassRef())) {
+ if (JSValueIsNull(context, value)) {
+ task->setCompletedDate(UNDEFINED_TIME);
+ return true;
+ } else if (!JSValueIsObjectOfClass(context, value, JSTZDate::getClassRef())) {
ThrowMsg(ConversionException, "Wrong parameter type.");
}
dplEvent->setContacts(converter->toContactArray(arguments[0]));
} Catch(ConversionException) {
LoggerE("Error on conversion : " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "3rd argument must be an array of 'Contact object'");
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "First argument must be an array of 'Contact object'");
}
// set event handler's data
else
{
LoggerE("Argument type mismatch : 1nd argument must be ContactInit object or string");
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "2nd argument must be 'ContactTextFormat'");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "2nd argument must be 'ContactTextFormat'");
return NULL;
}
}
} Catch(ConversionException) {
LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "1st argument must be 'ContactInit object'");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "1st argument must be 'ContactInit object'");
return NULL;
} Catch(Exception) {
LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
return NULL;
}
}
} Catch(ConversionException) {
LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "2nd argument must be 'ContactTextFormat'");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "2nd argument must be 'ContactTextFormat'");
return NULL;
} Catch(InvalidArgumentException) {
LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "1st argument must be vCard string");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "1st argument must be vCard string");
return NULL;
} Catch(UnsupportedException) {
LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::NOT_SUPPORTED_ERROR, "Only support vCard 3.0");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::NOT_SUPPORTED_ERROR, "Only support vCard 3.0");
return NULL;
} Catch(Exception) {
LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
return NULL;
}
}
contact = ContactFactory::getInstance().createContact();
} Catch(Exception) {
LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
return NULL;
}
}
jsobject = createJSObject(gContext, contact);
} Catch(Exception) {
LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
return NULL;
}
ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- contact->unsetName();
+ return true;//contact->unsetName();
else
contact->setName(converter->toContactName(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- contact->unsetPhotoURI();
+ return true;//contact->unsetPhotoURI();
else
contact->setPhotoURI(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- contact->unsetBirthday();
+ return true;//contact->unsetBirthday();
else
contact->setBirthday(converter->toDateTm(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- contact->unsetRingtoneURI();
+ return true;//contact->unsetRingtoneURI();
else
contact->setRingtoneURI(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
} Catch(Exception ) {
LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "1st argument must be a 'ContactAddressInit object'");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "1st argument must be a 'ContactAddressInit object'");
return NULL;
}
} Catch(Exception) {
LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "1st argument must be a 'ContactAddressInit object'");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "1st argument must be a 'ContactAddressInit object'");
return NULL;
}
jsobject = createJSObject(gContext, contactAddress);
} Catch(Exception) {
LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
return NULL;
}
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- contactAddress->unsetCountry();
+ return true;//contactAddress->unsetCountry();
else
contactAddress->setCountry(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- contactAddress->unsetRegion();
+ return true;//contactAddress->unsetRegion();
else
contactAddress->setRegion(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- contactAddress->unsetCity();
+ return true;//contactAddress->unsetCity();
else
contactAddress->setCity(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- contactAddress->unsetStreetAddress();
+ return true;//contactAddress->unsetStreetAddress();
else
contactAddress->setStreetAddress(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- contactAddress->unsetAdditionalInformation();
+ return true;//contactAddress->unsetAdditionalInformation();
else
contactAddress->setAdditionalInformation(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- contactAddress->unsetPostalCode();
+ return true;//contactAddress->unsetPostalCode();
else
contactAddress->setPostalCode(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- contactAddress->setLabel(converter->toString(value));
+ if(validator->isNullOrUndefined(value))
+ return true;//contactAddress->unsetLabel();
+ else
+ contactAddress->setLabel(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
contactAnniversary->setLabel(label);
}
} catch (const TypeMismatchException& err ) {
- JSWebAPIErrorFactory::postException(context, exception, err);
+// JSWebAPIErrorFactory::postException(context, exception, err);
return NULL;
} catch(const BasePlatformException& err) {
- JSWebAPIErrorFactory::postException(context, exception, err);
+// JSWebAPIErrorFactory::postException(context, exception, err);
return NULL;
} catch(const ConversionException& err) {
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
return NULL;
} catch(const NullPointerException& err) {
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
return NULL;
}
contactAnniversary->setDate(date);
} Catch(Exception) {
LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "1st argument must be a 'Date object'");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "1st argument must be a 'Date object'");
return NULL;
}
jsobject = createJSObject(gContext, contactAnniversary);
} Catch(Exception) {
LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong arguments");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong arguments");
return NULL;
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- anniversary->unsetLabel();
+ return true;//anniversary->unsetLabel();
else
anniversary->setLabel(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
label = Argvalidator.toString(3, false);
} catch (const TypeMismatchException& err ) {
- JSWebAPIErrorFactory::postException(context, exception, err);
+// JSWebAPIErrorFactory::postException(context, exception, err);
return NULL;
} catch(const BasePlatformException& err) {
- JSWebAPIErrorFactory::postException(context, exception, err);
+// JSWebAPIErrorFactory::postException(context, exception, err);
return NULL;
} catch(const ConversionException& err) {
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
return NULL;
} catch(const NullPointerException& err) {
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
return NULL;
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
contactGroup->setPhotoURI(Argvalidator.toString(2, true));
} catch (const TypeMismatchException& err ) {
- JSWebAPIErrorFactory::postException(context, exception, err);
+// JSWebAPIErrorFactory::postException(context, exception, err);
return NULL;
} catch(const BasePlatformException& err) {
- JSWebAPIErrorFactory::postException(context, exception, err);
+// JSWebAPIErrorFactory::postException(context, exception, err);
return NULL;
} catch(const ConversionException& err) {
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
return NULL;
} catch(const NullPointerException& err) {
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
return NULL;
}
jsobject = createJSObject(gContext, contactGroup);
} Catch(Exception) {
LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
return NULL;
}
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- contactGroup->unsetId();
+ return true;//contactGroup->unsetId();
else
contactGroup->setId(converter->toString(value));
return true;
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- contactGroup->unsetAddressBookId();
+ return true;//contactGroup->unsetAddressBookId();
else
contactGroup->setAddressBookId(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- contactGroup->unsetName();
+ return true;//contactGroup->unsetName();
else
contactGroup->setName(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- contactGroup->unsetRingtoneURI();
+ return true;//contactGroup->unsetRingtoneURI();
else
contactGroup->setRingtoneURI(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- contactGroup->unsetRingtoneURI();
+ return true;//contactGroup->unsetRingtoneURI();
else
contactGroup->setPhotoURI(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
} Catch(Exception ) {
LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "1st argument must be 'object'");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "1st argument must be 'object'");
return NULL;
}
} Catch(Exception) {
LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
return NULL;
}
jsobject = createJSObject(gContext, contactName);
} Catch(Exception) {
LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
return NULL;
}
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- contactName->unsetPrefix();
+ return true;//contactName->unsetPrefix();
else
contactName->setPrefix(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
ContactConverterFactory::getConverter(context);
BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- contactName->unsetSuffix();
+ return true;//contactName->unsetSuffix();
else
contactName->setSuffix(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- contactName->unsetFirstName();
+ return true;//contactName->unsetFirstName();
else
contactName->setFirstName(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- contactName->unsetMiddleName();
+ return true;//contactName->unsetMiddleName();
else
contactName->setMiddleName(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- contactName->unsetLastName();
+ return true;//contactName->unsetLastName();
else
contactName->setLastName(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- contactName->unsetPhoneticFirstName();
+ return true;//contactName->unsetPhoneticFirstName();
else
contactName->setPhoneticFirstName(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- contactName->unsetPhoneticMiddleName();
+ return true;//contactName->unsetPhoneticMiddleName();
else
contactName->setPhoneticMiddleName(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- contactName->unsetPhoneticLastName();
+ return true;//contactName->unsetPhoneticLastName();
else
contactName->setPhoneticLastName(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
} Catch(Exception ) {
LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "1st argument must be a 'object'");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "1st argument must be a 'object'");
return NULL;
}
} Catch(Exception) {
LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
return NULL;
}
jsobject = createJSObject(gContext, contactOrganization);
} Catch(Exception) {
LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
return NULL;
}
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- organization->unsetName();
+ return true;//organization->unsetName();
else
organization->setName(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- organization->unsetDepartment();
+ return true;//organization->unsetDepartment();
else
organization->setDepartment(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- organization->unsetTitle();
+ return true;//organization->unsetTitle();
else
organization->setTitle(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- organization->unsetRole();
+ return true;//organization->unsetRole();
else
organization->setRole(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- organization->unsetLogoURI();
+ return true;//organization->unsetLogoURI();
else
organization->setLogoURI(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- organization->unsetAssistant();
+ return true;//organization->unsetAssistant();
else
organization->setAssistant(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- organization->unsetLocation();
+ return true;//organization->unsetLocation();
else
organization->setLocation(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- organization->unsetDescription();
+ return true;//organization->unsetDescription();
else
organization->setDescription(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- organization->unsetPhoneticName();
+ return true;//organization->unsetPhoneticName();
else
organization->setPhoneticName(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- organization->unsetType();
+ return true;//organization->unsetType();
else
organization->setType(converter->toContactOrganizationType(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- organization->unsetLabel();
+ return true;//organization->unsetLabel();
else
organization->setLabel(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
label = Argvalidator.toString(3, false);
} catch (const TypeMismatchException& err ) {
- JSWebAPIErrorFactory::postException(context, exception, err);
+// JSWebAPIErrorFactory::postException(context, exception, err);
return NULL;
} catch(const BasePlatformException& err) {
- JSWebAPIErrorFactory::postException(context, exception, err);
+// JSWebAPIErrorFactory::postException(context, exception, err);
return NULL;
} catch(const ConversionException& err) {
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
return NULL;
} catch(const NullPointerException& err) {
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
return NULL;
}
jsobject = createJSObject(gContext, contactPhoneNumber);
} Catch(Exception) {
LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong arguments");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong arguments");
return NULL;
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
} Catch(Exception ) {
LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Wrong arguments");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Wrong arguments");
return NULL;
}
addressBookId = converter->toString(arguments[0]);
} Catch(Exception) {
LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong arguments");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong arguments");
return NULL;
}
contactId = converter->toString(arguments[1]);
} Catch(Exception) {
LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong arguments");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong arguments");
return NULL;
}
jsobject = createJSObject(gContext, contactRef);
} Catch(Exception) {
LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong arguments");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong arguments");
return NULL;
}
LoggerW("trying to set incorrect value");
}
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
return false;
}
LoggerW("trying to set incorrect value");
}
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
return false;
}
}
} catch (const TypeMismatchException& err ) {
- JSWebAPIErrorFactory::postException(context, exception, err);
+// JSWebAPIErrorFactory::postException(context, exception, err);
return NULL;
} catch(const BasePlatformException& err) {
- JSWebAPIErrorFactory::postException(context, exception, err);
+// JSWebAPIErrorFactory::postException(context, exception, err);
return NULL;
} catch(const ConversionException& err) {
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
return NULL;
} catch(const NullPointerException& err) {
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
return NULL;
}
jsobject = createJSObject(gContext, contactWebSite);
} Catch(Exception) {
LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong arguments");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong arguments");
return NULL;
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- webSite->unsetType();
+ return true;//webSite->unsetType();
else
{
ContactWebSiteType type = converter->toContactWebSiteType(converter->toString(value));
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
ContactConverterFactory::getConverter(context);
BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- person->unsetPhotoURI();
+ return true;//person->unsetPhotoURI();
else
person->setPhotoURI(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
ContactConverterFactory::getConverter(context);
BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- person->unsetRingtoneURI();
+ return true;//person->unsetRingtoneURI();
else
person->setRingtoneURI(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
if(validator->isNullOrUndefined(value))
- person->unsetDisplayContactId();
+ return true;//person->unsetDisplayContactId();
else
person->setDisplayContactId(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LoggerW("trying to set incorrect value");
- JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
}
return true;
Conversation::Conversation(unsigned int threadId, MessageType msgType)
{
LoggerD("Enter");
+ bool result = false;
if (msgType == EMAIL)
{
- makeConversationFromEmailThreadId(threadId);
+ result = makeConversationFromEmailThreadId(threadId);
}
else if((msgType == EMPTY_MESSAGE_CONVERSATION)||(msgType == EMPTY_EMAIL_CONVERSATION))
{
}
else
{
- makeConversationFromMsgId(threadId, msgType);
+ result = makeConversationFromMsgId(threadId, msgType);
+ }
+
+ if(result == false)
+ {
+ LoggerE("fail to make conversation");
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "fail to make conversation");
}
}
result = makeConversationFromMsgId(number, msgType);
if(result == FALSE)
{
+ LoggerE("fail to make conversation");
ThrowMsg(WrtDeviceApis::Commons::PlatformException, "fail to make conversation");
}
}
msg_struct_t msg_thread = NULL;
- msg_struct_list_s convViewList;
+// msg_struct_list_s convViewList;
+ msg_struct_list_s msgList;
msg_struct_list_s *addr_list = NULL;
msg_error_t err = MSG_SUCCESS;
// get msg from msgId
msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT);
-
+
if (msg_get_message(handle, (msg_message_id_t)msgId, msgInfo, sendOpt) != MSG_SUCCESS)
{
ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get message fail");
}
LoggerD("m_preview : " << m_preview);
- err = msg_get_conversation_view_list(handle, m_Id, &convViewList);
+
+// err = msg_get_conversation_view_list(handle, m_Id, &convViewList);
+ err = msg_get_message_list(handle, 0, m_Id, 0, 0, &msgList);
if (err != MSG_SUCCESS)
{
}
// get thread message count
- lastMsgIndex = convViewList.nCount - 1;
- m_messageCount = convViewList.nCount;
+// lastMsgIndex = convViewList.nCount - 1;
+// m_messageCount = convViewList.nCount;
+ lastMsgIndex = msgList.nCount - 1;
+ m_messageCount = msgList.nCount;
LoggerD("m_messageCount : " << m_messageCount);
// get thread read status
- msg_get_bool_value(convViewList.msg_struct_info[lastMsgIndex], MSG_CONV_MSG_READ_BOOL, &tempBool);
+// msg_get_bool_value(convViewList.msg_struct_info[lastMsgIndex], MSG_CONV_MSG_READ_BOOL, &tempBool);
+ msg_get_bool_value(msgList.msg_struct_info[lastMsgIndex], MSG_MESSAGE_READ_BOOL, &tempBool);
m_read = tempBool;
LoggerD("m_read : " << m_read);
// get thread last message Id
- msg_get_int_value(convViewList.msg_struct_info[lastMsgIndex], MSG_CONV_MSG_ID_INT, &tempInt);
+// msg_get_int_value(convViewList.msg_struct_info[lastMsgIndex], MSG_CONV_MSG_ID_INT, &tempInt);
+ msg_get_int_value(msgList.msg_struct_info[lastMsgIndex], MSG_MESSAGE_ID_INT, &tempInt);
m_lastMessageId = tempInt;
LoggerD("m_lastMessageId : " << m_lastMessageId);
ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get message fail");
}
- msg_get_int_value(convViewList.msg_struct_info[lastMsgIndex], MSG_CONV_MSG_DIRECTION_INT, &tempInt);
+// msg_get_int_value(convViewList.msg_struct_info[lastMsgIndex], MSG_CONV_MSG_DIRECTION_INT, &tempInt);
+ msg_get_int_value(msgList.msg_struct_info[lastMsgIndex], MSG_MESSAGE_DIRECTION_INT, &tempInt);
int type = tempInt;
LoggerD("direction : " << type);
m_direction = type;
LoggerE("Exception: " << ex.GetMessage());
}
- msg_release_list_struct(&convViewList);
+// msg_release_list_struct(&convViewList);
+ msg_release_list_struct(&msgList);
msg_release_struct(&msgInfo);
msg_release_struct(&sendOpt);
msg_release_struct(&msg_thread);
}
IMessagePtr msg = converter->toIMessage(messageArg);
+ if (msg->getMessageType() != priv->getObject()->getType()) {
+ std::ostringstream str;
+ str << "Message type: "
+ << msg->getMessageType()
+ << " doesn't match message service type: "
+ << priv->getObject()->getType();
+ LoggerW(str.str());
+ throw DeviceAPI::Common::TypeMismatchException(str.str().c_str());
+ }
+
// argu 2. Success callback
callbackManager->setOnSuccess(validator.toFunction(1));
EventMessageReceivedPtr jsEvent(new EventMessageReceived());
DBus::MessagePtr message = event.GetArg0();
- if (!message)
- {
- jsEvent->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::PlatformException);
- m_onMessageReceived.emit(jsEvent);
- }
- else
- {
- if (message->getInterface() == DBUS_INTERFACE_EMAIL_RECEIVED)
- {
- int account_id = 0, mail_id = 0, thread_id = 0, status = 0;
- std::string name;
- email_mailbox_t m_mailboxes;
+ Try {
- DBus::Message::ReadIterator it = message->getReadIterator();
- for (int i = 0; it->isValid(); it->next(), ++i)
+ if (!message)
+ {
+ jsEvent->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::PlatformException);
+ m_onMessageReceived.emit(jsEvent);
+ }
+ else
+ {
+ if (message->getInterface() == DBUS_INTERFACE_EMAIL_RECEIVED)
{
- if ((i == 0) && (it->getArgType() == DBUS_TYPE_INT32))
- {
- status = it->getInt();
- LoggerI("status: " << status);
- }
- else if ((i == 1) && (it->getArgType() == DBUS_TYPE_INT32))
- {
- account_id = it->getInt();
- LoggerI("account_id: " << account_id);
- }
- else if ((i == 2) && (it->getArgType() == DBUS_TYPE_INT32))
- {
- mail_id = it->getInt();
- LoggerI("mail_id: " << mail_id);
- }
- else if ((i == 3) && (it->getArgType() == DBUS_TYPE_STRING))
- {
- name = it->getString();
- LoggerI("name: " << name);
- }
- else if ((i == 4) && (it->getArgType() == DBUS_TYPE_INT32))
+ int account_id = 0, mail_id = 0, thread_id = 0, status = 0;
+ std::string name;
+ email_mailbox_t m_mailboxes;
+
+ DBus::Message::ReadIterator it = message->getReadIterator();
+ for (int i = 0; it->isValid(); it->next(), ++i)
{
- thread_id = it->getInt();
- LoggerI("thread_id: " << thread_id);
+ if ((i == 0) && (it->getArgType() == DBUS_TYPE_INT32))
+ {
+ status = it->getInt();
+ LoggerI("status: " << status);
+ }
+ else if ((i == 1) && (it->getArgType() == DBUS_TYPE_INT32))
+ {
+ account_id = it->getInt();
+ LoggerI("account_id: " << account_id);
+ }
+ else if ((i == 2) && (it->getArgType() == DBUS_TYPE_INT32))
+ {
+ mail_id = it->getInt();
+ LoggerI("mail_id: " << mail_id);
+ }
+ else if ((i == 3) && (it->getArgType() == DBUS_TYPE_STRING))
+ {
+ name = it->getString();
+ LoggerI("name: " << name);
+ }
+ else if ((i == 4) && (it->getArgType() == DBUS_TYPE_INT32))
+ {
+ thread_id = it->getInt();
+ LoggerI("thread_id: " << thread_id);
+ }
}
- }
- jsEvent->setMsg_Type(EMAIL);
- jsEvent->setAccount_Id(account_id);
+ jsEvent->setMsg_Type(EMAIL);
+ jsEvent->setAccount_Id(account_id);
- if ((mail_id > 0) && (NOTI_MAIL_ADD == status))
- { // TODO also RECEIVE_THREAD_ITEM?
- LoggerI("Email received. mail_id: " << mail_id);
+ if ((mail_id > 0) && (NOTI_MAIL_ADD == status))
+ { // TODO also RECEIVE_THREAD_ITEM?
+ LoggerI("Email received. mail_id: " << mail_id);
- IMessagePtr msg = MessageFactory::createMessage(EMAIL, mail_id);
- IConversationPtr conversation(new Conversation(thread_id, EMAIL));
+ IMessagePtr msg = MessageFactory::createMessage(EMAIL, mail_id);
+ IConversationPtr conversation(new Conversation(thread_id, EMAIL));
- // TODO Temporary fix: ignore messages from OUTBOX, SENTBOX & DRAFTBOX -> most probably we added them
- FolderType folder = msg->getCurrentFolder();
- jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_ADDED);
+ // TODO Temporary fix: ignore messages from OUTBOX, SENTBOX & DRAFTBOX -> most probably we added them
+ FolderType folder = msg->getCurrentFolder();
+ jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_ADDED);
- LoggerI("Added message is in folder: " << folder);
+ LoggerI("Added message is in folder: " << folder);
- jsEvent->setMessage(msg);
- jsEvent->setConversation(conversation);
-
- if(m_onMessageReceived.size() > 0){
- m_onMessageReceived.emit(jsEvent);
- }
-
- if(m_onConversationReceived.size() > 0){
- if(mail_id != thread_id)
- {
- jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_UPDATED);
+ jsEvent->setMessage(msg);
+ jsEvent->setConversation(conversation);
+
+ if(m_onMessageReceived.size() > 0){
+ m_onMessageReceived.emit(jsEvent);
}
- m_onConversationReceived.emit(jsEvent);
- }
- }
- else if ((name.size() > 0) && (NOTI_MAIL_DELETE == status))
- { // TODO also RECEIVE_THREAD_ITEM?
- LoggerI("name.size(): " << name.size());
- unsigned foundLocation = name.rfind(0x01);
- LoggerI("foundLocation: " << foundLocation);
- if(foundLocation != std::string::npos)
- {
- LoggerI("name: " << name);
- name = name.substr(foundLocation+1);
- LoggerI("name: " << name);
+ if(m_onConversationReceived.size() > 0){
+ if(mail_id != thread_id)
+ {
+ jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_UPDATED);
+ }
+ m_onConversationReceived.emit(jsEvent);
+ }
}
+ else if ((name.size() > 0) && (NOTI_MAIL_DELETE == status))
+ { // TODO also RECEIVE_THREAD_ITEM?
+ LoggerI("name.size(): " << name.size());
- std::vector<std::string> strIds = String::split(name, ',');
-
- std::stringstream stream;
- for (std::vector<std::string>::iterator it = strIds.begin(); it != strIds.end(); ++it)
- {
- LoggerD("ID is :" << *it);
-
- if ( (*it).length() > 0 ) //vaild id
+ unsigned foundLocation = name.rfind(0x01);
+ LoggerI("foundLocation: " << foundLocation);
+ if(foundLocation != std::string::npos)
{
- stream<< *it;
- int id;
- stream >> id;
-
- IMessagePtr msg = MessageFactory::createMessage(EMPTY_MESSAGE, id);
- IConversationPtr conversation(new Conversation(mail_id, EMPTY_EMAIL_CONVERSATION));
+ LoggerI("name: " << name);
+ name = name.substr(foundLocation+1);
+ LoggerI("name: " << name);
+ }
- FolderType folder = msg->getCurrentFolder();
- jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_DELETED);
+ std::vector<std::string> strIds = String::split(name, ',');
- if (true) { // if (OUTBOX != folder && SENTBOX != folder && DRAFTBOX != folder)
- jsEvent->setMessage(msg);
- jsEvent->setConversation(conversation);
- if(m_onMessageReceived.size() > 0){
- m_onMessageReceived.emit(jsEvent);
+ std::stringstream stream;
+ for (std::vector<std::string>::iterator it = strIds.begin(); it != strIds.end(); ++it)
+ {
+ LoggerD("ID is :" << *it);
+
+ if ( (*it).length() > 0 ) //vaild id
+ {
+ stream<< *it;
+ int id;
+ stream >> id;
+
+ IMessagePtr msg = MessageFactory::createMessage(EMPTY_MESSAGE, id);
+ IConversationPtr conversation(new Conversation(mail_id, EMPTY_EMAIL_CONVERSATION));
+
+ FolderType folder = msg->getCurrentFolder();
+ jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_DELETED);
+
+ if (true) { // if (OUTBOX != folder && SENTBOX != folder && DRAFTBOX != folder)
+ jsEvent->setMessage(msg);
+ jsEvent->setConversation(conversation);
+ if(m_onMessageReceived.size() > 0){
+ m_onMessageReceived.emit(jsEvent);
+ }
+ }
+ else {
+ LoggerW("New email message in ignored folder: " << folder);
}
}
- else {
- LoggerW("New email message in ignored folder: " << folder);
- }
- }
- stream.clear();
- } //for
+ stream.clear();
+ } //for
- }
- else if ((mail_id > 0) && (NOTI_MAIL_UPDATE == status))
- { // TODO also RECEIVE_THREAD_ITEM?
- LoggerI("Email received. mail_id: " << mail_id);
+ }
+ else if ((mail_id > 0) && (NOTI_MAIL_UPDATE == status))
+ { // TODO also RECEIVE_THREAD_ITEM?
+ LoggerI("Email received. mail_id: " << mail_id);
- IMessagePtr msg = MessageFactory::createMessage(EMAIL, mail_id);
- IConversationPtr conversation(new Conversation(mail_id, EMAIL));
+ IMessagePtr msg = MessageFactory::createMessage(EMAIL, mail_id);
+ IConversationPtr conversation(new Conversation(mail_id, EMAIL));
- FolderType folder = msg->getCurrentFolder();
- jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_UPDATED);
+ FolderType folder = msg->getCurrentFolder();
+ jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_UPDATED);
- if (true) { // if (OUTBOX != folder && SENTBOX != folder && DRAFTBOX != folder)
- jsEvent->setMessage(msg);
- jsEvent->setConversation(conversation);
- if(m_onMessageReceived.size() > 0)
- m_onMessageReceived.emit(jsEvent);
- if(m_onConversationReceived.size() > 0)
- m_onConversationReceived.emit(jsEvent);
- } else {
- LoggerW("New email message in ignored folder: " << folder);
+ if (true) { // if (OUTBOX != folder && SENTBOX != folder && DRAFTBOX != folder)
+ jsEvent->setMessage(msg);
+ jsEvent->setConversation(conversation);
+ if(m_onMessageReceived.size() > 0)
+ m_onMessageReceived.emit(jsEvent);
+ if(m_onConversationReceived.size() > 0)
+ m_onConversationReceived.emit(jsEvent);
+ } else {
+ LoggerW("New email message in ignored folder: " << folder);
+ }
}
- }
- else if ((mail_id > 0) && (NOTI_THREAD_DELETE == status))
- { // TODO also RECEIVE_THREAD_ITEM?
- LoggerI("Email received. delete thread Id : " << mail_id);
+ else if ((mail_id > 0) && (NOTI_THREAD_DELETE == status))
+ { // TODO also RECEIVE_THREAD_ITEM?
+ LoggerI("Email received. delete thread Id : " << mail_id);
- IConversationPtr conversation(new Conversation(mail_id, EMPTY_EMAIL_CONVERSATION));
- conversation->setConvId(mail_id);
- jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_DELETED);
- jsEvent->setConversation(conversation);
+ IConversationPtr conversation(new Conversation(mail_id, EMPTY_EMAIL_CONVERSATION));
+ conversation->setConvId(mail_id);
+ jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_DELETED);
+ jsEvent->setConversation(conversation);
- if(m_onConversationReceived.size() > 0){
- m_onConversationReceived.emit(jsEvent);
+ if(m_onConversationReceived.size() > 0){
+ m_onConversationReceived.emit(jsEvent);
+ }
}
- }
- else if (NOTI_MAILBOX_ADD == status)
- {
- LoggerI("Emailbox received. account Id: " << account_id);
- LoggerI("name Id: " << name);
- LoggerI("mailBox Id: " << mail_id);
+ else if (NOTI_MAILBOX_ADD == status)
+ {
+ LoggerI("Emailbox received. account Id: " << account_id);
+ LoggerI("name Id: " << name);
+ LoggerI("mailBox Id: " << mail_id);
- email_mailbox_t* mail_box = NULL;
+ email_mailbox_t* mail_box = NULL;
- if (EMAIL_ERROR_NONE != email_get_mailbox_by_mailbox_id(mail_id, &mail_box)) {
- LoggerE("Couldn't retrieve message or it has been malformed.");
- }
+ if (EMAIL_ERROR_NONE != email_get_mailbox_by_mailbox_id(mail_id, &mail_box)) {
+ LoggerE("Couldn't retrieve message or it has been malformed.");
+ }
- if(mail_box != NULL)
- {
- m_mailboxes = *mail_box;
- IMessageFolderPtr folderPtr(new MessageFolder(m_mailboxes));
- jsEvent->setMessageFolder(folderPtr);
- jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_ADDED);
- if(m_onFolderReceived.size() > 0)
+ if(mail_box != NULL)
{
- m_onFolderReceived.emit(jsEvent);
+ m_mailboxes = *mail_box;
+ IMessageFolderPtr folderPtr(new MessageFolder(m_mailboxes));
+ jsEvent->setMessageFolder(folderPtr);
+ jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_ADDED);
+ if(m_onFolderReceived.size() > 0)
+ {
+ m_onFolderReceived.emit(jsEvent);
+ }
+ }
+
+ if ( mail_box )
+ {
+ if( EMAIL_ERROR_NONE != email_free_mailbox( &mail_box , 1) )
+ LoggerD("fail to email_free_mailbox - err ");
}
-
- }
- if ( mail_box )
- {
- if( EMAIL_ERROR_NONE != email_free_mailbox( &mail_box , 1) )
- LoggerD("fail to email_free_mailbox - err ");
}
+ else if ((NOTI_MAILBOX_UPDATE == status) || (NOTI_MAILBOX_FIELD_UPDATE == status) || (NOTI_MAILBOX_RENAME == status))
+ {
+ LoggerI("Emailbox received. account Id: " << account_id);
+ LoggerI("name Id: " << name);
+ LoggerI("mailBox Id: " << mail_id);
- }
- else if ((NOTI_MAILBOX_UPDATE == status) || (NOTI_MAILBOX_FIELD_UPDATE == status) || (NOTI_MAILBOX_RENAME == status))
- {
- LoggerI("Emailbox received. account Id: " << account_id);
- LoggerI("name Id: " << name);
- LoggerI("mailBox Id: " << mail_id);
+ email_mailbox_t* mail_box = NULL;
- email_mailbox_t* mail_box = NULL;
+ if (EMAIL_ERROR_NONE != email_get_mailbox_by_mailbox_id(mail_id, &mail_box)) {
+ LoggerE("Couldn't retrieve message or it has been malformed.");
+ }
- if (EMAIL_ERROR_NONE != email_get_mailbox_by_mailbox_id(mail_id, &mail_box)) {
- LoggerE("Couldn't retrieve message or it has been malformed.");
- }
+ if(mail_box != NULL)
+ {
+ m_mailboxes = *mail_box;
+
+ IMessageFolderPtr folderPtr(new MessageFolder(m_mailboxes));
+ jsEvent->setMessageFolder(folderPtr);
+ jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_UPDATED);
- if(mail_box != NULL)
+ if(m_onFolderReceived.size() > 0)
+ {
+ m_onFolderReceived.emit(jsEvent);
+ }
+ }
+
+ if ( mail_box )
+ {
+ if( EMAIL_ERROR_NONE != email_free_mailbox( &mail_box , 1) )
+ LoggerD("fail to email_free_mailbox - err ");
+ }
+ }
+ else if (NOTI_MAILBOX_DELETE == status)
{
- m_mailboxes = *mail_box;
+ LoggerI("Emailbox received. account Id: " << account_id);
+ LoggerI("name Id: " << name);
+ LoggerI("mailBox Id: " << mail_id);
+
+ // make empty mailbox
+ m_mailboxes.mailbox_id = mail_id;
+ m_mailboxes.account_id = account_id;
+ m_mailboxes.alias = (char *)"";
+ m_mailboxes.mailbox_name = (char *)"";
IMessageFolderPtr folderPtr(new MessageFolder(m_mailboxes));
jsEvent->setMessageFolder(folderPtr);
- jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_UPDATED);
-
+ jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_DELETED);
+
if(m_onFolderReceived.size() > 0)
{
m_onFolderReceived.emit(jsEvent);
}
}
-
- if ( mail_box )
+ else
{
- if( EMAIL_ERROR_NONE != email_free_mailbox( &mail_box , 1) )
- LoggerD("fail to email_free_mailbox - err ");
- }
- }
- else if (NOTI_MAILBOX_DELETE == status)
- {
- LoggerI("Emailbox received. account Id: " << account_id);
- LoggerI("name Id: " << name);
- LoggerI("mailBox Id: " << mail_id);
-
- // make empty mailbox
- m_mailboxes.mailbox_id = mail_id;
- m_mailboxes.account_id = account_id;
- m_mailboxes.alias = (char *)"";
- m_mailboxes.mailbox_name = (char *)"";
-
- IMessageFolderPtr folderPtr(new MessageFolder(m_mailboxes));
- jsEvent->setMessageFolder(folderPtr);
- jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_DELETED);
-
- if(m_onFolderReceived.size() > 0)
- {
- m_onFolderReceived.emit(jsEvent);
+ LoggerE("Couldn't retrieve message or it has been malformed.");
}
- }
- else
+ }
+ else // DBUS_INTERFACE_EMAIL_RECEIVED
{
- LoggerE("Couldn't retrieve message or it has been malformed.");
+ LoggerD("Wrong DBus interface, skipping it.");
}
- }
- else // DBUS_INTERFACE_EMAIL_RECEIVED
- {
- LoggerD("Wrong DBus interface, skipping it.");
}
+ }Catch(WrtDeviceApis::Commons::Exception) {
+ LoggerE("Couldn't retrieve message or it has been malformed.");
}
}
LoggerD("szMimeStr " << szMimeStr);
- for(int idx =0; mimeTable[idx].szMIME != NULL ; idx++)
+ for(int idx =0; mimeTable[idx].szMIME != "" ; idx++)
{
if (!strcmp(mimeTable[idx].szMIME, szMimeStr)) {
retInt = mimeTable[idx].mime;
NotificationDetailInfo *priv = new NotificationDetailInfo();
try {
- priv->setMainText(validator.toString(0, false, ""));
+ priv->setMainText(validator.toString(0, false));
} catch (const BasePlatformException& err) {
LoggerW("mainText convertion is failed. %s", err.getMessage().c_str());
}
try {
- priv->setSubText(validator.toString(1, true, ""));
+ priv->setSubText(validator.toString(1, true));
} catch (const BasePlatformException& err) {
LoggerW("subText convertion is failed. %s", err.getMessage().c_str());
}
JSValueRef subText = JSUtil::getProperty(context, object, NOTIFICATION_DETAIL_INFO_SUB_TEXT);
priv->setSubText(JSUtil::JSValueToString(context, subText));
+ if (!subText)
+ LoggerI("Sub Text is NULL");
+
return priv;
}
// subText
std::string subText = priv->getSubText();
- if ( subText.empty())
- {
- JSUtil::setProperty(context, object, NOTIFICATION_DETAIL_INFO_SUB_TEXT, JSValueMakeNull(context), kJSPropertyAttributeNone);
- }
- else
- {
- JSUtil::setProperty(context, object, NOTIFICATION_DETAIL_INFO_SUB_TEXT,
+ JSUtil::setProperty(context, object, NOTIFICATION_DETAIL_INFO_SUB_TEXT,
JSUtil::toJSValueRef(context, priv->getSubText()), kJSPropertyAttributeNone);
- }
+
}
// notification
JSObjectRef notificationObj = validator.toObject(0, JSStatusNotification::getClassRef());
- LoggerI("Notification Obj: " << notificationObj);
- StatusNotification *notification = JSStatusNotification::getPrivateObject(context, notificationObj);
-
- LoggerI("Notification : " << notification);
-
+ StatusNotification *notification = JSStatusNotification::getPrivateObject(context, notificationObj);
if (!notification) {
throw TypeMismatchException("Notification's private object is NULL.");
}
LoggerI ("posted notification id : " << stream.str());
//delete notificaiton ID
- JSStringRef propertyIDName = JSStringCreateWithUTF8CString(NOTIFICATION_ID);
+ JSStringRef propertyIDName = JSStringCreateWithUTF8CString(NOTIFICATION_ID);
JSObjectDeleteProperty(context, notificationObj, propertyIDName, 0);
JSStringRelease(propertyIDName);
throw DeviceAPI::Common::UnknownException("Notification ID value is invalied.");
}
- //delete posted time
- JSStringRef propertyPostedTimeName = JSStringCreateWithUTF8CString(NOTIFICATION_POSTED_TIME);
- JSObjectDeleteProperty(context, notificationObj, propertyPostedTimeName, 0);
- JSStringRelease(propertyPostedTimeName);
+ //delete posted time
+ JSStringRef propertyPostedTimeName = JSStringCreateWithUTF8CString(NOTIFICATION_POSTED_TIME);
+ JSObjectDeleteProperty(context, notificationObj, propertyPostedTimeName, 0);
+ JSStringRelease(propertyPostedTimeName);
//posted time
JSUtil::setProperty(context, notificationObj, NOTIFICATION_POSTED_TIME,
else if( strStatusType.compare(TIZEN_STATUS_NOTIFICATION_TYPE_PROGRESS) == 0)
notiType = NOTI_TYPE_PROGRESS;
else
- throw TypeMismatchException("notification status type mismatch.");
+ notiType = NOTI_TYPE_NONE;
StatusNotification *priv = new StatusNotification(notiType);
}
catch (...)
{
- throw InvalidValuesException("Icon file path is invaild");
+ LoggerW("Icon file path is invaild");
}
-#if 0
- catch ( const BasePlatformException& err)
- {
- LoggerW("notification's icon path convertion is failed." << err.getMessage());
- }
-#endif
//sound
try {
}
catch (...)
{
- throw InvalidValuesException("sound file path is invaild");
+ LoggerW("sound file path is invaild");
}
-
- //vibration
- JSValueRef vibrationValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_VIBRATION);
- priv->setDefaultVibration(JSUtil::JSValueToBoolean(context, vibrationValue));
-
- //appControl
- JSValueRef appControlValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_APP_CONTROL);
- if (!JSValueIsUndefined(context, appControlValue))
- priv->setApplicationControl(DeviceAPI::Application::JSApplicationControl::getApplicationControl(context, JSUtil::JSValueToObject(context, appControlValue) ));
-
- //appID
- JSValueRef appIdValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_APP_ID);
- if (!JSValueIsUndefined(context, appIdValue))
- priv->setApplicationId(JSUtil::JSValueToString(context, appIdValue));
-
- //Light
- JSValueRef lightValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_LIGHT);
- LoggerI("Light :" << JSUtil::JSValueToString(context, lightValue));
- if (!JSValueIsUndefined(context, lightValue))
- priv->setLight(JSUtil::JSValueToString(context, lightValue));
-
- //onTime
- JSValueRef onTimeValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_LIGHT_ONTIME);
- if (!JSValueIsUndefined(context, onTimeValue))
- priv->setLightOnTime(JSUtil::JSValueToLong(context, onTimeValue));
-
- //offTime
- JSValueRef offTimeValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_LIGHT_OFFTIME);
- if (!JSValueIsUndefined(context, offTimeValue))
- priv->setLightOffTime(JSUtil::JSValueToLong(context, offTimeValue));
-
+
+ try {
+ //vibration
+ JSValueRef vibrationValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_VIBRATION);
+ priv->setDefaultVibration(JSUtil::JSValueToBoolean(context, vibrationValue));
+ }
+ catch (...)
+ {
+ LoggerW("sound file path is invaild");
+ }
+
+ try {
+ //appControl
+ JSValueRef appControlValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_APP_CONTROL);
+ if (!JSValueIsUndefined(context, appControlValue))
+ priv->setApplicationControl(DeviceAPI::Application::JSApplicationControl::getApplicationControl(context, JSUtil::JSValueToObject(context, appControlValue) ));
+ }
+ catch (...)
+ {
+ LoggerW("sound file path is invaild");
+ }
+
+ try {
+ //appID
+ JSValueRef appIdValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_APP_ID);
+ if (!JSValueIsUndefined(context, appIdValue))
+ priv->setApplicationId(JSUtil::JSValueToString(context, appIdValue));
+ }
+ catch (...)
+ {
+ LoggerW("sound file path is invaild");
+ }
+
+ try{
+ //Light
+ JSValueRef lightValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_LIGHT);
+ LoggerI("Light :" << JSUtil::JSValueToString(context, lightValue));
+ if (!JSValueIsUndefined(context, lightValue))
+ priv->setLight(JSUtil::JSValueToString(context, lightValue));
+ }
+ catch(...)
+ {
+ LoggerW("The LED value is invalid ");
+ }
+
+
+ try{
+ //onTime
+ JSValueRef onTimeValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_LIGHT_ONTIME);
+ if (!JSValueIsUndefined(context, onTimeValue))
+ priv->setLightOnTime(JSUtil::JSValueToLong(context, onTimeValue));
+ }
+ catch(...)
+ {
+ LoggerW("The LED value is invalid ");
+ }
+
+ try {
+ //offTime
+ JSValueRef offTimeValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_LIGHT_OFFTIME);
+ if (!JSValueIsUndefined(context, offTimeValue))
+ priv->setLightOffTime(JSUtil::JSValueToLong(context, offTimeValue));
+
+ }
+ catch(...)
+ {
+ LoggerW("The LED value is invalid ");
+ }
+
//progressType
NotificationProgressType progressType = NOTI_PROGRESS_TYPE_PERCENTAGE;
- JSStringRef propertyName = JSStringCreateWithUTF8CString(STATUS_NOTIFICATION_PROGRESS_TYPE);
- bool has = JSObjectHasProperty(context, notiInitDict, propertyName);
- JSStringRelease(propertyName);
- if (has)
+ try {
+ JSStringRef propertyName = JSStringCreateWithUTF8CString(STATUS_NOTIFICATION_PROGRESS_TYPE);
+ bool has = JSObjectHasProperty(context, notiInitDict, propertyName);
+ JSStringRelease(propertyName);
+ if (has)
+ {
+ JSValueRef progressTypeValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_PROGRESS_TYPE);
+ std::string strProgressType = JSUtil::JSValueToString(context, progressTypeValue);
+ LoggerI("==Progress Type : " << strProgressType);
+ if( strProgressType.compare(TIZEN_NOTIFICATION_PROGRESS_TYPE_PERCENTAGE) == 0)
+ progressType = NOTI_PROGRESS_TYPE_PERCENTAGE;
+ else if( strProgressType.compare(TIZEN_NOTIFICATION_PROGRESS_TYPE_BYTE) == 0)
+ progressType = NOTI_PROGRESS_TYPE_SIZE;
+ else
+ progressType = NOTI_PROGRESS_TYPE_NONE;
+ }
+ priv->setProgressType(progressType);
+ }
+ catch(...)
{
- JSValueRef progressTypeValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_PROGRESS_TYPE);
- std::string strProgressType = JSUtil::JSValueToString(context, progressTypeValue);
- LoggerI("==Progress Type : " << strProgressType);
- if( strProgressType.compare(TIZEN_NOTIFICATION_PROGRESS_TYPE_PERCENTAGE) == 0)
- progressType = NOTI_PROGRESS_TYPE_PERCENTAGE;
- else if( strProgressType.compare(TIZEN_NOTIFICATION_PROGRESS_TYPE_BYTE) == 0)
- progressType = NOTI_PROGRESS_TYPE_SIZE;
- else
- throw TypeMismatchException("Invalid Progress Type.");
+ //throw TypeMismatchException("The backgound image path is invalid ");
+ LoggerW("The progress type is invalid ");
}
- priv->setProgressType(progressType);
-#if 0
- JSValueRef progressTypeValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_PROGRESS_TYPE);
- if (progressTypeValue)
- {
+ try {
+ //ProgressValue
+ JSValueRef progressValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_PROGRESS_VALUE);
+ if (!JSValueIsUndefined(context, progressValue))
+ {
+ if ( progressType == NOTI_PROGRESS_TYPE_PERCENTAGE)
+ {
+ if ( 100 < JSUtil::JSValueToULong(context, progressValue) )
+ {
+ LoggerW("The percentage progress value must be between 0 and 100");
+ }
+ priv->setProgressValue((double)JSUtil::JSValueToULong(context, progressValue)/(double)100);
+ }
+ else
+ {
+ priv->setProgressValue((double)JSUtil::JSValueToULong(context, progressValue));
+ }
+ }
}
- if (!JSValueIsUndefined(context, progressTypeValue))
- {
- std::string strProgressType = JSUtil::JSValueToString(context, progressTypeValue);
- LoggerI("==Progress Type : " << strProgressType);
- if( strProgressType.compare(TIZEN_NOTIFICATION_PROGRESS_TYPE_PERCENTAGE) == 0)
- progressType = NOTI_PROGRESS_TYPE_PERCENTAGE;
- else if( strProgressType.compare(TIZEN_NOTIFICATION_PROGRESS_TYPE_BYTE) == 0)
- progressType = NOTI_PROGRESS_TYPE_SIZE;
- else
- throw TypeMismatchException("Invalid Progress Type.");
- }
- priv->setProgressType(progressType);
-#endif
- //ProgressValue
- JSValueRef progressValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_PROGRESS_VALUE);
- if (!JSValueIsUndefined(context, progressValue))
- {
- if ( progressType == NOTI_PROGRESS_TYPE_PERCENTAGE)
- {
- if ( 100 < JSUtil::JSValueToULong(context, progressValue) )
- throw TypeMismatchException("The percentage progress value must be between 0 and 100");
- priv->setProgressValue((double)JSUtil::JSValueToULong(context, progressValue)/(double)100);
- }
- else
- {
- priv->setProgressValue((double)JSUtil::JSValueToULong(context, progressValue));
- }
- }
-
+ catch (...)
+ {
+ LoggerW("The progress value is invalid ");
+ }
+
//DetailInfo
JSValueRef detailInfoValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_DETAIL_INFO);
JSObjectRef object = JSUtil::JSValueToObject(context, element);
if (object)
{
- NotificationDetailInfo* item = static_cast<NotificationDetailInfo*>(JSObjectGetPrivate(object));
- std::string main = item->getMainText();
- std::string sub = item->getSubText();
- LoggerI("Main : " << main << " Sub : " << sub);
-
- NotificationDetailInfo *detailinfo = new NotificationDetailInfo(NULL, (int)i, main, sub);
- detailInfos.push_back(detailinfo);
+ NotificationDetailInfo* item = static_cast<NotificationDetailInfo*>(JSObjectGetPrivate(object));
+ if (item)
+ {
+ std::string main = item->getMainText();
+ std::string sub = item->getSubText();
+ NotificationDetailInfo *detailinfo = new NotificationDetailInfo(NULL, (int)i, main, sub);
+ detailInfos.push_back(detailinfo);
+ }
+ else
+ {
+ //mainText
+ std::string main = JSUtil::JSValueToString(context, JSUtil::getProperty(context, object, NOTIFICATION_DETAIL_INFO_MAIN_TEXT));
+ std::string sub = JSUtil::JSValueToString(context, JSUtil::getProperty(context, object, NOTIFICATION_DETAIL_INFO_SUB_TEXT));
+ NotificationDetailInfo *detailinfo = new NotificationDetailInfo(NULL, (int)i, main, sub);
+ detailInfos.push_back(detailinfo);
+ }
+
}
}
}
- priv->setDetailInfos(detailInfos);
-
+ priv->setDetailInfos(detailInfos);
+
//backgroundimage
try {
JSValueRef backgroundImageValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_BACKGROUND_IMAGE_PATH);
}
catch(...)
{
- throw TypeMismatchException("The backgound image path is invalid : ");
+ //throw TypeMismatchException("The backgound image path is invalid ");
+ LoggerW("The backgound image path is invalid ");
}
-
- //number
- JSValueRef numberValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_NUMBER);
- if (!JSValueIsUndefined(context, numberValue))
- {
- priv->setNumber(JSUtil::JSValueToLong(context, numberValue));
+
+ try {
+ //number
+ JSValueRef numberValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_NUMBER);
+ if (!JSValueIsUndefined(context, numberValue))
+ {
+ priv->setNumber(JSUtil::JSValueToLong(context, numberValue));
+ }
}
-
+ catch (...) {
+ LoggerW("The number is invalid ");
+ }
+
//thumbnail
try {
JSValueRef thumbnailsValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_THUMBNAILS);
}
catch ( ... )
{
- throw TypeMismatchException("thumbnail path convertion is failed.");
+ //throw TypeMismatchException("thumbnail path convertion is failed.");
+ LoggerW("thumbnail path convertion is failed.");
}
//subIconPath
}
catch (...)
{
- throw TypeMismatchException("subIcon path convertion is failed.");
+ //throw TypeMismatchException("subIcon path convertion is failed.");
+ LoggerW("subIcon path convertion is failed.");
}
}
- setPrivateObject(context, obj, priv);
-
+ setPrivateObject(context, obj, priv);
}
catch ( const BasePlatformException& err)
{
LoggerW(" notification convertion is failed. " << err.getName().c_str() << ":" << err.getMessage().c_str());
- JSObjectRef error = JSWebAPIErrorFactory::makeErrorObject(context, err);
- *exception = error;
- return error;
+ //JSObjectRef error = JSWebAPIErrorFactory::makeErrorObject(context, err);
+ //*exception = error;
+ //return error;
}
return obj;
DeviceAPI::Filesystem::IPathPtr icon = DeviceAPI::Filesystem::Utils::fromVirtualPath(context, JSUtil::JSValueToString(context, iconPath));
priv->setIconPath(icon->getFullPath());
}
- //else
- //{
- // priv->setIconPath("");
- //}
// subIconPath
JSValueRef subIconPath = JSUtil::getProperty(context, object, STATUS_NOTIFICATION_SUB_ICON_PATH);
DeviceAPI::Filesystem::IPathPtr subIcon = DeviceAPI::Filesystem::Utils::fromVirtualPath(context, JSUtil::JSValueToString(context, subIconPath));
priv->setSubIconPath(subIcon->getFullPath());
}
- //else
- //{
- // priv->setSubIconPath("");
- //}
// number
JSValueRef number = JSUtil::getProperty(context, object, STATUS_NOTIFICATION_NUMBER);
DeviceAPI::Filesystem::IPathPtr backgroundImage = DeviceAPI::Filesystem::Utils::fromVirtualPath(context, JSUtil::JSValueToString(context, backgroundImagePath));
priv->setBackground(backgroundImage->getFullPath());
}
- //else
- //{
- // priv->setBackground("");
- //}
// thumbnails
JSValueRef thumbnails = JSUtil::getProperty(context, object, STATUS_NOTIFICATION_THUMBNAILS);
DeviceAPI::Filesystem::IPathPtr sound = DeviceAPI::Filesystem::Utils::fromVirtualPath(context, JSUtil::JSValueToString(context, soundPath));
priv->setSoundPath(sound->getFullPath());
}
- //else
- //{
- // priv->setSoundPath("");
- //}
// vibration
JSValueRef vibration = JSUtil::getProperty(context, object, STATUS_NOTIFICATION_VIBRATION);
JSValueRef offTime = JSUtil::getProperty(context, object, STATUS_NOTIFICATION_LIGHT_OFFTIME);
if (!JSValueIsNull(context, offTime))
priv->setLightOffTime(JSUtil::JSValueToLong(context, offTime));
-
-#if 0
- // progressType
- JSValueRef progressType = JSUtil::getProperty(context, object, STATUS_NOTIFICATION_PROGRESS_TYPE);
- std::string strProgressType = JSUtil::JSValueToString(context, progressType);
- LoggerI("Progress Type : " << strProgressType);
-
- NotificationProgressType progType = NOTI_PROGRESS_TYPE_NONE;
- if( strProgressType.compare(TIZEN_NOTIFICATION_PROGRESS_TYPE_PERCENTAGE) == 0)
- progType = NOTI_PROGRESS_TYPE_PERCENTAGE;
- else if( strProgressType.compare(TIZEN_NOTIFICATION_PROGRESS_TYPE_BYTE) == 0)
- progType = NOTI_PROGRESS_TYPE_SIZE;
- else
- throw InvalidValuesException("Invalid Progress Type.");
- priv->setProgressType(progType);
-
- // progressValue
- JSValueRef progressValue = JSUtil::getProperty(context, object, STATUS_NOTIFICATION_PROGRESS_VALUE);
- LoggerI(" Progress Value in Private Object = " << JSUtil::JSValueToULong(context, progressValue));
- if ( progType == NOTI_PROGRESS_TYPE_PERCENTAGE)
- {
- if ( 100 < JSUtil::JSValueToULong(context, progressValue) )
- throw InvalidValuesException("The percentage progress value must be between 0 and 100");
- priv->setProgressValue((double)JSUtil::JSValueToULong(context, progressValue)/(double)100);
- }
- else
- {
- priv->setProgressValue((double)JSUtil::JSValueToULong(context, progressValue));
- }
- #endif
+
return priv;
}
JSUtil::toJSValueRef(context, priv->getTitle()), kJSPropertyAttributeNone);
//content
- if (priv->getStrContent())
+ if (!priv->getContent().empty())
JSUtil::setProperty(context, object, NOTIFICATION_CONTENT,
JSUtil::toJSValueRef(context, priv->getContent()), kJSPropertyAttributeNone);
else
JSUtil::toJSValueRef(context, priv->getDefaultVibration()), kJSPropertyAttributeNone);
// appId
- if (!priv->getApplicationId().empty())
- JSUtil::setProperty(context, object, STATUS_NOTIFICATION_APP_ID,
+ JSUtil::setProperty(context, object, STATUS_NOTIFICATION_APP_ID,
JSUtil::toJSValueRef(context, priv->getApplicationId()), kJSPropertyAttributeNone);
- else
- JSUtil::setProperty(context, object, STATUS_NOTIFICATION_APP_ID, JSValueMakeNull(context), kJSPropertyAttributeNone);
-
+
//Light
- JSUtil::setProperty(context, object, STATUS_NOTIFICATION_LIGHT,
- JSUtil::toJSValueRef(context, priv->getLight()), kJSPropertyAttributeNone);
+ if (!priv->getLight().empty())
+ JSUtil::setProperty(context, object, STATUS_NOTIFICATION_LIGHT,
+ JSUtil::toJSValueRef(context, priv->getLight()), kJSPropertyAttributeNone);
+ else
+ JSUtil::setProperty(context, object, STATUS_NOTIFICATION_LIGHT,
+ JSValueMakeNull(context), kJSPropertyAttributeNone);
JSUtil::setProperty(context, object, STATUS_NOTIFICATION_LIGHT_ONTIME,
JSUtil::toJSValueRef(context, priv->getLightOnTime()), kJSPropertyAttributeNone);
{
public:
NotificationDetailInfo();
- NotificationDetailInfo(notification_h noti);
+ NotificationDetailInfo(notification_h noti);
NotificationDetailInfo(std::string &mainText, std::string &subText);
+ //NotificationDetailInfo(notification_h noti, int index, std::string &mainText);
NotificationDetailInfo(notification_h noti, int index, std::string &mainText, std::string &subText);
-
+
virtual ~NotificationDetailInfo();
std::string getMainText() const;
if (m_service)
{
- if (!appId.empty())
+ m_launchFlag = true;
+ if (service_set_app_id(m_service, appId.c_str())!= SERVICE_ERROR_NONE)
{
- m_launchFlag = true;
- if (service_set_app_id(m_service, appId.c_str())!= SERVICE_ERROR_NONE)
- {
- throw UnknownException("service set appId error");
- }
+ throw UnknownException("service set appId error");
}
}
{
for ( int idx = 0; idx < MAX_NOTIFICATION_DETAIL_INFO_LENGTH; idx++)
{
- std::string main = getInformation(idx);
- std::string sub = getSubInformation(idx);
- LoggerI("Main : " << main << " Sub : " << sub);
- NotificationDetailInfo *info = new NotificationDetailInfo(m_notiHandle, idx, main, sub);
- m_detailInfos.push_back(info);
+ if (!isNullInformation(idx))
+ {
+ std::string main = getInformation(idx);
+ std::string sub = getSubInformation(idx);
+
+ LoggerI("Main : [" << main << "] Sub : ['" << sub <<"]");
+
+ NotificationDetailInfo *info = new NotificationDetailInfo(m_notiHandle, idx, main, sub);
+ m_detailInfos.push_back(info);
+ }
}
}
else
NotificationDetailInfo* info = *it;
if ( idx < MAX_NOTIFICATION_DETAIL_INFO_LENGTH )
{
+
LoggerI("main " << info->getMainText() << " sub " << info->getSubText() );
setInformation(info->getMainText(), idx);
setSubInformation(info->getSubText(), idx);
}
+bool StatusNotification::isNullInformation(int index)
+{
+ if (m_notiHandle)
+ {
+ notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
+ switch (index)
+ {
+ case 0:
+ type = NOTIFICATION_TEXT_TYPE_INFO_1;
+ break;
+ case 1:
+ type = NOTIFICATION_TEXT_TYPE_INFO_2;
+ break;
+ case 2:
+ type = NOTIFICATION_TEXT_TYPE_INFO_3;
+ break;
+ default :
+ type = NOTIFICATION_TEXT_TYPE_NONE;
+ }
+ char *info = NULL;
+
+ if (NOTIFICATION_TEXT_TYPE_NONE != type && notification_get_text(m_notiHandle, type, &info) != NOTIFICATION_ERROR_NONE)
+ {
+ throw UnknownException("Detail Info index value is invalid or mainText value getting is failed in Detail Info.");
+ }
+
+ if (info)
+ {
+ LoggerI("is not null");
+ return false;
+ }
+ else
+ {
+ LoggerI("is null");
+ return true;
+ }
+
+ }
+ else
+ {
+ LoggerW("noti Handle is NULL");
+ throw UnknownException( "notification handle is null");
+ }
+}
+
std::string StatusNotification::getSubInformation(int index)
{
if (m_notiHandle)
if ( type != NOTIFICATION_TEXT_TYPE_NONE)
{
- if (getInformation(idx).compare(info))
+ if (getInformation(idx).compare(info) || isNullInformation(idx))
{
if (notification_set_text(m_notiHandle, type, info.c_str(),
NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
void setThumbnail( const std::string& info, int index);
std::string getThumbnail(int index);
- std::string getInformation(int index) ;
+ std::string getInformation(int index);
+ bool isNullInformation(int index);
void setInformation( const std::string& info, int index) ;
-
- std::string getSubInformation(int index) ;
+
+ std::string getSubInformation(int index);
void setSubInformation( const std::string& info, int index) ;
void loadDetailInfos();
}
int PowerManager::getPlatformBrightness(){
+ int currentPowerState = 1;
int brightness = 0;
+ int isCustomMode = 0;
+ int isAutoBrightness = 0;
int ret = 0;
- int isCustomMode = 0;
+ vconf_get_int(VCONFKEY_PM_STATE, ¤tPowerState);
+ if( currentPowerState == VCONFKEY_PM_STATE_NORMAL){
+ vconf_get_int(VCONFKEY_PM_CURRENT_BRIGHTNESS, &brightness);
+ LOGD("[PM_STATE_NORMAL] return VCONFKEY_PM_CURRENT_BRIGHTNESS %d", brightness);
+ return brightness;
+ }
+
vconf_get_int(VCONFKEY_PM_CUSTOM_BRIGHTNESS_STATUS, &isCustomMode);
if( (isCustomMode && mCurrentBrightness != -1) || mShouldBeReadFromCache ){
- LOGI("return custom brightness %d", mCurrentBrightness);
+ LOGD("return custom brightness %d", mCurrentBrightness);
return mCurrentBrightness;
}
- ret = vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &brightness);
- if( ret != 0 ){
- LoggerE("Platform error while getting brightness: %d", ret);
- throw UnknownException("Platform error while getting brightness");
+ vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &isAutoBrightness);
+ if( isAutoBrightness == 1 ){
+ ret = vconf_get_int(VCONFKEY_SETAPPL_PREFIX"/automatic_brightness_level" /*prevent RSA build error*/, &brightness);
+ if( ret != 0 ) //RSA binary has no AUTOMATIC_BRIGHTNESS
+ vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &brightness);
+ }else{
+ vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &brightness);
}
- LoggerE("VCONFKEY_SETAPPL_LCD_BRIGHTNESS %d", brightness);
+ LOGD("BRIGHTNESS(%s) %d", isAutoBrightness == 1 ? "auto" : "fix" , brightness);
return brightness;
}
token = strtok_r(duid, "=\r\n", &ptr);
if (token != NULL) {
token = strtok_r(NULL, "=\r\n", &ptr);
- deviceCapabilitiesInfo->duid = token;
- LoggerD("deviceCapabilitiesInfo->duid : " << deviceCapabilitiesInfo->duid);
+ if (token != NULL) {
+ deviceCapabilitiesInfo->duid = token;
+ LoggerD("deviceCapabilitiesInfo->duid : " << deviceCapabilitiesInfo->duid);
+ }
}
break;
}
EventRequestReceiver<EventGetSysteminfo>::ManualAnswer(event);
}
if (simState) {
- LoggerD("simState : " << simState);
free(simState);
}
} else {
const short MINUTES_UNIT = 2;
const short HOURS_UNIT = 3;
const short DAYS_UNIT = 4;
- const short WRONG_UNIT = 0xff;
}
struct DurationProperties
{
long long length;
short unit;
- std::string unitStr;
DurationProperties()
: length(0),
- unit(MSECS_UNIT), unitStr("MSECS")
+ unit(MSECS_UNIT)
{
}
};
JSClassRef JSTZDate::m_jsClassRef = JSClassCreate(JSTZDate::getClassInfo());
-JSObjectRef JSTZDate::createJSObject(JSContextRef context) {
+JSObjectRef JSTZDate::createJSObject(JSContextRef context, const bool isNotNull) {
LoggerD("entered");
- TZDatePtr tzDate(new TZDate());
+ TZDatePtr tzDate(new TZDate(isNotNull));
TZDatePrivObject *priv = new TZDatePrivObject(context, tzDate);
if (!priv) {
ThrowMsg(NullPointerException, "Can not new an object");
{
LoggerD( "entered" );
TZDatePrivObject *priv =
- static_cast<TZDatePrivObject*>( JSObjectGetPrivate( object ) ) ;
- delete priv;
+ static_cast<TZDatePrivObject*>(JSObjectGetPrivate(object));
+ if (priv)
+ delete priv;
}
JSObjectRef JSTZDate::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
LoggerD("entered");
TZDateProperties prop;
- TimeUtilConverter converter(ctx);
-
+ JSObjectRef tzDate = NULL;
Try {
- JSObjectRef tzDate = NULL;
-
- if (argumentCount == 0) {
+ if (argumentCount == 0)
tzDate = createJSObject(ctx);
- } else if (argumentCount <= 2) {
+ else if (argumentCount <= 2) {
+ TimeUtilConverter converter(ctx);
std::string timezone = "";
- if ((argumentCount == 2) && !JSValueIsNull(ctx, arguments[1]) && !JSValueIsUndefined(ctx, arguments[1])) {
- timezone = converter.toString(arguments[1]);
- }
+ try {
+ if ((argumentCount == 2) && !JSValueIsNull(ctx, arguments[1]) && !JSValueIsUndefined(ctx, arguments[1]))
+ timezone = converter.toString(arguments[1]);
- if (JSValueIsNull(ctx, arguments[0]) || JSValueIsUndefined(ctx, arguments[0])) {
- tzDate = createJSObject(ctx, timezone);
- } else {
struct tm date = converter.toDateTm(arguments[0]);
LoggerD("date = " << date.tm_year << "." << date.tm_mon << "." << date.tm_mday);
LoggerD(date.tm_hour << ":" << date.tm_min << ":" << date.tm_sec);
prop.milliseconds = converter.toLong(result);
LoggerD("getMilliseconds = " << prop.milliseconds);
}
- tzDate = createJSObject(ctx, prop);
+ } catch (...) {
+ LoggerE("fail to convert optional arguments");
+ tzDate = createJSObject(ctx, timezone);
}
+ if (tzDate == NULL)
+ tzDate = createJSObject(ctx, prop);
} else {
- prop.year = converter.toLong(arguments[0]);
+ ArgumentValidator validator(ctx, argumentCount, arguments);
+ prop.year = validator.toLong(0);
if ((prop.year >= 0) && (prop.year <= 99))
prop.year += 1900;
- prop.month = converter.toLong(arguments[1]);
- prop.day = converter.toLong(arguments[2]);
- if (argumentCount > 3) {
- if (!JSValueIsUndefined(ctx, arguments[3]) && !JSValueIsNull(ctx, arguments[3]))
- prop.hours = converter.toLong(arguments[3]);
- if (argumentCount > 4) {
- if (!JSValueIsUndefined(ctx, arguments[4]) && !JSValueIsNull(ctx, arguments[4]))
- prop.minutes = converter.toLong(arguments[4]);
- if (argumentCount > 5) {
- if (!JSValueIsUndefined(ctx, arguments[5]) && !JSValueIsNull(ctx, arguments[5]))
- prop.seconds = converter.toLong(arguments[5]);
- if (argumentCount > 6) {
- if (!JSValueIsUndefined(ctx, arguments[6]) && !JSValueIsNull(ctx, arguments[6]))
- prop.milliseconds= converter.toLong(arguments[6]);
- if (argumentCount > 7) {
- if (!JSValueIsUndefined(ctx, arguments[7]) && !JSValueIsNull(ctx, arguments[7]))
- prop.timezone = converter.toString(arguments[7]);
- }
- }
- }
- }
- }
+ prop.month = validator.toLong(1);
+ prop.day = validator.toLong(2);
+ prop.hours = validator.toLong(3, true);
+ prop.minutes = validator.toLong(4, true);
+ prop.seconds = validator.toLong(5, true);
+ prop.milliseconds= validator.toLong(6, true);
+ prop.timezone = validator.toString(7, true);
tzDate = createJSObject(ctx, prop);
}
-
- if (tzDate) {
- JSStringRef ctorName = JSStringCreateWithUTF8CString("constructor");
- JSObjectSetProperty(ctx, tzDate, ctorName, constructor,
- kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete | kJSPropertyAttributeDontEnum, NULL);
- JSStringRelease(ctorName);
- return tzDate;
- }
} Catch(ConversionException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(ctx, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch (InvalidArgumentException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(ctx, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
} Catch (WrtDeviceApis::Commons::Exception) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
}
- return JSWebAPIErrorFactory::postException(ctx, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
+
+ if (tzDate == NULL)
+ tzDate = createJSObject(ctx, false);
+
+ JSStringRef ctorName = JSStringCreateWithUTF8CString("constructor");
+ JSObjectSetProperty(ctx, tzDate, ctorName, constructor,
+ kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete | kJSPropertyAttributeDontEnum, NULL);
+ JSStringRelease(ctorName);
+ return tzDate;
}
const JSClassRef JSTZDate::getClassRef()
{
JSValueRef JSTZDate::getTimezone(JSContextRef context, JSObjectRef function,
JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
LoggerD("entered");
+ TimeUtilConverter converter(context);
Try {
TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
TZDatePtr tzDate(privateObject->getObject());
std::string timezone = tzDate->getTimezone();
- TimeUtilConverter converter(context);
return converter.toJSValueRef(timezone);
} Catch(NullPointerException) {
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
}
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
+ return converter.toJSValueRef("Invalid Date");
}
JSValueRef JSTZDate::toTimezone(JSContextRef context, JSObjectRef function,
}
TZDatePtr tzDate(privateObject->getObject());
+ if ((timezone == "") || (!tzDate->isAvailableTimezone(timezone)))
+ ThrowMsg(InvalidArgumentException, "Unsupported Timezone.");
+
return createJSObject(context, tzDate->getTime(), timezone);
} catch(const BasePlatformException& err){
return JSWebAPIErrorFactory::postException(context, exception, err);
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
} Catch (InvalidArgumentException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
} Catch(ConversionException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
return diffTZDate(context, thisObject, argumentCount, arguments, exception, DIFFERENCE);
} catch(const BasePlatformException& err){
return JSWebAPIErrorFactory::postException(context, exception, err);
- } Catch(InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
} Catch(NullPointerException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
} Catch(ConversionException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
} Catch(ConversionException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
} Catch(ConversionException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
} Catch(ConversionException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
} Catch(ConversionException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
LoggerE("Exception: " << _rethrown_exception.GetMessage());
} Catch (OutOfRangeException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "The result is beyond the scope that TZDate can handle.");
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "The result is beyond the scope that TZDate can handle.");
}
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
} Catch (InvalidArgumentException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
}
JSValueRef JSTZDate::toLocaleDateString(JSContextRef context, JSObjectRef function,
JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
LoggerD("Entered");
+ TimeUtilConverter converter(context);
Try {
TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
if (!privateObject) {
ThrowMsg(NullPointerException, "Private object not initialized");
}
- TimeUtilConverter converter(context);
-
TZDatePtr tzDate(privateObject->getObject());
std::string result = tzDate->toDateString(true);
return converter.toJSValueRef(result);
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
}
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
+ return converter.toJSValueRef("Invalid Date");
}
JSValueRef JSTZDate::toLocaleTimeString(JSContextRef context, JSObjectRef function,
JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
LoggerD("Entered");
+ TimeUtilConverter converter(context);
Try {
TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
if (!privateObject) {
ThrowMsg(NullPointerException, "Private object not initialized");
}
- TimeUtilConverter converter(context);
-
TZDatePtr tzDate(privateObject->getObject());
std::string result = tzDate->toTimeString(true);
return converter.toJSValueRef(result);
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
}
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
+ return converter.toJSValueRef("Invalid Date");
}
JSValueRef JSTZDate::toLocaleString(JSContextRef context, JSObjectRef function,
JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
LoggerD("Entered");
+ TimeUtilConverter converter(context);
Try {
TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
if (!privateObject) {
ThrowMsg(NullPointerException, "Private object not initialized");
}
- TimeUtilConverter converter(context);
-
TZDatePtr tzDate(privateObject->getObject());
std::string result = tzDate->toString(true);
return converter.toJSValueRef(result);
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
}
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
+ return converter.toJSValueRef("Invalid Date");
}
JSValueRef JSTZDate::toDateString(JSContextRef context, JSObjectRef function,
JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
LoggerD("Entered");
+ TimeUtilConverter converter(context);
Try {
TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
if (!privateObject) {
ThrowMsg(NullPointerException, "Private object not initialized");
}
- TimeUtilConverter converter(context);
-
TZDatePtr tzDate(privateObject->getObject());
std::string result = tzDate->toDateString();
return converter.toJSValueRef(result);
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
}
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
+ return converter.toJSValueRef("Invalid Date");
}
JSValueRef JSTZDate::toTimeString(JSContextRef context, JSObjectRef function,
JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
LoggerD("Entered");
+ TimeUtilConverter converter(context);
Try {
TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
if (!privateObject) {
ThrowMsg(NullPointerException, "Private object not initialized");
}
- TimeUtilConverter converter(context);
-
TZDatePtr tzDate(privateObject->getObject());
std::string result = tzDate->toTimeString();
return converter.toJSValueRef(result);
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
}
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
+ return converter.toJSValueRef("Invalid Date");
}
JSValueRef JSTZDate::toString(JSContextRef context, JSObjectRef function,
JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
LoggerD("Entered");
+ TimeUtilConverter converter(context);
Try {
TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
if (!privateObject) {
ThrowMsg(NullPointerException, "Private object not initialized");
}
- TimeUtilConverter converter(context);
-
TZDatePtr tzDate(privateObject->getObject());
std::string result = tzDate->toString();
return converter.toJSValueRef(result);
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
}
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
+ return converter.toJSValueRef("Invalid Date");
}
JSValueRef JSTZDate::getDate(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
JSValueRef JSTZDate::getTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception,
TZDate::TZDateFields dateFields) {
+ TimeUtilConverter converter(context);
try {
TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*> (JSObjectGetPrivate(thisObject));
TZDatePtr tzDate(privateObject->getObject());
long retVal = tzDate->get(dateFields);
- TimeUtilConverter converter(context);
LoggerD(">>> retVal:" << retVal);
return converter.toJSValueRef(static_cast<int> (retVal));
} Catch(NullPointerException) {
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
}
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
+ return converter.toJSValueRef(0);
}
JSValueRef JSTZDate::setDate(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
} Catch (InvalidArgumentException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
} Catch(ConversionException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
}
- return JSValueMakeNull(context);
+ return JSValueMakeUndefined(context);
} //setDate()
JSValueRef JSTZDate::setFullYear(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
} Catch(ConversionException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
}
- return JSValueMakeNull(context);
+ return JSValueMakeUndefined(context);
} //setFullYear()
JSValueRef JSTZDate::setHours(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
} Catch(ConversionException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
}
- return JSValueMakeNull(context);
+ return JSValueMakeUndefined(context);
} //setHours()
JSValueRef JSTZDate::setMilliseconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
} Catch(ConversionException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
}
- return JSValueMakeNull(context);
+ return JSValueMakeUndefined(context);
} //setMilliseconds()
JSValueRef JSTZDate::setMinutes(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
} Catch(ConversionException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
}
- return JSValueMakeNull(context);
+ return JSValueMakeUndefined(context);
} //setMinutes()
JSValueRef JSTZDate::setMonth(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
} Catch(ConversionException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
}
- return JSValueMakeNull(context);
+ return JSValueMakeUndefined(context);
} //setMonth()
JSValueRef JSTZDate::setSeconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
} Catch(ConversionException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
}
- return JSValueMakeNull(context);
+ return JSValueMakeUndefined(context);
} //setSeconds()
ArgumentValidator validator(context, argumentCount, arguments);
long data = validator.toLong(0);
- if ((dateFields == TZDate::TZDATE_YEAR) && (data < 0))
- ThrowMsg(InvalidArgumentException, "Invalid Argument:Year can't be set to negative");
TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*> (JSObjectGetPrivate(thisObject));
TZDatePtr tzDate(privateObject->getObject());
tzDate->set(dateFields,data);
- return JSValueMakeNull(context);
+ return JSValueMakeUndefined(context);
} //setTZDateValue
JSValueRef JSTZDate::getUTCDate(JSContextRef context, JSObjectRef function,
JSValueRef JSTZDate::getUTCTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, TZDate::TZDateFields DateFields, JSValueRef * exception) {
LoggerD("Entered");
+ TimeUtilConverter converter(context);
Try {
TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
if (!privateObject) {
ThrowMsg(NullPointerException, "Private object not initialized");
}
- TimeUtilConverter converter(context);
-
TZDatePtr tzDate(privateObject->getObject());
long result = tzDate->getUTC(DateFields);
LoggerE("Exception: " << _rethrown_exception.GetMessage());
} Catch (InvalidArgumentException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
}
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
+ return converter.toJSValueRef(0);
}
JSValueRef JSTZDate::setUTCDate(JSContextRef context, JSObjectRef function,
else
data = converter.toLong(arguments[0]);
- if ((dateFields == TZDate::TZDATE_YEAR) && (data < 0))
- ThrowMsg(InvalidArgumentException, "Invalid Argument:Year can't be set to negative");
TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
if (!privateObject) {
TZDatePtr tzDate(privateObject->getObject());
tzDate->setUTC(dateFields, data);
-
- return JSValueMakeNull(context);
} Catch(NullPointerException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
} Catch(ConversionException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
}
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
+ return JSValueMakeUndefined(context);
}
JSValueRef JSTZDate::getTimezoneAbbreviation(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
LoggerD("entered");
+ TimeUtilConverter converter(context);
Try {
TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
if (!privateObject) {
ThrowMsg(NullPointerException, "Private object not initialized");
}
- TimeUtilConverter converter(context);
-
TZDatePtr tzDate(privateObject->getObject());
std::string result;
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
}
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
+ return converter.toJSValueRef("Invalid Date");
}
JSValueRef JSTZDate::secondsFromUTC(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
}
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
}
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
}
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
}
static const JSClassDefinition* getClassInfo();
static const JSClassRef getClassRef();
- static JSObjectRef createJSObject(JSContextRef context);
+ static JSObjectRef createJSObject(JSContextRef context, const bool isNotNull = true);
static JSObjectRef createJSObject(JSContextRef context, const std::string &timezone);
static JSObjectRef createJSObject(JSContextRef context, const double milliseconds, const std::string &timezone);
static JSObjectRef createJSObject(JSContextRef context, const TZDateProperties &properties);
if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_TIMEDURATION_LENGTH)) {
return convert.toJSValueRef(static_cast<double>(convert.getDurationLength(object)));
} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_TIMEDURATION_UNIT)) {
- TimeDurationPrivObject* privateObject = static_cast<TimeDurationPrivObject*>(JSObjectGetPrivate(object));
- if (!privateObject) {
- LoggerE("Private object is not set.");
- ThrowMsg(ConversionException, "Private object not initialized");
- }
-
- DurationPropertiesPtr duration = privateObject->getObject();
- std::string unitStr = duration->unitStr;
- if (duration->unit != WRONG_UNIT)
- duration->unitStr = convert.toDurationUnitString(duration->unit);
- return convert.toJSValueRef(duration->unitStr);
+ return convert.toJSValueRef(convert.toDurationUnitString(convert.getDurationUnit(object)));
}
} Catch (ConversionException) {
LoggerE("ConversionException: " << _rethrown_exception.GetMessage());
if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_TIMEDURATION_LENGTH)) {
duration->length = convert.toLongLong(value);
+ return true;
} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_TIMEDURATION_UNIT)) {
- duration->unitStr = convert.toString(value);
- duration->unit = convert.toDurationUnit(duration->unitStr);
- if (duration->unit == WRONG_UNIT)
- LoggerE("Wrong Unit");
- } else
- return false;
-
- return true;
+ std::string unitStr = convert.toString(value);
+ short unit = convert.toDurationUnit(unitStr);
+ if ((unit == MSECS_UNIT) && (unitStr != "MSECS"))
+ ThrowMsg(InvalidArgumentException, unitStr + "is not one of TimeDurationUnit");
+ duration->unit = unit;
+ return true;
+ }
} Catch (NullPointerException) {
LoggerE("NullPointerException: " << _rethrown_exception.GetMessage());
} Catch (ConversionException) {
JSObjectRef JSTimeDuration::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) {
LoggerD("entered");
TimeUtilConverter convert(ctx);
+ JSObjectRef timeDuration = NULL;
Try {
DurationProperties duration;
if (argumentCount == 0)
if (argumentCount > 1) {
if (!JSValueIsUndefined(ctx, arguments[1]) && !JSValueIsNull(ctx, arguments[1])) {
- duration.unitStr = convert.toString(arguments[1]);
- duration.unit = convert.toDurationUnit(duration.unitStr);
- if (duration.unit == WRONG_UNIT)
- ThrowMsg(ConversionException, "Argument(unit) is invalid(wrong type unit)");
+ duration.unit = convert.toDurationUnit(convert.toString(arguments[1]));
}
}
- JSObjectRef timeDuration = createJSObject(ctx, duration);
- if (timeDuration) {
- JSStringRef ctorName = JSStringCreateWithUTF8CString("constructor");
- JSObjectSetProperty(ctx, timeDuration, ctorName, constructor,
- kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete | kJSPropertyAttributeDontEnum, NULL);
- JSStringRelease(ctorName);
- return timeDuration;
- }
+ timeDuration = createJSObject(ctx, duration);
} Catch(NullPointerException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(ctx, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(WrtDeviceApis::Commons::UnknownException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(ctx, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
} Catch(ConversionException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(ctx, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch (InvalidArgumentException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(ctx, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
} Catch (WrtDeviceApis::Commons::Exception) {
LoggerW("Trying to get incorrect value");
}
- return JSWebAPIErrorFactory::postException(ctx, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
+ if (timeDuration == NULL)
+ timeDuration = JSObjectMake(ctx, getClassRef(), NULL);
+
+ JSStringRef ctorName = JSStringCreateWithUTF8CString("constructor");
+ JSObjectSetProperty(ctx, timeDuration, ctorName, constructor,
+ kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete | kJSPropertyAttributeDontEnum, NULL);
+ JSStringRelease(ctorName);
+ return timeDuration;
}
JSValueRef JSTimeDuration::diffTimeDuration(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception, CompareType type) {
} Catch(ConversionException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
- } Catch (UnsupportedException) {
- LoggerE("JSTimeUtil::hasInstance NotSupportedException");
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_SUPPORTED_ERROR , "Not Support");
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
} Catch (WrtDeviceApis::Commons::Exception) {
} Catch(ConversionException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
- } Catch (UnsupportedException) {
- LoggerE("JSTimeUtil::hasInstance NotSupportedException");
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_SUPPORTED_ERROR , "Not Support");
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
} Catch (WrtDeviceApis::Commons::Exception) {
} Catch(ConversionException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
- } Catch (UnsupportedException) {
- LoggerE("JSTimeUtil::hasInstance NotSupportedException");
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_SUPPORTED_ERROR , "Not Support");
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
} Catch (WrtDeviceApis::Commons::Exception) {
} Catch(ConversionException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
- } Catch (UnsupportedException) {
- LoggerE("JSTimeUtil::hasInstance NotSupportedException");
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_SUPPORTED_ERROR , "Not Support");
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
} Catch (WrtDeviceApis::Commons::Exception) {
TimeUtilPrivObject* priv = static_cast<TimeUtilPrivObject*>(JSObjectGetPrivate(object));
JSObjectSetPrivate(object, NULL);
LoggerD("Deleting timeutil");
- delete priv;
+ if (priv)
+ delete priv;
}
bool JSTimeUtil::hasInstance(JSContextRef context,
LoggerE("Exception: " << _rethrown_exception.GetMessage());
} Catch(NullPointerException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch (WrtDeviceApis::Commons::Exception) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
}
}
return converter.toJSValueRef(timezonesArray);
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");;
- } Catch (UnsupportedException) {
- LoggerE("JSTimeUtil::hasInstance NotSupportedException");
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_SUPPORTED_ERROR , "Not Support");
} Catch (NullPointerException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(ConversionException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");;
- } Catch (UnsupportedException) {
- LoggerE("JSTimeUtil::hasInstance NotSupportedException");
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_SUPPORTED_ERROR , "Not Support");
} Catch (NullPointerException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
TimeUtilConverter converter(context);
return converter.toJSValueRef(timeFormat);
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
- } Catch (UnsupportedException) {
- LoggerE("JSTimeUtil::hasInstance NotSupportedException");
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_SUPPORTED_ERROR , "Not Support");
} Catch (NullPointerException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch(ConversionException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
- } Catch (InvalidArgumentException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
- } Catch (UnsupportedException) {
- LoggerE("JSTimeUtil::hasInstance NotSupportedException");
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_SUPPORTED_ERROR , "Not Support");
} Catch (PlatformException) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
} Catch (WrtDeviceApis::Commons::Exception) {
}
else {
myCalendar = NULL;
- ThrowMsg(Commons::PlatformException, "Can't make to ICU Calendar");
}
}
}
UErrorCode ec = U_ZERO_ERROR;
TimeUtilTools util;
- myCalendar = Calendar::createInstance(util.makeTimeZone(timezone) ,ec);
+ TimeZone *tz = util.makeTimeZone(timezone);
+ if (isAvailableTimezone(tz))
+ myCalendar = Calendar::createInstance(tz ,ec);
+ else {
+ if (tz)
+ delete tz;
+ myCalendar = Calendar::createInstance(ec);
+ }
if (U_SUCCESS(ec)) {
- TimeUtilTools util;
util.printDate(myCalendar);
- if (!util.compareTimeZoneName(myCalendar, timezone)) {
- myCalendar = NULL;
- ThrowMsg(Commons::InvalidArgumentException, "Unsupported Timezone.");
- }
} else {
myCalendar = NULL;
- ThrowMsg(Commons::PlatformException, "Can't make to ICU Calendar");
}
}
TimeUtilTools util;
myCalendar = _makeCalendar(properties);
- if (myCalendar != NULL) {
- if (!util.compareTimeZoneName(myCalendar, properties.timezone)) {
- delete myCalendar;
- myCalendar = NULL;
- ThrowMsg(Commons::InvalidArgumentException, "Unsupported Timezone.");
- }
- } else
- ThrowMsg(Commons::PlatformException, "Can't make to ICU Calendar");
}
TZDate::~TZDate()
return FALSE;
}
+bool TZDate::isAvailableTimezone(const std::string &timezone) {
+ TimeUtilTools util;
+ TimeZone *tz = util.makeTimeZone(timezone);
+
+ bool result = isAvailableTimezone(tz);
+
+ if (tz)
+ delete tz;
+ return result;
+}
+
+bool TZDate::isAvailableTimezone(TimeZone *tz) {
+ TimeUtilTools util;
+ bool result = true;
+ UnicodeString id;
+ tz->getID(id);
+
+ if (util.toString(id) == "Etc/Unknown")
+ result = false;
+
+ return result;
+}
+
Calendar *TZDate::_makeCalendar(const TZDateProperties &properties)
{
LoggerD("entered");
TimeUtilTools util;
Calendar *cal = NULL;
- if (properties.timezone == "")
+ if ((properties.timezone == "") || !isAvailableTimezone(properties.timezone))
cal = Calendar::createInstance(ec);
else
cal = Calendar::createInstance(util.makeTimeZone(properties.timezone) ,ec);
std::string TZDate::_getTimezoneName(Calendar *cal)
{
+ if (cal == NULL)
+ ThrowMsg(Commons::UnknownException, "Invalid Date");
+
UnicodeString id;
TimeUtilTools util;
}
TZDateProperties TZDate::toTimezone(const std::string timezone) {
+ if (myCalendar == NULL)
+ ThrowMsg(Commons::UnknownException, "Invalid Date");
+
TimeUtilTools util;
Calendar *newCalendar = myCalendar->clone();
- newCalendar->setTimeZone(*(util.makeTimeZone(timezone)));
+ if (newCalendar == NULL)
+ ThrowMsg(Commons::PlatformException, "Can't create new calendar");
- if (!util.compareTimeZoneName(newCalendar, timezone)) {
- delete newCalendar;
- ThrowMsg(Commons::InvalidArgumentException, "Unsupported Timezone.");
- }
+ newCalendar->setTimeZone(*(util.makeTimeZone(timezone)));
- TZDateProperties newProps = _makeProperties(newCalendar);
+ TZDateProperties newProps = _makeProperties(newCalendar);
delete newCalendar;
return newProps;
{
LoggerD("<<<");
+ if (cal == NULL)
+ ThrowMsg(Commons::UnknownException, "Invalid Date");
+
if (_convertDateField(field) == UCAL_FIELD_COUNT){
LoggerD(">>> UCAL_FIELD_COUNT");
return -1;
if (_convertDateField(field) == UCAL_FIELD_COUNT)
return;
+ if (myCalendar == NULL)
+ ThrowMsg(Commons::UnknownException, "Invalid Date");
+
+ if ((field == TZDATE_YEAR) && (value < 0)) {
+ LoggerE("Invalid Argument:Year can't be set to negative");
+ delete myCalendar;
+ myCalendar = NULL;
+ return;
+ }
TimeUtilTools util;
myCalendar->set(_convertDateField(field), util.toint32_t(value));
LoggerD("Field : " << field << " value : " << get(field));
try {
utcCalendar = Calendar::createInstance(*(TimeZone::getGMT()),ec);
- if (!U_SUCCESS(ec))
+ if (!U_SUCCESS(ec) || (utcCalendar == NULL))
ThrowMsg(Commons::PlatformException, "Can't create utcCalendar");
+ if (myCalendar == NULL)
+ ThrowMsg(Commons::UnknownException, "Invalid Date");
+
UDate date = myCalendar->getTime(ec);
if (!U_SUCCESS(ec))
ThrowMsg(Commons::PlatformException, "Can't get time of myCalendar");
TimeUtilTools util;
UErrorCode ec = U_ZERO_ERROR;
+ if (myCalendar == NULL)
+ ThrowMsg(Commons::UnknownException, "Invalid Date");
+
Calendar *otherCalendar = _makeCalendar(prop);
+ if (otherCalendar == NULL)
+ ThrowMsg(Commons::PlatformException, "Other calendar is null");
+
if (!util.compareTimeZoneName(otherCalendar, prop.timezone)) {
delete otherCalendar;
ThrowMsg(Commons::InvalidArgumentException, "Unsupported Timezone.");
TZDateProperties TZDate::addDuration(const DurationProperties &duration) {
LoggerD("entered");
+ if (myCalendar == NULL)
+ ThrowMsg(Commons::UnknownException, "Invalid Date");
+
UErrorCode ec = U_ZERO_ERROR;
TimeUtilTools util;
Calendar *cal = myCalendar->clone();
+ if (cal == NULL)
+ ThrowMsg(Commons::PlatformException, "Can't clone my calendar");
+
long long length = duration.length;
short unit = duration.unit;
int msec=0, sec=0, min=0, hour=0;
double TZDate::getTime() {
LoggerD("entered");
+ if (myCalendar == NULL)
+ ThrowMsg(Commons::UnknownException, "Invalid Date");
+
UErrorCode ec = U_ZERO_ERROR;
UDate date = myCalendar->getTime(ec);
bool TZDate::setTime(const double time) {
LoggerD("entered");
+ if (myCalendar == NULL)
+ ThrowMsg(Commons::UnknownException, "Invalid Date");
+
UErrorCode ec = U_ZERO_ERROR;
myCalendar->setTime(static_cast<UDate>(time), ec);
}
std::string TZDate::toDateString(bool bLocale) {
+ if (myCalendar == NULL)
+ ThrowMsg(Commons::UnknownException, "Invalid Date");
+
UErrorCode ec = U_ZERO_ERROR;
UnicodeString str;
TimeUtilTools util;
ThrowMsg(Commons::PlatformException, "can't make SimpleDateFormat or can't get time");
}
- std::string TZDate::toTimeString(bool bLocale) {
+ std::string TZDate::toTimeString(bool bLocale) {
+ if (myCalendar == NULL)
+ ThrowMsg(Commons::UnknownException, "Invalid Date");
+
UErrorCode ec = U_ZERO_ERROR;
UnicodeString str;
TimeUtilTools util;
}
std::string TZDate::toString(bool bLocale) {
+ if (myCalendar == NULL)
+ ThrowMsg(Commons::UnknownException, "Invalid Date");
+
LoggerD("entered");
UErrorCode ec = U_ZERO_ERROR;
std::string TZDate::getTimezoneAbbreviation() {
LoggerD("entered");
+ if (myCalendar == NULL)
+ ThrowMsg(Commons::UnknownException, "Invalid Date");
UErrorCode ec = U_ZERO_ERROR;
UnicodeString str;
long TZDate::secondsFromUTC() {
LoggerD("entered");
+ if (myCalendar == NULL)
+ ThrowMsg(Commons::UnknownException, "Invalid Date");
+
UErrorCode ec = U_ZERO_ERROR;
TimeUtilTools util;
bool TZDate::isDST() {
LoggerD("entered");
+ if (myCalendar == NULL)
+ ThrowMsg(Commons::UnknownException, "Invalid Date");
+
UErrorCode ec = U_ZERO_ERROR;
TimeUtilTools util;
UBool result = myCalendar->inDaylightTime(ec);
TZDateProperties TZDate::getDSTTransition(DSTTransition trans) {
LoggerD("entered");
+ if (myCalendar == NULL)
+ ThrowMsg(Commons::UnknownException, "Invalid Date");
+
TimeUtilTools util;
UErrorCode ec = U_ZERO_ERROR;
TZDateProperties props;
#include <ctime>
#include <unicode/calendar.h>
+#include <unicode/timezone.h>
#include "TZDateProperties.h"
#include "DurationProperties.h"
NEXT_TRANSITION
};
- TZDate(const bool isNotNull = TRUE);
+ TZDate(const bool isNotNull = true);
TZDate(const std::string &timezone);
TZDate(const TZDateProperties &properties);
virtual ~TZDate();
- virtual bool isNull();
- virtual long get(const TZDateFields field);
- virtual std::string getTimezone();
- virtual TZDateProperties toTimezone(const std::string timezone);
- virtual void set(const TZDateFields field, const long value);
-
- virtual long getUTC(const TZDateFields field);
- virtual void setUTC(const TZDateFields field, const long value);
-
- virtual long long difference(const TZDateProperties &prop);
- virtual TZDateProperties addDuration(const DurationProperties &duration);
- virtual std::string getUTCTimezoneName();
- virtual std::string getLocalTimezoneName();
- virtual TZDateProperties makeProperties();
-
- virtual double getTime();
- virtual bool setTime(const double time);
- virtual std::string toDateString(bool bLocale = false) ;
- virtual std::string toTimeString(bool bLocale = false);
- virtual std::string toString(bool bLocale = false);
-
- virtual std::string getTimezoneAbbreviation();
- virtual long secondsFromUTC();
- virtual bool isDST();
- virtual TZDateProperties getDSTTransition(DSTTransition trans);
-
+ bool isNull();
+ long get(const TZDateFields field);
+ std::string getTimezone();
+ TZDateProperties toTimezone(const std::string timezone);
+ void set(const TZDateFields field, const long value);
+
+ long getUTC(const TZDateFields field);
+ void setUTC(const TZDateFields field, const long value);
+
+ long long difference(const TZDateProperties &prop);
+ TZDateProperties addDuration(const DurationProperties &duration);
+ std::string getUTCTimezoneName();
+ std::string getLocalTimezoneName();
+ TZDateProperties makeProperties();
+
+ double getTime();
+ bool setTime(const double time);
+ std::string toDateString(bool bLocale = false) ;
+ std::string toTimeString(bool bLocale = false);
+ std::string toString(bool bLocale = false);
+
+ std::string getTimezoneAbbreviation();
+ long secondsFromUTC();
+ bool isDST();
+ TZDateProperties getDSTTransition(DSTTransition trans);
+ bool isAvailableTimezone(const std::string &timezone);
+ bool isAvailableTimezone(icu::TimeZone *tz);
private:
long _get(const TZDateFields field, icu::Calendar *cal);
std::string _getTimezoneName(icu::Calendar *cal);
DurationProperties duration;
duration.length = getDurationLength(value);
duration.unit = getDurationUnit(value);
- if (duration.unit == WRONG_UNIT)
- ThrowMsg(Commons::ConversionException, "Wrong Unit");
return duration;
}
}
-std::string TimeUtilConverter::getDurationUnitString(JSValueRef value) {
- if (JSValueIsNull(m_context, value) || JSValueIsUndefined(m_context, value) || !JSValueIsObjectOfClass(m_context, value, JSTimeDuration::getClassRef())) {
- ThrowMsg(Commons::ConversionException,
- "Wrong input type");
- }
- JSObjectRef obj = toJSObjectRef(value);
- return getDurationUnitString(obj);
-}
-
-std::string TimeUtilConverter::getDurationUnitString(JSObjectRef object) {
- TimeDurationPrivObject* privateObject = static_cast<TimeDurationPrivObject*>(JSObjectGetPrivate(object));
- if (!privateObject) {
- LoggerE("Private object is not set.");
- ThrowMsg(Commons::ConversionException, "Private object not initialized");
- }
-
- DurationPropertiesPtr duration = privateObject->getObject();
-
- return duration->unitStr;
-
-}
-
short TimeUtilConverter::toDurationUnit(std::string strUnit) {
if (!strUnit.compare("DAYS"))
return DAYS_UNIT;
return MINUTES_UNIT;
else if (!strUnit.compare("HOURS"))
return HOURS_UNIT;
- else if (!strUnit.compare("MSECS"))
- return MSECS_UNIT;
else
- return WRONG_UNIT;
+ return MSECS_UNIT;
}
std::string TimeUtilConverter::toDurationUnitString(short unit) {
case HOURS_UNIT:
return "HOURS";
case MSECS_UNIT:
- return "MSECS";
default:
- return "";
+ return "MSECS";
}
}
long long TimeUtilConverter::convertDurationLength(DurationProperties duration, short unit) {
- if ((duration.unit == WRONG_UNIT) || (unit == WRONG_UNIT))
- ThrowMsg(Commons::ConversionException, "Wrong Unit");
if (duration.unit < unit)
ThrowMsg(Commons::ConversionException, "Unit is larger than duration's unit");
result.length /= 24;
// intentional fall-through
}
- result.unitStr = toDurationUnitString(result.unit);
return result;
}
long long getDurationLength(JSObjectRef object);
short getDurationUnit(JSValueRef value);
short getDurationUnit(JSObjectRef object);
- std::string getDurationUnitString(JSValueRef value);
- std::string getDurationUnitString(JSObjectRef object);
short toDurationUnit(std::string strUnit);
std::string toDurationUnitString(short unit);
long long convertDurationLength(DurationProperties duration, short unit);