Update change log and spec for wrt-plugins-tizen_0.4.57
authorDongjin Choi <milkelf.choi@samsung.com>
Thu, 25 Jul 2013 12:05:10 +0000 (21:05 +0900)
committerDongjin Choi <milkelf.choi@samsung.com>
Thu, 25 Jul 2013 12:05:10 +0000 (21:05 +0900)
[model] REDWOOD
[binary_type] PDA
[customer] OPEN

[NBS] Fix bug about open profile

[Issue#] VPSS-1080
[Problem] Decoding iCalendar leads to app crash.
[Cause] Internal calendar object accessed before its initialization.
[Solution] Initialize the static calendar object before the conversion.

[Issue#] VPSS-1080
[Problem] Decoding iCalendar leads to app crash.
[Cause] Internal calendar object accessed before its initialization.
[Solution] Initialize the static calendar object before the conversion.

[Issue#] N/A
[Problem] One TC for iCalendar conversion failed.
[Cause] Platform iCalendar conversion routine change and wrong string input from TC.
[Solution] Fix TC string input as per guide from platform.

[Issue#] N/A
[Problem] sometimes callback function of kill() API is not called
[Cause] event is skipped by unknown reason.
[Solution] add second chance code to call callback functdion of kill() API

[Issue#] N/A
[Problem] wrong exception is thrown
[Cause] N/A
[Solution] change exception and return code

[Issue] N/A
[Problem] Bug fixed for intensive test
[Cause] invalid operation of converting
[Solution] 1. ignore the invalid rating value.
           2. throw the invalidValue exception when name is empty string.
           3. ignore the undfined for geolocation
           4. Add the condition when lyrics is invalid

[Issue#] N/A
[Problem] if wrong daysOfTheWeek value is eixst in vector, all daysOfTheWeek value io skipped
[Cause] N/A
[Solution] remove wrong value only.

[Issue] N/A
[Problem] If setting unit of TimeDuration to wrong value, exception is raised.
[Cause] When setting unit of TimeDuration, it checks if unit value is valid or not. And if it is not valid, it sends an exception.
[Solution] It will not send exception in the case. It will raise exception when TimeDuration with invalid unit is one of arguments.

[Issue#] N/A
[Problem] notification default id value is null.
[Cause] N/A
[Solution] defatul value is undefined before notificaiton posting.

[Issue#] N/A
[Problem] Wrong attribute for a task, wrong default values for dates.
[Cause] Wrong attribute assignment and wrong default values for dates.
[Solution] Revise attribute assignment and default values.

[Issue] TTS-1759
[Problem] sms update error not occur
[Cause] sms update bug
[Solution] sms update error called for error case

[Issue] N/A
[Problem] InvalidError callack is not thrown
[Cause] Not implemented
[Solution] Throw the InvalidError callback when the value is not valid.

[team] WebAPI
[request] N/A
[horizontal_expansion] N/A

UnitTC passed.

35 files changed:
packaging/wrt-plugins-tizen.spec
src/Alarm/JSAlarmAbsolute.cpp
src/Alarm/JSAlarmManager.cpp
src/Alarm/JSAlarmRelative.cpp
src/Application/ApplicationManager.cpp
src/Calendar/JSCalendarEvent.cpp
src/Calendar/JSCalendarEvent.h
src/Calendar/JSCalendarItemProperties.cpp
src/Calendar/JSCalendarItemProperties.h
src/Calendar/JSCalendarTask.cpp
src/Calendar/JSCalendarTask.h
src/Common/Logger.h
src/Content/AudioLyricsUtil.cpp
src/Content/ContentController.cpp
src/Content/ContentConverter.cpp
src/Content/ContentListener.cpp
src/Content/ContentManager.cpp
src/Content/ContentSearchVisitor.cpp
src/Content/ContentUtility.h
src/Content/JSContent.cpp
src/Content/JSContentManager.cpp
src/Content/JSImage.cpp
src/Content/JSImage.h
src/Content/JSVideo.cpp
src/Content/JSVideo.h
src/Messaging/Mms.cpp
src/Messaging/Sms.cpp
src/NetworkBearerSelection/NetworkBearerSelection.cpp
src/Notification/JSStatusNotification.cpp
src/Systeminfo/JSDeviceCapabilitiesInfo.cpp
src/TimeUtil/DurationProperties.h
src/TimeUtil/JSTimeDuration.cpp
src/TimeUtil/TZDate.cpp
src/TimeUtil/TimeUtilConverter.cpp
src/TimeUtil/TimeUtilConverter.h

index 2b0dc62..58c1415 100755 (executable)
@@ -1,6 +1,6 @@
 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
index e18815d..7f24090 100644 (file)
@@ -130,7 +130,8 @@ JSObjectRef DLL_EXPORT JSAlarmAbsolute::constructor(JSContextRef ctx, JSObjectRe
                          (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());
                     }
                 }
 
index d491691..e572cc4 100644 (file)
@@ -222,6 +222,10 @@ JSValueRef JSAlarmManager::add(JSContextRef ctx, JSObjectRef object, JSObjectRef
             }
 
             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());
index 92c58bd..e345cca 100644 (file)
@@ -199,7 +199,7 @@ JSValueRef JSAlarmRelative::getRemainingSeconds(JSContextRef ctx, JSObjectRef fu
             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");
             }
         }
 
@@ -215,8 +215,7 @@ JSValueRef JSAlarmRelative::getRemainingSeconds(JSContextRef ctx, JSObjectRef fu
         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);
 
index 75d11d4..d9a3b06 100644 (file)
@@ -536,8 +536,9 @@ void ApplicationManager::invokeManualAnswerKill(int pid)
        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);
@@ -978,6 +979,35 @@ void ApplicationManager::OnRequestReceived(const EventApplicationLaunchPtr& even
        }
 }
 
+// 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
@@ -1046,6 +1076,19 @@ void ApplicationManager::OnRequestReceived(const EventApplicationKillPtr& event)
                        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();
index c8ff3e5..a0b9144 100755 (executable)
@@ -73,6 +73,7 @@ JSClassDefinition JSCalendarEvent::m_classInfo = {
 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 }
@@ -104,13 +105,9 @@ void JSCalendarEvent::initialize(JSContextRef context,
 
        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)
@@ -158,6 +155,12 @@ JSObjectRef DLL_EXPORT JSCalendarEvent::constructor(JSContextRef context,
             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);
@@ -395,10 +398,6 @@ JSValueRef JSCalendarEvent::getPropertyIsDetached(JSContextRef context,
     Try
     {
         CalendarEventPtr event = getPrivateObject(object);
-        if(CalendarEvent::EVENT_TYPE != event->getCalendarType()) {
-            return JSValueMakeUndefined(context);
-        }
-
         Converter converter(context);
         return converter.toJSValueRef(event->getIsDetached());
     }
@@ -409,6 +408,48 @@ JSValueRef JSCalendarEvent::getPropertyIsDetached(JSContextRef context,
     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,
index 10c3384..9dd4bb4 100755 (executable)
@@ -119,6 +119,15 @@ class JSCalendarEvent
             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,
index 2d3f0b6..02ff81b 100755 (executable)
@@ -77,25 +77,22 @@ JSClassDefinition JSCalendarItemProperties::m_classInfo = {
 
 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 },
 
@@ -433,7 +430,7 @@ JSValueRef JSCalendarItemProperties::getPropertyStartDate(JSContextRef context,
 
         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());
         }
@@ -925,49 +922,6 @@ bool JSCalendarItemProperties::setPropertyIsAllDay(JSContextRef context,
     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,
@@ -1087,123 +1041,6 @@ bool JSCalendarItemProperties::setPropertyDueDate(JSContextRef context,
     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,
@@ -1268,7 +1105,7 @@ JSValueRef JSCalendarItemProperties::getPropertyEndDate(JSContextRef context,
         }
 
         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());
index 793a124..6ac2c6f 100755 (executable)
@@ -235,15 +235,6 @@ class JSCalendarItemProperties
             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,
@@ -253,24 +244,6 @@ class JSCalendarItemProperties
             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,
index 77804c1..812f90a 100755 (executable)
@@ -66,6 +66,8 @@ JSClassDefinition JSCalendarTask::m_classInfo = {
 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 }
 };
@@ -90,13 +92,9 @@ void JSCalendarTask::initialize(JSContextRef context,
 
        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)
@@ -143,6 +141,12 @@ JSObjectRef DLL_EXPORT JSCalendarTask::constructor(JSContextRef context,
             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);
@@ -264,5 +268,108 @@ JSValueRef JSCalendarTask::getPropertyId(JSContextRef context,
     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;
+}
 }
 }
index e0e4918..9abfbff 100755 (executable)
@@ -102,6 +102,24 @@ class JSCalendarTask
             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);
 };
 
 }
