Update change log and spec for wrt-plugins-tizen_0.2.82
authorKisub Song <kisubs.song@samsung.com>
Tue, 11 Sep 2012 10:16:41 +0000 (19:16 +0900)
committerKisub Song <kisubs.song@samsung.com>
Tue, 11 Sep 2012 10:16:41 +0000 (19:16 +0900)
Changed Modules : Calendar and TimeUtil

[Version] 0.2.82
[Project] GT-I8800, Public
[Title] SEL Verification
[Team] WebAPI
[BinType] PDA
[Customer] Open

[Issue#] S1-8507
[Problem] Calendar - Crash while converting recurrent event to web event
[Cause] missing null check before strtok
[Solution] Add null check

[Issue#] N_SE-9207
[Problem] TimeUtil - addDuration(new tizen.TimeDuration(2222222222, DAYS)) result has minus value.
[Cause] The type of TimeDuration's length is long long. But the parameter type of add in ICU is int32. So type conversion problem occurs.
[Solution] If TimeDuration's length is over int32's max/min value, it will be added first within the limits of the possible and the rest will be added next. And If result is over max/min value that can be handled in ICU, it will raise an UNKNOWN Exception.

[SCMRequest] N/A

Change-Id: I47418cd43b86a724b034afbfa1d3b1322179aac5

debian/changelog
packaging/wrt-plugins-tizen.spec
src/platform/Tizen/Calendar/EventWrapper.cpp
src/platform/Tizen/TimeUtil/TZDate.cpp
src/standards/Tizen/TimeUtil/JSTZDate.cpp

index c192f2c..3833d99 100644 (file)
@@ -1,5 +1,13 @@
 wrt-plugins-tizen (0.2.81) unstable; urgency=low
 
+  * Bug fix on Calendar and TimeUtil
+  * Git : framework/web/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.82
+
+ -- Kisub Song <kisubs.song@samsung.com>  Tue, 11 Sep 2012 18:29:57 +0900
+
+wrt-plugins-tizen (0.2.81) unstable; urgency=low
+
   * Bug fix on Device, Contact
   * git : slp/pkgs/w/wrt-plugins-tizen
   * Tag : wrt-plugins-tizen_0.2.81
index 7e9f159..b46028c 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       wrt-plugins-tizen
 Summary:    JavaScript plugins for WebRuntime
-Version:    0.2.81
+Version:    0.2.82
 Release:    0
 Group:      TO_BE_FILLED
 License:    TO_BE_FILLED
index 3a52c91..9065f34 100755 (executable)
@@ -1234,16 +1234,16 @@ void EventWrapper::setCompletedDateToPlatformEvent()
 
 void EventWrapper::setProgressToPlatformEvent()
 {
-       if (!m_platformEvent) {
-               ThrowMsg(UnknownException, "Null platform pointer.");
-       }
+    if (!m_platformEvent) {
+        ThrowMsg(UnknownException, "Null platform pointer.");
+    }
 
-       int progress = m_abstractEvent->getProgress();
-       if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
-               CAL_VALUE_INT_PROGRESS,
-               progress)) {
-               ThrowMsg(PlatformException, "Can't set visibility.");
-       }
+    int progress = m_abstractEvent->getProgress();
+    if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
+        CAL_VALUE_INT_PROGRESS,
+        progress)) {
+        ThrowMsg(PlatformException, "Can't set visibility.");
+    }
 }
 
 CalendarEventPtr EventWrapper::convertPlatformEventToAbstractEvent()
@@ -1385,10 +1385,13 @@ void EventWrapper::setRecurrenceRuleFromPlatformEvent()
     std::vector<std::string> daysOfTheWeek;
     char* byday = calendar_svc_struct_get_str(m_platformEvent, CALS_VALUE_TXT_RRULE_BYDAY);
     LogInfo("Loaded byday: "<<byday);
