Name: wrt-plugins-tizen
Summary: JavaScript plugins for WebRuntime
-Version: 0.4.56
+Version: 0.4.57
Release: 0
Group: Development/Libraries
License: Apache License, Version 2.0
(daysOfTheWeek[i]!="TU") && (daysOfTheWeek[i]!="WE") &&
(daysOfTheWeek[i]!="TH") && (daysOfTheWeek[i]!="FR") &&
(daysOfTheWeek[i]!="SA") ) {
- throw TypeMismatchException("Invalid days of the week value.");
+ // remove unacceptable data from vector
+ daysOfTheWeek.erase(std::remove(daysOfTheWeek.begin(), daysOfTheWeek.end(), daysOfTheWeek[i]), daysOfTheWeek.end());
}
}
}
delay = alarmPtr->getDelay();
+ if (delay < 0) {
+ throw InvalidValuesException("Alarm scheduling failed : delay cannot be negative value.");
+ }
+
long interval = alarmPtr->getPeriod();
service = alarmPtr->getService();
service_set_app_id(service, appId.c_str());
if(err == ALARM_ERROR_INVALID_PARAMETER) {
return JSValueMakeNull(ctx);
} else {
- throw UnknownException("Unknown exception occurred.");
+ throw UnknownException("Unknown exception occurred. fail to get scheduled date");
}
}
LoggerI("nextTime: "<<nextTime<<", currentTime: "<<currentTime<<", result: "<<result);
if(result < 0) {
- // It is impossible
- throw UnknownException("Unknown exception occurred.");
+ return JSValueMakeNull(ctx);
}
TIME_TRACER_ITEM_END(__FUNCTION__, 0);
DPL::Mutex::ScopedLock lock(&m_killMapLock);
std::map<int, EventApplicationKillPtr>::iterator it = m_killEventMap.find(pid);
- if (it == m_killEventMap.end())
+ if (it == m_killEventMap.end()) {
return;
+ }
EventApplicationKillPtr event = it->second;
m_killEventMap.erase(it);
}
}
+// Because of platform issue, some termination event is not come to app_manager_set_app_context_event_cb().
+// To prevent blocking issue by wating callback function, add termination checking code.
+// this function check whether callback is called or not after 3 sec. if callback is not called,
+// calls callback function forcibily.
+// After fixing platform issue, below code should be removed
+
+typedef struct {
+ ApplicationManager* appManager;
+ int pid;
+ EventApplicationKillPtr event;
+} KILL_DATA_T;
+
+gboolean check_terminate_callback (gpointer user_data)
+{
+ //EventApplicationKillPtr event = (EventApplicationKillPtr)data;
+ KILL_DATA_T* data = (KILL_DATA_T*)user_data;
+
+ char * appId = NULL;
+ if (app_manager_get_app_id(data->pid, &appId) == APP_MANAGER_ERROR_NONE) {
+ // if context is still alive, error callback should be called.
+ data->event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
+ }
+
+ data->appManager->invokeManualAnswerKill(data->pid);
+
+ return false;
+}
+
+
void ApplicationManager::OnRequestReceived(const EventApplicationKillPtr& event)
{
Try
return;
}
+ // Because of platform issue, some termination event is not come to app_manager_set_app_context_event_cb().
+ // To prevent blocking issue by wating callback function, add termination checking code.
+ // this function check whether callback is called or not after 3 sec. if callback is not called,
+ // calls callback function forcibily.
+ // After fixing platform issue, below code should be removed
+ {
+ KILL_DATA_T *data = new KILL_DATA_T;
+ data->pid = pid;
+ data->appManager = this;
+ data->event = event;
+ g_timeout_add(3000, check_terminate_callback, (void*)data);
+ }
+
DPL::Mutex::ScopedLock lock(&m_killMapLock);
m_killEventMap[pid] = event;
event->switchToManualAnswer();
JSStaticValue JSCalendarEvent::m_property[] = {
{ TIZEN_CALENDAR_EVENT_ID, getPropertyId, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ TIZEN_CALENDAR_EVENT_IS_DETACHED, getPropertyIsDetached, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+ { TIZEN_CALENDAR_EVENT_AVAILABILITY, getPropertyAvailability, setPropertyAvailability, kJSPropertyAttributeNone | kJSPropertyAttributeDontDelete },
{ TIZEN_CALENDAR_EVENT_RECURRENCE_RULE, getPropertyRecurrenceRule, setPropertyRecurrenceRule, kJSPropertyAttributeNone | kJSPropertyAttributeDontDelete },
{ 0, 0, 0, 0 }
if (NULL==m_calendar) {
m_calendar = CalendarFactory::getInstance().createCalendarObject();
- LoggerD("Static calendar for event created.");
+ m_calendar->setType(CalendarEvent::EVENT_TYPE);
+ LoggerD("Static calendar for event created.");
}
-
- if (m_calendar) {
- m_calendar->setType(CalendarEvent::EVENT_TYPE);
- LoggerD("Calendar object type is set to event.");
- }
}
void JSCalendarEvent::finalize(JSObjectRef object)
eventStr = converter.toString(arguments[0]);
format = converter.toVObjectFormat(converter.toString(arguments[1]));
+ if (NULL==m_calendar) {
+ m_calendar = CalendarFactory::getInstance().createCalendarObject();
+ m_calendar->setType(CalendarEvent::EVENT_TYPE);
+ LoggerD("Static calendar for event created.");
+ }
+
IEventCreateEventFromStringPtr dplEvent(new IEventCreateEventFromString());
dplEvent->setEventString(eventStr);
dplEvent->setFormat(format);
Try
{
CalendarEventPtr event = getPrivateObject(object);
- if(CalendarEvent::EVENT_TYPE != event->getCalendarType()) {
- return JSValueMakeUndefined(context);
- }
-
Converter converter(context);
return converter.toJSValueRef(event->getIsDetached());
}
return JSValueMakeUndefined(context);
}
+JSValueRef JSCalendarEvent::getPropertyAvailability(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
+{
+ Try
+ {
+ CalendarConverter converter(context);
+ CalendarEventPtr event = getPrivateObject(object);
+ std::string availability = converter.toTizenValue(event->getAvailability());
+ return converter.toJSValueRef(availability);
+ }
+ Catch(Exception)
+ {
+ LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+ }
+ return JSValueMakeUndefined(context);
+}
+
+bool JSCalendarEvent::setPropertyAvailability(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef value,
+ JSValueRef* exception)
+{
+ CalendarEventPtr event(NULL);
+ Try
+ {
+ event = getPrivateObject(object);
+ CalendarConverter converter(context);
+ CalendarEvent::EventAvailability availability = converter.toEventAvailability(converter.toString(value));
+ event->setAvailability(availability);
+ return true;
+ }
+ Catch(Exception)
+ {
+ LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+ }
+
+ return true;
+}
+
JSValueRef JSCalendarEvent::getPropertyRecurrenceRule(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
JSObjectRef object,
JSStringRef propertyName,
JSValueRef* exception);
+ static JSValueRef getPropertyAvailability(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception);
+ static bool setPropertyAvailability(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef value,
+ JSValueRef* exception);
static JSValueRef getPropertyRecurrenceRule(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
JSStaticValue JSCalendarItemProperties::m_property[] = {
// Item Properties
- { TIZEN_CALENDAR_ITEM_DESCRIPTION, getPropertyDescription, setPropertyDescription, kJSPropertyAttributeNone },
- { TIZEN_CALENDAR_ITEM_SUMMARY, getPropertySummary, setPropertySummary, kJSPropertyAttributeNone },
- { TIZEN_CALENDAR_ITEM_START_DATE, getPropertyStartDate, setPropertyStartDate, kJSPropertyAttributeNone },
- { TIZEN_CALENDAR_ITEM_LOCATION, getPropertyLocation, setPropertyLocation, kJSPropertyAttributeNone },
- { TIZEN_CALENDAR_ITEM_GEOLOCATION, getPropertyGeolocation, setPropertyGeolocation, kJSPropertyAttributeNone },
- { TIZEN_CALENDAR_ITEM_ORGANIZER, getPropertyOrganizer, setPropertyOrganizer, kJSPropertyAttributeNone },
- { TIZEN_CALENDAR_ITEM_VISIBILITY, getPropertyVisibility, setPropertyVisibility, kJSPropertyAttributeNone },
- { TIZEN_CALENDAR_ITEM_STATUS, getPropertyStatus, setPropertyStatus, kJSPropertyAttributeNone },
- { TIZEN_CALENDAR_ITEM_ALARMS, getPropertyAlarms, setPropertyAlarms, kJSPropertyAttributeNone },
- { TIZEN_CALENDAR_ITEM_CATEGORIES, getPropertyCategories, setPropertyCategories, kJSPropertyAttributeNone },
- { TIZEN_CALENDAR_ITEM_DURATION, getPropertyDuration, setPropertyDuration, kJSPropertyAttributeNone },
- { TIZEN_CALENDAR_ITEM_IS_ALL_DAY, getPropertyIsAllDay, setPropertyIsAllDay, kJSPropertyAttributeNone },
- { TIZEN_CALENDAR_ITEM_ATTENDEES, getPropertyAttendees, setPropertyAttendees, kJSPropertyAttributeNone },
- { TIZEN_CALENDAR_EVENT_AVAILABILITY, getPropertyAvailability, setPropertyAvailability, kJSPropertyAttributeNone },
- { TIZEN_CALENDAR_TASK_DUE_DATE, getPropertyDueDate, setPropertyDueDate, kJSPropertyAttributeNone },
- { TIZEN_CALENDAR_TASK_COMPLETED_DATE, getPropertyCompletedDate, setPropertyCompletedDate, kJSPropertyAttributeNone },
- { TIZEN_CALENDAR_TASK_PROGRESS, getPropertyProgress, setPropertyProgress, kJSPropertyAttributeNone },
- { TIZEN_CALENDAR_ITEM_PRIORITY, getPropertyPriority, setPropertyPriority, kJSPropertyAttributeNone },
- { TIZEN_CALENDAR_EVENT_END_DATE, getPropertyEndDate, setPropertyEndDate, kJSPropertyAttributeNone },
+ { TIZEN_CALENDAR_ITEM_DESCRIPTION, getPropertyDescription, setPropertyDescription, kJSPropertyAttributeNone | kJSPropertyAttributeDontDelete },
+ { TIZEN_CALENDAR_ITEM_SUMMARY, getPropertySummary, setPropertySummary, kJSPropertyAttributeNone | kJSPropertyAttributeDontDelete },
+ { TIZEN_CALENDAR_ITEM_START_DATE, getPropertyStartDate, setPropertyStartDate, kJSPropertyAttributeNone | kJSPropertyAttributeDontDelete },
+ { TIZEN_CALENDAR_ITEM_LOCATION, getPropertyLocation, setPropertyLocation, kJSPropertyAttributeNone | kJSPropertyAttributeDontDelete },
+ { TIZEN_CALENDAR_ITEM_GEOLOCATION, getPropertyGeolocation, setPropertyGeolocation, kJSPropertyAttributeNone | kJSPropertyAttributeDontDelete },
+ { TIZEN_CALENDAR_ITEM_ORGANIZER, getPropertyOrganizer, setPropertyOrganizer, kJSPropertyAttributeNone | kJSPropertyAttributeDontDelete },
+ { TIZEN_CALENDAR_ITEM_VISIBILITY, getPropertyVisibility, setPropertyVisibility, kJSPropertyAttributeNone | kJSPropertyAttributeDontDelete },
+ { TIZEN_CALENDAR_ITEM_STATUS, getPropertyStatus, setPropertyStatus, kJSPropertyAttributeNone | kJSPropertyAttributeDontDelete },
+ { TIZEN_CALENDAR_ITEM_ALARMS, getPropertyAlarms, setPropertyAlarms, kJSPropertyAttributeNone | kJSPropertyAttributeDontDelete },
+ { TIZEN_CALENDAR_ITEM_CATEGORIES, getPropertyCategories, setPropertyCategories, kJSPropertyAttributeNone | kJSPropertyAttributeDontDelete },
+ { TIZEN_CALENDAR_ITEM_DURATION, getPropertyDuration, setPropertyDuration, kJSPropertyAttributeNone | kJSPropertyAttributeDontDelete },
+ { TIZEN_CALENDAR_ITEM_IS_ALL_DAY, getPropertyIsAllDay, setPropertyIsAllDay, kJSPropertyAttributeNone | kJSPropertyAttributeDontDelete },
+ { TIZEN_CALENDAR_ITEM_ATTENDEES, getPropertyAttendees, setPropertyAttendees, kJSPropertyAttributeNone | kJSPropertyAttributeDontDelete },
+ { TIZEN_CALENDAR_TASK_DUE_DATE, getPropertyDueDate, setPropertyDueDate, kJSPropertyAttributeNone | kJSPropertyAttributeDontDelete },
+ { TIZEN_CALENDAR_ITEM_PRIORITY, getPropertyPriority, setPropertyPriority, kJSPropertyAttributeNone | kJSPropertyAttributeDontDelete },
+ { TIZEN_CALENDAR_EVENT_END_DATE, getPropertyEndDate, setPropertyEndDate, kJSPropertyAttributeNone | kJSPropertyAttributeDontDelete },
{ TIZEN_CALENDAR_EVENT_LAST_MODIFICATION_DATE, getPropertyLastModificationDate, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ TIZEN_CALENDAR_ITEM_CALENDAR_ID, getPropertyCalendarId, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
LoggerI("start time before converted to TZDate: "<<item->getStartTime()<<", time zone: "<<item->getTimeZone());
if (UNDEFINED_TIME==item->getStartTime()) {
- return JSValueMakeUndefined(context);
+ return JSValueMakeNull(context);
} else {
return timeConverter.toJSValueRefTZDate((double)(item->getStartTime()*1000.0), item->getTimeZone());
}
return true;
}
-JSValueRef JSCalendarItemProperties::getPropertyAvailability(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
-{
- Try
- {
- CalendarConverter converter(context);
- CalendarEventPtr event = getPrivateObject(object);
- std::string availability = converter.toTizenValue(event->getAvailability());
- return converter.toJSValueRef(availability);
- }
- Catch(Exception)
- {
- LoggerW("Exception: "<<_rethrown_exception.GetMessage());
- }
- return JSValueMakeUndefined(context);
-}
-
-bool JSCalendarItemProperties::setPropertyAvailability(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef value,
- JSValueRef* exception)
-{
- CalendarEventPtr event(NULL);
- Try
- {
- event = getPrivateObject(object);
- CalendarConverter converter(context);
- CalendarEvent::EventAvailability availability =
- converter.toEventAvailability(converter.toString(value));
- event->setAvailability(availability);
- return true;
- }
- Catch(Exception)
- {
- LoggerW("Exception: "<<_rethrown_exception.GetMessage());
- }
-
- return true;
-}
-
JSValueRef JSCalendarItemProperties::getPropertyAttendees(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
return true;
}
-JSValueRef JSCalendarItemProperties::getPropertyCompletedDate(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
-{
- Try
- {
- CalendarItemPropertiesPrivObject *privateObject =
- static_cast<CalendarItemPropertiesPrivObject*>(JSObjectGetPrivate(object));
- CalendarEventPtr task = privateObject->getObject();
- if(CalendarEvent::TASK_TYPE != task->getCalendarType()) {
- return JSValueMakeUndefined(context);
- }
- if (!task) {
- ThrowMsg(NullPointerException, "Task object is NULL.");
- }
-
- if (UNDEFINED_TIME==task->getCompletedDate()) {
- return JSValueMakeUndefined(context);
- } else {
- TimeUtilConverter timeConverter(context);
- return timeConverter.toJSValueRefTZDate((double)(task->getCompletedDate()*1000.0), task->getTimeZone());
- }
- }
- Catch(Exception)
- {
- LoggerW("Exception: "<<_rethrown_exception.GetMessage());
- }
- return JSValueMakeUndefined(context);
-}
-
-bool JSCalendarItemProperties::setPropertyCompletedDate(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef value,
- JSValueRef* exception)
-{
- Try
- {
- CalendarEventPtr task = getPrivateObject(object);
- if (!task) {
- ThrowMsg(NullPointerException, "Task object is NULL.");
- }
- if(CalendarEvent::TASK_TYPE != task->getCalendarType()) {
- ThrowMsg(InvalidArgumentException, "Wrong calendar type.");
- }
- if (!JSValueIsObjectOfClass(context, value, JSTZDate::getClassRef())) {
- ThrowMsg(ConversionException, "Wrong parameter type.");
- }
-
- TimeUtilConverter converter(context);
- long long int completedDate = (long long int) (converter.getTimeInMilliseconds(value)/1000);
-
- task->setCompletedDate(completedDate);
-
- if( task->getTimeZone().empty() ) {
- std::string timeZone = converter.getPropertiesInTZDate(value).timezone;
- task->setTimeZone(timeZone);
- }
- return true;
- }
- Catch(Exception)
- {
- LoggerW("Exception: "<<_rethrown_exception.GetMessage());
- }
-
- return true;
-}
-
-JSValueRef JSCalendarItemProperties::getPropertyProgress(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
-{
- Try
- {
- CalendarEventPtr task = getPrivateObject(object);
- if(CalendarEvent::TASK_TYPE != task->getCalendarType()) {
- return JSValueMakeUndefined(context);
- }
-
- Converter converter(context);
- return converter.toJSValueRef(task->getProgress());
- }
- Catch(Exception)
- {
- LoggerW("Exception: "<<_rethrown_exception.GetMessage());
- }
- return JSValueMakeUndefined(context);
-}
-
-bool JSCalendarItemProperties::setPropertyProgress(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef value,
- JSValueRef* exception)
-{
- Try
- {
- CalendarEventPtr task = getPrivateObject(object);
- if(CalendarEvent::TASK_TYPE != task->getCalendarType()) {
- return JSValueMakeUndefined(context);
- }
-
- Converter converter(context);
- int progress = converter.toInt(value);
- task->setProgress(progress);
- return true;
- }
- Catch(Exception)
- {
- LoggerW("Exception: "<<_rethrown_exception.GetMessage());
- }
-
- return true;
-}
-
JSValueRef JSCalendarItemProperties::getPropertyPriority(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
}
if (UNDEFINED_TIME==event->getEndTime()) {
- return JSValueMakeUndefined(context);
+ return JSValueMakeNull(context);
} else {
TimeUtilConverter timeConverter(context);
return timeConverter.toJSValueRefTZDate((double)(event->getEndTime()*1000.0), event->getTimeZone());
JSStringRef propertyName,
JSValueRef value,
JSValueRef* exception);
- static JSValueRef getPropertyAvailability(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
- static bool setPropertyAvailability(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef value,
- JSValueRef* exception);
static JSValueRef getPropertyDueDate(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
JSStringRef propertyName,
JSValueRef value,
JSValueRef* exception);
- static JSValueRef getPropertyCompletedDate(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
- static bool setPropertyCompletedDate(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef value,
- JSValueRef* exception);
- static JSValueRef getPropertyProgress(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
- static bool setPropertyProgress(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef value,
- JSValueRef* exception);
static JSValueRef getPropertyPriority(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
JSStaticValue JSCalendarTask::m_property[] = {
//Task properties
{ TIZEN_CALENDAR_TASK_ID, getPropertyId, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+ { TIZEN_CALENDAR_TASK_COMPLETED_DATE, getPropertyCompletedDate, setPropertyCompletedDate, kJSPropertyAttributeNone | kJSPropertyAttributeDontDelete },
+ { TIZEN_CALENDAR_TASK_PROGRESS, getPropertyProgress, setPropertyProgress, kJSPropertyAttributeNone | kJSPropertyAttributeDontDelete },
{ 0, 0, 0, 0 }
};
if (NULL==m_calendar) {
m_calendar = CalendarFactory::getInstance().createCalendarObject();
- LoggerD("Static calendar for task created.");
+ m_calendar->setType(CalendarEvent::TASK_TYPE);
+ LoggerD("Static calendar for task created.");
}
-
- if (m_calendar) {
- m_calendar->setType(CalendarEvent::TASK_TYPE);
- LoggerD("Calendar object type is set to task.");
- }
}
void JSCalendarTask::finalize(JSObjectRef object)
eventStr = converter.toString(arguments[0]);
format = converter.toVObjectFormat(converter.toString(arguments[1]));
+ if (NULL==m_calendar) {
+ m_calendar = CalendarFactory::getInstance().createCalendarObject();
+ m_calendar->setType(CalendarEvent::TASK_TYPE);
+ LoggerD("Static calendar for task created.");
+ }
+
IEventCreateEventFromStringPtr dplEvent(new IEventCreateEventFromString());
dplEvent->setEventString(eventStr);
dplEvent->setFormat(format);
return JSValueMakeUndefined(context);
}
+JSValueRef JSCalendarTask::getPropertyCompletedDate(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
+{
+ Try
+ {
+ CalendarTaskPrivObject *privateObject =
+ static_cast<CalendarTaskPrivObject*>(JSObjectGetPrivate(object));
+ CalendarEventPtr task = privateObject->getObject();
+ if (!task) {
+ ThrowMsg(NullPointerException, "Task object is NULL.");
+ }
+
+ if (UNDEFINED_TIME==task->getCompletedDate()) {
+ return JSValueMakeUndefined(context);
+ } else {
+ TimeUtilConverter timeConverter(context);
+ return timeConverter.toJSValueRefTZDate((double)(task->getCompletedDate()*1000.0), task->getTimeZone());
+ }
+ }
+ Catch(Exception)
+ {
+ LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+ }
+ return JSValueMakeUndefined(context);
+}
+
+bool JSCalendarTask::setPropertyCompletedDate(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef value,
+ JSValueRef* exception)
+{
+ Try
+ {
+ CalendarEventPtr task = getPrivateObject(object);
+ if (!task) {
+ ThrowMsg(NullPointerException, "Task object is NULL.");
+ }
+
+ if (!JSValueIsObjectOfClass(context, value, JSTZDate::getClassRef())) {
+ ThrowMsg(ConversionException, "Wrong parameter type.");
+ }
+
+ TimeUtilConverter converter(context);
+ long long int completedDate = (long long int) (converter.getTimeInMilliseconds(value)/1000);
+
+ task->setCompletedDate(completedDate);
+
+ if( task->getTimeZone().empty() ) {
+ std::string timeZone = converter.getPropertiesInTZDate(value).timezone;
+ task->setTimeZone(timeZone);
+ }
+ return true;
+ }
+ Catch(Exception)
+ {
+ LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+ }
+
+ return true;
+}
+
+JSValueRef JSCalendarTask::getPropertyProgress(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
+{
+ Try
+ {
+ CalendarEventPtr task = getPrivateObject(object);
+ Converter converter(context);
+ return converter.toJSValueRef(task->getProgress());
+ }
+ Catch(Exception)
+ {
+ LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+ }
+ return JSValueMakeUndefined(context);
+}
+
+bool JSCalendarTask::setPropertyProgress(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef value,
+ JSValueRef* exception)
+{
+ Try
+ {
+ CalendarEventPtr task = getPrivateObject(object);
+ Converter converter(context);
+ int progress = converter.toInt(value);
+ task->setProgress(progress);
+ return true;
+ }
+ Catch(Exception)
+ {
+ LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+ }
+
+ return true;
+}
}
}
JSObjectRef object,
JSStringRef propertyName,
JSValueRef* exception);
+ static JSValueRef getPropertyCompletedDate(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception);
+ static bool setPropertyCompletedDate(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef value,
+ JSValueRef* exception);
+ static JSValueRef getPropertyProgress(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception);
+ static bool setPropertyProgress(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef value,
+ JSValueRef* exception);
};
}
print_log(prio, LOG_TAG, platformLog.str().c_str(), __MODULE__, __func__, __LINE__, ##args); \
} while(0)
#else
-#define _SLOGGER(prio,fmt,args....) (0)
+#define _SLOGGER(prio,fmt,args...) (0)
#endif
istringstream(strSyncTextNum) >> nSyncTextNum;
free(strSyncTextNum);
strSyncTextNum = NULL;
-
if ( nSyncTextNum > 0)
{
-
- MediacontentLyricsPtr lyricsPtr(new MediacontentLyrics());
- lyricsPtr->setMediaLyricsType("SYNCHRONIZED");
- for(int i=0; i < nSyncTextNum; i++)
- {
- unsigned long time_info = 0;
- char * lyrics = NULL;
- if ( METADATA_EXTRACTOR_ERROR_NONE ==
- metadata_extractor_get_synclyrics(m_extractor, i, &time_info, &lyrics))
- {
- lyricsPtr->addMediaLyricsTimeStamp(time_info);
- lyricsPtr->addMediaLyricsText(lyrics);
- LoggerD( "timestamp " << time_info << "lyrics : " << lyrics);
- }
- }
-
- result = lyricsPtr;
+ MediacontentLyricsPtr lyricsPtr(new MediacontentLyrics());
+ lyricsPtr->setMediaLyricsType("SYNCHRONIZED");
+ for(int i=0; i < nSyncTextNum; i++)
+ {
+ unsigned long time_info = 0;
+ char * lyrics = NULL;
+ if ( METADATA_EXTRACTOR_ERROR_NONE ==
+ metadata_extractor_get_synclyrics(m_extractor, i, &time_info, &lyrics))
+ {
+ lyricsPtr->addMediaLyricsTimeStamp(time_info);
+ if(lyrics != NULL)
+ {
+ lyricsPtr->addMediaLyricsText(lyrics);
+ //LoggerI( "[" << time_info << "]"<< "lyrics : " << lyrics);
+ }
+ else
+ {
+ lyricsPtr->addMediaLyricsText("");
+ }
+ }
+ if(lyrics != NULL)
+ {
+ free(lyrics);
+ }
+ }
+ result = lyricsPtr;
}
else
{
if (unSyncText)
{
MediacontentLyricsPtr lyricsPtr(new MediacontentLyrics());
- LoggerD("UNSYNCHRONIZED: " << unSyncText);
lyricsPtr->setMediaLyricsType("UNSYNCHRONIZED");
lyricsPtr->addMediaLyricsTimeStamp(0);
lyricsPtr->addMediaLyricsText(unSyncText);
#include "ContentAsyncCallbackManager.h"
#include <Logger.h>
+using namespace DeviceAPI::Common;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
namespace DeviceAPI {
namespace Content {
}
else
{
- JSValueRef errorObject = DeviceAPI::Common::JSWebAPIErrorFactory::makeErrorObject(
- cbm->getContext(), DeviceAPI::Common::JSWebAPIErrorFactory::UNKNOWN_ERROR);
- cbm->callOnError(errorObject);
+ JSValueRef error = NULL;
+ if (ExceptionCodes::None != event->getExceptionCode())
+ {
+ switch (event->getExceptionCode())
+ {
+ case ExceptionCodes::InvalidArgumentException:
+ error = JSWebAPIErrorFactory::makeErrorObject(cbm->getContext(), JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "The value is not valid");
+ break;
+ default:
+ error = JSWebAPIErrorFactory::makeErrorObject(cbm->getContext(), JSWebAPIErrorFactory::UNKNOWN_ERROR,"unknown error");
+ break;
+ }
+ cbm->callOnError(error);
+ return;
+ }
}
return;
}
vedioPtr->setVideoLongitude(DEFAULT_GEOLOCATION);
}
}
+
+ JSValueRef nameValRef = JSUtil::getProperty(m_context , JSUtil::JSValueToObject(m_context, element), "name");
+ if((JSValueIsNull(m_context, nameValRef) || JSValueIsUndefined(m_context, nameValRef)) ||
+ JSUtil::JSValueToString(m_context, nameValRef) == ""){
+ ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "name is not valid.");
+ }
+
resultVector.push_back(JSMedia::getMediaObject(arg));
}
*result = resultVector;
if(!JSValueIsUndefined(globalCtx,oncontentremoved)) {
m_callback->setCallback("oncontentremoved", JSUtil::JSValueToObject(globalCtx, oncontentremoved));
}
-/*
- // oncontentadded
- JSValueRef oncontentadded = JSUtils::getJSPropertyOrUndefined(globalCtx, object, "oncontentadded");
- if (validator.isNullOrUndefined(oncontentadded)) {
- oncontentadded = NULL;
- }
- else if (validator.isCallback(oncontentadded)) {
- JSObjectRef cbObj = JSValueToObject(globalCtx, oncontentadded, NULL);
- if(JSObjectIsFunction(globalCtx, cbObj)) {
- m_callback->setCallback("oncontentadded", cbObj);
- }
- else {
- ThrowMsg(ConversionException,"oncontentadded is not a callback function.");
- }
- }
- else{
- ThrowMsg(ConversionException, "oncontentadded is not available");
- }
-
- // oncontentupdated
- JSValueRef oncontentupdated = JSUtils::getJSPropertyOrUndefined(globalCtx, object, "oncontentupdated");
- if (validator.isNullOrUndefined(oncontentupdated)) {
- oncontentupdated = NULL;
- }
- else if (validator.isCallback(oncontentupdated)) {
- JSObjectRef cbObj = JSValueToObject(globalCtx, oncontentupdated, NULL);
- if(JSObjectIsFunction(globalCtx, cbObj)) {
- m_callback->setCallback("oncontentupdated", cbObj);
- }
- else {
- ThrowMsg(ConversionException,"oncontentupdated is not a callback function.");
- }
- }
- else{
- ThrowMsg(ConversionException, "oncontentupdated is not available");
- }
- // oncontentremoved
- JSValueRef oncontentremoved = JSUtils::getJSPropertyOrUndefined(globalCtx, object, "oncontentremoved");
- if (validator.isNullOrUndefined(oncontentremoved)) {
- oncontentremoved = NULL;
- }
- else if (validator.isCallback(oncontentremoved)) {
- JSObjectRef cbObj = JSValueToObject(globalCtx, oncontentremoved, NULL);
- if(JSObjectIsFunction(globalCtx, cbObj)) {
- m_callback->setCallback("oncontentremoved", cbObj);
- }
- else {
- ThrowMsg(ConversionException,"oncontentremoved is not a callback function.");
- }
- }
- else{
- ThrowMsg(ConversionException, "oncontentremoved is not available");
- }
-*/
}
ContentListener::~ContentListener() {
tmpStr = NULL;
}
}
-
+
if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_description(info, &tmpStr) )
{
if (tmpStr)
FilterValidatorPtr validator = MediaFilterValidatorFactory::getMediaFilterValidator(MediaFilterValidatorFactory::QUERY_MEDIA);
bool success = jsFilter->validate(validator);
- if(!success)
- ThrowMsg(PlatformException, "Invalid attirbutes.");
+ if(!success){
+ eBrowse->setExceptionCode(ExceptionCodes::InvalidArgumentException);
+ ThrowMsg(InvalidArgumentException, "Invalid attirbutes.");
+ }
IFilterVisitorPtr IVisitor = DPL::StaticPointerCast<IFilterVisitor>(visitor);
jsFilter->travel(IVisitor);
ThrowMsg(PlatformException, "mediaType(" << matchValue->getString() << ") is not supported.");
}
}
- else if(attrName.compare("contentURI")==0 || attrName.compare("thumbnailURIs")==0)
+ else if(attrName.compare("MEDIA_PATH")==0 || attrName.compare("MEDIA_THUMBNAIL_PATH")==0)
{
matchValueStr = ContentUtility::convertUriToPath(matchValue->getString());
}
#include <string>
+namespace DeviceAPI {
+namespace Content {
+
const double MAX_LATITUDE = 90;
const double MIN_LATITUDE = -90;
const double MAX_LONGITUDE = 180;
const double MIN_LONGITUDE = -180;
-namespace DeviceAPI {
-namespace Content {
-
class ContentUtility
{
public:
} // Content
} // DeviceAPI
-#endif // _PLATFORM_CONTENT_UTILITY_H_
\ No newline at end of file
+#endif // _PLATFORM_CONTENT_UTILITY_H_
{
Converter converter(context);
MediacontentMediaPtr media = getMediaObject(object);
- if(!(media->getDescription().empty()))
+// if(!(media->getDescription().empty()))
{
return converter.toJSValueRef(media->getDescription());
}
MediacontentMediaPtr objMedia = getMediaObject(object);
int rating = converter.toInt(value);
- if(rating < 0)
+ if(rating < 0 || rating > 10)
{
- rating = 0;
+ Throw(WrtDeviceApis::Commons::InvalidArgumentException);
}
if ( objMedia->getRating() != rating)
{
- objMedia->setRating(rating, true);
+ objMedia->setRating(rating, true);
}
-
- return true;
+ return true;
}
Catch(Exception)
{
LoggerW("trying to set incorrect value");
- DeviceAPI::Common::JSWebAPIErrorFactory::postException(context, exception, DeviceAPI::Common::JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR);
}
return false;
{
objMedia->setDisplayName(displayName, true);
}
-
+
return true;
}
Catch(Exception)
{
LoggerW("trying to set incorrect value");
- DeviceAPI::Common::JSWebAPIErrorFactory::postException(context, exception, DeviceAPI::Common::JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR);
}
return false;
Catch(Exception)
{
LoggerW("trying to set incorrect value");
- DeviceAPI::Common::JSWebAPIErrorFactory::postException(context, exception, DeviceAPI::Common::JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR);
}
-
return false;
}
}
}
+ JSValueRef nameValRef = JSUtil::getProperty(context , JSUtil::JSValueToObject(context, arguments[0]), "name");
+ if((JSValueIsNull(context, nameValRef) || JSValueIsUndefined(context, nameValRef)) ||
+ JSUtil::JSValueToString(context, nameValRef) == ""){
+ ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "name is not valid.");
+ }
event = JSMedia::getMediaObject(arg);
dplEvent->setMediaItem(event);
finalize,
NULL, //hasProperty,
NULL, //getProperty,
- NULL, //setProperty,
+ setProperty, //setProperty,
NULL, //DeleteProperty,
NULL, //GetPropertyNames,
NULL, //CallAsFunction,
return result;
}
-JSValueRef JSImage::getPropertyGeoLocation(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
-{
-
- Try
- {
- Converter converter(context);
- MediacontentImagePtr image = getImageObject(object);
- if(image->getImageLatitude() != DEFAULT_GEOLOCATION &&
- image->getImageLongitude() != DEFAULT_GEOLOCATION){
- DeviceAPI::Tizen::SimpleCoordinatesPtr geoPtr(new SimpleCoordinates(image->getImageLatitude(),image->getImageLongitude()));
- return JSSimpleCoordinates::createJSObject(context,geoPtr);
- }
- }
- Catch(Exception)
- {
- LoggerW("trying to get incorrect value");
- }
- return JSValueMakeNull(context);
-}
-
-
JSValueRef JSImage::getPropertyWidth(
JSContextRef context,
JSObjectRef object,
return false;
}
-bool JSImage::setPropertyGeolocation(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef value,
- JSValueRef* exception)
-{
- Try
- {
- Converter converter(context);
- MediacontentImagePtr objImg = getImageObject(object);
-
- DeviceAPI::Tizen::SimpleCoordinatesPtr geoLocation =
- DeviceAPI::Tizen::JSSimpleCoordinates::getSimpleCoordinates(context, value);
-
- objImg->setImageLatitude(geoLocation->getLatitude());
- objImg->setImageLongitude(geoLocation->getLongitude());
-
- return true;
- }
- Catch(Exception)
- {
- LoggerW("trying to get incorrect value");
- DeviceAPI::Common::JSWebAPIErrorFactory::postException(context, exception, DeviceAPI::Common::JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR);
- }
-
- return false;
+bool JSImage::setProperty(JSContextRef context, JSObjectRef object,
+ JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
+{
+ try {
+ // check geolocation
+ if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CONTENT_IMAGE_GEOLOCATION)) {
+ if(JSValueIsUndefined(context, value)){
+ throw TypeMismatchException("Invalid geolocation");
+ }
+ }
+ } catch (const BasePlatformException &err) {
+ LOGE("setProperty error< %s : %s> " , err.getName().c_str(), err.getMessage().c_str());
+ return true;
+ }
+ return false;
}
+
}
}
* Getters and setters for properties
*/
- static JSValueRef getPropertyGeoLocation(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
-
static JSValueRef getPropertyWidth(
JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
JSValueRef* exception);
- static bool setPropertyGeolocation(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef value,
- JSValueRef* exception);
-
static bool setPropertyOrientation(
JSContextRef context,
JSObjectRef object,
JSValueRef value,
JSValueRef* exception);
+ static bool setProperty(
+ JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef value,
+ JSValueRef* exception);
finalize,
NULL, //hasProperty,
NULL, //getProperty,
- NULL, //setProperty,
+ setProperty, //setProperty,
NULL, //DeleteProperty,
NULL, //GetPropertyNames,
NULL, //CallAsFunction,
return result;
}
-JSValueRef JSVideo::getPropertyGeoLocation(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
-{
- Try
- {
- Converter converter(context);
- MediacontentVideoPtr video = getVideoObject(object);
- if(video->getVideoLatitude() != DEFAULT_GEOLOCATION &&
- video->getVideoLongitude() != DEFAULT_GEOLOCATION){
- SimpleCoordinatesPtr geoPtr(new SimpleCoordinates(video->getVideoLatitude(),video->getVideoLongitude()));
- return JSSimpleCoordinates::createJSObject(context,geoPtr);
- }
- }
- Catch(Exception)
- {
- LoggerW("trying to get incorrect value");
- }
- return JSValueMakeNull(context);
-}
-
-bool JSVideo::setPropertyGeoLocation(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef value,
- JSValueRef* exception)
-{
- Try
- {
- Converter converter(context);
- MediacontentVideoPtr video = getVideoObject(object);
-
- DeviceAPI::Tizen::SimpleCoordinatesPtr geoLocation =
- DeviceAPI::Tizen::JSSimpleCoordinates::getSimpleCoordinates(context, value);
-
- if(geoLocation){
- video->setVideoLatitude(geoLocation->getLatitude());
- video->setVideoLongitude(geoLocation->getLongitude());
- return true;
- }
- }
- Catch(Exception)
- {
- LoggerW("trying to get incorrect value");
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR);
- }
- return false;
-}
-
-
JSValueRef JSVideo::getPropertyAlbum(
JSContextRef context,
JSObjectRef object,
return false;
}
+bool JSVideo::setProperty(JSContextRef context, JSObjectRef object,
+ JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
+{
+ try {
+ // check geolocation
+ if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CONTENT_VIDEO_GEOLOCATION)) {
+ if(JSValueIsUndefined(context, value)){
+ throw TypeMismatchException("Invalid geolocation");
+ }
+ }
+ } catch (const BasePlatformException &err) {
+ LOGE("setProperty error< %s : %s> " , err.getName().c_str(), err.getMessage().c_str());
+ return true;
+ }
+ return false;
+}
+
}
}
* Getters and setters for properties
*/
- static JSValueRef getPropertyGeoLocation(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
-
static JSValueRef getPropertyAlbum(
JSContextRef context,
JSObjectRef object,
JSObjectRef object,
JSStringRef propertyName,
JSValueRef value,
- JSValueRef* exception);
-
- static bool setPropertyGeoLocation(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef value,
JSValueRef* exception);
- //todo-dykim
- //static JSValueRef setPropertyPlayedTime
+ static bool setProperty(
+ JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef value,
+ JSValueRef* exception);
+
};
msg_release_struct(&msg);
msg_release_struct(&sendOpt);
LoggerE("platform error occurs");
+ ReThrow(WrtDeviceApis::Commons::PlatformException);
}
}
msg_release_struct(&msg);
msg_release_struct(&sendOpt);
LoggerE("platform error occurs");
+ ReThrow(WrtDeviceApis::Commons::PlatformException);
}
}
static void connection_opened_callback(connection_error_e result, void* user_data)
{
- LoggerD("enter");
+ LoggerD("result : " << result);
if (result == CONNECTION_ERROR_NONE) {
LoggerD("Connection open Succeeded");
if(user_data != NULL) {
{
if(m_connectionHandle != NULL) {
LoggerD("Client deregistration success");
+ if (m_profileHandle) {
+ connection_profile_destroy(m_profileHandle);
+ m_profileHandle = NULL;
+ }
connection_destroy(m_connectionHandle);
} else {
LoggerD("Client deregistration failed");
return;
}
- connection_profile_iterator_h profileIter;
+ if (m_profileHandle) {
+ connection_profile_destroy(m_profileHandle);
+ m_profileHandle = NULL;
+ }
- int ret = connection_get_profile_iterator(m_connectionHandle, CONNECTION_ITERATOR_TYPE_REGISTERED, &profileIter);
- if (ret != CONNECTION_ERROR_NONE) {
- LoggerD("Fail to get profile iterator");
+ if (connection_get_default_cellular_service_profile(m_connectionHandle, CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET, &m_profileHandle) != CONNECTION_ERROR_NONE) {
+ LoggerD("Fail to get profile handle");
makeRequestCallback(event, CONNECTION_STATE_PLATFORM_ERROR);
return;
}
- while (connection_profile_iterator_has_next(profileIter)) {
- if (connection_profile_iterator_next(profileIter, &m_profileHandle) != CONNECTION_ERROR_NONE) {
- LoggerD("Fail to get profile handle");
- makeRequestCallback(event, CONNECTION_STATE_PLATFORM_ERROR);
- return;
- }
- }
NewtorkBearerSelectionPendingEvent *pendingEvent = new NewtorkBearerSelectionPendingEvent((void *)this, event);
if (connection_profile_unset_state_changed_cb(m_profileHandle) != CONNECTION_ERROR_NONE) {
LoggerD("unset callback is failed");
+ if (m_profileHandle) {
+ connection_profile_destroy(m_profileHandle);
+ m_profileHandle = NULL;
+ }
return;
}
if (connection_profile_unset_state_changed_cb(m_profileHandle) != CONNECTION_ERROR_NONE) {
LoggerD("unset callback is failed");
+ if (m_profileHandle) {
+ connection_profile_destroy(m_profileHandle);
+ m_profileHandle = NULL;
+ }
makeRequestCallback(event, CONNECTION_STATE_PLATFORM_ERROR);
return;
}
{
LoggerD("enter");
- m_profileHandle = NULL;
- connection_profile_iterator_h profileIter;
+ if (m_profileHandle) {
+ connection_profile_destroy(m_profileHandle);
+ m_profileHandle = NULL;
+ }
- int ret = connection_get_profile_iterator(m_connectionHandle, CONNECTION_ITERATOR_TYPE_REGISTERED, &profileIter);
- if (ret != CONNECTION_ERROR_NONE) {
- LoggerD("Fail to get profile iterator");
+ if (connection_get_default_cellular_service_profile(m_connectionHandle, CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET, &m_profileHandle) != CONNECTION_ERROR_NONE) {
+ LoggerD("Fail to get profile handle");
makeRequestCallback(event, CONNECTION_STATE_PLATFORM_ERROR);
return;
}
- while (connection_profile_iterator_has_next(profileIter)) {
- if (connection_profile_iterator_next(profileIter, &m_profileHandle) != CONNECTION_ERROR_NONE) {
- LoggerD("Fail to get profile handle");
- makeRequestCallback(event, CONNECTION_STATE_PLATFORM_ERROR);
- return;
- }
- }
NewtorkBearerSelectionPendingEvent *pendingEvent = new NewtorkBearerSelectionPendingEvent((void *)this, event);
if (connection_open_profile(m_connectionHandle, m_profileHandle, connection_opened_callback, pendingEvent) != CONNECTION_ERROR_NONE) {
LoggerD("Connection open Failed");
+ if (m_profileHandle) {
+ connection_profile_destroy(m_profileHandle);
+ m_profileHandle = NULL;
+ }
makeRequestCallback(event, CONNECTION_STATE_PLATFORM_ERROR);
delete pendingEvent;
pendingEvent = NULL;
if (connection_profile_get_network_interface_name(m_profileHandle, &interfaceName) != CONNECTION_ERROR_NONE) {
LoggerD("Fail to get interface name!");
+ if (m_profileHandle) {
+ connection_profile_destroy(m_profileHandle);
+ m_profileHandle = NULL;
+ }
makeRequestCallback(event, CONNECTION_STATE_PLATFORM_ERROR);
}
else {
LoggerD("connection close failed");
makeRequestCallback(event, CONNECTION_STATE_PLATFORM_ERROR);
}
- m_profileHandle = NULL;
+ if (m_profileHandle) {
+ connection_profile_destroy(m_profileHandle);
+ m_profileHandle = NULL;
+ }
return;
}
NewtorkBearerSelectionPendingEvent *pendingEvent = new NewtorkBearerSelectionPendingEvent((void *)this, event);
if (connection_profile_set_state_changed_cb(m_profileHandle, connection_state_changed_callback, pendingEvent) != CONNECTION_ERROR_NONE) {
LoggerE("Callback register is failed.");
+ if (m_profileHandle) {
+ connection_profile_destroy(m_profileHandle);
+ m_profileHandle = NULL;
+ }
delete pendingEvent;
pendingEvent = NULL;
} else {
void NetworkBearerSelection::deregistStateChangeListener(const EventNetworkBearerReleasePtr &event)
{
LoggerD("enter");
- m_profileHandle = NULL;
+ if (m_profileHandle) {
+ connection_profile_destroy(m_profileHandle);
+ m_profileHandle = NULL;
+ }
m_connectionState = NETWORK_DISCONNECTED;
EventRequestReceiver<EventNetworkBearerRelease>::ManualAnswer(event);
}
if (connection_profile_unset_state_changed_cb(m_profileHandle) != CONNECTION_ERROR_NONE) {
LoggerD("unset callback is failed");
}
- m_profileHandle = NULL;
+ if (m_profileHandle) {
+ connection_profile_destroy(m_profileHandle);
+ m_profileHandle = NULL;
+ }
} else if (state == CONNECTION_STATE_CONNECTED) {
m_connectionState = NETWORK_CONNECTED;
}
else
{
JSUtil::setProperty(context, object, NOTIFICATION_ID,
- JSValueMakeNull(context), kJSPropertyAttributeReadOnly);
+ JSValueMakeUndefined(context), kJSPropertyAttributeReadOnly);
}
//postedTime
LoggerD("fail file open.");
return convert.toJSValueRef(deviceCapabilitiesInfo->duid);
}
-
while(fgets(duid, DUID_BUFFER_SIZE-1, fp)) {
if (strncmp(duid, "http://tizen.org/system/duid", DUID_KEY_STRING) == 0) {
- deviceCapabilitiesInfo->duid = duid + (DUID_KEY_STRING+1);
- LoggerD("deviceCapabilitiesInfo->duid : " << deviceCapabilitiesInfo->duid);
+ char* token = NULL;
+ char* ptr = NULL;
+ 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);
+ }
break;
}
}
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)
+ unit(MSECS_UNIT), unitStr("MSECS")
{
}
};
if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_TIMEDURATION_LENGTH)) {
return convert.toJSValueRef(static_cast<double>(convert.getDurationLength(object)));
} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_TIMEDURATION_UNIT)) {
- std::string strUnit = convert.toDurationUnitString(convert.getDurationUnit(object));
- if (strUnit == "")
- ThrowMsg(InvalidArgumentException, "unit string is invald.");
- return convert.toJSValueRef(strUnit);
+ 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);
}
} Catch (ConversionException) {
LoggerE("ConversionException: " << _rethrown_exception.GetMessage());
if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_TIMEDURATION_LENGTH)) {
duration->length = convert.toLongLong(value);
} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_TIMEDURATION_UNIT)) {
- short unit = convert.toDurationUnit(convert.toString(value));
- if (unit == 0xff)
- ThrowMsg(ConversionException, "property doesn't exist.");
- duration->unit = 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;
} Catch (NullPointerException) {
LoggerE("NullPointerException: " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch (ConversionException) {
LoggerE("ConversionException: " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch (InvalidArgumentException) {
LoggerE("InvalidArgumentException: " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid Values");
} Catch (WrtDeviceApis::Commons::Exception) {
LoggerE("Exception: " << _rethrown_exception.GetMessage());
- *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown Error");
}
return false;
}
if (argumentCount > 1) {
if (!JSValueIsUndefined(ctx, arguments[1]) && !JSValueIsNull(ctx, arguments[1])) {
- std::string unit = convert.toString(arguments[1]);
- duration.unit = convert.toDurationUnit(unit);
- if (duration.unit == 0xff)
+ 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)");
}
}
return -1;
UErrorCode ec = U_ZERO_ERROR;
- TimeUtilTools util;
+ Calendar *utcCalendar = NULL;
- Calendar *utcCalendar = myCalendar->clone();
- utcCalendar->setTimeZone(*(TimeZone::getGMT()));
+ try {
+ utcCalendar = Calendar::createInstance(*(TimeZone::getGMT()),ec);
+ if (!U_SUCCESS(ec))
+ ThrowMsg(Commons::PlatformException, "Can't create utcCalendar");
- int32_t value = utcCalendar->get(_convertDateField(field), ec);
- delete utcCalendar;
+ UDate date = myCalendar->getTime(ec);
+ if (!U_SUCCESS(ec))
+ ThrowMsg(Commons::PlatformException, "Can't get time of myCalendar");
- if (U_SUCCESS(ec)) {
+ utcCalendar->setTime(date, ec);
+ if (!U_SUCCESS(ec))
+ ThrowMsg(Commons::PlatformException, "Can't set time of utcCalendar");
+
+ int32_t value = utcCalendar->get(_convertDateField(field), ec);
+
+ if (!U_SUCCESS(ec))
+ ThrowMsg(Commons::PlatformException, "Can't get data of utcCalendar");
+
+ if (utcCalendar)
+ delete utcCalendar;
+ utcCalendar = NULL;
+
+ TimeUtilTools util;
long result = util.tolong(value);
if (field == TZDATE_DAY_OF_WEEK)
result--;
LoggerD("result : " << result);
return result;
+ } catch (const Commons::PlatformException& err) {
+ LoggerE(err.GetMessage());
}
+ if (utcCalendar)
+ delete utcCalendar;
ThrowMsg(Commons::PlatformException, "Can't get UTC Calendar value");
}
TZDateProperties TimeUtilConverter::getPropertiesInTZDate(JSValueRef arg) {
if (JSValueIsNull(m_context, arg) || JSValueIsUndefined(m_context, arg) || !JSValueIsObjectOfClass(m_context, arg, JSTZDate::getClassRef())) {
ThrowMsg(Commons::ConversionException,
- "Message is JS null or JS undefined.");
+ "Wrong Input Type");
}
JSObjectRef obj = toJSObjectRef(arg);
return getPropertiesInTZDate(obj);
DurationPropertiesPtr TimeUtilConverter::getDuration(JSValueRef value) {
if (!JSValueIsObjectOfClass(m_context, value, JSTimeDuration::getClassRef())) {
- ThrowMsg(Commons::ConversionException, "Wrong duration object.");
+ ThrowMsg(Commons::ConversionException, "Wrong input type");
}
TimeDurationPrivObject* privateObject = static_cast<TimeDurationPrivObject*>(JSObjectGetPrivate(toJSObjectRef(value)));
DurationProperties duration;
duration.length = getDurationLength(value);
duration.unit = getDurationUnit(value);
+ if (duration.unit == WRONG_UNIT)
+ ThrowMsg(Commons::ConversionException, "Wrong Unit");
return duration;
}
long long TimeUtilConverter::getDurationLength(JSValueRef value) {
if (JSValueIsNull(m_context, value) || JSValueIsUndefined(m_context, value) || !JSValueIsObjectOfClass(m_context, value, JSTimeDuration::getClassRef())) {
ThrowMsg(Commons::ConversionException,
- "Duration is JS null or JS undefined.");
+ "Wrong input type");
}
JSObjectRef obj = toJSObjectRef(value);
return getDurationLength(obj);
short TimeUtilConverter::getDurationUnit(JSValueRef value) {
if (JSValueIsNull(m_context, value) || JSValueIsUndefined(m_context, value) || !JSValueIsObjectOfClass(m_context, value, JSTimeDuration::getClassRef())) {
ThrowMsg(Commons::ConversionException,
- "Duration is JS null or JS undefined.");
+ "Wrong input type");
}
JSObjectRef obj = toJSObjectRef(value);
return getDurationUnit(obj);
}
+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;
else if (!strUnit.compare("MSECS"))
return MSECS_UNIT;
else
- return 0xff;
+ return WRONG_UNIT;
}
std::string TimeUtilConverter::toDurationUnitString(short unit) {
}
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 thatn duration's unit");
+ ThrowMsg(Commons::ConversionException, "Unit is larger than duration's unit");
if (duration.unit == unit)
return duration.length;
result.length /= 24;
// intentional fall-through
}
+ result.unitStr = toDurationUnitString(result.unit);
return result;
}
double TimeUtilConverter::getTimeInMilliseconds(JSValueRef arg) {
if (JSValueIsNull(m_context, arg) || JSValueIsUndefined(m_context, arg) || !JSValueIsObjectOfClass(m_context, arg, JSTZDate::getClassRef())) {
ThrowMsg(Commons::ConversionException,
- "JSValueRef is JS null or JS undefined.");
+ "Wrong input type");
}
JSObjectRef obj = toJSObjectRef(arg);
double TimeUtilConverter::getTimeInMilliseconds(JSObjectRef arg) {
if (!arg) {
LoggerE("Object is null");
- ThrowMsg(Commons::ConversionException, "Private object not initialized");
+ ThrowMsg(Commons::ConversionException, "Object is null");
}
TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(arg));
tm TimeUtilConverter::toTZDateTime(JSValueRef arg) {
if (JSValueIsNull(m_context, arg) || JSValueIsUndefined(m_context, arg) || !JSValueIsObjectOfClass(m_context, arg, JSTZDate::getClassRef())) {
ThrowMsg(Commons::ConversionException,
- "JSValueRef is JS null or JS undefined.");
+ "Wrong input type");
}
JSObjectRef obj = toJSObjectRef(arg);
tm TimeUtilConverter::toTZDateTime(JSObjectRef arg) {
if (!arg) {
LoggerE("Object is null");
- ThrowMsg(Commons::ConversionException, "Private object not initialized");
+ ThrowMsg(Commons::ConversionException, "Object is null");
}
TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(arg));
TZDatePtr tzDate = privateObject->getObject();
TZDatePtr utcTzDate(new TZDate(tzDate->getUTCTimezoneName()));
if (!utcTzDate->setTime(tzDate->getTime()))
- ThrowMsg(Commons::ConversionException, "Can not set UTC Time");
+ ThrowMsg(Commons::ConversionException, "Can not set Time");
TZDateProperties utcProperties = utcTzDate->makeProperties();
struct tm utcTm;
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);