index 38eb99e..662e266 100644 (file)
@@ -46,7 +46,7 @@
         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
 
 
index f46df7b..be7b2be 100755 (executable)
@@ -63,26 +63,34 @@ MediacontentLyricsPtr MediaLyricsUtil::fetchLyrics(string filepath)
                                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
                                {       
@@ -94,7 +102,6 @@ MediacontentLyricsPtr MediaLyricsUtil::fetchLyrics(string filepath)
                                                if (unSyncText)
                                                {
                                                        MediacontentLyricsPtr lyricsPtr(new MediacontentLyrics());
-                                                       LoggerD("UNSYNCHRONIZED: " << unSyncText);
                                                        lyricsPtr->setMediaLyricsType("UNSYNCHRONIZED");
                                                        lyricsPtr->addMediaLyricsTimeStamp(0);
                                                        lyricsPtr->addMediaLyricsText(unSyncText);
index 3a2ab38..0291398 100755 (executable)
 #include "ContentAsyncCallbackManager.h"
 #include <Logger.h>
 
+using namespace DeviceAPI::Common;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
 namespace DeviceAPI {
 namespace Content {
 
@@ -94,9 +98,21 @@ void MediacontentManagerController::OnAnswerReceived(const IEventBrowseFolderPtr
         }
         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;
     }
index 3bf4c1c..9e4287c 100755 (executable)
@@ -170,6 +170,13 @@ MediacontentMediaListPtr MediaConverter::toVectorOfMediaItem(JSValueRef events)
                 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;
index 2b47c82..c60c09f 100755 (executable)
@@ -49,61 +49,7 @@ ContentListener::ContentListener(JSContextRef globalCtx, JSObjectRef object)
     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() {
index 3e700ac..6d6d798 100755 (executable)
@@ -253,7 +253,7 @@ void MediacontentManager::readCommonDataFromMediaInfo(media_info_h info, Mediaco
                        tmpStr = NULL;
                }
        }
-       
+
        if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_description(info, &tmpStr) )
        {
                if (tmpStr)
@@ -765,8 +765,10 @@ void MediacontentManager::OnRequestReceived(const IEventBrowseFolderPtr &eBrowse
                 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);
index ed7f38e..9518ae7 100755 (executable)
@@ -200,7 +200,7 @@ string MediaSearchVisitor::convertAttribute(string &attrName, AnyPtr& matchValue
                        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());
        }
index 3eeb771..496769c 100755 (executable)
 
 #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:
@@ -46,4 +46,4 @@ private:
 } // Content
 } // DeviceAPI
 