-    char* pch = strtok(byday, ",");
-    while (NULL != pch) {
-        daysOfTheWeek.push_back(pch);
-        pch = strtok(NULL, ",");
+    if (byday) {
+        char *saveptr = NULL;
+        char* pch = strtok_r(byday, ",", &saveptr);
+        while (NULL != pch) {
+            daysOfTheWeek.push_back(pch);
+            pch = strtok_r(NULL, ",", &saveptr);
+        }
     }
     rrule->setDaysOfTheWeek(daysOfTheWeek);
     LogInfo("Number of daysOfTheWeek: "<<rrule->getDaysOfTheWeek().size());
@@ -1404,19 +1407,22 @@ void EventWrapper::setRecurrenceRuleFromPlatformEvent()
     // load the recurrence end date
     long long int endDate = calendar_svc_struct_get_lli(m_platformEvent, CALS_VALUE_LLI_RRULE_UNTIL_UTIME);
     rrule->setEndDate(endDate);
-       LogDebug("endDate from platform = " << endDate);
+    LogDebug("endDate from platform = " << endDate);
 
     // load the exceptions
     std::vector<long long int> exceptions;
     char* exdate = calendar_svc_struct_get_str(m_platformEvent, CAL_VALUE_TXT_EXDATE);
     LogInfo("Loaded exdate: "<<exdate);
-    pch = strtok(exdate, ",");
-    while (NULL != pch) {
-        std::stringstream ss(pch);
-        long long int oneException;
-        ss>>oneException;
-        exceptions.push_back(oneException);
-        pch = strtok(NULL, ",");
+    if (exdate) {
+        char *saveptr = NULL;
+        char *pch = strtok_r(exdate, ",", &saveptr);
+        while (NULL != pch) {
+            std::stringstream ss(pch);
+            long long int oneException;
+            ss>>oneException;
+            exceptions.push_back(oneException);
+            pch = strtok_r(NULL, ",", &saveptr);
+        }
     }
     rrule->setExceptions(exceptions);
     LogInfo("Number of exceptions: "<<rrule->getExceptions().size());
@@ -1531,15 +1537,16 @@ void EventWrapper::setCategoriesFromPlatformEvent()
             m_platformEvent,
             CAL_VALUE_TXT_CATEGORIES);
 
-       if( categories ) {
-           LogInfo("Loaded categories: "<<categories);
+    if( categories ) {
+        LogInfo("Loaded categories: "<<categories);
 
-           char* pch = strtok(categories, ",");
-           while (NULL != pch) {
-               m_abstractEvent->getCategories()->push_back(pch);
-               pch = strtok(NULL, ",");
-           }
-       }
+        char *saveptr = NULL;
+        char* pch = strtok_r(categories, ",", &saveptr);
+        while (NULL != pch) {
+            m_abstractEvent->getCategories()->push_back(pch);
+            pch = strtok_r(NULL, ",", &saveptr);
+        }
+    }
 
     LogInfo("Number of categories: "<<m_abstractEvent->getCategories()->size());
 }
@@ -1563,8 +1570,8 @@ void EventWrapper::setParentIdFromPlatformEvent()
         ThrowMsg(UnknownException, "Null platform pointer.");
     }
 
-       int parentId = calendar_svc_struct_get_int(m_platformEvent,
-               CAL_VALUE_INT_ORIGINAL_EVENT_ID);
+    int parentId = calendar_svc_struct_get_int(m_platformEvent,
+        CAL_VALUE_INT_ORIGINAL_EVENT_ID);
 
     m_abstractEvent->setParentId(parentId);
 }
