Update change log and spec for wrt-plugins-tizen_0.2.84
authorKisub Song <kisubs.song@samsung.com>
Sat, 15 Sep 2012 14:20:24 +0000 (23:20 +0900)
committerKisub Song <kisubs.song@samsung.com>
Sat, 15 Sep 2012 14:20:24 +0000 (23:20 +0900)
Changed Modules : Messaging, Call, LBS and Contact

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

[Issue#] N_SE-10078
[Problem] Messaging - addDraftMessage is success with small receipt
number
[Cause] exception is not thrown for invaild number
[Solution] throw exception on invalid case

[Issue#] N/A
[Problem] Call - Can not remove all events listener in destructor.
[Cause] N/A
[Solution] Fixed bug of increase of iterator pointer.

[Issue#] N/A
[Problem] LBS - Some test cases are failed
[Cause] input parameter is not handled properly.
[Solution] modify code

[Issue#] N_SE-10181
[Problem] Messaging - Crash during addMessageChangeListener Lto new
messages
[Cause] wrong array index
[Solution] fix the last array index from mesgId to mesg count

[Issue#] N/A
[Problem] Contact - getting wrong category list from find function
[Cause] Calc wrong index from list
[Solution] Fixed index inc rule

[SCMRequest] N/A

Change-Id: Ieac8df0ce242d5ad0c0e49326f76b425e425eceb

30 files changed:
debian/changelog
packaging/wrt-plugins-tizen.spec
src/platform/API/Calendar/CalendarEvent.cpp
src/platform/API/Calendar/CalendarEvent.h
src/platform/API/Calendar/EventAlarm.cpp
src/platform/API/Calendar/EventAlarm.h
src/platform/API/Calendar/EventRecurrenceRule.cpp
src/platform/API/Calendar/EventRecurrenceRule.h
src/platform/Tizen/Calendar/Calendar.cpp
src/platform/Tizen/Calendar/EventWrapper.cpp
src/platform/Tizen/Calendar/EventWrapper.h
src/platform/Tizen/Call/CallHistory.cpp
src/platform/Tizen/Contact/query-svc/query-svc.c
src/platform/Tizen/Messaging/Conversation.cpp
src/platform/Tizen/Messaging/Sms.cpp
src/standards/Tizen/Calendar/CMakeLists.txt
src/standards/Tizen/Calendar/CalendarConverter.cpp
src/standards/Tizen/Calendar/CalendarConverter.h
src/standards/Tizen/Calendar/CalendarResponseDispatcher.cpp
src/standards/Tizen/Calendar/JSCalendar.cpp
src/standards/Tizen/Calendar/JSCalendarAlarm.cpp
src/standards/Tizen/Calendar/JSCalendarEvent.cpp
src/standards/Tizen/Calendar/JSCalendarItemProperties.cpp
src/standards/Tizen/Calendar/JSCalendarRecurrenceRule.cpp
src/standards/Tizen/Calendar/JSNumberArray.cpp [new file with mode: 0755]
src/standards/Tizen/Calendar/JSNumberArray.h [new file with mode: 0755]
src/standards/Tizen/Calendar/JSStringArray.cpp [new file with mode: 0755]
src/standards/Tizen/Calendar/JSStringArray.h [new file with mode: 0755]
src/standards/Tizen/Call/JSCallHistoryEntry.cpp
src/standards/Tizen/LBS/JSLocationServiceProvider.cpp

index 1ce591e..3a16bc8 100644 (file)
@@ -1,3 +1,11 @@
+wrt-plugins-tizen (0.2.84) unstable; urgency=low
+
+  * Bug fix on Application
+  * Git : framework/web/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.84
+
+ -- Kisub Song <kisubs.song@samsung.com>  Sat, 15 Sep 2012 23:14:41 +0900
+
 wrt-plugins-tizen (0.2.83) unstable; urgency=low
 
   * Bug fix on Application
index 9e7c9a8..263c9a8 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       wrt-plugins-tizen
 Summary:    JavaScript plugins for WebRuntime
-Version:    0.2.83
+Version:    0.2.84
 Release:    0
 Group:      TO_BE_FILLED
 License:    TO_BE_FILLED
index c22402f..7546bde 100755 (executable)
@@ -31,7 +31,8 @@ CalendarEvent::CalendarEvent():
     m_endTime(UNDEFINED_TIME),
     m_recurrence(new EventRecurrenceRule()),
     m_status(UNDEFINED_STATUS),
-    m_categories(new CategoryList()),
+    m_alarms(new EventAlarmList()),
+    m_categories(new StringArray()),
     m_isAllDay(false),
     m_lastModifiedDate(UNDEFINED_TIME),
     m_visibility(PUBLIC_VISIBILITY),
@@ -80,11 +81,21 @@ CalendarEvent::CalendarEvent(const CalendarEvent &original)
     m_recurrence->setTimeZone(original.getRecurrenceRule()->getTimeZone());
 
     m_status = original.getStatus();
-    m_alarmsTick = original.getAlarmsTick();
-    m_alarmsType = original.getAlarmsType();
-    m_alarmsDescription = original.getAlarmsDescription();
 
-    CategoryListPtr categoriesPtr( new CategoryList() );
+    LogDebug("Copying alarms...");
+    EventAlarmListPtr alarmsPtr( new EventAlarmList() );
+    m_alarms = alarmsPtr;
+    for( unsigned int i=0; i<original.getAlarms()->size(); i++) {
+        EventAlarmPtr alarmPtr( new EventAlarm() );
+        alarmPtr->setAbsoluteDate(original.getAlarms()->at(i)->getAbsoluteDate());
+        alarmPtr->setDuration(original.getAlarms()->at(i)->getDuration());
+        alarmPtr->setMethods(original.getAlarms()->at(i)->getMethods());
+        alarmPtr->setTimeZone(original.getAlarms()->at(i)->getTimeZone());
+        alarmPtr->setDescription(original.getAlarms()->at(i)->getDescription());
+        m_alarms->push_back(alarmPtr);
+    }
+
+    StringArrayPtr categoriesPtr( new StringArray() );
     m_categories = categoriesPtr;
     *m_categories = *(original.getCategories());
 
@@ -255,41 +266,20 @@ void CalendarEvent::setStatus(EventStatus value)
     m_status = value;
 }
 
-std::vector<long> CalendarEvent::getAlarmsTick() const
-{
-    return m_alarmsTick;
-}
-
-void CalendarEvent::setAlarmsTick(std::vector<long> &value)
-{
-    m_alarmsTick = value;
-}
-
-std::vector<CalendarEvent::EventAlarmType> CalendarEvent::getAlarmsType() const
+EventAlarmListPtr CalendarEvent::getAlarms() const
 {
-    return m_alarmsType;
+    return m_alarms;
 }
-
-void CalendarEvent::setAlarmsType(std::vector<EventAlarmType> &value)
-{
-    m_alarmsType = value;
-}
-
-std::vector<std::string> CalendarEvent::getAlarmsDescription() const
-{
-    return m_alarmsDescription;
-}
-
-void CalendarEvent::setAlarmsDescription(std::vector<std::string> &value)
+void CalendarEvent::setAlarms(const EventAlarmListPtr value)
 {
-    m_alarmsDescription = value;
+    m_alarms = value;
 }
 
-CategoryListPtr CalendarEvent::getCategories() const
+StringArrayPtr CalendarEvent::getCategories() const
 {
     return m_categories;
 }
-void CalendarEvent::setCategories(const CategoryListPtr &value)
+void CalendarEvent::setCategories(const StringArrayPtr value)
 {
     m_categories = value;
 }
@@ -404,7 +394,7 @@ EventAttendeeListPtr CalendarEvent::getAttendees() const
     return m_attendees;
 }
 
-void CalendarEvent::setAttendees(const EventAttendeeListPtr &value)
+void CalendarEvent::setAttendees(const EventAttendeeListPtr value)
 {
     m_attendees = value;
 }
index caf7f49..20af461 100755 (executable)
@@ -23,6 +23,7 @@
 #include <vector>
 #include <dpl/shared_ptr.h>
 
+#include "EventAlarm.h"
 #include "EventAttendee.h"
 #include "EventRecurrenceRule.h"
 
@@ -36,9 +37,6 @@ namespace Calendar {
 #define UNDEFINED_GEO 0
 #define UNDEFINED_ID "0"
 
-typedef std::vector<std::string> CategoryList;
-typedef DPL::SharedPtr<CategoryList> CategoryListPtr;
-
 typedef std::vector<std::string> AttributeList;
 typedef DPL::SharedPtr<AttributeList> AttributeListPtr;
 
@@ -59,14 +57,6 @@ class CalendarEvent
 
     typedef enum
     {
-        NO_ALARM,
-        SILENT_ALARM,
-        SOUND_ALARM,
-        UNDEFINED_ALARM_TYPE
-    } EventAlarmType;
-
-    typedef enum
-    {
         PUBLIC_VISIBILITY,
         PRIVATE_VISIBILITY,
         CONFIDENTIAL_VISIBILITY,
@@ -141,17 +131,11 @@ class CalendarEvent
     EventStatus getStatus() const;
     void setStatus(EventStatus value);
 
-    std::vector<long> getAlarmsTick() const;
-    void setAlarmsTick(std::vector<long> &value);
-
-    std::vector<EventAlarmType> getAlarmsType() const;
-    void setAlarmsType(std::vector<EventAlarmType> &value);
-
-    std::vector<std::string> getAlarmsDescription() const;
-    void setAlarmsDescription(std::vector<std::string> &value);
+    EventAlarmListPtr getAlarms() const;
+    void setAlarms(const EventAlarmListPtr value);
 
-    CategoryListPtr getCategories() const;
-    void setCategories(const CategoryListPtr &value);
+    StringArrayPtr getCategories() const;
+    void setCategories(const StringArrayPtr value);
 
     void display() const;
     bool validate() const;
@@ -178,7 +162,7 @@ class CalendarEvent
     void setRecurrenceId(long long int value);
 
     EventAttendeeListPtr getAttendees() const;
-    void setAttendees(const EventAttendeeListPtr &value);
+    void setAttendees(const EventAttendeeListPtr value);
 
     bool getIsDetached() const;
     void setIsDetached(bool value);
@@ -221,10 +205,8 @@ class CalendarEvent
     std::string m_location;
     EventRecurrenceRulePtr m_recurrence;
     EventStatus m_status;
-    std::vector<long> m_alarmsTick;
-    std::vector<EventAlarmType> m_alarmsType;
-    std::vector<std::string> m_alarmsDescription;
-    CategoryListPtr m_categories;
+    EventAlarmListPtr m_alarms;
+    StringArrayPtr m_categories;
     bool m_isAllDay;
     std::string m_organizer;
     long long int m_lastModifiedDate;
index 576a66f..8d87b96 100755 (executable)
@@ -16,6 +16,7 @@
 
 
 #include "EventAlarm.h"
+#include "EventRecurrenceRule.h"
 #include <dpl/log/log.h>
 
 namespace TizenApis {
@@ -49,11 +50,11 @@ void EventAlarm::setDuration(TizenApis::Api::TimeUtil::DurationProperties value)
     m_duration = value;
 }
 
-std::vector<CalendarEvent::EventAlarmType> EventAlarm::getMethods() const
+std::vector<EventAlarm::EventAlarmType> EventAlarm::getMethods() const
 {
     return m_methods;
 }
-void EventAlarm::setMethods(const std::vector<CalendarEvent::EventAlarmType> &value)
+void EventAlarm::setMethods(const std::vector<EventAlarm::EventAlarmType> &value)
 {
     m_methods = value;
 }
index c00728f..6c0eb82 100755 (executable)
@@ -22,7 +22,6 @@
 #include <ctime>
 #include <string>
 #include <dpl/shared_ptr.h>
-#include "CalendarEvent.h"
 #include "API/TimeUtil/DurationProperties.h"
 
 namespace TizenApis {
@@ -32,6 +31,14 @@ namespace Calendar {
 class EventAlarm
 {
   public:
+    typedef enum
+    {
+        NO_ALARM,
+        SILENT_ALARM,
+        SOUND_ALARM,
+        UNDEFINED_ALARM_TYPE
+    } EventAlarmType;
+
     EventAlarm();
     virtual ~EventAlarm();
 
@@ -41,8 +48,8 @@ class EventAlarm
     TizenApis::Api::TimeUtil::DurationProperties getDuration() const;
     void setDuration(TizenApis::Api::TimeUtil::DurationProperties value);
 
-    std::vector<CalendarEvent::EventAlarmType> getMethods() const;
-    void setMethods(const std::vector<CalendarEvent::EventAlarmType> &value);
+    std::vector<EventAlarmType> getMethods() const;
+    void setMethods(const std::vector<EventAlarmType> &value);
 
     std::string getTimeZone() const;
     void setTimeZone(const std::string &value);
@@ -53,7 +60,7 @@ class EventAlarm
   protected:
     long long int m_absoluteDate;
     TizenApis::Api::TimeUtil::DurationProperties m_duration;
-    std::vector<CalendarEvent::EventAlarmType> m_methods;
+    std::vector<EventAlarmType> m_methods;
     std::string m_description;
     std::string m_timeZone;
 };
index 459a4a8..8519cf3 100755 (executable)
@@ -29,7 +29,11 @@ EventRecurrenceRule::EventRecurrenceRule()
     m_interval = DEFAULT_INTERVAL;
     m_endDate = UNDEFINED_TIME;
     m_occurrenceCount = -1;
+    StringArrayPtr stringArrayPtr(new StringArray());
+    m_daysOfTheWeek = stringArrayPtr;
     m_setPosition = false;
+    NumberArrayPtr numberArrayPtr(new NumberArray());
+    m_exceptions = numberArrayPtr;
     m_timeZone = DEFAULT_TIMEZONE;
 }
 
@@ -86,12 +90,12 @@ void EventRecurrenceRule::setDaysOfTheMonth(std::vector<int> value)
     m_daysOfTheMonth = value;
 }
 
-std::vector<std::string> EventRecurrenceRule::getDaysOfTheWeek() const
+StringArrayPtr EventRecurrenceRule::getDaysOfTheWeek() const
 {
     return m_daysOfTheWeek;
 }
 
-void EventRecurrenceRule::setDaysOfTheWeek(std::vector<std::string> value)
+void EventRecurrenceRule::setDaysOfTheWeek(StringArrayPtr value)
 {
     m_daysOfTheWeek = value;
 }
@@ -126,12 +130,12 @@ void EventRecurrenceRule::setSetPosition(bool value)
     m_setPosition = value;
 }
 
-std::vector<long long int> EventRecurrenceRule::getExceptions() const
+NumberArrayPtr EventRecurrenceRule::getExceptions() const
 {
     return m_exceptions;
 }
 
-void EventRecurrenceRule::setExceptions(std::vector<long long int> value)
+void EventRecurrenceRule::setExceptions(NumberArrayPtr value)
 {
     m_exceptions = value;
 }
index 2185f1a..1f1d467 100755 (executable)
@@ -27,8 +27,14 @@ namespace TizenApis {
 namespace Api {
 namespace Calendar {
 
+typedef std::vector<std::string> StringArray;
+typedef DPL::SharedPtr<StringArray> StringArrayPtr;
+
+typedef std::vector<long long int> NumberArray;
+typedef DPL::SharedPtr<NumberArray> NumberArrayPtr;
+
 #define UNDEFINED_TIME -1
-#define DEFAULT_TIMEZONE "UTC"
+#define DEFAULT_TIMEZONE ""
 #define DEFAULT_INTERVAL 1
 
 class EventRecurrenceRule
@@ -63,8 +69,8 @@ class EventRecurrenceRule
     std::vector<int> getDaysOfTheMonth() const;
     void setDaysOfTheMonth(std::vector<int> value);
 
-    std::vector<std::string> getDaysOfTheWeek() const;
-    void setDaysOfTheWeek(std::vector<std::string> value);
+    StringArrayPtr getDaysOfTheWeek() const;
+    void setDaysOfTheWeek(StringArrayPtr value);
 
     std::vector<int> getDaysOfTheYear() const;
     void setDaysOfTheYear(std::vector<int> value);
@@ -75,8 +81,8 @@ class EventRecurrenceRule
     bool getSetPosition() const;
     void setSetPosition(bool value);
 
-    std::vector<long long int> getExceptions() const;
-    void setExceptions(std::vector<long long int> value);
+    NumberArrayPtr getExceptions() const;
+    void setExceptions(NumberArrayPtr value);
 
     std::string getTimeZone() const;
     void setTimeZone(std::string value);
@@ -87,11 +93,11 @@ class EventRecurrenceRule
     long long int m_endDate;
     long m_occurrenceCount;
     std::vector<int> m_daysOfTheMonth;
-    std::vector<std::string> m_daysOfTheWeek;
+    StringArrayPtr m_daysOfTheWeek;
     std::vector<int> m_daysOfTheYear;
     std::vector<int> m_weeksOfTheYear;
     bool m_setPosition;
-    std::vector<long long int> m_exceptions;
+    NumberArrayPtr m_exceptions;
     std::string m_timeZone;
 };
 
index ffd20b6..7d7b600 100755 (executable)
@@ -861,7 +861,7 @@ void Calendar::OnRequestReceived(const IEventExpandEventRecurrencePtr &event)
     Try {
         if ( 0 >= calEvent->getRecurrenceRule()->getFrequency())
         {
-            ThrowMsg(PlatformException, "This is not a recurring event.");
+            ThrowMsg(InvalidArgumentException, "This is not a recurring event.");
         }
 
         DPL::ScopedPtr<EventWrapper> eventWrapper(new EventWrapper(CalendarEvent::EVENT_TYPE));
@@ -943,6 +943,12 @@ void Calendar::OnRequestReceived(const IEventExpandEventRecurrencePtr &event)
 
         LogInfo("Length of total expanded events: "<<event->getExpandedEventList()->size());
     }
+    Catch (InvalidArgumentException)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        event->setResult(false);
+        event->setExceptionCode(ExceptionCodes::InvalidArgumentException);
+    }
     Catch (Exception)
     {
         LogWarning("Exception: "<<_rethrown_exception.GetMessage());
index 9065f34..63a9df5 100755 (executable)
@@ -281,7 +281,7 @@ void EventWrapper::deleteEvent()
             ThrowMsg(PlatformException, "Can't delete the instance. Error code " << error);
         }
 
-        m_abstractEvent->getRecurrenceRule()->getExceptions().push_back(recurrenceId);
+        (*m_abstractEvent->getRecurrenceRule()->getExceptions()).push_back(recurrenceId);
         LogDebug("The recurring event is updated.");
     }
 }
@@ -544,7 +544,7 @@ void EventWrapper::setRecurrenceRuleToPlatformEvent()
     }
     case EventRecurrenceRule::YEARLY_RECURRENCE:
     {
-        if(CAL_SUCCESS!=calendar_svc_struct_set_int(m_platformEvent, CALS_VALUE_INT_RRULE_FREQ, CAL_REPEAT_EVERY_YEAR)) {
+        if(CAL_SUCCESS!=calendar_svc_struct_set_int(m_platformEvent, CALS_VALUE_INT_RRULE_FREQ, CALS_FREQ_YEARLY)) {
             ThrowMsg(PlatformException, "Failed setting frequency.");
         }
         break;
@@ -556,12 +556,12 @@ void EventWrapper::setRecurrenceRuleToPlatformEvent()
     }
 
     // set byday
-    std::vector<std::string> daysOfTheWeek = rrule->getDaysOfTheWeek();
-    if( 0 != daysOfTheWeek.size() ) {
+    StringArrayPtr daysOfTheWeek = rrule->getDaysOfTheWeek();
+    if( 0 != daysOfTheWeek->size() ) {
         std::string byday = "";
-        for(unsigned int i=0; i<daysOfTheWeek.size(); i++) {
-            byday.append(daysOfTheWeek.at(i));
-            if(i!=daysOfTheWeek.size()-1) {
+        for(unsigned int i=0; i<daysOfTheWeek->size(); i++) {
+            byday.append(daysOfTheWeek->at(i));
+            if(i!=daysOfTheWeek->size()-1) {
                 byday.append(",");
             }
         }
@@ -586,17 +586,17 @@ void EventWrapper::setRecurrenceRuleToPlatformEvent()
     }
 
     // set the exceptions
-    if ( !rrule->getExceptions().empty() )
+    if ( !rrule->getExceptions()->empty() )
     {
-        LogInfo("Set the exceptions of length: "<<rrule->getExceptions().size());
+        LogInfo("Set the exceptions of length: "<<rrule->getExceptions()->size());
 
         std::string exdate = "";
-        for( unsigned int i=0; i<rrule->getExceptions().size(); i++ )
+        for( unsigned int i=0; i<rrule->getExceptions()->size(); i++ )
         {
             std::stringstream ss;
-            ss<<rrule->getExceptions().at(i);
+            ss<<rrule->getExceptions()->at(i);
             exdate.append(ss.str());
-            if(i!=rrule->getExceptions().size()-1) {
+            if(i!=rrule->getExceptions()->size()-1) {
                 exdate.append(",");
             }
         }
@@ -637,50 +637,89 @@ void EventWrapper::setAlarmsToPlatformEvent()
         ThrowMsg(UnknownException, "Null platform pointer.");
     }
 
-    if( 0 != m_abstractEvent->getAlarmsTick().size() ) {
+    if( 0 != m_abstractEvent->getAlarms()->size() ) {
+        int errorCode;
         GList* list = NULL;
         calendar_svc_struct_get_list(m_platformEvent, CAL_VALUE_LST_ALARM, &list);
 
-        for( unsigned int i=0; i<m_abstractEvent->getAlarmsTick().size(); i++ )
+        for( unsigned int i=0; i<m_abstractEvent->getAlarms()->size(); i++ )
         {
             LogInfo("Set the alarms #"<<i);
+            EventAlarmPtr theAlarm = m_abstractEvent->getAlarms()->at(i);
 
             cal_value *value = calendar_svc_value_new(CAL_VALUE_LST_ALARM);
 
-            // We have to use alarm tick and tick unit for alarm creation.
-            int errorCode = calendar_svc_value_set_int(
-                    value,
-                    CAL_VALUE_INT_ALARMS_TICK,
-                    m_abstractEvent->getAlarmsTick().at(i));
-            if (CAL_SUCCESS != errorCode) {
-                if (value) {
-                    calendar_svc_value_free(&value);
+            cal_sch_remind_tick_unit_t tickUnit = CAL_SCH_TIME_UNIT_OFF;
+            int tick = 0;
+            if( UNDEFINED_TIME!=theAlarm->getAbsoluteDate() ) {
+                tickUnit = CAL_SCH_TIME_UNIT_SPECIFIC;
+            } else {
+                if( TizenApis::Api::TimeUtil::MSECS_UNIT==theAlarm->getDuration().unit ) {
+                    tickUnit = CAL_SCH_TIME_UNIT_MIN; // minimum calendar time unit.
+                    tick = theAlarm->getDuration().length / 60000;
+                } else if( TizenApis::Api::TimeUtil::SECONDS_UNIT==theAlarm->getDuration().unit ) {
+                    tickUnit = CAL_SCH_TIME_UNIT_MIN;
+                    tick = theAlarm->getDuration().length / 1000;
+                } else if( TizenApis::Api::TimeUtil::MINUTES_UNIT==theAlarm->getDuration().unit ) {
+                    tickUnit = CAL_SCH_TIME_UNIT_MIN;
+                    tick = theAlarm->getDuration().length;
+                } else if( TizenApis::Api::TimeUtil::HOURS_UNIT==theAlarm->getDuration().unit ) {
+                    tickUnit = CAL_SCH_TIME_UNIT_HOUR;
+                    tick = theAlarm->getDuration().length;
+                } else if( TizenApis::Api::TimeUtil::DAYS_UNIT==theAlarm->getDuration().unit ) {
+                    tickUnit = CAL_SCH_TIME_UNIT_DAY;
+                    tick = theAlarm->getDuration().length;
+                } else {
+                    LogError("Wrong alarm time unit: "<<theAlarm->getDuration().unit);
+                }
+            }
+
+            if( CAL_SCH_TIME_UNIT_SPECIFIC==tickUnit ) {
+                long long int time = theAlarm->getAbsoluteDate();
+                LogInfo("Save absolute date: "<<time);
+                errorCode = calendar_svc_value_set_lli(value,
+                        CAL_VALUE_LLI_ALARMS_TIME,
+                        time);
+                if (CAL_SUCCESS != errorCode) {
+                    if (value) {
+                        calendar_svc_value_free(&value);
+                    }
+                    ThrowMsg(PlatformException, "Can't set alarm time: "<<errorCode);
+                }
+            } else {
+                errorCode = calendar_svc_value_set_int(
+                        value,
+                        CAL_VALUE_INT_ALARMS_TICK,
+                        tick);
+                if (CAL_SUCCESS != errorCode) {
+                    if (value) {
+                        calendar_svc_value_free(&value);
+                    }
+                    ThrowMsg(PlatformException, "Can't set alarm tick: "<<errorCode);
                 }
-                LogError("Can't set CAL_VALUE_INT_ALARMS_TICK, error: " << errorCode);
-                ThrowMsg(PlatformException, "Can't set alarm tick.");
             }
+
             errorCode = calendar_svc_value_set_int(
                     value,
                     CAL_VALUE_INT_ALARMS_TICK_UNIT,
-                    CAL_SCH_TIME_UNIT_MIN);
+                    tickUnit);
             if (CAL_SUCCESS != errorCode) {
                 if (value) {
                     calendar_svc_value_free(&value);
                 }
-                LogError("Can't set CAL_VALUE_INT_ALARMS_TICK_UNIT, error: " << errorCode);
-                ThrowMsg(PlatformException, "Can't set alarm tick unit.");
+                ThrowMsg(PlatformException, "Can't set alarm tick unit: "<<errorCode);
             }
 
             // Set the alarm type.
             cal_alert_type_t alarmType = CAL_ALERT_MELODY;
-            switch (m_abstractEvent->getAlarmsType().at(i)) {
-            case CalendarEvent::NO_ALARM:
+            switch (theAlarm->getMethods().at(0)) {
+            case EventAlarm::NO_ALARM:
                 alarmType = CAL_ALERT_MUTE;
                 break;
-            case CalendarEvent::SOUND_ALARM:
+            case EventAlarm::SOUND_ALARM:
                 alarmType = CAL_ALERT_MELODY;
                 break;
-            case CalendarEvent::SILENT_ALARM:
+            case EventAlarm::SILENT_ALARM:
                 alarmType = CAL_ALERT_VIBRATION;
                 break;
             default:
@@ -695,21 +734,19 @@ void EventWrapper::setAlarmsToPlatformEvent()
                 if (value) {
                     calendar_svc_value_free(&value);
                 }
-                LogError("Can't set CAL_VALUE_INT_ALARMS_TYPE, error: " << errorCode);
-                ThrowMsg(PlatformException, "Can't set alarm type.");
+                ThrowMsg(PlatformException, "Can't set alarm type: "<<errorCode);
             }
 
             // Set the display text
             errorCode = calendar_svc_value_set_str(
                     value,
                     CAL_VALUE_TXT_ALARMS_DESCRIPTION,
-                    m_abstractEvent->getAlarmsDescription().at(i).c_str());
+                    theAlarm->getDescription().c_str());
             if (CAL_SUCCESS != errorCode) {
                 if (value) {
                     calendar_svc_value_free(&value);
                 }
-                LogError("Can't set CAL_VALUE_TXT_ALARMS_DESCRIPTION, error: " << errorCode);
-                ThrowMsg(PlatformException, "Can't set alarm description.");
+                ThrowMsg(PlatformException, "Can't set alarm description: "<<errorCode);
             }
 
             list = g_list_append(list, value);
@@ -1123,6 +1160,7 @@ void EventWrapper::setAttendeesToPlatformEvent()
             std::stringstream ss(attendeeList->at(i)->getAddressBookId());
             int addressBookId;
             ss>>addressBookId;
+            LogInfo("addressBookId: "<<addressBookId);
             if (CAL_SUCCESS !=
                 calendar_svc_value_set_int(attendee, CAL_VALUE_INT_ATTENDEE_DETAIL_CT_INDEX,
                                            addressBookId)) {
@@ -1382,19 +1420,19 @@ void EventWrapper::setRecurrenceRuleFromPlatformEvent()
     }
 
     // load the byday
-    std::vector<std::string> daysOfTheWeek;
+    StringArrayPtr daysOfTheWeek(new StringArray());
     char* byday = calendar_svc_struct_get_str(m_platformEvent, CALS_VALUE_TXT_RRULE_BYDAY);
     LogInfo("Loaded byday: "<<byday);
     if (byday) {
         char *saveptr = NULL;
         char* pch = strtok_r(byday, ",", &saveptr);
         while (NULL != pch) {
-            daysOfTheWeek.push_back(pch);
+            (*daysOfTheWeek).push_back(pch);
             pch = strtok_r(NULL, ",", &saveptr);
         }
     }
     rrule->setDaysOfTheWeek(daysOfTheWeek);
-    LogInfo("Number of daysOfTheWeek: "<<rrule->getDaysOfTheWeek().size());
+    LogInfo("Number of daysOfTheWeek: "<<rrule->getDaysOfTheWeek()->size());
 
     // load the recurrence interval
     int interval = calendar_svc_struct_get_int(m_platformEvent, CALS_VALUE_INT_RRULE_INTERVAL);
@@ -1410,7 +1448,7 @@ void EventWrapper::setRecurrenceRuleFromPlatformEvent()
     LogDebug("endDate from platform = " << endDate);
 
     // load the exceptions
-    std::vector<long long int> exceptions;
+    NumberArrayPtr exceptions(new NumberArray());
     char* exdate = calendar_svc_struct_get_str(m_platformEvent, CAL_VALUE_TXT_EXDATE);
     LogInfo("Loaded exdate: "<<exdate);
     if (exdate) {
@@ -1420,12 +1458,12 @@ void EventWrapper::setRecurrenceRuleFromPlatformEvent()
             std::stringstream ss(pch);
             long long int oneException;
             ss>>oneException;
-            exceptions.push_back(oneException);
+            (*exceptions).push_back(oneException);
             pch = strtok_r(NULL, ",", &saveptr);
         }
     }
     rrule->setExceptions(exceptions);
-    LogInfo("Number of exceptions: "<<rrule->getExceptions().size());
+    LogInfo("Number of exceptions: "<<rrule->getExceptions()->size());
 
     // set the loaded recurrence rule
     m_abstractEvent->setRecurrenceRule(rrule);
@@ -1437,59 +1475,94 @@ void EventWrapper::setAlarmsFromPlatformEvent()
         ThrowMsg(UnknownException, "Null platform pointer.");
     }
 
-    std::vector<long> alarmsTick;
-    std::vector<CalendarEvent::EventAlarmType> alarmsType;
-    std::vector<std::string> alarmsDescription;
-
     GList* alarmList = NULL;
     calendar_svc_struct_get_list(m_platformEvent, CAL_VALUE_LST_ALARM, &alarmList);
     cal_value* alarmValue = NULL;
+    int tick, tickUnit;
     for (; alarmList; alarmList = g_list_next(alarmList)) {
         LogDebug("Processing alarm...");
         alarmValue = static_cast<cal_value*>(alarmList->data);
 
-        int tick = calendar_svc_value_get_int(alarmValue, CAL_VALUE_INT_ALARMS_TICK);
-        if (CAL_ERR_FAIL == tick) {
-            LogError("Cannot read alarm tick. Stop processing alarms.");
+        EventAlarmPtr theAlarm( new EventAlarm() );
+
+        tickUnit = calendar_svc_value_get_int(alarmValue, CAL_VALUE_INT_ALARMS_TICK_UNIT);
+        if (CAL_ERR_FAIL == tickUnit) {
+            LogError("Cannot read alarm tick unit. Stop processing alarms.");
             return;
         }
-        alarmsTick.push_back(tick);
 
+        if( CAL_SCH_TIME_UNIT_SPECIFIC==tickUnit ) {
+            long long int absoluteDate = calendar_svc_value_get_lli(
+                    alarmValue,
+                    CAL_VALUE_LLI_ALARMS_TIME);
+            if (CAL_ERR_FAIL == absoluteDate) {
+                LogError("Cannot read alarm time. Stop processing alarms.");
+                return;
+            }
+            LogInfo("Load absolute date: "<<absoluteDate);
+            theAlarm->setAbsoluteDate(absoluteDate);
+        } else {
+            tick = calendar_svc_value_get_int(alarmValue, CAL_VALUE_INT_ALARMS_TICK);
+            if (CAL_ERR_FAIL == tick) {
+                LogError("Cannot read alarm tick. Stop processing alarms.");
+                return;
+            }
+
+            TizenApis::Api::TimeUtil::DurationProperties duration;
+            if( CAL_SCH_TIME_UNIT_MIN==tickUnit ) {
+                duration.unit = TizenApis::Api::TimeUtil::MINUTES_UNIT;
+                duration.length = tick;
+            } else if( CAL_SCH_TIME_UNIT_HOUR==tickUnit ) {
+                duration.unit = TizenApis::Api::TimeUtil::HOURS_UNIT;
+                duration.length = tick;
+            } else if( CAL_SCH_TIME_UNIT_DAY==tickUnit ) {
+                duration.unit = TizenApis::Api::TimeUtil::DAYS_UNIT;
+                duration.length = tick;
+            } else if( CAL_SCH_TIME_UNIT_WEEK==tickUnit) {
+                duration.unit = TizenApis::Api::TimeUtil::DAYS_UNIT;
+                duration.length = tick*7;
+            } else {
+                LogWarning("Wrong tick unit: "<<tickUnit);
+            }
+
+            theAlarm->setDuration(duration);
+        }
+
+        std::vector<EventAlarm::EventAlarmType> methods;
         cal_alert_type_t type = static_cast<cal_alert_type_t>(calendar_svc_value_get_int(alarmValue, CAL_VALUE_INT_ALARMS_TYPE));
         if ( 0 > type) {
             LogError("Cannot read alarm type. Setting the default value.");
         }
         switch (type) {
         case CAL_ALERT_VIBRATION:
-            alarmsType.push_back(CalendarEvent::SILENT_ALARM);
+            methods.push_back(EventAlarm::SILENT_ALARM);
             break;
         case CAL_ALERT_MELODY:
         case CAL_ALERT_INCREASING_MELODY:
         case CAL_ALERT_VIBRATION_THEN_MELODY:
         case CAL_ALERT_VIBMELODY:
         case CAL_ALERT_VIB_INCREASING_MELODY:
-            alarmsType.push_back(CalendarEvent::SOUND_ALARM);
+            methods.push_back(EventAlarm::SOUND_ALARM);
             break;
         case CAL_ALERT_MUTE:
         default:
-            alarmsType.push_back(CalendarEvent::NO_ALARM);
+            methods.push_back(EventAlarm::NO_ALARM);
             break;
         }
+        theAlarm->setMethods(methods);
 
         char* description = calendar_svc_value_get_str(alarmValue, CAL_VALUE_TXT_ALARMS_DESCRIPTION);
         if (NULL == description) {
-            LogError("Cannot read alarm description. Setting NULL.");
-            alarmsDescription.push_back("");
+            LogError("Cannot read alarm description. Setting empty string.");
+            theAlarm->setDescription("");
         } else {
-            alarmsDescription.push_back(description);
+            theAlarm->setDescription(description);
         }
 
-        // Save the vectors.
-        m_abstractEvent->setAlarmsTick(alarmsTick);
-        m_abstractEvent->setAlarmsType(alarmsType);
-        m_abstractEvent->setAlarmsDescription(alarmsDescription);
+        // Save the alarm.
+        m_abstractEvent->getAlarms()->push_back(theAlarm);
     }
-    LogInfo("Number of alarms: "<<m_abstractEvent->getAlarmsTick().size());
+    LogInfo("Number of alarms: "<<m_abstractEvent->getAlarms()->size());
 }
 
 void EventWrapper::setStatusFromPlatformEvent()
@@ -1858,6 +1931,7 @@ void EventWrapper::setAttendeesFromPlatformEvent()
 
         // load addressBookId
         int attendeeAddressBookId = calendar_svc_value_get_int(attendee, CAL_VALUE_INT_ATTENDEE_DETAIL_CT_INDEX);
+        LogInfo("attendeeAddressBookId: "<<attendeeAddressBookId);
         if ( 0>attendeeAddressBookId) {
             LogError("Cannot read attendee address book id. Setting an empty string.");
             attendeeAddressBookId = -1;
index efca8a7..ec83286 100755 (executable)
@@ -22,6 +22,7 @@
 #include <calendar-svc-provider.h>
 #include <dpl/shared_ptr.h>
 #include <API/Calendar/CalendarEvent.h>
+#include <API/Calendar/EventAlarm.h>
 #include <API/Calendar/EventAttendee.h>
 #include <API/Calendar/EventRecurrenceRule.h>
 
index 323c7b3..cf8af8d 100755 (executable)
@@ -73,7 +73,6 @@ CallHistory::~CallHistory()
                        contacts_svc_unsubscribe_change(CTS_SUBSCRIBE_PLOG_CHANGE, addedListenerCB);
                        contacts_svc_unsubscribe_change(CTS_SUBSCRIBE_MISSED_CALL_CHANGE, changedListenerCB);
                        it = CallHistory::m_watchers.erase(it);
-                       ++it;
                }
                LogDebug("CallHistory Watcher is removed. (" << CallHistory::m_watchers.size() << ")");
        }
index 6a7d2cf..e8b16b4 100755 (executable)
@@ -2746,9 +2746,9 @@ API query_error fetch_next_row(ADVANCED_HANDLE handle)
 
                                if(q_handle->next_count != 0)
                                {
-                                       ADVANCED_CATCH_SET_ERROR(((q_handle->category_pos + q_handle->next_count) < q_handle->category_total_count), {}, QUERY_NO_RECORD, ("no record"));
-                                       ADVANCED_CATCH_SET_ERROR((q_handle->category[q_handle->category_pos + q_handle->next_count].sibling != 0), {}, QUERY_NO_RECORD, ("no record"));
-                                       q_handle->category_pos = q_handle->category_pos + q_handle->next_count;
+                                       ADVANCED_CATCH_SET_ERROR(((q_handle->category_pos + 1) < q_handle->category_total_count), {}, QUERY_NO_RECORD, ("no record"));
+                                       ADVANCED_CATCH_SET_ERROR((q_handle->category[q_handle->category_pos + 1].sibling != 0), {}, QUERY_NO_RECORD, ("no record"));
+                                       q_handle->category_pos++;
                                        q_handle->next_count++;
                                        return QUERY_SUCCESS;
                                }else
@@ -2768,6 +2768,8 @@ API query_error fetch_next_row(ADVANCED_HANDLE handle)
                                                        low = j + 1;
                                                else if(q_handle->category[j].contact_id == contact_id)
                                                {
+                                                       while(j > 0 && q_handle->category[j-1].contact_id == contact_id)
+                                                               j--;
                                                        q_handle->category_pos = j;
                                                        q_handle->next_count++;
                                                        return QUERY_SUCCESS;
index 4de99b6..eafb6a6 100644 (file)
@@ -554,7 +554,7 @@ bool Conversation::makeConversationFromMsgId(unsigned int msgId, Api::Messaging:
                        if (nToCnt > 0 && nToCnt < MAX_TO_ADDRESS_CNT )
                        {
                                char strNumber[MAX_ADDRESS_VAL_LEN] = {0,};
-                               msg_get_str_value(addr_list->msg_struct_info[m_lastMessageId], MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, strNumber, MAX_ADDRESS_VAL_LEN);
+                               msg_get_str_value(addr_list->msg_struct_info[nToCnt-1], MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, strNumber, MAX_ADDRESS_VAL_LEN);
 
                                if (strNumber != NULL)
                                {
index 9a3dbdf..655eb8f 100644 (file)
@@ -611,6 +611,7 @@ void Sms::updateTo()
                        else
                        {
                                LogError("wrong phone number format");
+                               ThrowMsg(WrtDeviceApis::Commons::PlatformException, "wrong phone number format");                               
                        }
                }
        }
index e2d4ea8..74a4e0d 100755 (executable)
@@ -22,6 +22,8 @@ set(SRCS
   JSCalendarAttendee.cpp
   JSCalendarRecurrenceRule.cpp
   JSCalendarAlarm.cpp
+  JSStringArray.cpp
+  JSNumberArray.cpp
   CalendarAsyncCallbackManager.cpp
   CalendarListenerManager.cpp
   plugin_initializer.cpp
index 5d1dda5..a98b55f 100755 (executable)
@@ -28,6 +28,9 @@
 #include "JSCalendarAttendee.h"
 #include "JSCalendarRecurrenceRule.h"
 #include "JSCalendarAlarm.h"
+#include "JSStringArray.h"
+#include "JSNumberArray.h"
+
 #include <Tizen/TimeUtil/TimeUtilConverter.h>
 #include <API/TimeUtil/DurationProperties.h>
 #include <Tizen/Tizen/JSSimpleCoordinates.h>
@@ -88,25 +91,73 @@ JSValueRef CalendarConverter::toJSValueRef(const std::vector<ICalendarPtr> &arg)
     return toJSValueRef_(arg, &CalendarConverter::toJSValueRefCalendar, this);
 }
 
-CalendarEvent::EventAlarmType CalendarConverter::toEventAlarmType(std::string alarmMethod)
+JSValueRef CalendarConverter::toJSValueRef(const StringArrayPtr &arg)
+{
+       return JSStringArray::createArray(m_context, arg);
+}
+
+JSValueRef CalendarConverter::toJSValueRef(const NumberArrayPtr &arg)
+{
+       return JSNumberArray::createArray(m_context, arg);
+}
+
+StringArrayPtr CalendarConverter::toStringArray(const JSValueRef &jsValue)
+{
+       if(JSStringArray::isObjectOfClass(m_context, jsValue))
+               return JSStringArray::getStringArray(m_context, jsValue);
+
+       if(!JSIsArrayValue(m_context, jsValue))
+               ThrowMsg(WrtDeviceApis::Commons::ConversionException, "StringArray is not array.");
+
+       StringArrayPtr result = StringArrayPtr(new StringArray());
+       JSObjectRef jsObject = toJSObjectRef(jsValue);
+    for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) {
+        JSValueRef element = JSGetArrayElement(m_context, jsObject, i);
+        result->push_back(toString(element));
+    }
+    return result;
+}
+
+NumberArrayPtr CalendarConverter::toNumberArray(const JSValueRef &jsValue)
+{
+    LogDebug("entered");
+       if(JSNumberArray::isObjectOfClass(m_context, jsValue))
+               return JSNumberArray::getNumberArray(m_context, jsValue);
+
+       if(!JSIsArrayValue(m_context, jsValue))
+               ThrowMsg(WrtDeviceApis::Commons::ConversionException, "NumberArray is not array.");
+
+    TimeUtilConverter timeConverter(m_context);
+
+       NumberArrayPtr result = NumberArrayPtr(new NumberArray());
+       JSObjectRef jsObject = toJSObjectRef(jsValue);
+    for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) {
+        JSValueRef element = JSGetArrayElement(m_context, jsObject, i);
+        result->push_back((long long int) (timeConverter.getTimeInMilliseconds(element)/1000));
+    }
+    LogInfo("First exception: "<<result->at(0));
+    return result;
+}
+
+EventAlarm::EventAlarmType CalendarConverter::toEventAlarmType(std::string alarmMethod)
 const
 {
     if (!alarmMethod.compare(TIZEN_CALENDAR_PROPERTY_DISPLAY_ALARM))
-        return CalendarEvent::SILENT_ALARM;
+        return EventAlarm::SILENT_ALARM;
     else if (!alarmMethod.compare(TIZEN_CALENDAR_PROPERTY_SOUND_ALARM))
-        return CalendarEvent::SOUND_ALARM;
+        return EventAlarm::SOUND_ALARM;
     else
         ThrowMsg(ConversionException, "Invalid alarm type.");
 
-    return CalendarEvent::UNDEFINED_ALARM_TYPE;
+    return EventAlarm::UNDEFINED_ALARM_TYPE;
 }
 
-std::string CalendarConverter::toTizenValue(CalendarEvent::EventAlarmType abstractValue) const
+std::string CalendarConverter::toTizenValue(EventAlarm::EventAlarmType abstractValue) const
 {
     switch (abstractValue) {
-    case CalendarEvent::SILENT_ALARM:
+    case EventAlarm::SILENT_ALARM:
         return TIZEN_CALENDAR_PROPERTY_DISPLAY_ALARM;
-    case CalendarEvent::SOUND_ALARM:
+    case EventAlarm::SOUND_ALARM:
         return TIZEN_CALENDAR_PROPERTY_SOUND_ALARM;
     default:
         break;
@@ -250,7 +301,7 @@ EventRecurrenceRulePtr CalendarConverter::toEventRecurrenceRule(JSValueRef rrule
         result->setDaysOfTheMonth(toVectorOfInts(daysOfTheMonthData));
     }*/
     if (!JSValueIsUndefined(m_context, daysOfTheWeekData)) {
-        result->setDaysOfTheWeek(toVectorOfStrings(daysOfTheWeekData));
+        result->setDaysOfTheWeek(toStringArray(daysOfTheWeekData));
     }
     /*if (!JSValueIsUndefined(m_context, daysOfTheYearData)) {
         result->setDaysOfTheYear(toVectorOfInts(daysOfTheYearData));
@@ -263,7 +314,7 @@ EventRecurrenceRulePtr CalendarConverter::toEventRecurrenceRule(JSValueRef rrule
         //result->setSetPosition(toBool(setPositionData));
     }
     if (!JSValueIsUndefined(m_context, exceptionsData)) {
-        result->setExceptions(toVectorOfTimeFromTZDate(exceptionsData));
+        result->setExceptions(toNumberArray(exceptionsData));
     }
 
     return result;
@@ -478,10 +529,10 @@ JSValueRef CalendarConverter::toFunction(const JSValueRef& arg)
     ThrowMsg(ConversionException, "Not a function.");
 }
 
-CategoryListPtr CalendarConverter::toCategories(JSValueRef categories)
+StringArrayPtr CalendarConverter::toCategories(JSValueRef categories)
 {
     LogDebug("entered");
-    CategoryListPtr result(new CategoryList());
+    StringArrayPtr result(new StringArray());
     *result = toVectorOfStrings(categories);
     return result;
 }
@@ -610,7 +661,7 @@ EventAlarmPtr CalendarConverter::toEventAlarm(JSValueRef alarm)
     }
     if (!JSValueIsUndefined(m_context, methodData)) {
         std::string method = toString(methodData);
-        std::vector<CalendarEvent::EventAlarmType> convertedMethods;
+        std::vector<EventAlarm::EventAlarmType> convertedMethods;
         convertedMethods.push_back(toEventAlarmType(method));
         result->setMethods(convertedMethods);
     }
@@ -708,20 +759,24 @@ CalendarEventPtr CalendarConverter::toEvent(const JSValueRef event)
     if (!JSValueIsUndefined(m_context, descriptionData)) {
         result->setDescription(toString(descriptionData));
     }
+
     if (!JSValueIsUndefined(m_context, summaryData)) {
         result->setSubject(toString(summaryData));
     }
+    
     //It's important to set startTime before duration to set end date
     if (!JSValueIsUndefined(m_context, startTimeData)) {
         result->setStartTime((long long int) (timeUtilConverter.getTimeInMilliseconds(startTimeData)/1000));
         result->setTimeZone(timeUtilConverter.getPropertiesInTZDate(startTimeData).timezone);
         LogInfo("start time converted from TZDate: "<<result->getStartTime()<<", time zone: "<<result->getTimeZone());
     } else {
+    
         //set default value, current local time.
         if(m_calendarType == CalendarEvent::EVENT_TYPE) {
             //result->setStartTime(std::time(NULL));
         }
     }
+    
     if (!JSValueIsUndefined(m_context, durationData)) {
         long length = timeUtilConverter.getDurationLength(durationData);
         int unit = timeUtilConverter.getDurationUnit(durationData);
@@ -745,10 +800,11 @@ CalendarEventPtr CalendarConverter::toEvent(const JSValueRef event)
         result->setLocation(toString(locationData));
     }
     if (!JSValueIsUndefined(m_context, categoriesData)) {
-        CategoryListPtr categories(new CategoryList());
+        StringArrayPtr categories(new StringArray());
         *categories = toVectorOfStrings(categoriesData);
         result->setCategories(categories);
     }
+    
     if (!JSValueIsUndefined(m_context, statusData)) {
         result->setStatus(toEventStatus(toString(statusData)));
     } else {
@@ -756,46 +812,7 @@ CalendarEventPtr CalendarConverter::toEvent(const JSValueRef event)
     }
     if (!JSValueIsUndefined(m_context, alarmsData)) {
         EventAlarmListPtr alarms = toVectorOfEventAlarmsFromReference(alarmsData);
-        std::vector<CalendarEvent::EventAlarmType> alarmsType;
-        std::vector<long> alarmsTick;
-        std::vector<std::string> alarmsDescription;
-
-        for( unsigned int i=0; i<alarms->size(); i++) {
-            EventAlarmPtr theAlarm = alarms->at(i);
-            alarmsType.push_back(theAlarm->getMethods().at(0));
-            alarmsDescription.push_back(theAlarm->getDescription());
-
-            if( 0 < theAlarm->getAbsoluteDate() ) {
-                alarmsTick.push_back(theAlarm->getAbsoluteDate()/60); // minutes only in platform.
-            } else {
-                long tick;
-                long length = theAlarm->getDuration().length;
-                switch(theAlarm->getDuration().unit) {
-                case TizenApis::Api::TimeUtil::MSECS_UNIT:
-                    tick = length/(1000*60);
-                    break;
-                case TizenApis::Api::TimeUtil::SECONDS_UNIT:
-                    tick = length/60;
-                    break;
-                case TizenApis::Api::TimeUtil::MINUTES_UNIT:
-                    tick = length;
-                    break;
-                case TizenApis::Api::TimeUtil::HOURS_UNIT:
-                    tick = length*60;
-                    break;
-                case TizenApis::Api::TimeUtil::DAYS_UNIT:
-                    tick = length*60*24;
-                    break;
-                default:
-                    ThrowMsg(ConversionException, "Wrong alarm unit type.");
-                }
-
-                alarmsTick.push_back(tick);
-            }
-        }
-        result->setAlarmsType(alarmsType);
-        result->setAlarmsTick(alarmsTick);
-        result->setAlarmsDescription(alarmsDescription);
+        result->setAlarms(alarms);
     }
     if (!JSValueIsUndefined(m_context, isAllDayData)) {
         result->setIsAllDay(toBool(isAllDayData));
@@ -826,17 +843,27 @@ CalendarEventPtr CalendarConverter::toEvent(const JSValueRef event)
         result->setPriority(toTaskPriority(toString(priorityData)));
     }
     if (!JSValueIsUndefined(m_context, endDateData)) {
+        if( result->getTimeZone().empty() ) {
+            result->setTimeZone(timeUtilConverter.getPropertiesInTZDate(endDateData).timezone);
+        }
         result->setEndTime((long long int) (timeUtilConverter.getTimeInMilliseconds(endDateData)/1000));
     }
     if (!JSValueIsUndefined(m_context, dueDateData)) {
+        if( result->getTimeZone().empty() ) {
+            result->setTimeZone(timeUtilConverter.getPropertiesInTZDate(dueDateData).timezone);
+        }
         result->setEndTime((long long int) (timeUtilConverter.getTimeInMilliseconds(dueDateData)/1000));
     }
     if (!JSValueIsUndefined(m_context, completedDateData)) {
+        if( result->getTimeZone().empty() ) {
+            result->setTimeZone(timeUtilConverter.getPropertiesInTZDate(completedDateData).timezone);
+        }
         result->setCompletedDate((long long int) (timeUtilConverter.getTimeInMilliseconds(completedDateData)/1000));
     }
     if (!JSValueIsUndefined(m_context, progressData)) {
         result->setProgress(toInt(progressData));
     }
+    LogDebug("timezone: "<<result->getTimeZone());
 
     return result;
 }
index 50584a3..236984f 100755 (executable)
@@ -41,12 +41,12 @@ class CalendarConverter : public WrtDeviceApis::CommonsJavaScript::Converter
     TizenApis::Api::Calendar::CalendarEventPtr toEvent(const JSValueRef event);
     TizenApis::Api::Calendar::CalendarEventListPtr toVectorOfEvents(JSValueRef events);
     TizenApis::Api::Calendar::CalendarEventListPtr toVectorOfEventsFromProperty(JSValueRef events);
-    TizenApis::Api::Calendar::CategoryListPtr toCategories(JSValueRef categories);
+    TizenApis::Api::Calendar::StringArrayPtr toCategories(JSValueRef categories);
     TizenApis::Api::Calendar::EventAttendeePtr toAttendee(JSValueRef attendee);
     TizenApis::Api::Calendar::EventAttendeeListPtr toVectorOfAttendeesFromDictionary(JSValueRef attendees);
     TizenApis::Api::Calendar::EventAttendeeListPtr toVectorOfAttendeesFromReference(JSValueRef attendees);
 
-    TizenApis::Api::Calendar::CalendarEvent::EventAlarmType toEventAlarmType(std::string tizenValue) const;
+    TizenApis::Api::Calendar::EventAlarm::EventAlarmType toEventAlarmType(std::string tizenValue) const;
     TizenApis::Api::Calendar::CalendarEvent::EventStatus toEventStatus(std::string tizenValue) const;
     TizenApis::Api::Calendar::EventRecurrenceRule::EventRecurrence toRecurrenceFrequency(std::string tizenValue) const;
     TizenApis::Api::Calendar::EventRecurrenceRulePtr toEventRecurrenceRule(JSValueRef rrule);
@@ -57,7 +57,7 @@ class CalendarConverter : public WrtDeviceApis::CommonsJavaScript::Converter
     TizenApis::Api::Calendar::EventAttendee::EventAttendeeStatus toEventAttendeeStatus(std::string tizenValue) const;
     TizenApis::Api::Calendar::EventAttendee::EventAttendeeType toEventAttendeeType(std::string tizenValue) const;
 
-    std::string toTizenValue(TizenApis::Api::Calendar::CalendarEvent::EventAlarmType abstractValue) const;
+    std::string toTizenValue(TizenApis::Api::Calendar::EventAlarm::EventAlarmType abstractValue) const;
     std::string toTizenValue(TizenApis::Api::Calendar::CalendarEvent::EventStatus abstractValue) const;
     std::string toTizenValue(TizenApis::Api::Calendar::EventRecurrenceRule::EventRecurrence abstractValue) const;
     std::string toTizenValue(TizenApis::Api::Calendar::CalendarEvent::EventVisibility abstractValue) const;
@@ -73,6 +73,10 @@ class CalendarConverter : public WrtDeviceApis::CommonsJavaScript::Converter
     JSValueRef toJSValueRefTaskArray(const TizenApis::Api::Calendar::CalendarEventListPtr &arg);
     JSValueRef toJSValueRefCalendar(const TizenApis::Api::Calendar::ICalendarPtr& arg);
     JSValueRef toJSValueRef(const std::vector<TizenApis::Api::Calendar::ICalendarPtr> &arg);
+    JSValueRef toJSValueRef(const TizenApis::Api::Calendar::StringArrayPtr &arg);
+    JSValueRef toJSValueRef(const TizenApis::Api::Calendar::NumberArrayPtr &arg);
+    TizenApis::Api::Calendar::StringArrayPtr toStringArray(const JSValueRef &jsValue);
+    TizenApis::Api::Calendar::NumberArrayPtr toNumberArray(const JSValueRef &jsValue);
 
     TizenApis::Api::Calendar::EventAlarmPtr toEventAlarm(JSValueRef alarm);
     TizenApis::Api::Calendar::EventAlarmListPtr toVectorOfEventAlarmsFromDictionary(JSValueRef alarms);
index 7b638fa..2413666 100755 (executable)
@@ -233,8 +233,10 @@ void CalendarResponseDispatcher::OnAnswerReceived(const IEventExpandEventRecurre
             return;
         } else {
             JSValueRef errorObject;
-            if (event->getExceptionCode() ==
-                ExceptionCodes::NotFoundException) {
+            if (event->getExceptionCode()==ExceptionCodes::InvalidArgumentException) {
+                errorObject = TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(
+                        cbm->getContext(), TizenApis::Commons::JSTizenException::INVALID_VALUES_ERROR);
+            } else if (event->getExceptionCode()==ExceptionCodes::NotFoundException) {
                 errorObject = TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(
                         cbm->getContext(), TizenApis::Commons::JSTizenException::NOT_FOUND_ERROR);
             } else {
index 6e81d93..6861edb 100755 (executable)
@@ -347,6 +347,8 @@ JSValueRef JSCalendar::update(JSContextRef context,
             ThrowMsg(ConversionException, "Wrong first parameter type.");
         }
 
+        CalendarConverter converter(context);
+
         JSObjectRef arg = JSValueToObject(context, arguments[0], exception);
         CalendarEventPtr item = JSCalendarEvent::getPrivateObject(arg);
         if (!item) {
@@ -354,7 +356,6 @@ JSValueRef JSCalendar::update(JSContextRef context,
         }
 
         bool updateAllInstances = true; // Set the default value.
-        CalendarConverter converter(context);
         if (argumentCount>=2) {
             updateAllInstances = converter.toBool(arguments[1]);
         }
index 897506c..250f254 100755 (executable)
@@ -148,7 +148,7 @@ JSObjectRef JSCalendarAlarm::constructor(JSContextRef context,
 
             if (argumentCount>=2) {
                 std::string method = converter.toString(arguments[1]);
-                std::vector<CalendarEvent::EventAlarmType> convertedMethods;
+                std::vector<EventAlarm::EventAlarmType> convertedMethods;
                 convertedMethods.push_back(converter.toEventAlarmType(method));
                 alarm->setMethods(convertedMethods);
             }
@@ -161,7 +161,7 @@ JSObjectRef JSCalendarAlarm::constructor(JSContextRef context,
 
             if (argumentCount>=2) {
                 std::string method = converter.toString(arguments[1]);
-                std::vector<CalendarEvent::EventAlarmType> convertedMethods;
+                std::vector<EventAlarm::EventAlarmType> convertedMethods;
                 convertedMethods.push_back(converter.toEventAlarmType(method));
                 alarm->setMethods(convertedMethods);
             }
@@ -307,7 +307,7 @@ bool JSCalendarAlarm::setProperty(JSContextRef context,
             return true;
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ALARM_METHOD)) {
             std::string method = converter.toString(value);
-            std::vector<CalendarEvent::EventAlarmType> convertedMethods;
+            std::vector<EventAlarm::EventAlarmType> convertedMethods;
             convertedMethods.push_back(converter.toEventAlarmType(method));
             alarm->setMethods(convertedMethods);
             return true;
index 2c8ad19..27e8727 100755 (executable)
@@ -381,7 +381,11 @@ JSValueRef JSCalendarEvent::getPropertyId(JSContextRef context,
                        ss<<event->getParentId();
                        eventId->setUId(ss.str());
                } else {
-               eventId->setUId(event->getUId());
+                   if (UNDEFINED_ITEM_ID==event->getId()) {
+                return JSValueMakeNull(context);
+                   } else {
+               eventId->setUId(event->getUId());
+                   }
                }
         std::stringstream ss;
         std::time_t rid = event->getRecurrenceId();
index 0121740..68ef14b 100755 (executable)
@@ -461,7 +461,7 @@ JSValueRef JSCalendarItemProperties::getPropertyStartTime(JSContextRef context,
 
         LogInfo("start time before converted to TZDate: "<<event->getStartTime()<<", time zone: "<<event->getTimeZone());
         if (UNDEFINED_TIME==event->getStartTime()) {
-            return JSValueMakeNull(context);
+            return JSValueMakeUndefined(context);
         } else {
             return timeConverter.toJSValueRefTZDate((double)(event->getStartTime()*1000.0), event->getTimeZone());
         }
@@ -561,11 +561,11 @@ JSValueRef JSCalendarItemProperties::getPropertyCategories(JSContextRef context,
     LogDebug("entered");
     Try
     {
-        Converter converter(context);
+        CalendarConverter converter(context);
         CalendarEventPtr event = getPrivateObject(object);
-        CategoryListPtr categories = event->getCategories();
+        StringArrayPtr categories = event->getCategories();
         if (categories) {
-            return converter.toJSValueRef(*categories);
+            return converter.toJSValueRef(categories);
         }
     }
     Catch(Exception)
@@ -586,7 +586,7 @@ bool JSCalendarItemProperties::setPropertyCategories(JSContextRef context,
     {
         CalendarEventPtr event = getPrivateObject(object);
         CalendarConverter converter(context);
-        event->setCategories(converter.toCategories(value));
+               event->setCategories(converter.toStringArray(value));
         return true;
     }
     Catch(Exception)
@@ -658,19 +658,8 @@ JSValueRef JSCalendarItemProperties::getPropertyAlarms(JSContextRef context,
         if (NULL == jsResult) {
             ThrowMsg(NullPointerException, "Can not create array object.");
         }
-        for( unsigned int i=0; i<event->getAlarmsTick().size(); i++) {
-            EventAlarmPtr alarm(new EventAlarm());
-            TizenApis::Api::TimeUtil::DurationProperties duration;
-            duration.unit = TizenApis::Api::TimeUtil::MINUTES_UNIT;
-            duration.length = event->getAlarmsTick().at(i);
-            alarm->setDuration(duration); // Default unit is minute.
-            std::vector<CalendarEvent::EventAlarmType> methodVector;
-            methodVector.push_back(event->getAlarmsType().at(i)); // Only one alarm type is saved.
-            alarm->setMethods(methodVector);
-            alarm->setTimeZone(event->getTimeZone());
-            alarm->setDescription(event->getAlarmsDescription().at(i));
-
-            if (!JSSetArrayElement(context, jsResult, i, JSCalendarAlarm::createJSCalendarAlarm(context, alarm))) {
+        for( unsigned int i=0; i<event->getAlarms()->size(); i++) {
+            if (!JSSetArrayElement(context, jsResult, i, JSCalendarAlarm::createJSCalendarAlarm(context, event->getAlarms()->at(i)))) {
                ThrowMsg(UnknownException, "Can not insert value into array.");
             }
         }
@@ -697,46 +686,8 @@ bool JSCalendarItemProperties::setPropertyAlarms(JSContextRef context,
         CalendarConverter converter(context);
 
         EventAlarmListPtr alarms = converter.toVectorOfEventAlarmsFromReference(value);
-        std::vector<CalendarEvent::EventAlarmType> alarmsType;
-        std::vector<long> alarmsTick;
-        std::vector<std::string> alarmsDescription;
-
-        // Set the multiple alarms.
-        for( unsigned int i=0; i<alarms->size(); i++) {
-            EventAlarmPtr theAlarm = alarms->at(i);
-            alarmsType.push_back(theAlarm->getMethods().at(0));
-            alarmsDescription.push_back(theAlarm->getDescription());
-            if( 0 < theAlarm->getAbsoluteDate() ) {
-                alarmsTick.push_back(theAlarm->getAbsoluteDate()/60);
-            } else {
-                long tick;
-                long length = theAlarm->getDuration().length;
-                switch(theAlarm->getDuration().unit) {
-                case TizenApis::Api::TimeUtil::MSECS_UNIT:
-                    tick = length/(1000*60);
-                    break;
-                case TizenApis::Api::TimeUtil::SECONDS_UNIT:
-                    tick = length/60;
-                    break;
-                case TizenApis::Api::TimeUtil::MINUTES_UNIT:
-                    tick = length;
-                    break;
-                case TizenApis::Api::TimeUtil::HOURS_UNIT:
-                    tick = length*60;
-                    break;
-                case TizenApis::Api::TimeUtil::DAYS_UNIT:
-                    tick = length*60*24;
-                    break;
-                default:
-                    ThrowMsg(ConversionException, "Wrong alarm unit type.");
-                }
 
-                alarmsTick.push_back(tick);
-            }
-        }
-        event->setAlarmsType(alarmsType);
-        event->setAlarmsTick(alarmsTick);
-        event->setAlarmsDescription(alarmsDescription);
+        event->setAlarms(alarms);
         return true;
     }
     Catch(Exception)
@@ -1169,7 +1120,7 @@ JSValueRef JSCalendarItemProperties::getPropertyDueDate(JSContextRef context,
         }
 
         if (UNDEFINED_TIME==task->getEndTime()) {
-            return JSValueMakeNull(context);
+            return JSValueMakeUndefined(context);
         } else {
             TimeUtilConverter timeConverter(context);
             return timeConverter.toJSValueRefTZDate((double)(task->getEndTime()*1000.0), task->getTimeZone());
@@ -1241,7 +1192,7 @@ JSValueRef JSCalendarItemProperties::getPropertyCompletedDate(JSContextRef conte
         }
 
         if (UNDEFINED_TIME==task->getCompletedDate()) {
-            return JSValueMakeNull(context);
+            return JSValueMakeUndefined(context);
         } else {
             TimeUtilConverter timeConverter(context);
             return timeConverter.toJSValueRefTZDate((double)(task->getCompletedDate()*1000.0), task->getTimeZone());
@@ -1413,7 +1364,7 @@ JSValueRef JSCalendarItemProperties::getPropertyEndDate(JSContextRef context,
         }
 
         if (UNDEFINED_TIME==event->getEndTime()) {
-            return JSValueMakeNull(context);
+            return JSValueMakeUndefined(context);
         } else {
             TimeUtilConverter timeConverter(context);
             return timeConverter.toJSValueRefTZDate((double)(event->getEndTime()*1000.0), event->getTimeZone());
index 48a9bcd..0652d6f 100755 (executable)
@@ -256,19 +256,7 @@ JSValueRef JSCalendarRecurrenceRule::getProperty(JSContextRef context,
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_SET_POSITION)) {
             return converter.toJSValueRef(rrule->getSetPosition());
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_EXCEPTIONS)) {
-            JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL);
-            if (NULL == jsResult) {
-                ThrowMsg(NullPointerException, "Can not create array object.");
-            }
-
-            for (std::size_t i = 0; i < rrule->getExceptions().size(); ++i) {
-                JSValueRef tmpVal = timeConverter.toJSValueRefTZDate((double)(rrule->getExceptions().at(i)*1000.0), rrule->getTimeZone());
-                if (!JSSetArrayElement(context, jsResult, i, tmpVal)) {
-                    ThrowMsg(UnknownException, "Can not insert value into array.");
-                }
-            }
-
-            return jsResult;
+            return converter.toJSValueRef(rrule->getExceptions());
         }
     }
     Catch(Exception)
@@ -326,8 +314,7 @@ bool JSCalendarRecurrenceRule::setProperty(JSContextRef context,
             rrule->setDaysOfTheMonth(daysOfTheMonth);
             return true;*/
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_DAYS_OF_THE_WEEK)) {
-            std::vector<std::string> daysOfTheWeek = converter.toVectorOfStrings(value);
-            rrule->setDaysOfTheWeek(daysOfTheWeek);
+            rrule->setDaysOfTheWeek(converter.toStringArray(value));
             return true;
         /*} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_DAYS_OF_THE_YEAR)) {
             std::vector<int> daysOfTheYear = converter.toVectorOfInts(value);
@@ -344,8 +331,7 @@ bool JSCalendarRecurrenceRule::setProperty(JSContextRef context,
             rrule->setSetPosition(setPosition);*/
             return true;
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_EXCEPTIONS)) {
-            // Only save the converted time info.
-            rrule->setExceptions(converter.toVectorOfTimeFromTZDate(value));
+            rrule->setExceptions(converter.toNumberArray(value));
             return true;
         }
     }
diff --git a/src/standards/Tizen/Calendar/JSNumberArray.cpp b/src/standards/Tizen/Calendar/JSNumberArray.cpp
new file mode 100755 (executable)
index 0000000..6e4f8a6
--- /dev/null
@@ -0,0 +1,604 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <algorithm>
+#include <dpl/log/log.h>
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/ScopedJSStringRef.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include "CalendarConverter.h"
+#include "JSNumberArray.h"
+#include <Tizen/TimeUtil/TimeUtilConverter.h>
+
+#define FUNCTION_CONCAT "concat"
+#define FUNCTION_JOIN "join"
+#define FUNCTION_POP "pop"
+#define FUNCTION_PUSH "push"
+#define FUNCTION_REVERSE "reverse"
+#define FUNCTION_SHIFT "shift"
+#define FUNCTION_SLICE "slice"
+#define FUNCTION_SORT "sort"
+#define FUNCTION_SPLICE "splice"
+#define FUNCTION_TOSTRING "toString"
+#define FUNCTION_UNSHIFT "unshift"
+#define FUNCTION_VALUEOF "valueOf"
+#define ARRAY "Array"
+#define ATTRIBUTE_LENGTH "length"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Calendar {
+
+using namespace TizenApis::Api::Calendar;
+using namespace TizenApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+JSClassDefinition JSNumberArray::m_classInfo = {
+       0,
+       kJSClassAttributeNone,
+       ARRAY,
+       0,
+       m_property,
+       m_function,
+       initialize,
+       finalize,
+       hasProperty,
+       getProperty,
+       setProperty,
+       NULL, //deleteProperty,
+       getPropertyNames,
+       NULL, //callAsFunction,
+       NULL, //callAsConstructor,
+       NULL, //hasInstance,
+       NULL, //convertToType,
+};
+
+JSStaticValue JSNumberArray::m_property[] = {
+       { ATTRIBUTE_LENGTH, getLength, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
+       { 0, 0, 0, 0 }
+};
+
+JSStaticFunction JSNumberArray::m_function[] = {
+       { FUNCTION_CONCAT, concat, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
+       { FUNCTION_JOIN, join, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
+       { FUNCTION_POP, pop, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
+       { FUNCTION_PUSH, push, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
+       { FUNCTION_REVERSE, reverse, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
+       { FUNCTION_SHIFT, shift, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
+       { FUNCTION_SLICE, slice, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
+       { FUNCTION_SORT, sort, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
+       { FUNCTION_SPLICE, splice, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
+       { FUNCTION_TOSTRING, toString, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
+       { FUNCTION_UNSHIFT, unshift, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
+       { FUNCTION_VALUEOF, valueOf, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
+       { 0, 0, 0 }
+};
+
+JSClassRef JSNumberArray::m_jsClassRef = JSClassCreate(
+               JSNumberArray::getClassInfo());
+
+JSValueRef JSNumberArray::getLength(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       Try
+       {
+               JSNumberArrayPriv* priv =
+                       static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(object));
+               if (!priv) {
+                       Throw(WrtDeviceApis::Commons::NullPointerException);
+               }
+               NumberArrayPtr numbers = priv->getObject();
+               if (numbers) {
+                       WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
+                                       WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
+                       return converter->toJSValueRef(numbers->size());
+               }
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("invalid conversion");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+JSObjectRef JSNumberArray::createArray(JSContextRef context,
+               const NumberArrayPtr &numbers)
+{
+       JSNumberArrayPriv *priv = new JSNumberArrayPriv(context, numbers);
+       return JSObjectMake(context, getClassRef(), priv);
+}
+
+const JSClassDefinition* JSNumberArray::getClassInfo()
+{
+       return &(m_classInfo);
+}
+
+JSClassRef JSNumberArray::getClassRef()
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_classInfo);
+       }
+       return m_jsClassRef;
+}
+
+bool JSNumberArray::isObjectOfClass(JSContextRef context, JSValueRef value)
+{
+       return JSValueIsObjectOfClass(context, value, getClassRef());
+}
+
+NumberArrayPtr JSNumberArray::getNumberArray(JSContextRef context, JSValueRef value)
+{
+       if (!isObjectOfClass(context, value)) {
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+       }
+       JSObjectRef object = JSValueToObject(context, value, NULL);
+       if (!object) {
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+       }
+       JSNumberArrayPriv* priv = static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               Throw(WrtDeviceApis::Commons::NullPointerException);
+       }
+       return priv->getObject();
+}
+
+void JSNumberArray::initialize(JSContextRef context,
+               JSObjectRef object)
+{
+}
+
+void JSNumberArray::finalize(JSObjectRef object)
+{
+       JSNumberArrayPriv* priv =
+               static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(object));
+       delete priv;
+       JSObjectSetPrivate(object, NULL);
+}
+
+bool JSNumberArray::hasProperty(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName)
+{
+       WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
+                       WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
+       Try
+       {
+               size_t index = converter->toSizeT(propertyName);
+               JSNumberArrayPriv* priv =
+                       static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(object));
+               if (!priv) {
+                       Throw(WrtDeviceApis::Commons::NullPointerException);
+               }
+               NumberArrayPtr numbers = priv->getObject();
+               if (index < numbers->size()) {
+                       return true;
+               }
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               //not reporting error is intended
+       }
+       return false;
+}
+
+JSValueRef JSNumberArray::getProperty(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+    LogDebug("entered");
+       WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
+                       WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
+    TimeUtilConverter timeConverter(context);
+
+       Try
+       {
+               size_t index = converter->toSizeT(propertyName);
+               JSNumberArrayPriv* priv =
+                       static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(object));
+               if (!priv) {
+                       Throw(WrtDeviceApis::Commons::NullPointerException);
+               }
+               NumberArrayPtr numbers = priv->getObject();
+               if (index < numbers->size()) {
+                       long long int result = numbers->at(index);
+            LogInfo("index: "<<index<<", result: "<<result);
+            return timeConverter.toJSValueRefTZDate((double)(result*1000.0), "");
+               }
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("invalid property");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSNumberArray::setProperty(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef value,
+               JSValueRef* exception)
+{
+       WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
+                       WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
+    TimeUtilConverter timeConverter(context);
+
+       Try
+       {
+               size_t index = converter->toSizeT(propertyName);
+               long long int number = 0;
+               if (!JSValueIsUndefined(context, value)) {
+                       number = timeConverter.getTimeInMilliseconds(value)/1000;
+               }
+               JSNumberArrayPriv* priv =
+                       static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(object));
+               if (!priv) {
+                       Throw(WrtDeviceApis::Commons::NullPointerException);
+               }
+               NumberArrayPtr numbers = priv->getObject();
+               if (!numbers) {
+                       Throw(WrtDeviceApis::Commons::NullPointerException);
+               }
+               if (numbers->size() <= index) {
+                       numbers->resize(index + 1);
+               }
+               (*numbers)[index] = number;
+               return true;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+       }
+       return false;
+}
+
+void JSNumberArray::getPropertyNames(JSContextRef context,
+               JSObjectRef object,
+               JSPropertyNameAccumulatorRef propertyNames)
+{
+    CalendarConverter converter(context);
+
+       Try
+       {
+               JSNumberArrayPriv* priv =
+                       static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(object));
+               if (!priv) {
+                       Throw(WrtDeviceApis::Commons::NullPointerException);
+               }
+               NumberArrayPtr numbers = priv->getObject();
+
+               int count = numbers->size();
+
+               for(int i=0; i < count; i++)
+               {
+                       ScopedJSStringRef name(converter.toJSStringRef(converter.toString(i)));
+                       JSPropertyNameAccumulatorAddName(propertyNames, name.get());
+               }
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("invalid property");
+       }
+}
+
+JSValueRef JSNumberArray::concat(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       Try
+       {
+               NumberArrayPtr numbers = NumberArrayPtr(new NumberArray());
+               JSNumberArrayPriv *newPrivateObject = new JSNumberArrayPriv(
+                               context,
+                               numbers);
+               JSValueRef result = JSObjectMake(context,
+                                                                                getClassRef(), newPrivateObject);
+
+               //copy current numbers
+               JSNumberArrayPriv* priv =
+                       static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(thisObject));
+               NumberArrayPtr currentNumbers = priv->getObject();
+               for (size_t i = 0; i < currentNumbers->size(); ++i) {
+                       numbers->push_back(currentNumbers->at(i));
+               }
+
+               //copy submitted arrays
+               WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
+                               WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
+               for (size_t i = 0; i < argumentCount; ++i) {
+                       if (!JSIsArrayValue(context, arguments[i])) {
+                               Throw(WrtDeviceApis::Commons::ConversionException);
+                       }
+                       // process array of numbers
+                       JSObjectRef arrayObj = converter->toJSObjectRef(arguments[i]);
+                       unsigned int len = JSGetArrayLength(context, arrayObj);
+                       for (unsigned int e = 0; e < len; ++e) {
+                               JSValueRef att = JSGetArrayElement(context, arrayObj, e);
+                               numbers->push_back(converter->toLong(att));
+                       }
+               }
+               return result;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+}
+
+JSValueRef JSNumberArray::join(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       Try
+       {
+               std::string result;
+               std::string separator(",");
+               WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
+                               WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
+               JSNumberArrayPriv* priv =
+                       static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(thisObject));
+               NumberArrayPtr currentNumbers = priv->getObject();
+               if (argumentCount > 0 && JSValueIsNumber(context, arguments[0])) {
+                       separator = converter->toLong(arguments[0]);
+               }
+               for (size_t i = 0; i < currentNumbers->size(); ++i) {
+                       if (i != 0) {
+                               result += separator;
+                       }
+                       result += currentNumbers->at(i);
+               }
+               return converter->toJSValueRef(result);
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+}
+
+JSValueRef JSNumberArray::pop(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       Try
+       {
+               WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
+                               WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
+               JSNumberArrayPriv* priv =
+                       static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(thisObject));
+               NumberArrayPtr currentNumbers = priv->getObject();
+               if (currentNumbers->size() > 0) {
+                       long long int result = currentNumbers->at(
+                                       currentNumbers->size() - 1);
+                       currentNumbers->pop_back();
+                       return converter->toJSValueRef(result);
+               }
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSNumberArray::push(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       Try
+       {
+               WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
+                               WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
+               JSNumberArrayPriv* priv =
+                       static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(thisObject));
+               NumberArrayPtr currentNumbers = priv->getObject();
+               for (size_t i = 0; i < argumentCount; ++i) {
+                       currentNumbers->push_back(converter->toLong(arguments[i]));
+               }
+               return converter->toJSValueRef(currentNumbers->size());
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+}
+
+JSValueRef JSNumberArray::reverse(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       Try
+       {
+               WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
+                               WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
+               JSNumberArrayPriv* priv =
+                       static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(thisObject));
+               NumberArrayPtr currentNumbers = priv->getObject();
+               std::reverse(currentNumbers->begin(), currentNumbers->end());
+               return thisObject;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSNumberArray::shift(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       Try
+       {
+               WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
+                               WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
+               JSNumberArrayPriv* priv =
+                       static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(thisObject));
+               NumberArrayPtr currentNumbers = priv->getObject();
+               if (currentNumbers->size() > 0) {
+                       long long int result = currentNumbers->at(0);
+                       currentNumbers->erase(currentNumbers->begin());
+                       return converter->toJSValueRef(result);
+               }
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSNumberArray::slice(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       Try
+       {
+               if (argumentCount < 1) {
+                       return JSValueMakeUndefined(context);
+               }
+               WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
+                               WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
+               NumberArrayPtr numbers = NumberArrayPtr(new NumberArray());
+               JSNumberArrayPriv *newPrivateObject = new JSNumberArrayPriv(
+                               context,
+                               numbers);
+               JSValueRef result = JSObjectMake(context,
+                                                                                getClassRef(), newPrivateObject);
+
+               //copy current numbers
+               JSNumberArrayPriv* priv =
+                       static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(thisObject));
+               NumberArrayPtr currentNumbers = priv->getObject();
+               std::size_t first = converter->toSizeT(arguments[0]);
+               std::size_t last = currentNumbers->size() - 1;
+               if (argumentCount > 1) {
+                       last = converter->toSizeT(arguments[1]);
+                       if (last >= currentNumbers->size()) {
+                               last = currentNumbers->size() - 1;
+                       }
+               }
+               if (first < 0) {
+                       first = 0;
+               }
+               for (size_t i = first; i <= last; ++i) {
+                       numbers->push_back(currentNumbers->at(i));
+               }
+
+               return result;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+}
+
+JSValueRef JSNumberArray::sort(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       Try
+       {
+               WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
+                               WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
+               JSNumberArrayPriv* priv =
+                       static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(thisObject));
+               NumberArrayPtr currentNumbers = priv->getObject();
+               std::sort(currentNumbers->begin(), currentNumbers->end());
+               return thisObject;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSNumberArray::splice(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSNumberArray::toString(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       return join(context, function, thisObject, 0, arguments, exception);
+}
+
+JSValueRef JSNumberArray::unshift(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSNumberArray::valueOf(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       return JSValueMakeUndefined(context);
+}
+
+} // Calendar
+} // Tizen1_0
+} // TizenApis
diff --git a/src/standards/Tizen/Calendar/JSNumberArray.h b/src/standards/Tizen/Calendar/JSNumberArray.h
new file mode 100755 (executable)
index 0000000..80452cc
--- /dev/null
@@ -0,0 +1,182 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef _TIZEN_CALENDAR_JS_NUMBER_ARRAY_H_
+#define _TIZEN_CALENDAR_JS_NUMBER_ARRAY_H_
+
+#include <vector>
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Calendar/CalendarEvent.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Calendar {
+
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<TizenApis::Api::Calendar::NumberArrayPtr>::Type JSNumberArrayPriv;
+
+class JSNumberArray
+{
+public:
+
+       static const JSClassDefinition* getClassInfo();
+
+       static JSClassRef getClassRef();
+
+       static JSObjectRef createArray(JSContextRef context,
+                       const TizenApis::Api::Calendar::NumberArrayPtr &Numbers);
+
+       static bool isObjectOfClass(JSContextRef context, JSValueRef value);
+
+       static TizenApis::Api::Calendar::NumberArrayPtr getNumberArray(JSContextRef context, JSValueRef value);
+
+private:
+
+       /**
+        * The callback invoked when an object is first created.
+        */
+       static void initialize(JSContextRef context,
+                       JSObjectRef object);
+
+       /**
+        * The callback invoked when an object is finalized.
+        */
+       static void finalize(JSObjectRef object);
+
+       static JSValueRef getLength(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception);
+
+       static bool hasProperty(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName);
+
+       static JSValueRef getProperty(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception);
+
+       static bool setProperty(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef value,
+                       JSValueRef* exception);
+
+       static void getPropertyNames(JSContextRef context,
+                       JSObjectRef object,
+                       JSPropertyNameAccumulatorRef propertyNames);
+
+       static JSValueRef concat(JSContextRef context,
+                       JSObjectRef function,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+       static JSValueRef join(JSContextRef context,
+                       JSObjectRef function,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+
+       static JSValueRef pop(JSContextRef context,
+                       JSObjectRef function,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+       static JSValueRef push(JSContextRef context,
+                       JSObjectRef function,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+       static JSValueRef reverse(JSContextRef context,
+                       JSObjectRef function,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+       static JSValueRef shift(JSContextRef context,
+                       JSObjectRef function,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+       static JSValueRef slice(JSContextRef context,
+                       JSObjectRef function,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+       static JSValueRef sort(JSContextRef context,
+                       JSObjectRef function,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+       static JSValueRef splice(JSContextRef context,
+                       JSObjectRef function,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+       static JSValueRef toString(JSContextRef context,
+                       JSObjectRef function,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+       static JSValueRef unshift(JSContextRef context,
+                       JSObjectRef function,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+       static JSValueRef valueOf(JSContextRef context,
+                       JSObjectRef function,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+
+       static bool checkValue(const long long int &value);
+
+       static JSClassRef m_jsClassRef;
+       /**
+        * This structure describes a statically declared function property.
+        */
+       static JSStaticFunction m_function[];
+
+       /**
+        * This structure contains properties and callbacks that define a type of object.
+        */
+       static JSClassDefinition m_classInfo;
+
+       /**
+        * This member variable contains the initialization values for the static properties of this class.
+        * The values are given according to the data structure JSPropertySpec
+        */
+       static JSStaticValue m_property[];
+};
+
+} // Calendar
+} // Tizen1_0
+} // TizenApis
+
+#endif // _TIZEN_CALENDAR_JS_NUMBER_ARRAY_H_
diff --git a/src/standards/Tizen/Calendar/JSStringArray.cpp b/src/standards/Tizen/Calendar/JSStringArray.cpp
new file mode 100755 (executable)
index 0000000..fc3add3
--- /dev/null
@@ -0,0 +1,599 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <algorithm>
+#include <dpl/log/log.h>
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/ScopedJSStringRef.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include "CalendarConverter.h"
+#include "JSStringArray.h"
+
+#define FUNCTION_CONCAT "concat"
+#define FUNCTION_JOIN "join"
+#define FUNCTION_POP "pop"
+#define FUNCTION_PUSH "push"
+#define FUNCTION_REVERSE "reverse"
+#define FUNCTION_SHIFT "shift"
+#define FUNCTION_SLICE "slice"
+#define FUNCTION_SORT "sort"
+#define FUNCTION_SPLICE "splice"
+#define FUNCTION_TOSTRING "toString"
+#define FUNCTION_UNSHIFT "unshift"
+#define FUNCTION_VALUEOF "valueOf"
+#define ARRAY "Array"
+#define ATTRIBUTE_LENGTH "length"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Calendar {
+
+using namespace TizenApis::Api::Calendar;
+using namespace TizenApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+JSClassDefinition JSStringArray::m_classInfo = {
+       0,
+       kJSClassAttributeNone,
+       ARRAY,
+       0,
+       m_property,
+       m_function,
+       initialize,
+       finalize,
+       hasProperty,
+       getProperty,
+       setProperty,
+       NULL, //deleteProperty,
+       getPropertyNames,
+       NULL, //callAsFunction,
+       NULL, //callAsConstructor,
+       NULL, //hasInstance,
+       NULL, //convertToType,
+};
+
+JSStaticValue JSStringArray::m_property[] = {
+       { ATTRIBUTE_LENGTH, getLength, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
+       { 0, 0, 0, 0 }
+};
+
+JSStaticFunction JSStringArray::m_function[] = {
+       { FUNCTION_CONCAT, concat, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
+       { FUNCTION_JOIN, join, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
+       { FUNCTION_POP, pop, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
+       { FUNCTION_PUSH, push, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
+       { FUNCTION_REVERSE, reverse, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
+       { FUNCTION_SHIFT, shift, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
+       { FUNCTION_SLICE, slice, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
+       { FUNCTION_SORT, sort, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
+       { FUNCTION_SPLICE, splice, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
+       { FUNCTION_TOSTRING, toString, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
+       { FUNCTION_UNSHIFT, unshift, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
+       { FUNCTION_VALUEOF, valueOf, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
+       { 0, 0, 0 }
+};
+
+JSClassRef JSStringArray::m_jsClassRef = JSClassCreate(
+               JSStringArray::getClassInfo());
+
+JSValueRef JSStringArray::getLength(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       Try
+       {
+               JSStringArrayPriv* priv =
+                       static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(object));
+               if (!priv) {
+                       Throw(WrtDeviceApis::Commons::NullPointerException);
+               }
+               StringArrayPtr strs = priv->getObject();
+               if (strs) {
+                       WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
+                                       WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
+                       return converter->toJSValueRef(strs->size());
+               }
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("invalid conversion");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+JSObjectRef JSStringArray::createArray(JSContextRef context,
+               const StringArrayPtr &strs)
+{
+       JSStringArrayPriv *priv = new JSStringArrayPriv(context, strs);
+       return JSObjectMake(context, getClassRef(), priv);
+}
+
+const JSClassDefinition* JSStringArray::getClassInfo()
+{
+       return &(m_classInfo);
+}
+
+JSClassRef JSStringArray::getClassRef()
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_classInfo);
+       }
+       return m_jsClassRef;
+}
+
+bool JSStringArray::isObjectOfClass(JSContextRef context, JSValueRef value)
+{
+       return JSValueIsObjectOfClass(context, value, getClassRef());
+}
+
+StringArrayPtr JSStringArray::getStringArray(JSContextRef context, JSValueRef value)
+{
+       if (!isObjectOfClass(context, value)) {
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+       }
+       JSObjectRef object = JSValueToObject(context, value, NULL);
+       if (!object) {
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+       }
+       JSStringArrayPriv* priv = static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               Throw(WrtDeviceApis::Commons::NullPointerException);
+       }
+       return priv->getObject();
+}
+
+void JSStringArray::initialize(JSContextRef context,
+               JSObjectRef object)
+{
+}
+
+void JSStringArray::finalize(JSObjectRef object)
+{
+       JSStringArrayPriv* priv =
+               static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(object));
+       delete priv;
+       JSObjectSetPrivate(object, NULL);
+}
+
+bool JSStringArray::hasProperty(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName)
+{
+       WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
+                       WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
+       Try
+       {
+               size_t index = converter->toSizeT(propertyName);
+               JSStringArrayPriv* priv =
+                       static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(object));
+               if (!priv) {
+                       Throw(WrtDeviceApis::Commons::NullPointerException);
+               }
+               StringArrayPtr strs = priv->getObject();
+               if (index < strs->size()) {
+                       return true;
+               }
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               //not reporting error is intended
+       }
+       return false;
+}
+
+JSValueRef JSStringArray::getProperty(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
+                       WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
+       Try
+       {
+               size_t index = converter->toSizeT(propertyName);
+               JSStringArrayPriv* priv =
+                       static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(object));
+               if (!priv) {
+                       Throw(WrtDeviceApis::Commons::NullPointerException);
+               }
+               StringArrayPtr strs = priv->getObject();
+               if (index < strs->size()) {
+                       std::string result = strs->at(index);
+                       if (!result.empty()) {
+                               return converter->toJSValueRef(result);
+                       }
+               }
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("invalid property");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSStringArray::setProperty(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef value,
+               JSValueRef* exception)
+{
+       WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
+                       WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
+       Try
+       {
+               size_t index = converter->toSizeT(propertyName);
+               std::string str;
+               if (!JSValueIsUndefined(context, value)) {
+                       str = converter->toString(value);
+               }
+               JSStringArrayPriv* priv =
+                       static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(object));
+               if (!priv) {
+                       Throw(WrtDeviceApis::Commons::NullPointerException);
+               }
+               StringArrayPtr strs = priv->getObject();
+               if (!strs) {
+                       Throw(WrtDeviceApis::Commons::NullPointerException);
+               }
+               if (strs->size() <= index) {
+                       strs->resize(index + 1);
+               }
+               (*strs)[index] = str;
+               return true;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+       }
+       return false;
+}
+
+void JSStringArray::getPropertyNames(JSContextRef context,
+               JSObjectRef object,
+               JSPropertyNameAccumulatorRef propertyNames)
+{
+    CalendarConverter converter(context);
+
+       Try
+       {
+               JSStringArrayPriv* priv =
+                       static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(object));
+               if (!priv) {
+                       Throw(WrtDeviceApis::Commons::NullPointerException);
+               }
+               StringArrayPtr strings = priv->getObject();
+
+               int count = strings->size();
+
+               for(int i=0; i < count; i++)
+               {
+                       ScopedJSStringRef name(converter.toJSStringRef(converter.toString(i)));
+                       JSPropertyNameAccumulatorAddName(propertyNames, name.get());
+               }
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("invalid property");
+       }
+}
+
+JSValueRef JSStringArray::concat(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       Try
+       {
+               StringArrayPtr strs = StringArrayPtr(new StringArray());
+               JSStringArrayPriv *newPrivateObject = new JSStringArrayPriv(
+                               context,
+                               strs);
+               JSValueRef result = JSObjectMake(context,
+                                                                                getClassRef(), newPrivateObject);
+
+               //copy current strs
+               JSStringArrayPriv* priv =
+                       static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(thisObject));
+               StringArrayPtr currentStrings = priv->getObject();
+               for (size_t i = 0; i < currentStrings->size(); ++i) {
+                       strs->push_back(currentStrings->at(i));
+               }
+
+               //copy submitted arrays
+               WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
+                               WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
+               for (size_t i = 0; i < argumentCount; ++i) {
+                       if (!JSIsArrayValue(context, arguments[i])) {
+                               Throw(WrtDeviceApis::Commons::ConversionException);
+                       }
+                       // process array of strings
+                       JSObjectRef arrayObj = converter->toJSObjectRef(arguments[i]);
+                       unsigned int len = JSGetArrayLength(context, arrayObj);
+                       for (unsigned int e = 0; e < len; ++e) {
+                               JSValueRef att = JSGetArrayElement(context, arrayObj, e);
+                               strs->push_back(converter->toString(att));
+                       }
+               }
+               return result;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+}
+
+JSValueRef JSStringArray::join(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       Try
+       {
+               std::string result;
+               std::string separator(",");
+               WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
+                               WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
+               JSStringArrayPriv* priv =
+                       static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(thisObject));
+               StringArrayPtr currentStrings = priv->getObject();
+               if (argumentCount > 0 && JSValueIsString(context, arguments[0])) {
+                       separator = converter->toString(arguments[0]);
+               }
+               for (size_t i = 0; i < currentStrings->size(); ++i) {
+                       if (i != 0) {
+                               result += separator;
+                       }
+                       result += currentStrings->at(i);
+               }
+               return converter->toJSValueRef(result);
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+}
+
+JSValueRef JSStringArray::pop(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       Try
+       {
+               WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
+                               WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
+               JSStringArrayPriv* priv =
+                       static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(thisObject));
+               StringArrayPtr currentStrings = priv->getObject();
+               if (currentStrings->size() > 0) {
+                       std::string result = currentStrings->at(
+                                       currentStrings->size() - 1);
+                       currentStrings->pop_back();
+                       return converter->toJSValueRef(result);
+               }
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSStringArray::push(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       Try
+       {
+               WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
+                               WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
+               JSStringArrayPriv* priv =
+                       static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(thisObject));
+               StringArrayPtr currentStrings = priv->getObject();
+               for (size_t i = 0; i < argumentCount; ++i) {
+                       currentStrings->push_back(converter->toString(arguments[i]));
+               }
+               return converter->toJSValueRef(currentStrings->size());
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+}
+
+JSValueRef JSStringArray::reverse(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       Try
+       {
+               WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
+                               WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
+               JSStringArrayPriv* priv =
+                       static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(thisObject));
+               StringArrayPtr currentStrings = priv->getObject();
+               std::reverse(currentStrings->begin(), currentStrings->end());
+               return thisObject;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSStringArray::shift(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       Try
+       {
+               WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
+                               WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
+               JSStringArrayPriv* priv =
+                       static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(thisObject));
+               StringArrayPtr currentStrings = priv->getObject();
+               if (currentStrings->size() > 0) {
+                       std::string result = currentStrings->at(0);
+                       currentStrings->erase(currentStrings->begin());
+                       return converter->toJSValueRef(result);
+               }
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSStringArray::slice(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       Try
+       {
+               if (argumentCount < 1) {
+                       return JSValueMakeUndefined(context);
+               }
+               WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
+                               WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
+               StringArrayPtr strs = StringArrayPtr(new StringArray());
+               JSStringArrayPriv *newPrivateObject = new JSStringArrayPriv(
+                               context,
+                               strs);
+               JSValueRef result = JSObjectMake(context,
+                                                                                getClassRef(), newPrivateObject);
+
+               //copy current strs
+               JSStringArrayPriv* priv =
+                       static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(thisObject));
+               StringArrayPtr currentStrings = priv->getObject();
+               std::size_t first = converter->toSizeT(arguments[0]);
+               std::size_t last = currentStrings->size() - 1;
+               if (argumentCount > 1) {
+                       last = converter->toSizeT(arguments[1]);
+                       if (last >= currentStrings->size()) {
+                               last = currentStrings->size() - 1;
+                       }
+               }
+               if (first < 0) {
+                       first = 0;
+               }
+               for (size_t i = first; i <= last; ++i) {
+                       strs->push_back(currentStrings->at(i));
+               }
+
+               return result;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+}
+
+JSValueRef JSStringArray::sort(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       Try
+       {
+               WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
+                               WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
+               JSStringArrayPriv* priv =
+                       static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(thisObject));
+               StringArrayPtr currentStrings = priv->getObject();
+               std::sort(currentStrings->begin(), currentStrings->end());
+               return thisObject;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSStringArray::splice(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSStringArray::toString(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       return join(context, function, thisObject, 0, arguments, exception);
+}
+
+JSValueRef JSStringArray::unshift(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSStringArray::valueOf(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       return JSValueMakeUndefined(context);
+}
+
+} // Calendar
+} // Tizen1_0
+} // TizenApis
diff --git a/src/standards/Tizen/Calendar/JSStringArray.h b/src/standards/Tizen/Calendar/JSStringArray.h
new file mode 100755 (executable)
index 0000000..f853450
--- /dev/null
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef _TIZEN_CALENDAR_JS_STRING_ARRAY_H_
+#define _TIZEN_CALENDAR_JS_STRING_ARRAY_H_
+
+#include <vector>
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Calendar/CalendarEvent.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Calendar {
+
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<TizenApis::Api::Calendar::StringArrayPtr>::Type JSStringArrayPriv;
+
+class JSStringArray
+{
+public:
+
+       static const JSClassDefinition* getClassInfo();
+
+       static JSClassRef getClassRef();
+
+       static JSObjectRef createArray(JSContextRef context,
+                       const TizenApis::Api::Calendar::StringArrayPtr &Strings);
+
+       static bool isObjectOfClass(JSContextRef context, JSValueRef value);
+
+       static TizenApis::Api::Calendar::StringArrayPtr getStringArray(JSContextRef context, JSValueRef value);
+
+private:
+
+       /**
+        * The callback invoked when an object is first created.
+        */
+       static void initialize(JSContextRef context,
+                       JSObjectRef object);
+
+       /**
+        * The callback invoked when an object is finalized.
+        */
+       static void finalize(JSObjectRef object);
+
+       static JSValueRef getLength(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception);
+
+       static bool hasProperty(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName);
+
+       static JSValueRef getProperty(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception);
+
+       static bool setProperty(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef value,
+                       JSValueRef* exception);
+
+       static void getPropertyNames(JSContextRef context,
+                       JSObjectRef object,
+                       JSPropertyNameAccumulatorRef propertyNames);
+
+       static JSValueRef concat(JSContextRef context,
+                       JSObjectRef function,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+       static JSValueRef join(JSContextRef context,
+                       JSObjectRef function,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+       static JSValueRef pop(JSContextRef context,
+                       JSObjectRef function,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+       static JSValueRef push(JSContextRef context,
+                       JSObjectRef function,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+       static JSValueRef reverse(JSContextRef context,
+                       JSObjectRef function,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+       static JSValueRef shift(JSContextRef context,
+                       JSObjectRef function,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+       static JSValueRef slice(JSContextRef context,
+                       JSObjectRef function,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+       static JSValueRef sort(JSContextRef context,
+                       JSObjectRef function,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+       static JSValueRef splice(JSContextRef context,
+                       JSObjectRef function,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+       static JSValueRef toString(JSContextRef context,
+                       JSObjectRef function,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+       static JSValueRef unshift(JSContextRef context,
+                       JSObjectRef function,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+       static JSValueRef valueOf(JSContextRef context,
+                       JSObjectRef function,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+
+       static bool checkValue(const std::string &value);
+
+       static JSClassRef m_jsClassRef;
+       /**
+        * This structure describes a statically declared function property.
+        */
+       static JSStaticFunction m_function[];
+
+       /**
+        * This structure contains properties and callbacks that define a type of object.
+        */
+       static JSClassDefinition m_classInfo;
+
+       /**
+        * This member variable contains the initialization values for the static properties of this class.
+        * The values are given according to the data structure JSPropertySpec
+        */
+       static JSStaticValue m_property[];
+};
+
+} // Calendar
+} // Tizen1_0
+} // TizenApis
+
+#endif // _TIZEN_CALENDAR_JS_STRING_ARRAY_H_
\ No newline at end of file
index 3eca5d7..256426a 100755 (executable)
@@ -209,7 +209,7 @@ bool JSCallHistoryEntry::setProperty(JSContextRef context,
                                                callHistoryEntry->setMarkSeen(entryInfo->getEntryId());
                                                entryInfo->setDirection(STR_MISSED);
                                        } else {
-                                               Throw(WrtDeviceApis::Commons::UnsupportedException);
+                                               Throw(WrtDeviceApis::Commons::ConversionException);
                                        }
 
                                        return true;
@@ -220,10 +220,10 @@ bool JSCallHistoryEntry::setProperty(JSContextRef context,
                                Throw(WrtDeviceApis::Commons::Exception);
                        }
                } else {
-                       Throw(WrtDeviceApis::Commons::UnsupportedException);
+                       Throw(WrtDeviceApis::Commons::ConversionException);
                }
-       } catch(const WrtDeviceApis::Commons::UnsupportedException& ex) {
-               JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, "Not supported error");
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
        } catch (const WrtDeviceApis::Commons::Exception& ex) {
                JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
        }
index d04d14b..0a1231f 100755 (executable)
@@ -126,7 +126,7 @@ JSValueRef JSLocationServiceProvider::getProperty(JSContextRef ctx, JSObjectRef
                        JSObjectSetProperty(ctx, metaobject , key , valueRef ,kJSPropertyAttributeReadOnly, NULL );
                        JSStringRelease(key);
                        JSStringRelease(value);
-               }               
+               }
                return metaobject;
        }
        else if(JSStringIsEqualToUTF8CString(propertyName, "attribution")) {
@@ -148,7 +148,7 @@ JSValueRef JSLocationServiceProvider::getProperty(JSContextRef ctx, JSObjectRef
                delete []supportedOptionValues;
                return supportedOptionArray;
        }
-       else if(JSStringIsEqualToUTF8CString(propertyName, "connectivity")) {           
+       else if(JSStringIsEqualToUTF8CString(propertyName, "connectivity")) {
                JSStringRef conn = JSStringCreateWithUTF8CString(priv->getConnectivity().c_str());
                JSValueRef jsv = JSValueMakeString(ctx, conn);
                JSStringRelease(conn);
@@ -195,69 +195,113 @@ JSValueRef JSLocationServiceProvider::setOptions(JSContextRef ctx, JSObjectRef o
                return Commons::JSTizenExceptionFactory::postException(ctx,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The object is not LocationServiceProvider instance");
        }
 
-       JSValueRef convertedArguments[3];
-       JSObjectRef convertedArgumentObjects[3];
-       for( unsigned int i = 0 ; i < 3; i++ ){
-               if( i < argumentCount ){
-                       convertedArguments[i] = arguments[i];
-                       if( JSValueIsObject(ctx, arguments[i]) )
-                               convertedArgumentObjects[i] = JSValueToObject(ctx, arguments[i] , NULL );
-                       else
-                               convertedArgumentObjects[i] = NULL;
-               }else{
-                       convertedArguments[i] = JSValueMakeUndefined(ctx);
-                       convertedArgumentObjects[i] = NULL;
+       JSValueRef convertedArg[3];
+       JSObjectRef convertedArgObjects[3];
+       for( unsigned int i = 0 ; i < 3; i++ )
+       {
+               if(i<argumentCount)
+               {
+                       convertedArg[i] = arguments[i];
+                       convertedArgObjects[i] = JSValueToObject(ctx, arguments[i] , NULL );
+               }
+               else
+               {
+                       convertedArg[i] = JSValueMakeUndefined(ctx);
+                       convertedArgObjects[i] = NULL;
                }
        }
 
+       //Check the first argument
+       if(JSValueIsNull(ctx, convertedArg[0]) || JSValueIsUndefined(ctx, convertedArg[0]) || !JSValueIsObject(ctx, convertedArg[0]))
+       {
+               return Commons::JSTizenExceptionFactory::postException(ctx,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The first argument is invalid (null, undefined or not an object)");
+       }
+
+       JSObjectRef onsuccess;
+       JSObjectRef onfail;
+
        // The second argument is null or undefined or function object
-       if(  !JSValueIsNull(ctx, convertedArguments[1]) &&
-                 !JSValueIsUndefined(ctx, convertedArguments[1]) &&
-                 ( convertedArgumentObjects[1] == NULL || !JSObjectIsFunction(ctx, convertedArgumentObjects[1]) )
-         )
-               return Commons::JSTizenExceptionFactory::postException(ctx,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The first argument must be function or null");
+       bool isFunctionOnSuccess = false;
+       if(JSValueIsNull(ctx, convertedArg[1]) || JSValueIsUndefined(ctx, convertedArg[1]))
+       {
+               isFunctionOnSuccess = false;
+               LOGD("%s - 2rd argument is OK (Either null or undefined) ", __func__);
+       }
+       else if (JSObjectIsFunction(ctx, convertedArgObjects[1]))
+       {
+               isFunctionOnSuccess = true;
+               onsuccess = convertedArgObjects[1];
+               LOGD("%s - 2rd argument is OK (function) ", __func__);
+       }
+       else
+       {
+               return Commons::JSTizenExceptionFactory::postException(ctx,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The second argument must be a function");
+       }
 
        // The third argument is null or undefined or function object
-       if(  !JSValueIsNull(ctx, convertedArguments[2]) &&
-                 !JSValueIsUndefined(ctx, convertedArguments[2]) &&
-                 ( convertedArgumentObjects[2] == NULL || !JSObjectIsFunction(ctx, convertedArgumentObjects[2]))
-          )
-               return Commons::JSTizenExceptionFactory::postException(ctx,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The first argument must be function or null");
-
-       // The first argument is option object
-       JSObjectRef jsOptions = convertedArgumentObjects[0];
-       if( jsOptions == NULL ){
-               return Commons::JSTizenExceptionFactory::postException(ctx, exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The option arguments is not Object");
+       bool isFunctionOnFail = false;
+       if(JSValueIsNull(ctx, convertedArg[2]) || JSValueIsUndefined(ctx, convertedArg[2]))
+       {
+               isFunctionOnFail = false;
+               LOGD("%s - 3rd argument is OK (Either null or undefined) ", __func__);
+       }
+       else if (JSObjectIsFunction(ctx, convertedArgObjects[2]))
+       {
+               isFunctionOnFail = true;
+               onfail = convertedArgObjects[2];
+               LOGD("%s - 3rd argument is OK (function) ", __func__);
+       }
+       else
+       {
+               return Commons::JSTizenExceptionFactory::postException(ctx,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The third argument must be a function");
        }
 
        // Initialize a CallbackData
        CallbackData * userdata = NULL;
+       userdata = new CallbackData();
 
-       JSObjectRef onsuccess = convertedArgumentObjects[1];
-       JSObjectRef onfail = convertedArgumentObjects[2];
-       if( onsuccess != NULL || onfail != NULL ){
-               userdata = new CallbackData();
+       //set the success callback
+       if(isFunctionOnSuccess)
+       {
+               userdata->onSuccess = onsuccess;
+               JSValueProtect(ctx, onsuccess);
+       }
+       else
+       {
                userdata->onSuccess = NULL;
+       }
+
+       //set the error callback
+       if(isFunctionOnFail)
+       {
+               userdata->onFail = onfail;
+               JSValueProtect(ctx, onfail);
+       }
+       else
+       {
                userdata->onFail = NULL;
+       }
 
-               if( onsuccess ){
-                       userdata->onSuccess = onsuccess;
-                       JSValueProtect(ctx, onsuccess);
-               }
-               if( onfail ){
-                       userdata->onFail = onfail;
-                       JSValueProtect(ctx, onfail);
-               }
+       // The first argument is option object
+       JSObjectRef jsOptions = convertedArgObjects[0];
+       if( jsOptions == NULL ){
+               return Commons::JSTizenExceptionFactory::postException(ctx, exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The option arguments is not Object");
        }
 
        // Convert  Object to vector
-       std::vector<std::pair<std::string, std::string>> options = LBSUtil::convertObject(ctx, jsOptions);      
+       std::vector<std::pair<std::string, std::string>> options = LBSUtil::convertObject(ctx, jsOptions);
 
        // Call native setOption function
        int ret = priv->setOption(options , _setOptionCb , userdata, NULL);
+       LOGD("ret : %d ", ret);
 
        // Invalid options values
        if( ret != 0 ){
+               JSObjectRef error = Commons::JSTizenExceptionFactory::makeErrorObject(JSLBS::getGlobalContext(), Commons::JSTizenException::INVALID_VALUES_ERROR , "invalid option value");
+               JSValueRef args[1] = {error};
+               if( userdata->onFail )
+                       JSObjectCallAsFunction(JSLBS::getGlobalContext(), userdata->onFail  , NULL, 1, args, NULL);
+
                //remove callback values
                if( userdata != NULL ){
                        if( userdata->onSuccess )
@@ -266,10 +310,6 @@ JSValueRef JSLocationServiceProvider::setOptions(JSContextRef ctx, JSObjectRef o
                                JSValueUnprotect(ctx, userdata->onFail);
                        delete userdata;
                }
-
-               JSObjectRef error = Commons::JSTizenExceptionFactory::makeErrorObject(JSLBS::getGlobalContext(), Commons::JSTizenException::INVALID_VALUES_ERROR , "invalid option value");
-               JSValueRef args[1] = {error};
-               JSObjectCallAsFunction(JSLBS::getGlobalContext(), onfail  , NULL, 1, args, NULL);
        }
 
        return JSValueMakeUndefined(ctx);