-#endif // _PLATFORM_CONTENT_UTILITY_H_
\ No newline at end of file
+#endif // _PLATFORM_CONTENT_UTILITY_H_
index fd8cd3d..35cf614 100755 (executable)
@@ -280,7 +280,7 @@ JSValueRef JSMedia::getPropertyDescription(
     {
         Converter converter(context);
         MediacontentMediaPtr media = getMediaObject(object);
-        if(!(media->getDescription().empty()))
+//        if(!(media->getDescription().empty()))
         {
             return converter.toJSValueRef(media->getDescription());
         }
@@ -449,21 +449,19 @@ bool      JSMedia::setPropertyRating(
        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;
@@ -487,13 +485,12 @@ bool JSMedia::setPropertyDisplayName(
                {
                        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;
@@ -522,9 +519,7 @@ bool JSMedia::setPropertyDescription(
        Catch(Exception)
        {
                LoggerW("trying to set incorrect value");
-               DeviceAPI::Common::JSWebAPIErrorFactory::postException(context, exception, DeviceAPI::Common::JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR);
        }
-
        return false;
 }
 
index 0a99561..a5d864b 100755 (executable)
@@ -526,6 +526,11 @@ JSValueRef JSMediacontentManager::updateItem(
             }
         }
 
+        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);
 
index e4d6479..b897667 100755 (executable)
@@ -55,7 +55,7 @@ JSClassDefinition JSImage::m_classInfo =
        finalize,
        NULL, //hasProperty,
        NULL, //getProperty,
-       NULL, //setProperty,
+       setProperty, //setProperty,
        NULL, //DeleteProperty,
        NULL, //GetPropertyNames,
        NULL, //CallAsFunction,
@@ -139,31 +139,6 @@ MediacontentImagePtr JSImage::getImageObject(JSObjectRef object)
     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,
@@ -254,36 +229,25 @@ bool      JSImage::setPropertyOrientation(
     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;
 }
 
+
 }
 }
 
index 4149104..1ab6c38 100755 (executable)
@@ -85,12 +85,6 @@ private:
      * Getters and setters for properties
      */
        
-    static JSValueRef  getPropertyGeoLocation(
-                                       JSContextRef context,
-                                       JSObjectRef object,
-                                       JSStringRef propertyName,
-                                       JSValueRef* exception);
-
     static JSValueRef  getPropertyWidth(
                                        JSContextRef context,
                                        JSObjectRef object,
@@ -110,13 +104,6 @@ private:
                                        JSStringRef propertyName,
                                        JSValueRef* exception);    
 
-      static bool              setPropertyGeolocation(
-                                       JSContextRef context,
-                                       JSObjectRef object,
-                                       JSStringRef propertyName,
-                                       JSValueRef value,
-                                       JSValueRef* exception); 
-         
     static bool                setPropertyOrientation(
                                        JSContextRef context,
                                        JSObjectRef object,
@@ -124,6 +111,12 @@ private:
                                        JSValueRef value,
                                        JSValueRef* exception); 
 
+    static bool         setProperty(
+                                JSContextRef context,
+                                JSObjectRef object,
+                                JSStringRef propertyName,
+                                JSValueRef value, 
+                                JSValueRef* exception);
 
 
  
index 1a605e5..1b3f9c3 100755 (executable)
@@ -53,7 +53,7 @@ JSClassDefinition JSVideo::m_classInfo =
        finalize,
        NULL, //hasProperty,
        NULL, //getProperty,
-       NULL, //setProperty,
+       setProperty, //setProperty,
        NULL, //DeleteProperty,
        NULL, //GetPropertyNames,
        NULL, //CallAsFunction,
@@ -144,59 +144,6 @@ MediacontentVideoPtr JSVideo::getVideoObject(JSObjectRef object)
     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, 
@@ -379,6 +326,23 @@ bool JSVideo::setPropertyAlbum(
        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;
+}
+
 
 }
 }