index cfb92d6..6d04085 100755 (executable)
@@ -372,17 +372,77 @@ TZDateProperties TZDate::addDuration(const DurationProperties &duration) {
        TimeUtilTools util;
 
        Calendar *cal = myCalendar->clone();
-       if (duration.unit == DAYS_UNIT) {
-               cal->add(UCAL_DATE, util.toint32_t(duration.length), ec);
-       } else if (duration.unit == MINUTES_UNIT) {
-               cal->add(UCAL_MINUTE, util.toint32_t(duration.length), ec);
-       } else if (duration.unit == HOURS_UNIT) {
-               cal->add(UCAL_HOUR_OF_DAY, util.toint32_t(duration.length), ec);
-       } else if (duration.unit == MSECS_UNIT) {
-               cal->add(UCAL_MILLISECOND, util.toint32_t(duration.length), ec);
-       } else {
-               cal->add(UCAL_SECOND, util.toint32_t(duration.length), ec);
+       long long length = duration.length;
+       short unit = duration.unit;
+       int msec=0, sec=0, min=0, hour=0;
+       long long day=0;
+
+       if (unit == MSECS_UNIT) {
+               msec = length % 1000;
+               length /= 1000;
+               unit = SECONDS_UNIT;
+       }
+       if ((length != 0) && (unit == SECONDS_UNIT)) {
+               sec = length % 60;
+               length /= 60;
+               unit = MINUTES_UNIT;
+       }
+       if ((length != 0) && (unit == MINUTES_UNIT)) {
+               min = length % 60;
+               length /= 60;
+               unit = HOURS_UNIT;
+       }
+       if ((length != 0) && (unit == HOURS_UNIT)) {
+               hour = length % 24;
+               length /= 24;
+               unit = DAYS_UNIT;
+       }
+       day = length;
+       LogDebug("day:"<<day<<" hour:"<<hour<<" min:"<<min<<" sec:"<<sec<<" msec:"<<msec);
+       try {
+               if (msec != 0) {
+                       cal->add(UCAL_MILLISECOND, util.toint32_t(msec), ec);
+                       if (!U_SUCCESS(ec))
+                               Throw(Commons::PlatformException);
+               }
+               if (sec != 0) {
+                       cal->add(UCAL_SECOND, util.toint32_t(sec), ec);
+                       if (!U_SUCCESS(ec))
+                               Throw(Commons::PlatformException);
+               }
+               if (min != 0) {
+                       cal->add(UCAL_MINUTE, util.toint32_t(min), ec);
+                       if (!U_SUCCESS(ec))
+                               Throw(Commons::PlatformException);
+               }
+               if (hour != 0) {
+                       cal->add(UCAL_HOUR_OF_DAY, util.toint32_t(hour), ec);
+                       if (!U_SUCCESS(ec))
+                               Throw(Commons::PlatformException);
+               }
+               while (day != 0) {
+                       LogDebug("1st day : " << day);
+                       int amount = 0;
+
+                       if (day < INT_MIN)
+                               amount = INT_MIN;
+                       else if (day > INT_MAX)
+                               amount = INT_MAX;
+                       else
+                               amount = day;
+
+                       day -= amount;
+                       LogDebug("amount : " << amount);
+                       LogDebug("2nd day : " << day);
+                       cal->add(UCAL_DATE, util.toint32_t(amount), ec);
+                       if (!U_SUCCESS(ec))
+                               Throw(Commons::PlatformException);
+               } ;
+       } catch (Commons::PlatformException) {
+               delete cal;
+               ThrowMsg(Commons::PlatformException, "Calendar error in addDuration");
        }
+
        TZDateProperties result = _makeProperties(cal);
        util.printDate(cal);
        delete cal;
index 1706c5f..0151ee8 100755 (executable)
@@ -595,6 +595,13 @@ JSValueRef JSTZDate::addDuration(JSContextRef context, JSObjectRef function,
 
                ITZDatePtr tzDate(privateObject->getObject());
                TZDateProperties result = tzDate->addDuration(duration);
+
+                long long diff = -(tzDate->difference(result));
+                long long durationtoMsec = converter.convertDurationLength(duration, MSECS_UNIT);
+               if (diff != durationtoMsec) {
+                       LogError("result - orignal != duration diff:"<<diff <<"durationtoMsec:" << durationtoMsec);
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "The result is beyond the scope that TZDate can handle.");
+               }
                return (static_cast<JSValueRef>(createJSObject(context, result)));
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());