index a8a3f99..1679538 100755 (executable)
@@ -80,12 +80,6 @@ private:
      * Getters and setters for properties
      */
 
-    static JSValueRef  getPropertyGeoLocation(
-                                       JSContextRef context,
-                                       JSObjectRef object,
-                                       JSStringRef propertyName,
-                                       JSValueRef* exception);
-
     static JSValueRef  getPropertyAlbum(
                                        JSContextRef context,
                                        JSObjectRef object,
@@ -144,17 +138,15 @@ private:
                                        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);
+
 
 };
 
index e2abd79..c7344b4 100644 (file)
@@ -1147,6 +1147,7 @@ void Mms::updateMessage()
                msg_release_struct(&msg);
                msg_release_struct(&sendOpt);
                LoggerE("platform error occurs");
+               ReThrow(WrtDeviceApis::Commons::PlatformException);
        }
 }
 
index e98b951..1f61c85 100644 (file)
@@ -876,6 +876,7 @@ void Sms::updateMessage()
                msg_release_struct(&msg);
                msg_release_struct(&sendOpt);
                LoggerE("platform error occurs");
+               ReThrow(WrtDeviceApis::Commons::PlatformException);
        }
 }
 
index bbb4c9a..ff38708 100755 (executable)
@@ -60,7 +60,7 @@ static void connection_state_changed_callback(connection_profile_state_e state,
 
 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) {
@@ -156,6 +156,10 @@ NetworkBearerSelection::~NetworkBearerSelection()
 {
     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");
@@ -181,21 +185,16 @@ void NetworkBearerSelection::OnRequestReceived(const EventNetworkBearerSelection
         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);
 
@@ -220,6 +219,10 @@ void NetworkBearerSelection::OnRequestReceived(const EventNetworkBearerReleasePt
 
         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;
         }        
         
@@ -243,6 +246,10 @@ void NetworkBearerSelection::reLaunchConnection(const EventNetworkBearerSelectio
 
     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;
     }
@@ -261,27 +268,25 @@ void NetworkBearerSelection::removeStateChangeListener(const EventNetworkBearerS
 {
     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;
@@ -297,6 +302,10 @@ void NetworkBearerSelection::registStateChangeListener(const EventNetworkBearerS
 
        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 {
@@ -313,7 +322,10 @@ void NetworkBearerSelection::registStateChangeListener(const EventNetworkBearerS
             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;
     }
 
@@ -323,6 +335,10 @@ void NetworkBearerSelection::registStateChangeListener(const EventNetworkBearerS
     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 {
@@ -333,7 +349,10 @@ void NetworkBearerSelection::registStateChangeListener(const EventNetworkBearerS
 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);         
 }
@@ -358,7 +377,10 @@ void NetworkBearerSelection::makeRequestCallback(const EventNetworkBearerSelecti
         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;
     }
index bd00cd7..b270a59 100755 (executable)
@@ -740,7 +740,7 @@ void JSStatusNotification::setPrivateObject(JSContextRef context, JSObjectRef ob
     else
     {
            JSUtil::setProperty(context, object, NOTIFICATION_ID,
-                   JSValueMakeNull(context), kJSPropertyAttributeReadOnly);
+                   JSValueMakeUndefined(context), kJSPropertyAttributeReadOnly);
     }
 
     //postedTime
index d15508b..27e8e09 100755 (executable)
@@ -692,11 +692,16 @@ JSValueRef JSDeviceCapabilitiesInfo::getProperty(JSContextRef context, JSObjectR
                 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;
                 }
             }
index 2e36243..fc05c1e 100755 (executable)
@@ -34,16 +34,17 @@ namespace {
        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")
        {
        }
 };
index 9e836eb..20b7521 100755 (executable)
@@ -114,10 +114,17 @@ JSValueRef JSTimeDuration::getProperty(JSContextRef context, JSObjectRef object,
                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());
@@ -147,26 +154,22 @@ bool JSTimeDuration::setProperty(JSContextRef context, JSObjectRef object,
                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;
 }
@@ -205,9 +208,9 @@ JSObjectRef JSTimeDuration::constructor(JSContextRef ctx, JSObjectRef constructo
 
                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)");
                        }
                }
index d7d5653..bb04c8b 100755 (executable)
@@ -285,23 +285,43 @@ long TZDate::getUTC(const TZDateFields field)
                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");
 }
 
index df96235..e5e1024 100755 (executable)
@@ -48,7 +48,7 @@ short TimeUtilConverter::toShort(const JSValueRef& arg)
 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);
@@ -100,7 +100,7 @@ JSObjectRef TimeUtilConverter::makeMillisecondDurationObject(const long long len
 
 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)));
@@ -112,13 +112,15 @@ DurationProperties TimeUtilConverter::getDurationProperties(JSValueRef 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);
@@ -139,7 +141,7 @@ long long TimeUtilConverter::getDurationLength(JSObjectRef object) {
 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);
@@ -158,6 +160,28 @@ short TimeUtilConverter::getDurationUnit(JSObjectRef object) {
 
 }
 
+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;
@@ -170,7 +194,7 @@ short TimeUtilConverter::toDurationUnit(std::string strUnit) {
        else if (!strUnit.compare("MSECS"))
                return  MSECS_UNIT;
        else
-               return 0xff;
+               return WRONG_UNIT;
 }
 
 std::string TimeUtilConverter::toDurationUnitString(short unit) {
@@ -191,8 +215,10 @@ 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;
@@ -260,13 +286,14 @@ DurationProperties TimeUtilConverter::optimizedTimeDuration(DurationProperties o
                        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);
 
@@ -276,7 +303,7 @@ double TimeUtilConverter::getTimeInMilliseconds(JSValueRef 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));
@@ -293,7 +320,7 @@ double TimeUtilConverter::getTimeInMilliseconds(JSObjectRef 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);
 
@@ -303,7 +330,7 @@ tm TimeUtilConverter::toTZDateTime(JSValueRef 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));
@@ -315,7 +342,7 @@ tm TimeUtilConverter::toTZDateTime(JSObjectRef 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;
index e29d558..a28d716 100755 (executable)
@@ -55,6 +55,8 @@ class TimeUtilConverter : public Converter
        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);